Hello,
I'm tring to made a manual gtk3 application (I would like use full GTK3 power, posibly with glade). My code is
uses
Classes, SysUtils, LazGtk3, LazGio2, glib2;
//Find in /usr/lib/lazarus/default/lcl/interfaces/gtk3 and the binding subdir
...
procedure InitGTK3;
procedure GTKActivate(app:PGApplication;user_data:gpointer);cdecl;
var
//Main window
MainBox:PGtkBox;
button:PGtkButton;
begin
WriteLn('success');
Write('Building GTK+GUI. ');
//MainWindow
MainWindow := TGtkWindow.new(GTK_WINDOW_TOPLEVEL);
MainWindow^.title := Pgchar(SMainTitle);
// MainWindow^.set_default_size( 200, 200);
// MainBox := TGtkBox.new(GTK_ORIENTATION_VERTICAL,3);
button := gtk_button_new_with_label ('Hello World');
gtk_container_add (MainWindow, button);
//gtk_container_add(MainWindow,MainBox);
MainWindow^.show;
end;
begin
if GTKStarted then
Exit;
Write('GTK3 application initialization... ');
GTKStarted := True;
GTKApplication := gtk_application_new('org.gtk.example',0);
if GTKApplication = NULL then
begin
WriteLn('fail (on gtk_application_new)');
halt(1);
end;
g_signal_connect(GTKApplication, 'activate', G_CALLBACK(@GTKActivate), NULL);
WriteLn('done');
Write('GTKActivate raise... ');
GTKApplication^.run(argc,argv);
g_object_unref (GTKApplication);
end;
.
But after the
end; of GTKActivate, the window without widgets is shown and a div by zero occur. This occur only when a window is show :
...
//MainWindow^.show;
end;
Work without errors. Can you help me (I would like use the "one instance" ability)