Gtk3 port theming

flo.xfce at gmx-topmail.de flo.xfce at gmx-topmail.de
Tue May 17 17:05:53 CEST 2016


Well I guess the docs recommend using the CSS provider more in static
way, like in xfce4-notifyd's Gtk3 version. It would be nice to have some
soirt of set_css_property () API, but I couldn't find something like
this (at least a getter is provided by GtkStyleProvider).
Nevertheless I wouldn't use the override functions. As you said, they
are already deprecated, so we would have to deal with them again sooner
or later.

On 05/15/16 19:21, Matthew Brush wrote:
> On 2016-05-15 05:37 AM, flo.xfce at gmx-topmail.de wrote:
>> Hi all,
>> in Landrys porting efforts of various panel plugins (and I have seen it
>> in other applications, too) I came across code like this:
>>
>> css = g_strdup_printf("label { color: %s; }", gdk_rgba_to_string(color));
>> css_provider = gtk_css_provider_new ();
>> gtk_css_provider_load_from_data (css_provider, css, strlen(css), NULL);
>>
>> This looks really hacky to me, so my question: Is this the recommended
>> way of setting widget styles independet of the user's theme? In Xfce
>> there are multiple situation where we allow overwriting of the theme,
>> for example the panel where you can set custom backgrounds. I'm just
>> curious what would be the right way of achieving this.
>>
> 
> If it didn't need to be dynamic, I'd say to use a separate
> application-specific CSS file.
> 
> Another way is to use stuff like `gtk_widget_override_color()` and
> friends (deprecated since 3.16)[0]. The docs for it also tell the
> non-deprecated alternative to use, but I don't know if it's saying to do
> like you showed above, or to write a whole custom GtkStyleProvider
> subclass and such. In any case, you might have more luck deciphering
> those docs than I.
> 
> In theory, it should be safe to use `gtk_widget_override_*` functions
> until GTK+ 4, but who knows if the GTK+ devs are going to just make it
> do nothing, breaking the apps in question without technically breaking
> any API/ABI guarantees, like they've done in the past[1].
> 
> Cheers,
> Matthew Brush
> 
> [0]:
> https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-override-color
> 
> [1]: https://bugzilla.gnome.org/show_bug.cgi?id=735211
> _______________________________________________
> Xfce4-dev mailing list
> Xfce4-dev at xfce.org
> https://mail.xfce.org/mailman/listinfo/xfce4-dev


More information about the Xfce4-dev mailing list