[metacity/wip/gtk-theme: 49/61] theme: Add titlebar_spacing
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity/wip/gtk-theme: 49/61] theme: Add titlebar_spacing
- Date: Tue, 20 Jan 2015 23:17:47 +0000 (UTC)
commit ff228822d761750391433a502b93594a93e65b58
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.
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 a45e524..156b23e 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -237,6 +237,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;
@@ -793,13 +797,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 (meta_prefs_get_theme ())
+ {
+ 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 (meta_prefs_get_theme ())
+ {
+ 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 */
@@ -896,7 +910,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 (meta_prefs_get_theme ())
+ 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);
@@ -914,7 +931,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 (meta_prefs_get_theme ())
+ 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
@@ -922,7 +944,15 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
*(right_bg_rects[i]) = rect->visible;
- x = rect->visible.x - layout->button_border.left;
+ if (meta_prefs_get_theme ())
+ x = rect->visible.x - layout->button_border.left;
+ else
+ {
+ x = rect->visible.x;
+
+ if (i > 0)
+ x -= layout->titlebar_spacing;
+ }
--i;
}
@@ -940,7 +970,10 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
rect = left_func_rects[i];
- rect->visible.x = x + layout->button_border.left;
+ if (meta_prefs_get_theme ())
+ 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;
@@ -955,7 +988,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 (meta_prefs_get_theme ())
+ 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 b4eca89..ffec77c 100644
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -131,6 +131,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]