Recent

Author Topic: [SOLVED]GTK2 gtk_widget_realize problem and GTK future on Linux  (Read 7550 times)

WooBean

  • Sr. Member
  • ****
  • Posts: 303
[SOLVED]GTK2 gtk_widget_realize problem and GTK future on Linux
« on: February 28, 2018, 12:53:14 pm »
Hi to all travelling from MS Windows and Embarcadero Delphi to Linux and Lazarus/FPC.

While trying to understand an example of code boundled with Lazarus 1.8.0/FPC 3.0.4 installation on Linux Mint 18.3 Sylvia/64 bit I jumped into a GTK2 problem. The demo program "canvastest" has a few buttons with associated graphical actions. All buttons but one work. The button "Show Shaped Window" when clicked causes program to suddenly crash with no error info. Expected action was to create a non-standard shape window form.
 
Trying find out the cause I've found in the file "/usr/share/fpcsrc/3.0.4/packages/gtk2/src/gtk+/gtk/gtkwidget.inc" the last successfuly executed line of code in the debugger session. It was line 350: "procedure gtk_widget_realize(widget:PGtkWidget); cdecl; external gtklib;". I assumed that external library is in the file gtklib.so but there is no such file or at least Linux doesn't show it when asked.

What is more the same example program compiled in Windows (64-bit) and for Windows works correctly. Of course low level code is different from that in Linux and GTK libraries are not used for Windows version of the example.

Questions:
1. do I correctly assume the cause of GTK2 problem?
2. I met in the net that GTK2 is not maintained since 4 years now so what we (Lazarus users) can expect for the future of graphical environmet for Lazarus installed on Linux?
« Last Edit: February 28, 2018, 03:55:36 pm by WooBean »
Platforms: Win7/64, Linux Mint 22.1 Xia

Thaddy

  • Hero Member
  • *****
  • Posts: 19115
  • Glad to be alive.
Re: GTK2 gtk_widget_realize problem and GTK future on Linux
« Reply #1 on: February 28, 2018, 01:02:07 pm »
1. No. (a fact)
2. can't answer that since 1) is no. (opinion)
objects are fine constructs. You can even initialize them with constructors.

WooBean

  • Sr. Member
  • ****
  • Posts: 303
Re: GTK2 gtk_widget_realize problem and GTK future on Linux
« Reply #2 on: February 28, 2018, 01:33:13 pm »
1. No. (a fact)
2. can't answer that since 1) is no. (opinion)
Hello Thaddy,
when I started learning English (45 years ago or so) my teachers often said "would you be more specific?". And would you? I am aware that native (or almost) English speakers are not happy reading or listening to foreigners' version of Shakespeare language. And what then? Keep smiling.

WooBean     
Platforms: Win7/64, Linux Mint 22.1 Xia

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12836
  • FPC developer.
Re: GTK2 gtk_widget_realize problem and GTK future on Linux
« Reply #3 on: February 28, 2018, 01:49:05 pm »
(1). gtklib is a simple pascal string constant.  It probably contains just "GTK2"  meaning that libgtk2.so is sought.
     The application wouldn't start if the dependency wasn't satisfied, so that is not the problem.

What causes the problem is not clear. Could be something in the build of GTK for that platform that is either buggy or triggers a bug, but that is hard to find out.

GTK is notoriously buggy and versioned, so the same program can behave differently on different distro/versions.

(2) Well there is QT of course, and maybe a hope that the GTK situation improves.  If both fail, there is still Wine.


WooBean

  • Sr. Member
  • ****
  • Posts: 303
Re: [SOLVED]GTK2 gtk_widget_realize problem and GTK future on Linux
« Reply #4 on: February 28, 2018, 03:54:59 pm »
(1). gtklib is a simple pascal string constant.  It probably contains just "GTK2"  meaning that libgtk2.so is sought.
     The application wouldn't start if the dependency wasn't satisfied, so that is not the problem.
...

(2) Well there is QT of course, and maybe a hope that the GTK situation improves.  If both fail, there is still Wine.

Thanks marcov,

I should have spotted that external procedure or function definition needs string constant to declare library (see doc link:  https://www.freepascal.org/docs-html/current/ref/refse95.html#x185-20700014.8). Actually it is gtklib = 'libgtk-x11-2.0.so'; //line 102 in unit gtk2. The procedure gtk_widget_realize(widget:PGtkWidget) was many times succesfully called in the demo application except this one case involved in non-standard shape form creating.

For now it is enough. We'll wait for some progress at Lazarus Team.

Thank you,

WooBean
« Last Edit: February 28, 2018, 03:56:46 pm by WooBean »
Platforms: Win7/64, Linux Mint 22.1 Xia

zeljko

  • Hero Member
  • *****
  • Posts: 1920
    • http://wiki.lazarus.freepascal.org/User:Zeljan

WooBean

  • Sr. Member
  • ****
  • Posts: 303
Re: [SOLVED]GTK2 gtk_widget_realize problem and GTK future on Linux
« Reply #6 on: March 01, 2018, 08:11:06 pm »
@zeljko
Thanks for clearing a situation of gtk2 status. Looks badly.

Meanwhile, I tried using all possible widgetsets for  a test program "canvastest". Short results:
gtk  - NOT compiles (Linux)
gtk2 - OK, custom shape (ellipse) form error - app crashes (Linux)
qt -   NOT compiles (Linux)
qt5 - NOT compiles (Linux)
win32 - NOT TESTED (Linux), OK (Win64)
wince -  NOT TESTED
fpgui -   NOT compiles (Linux)
nogui -  NOT TESTED
carbon - NOT TESTED
cocoa -  NOT TESTED
customdrawn - OK (Linux), app works but effects not satisfying (too simplified)
gtk3 - NOT compiles (Linux)
mui -  NOT compiles (Linux) 

Compiler's errors were reported mostly as linking problems.

So, creating applications' GUI with Lazarus for Linux target is not as easy as it should and must be. At least for beginners.

Small suggestion for Lazarus Team - it would be nice if inaccessible config options (due to lack of something)  were grayed and truly inaccessible. 
« Last Edit: March 02, 2018, 07:24:58 am by WooBean »
Platforms: Win7/64, Linux Mint 22.1 Xia

mse

  • Sr. Member
  • ****
  • Posts: 286
Re: [SOLVED]GTK2 gtk_widget_realize problem and GTK future on Linux
« Reply #7 on: March 01, 2018, 08:24:44 pm »
If you are interested in a cross platform GUI framework for Free Pascal with same look and feel on all supported platforms fpGUI and MSEide+MSEgui are other options.

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 413
  • I use FPC [main] 💪🐯💪
Re: [SOLVED]GTK2 gtk_widget_realize problem and GTK future on Linux
« Reply #8 on: April 09, 2025, 06:12:39 am »
Ha ha! Fixed it! The mistake was so simple as it turned out )

https://gitlab.com/freepascal.org/lazarus/lazarus/-/merge_requests/457
I may seem rude - please don't take it personally

 

TinyPortal © 2005-2018