Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-10

Gtk3 "hello world" application crash

11 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Krzysztof

Hi,

According to this wiki page: http://wiki.freepascal.org/Gtk%2B3 I downloaded latest gtk3 headers from:
http://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/bindings/gtk3/

I have very simple Hello World application which is working fine on GTK2:

gtk_init(@argc, @argv);
windows := gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(window);
gtk_main();

but on GTK3 it crash on gtk_main(); (but I see main window for a few milliseconds).
I know that GTK3 is on development stage, but is anyone successful using it on this stage? Because last update of headers were over a year ago. There are also missing main functions like g_signal_connect() or functions for box layouts.

Linux Mint 14 64bit, XFCE edition
Free Pascal 2.6.2
Lazarus 1.0.8

Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131001/a83beb39/attachment.html>

Reply by email

zeljko
to Krzysztof
Krzysztof wrote 19 lines
Hi, According to this wiki page: http://wiki.freepascal.org/Gtk%2B3 I downloaded latest gtk3 headers from: http://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/bindings/gtk3/ I have very simple Hello World application which is working fine on GTK2: gtk_init(@argc, @argv); windows := gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_show(window); gtk_main(); but on GTK3 it crash on gtk_main(); (but I see main window for a few milliseconds). I know that GTK3 is on development stage, but is anyone successful using it on this stage? Because last update of headers were over a year ago. There are also missing main functions like g_signal_connect() or functions for box layouts.

Look at implementation in lazarus/lcl/interfaces/gtk3 . It works , also most of wincontrols works (using bit modified bindings from lazarus/lcl/interfaces/gtk3/gtk3bindings

zeljko

Reply by email

Krzysztof
to zeljko
Show quoted text 6 lines
Look at implementation in lazarus/lcl/interfaces/gtk3 . It works , also most of wincontrols works (using bit modified bindings from lazarus/lcl/interfaces/gtk3/**gtk3bindings zeljko

Yes. I checked also source from interfaces. Same problem. Maybe I'm doing something wrong? My steps:
1. I copied headers from lazarus/lcl/interfaces/gtk3/gtk3binding into my project source because I'm not interested in LCL, I need to write pure Gtk3 application
2. I installed gtk3 dev headers in my ubuntu distro by: sudo aptitude install libgtk-3-dev. Other dependences were installed too, like: gir1.2-gtk-3.0{a} libatk-bridge2.0-dev{a} libgtk-3-dev libwayland-dev{a} libxkbcommon-dev{a}
3. Application is compiling fine, but crash in gtk_main() with error: "External: SIGFPE"
4. When I run program from console I see error text: "EDivByZero : Divizion by zero"

BTW: Have Lazarus Gtk3 support for windows too? I mean, I see only link to linux .so library, but Gtk3 has package for windows too where dll libs are used.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131002/d297d7b0/attachment.html>

Reply by email

Krzysztof
to zeljko: Look at implementation in lazarus/lcl/interfaces/gtk3 . It works , also most of…

Ok I give up. Could not find simple Gtk3 example in lazarus implementation. So I found another gtk hello world in C based on Gtk3 from: https://developer.gnome.org/gnome-devel-demos/3.6/checkbutton.c.html.en . But same error with division by zero:

var
  window: PGtkWidget;
  app: PGtkApplication;
  status: Integer;
  procedure activate; cdecl;
  begin
    window := gtk_application_window_new(app);
    gtk_window_set_title(PGtkWindow(window), 'CheckButton Example');
    gtk_window_set_default_size (PGtkWindow(window), 300, 100);
    gtk_widget_show_all(window);
  end;
begin
  g_type_init();
  app := gtk_application_new ('org.example.checkbutton',
G_APPLICATION_FLAGS_NONE);
  g_signal_connect_data(app, 'activate', @activate, nil, nil, 0);
  status := g_application_run (PGApplication(app), argc, argv);
  g_object_unref (app);
end.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131003/91213d04/attachment.html>

Reply by email

zeljko
to Krzysztof
Krzysztof wrote 28 lines
Ok I give up. Could not find simple Gtk3 example in lazarus implementation. So I found another gtk hello world in C based on Gtk3 from: https://developer.gnome.org/gnome-devel-demos/3.6/checkbutton.c.html.en . But same error with division by zero: var window: PGtkWidget; app: PGtkApplication; status: Integer; procedure activate; cdecl; begin window := gtk_application_window_new(app); gtk_window_set_title(PGtkWindow(window), 'CheckButton Example'); gtk_window_set_default_size (PGtkWindow(window), 300, 100); gtk_widget_show_all(window); end; begin g_type_init(); app := gtk_application_new ('org.example.checkbutton', G_APPLICATION_FLAGS_NONE); g_signal_connect_data(app, 'activate', @activate, nil, nil, 0); status := g_application_run (PGApplication(app), argc, argv); g_object_unref (app); end.
Have you tried to add (eg. to initialization) ?
SetExceptionMask([exDenormalized,exInvalidOp,exOverflow,exPrecision,exUnderflow,exZeroDivide]);

Reply by email

Krzysztof
to zeljko

Totally forgot about SetExceptionMask! Remember that I needed to use it in fpGUI application too. I forgot about this because Gtk2 example is working fine. Thanks zeljko, now it is working! Great :D

2013/10/3 zeljko

Show quoted text 40 lines
On 10/03/2013 11:50 AM, Krzysztof wrote: > Ok I give up. Could not find simple Gtk3 example in lazarus > implementation. So I found another gtk hello world in C based on Gtk3 > from: > https://developer.gnome.org/**gnome-devel-demos/3.6/** > checkbutton.c.html.en<https://developer.gnome.org/gnome-devel-demos/3.6/checkbutton.c.html.en> > . But same error with division by zero: > > var > window: PGtkWidget; > app: PGtkApplication; > status: Integer; > > procedure activate; cdecl; > begin > window := gtk_application_window_new(**app); > gtk_window_set_title(**PGtkWindow(window), 'CheckButton Example'); > gtk_window_set_default_size (PGtkWindow(window), 300, 100); > > gtk_widget_show_all(window); > end; > > begin > g_type_init(); > app := gtk_application_new ('org.example.checkbutton', > G_APPLICATION_FLAGS_NONE); > g_signal_connect_data(app, 'activate', @activate, nil, nil, 0); > status := g_application_run (PGApplication(app), argc, argv); > g_object_unref (app); > end. > Have you tried to add (eg. to initialization) ? SetExceptionMask([**exDenormalized,exInvalidOp,**exOverflow,exPrecision,** exUnderflow,exZeroDivide]);

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131003/7e54193b/attachment.html>

Reply by email

Andrew Haines
to Krzysztof: According to this wiki page: http://wiki.freepascal.org/Gtk%2B3 I downloaded latest gtk3…
Krzysztof wrote 16 lines
Hi, According to this wiki page: http://wiki.freepascal.org/Gtk%2B3 I downloaded latest gtk3 headers from: http://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/bindings/gtk3/ I have very simple Hello World application which is working fine on GTK2: gtk_init(@argc, @argv); windows := gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_show(window); gtk_main(); but on GTK3 it crash on gtk_main(); (but I see main window for a few milliseconds).

I am a bit late to answer but there are a few examples here:

http://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/bindings/gtk3/examples/

Regards,

Andrew Haines

Reply by email

Andrew Haines
to Krzysztof: According to this wiki page: http://wiki.freepascal.org/Gtk%2B3 I downloaded latest gtk3…
Krzysztof wrote
There are also missing main functions like g_signal_connect() or functions for box layouts.

g_signal_connect is a c macro around g_signal_connect_data which is available. The bindings are generated using introspection, so everything works but some convenience macros aren't available.

Which function's for box layouts are missing? The generator does not include things which are marked deprecated in the introspection files so that could be the cause.

Regards,

Andrew

Reply by email

Andrew Haines
to Krzysztof
Krzysztof wrote 12 lines
2013/10/6 Andrew Haines < <mailto:>> Which function's for box layouts are missing? The generator does not include things which are marked deprecated in the introspection files so that could be the cause. For example gtk_vbox_new();

Ah ok this is a deprecated class in Gtk 3. Now you should use gtk_box_new(<Orientation>);
GTK_ORIENTATION_HORIZONTAL
GTK_ORIENTATION_VERTICAL

Regards,

Andrew

Reply by email