diff options
author | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2015-01-21 00:43:59 +0200 |
---|---|---|
committer | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2015-04-04 15:33:58 +0300 |
commit | 72f5e7a56b8951867297690923d7e393545dc648 (patch) | |
tree | 29b907fff5fc2cc81b6205ecb11805ece35829d0 | |
parent | de292b3f70d4296ba4d603fee9d95fe3028759fa (diff) | |
download | metacity-72f5e7a56b8951867297690923d7e393545dc648.tar.gz |
theme: don't load metacity theme when using GTK+ theme
All geometry/drawing information is now picked up from the GTK+ theme,
so replace the remaining bits (hide_buttons + title_scale) with
hardcoded values from the default Adwaita theme.
If there is a need to theme those constants again in the future,
we should make them available from GTK+ where they are available
for client-side decorations as well. They certainly don't justify
maintaining support for a complex theme format.
Based on mutter commit:
https://git.gnome.org/browse/mutter/commit/?id=d5e6177900f5cdf90bb3ba86603d6b6ff0a919f7
-rw-r--r-- | src/ui/theme.c | 94 |
1 files changed, 91 insertions, 3 deletions
diff --git a/src/ui/theme.c b/src/ui/theme.c index e875f0e8..00a14720 100644 --- a/src/ui/theme.c +++ b/src/ui/theme.c @@ -5350,9 +5350,9 @@ meta_theme_get_current (void) return meta_current_theme; } -void -meta_theme_set_current (const char *name, - gboolean force_reload) +static void +theme_set_current_metacity (const gchar *name, + gboolean force_reload) { MetaTheme *new_theme; GError *err; @@ -5384,6 +5384,94 @@ meta_theme_set_current (const char *name, } } +static void +theme_set_current_gtk (const gchar *name) +{ + int i, j, frame_type; + + meta_topic (META_DEBUG_THEMES, "Setting current theme to \"%s\"\n", name); + + if (meta_current_theme) + return; + meta_current_theme = meta_theme_new (); + + for (frame_type = 0; frame_type < META_FRAME_TYPE_LAST; frame_type++) + { + MetaFrameStyleSet *style_set = meta_frame_style_set_new (NULL); + MetaFrameStyle *style = meta_frame_style_new (NULL); + + style->layout = meta_frame_layout_new (); + + switch (frame_type) + { + case META_FRAME_TYPE_NORMAL: + break; + case META_FRAME_TYPE_DIALOG: + case META_FRAME_TYPE_MODAL_DIALOG: + case META_FRAME_TYPE_ATTACHED: + style->layout->hide_buttons = TRUE; + break; + case META_FRAME_TYPE_MENU: + case META_FRAME_TYPE_UTILITY: + style->layout->title_scale = PANGO_SCALE_SMALL; + break; + case META_FRAME_TYPE_BORDER: + style->layout->has_title = FALSE; + style->layout->hide_buttons = TRUE; + break; + default: + g_assert_not_reached (); + } + + for (i = 0; i < META_FRAME_FOCUS_LAST; i++) + { + for (j = 0; j < META_FRAME_RESIZE_LAST; j++) + { + meta_frame_style_ref (style); + style_set->normal_styles[j][i] = style; + + meta_frame_style_ref (style); + style_set->shaded_styles[j][i] = style; + } + + meta_frame_style_ref (style); + style_set->maximized_styles[i] = style; + + meta_frame_style_ref (style); + style_set->tiled_left_styles[i] = style; + + meta_frame_style_ref (style); + style_set->tiled_right_styles[i] = style; + + meta_frame_style_ref (style); + style_set->maximized_and_shaded_styles[i] = style; + + meta_frame_style_ref (style); + style_set->tiled_left_and_shaded_styles[i] = style; + + meta_frame_style_ref (style); + style_set->tiled_right_and_shaded_styles[i] = style; + } + + meta_frame_style_unref (style); + meta_current_theme->style_sets_by_type[frame_type] = style_set; + } +} + +void +meta_theme_set_current (const char *name, + gboolean force_reload) +{ + if (meta_prefs_get_theme ()) + { + theme_set_current_metacity (name, force_reload); + } + else + { + theme_set_current_gtk (name); + } +} + MetaTheme* meta_theme_new (void) { |