[metacity/wip/gtk-theme: 58/61] theme: don't load metacity theme when using GTK+ theme



commit 7c43096ce6d0e0b3b5cff79710fc6c32ce5f6d50
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Wed Jan 21 00:43:59 2015 +0200

    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

 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 250d271..ced1260 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -5364,9 +5364,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;
@@ -5398,6 +5398,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)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]