Recent

Author Topic: GTK3 div by 0  (Read 1245 times)

MiniApp

  • New Member
  • *
  • Posts: 10
GTK3 div by 0
« on: June 10, 2017, 07:35:38 pm »
Hello,

I'm tring to made a manual gtk3 application (I would like use full GTK3 power, posibly with glade). My code is
Code: Pascal  [Select][+][-]
  1. uses
  2.   Classes, SysUtils, LazGtk3, LazGio2, glib2;
  3. //Find in /usr/lib/lazarus/default/lcl/interfaces/gtk3 and the binding subdir
  4. ...
  5. procedure InitGTK3;
  6.   procedure GTKActivate(app:PGApplication;user_data:gpointer);cdecl;
  7.   var
  8.     //Main window
  9.     MainBox:PGtkBox;
  10.     button:PGtkButton;
  11.   begin
  12.     WriteLn('success');
  13.     Write('Building GTK+GUI. ');
  14.     //MainWindow
  15.     MainWindow := TGtkWindow.new(GTK_WINDOW_TOPLEVEL);
  16.     MainWindow^.title := Pgchar(SMainTitle);
  17. //   MainWindow^.set_default_size( 200, 200);
  18.    // MainBox := TGtkBox.new(GTK_ORIENTATION_VERTICAL,3);
  19.     button := gtk_button_new_with_label ('Hello World');
  20.     gtk_container_add (MainWindow, button);
  21.     //gtk_container_add(MainWindow,MainBox);
  22.     MainWindow^.show;
  23.   end;
  24. begin
  25.   if GTKStarted then
  26.     Exit;
  27.   Write('GTK3 application initialization... ');
  28.   GTKStarted := True;
  29.   GTKApplication := gtk_application_new('org.gtk.example',0);
  30.   if GTKApplication = NULL then
  31.     begin
  32.       WriteLn('fail (on gtk_application_new)');
  33.       halt(1);
  34.     end;
  35.   g_signal_connect(GTKApplication, 'activate', G_CALLBACK(@GTKActivate), NULL);
  36.   WriteLn('done');
  37.   Write('GTKActivate raise... ');
  38.   GTKApplication^.run(argc,argv);
  39.   g_object_unref (GTKApplication);
  40. 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 :
Code: Pascal  [Select][+][-]
  1. ...
  2. //MainWindow^.show;
  3. end;
Work without errors. Can you help me (I would like use the "one instance" ability)
French and under the latest Ubuntu ;-p !

 

TinyPortal © 2005-2018