[metacity/wip/gtk-theme: 13/51] theme: Add titlebar_spacing



commit 6d0f4b98ddc0c2989ad8425561370d6b463ea595
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Oct 1 05:44:19 2014 +0200

    theme: Add titlebar_spacing
    
    Rather than defining the space to the left and right of buttons, add a
    simple spacing property that defines the space between buttons, which is
    what GTK+ does for client-side decorations (e.g. GtkButtons in a GtkBox).
    Unfortunately the value is hardcoded in GTK+; if it is exposed in the
    theme in the future, we should pick it up from there, but for now we
    just use the same value as GTK+.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=741917
    
    NOTE: Updated for metacity in way it does not break existing themes.

 src/ui/theme.c |   58 +++++++++++++++++++++++++++++++++++++++++++++++--------
 src/ui/theme.h |    3 ++
 2 files changed, 52 insertions(+), 9 deletions(-)
---
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 3fff8db..ccc383c 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -231,6 +231,10 @@ meta_frame_layout_new  (void)
   layout->button_width = -1;
   layout->button_height = -1;
 
+  /* Spacing as hardcoded in GTK+:
+   * https://git.gnome.org/browse/gtk+/tree/gtk/gtkheaderbar.c?h=gtk-3-14#n53
+   */
+  layout->titlebar_spacing = 6;
   layout->has_title = TRUE;
   layout->title_scale = 1.0;
 
@@ -757,13 +761,23 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout  *layout,
 
       space_used_by_buttons += button_width * n_left;
       space_used_by_buttons += (button_width * 0.75) * n_left_spacers;
-      space_used_by_buttons += layout->button_border.left * n_left;
-      space_used_by_buttons += layout->button_border.right * n_left;
+      if (g_getenv ("USE_METACITY_THEME") != NULL)
+        {
+          space_used_by_buttons += layout->button_border.left * n_left;
+          space_used_by_buttons += layout->button_border.right * n_left;
+        }
+      else
+        space_used_by_buttons += layout->titlebar_spacing * MAX (n_left - 1, 0);
 
       space_used_by_buttons += button_width * n_right;
       space_used_by_buttons += (button_width * 0.75) * n_right_spacers;
-      space_used_by_buttons += layout->button_border.left * n_right;
-      space_used_by_buttons += layout->button_border.right * n_right;
+      if (g_getenv ("USE_METACITY_THEME") != NULL)
+        {
+          space_used_by_buttons += layout->button_border.left * n_right;
+          space_used_by_buttons += layout->button_border.right * n_right;
+        }
+      else
+        space_used_by_buttons += layout->titlebar_spacing * MAX (n_right - 1, 0);
 
       if (space_used_by_buttons <= space_available)
         break; /* Everything fits, bail out */
@@ -860,7 +874,10 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout  *layout,
         break;
 
       rect = right_func_rects[i];
-      rect->visible.x = x - layout->button_border.right - button_width;
+      if (g_getenv ("USE_METACITY_THEME") != NULL)
+        rect->visible.x = x - layout->button_border.right - button_width;
+      else
+        rect->visible.x = x - button_width;
       if (right_buttons_has_spacer[i])
         rect->visible.x -= (button_width * 0.75);
 
@@ -878,7 +895,12 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout  *layout,
           rect->clickable.height = button_height;
 
           if (i == n_right - 1)
-            rect->clickable.width += layout->right_titlebar_edge + layout->right_width + 
layout->button_border.right;
+            {
+              if (g_getenv ("USE_METACITY_THEME") != NULL)
+                rect->clickable.width += layout->right_titlebar_edge + layout->right_width + 
layout->button_border.right;
+              else
+                rect->clickable.width += layout->right_titlebar_edge + layout->right_width;
+            }
 
         }
       else
@@ -886,7 +908,15 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout  *layout,
 
       *(right_bg_rects[i]) = rect->visible;
 
-      x = rect->visible.x - layout->button_border.left;
+      if (g_getenv ("USE_METACITY_THEME") != NULL)
+        x = rect->visible.x - layout->button_border.left;
+      else
+        {
+          x = rect->visible.x;
+
+          if (i > 0)
+            x -= layout->titlebar_spacing;
+        }
 
       --i;
     }
@@ -904,7 +934,10 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout  *layout,
 
       rect = left_func_rects[i];
 
-      rect->visible.x = x + layout->button_border.left;
+      if (g_getenv ("USE_METACITY_THEME") != NULL)
+        rect->visible.x = x + layout->button_border.left;
+      else
+        rect->visible.x = x;
       rect->visible.y = button_y;
       rect->visible.width = button_width;
       rect->visible.height = button_height;
@@ -919,7 +952,14 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout  *layout,
       else
         g_memmove (&(rect->clickable), &(rect->visible), sizeof(rect->clickable));
 
-      x = rect->visible.x + rect->visible.width + layout->button_border.right;
+      if (g_getenv ("USE_METACITY_THEME") != NULL)
+        x = rect->visible.x + rect->visible.width + layout->button_border.right;
+      else
+        {
+          x = rect->visible.x + rect->visible.width;
+          if (i < n_left - 1)
+            x += layout->titlebar_spacing;
+        }
       if (left_buttons_has_spacer[i])
         x += (button_width * 0.75);
 
diff --git a/src/ui/theme.h b/src/ui/theme.h
index 5dc5028..eb766fd 100644
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -176,6 +176,9 @@ struct _MetaFrameLayout
   /** Space around buttons */
   GtkBorder button_border;
 
+  /** Space between titlebar elements */
+  guint titlebar_spacing;
+
   /** scale factor for title text */
   double title_scale;
 


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