After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 701175 - Apply custom css styles
Apply custom css styles
Status: RESOLVED OBSOLETE
Product: glade
Classification: Applications
Component: user interface
3.15.x
Other All
: Normal enhancement
: ---
Assigned To: Glade 3 Maintainers
Glade 3 Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-05-29 07:27 UTC by Domenico Ferrari
Modified: 2018-03-26 15:29 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Domenico Ferrari 2013-05-29 07:27:29 UTC
Why not apply custom css style classes in the editor like it is done in the preview?
Comment 1 Tristan Van Berkom 2013-05-29 08:01:11 UTC
(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.
Comment 2 Domenico Ferrari 2013-05-29 08:28:50 UTC
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));
Comment 3 Tristan Van Berkom 2013-05-29 10:00:27 UTC
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.
Comment 4 Domenico Ferrari 2013-05-29 13:14:17 UTC
Maybe gtk_style_context_list_classes would suffice
Comment 5 Tristan Van Berkom 2013-05-29 14:16:08 UTC
(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).
Comment 6 GNOME Infrastructure Team 2018-03-26 15:29:32 UTC
-- 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.