summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberts Muktupāvels <alberts.muktupavels@gmail.com>2015-01-21 00:43:59 +0200
committerAlberts Muktupāvels <alberts.muktupavels@gmail.com>2015-02-19 23:24:20 +0200
commitae2c693d88ffea50a6020934399a55fa026e034a (patch)
tree5516338373c7a4b03be186e9b36f9090c25a81de
parent87e07ac5ee2f2545ca816fcb65ab91d138c44d5f (diff)
downloadmetacity-ae2c693d88ffea50a6020934399a55fa026e034a.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.c94
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)
{