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 633866 - Handle icon theme changes
Handle icon theme changes
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Dan Winship
gnome-shell-maint
: 611949 (view as bug list)
Depends on: 633865
Blocks:
 
 
Reported: 2010-11-02 23:32 UTC by Owen Taylor
Modified: 2010-11-15 23:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Make the icon theme part of the StThemeContext (4.72 KB, patch)
2010-11-02 23:32 UTC, Owen Taylor
needs-work Details | Review
Evict cached icons when the icon theme changes (4.43 KB, patch)
2010-11-02 23:32 UTC, Owen Taylor
reviewed Details | Review
Remove _for_theme() variant of st_texture_cache_load_icon_name() (6.48 KB, patch)
2010-11-12 22:17 UTC, Owen Taylor
committed Details | Review
Handle icon theme changes (5.92 KB, patch)
2010-11-13 00:27 UTC, Owen Taylor
none Details | Review
Handle icon theme changes (6.21 KB, patch)
2010-11-13 00:29 UTC, Owen Taylor
committed Details | Review

Description Owen Taylor 2010-11-02 23:32:49 UTC
This will be necessary to get the "High Contrast" option on the accessiblity
menu working - it doesn't work even with this option, but if you do:

 gconftool-2 -s -t string /desktop/gnome/interface/icon_theme HighContrast
 gconftool-2 -s -t string /desktop/gnome/interface/icon_theme gnome

that swaps out the volume icon, etc, so I think HighContrast not working is
something else.
Comment 1 Owen Taylor 2010-11-02 23:32:51 UTC
Created attachment 173729 [details] [review]
Make the icon theme part of the StThemeContext

Add st_theme_context_set_icon_theme(); making the icon theme be part
of the theme context will be useful for allowing named icons to be
loaded by StThemeNode. It also means that we can just reuse
the ::style-changed signal to reload named icons on theme changes,
instead of having to do separate notification.
Comment 2 Owen Taylor 2010-11-02 23:32:53 UTC
Created attachment 173730 [details] [review]
Evict cached icons when the icon theme changes

When there is a ::changed signal on the GtkIconTheme, because the
configured theme or it's contents have changed, blow away any icons
we have cached so the next lookup will get the right icons.
Comment 3 drago01 2010-11-04 19:43:18 UTC
*** Bug 611949 has been marked as a duplicate of this bug. ***
Comment 4 Dan Winship 2010-11-05 14:25:41 UTC
Comment on attachment 173729 [details] [review]
Make the icon theme part of the StThemeContext

>+  if (context->icon_theme)
>+    {
>+      g_signal_handlers_disconnect_by_func (icon_theme,

should be context->icon_theme

>+  if (context->icon_theme)
>+    {
>+      g_object_ref (context->icon_theme);
>+      g_signal_connect (icon_theme, "changed",

and that one's not actually wrong, but it's inconsistent.

Also, shouldn't st_theme_context_set_icon_theme() call st_theme_context_changed()?
Comment 5 Dan Winship 2010-11-05 15:36:08 UTC
Comment on attachment 173730 [details] [review]
Evict cached icons when the icon theme changes

> static void
>+theme_context_evict_icons (StThemeContext *context)
>+{
>+  /* The hackiness is that though we set a #GtkIconTheme for the context,
>+   * when we actually do lookups in StTextureCache we are just using
>+   * gtk_icon_theme_get_default(). That's why we don't pass a GtkIconTheme
>+   * to st_texture_cache_evict_icons().
>+   */
>+  StTextureCache *cache = st_texture_cache_get_default ();
>+  st_texture_cache_evict_icons (cache);
>+}

The comment is weird because it suggests that "the hackiness" has already been referred to elsewhere, which afaict it hasn't.

But anyway, the coupling here seems weird. If StTextureCache isn't using the theme context's icon theme, shouldn't it just listen to GtkIconTheme::changed itself? Or, if we were going to fix StTextureCache to have an associated StThemeContext, it could listen to StThemeContext::changed. Or failing that, we should at least make StTextureCache and StThemeContext have the same scope rather than one being global and one being per-stage.

>+    context.set_icon_theme(Gtk.IconTheme.get_default());

does this belong in the previous patch?
Comment 6 Owen Taylor 2010-11-05 17:28:33 UTC
(In reply to comment #5)
> (From update of attachment 173730 [details] [review])
> > static void
> >+theme_context_evict_icons (StThemeContext *context)
> >+{
> >+  /* The hackiness is that though we set a #GtkIconTheme for the context,
> >+   * when we actually do lookups in StTextureCache we are just using
> >+   * gtk_icon_theme_get_default(). That's why we don't pass a GtkIconTheme
> >+   * to st_texture_cache_evict_icons().
> >+   */
> >+  StTextureCache *cache = st_texture_cache_get_default ();
> >+  st_texture_cache_evict_icons (cache);
> >+}
> 
> The comment is weird because it suggests that "the hackiness" has already been
> referred to elsewhere, which afaict it hasn't.

Yeah, the wording is a bit odd can be improved.
 
> But anyway, the coupling here seems weird. If StTextureCache isn't using the
> theme context's icon theme, shouldn't it just listen to GtkIconTheme::changed
> itself? 

Hmm, so probably what this would look like is:

 - Add a signal to StTexturCache
 - Emit that signal *after* evicting icons
 - Make StThemeContext catch that signal and invalidate styles

You can't just have two independent signal connections because the ordering matters... we need to invalidate styles after we have invalidated icons. Maybe I'll give that approach a try and just skip setting the icon theme on the theme context.

> Or, if we were going to fix StTextureCache to have an associated
> StThemeContext, it could listen to StThemeContext::changed. Or failing that, we
> should at least make StTextureCache and StThemeContext have the same scope
> rather than one being global and one being per-stage.

Clearly, what I have here is half-baked and only works when everybody is using a single GtkIconTheme. I was sort of hoping to just sneak it through like that, and deal with figuring things out when we actually had a reason to...

I don't think it's conceptually right to have StTextureCache be per-stage ... in a multiple-toplevel application - the different stages should share the same cache of textures.

And it's not right for StThemeContext to be global - it's a lightweight object representing information shared about a tree of StThemeNodes.

I think what would be "right" is either:

 - Have StTextureCache be per GtkIconTheme (which basically means per GdkScreen). We could add st_widget_get_texture_cache() to avoid people having to juggle IconThemes at the JS level.

Or:

 - Pass the GtkIconTheme in to the named-icon lookup functions, and make the GtkIconTheme part of the cache key. I guess with %p and use weak pointers to get notification when an icon theme vanishes. 

Practically speaking, neither really helps the shell at all.

> >+    context.set_icon_theme(Gtk.IconTheme.get_default());
> 
> does this belong in the previous patch?

yep.
Comment 7 Dan Winship 2010-11-05 18:22:15 UTC
(In reply to comment #6)
> Practically speaking, neither really helps the shell at all.

yeah, i don't think it's worth putting *too* much work into it. I didn't notice the invalidation/redrawing ordering constraint when I was thinking about it before...
Comment 8 Owen Taylor 2010-11-12 22:17:36 UTC
Created attachment 174370 [details] [review]
Remove _for_theme() variant of st_texture_cache_load_icon_name()

Now that we're using St.Icon in the Javascript, there is no reason
to have separate st_texture_cache_load_icon_name() and
st_texture_cache_load_icon_name_for_theme(), instead just add
the StThemeNode argument to st_texture_cache_load_icon_name().
Comment 9 Owen Taylor 2010-11-12 22:41:35 UTC
Comment on attachment 174370 [details] [review]
Remove _for_theme() variant of st_texture_cache_load_icon_name()

Oops attached that patch to the wrong bug. Now pushed as part of bug 633865
where it belonged.
Comment 10 Owen Taylor 2010-11-13 00:22:28 UTC
New testing methology with a gnome3 gnome-settings-daemon:

 gsettings set org.gnome.desktop.interface icon-theme HighContrast
 gsettings set org.gnome.desktop.interface icon-theme gnome
Comment 11 Owen Taylor 2010-11-13 00:27:00 UTC
Created attachment 174371 [details] [review]
Handle icon theme changes

Here's a new simpler approach. I'm aware of the inconsistencies that:

 - For StTextureCache I call gtk_icon_theme_get_default() once
   and store it in a member variable.
 - Except for the usage of gtk_icon_theme_get_default() where
   I don't (in a thread, in a fallback case, StTextureCache isn't
   readily available)
 - For StThemeContext, I call st_texture_cache_get_default()
   both in init() and finalize() and assume they are the same.

And they don't worry me much :-)
Comment 12 Owen Taylor 2010-11-13 00:29:05 UTC
Created attachment 174372 [details] [review]
Handle icon theme changes

Add an explanatory comment to the code.
Comment 13 Owen Taylor 2010-11-15 23:46:22 UTC
Attachment 174372 [details] pushed as 8734a59 - Handle icon theme changes