GNOME Bugzilla – Bug 701175
Apply custom css styles
Last modified: 2018-03-26 15:29:32 UTC
Why not apply custom css style classes in the editor like it is done in the preview?
(In reply to comment #0) > Why not apply custom css style classes in the editor like it is done in the > preview? No real reason, except that it would cost some custom code in the plugin. Since the css style classes are custom GtkBuilder input, we have custom code to load and save it, we just need to add more custom code to apply them to the runtime widgets in the workspace.
Style tag is processed by GtkWidget. It could be like the code of gtkwidget.c context = gtk_widget_get_style_context (GTK_WIDGET (buildable)); for (l = style_data->classes; l; l = l->next) gtk_style_context_add_class (context, (const gchar *)l->data); gtk_widget_reset_style (GTK_WIDGET (buildable));
Yes. FWIW it needs to be done in GtkWidget's adaptor code in the set_property() method, around here: https://git.gnome.org/browse/glade/tree/plugins/gtk+/glade-gtk-widget.c#n721 The virtual property used to store the list of style classes in Glade's runtime is defined as follows: <property id="glade-style-classes" _name="Style Classes" weight="4.25" custom-layout="True" save="False" ignore="True" since="3.0"> <parameter-spec> <type>GParamBoxed</type> <value-type>GladeStringList</value-type> </parameter-spec> <_tooltip>A list of style class names to apply to this widget</_tooltip> </property> Which means a 'GList *' of 'GladeString' structures can be fetched with glade_widget_property_get() in the adaptor's set_property() method. The 'ignore' attribute will need to be removed for the adaptor's set_property() method to apply. There is one problem however, which is tracking which styles were previously set on the runtime widget and unsetting them before applying the new list of style properties (otherwise style properties will just accumulate in the runtime). Perhaps this can be a list stored on the runtime widget with some object qdata.
Maybe gtk_style_context_list_classes would suffice
(In reply to comment #4) > Maybe gtk_style_context_list_classes would suffice No it wouldn't be right. Many widgets add style classes to themselves in their initializers (or in some other cases, like in specific states, or as the result of some property values). It would be important to only remove the style classes which were added by Glade. Anyway, this is not all that difficult to do... there are just so many similar details (so many details) that can also be done. I appreciate the bug report, though, I can't say when I'll get around to doing this myself (unless someone has a patch... I wouldn't be against this).
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glade/issues/128.