[metacity/wip/gtk-theme: 43/51] theme: Don't load metacity themes



commit 8f9f823096913600b8849bc9db212d0a842f46d2
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Sep 25 16:58:20 2014 +0100

    theme: Don't load metacity themes
    
    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 and stop loading
    the metacity theme altogether.
    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.
    
    NOTE: Updated for metacity in way it does not break existing themes.
    Title is kept from original commit, but is wrong for metacity.
    Metacity are still able to use old themes.

 src/ui/theme.c |   95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 92 insertions(+), 3 deletions(-)
---
diff --git a/src/ui/theme.c b/src/ui/theme.c
index b54e147..87822c8 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -5419,9 +5419,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;
@@ -5453,6 +5453,95 @@ meta_theme_set_current (const char *name,
     }
 }
 
+static void
+theme_set_current_gtk (const gchar *name,
+                       gboolean     force_reload)
+{
+  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 (g_getenv ("USE_METACITY_THEME") != NULL)
+    {
+      theme_set_current_metacity (name, force_reload);
+    }
+  else
+    {
+      theme_set_current_gtk (name, force_reload);
+    }
+}
+
 MetaTheme*
 meta_theme_new (void)
 {


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