diff options
author | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2016-02-04 10:32:02 +0200 |
---|---|---|
committer | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2016-02-07 04:05:40 +0200 |
commit | 06848ada66d821a7bdde18751f050619e4c136d6 (patch) | |
tree | cc584102d7b4c24fa1c310e21b1a428a25c27bc4 | |
parent | c1d434c7fe4b4e31e616f9ebcf50bce6184a6031 (diff) | |
download | metacity-06848ada66d821a7bdde18751f050619e4c136d6.tar.gz |
libmetacity: don't use GtkSettings to change gtk-theme-name
-rw-r--r-- | libmetacity/meta-style-info.c | 9 | ||||
-rw-r--r-- | libmetacity/meta-style-info.h | 3 | ||||
-rw-r--r-- | libmetacity/meta-theme-gtk.c | 42 | ||||
-rw-r--r-- | libmetacity/meta-theme.c | 35 |
4 files changed, 62 insertions, 27 deletions
diff --git a/libmetacity/meta-style-info.c b/libmetacity/meta-style-info.c index 5eb102bb..d6194222 100644 --- a/libmetacity/meta-style-info.c +++ b/libmetacity/meta-style-info.c @@ -92,22 +92,17 @@ create_style_context (GtkStyleContext *parent, } MetaStyleInfo * -meta_style_info_new (const gchar *variant, +meta_style_info_new (const gchar *theme_name, + const gchar *variant, gboolean composited) { MetaStyleInfo *style_info; GtkCssProvider *provider; - char *theme_name; - - g_object_get (gtk_settings_get_default (), - "gtk-theme-name", &theme_name, - NULL); if (theme_name && *theme_name) provider = gtk_css_provider_get_named (theme_name, variant); else provider = gtk_css_provider_get_default (); - g_free (theme_name); style_info = g_new0 (MetaStyleInfo, 1); style_info->refcount = 1; diff --git a/libmetacity/meta-style-info.h b/libmetacity/meta-style-info.h index a4b826a2..53560874 100644 --- a/libmetacity/meta-style-info.h +++ b/libmetacity/meta-style-info.h @@ -41,7 +41,8 @@ typedef struct GtkStyleContext *styles[META_STYLE_ELEMENT_LAST]; } MetaStyleInfo; -MetaStyleInfo *meta_style_info_new (const gchar *variant, +MetaStyleInfo *meta_style_info_new (const gchar *theme_name, + const gchar *variant, gboolean composited); MetaStyleInfo *meta_style_info_ref (MetaStyleInfo *style_info); diff --git a/libmetacity/meta-theme-gtk.c b/libmetacity/meta-theme-gtk.c index 866bd962..950514e6 100644 --- a/libmetacity/meta-theme-gtk.c +++ b/libmetacity/meta-theme-gtk.c @@ -26,27 +26,39 @@ struct _MetaThemeGtk { - MetaThemeImpl parent; + MetaThemeImpl parent; + + gchar *name; }; G_DEFINE_TYPE (MetaThemeGtk, meta_theme_gtk, META_TYPE_THEME_IMPL) +static void +meta_theme_gtk_finalize (GObject *object) +{ + MetaThemeGtk *gtk; + + gtk = META_THEME_GTK (object); + + g_free (gtk->name); + + G_OBJECT_CLASS (meta_theme_gtk_parent_class)->finalize (object); +} + static gboolean meta_theme_gtk_load (MetaThemeImpl *impl, const gchar *name, GError **error) { - GtkSettings *settings; + MetaThemeGtk *gtk; MetaFrameType type; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - settings = gtk_settings_get_default (); - - if (settings == NULL) - return FALSE; + gtk = META_THEME_GTK (impl); - g_object_set (settings, "gtk-theme-name", name, NULL); + g_free (gtk->name); + gtk->name = g_strdup (name); for (type = 0; type < META_FRAME_TYPE_LAST; type++) { @@ -126,17 +138,11 @@ meta_theme_gtk_load (MetaThemeImpl *impl, static gchar * meta_theme_gtk_get_name (MetaThemeImpl *impl) { - GtkSettings *settings; - gchar *name; + MetaThemeGtk *gtk; - settings = gtk_settings_get_default (); + gtk = META_THEME_GTK (impl); - if (settings == NULL) - return NULL; - - g_object_get (settings, "gtk-theme-name", &name, NULL); - - return name; + return gtk->name; } static void @@ -1022,10 +1028,14 @@ meta_theme_gtk_draw_frame (MetaThemeImpl *impl, static void meta_theme_gtk_class_init (MetaThemeGtkClass *gtk_class) { + GObjectClass *object_class; MetaThemeImplClass *impl_class; + object_class = G_OBJECT_CLASS (gtk_class); impl_class = META_THEME_IMPL_CLASS (gtk_class); + object_class->finalize = meta_theme_gtk_finalize; + impl_class->load = meta_theme_gtk_load; impl_class->get_name = meta_theme_gtk_get_name; impl_class->get_frame_borders = meta_theme_gtk_get_frame_borders; diff --git a/libmetacity/meta-theme.c b/libmetacity/meta-theme.c index 66eb8549..db8ce601 100644 --- a/libmetacity/meta-theme.c +++ b/libmetacity/meta-theme.c @@ -37,6 +37,7 @@ struct _MetaTheme PangoFontDescription *titlebar_font; + gchar *theme_name; GHashTable *variants; }; @@ -97,6 +98,8 @@ meta_theme_finalize (GObject *object) theme->titlebar_font = NULL; } + g_free (theme->theme_name); + G_OBJECT_CLASS (meta_theme_parent_class)->finalize (object); } @@ -206,6 +209,25 @@ meta_theme_load (MetaTheme *theme, const gchar *name, GError **error) { + g_free (theme->theme_name); + + if (theme->type == META_THEME_TYPE_GTK) + { + theme->theme_name = g_strdup (name); + } + else if (theme->type == META_THEME_TYPE_METACITY) + { + GtkSettings *settings; + + settings = gtk_settings_get_default (); + + g_object_get (settings, "gtk-theme-name", &theme->theme_name, NULL); + } + else + { + g_assert_not_reached (); + } + return META_THEME_IMPL_GET_CLASS (theme->impl)->load (theme->impl, name, error); } @@ -226,9 +248,15 @@ meta_theme_style_invalidate (MetaTheme *theme) variant = g_strdup ((gchar *) l->data); if (g_strcmp0 (variant, "default") == 0) - style_info = meta_style_info_new (NULL, theme->composited); + { + style_info = meta_style_info_new (theme->theme_name, NULL, + theme->composited); + } else - style_info = meta_style_info_new (variant, theme->composited); + { + style_info = meta_style_info_new (theme->theme_name, variant, + theme->composited); + } g_hash_table_insert (theme->variants, variant, style_info); } @@ -249,7 +277,8 @@ meta_theme_get_style_info (MetaTheme *theme, if (style_info == NULL) { - style_info = meta_style_info_new (variant, theme->composited); + style_info = meta_style_info_new (theme->theme_name, variant, + theme->composited); g_hash_table_insert (theme->variants, g_strdup (variant), style_info); } |