Page 1 of 1
5.40LTS - Using gtk api with gtk2 subsystem does not work
Posted: Thu Oct 22, 2015 1:51 pm
by Niffo
Using the gtk api gtk_window_set_icon_from_file_() with the "gtk2" subsystem causes the following error at launch (from debugger or executable)
- Using the same api in PB5.31 is OK.
- Using the same api in PB5.40 without subsystem is OK.
Code: Select all
OpenWindow(0, 100, 100, 300, 200, "gtk api test")
gtk_window_set_icon_from_file_(WindowID(0), "any_png.png", 0)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Code: Select all
Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported
(seen on Debian 8-64 / Gnome with PB-5.40LTS 64bits)
Re: 5.40LTS - Using gtk api with gtk2 subsystem does not wor
Posted: Thu Oct 22, 2015 3:50 pm
by Shardik
Niffo wrote:Using the gtk api gtk_window_set_icon_from_file_() with the "gtk2" subsystem causes the following error at launch.
Sorry, but I can't confirm this. I modified your example to load an icon contained in each PB installation and it works equally well in PB 5.40 x86 without subsystem and with subsystem "gtk2" (Kubuntu 14.04 x86 with KDE):
Code: Select all
OpenWindow(0, 100, 100, 300, 200, "gtk api test")
gtk_window_set_icon_from_file_(WindowID(0), #PB_Compiler_Home + "examples/sources/Data/Drive.bmp", 0)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
By the way, with which distribution and desktop/window manager did you test?
And in your example
UsePNGImageDecoder() is missing although you are loading a png image but maybe the API function is handling that...
Re: 5.40LTS - Using gtk api with gtk2 subsystem does not wor
Posted: Thu Oct 22, 2015 5:12 pm
by Niffo
No need to add "UsePNGImageDecoder()" as it is an API.
I added my configuration (distribution / desktop) in the first post
The same with your example :

Re: 5.40LTS - Using gtk api with gtk2 subsystem does not wor
Posted: Fri Oct 23, 2015 10:42 am
by Shardik
I can only reproduce your error message with subsystem "gtk2" on 2 from 11 tested distributions. Both use Gnome 3 as window manager.
Another observation: before installing libgtk-3-dev on Debian 7 the error with subsystem "gtk2" didn't occur.
A different problem is that 7 from 11 window managers don't seem to display an icon in a window title at all (only Enlightenment, KDE and LXDE). Here are the results of testing different distributions with different window managers running my code example posted above in PB 5.40:
Code: Select all
Error displayed Icon displayed Distribution and Window Manager
--------------- -------------- ----------------------------------------
- + Bodhi Linux 3.0.0 x86 with Enlightenment
+ - Debian 7 x86 with Gnome 3
- - ElementaryOS 0.2.1 x86 with Pantheon
+ - Fedora 21 x86 with Gnome 3
- + Kubuntu 14.04 x86 with KDE
- - Linux Mint 17 x86 with Cinnamon
- + Lubuntu 14.04 x86 with LXDE
- + Ubuntu 14.04 x64 with KDE
- - Ubuntu 14.04 x86 with Unity
- - Ubuntu MATE 14.04 x86 with MATE
- - Xubuntu 14.04 x86 with Xfce
Re: 5.40LTS - Using gtk api with gtk2 subsystem does not wor
Posted: Fri Nov 20, 2015 1:03 pm
by Fred
That's wierd because we should link with:
`pkg-config --libs gtk+-3.0` `pkg-config --libs gthread-2.0`
which shouldn't link gtk2
I can't reproduce it here.
Re: 5.40LTS - Using gtk api with gtk2 subsystem does not wor
Posted: Wed Aug 03, 2016 1:27 pm
by Shardik
As I am currently testing stuff with Fedora 23 Gnome 3 and both GTK2 and GTK3, I experienced the same error message again in PB 5.43 x86. The solution is quite simple: for Gnome 3 you have to define all utilized API functions in an ImportC..EndImport block! The following code example is working in Gnome 3 with both GTK2 and GTK3 without the error message reported by Niffo. Commenting out the ImportC..EndImport block will again produce the error message in GTK2!
Code: Select all
ImportC ""
gtk_window_set_icon_from_file(*Window.GtkWindow, Filename.P-UTF8, *Error.GError)
EndImport
OpenWindow(0, 100, 100, 300, 200, "GTK API test")
gtk_window_set_icon_from_file(WindowID(0), #PB_Compiler_Home + "examples/sources/Data/Drive.bmp", 0)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
I also tested another more complicated code example utilizing 9 different API functions. In Gnome 3 all 9 functions had to be imported in order to work in GTK2 without error message!
Re: 5.40LTS - Using gtk api with gtk2 subsystem does not wor
Posted: Wed Aug 03, 2016 5:16 pm
by gerd
I do get the same error as Niffo, if I set subsystem "gtk2".
Now, if I use exactly the code Shardik posted, I don't get the error. But there is a slight difference between Niffos and Shardiks code.
Niffo:
Code: Select all
gtk_window_set_icon_from_file_(WindowID(0), #PB_Compiler_Home + "examples/sources/Data/Drive.bmp", 0)
This code has an underscore in front of the opening parenthesis.
Shardik:
Code: Select all
gtk_window_set_icon_from_file(WindowID(0), #PB_Compiler_Home + "examples/sources/Data/Drive.bmp", 0)
This one doesn't have the underscore. And this with the import before does not throw the error.
PureBasic 5.50; openSuse 13.1; KDE
Regards
gerd
Re: 5.40LTS - Using gtk api with gtk2 subsystem does not wor
Posted: Wed Aug 03, 2016 7:05 pm
by Shardik
gerd wrote:Now, if I use exactly the code Shardik posted, I don't get the error. But there is a slight difference between Niffos and Shardiks code.
Niffo:
Code: Select all
gtk_window_set_icon_from_file_(WindowID(0), #PB_Compiler_Home + "examples/sources/Data/Drive.bmp", 0)
This code has an underscore in front of the opening parenthesis.
Yes, Niffo is using the API function predefined in PureBasic which uses an underscore and therefore doesn't need an Import statement.
gerd wrote:Shardik:
Code: Select all
gtk_window_set_icon_from_file(WindowID(0), #PB_Compiler_Home + "examples/sources/Data/Drive.bmp", 0)
This one doesn't have the underscore. And this with the import before does not throw the error.
My code uses ImportC to import the API function and therefore doesn't use the underscore in front of the parenthesis because with an underscore the API function wouldn't be found by the ImportC statement.
So that's the essence: no error message in GTK2 when importing API functions with an ImportC..EndImport block but the reported error message in GTK2 when using the API functions predefined in PureBasic...

Re: 5.40LTS - Using gtk api with gtk2 subsystem does not wor
Posted: Wed Aug 03, 2016 9:35 pm
by gerd
Yes Shardik,
but before PureBasic 5.40 we didn't need to import the API function, we just used the predefined function with the underscore.
Now, if you have an older ongoing project with API, you will have to import every single API function to make it work
with PureBasic 5.40 and above. This, for instance, for me is not possible, because I just don't know enough about all this.
And that's, why my project is on hold.
And even worse, some of the GTK2 functions don't exist anymore in GTK3. Of course this is not PureBasics fault
or anything Purebasic could change, but doesn't help much.
Regards
gerd