Porting panel plugins to Gtk3
landry at xfce.org
Sun May 1 14:02:35 CEST 2016
so, if we want to have Xfce 4.14 with Gtk+3 in a foreseeable future, at
some point porting has to resume/restart.. in the past days, i've spent
some time porting *some* of the panel plugins i *somewhat* maintain, and
here are some tips and tricks:
* i'm targetting Gtk+3 only, bye-bye Gtk+2. Technically it would be
doable to support both with some #ifdefs, but is there a point..
* i'm going for a feature-parity target first. No UI revamp, no
revolution. Ideally, i'd like to move dialog construction to .ui files
/ GtkBuilder, that might come next. Same thing, using cairo drawing
instead of abusing progressbars for monitors/meters might be nice,
* devhelp is your friend to browse the Gtk+3 doc, as is
* there's an ongoing discussion to know if we finally target 3.14 or
3.20, as there are some 'breaking' changes wrt styling in >= 3.16 with
css providers (see
* styling that worked in 3.14 is considered deprecated in 3.16/3.20, so
has to be #ifdef'ed, see for example http://git.xfce.org/panel-plugins/xfce4-systemload-plugin/tree/panel-plugin/systemload.c#n448
* most of the changes are mechanical, Replacing XfceHVBox /
GtkHBox/GtkVBox by GtkBox, using GtkOrientable, replacing GtkTable by
GtkGrid, replacing GTK_STOCK* macros by their gtk equivalent names,
replacing GtkToggleButton/GtkCheckBox by GtkSwitch, replacing GdkColor
by GdkRGBA, usinc GtkCssProvider instead of setting bg/base colors.. all
this is documented in Gtk+3 doc when a widget is deprecated, and the
general migration doc is here :
So far, i've ported over the following plugins (have a look at the
commits to see what changes are needed):
Not everything is perfect, but things are moving nicely.
To 'compare' gtk2 and gtk3 version and have both in the same panel, i
use the following trick (for a 'foo' panel plugin):
* in /usr/share/xfce4/panel/plugins/, copy foo.desktop to foo-git.desktop
* in foo-git.desktop, only keep untranslated Name/Comment and append 'git' to Name to differentiate plugins
* append X-XFCE-API=2.0 to foo-git.desktop
* append '-git' to X-XFCE-Module line
* symlink path/to/my/workdir/panel-plugin/.libs/libfoo.so to /usr/lib/xfce4/panel/plugins/libfoo-git.so
xfce4-panel -a should allow you to load the git version of the plugin,
without overwriting the 'released' gtk2 version.
Mandatory screenshots using clearklooks theme, one with gtk3 versions
http://i.imgur.com/UwZEaGN.png (not all the checkbox are migrated to
gtkswitch, and i know systemload dialog is a bit huge...)
and the same thing with the last release of the same plugins
http://i.imgur.com/aS44yQV.png and the two panels with the same plugins
loaded using default config. Okay, progressbars dont look the same,
buttons might be a git bigger...
All that to say that it's an easy task for someone who wants to start
playing with gtk code and porting to gtk3 - all help on this is welcome!
If there's a plugin you use and care about, and that looks
abandoned/unmaintained, grab the git master, try to apply the same
changes, and post patches to bugzilla/the list.
Of course, feedback, criticism and testing are welcome! I've only tested
those changes on my OpenBSD desktop with Gtk 3.20.3..
More information about the Xfce4-dev