Programming => Widgetset => GTK => Topic started by: dbannon on October 23, 2019, 10:06:52 am
Title: gtk3 and gdk_pixbuf_save()
Post by: dbannon on October 23, 2019, 10:06:52 am
Thought I'd have a little play with GTK3, particularly the TrayIcon. Initially appeared quite easy to get it to work with LibAppIndicator but I have run into problems with the function gdk_pixbuf_save() that is derived from libgdk_pixbuf-2.0.so.0. Same library in both gtk2 and gtk3.
In gtk2 its accessed via Gdk2Pixbuf unit from - /usr/share/fpcsrc/3.0.4/packages/gtk2/src/gtk+/gdkpixbuf/gtk2pixbuf.pas
In gtk3 I choose to 'use' LazGdkPixbuf2 unit from - lcl/interfaces/gtk3/gtk3bindings/lazgdkpixbuf2.pas
and I wonder if thats was a mistake. Not wanting to bore everyon with TrayIcon issues, I reduced it down to the following code, its a form with nothing more than a TrayIcon that has had a icon and a menu assigned in the Object Inspector
It does not like my icon, apparently does not believe its a pixbuf. Apart from gdk_pixbuf_save() is there some other way to dump the icon out to have a look at it ?
Davo
Title: Re: gtk3 and gdk_pixbuf_save()
Post by: zeljko on October 23, 2019, 10:54:35 am
Handle is wrong in your case. It points to TObject not to PGdkPixbuf, you should use TGtk3Image(TrayIcon1.Icon.Handle).Handle
Title: Re: gtk3 and gdk_pixbuf_save()
Post by: dbannon on October 23, 2019, 11:22:36 am
Yep, thats it ! One more step....
Thanks zeljko !
Title: Re: gtk3 and gdk_pixbuf_save()
Post by: dbannon on October 23, 2019, 12:38:57 pm
OK, struck another hard one. And not one I can bring out and identify....
Further in, we pass a menu to the LibAppIndicator3 using this function -
Again, its wanting the menu in some GTK3 format ? I tried Pointer(TGTK3Menu(FTrayIcon.PopUpMenu.Handle)) but I am only guessing and guessing does not work !
Davo
Title: Re: gtk3 and gdk_pixbuf_save()
Post by: zeljko on October 23, 2019, 02:39:27 pm
Just check first what is TGtk3 class. writeln('TrayIcon popupMenu class is ',TGtk3Widget(FTrayIcon.PopUpMenu.Handle).ClassName); and then use eg: TGtk3Menu(FTrayIcon.PopUpMenu.Handle).Widget <- note Widget , it's Gtk3 handle
Title: Re: gtk3 and gdk_pixbuf_save()
Post by: dbannon on October 24, 2019, 11:44:46 am
Yep, thats it zeljko, I still needed to cast it with a PGtkMenu( but that works and now so does the whole thing. I'll need to do some more tests but looks like I can make a patch to add TrayIcon to GTK3, excellent !