summaryrefslogtreecommitdiff
path: root/gtk/gtkicontheme.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2005-08-22 20:12:15 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2005-08-22 20:12:15 +0000
commitf2cb87d3a947740d180aacb749a5c2fb21aa5eb9 (patch)
tree0b40f6b7e16dd6eddc0057706e550c846defd381 /gtk/gtkicontheme.c
parent97ec1cdf4f8d16906f43ef02c11ac13b96d22ad2 (diff)
downloadgdk-pixbuf-f2cb87d3a947740d180aacb749a5c2fb21aa5eb9.tar.gz
Implement a clientmessage based scheme for makeing sure that all GTK+
2005-08-22 Matthias Clasen <mclasen@redhat.com> * gtk/gtkwindow.c (gtk_window_client_event): * gtk/gtkicontheme.c (ensure_valid_themes) (_gtk_icon_theme_check_reload): Implement a clientmessage based scheme for makeing sure that all GTK+ applications notice if an icon theme has been updated. This should prevent multiple versions of an icon theme cache to be mapped in memory at the same time, which can cause excessive memory consumption. (#313156, Chris Lahey)
Diffstat (limited to 'gtk/gtkicontheme.c')
-rw-r--r--gtk/gtkicontheme.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 360a5c7b4..07f55e03e 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -96,6 +96,8 @@ struct _GtkIconThemePrivate
GList *dir_mtimes;
gulong reset_styles_idle;
+
+ gboolean check_reload;
};
struct _GtkIconInfo
@@ -1128,7 +1130,7 @@ ensure_valid_themes (GtkIconTheme *icon_theme)
{
GtkIconThemePrivate *priv = icon_theme->priv;
GTimeVal tv;
-
+
if (priv->themes_valid)
{
g_get_current_time (&tv);
@@ -1138,7 +1140,26 @@ ensure_valid_themes (GtkIconTheme *icon_theme)
}
if (!priv->themes_valid)
- load_themes (icon_theme);
+ {
+ load_themes (icon_theme);
+
+ if (!priv->check_reload)
+ {
+ static GdkAtom atom_iconthemes = GDK_NONE;
+ GdkEvent *event = gdk_event_new (GDK_CLIENT_EVENT);
+ int i;
+
+ if (!atom_iconthemes)
+ atom_iconthemes = gdk_atom_intern ("_GTK_LOAD_ICONTHEMES", FALSE);
+
+ for (i = 0; i < 5; i++)
+ event->client.data.l[i] = 0;
+ event->client.data_format = 32;
+ event->client.message_type = atom_iconthemes;
+
+ gdk_screen_broadcast_client_message (priv->screen, event);
+ }
+ }
}
/**
@@ -2937,6 +2958,29 @@ find_builtin_icon (const gchar *icon_name,
return min_icon;
}
+void
+_gtk_icon_theme_check_reload (GdkDisplay *display)
+{
+ gint n_screens, i;
+ GdkScreen *screen;
+ GtkIconTheme *icon_theme;
+
+ n_screens = gdk_display_get_n_screens (display);
+
+ for (i = 0; i < n_screens; i++)
+ {
+ screen = gdk_display_get_screen (display, i);
+
+ icon_theme = g_object_get_data (G_OBJECT (screen), "gtk-icon-theme");
+ if (icon_theme)
+ {
+ icon_theme->priv->check_reload = TRUE;
+ ensure_valid_themes (icon_theme);
+ icon_theme->priv->check_reload = FALSE;
+ }
+ }
+}
+
#ifdef G_OS_WIN32
/* DLL ABI stability backward compatibility versions */