[metacity] libmetacity: don't expose MetaButtonType
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] libmetacity: don't expose MetaButtonType
- Date: Thu, 18 Aug 2016 11:44:08 +0000 (UTC)
commit 5318cdbf7e16a454f3b685f5ddd5a36a1d072772
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Tue Aug 16 16:50:41 2016 +0300
libmetacity: don't expose MetaButtonType
libmetacity/Makefile.am | 1 +
libmetacity/meta-button-enums.h | 25 ----
libmetacity/meta-button-type-private.h | 52 ++++++++
libmetacity/meta-frame-style-private.h | 1 +
libmetacity/meta-theme-gtk.c | 112 ++++++++++++-----
libmetacity/meta-theme-impl-private.h | 14 +--
libmetacity/meta-theme-impl.c | 190 -----------------------------
libmetacity/meta-theme-metacity-private.h | 2 +-
libmetacity/meta-theme-metacity.c | 177 ++++++++++++++++++++++++++-
libmetacity/meta-theme.c | 2 +-
libmetacity/meta-theme.h | 2 +-
src/ui/frames.c | 52 ++++----
theme-viewer/theme-viewer-window.c | 32 +++---
13 files changed, 357 insertions(+), 305 deletions(-)
---
diff --git a/libmetacity/Makefile.am b/libmetacity/Makefile.am
index 4a81e2d..b355067 100644
--- a/libmetacity/Makefile.am
+++ b/libmetacity/Makefile.am
@@ -8,6 +8,7 @@ libmetacity_la_SOURCES = \
meta-button-function.h \
meta-button-layout.c \
meta-button-layout.h \
+ meta-button-type-private.h \
meta-color.c \
meta-color.h \
meta-color-private.h \
diff --git a/libmetacity/meta-button-enums.h b/libmetacity/meta-button-enums.h
index dd133cb..fe57829 100644
--- a/libmetacity/meta-button-enums.h
+++ b/libmetacity/meta-button-enums.h
@@ -30,31 +30,6 @@ typedef enum
META_BUTTON_STATE_LAST
} MetaButtonState;
-typedef enum
-{
- /* Ordered so that background is drawn first */
- META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND,
- META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND,
- META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND,
- META_BUTTON_TYPE_LEFT_SINGLE_BACKGROUND,
- META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND,
- META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND,
- META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND,
- META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND,
- META_BUTTON_TYPE_CLOSE,
- META_BUTTON_TYPE_MAXIMIZE,
- META_BUTTON_TYPE_MINIMIZE,
- META_BUTTON_TYPE_MENU,
- META_BUTTON_TYPE_APPMENU,
- META_BUTTON_TYPE_SHADE,
- META_BUTTON_TYPE_ABOVE,
- META_BUTTON_TYPE_STICK,
- META_BUTTON_TYPE_UNSHADE,
- META_BUTTON_TYPE_UNABOVE,
- META_BUTTON_TYPE_UNSTICK,
- META_BUTTON_TYPE_LAST
-} MetaButtonType;
-
G_END_DECLS
#endif
diff --git a/libmetacity/meta-button-type-private.h b/libmetacity/meta-button-type-private.h
new file mode 100644
index 0000000..22f90d5
--- /dev/null
+++ b/libmetacity/meta-button-type-private.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2001 Havoc Pennington
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef META_BUTTON_TYPE_PRIVATE_H
+#define META_BUTTON_TYPE_PRIVATE_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef enum
+{
+ /* Ordered so that background is drawn first */
+ META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND,
+ META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND,
+ META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND,
+ META_BUTTON_TYPE_LEFT_SINGLE_BACKGROUND,
+ META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND,
+ META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND,
+ META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND,
+ META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND,
+ META_BUTTON_TYPE_CLOSE,
+ META_BUTTON_TYPE_MAXIMIZE,
+ META_BUTTON_TYPE_MINIMIZE,
+ META_BUTTON_TYPE_MENU,
+ META_BUTTON_TYPE_APPMENU,
+ META_BUTTON_TYPE_SHADE,
+ META_BUTTON_TYPE_ABOVE,
+ META_BUTTON_TYPE_STICK,
+ META_BUTTON_TYPE_UNSHADE,
+ META_BUTTON_TYPE_UNABOVE,
+ META_BUTTON_TYPE_UNSTICK,
+ META_BUTTON_TYPE_LAST
+} MetaButtonType;
+
+G_END_DECLS
+
+#endif
diff --git a/libmetacity/meta-frame-style-private.h b/libmetacity/meta-frame-style-private.h
index 2769cc0..01d2489 100644
--- a/libmetacity/meta-frame-style-private.h
+++ b/libmetacity/meta-frame-style-private.h
@@ -20,6 +20,7 @@
#define META_FRAME_STYLE_PRIVATE_H
#include "meta-button-enums.h"
+#include "meta-button-type-private.h"
#include "meta-color-spec-private.h"
#include "meta-draw-op-private.h"
#include "meta-frame-enums.h"
diff --git a/libmetacity/meta-theme-gtk.c b/libmetacity/meta-theme-gtk.c
index 33e7052..708526d 100644
--- a/libmetacity/meta-theme-gtk.c
+++ b/libmetacity/meta-theme-gtk.c
@@ -721,19 +721,77 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl *impl,
}
static const char *
-get_class_from_button_type (MetaButtonType type)
+get_class_from_button_function (MetaButtonFunction function)
{
- if (type == META_BUTTON_TYPE_CLOSE)
+ if (function == META_BUTTON_FUNCTION_CLOSE)
return "close";
- else if (type == META_BUTTON_TYPE_MAXIMIZE)
+ else if (function == META_BUTTON_FUNCTION_MAXIMIZE)
return "maximize";
- else if (type == META_BUTTON_TYPE_MINIMIZE)
+ else if (function == META_BUTTON_FUNCTION_MINIMIZE)
return "minimize";
return NULL;
}
static void
+get_button_rect (MetaButtonFunction function,
+ const MetaFrameGeometry *fgeom,
+ GdkRectangle *rect)
+{
+ switch (function)
+ {
+ case META_BUTTON_FUNCTION_CLOSE:
+ *rect = fgeom->close_rect.visible;
+ break;
+
+ case META_BUTTON_FUNCTION_SHADE:
+ *rect = fgeom->shade_rect.visible;
+ break;
+
+ case META_BUTTON_FUNCTION_UNSHADE:
+ *rect = fgeom->unshade_rect.visible;
+ break;
+
+ case META_BUTTON_FUNCTION_ABOVE:
+ *rect = fgeom->above_rect.visible;
+ break;
+
+ case META_BUTTON_FUNCTION_UNABOVE:
+ *rect = fgeom->unabove_rect.visible;
+ break;
+
+ case META_BUTTON_FUNCTION_STICK:
+ *rect = fgeom->stick_rect.visible;
+ break;
+
+ case META_BUTTON_FUNCTION_UNSTICK:
+ *rect = fgeom->unstick_rect.visible;
+ break;
+
+ case META_BUTTON_FUNCTION_MAXIMIZE:
+ *rect = fgeom->max_rect.visible;
+ break;
+
+ case META_BUTTON_FUNCTION_MINIMIZE:
+ *rect = fgeom->min_rect.visible;
+ break;
+
+ case META_BUTTON_FUNCTION_MENU:
+ *rect = fgeom->menu_rect.visible;
+ break;
+
+ case META_BUTTON_FUNCTION_APPMENU:
+ *rect = fgeom->appmenu_rect.visible;
+ break;
+
+ case META_BUTTON_FUNCTION_LAST:
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
+static void
meta_theme_gtk_draw_frame (MetaThemeImpl *impl,
MetaFrameStyle *style,
MetaStyleInfo *style_info,
@@ -741,14 +799,14 @@ meta_theme_gtk_draw_frame (MetaThemeImpl *impl,
const MetaFrameGeometry *fgeom,
PangoLayout *title_layout,
MetaFrameFlags flags,
- MetaButtonState button_states[META_BUTTON_TYPE_LAST],
+ MetaButtonState button_states[META_BUTTON_FUNCTION_LAST],
GdkPixbuf *mini_icon,
GdkPixbuf *icon)
{
gdouble scale;
GtkStyleContext *context;
GtkStateFlags state;
- MetaButtonType button_type;
+ MetaButtonFunction button_function;
MetaRectangleDouble visible_rect;
MetaRectangleDouble titlebar_rect;
const MetaFrameBorders *borders;
@@ -828,19 +886,19 @@ meta_theme_gtk_draw_frame (MetaThemeImpl *impl,
context = meta_style_info_get_style (style_info, META_STYLE_ELEMENT_BUTTON);
state = gtk_style_context_get_state (context);
- for (button_type = META_BUTTON_TYPE_CLOSE; button_type < META_BUTTON_TYPE_LAST; button_type++)
+ for (button_function = 0; button_function < META_BUTTON_FUNCTION_LAST; button_function++)
{
MetaButtonState button_state;
const char *button_class;
GdkRectangle tmp_rect;
MetaRectangleDouble button_rect;
- button_class = get_class_from_button_type (button_type);
+ button_class = get_class_from_button_function (button_function);
if (button_class)
gtk_style_context_add_class (context, button_class);
- button_state = map_button_state (button_type, fgeom, 0, button_states);
+ button_state = button_states [button_function];
if (button_state == META_BUTTON_STATE_PRELIGHT)
gtk_style_context_set_state (context, state | GTK_STATE_PRELIGHT);
@@ -851,7 +909,7 @@ meta_theme_gtk_draw_frame (MetaThemeImpl *impl,
cairo_save (cr);
- get_button_rect (button_type, fgeom, 0, &tmp_rect);
+ get_button_rect (button_function, fgeom, &tmp_rect);
button_rect.x = tmp_rect.x / scale;
button_rect.y = tmp_rect.y / scale;
@@ -870,41 +928,33 @@ meta_theme_gtk_draw_frame (MetaThemeImpl *impl,
button_rect.x, button_rect.y,
button_rect.width, button_rect.height);
- switch (button_type)
+ switch (button_function)
{
- case META_BUTTON_TYPE_CLOSE:
+ case META_BUTTON_FUNCTION_CLOSE:
icon_name = "window-close-symbolic";
break;
- case META_BUTTON_TYPE_MAXIMIZE:
+ case META_BUTTON_FUNCTION_MAXIMIZE:
if (flags & META_FRAME_MAXIMIZED)
icon_name = "window-restore-symbolic";
else
icon_name = "window-maximize-symbolic";
break;
- case META_BUTTON_TYPE_MINIMIZE:
+ case META_BUTTON_FUNCTION_MINIMIZE:
icon_name = "window-minimize-symbolic";
break;
- case META_BUTTON_TYPE_MENU:
+ case META_BUTTON_FUNCTION_MENU:
icon_name = "open-menu-symbolic";
break;
- case META_BUTTON_TYPE_APPMENU:
+ case META_BUTTON_FUNCTION_APPMENU:
pixbuf = g_object_ref (mini_icon);
break;
- case META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND:
- case META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND:
- case META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND:
- case META_BUTTON_TYPE_LEFT_SINGLE_BACKGROUND:
- case META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND:
- case META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND:
- case META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND:
- case META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND:
- case META_BUTTON_TYPE_SHADE:
- case META_BUTTON_TYPE_ABOVE:
- case META_BUTTON_TYPE_STICK:
- case META_BUTTON_TYPE_UNSHADE:
- case META_BUTTON_TYPE_UNABOVE:
- case META_BUTTON_TYPE_UNSTICK:
- case META_BUTTON_TYPE_LAST:
+ case META_BUTTON_FUNCTION_SHADE:
+ case META_BUTTON_FUNCTION_ABOVE:
+ case META_BUTTON_FUNCTION_STICK:
+ case META_BUTTON_FUNCTION_UNSHADE:
+ case META_BUTTON_FUNCTION_UNABOVE:
+ case META_BUTTON_FUNCTION_UNSTICK:
+ case META_BUTTON_FUNCTION_LAST:
default:
icon_name = NULL;
break;
diff --git a/libmetacity/meta-theme-impl-private.h b/libmetacity/meta-theme-impl-private.h
index 00ec269..0144f79 100644
--- a/libmetacity/meta-theme-impl-private.h
+++ b/libmetacity/meta-theme-impl-private.h
@@ -67,7 +67,7 @@ struct _MetaThemeImplClass
const MetaFrameGeometry *fgeom,
PangoLayout *title_layout,
MetaFrameFlags flags,
- MetaButtonState button_states[META_BUTTON_TYPE_LAST],
+ MetaButtonState button_states[META_BUTTON_FUNCTION_LAST],
GdkPixbuf *mini_icon,
GdkPixbuf *icon);
};
@@ -89,18 +89,6 @@ MetaFrameStyleSet *meta_theme_impl_get_style_set (MetaThemeImpl *impl
MetaFrameType type);
G_GNUC_INTERNAL
-void get_button_rect (MetaButtonType type,
- const MetaFrameGeometry *fgeom,
- gint middle_background_offset,
- GdkRectangle *rect);
-
-G_GNUC_INTERNAL
-MetaButtonState map_button_state (MetaButtonType button_type,
- const MetaFrameGeometry *fgeom,
- gint middle_bg_offset,
- MetaButtonState
button_states[META_BUTTON_TYPE_LAST]);
-
-G_GNUC_INTERNAL
void scale_border (GtkBorder *border,
double factor);
diff --git a/libmetacity/meta-theme-impl.c b/libmetacity/meta-theme-impl.c
index aed2c48..f5583ba 100644
--- a/libmetacity/meta-theme-impl.c
+++ b/libmetacity/meta-theme-impl.c
@@ -31,42 +31,6 @@ typedef struct
G_DEFINE_TYPE_WITH_PRIVATE (MetaThemeImpl, meta_theme_impl, G_TYPE_OBJECT)
-static MetaButtonType
-map_button_function_to_type (MetaButtonFunction function)
-{
- switch (function)
- {
- case META_BUTTON_FUNCTION_SHADE:
- return META_BUTTON_TYPE_SHADE;
- case META_BUTTON_FUNCTION_ABOVE:
- return META_BUTTON_TYPE_ABOVE;
- case META_BUTTON_FUNCTION_STICK:
- return META_BUTTON_TYPE_STICK;
- case META_BUTTON_FUNCTION_UNSHADE:
- return META_BUTTON_TYPE_UNSHADE;
- case META_BUTTON_FUNCTION_UNABOVE:
- return META_BUTTON_TYPE_UNABOVE;
- case META_BUTTON_FUNCTION_UNSTICK:
- return META_BUTTON_TYPE_UNSTICK;
- case META_BUTTON_FUNCTION_MENU:
- return META_BUTTON_TYPE_MENU;
- case META_BUTTON_FUNCTION_APPMENU:
- return META_BUTTON_TYPE_APPMENU;
- case META_BUTTON_FUNCTION_MINIMIZE:
- return META_BUTTON_TYPE_MINIMIZE;
- case META_BUTTON_FUNCTION_MAXIMIZE:
- return META_BUTTON_TYPE_MAXIMIZE;
- case META_BUTTON_FUNCTION_CLOSE:
- return META_BUTTON_TYPE_CLOSE;
- case META_BUTTON_FUNCTION_LAST:
- return META_BUTTON_TYPE_LAST;
- default:
- break;
- }
-
- return META_BUTTON_TYPE_LAST;
-}
-
static void
meta_theme_impl_dispose (GObject *object)
{
@@ -168,160 +132,6 @@ meta_theme_impl_get_style_set (MetaThemeImpl *impl,
}
void
-get_button_rect (MetaButtonType type,
- const MetaFrameGeometry *fgeom,
- gint middle_background_offset,
- GdkRectangle *rect)
-{
- switch (type)
- {
- case META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND:
- *rect = fgeom->left_left_background;
- break;
-
- case META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND:
- *rect = fgeom->left_middle_backgrounds[middle_background_offset];
- break;
-
- case META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND:
- *rect = fgeom->left_right_background;
- break;
-
- case META_BUTTON_TYPE_LEFT_SINGLE_BACKGROUND:
- *rect = fgeom->left_single_background;
- break;
-
- case META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND:
- *rect = fgeom->right_left_background;
- break;
-
- case META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND:
- *rect = fgeom->right_middle_backgrounds[middle_background_offset];
- break;
-
- case META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND:
- *rect = fgeom->right_right_background;
- break;
-
- case META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND:
- *rect = fgeom->right_single_background;
- break;
-
- case META_BUTTON_TYPE_CLOSE:
- *rect = fgeom->close_rect.visible;
- break;
-
- case META_BUTTON_TYPE_SHADE:
- *rect = fgeom->shade_rect.visible;
- break;
-
- case META_BUTTON_TYPE_UNSHADE:
- *rect = fgeom->unshade_rect.visible;
- break;
-
- case META_BUTTON_TYPE_ABOVE:
- *rect = fgeom->above_rect.visible;
- break;
-
- case META_BUTTON_TYPE_UNABOVE:
- *rect = fgeom->unabove_rect.visible;
- break;
-
- case META_BUTTON_TYPE_STICK:
- *rect = fgeom->stick_rect.visible;
- break;
-
- case META_BUTTON_TYPE_UNSTICK:
- *rect = fgeom->unstick_rect.visible;
- break;
-
- case META_BUTTON_TYPE_MAXIMIZE:
- *rect = fgeom->max_rect.visible;
- break;
-
- case META_BUTTON_TYPE_MINIMIZE:
- *rect = fgeom->min_rect.visible;
- break;
-
- case META_BUTTON_TYPE_MENU:
- *rect = fgeom->menu_rect.visible;
- break;
-
- case META_BUTTON_TYPE_APPMENU:
- *rect = fgeom->appmenu_rect.visible;
- break;
-
- case META_BUTTON_TYPE_LAST:
- default:
- g_assert_not_reached ();
- break;
- }
-}
-
-MetaButtonState
-map_button_state (MetaButtonType button_type,
- const MetaFrameGeometry *fgeom,
- gint middle_bg_offset,
- MetaButtonState button_states[META_BUTTON_TYPE_LAST])
-{
- MetaButtonFunction function = META_BUTTON_FUNCTION_LAST;
-
- switch (button_type)
- {
- /* First handle functions, which map directly */
- case META_BUTTON_TYPE_SHADE:
- case META_BUTTON_TYPE_ABOVE:
- case META_BUTTON_TYPE_STICK:
- case META_BUTTON_TYPE_UNSHADE:
- case META_BUTTON_TYPE_UNABOVE:
- case META_BUTTON_TYPE_UNSTICK:
- case META_BUTTON_TYPE_MENU:
- case META_BUTTON_TYPE_APPMENU:
- case META_BUTTON_TYPE_MINIMIZE:
- case META_BUTTON_TYPE_MAXIMIZE:
- case META_BUTTON_TYPE_CLOSE:
- return button_states[button_type];
-
- /* Map position buttons to the corresponding function */
- case META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND:
- case META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND:
- if (fgeom->n_right_buttons > 0)
- function = fgeom->button_layout.right_buttons[0];
- break;
- case META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND:
- if (fgeom->n_right_buttons > 0)
- function = fgeom->button_layout.right_buttons[fgeom->n_right_buttons - 1];
- break;
- case META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND:
- if (middle_bg_offset + 1 < fgeom->n_right_buttons)
- function = fgeom->button_layout.right_buttons[middle_bg_offset + 1];
- break;
- case META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND:
- case META_BUTTON_TYPE_LEFT_SINGLE_BACKGROUND:
- if (fgeom->n_left_buttons > 0)
- function = fgeom->button_layout.left_buttons[0];
- break;
- case META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND:
- if (fgeom->n_left_buttons > 0)
- function = fgeom->button_layout.left_buttons[fgeom->n_left_buttons - 1];
- break;
- case META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND:
- if (middle_bg_offset + 1 < fgeom->n_left_buttons)
- function = fgeom->button_layout.left_buttons[middle_bg_offset + 1];
- break;
- case META_BUTTON_TYPE_LAST:
- break;
- default:
- break;
- }
-
- if (function != META_BUTTON_FUNCTION_LAST)
- return button_states[map_button_function_to_type (function)];
-
- return META_BUTTON_STATE_LAST;
-}
-
-void
scale_border (GtkBorder *border,
double factor)
{
diff --git a/libmetacity/meta-theme-metacity-private.h b/libmetacity/meta-theme-metacity-private.h
index e4d726d..9b8c830 100644
--- a/libmetacity/meta-theme-metacity-private.h
+++ b/libmetacity/meta-theme-metacity-private.h
@@ -19,7 +19,7 @@
#ifndef META_THEME_METACITY_PRIVATE_H
#define META_THEME_METACITY_PRIVATE_H
-#include "meta-button-enums.h"
+#include "meta-button-type-private.h"
#include "meta-theme-impl-private.h"
G_BEGIN_DECLS
diff --git a/libmetacity/meta-theme-metacity.c b/libmetacity/meta-theme-metacity.c
index c16cd29..51a5d40 100644
--- a/libmetacity/meta-theme-metacity.c
+++ b/libmetacity/meta-theme-metacity.c
@@ -5288,6 +5288,181 @@ clip_to_rounded_corners (cairo_t *cr,
}
static void
+get_button_rect (MetaButtonType type,
+ const MetaFrameGeometry *fgeom,
+ gint middle_background_offset,
+ GdkRectangle *rect)
+{
+ switch (type)
+ {
+ case META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND:
+ *rect = fgeom->left_left_background;
+ break;
+
+ case META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND:
+ *rect = fgeom->left_middle_backgrounds[middle_background_offset];
+ break;
+
+ case META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND:
+ *rect = fgeom->left_right_background;
+ break;
+
+ case META_BUTTON_TYPE_LEFT_SINGLE_BACKGROUND:
+ *rect = fgeom->left_single_background;
+ break;
+
+ case META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND:
+ *rect = fgeom->right_left_background;
+ break;
+
+ case META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND:
+ *rect = fgeom->right_middle_backgrounds[middle_background_offset];
+ break;
+
+ case META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND:
+ *rect = fgeom->right_right_background;
+ break;
+
+ case META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND:
+ *rect = fgeom->right_single_background;
+ break;
+
+ case META_BUTTON_TYPE_CLOSE:
+ *rect = fgeom->close_rect.visible;
+ break;
+
+ case META_BUTTON_TYPE_SHADE:
+ *rect = fgeom->shade_rect.visible;
+ break;
+
+ case META_BUTTON_TYPE_UNSHADE:
+ *rect = fgeom->unshade_rect.visible;
+ break;
+
+ case META_BUTTON_TYPE_ABOVE:
+ *rect = fgeom->above_rect.visible;
+ break;
+
+ case META_BUTTON_TYPE_UNABOVE:
+ *rect = fgeom->unabove_rect.visible;
+ break;
+
+ case META_BUTTON_TYPE_STICK:
+ *rect = fgeom->stick_rect.visible;
+ break;
+
+ case META_BUTTON_TYPE_UNSTICK:
+ *rect = fgeom->unstick_rect.visible;
+ break;
+
+ case META_BUTTON_TYPE_MAXIMIZE:
+ *rect = fgeom->max_rect.visible;
+ break;
+
+ case META_BUTTON_TYPE_MINIMIZE:
+ *rect = fgeom->min_rect.visible;
+ break;
+
+ case META_BUTTON_TYPE_MENU:
+ *rect = fgeom->menu_rect.visible;
+ break;
+
+ case META_BUTTON_TYPE_APPMENU:
+ *rect = fgeom->appmenu_rect.visible;
+ break;
+
+ case META_BUTTON_TYPE_LAST:
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
+static MetaButtonState
+map_button_state (MetaButtonType button_type,
+ const MetaFrameGeometry *fgeom,
+ gint middle_bg_offset,
+ MetaButtonState button_states[META_BUTTON_FUNCTION_LAST])
+{
+ MetaButtonFunction function = META_BUTTON_FUNCTION_LAST;
+
+ switch (button_type)
+ {
+ /* First handle functions, which map directly */
+ case META_BUTTON_TYPE_SHADE:
+ function = META_BUTTON_FUNCTION_SHADE;
+ break;
+ case META_BUTTON_TYPE_ABOVE:
+ function = META_BUTTON_FUNCTION_ABOVE;
+ break;
+ case META_BUTTON_TYPE_STICK:
+ function = META_BUTTON_FUNCTION_STICK;
+ break;
+ case META_BUTTON_TYPE_UNSHADE:
+ function = META_BUTTON_FUNCTION_UNSHADE;
+ break;
+ case META_BUTTON_TYPE_UNABOVE:
+ function = META_BUTTON_FUNCTION_UNABOVE;
+ break;;
+ case META_BUTTON_TYPE_UNSTICK:
+ function = META_BUTTON_FUNCTION_UNSTICK;
+ break;
+ case META_BUTTON_TYPE_MENU:
+ function = META_BUTTON_FUNCTION_MENU;
+ break;
+ case META_BUTTON_TYPE_APPMENU:
+ function = META_BUTTON_FUNCTION_APPMENU;
+ break;
+ case META_BUTTON_TYPE_MINIMIZE:
+ function = META_BUTTON_FUNCTION_MINIMIZE;
+ break;
+ case META_BUTTON_TYPE_MAXIMIZE:
+ function = META_BUTTON_FUNCTION_MAXIMIZE;
+ break;
+ case META_BUTTON_TYPE_CLOSE:
+ function = META_BUTTON_FUNCTION_CLOSE;
+ break;
+
+ /* Map position buttons to the corresponding function */
+ case META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND:
+ case META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND:
+ if (fgeom->n_right_buttons > 0)
+ function = fgeom->button_layout.right_buttons[0];
+ break;
+ case META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND:
+ if (fgeom->n_right_buttons > 0)
+ function = fgeom->button_layout.right_buttons[fgeom->n_right_buttons - 1];
+ break;
+ case META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND:
+ if (middle_bg_offset + 1 < fgeom->n_right_buttons)
+ function = fgeom->button_layout.right_buttons[middle_bg_offset + 1];
+ break;
+ case META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND:
+ case META_BUTTON_TYPE_LEFT_SINGLE_BACKGROUND:
+ if (fgeom->n_left_buttons > 0)
+ function = fgeom->button_layout.left_buttons[0];
+ break;
+ case META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND:
+ if (fgeom->n_left_buttons > 0)
+ function = fgeom->button_layout.left_buttons[fgeom->n_left_buttons - 1];
+ break;
+ case META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND:
+ if (middle_bg_offset + 1 < fgeom->n_left_buttons)
+ function = fgeom->button_layout.left_buttons[middle_bg_offset + 1];
+ break;
+ case META_BUTTON_TYPE_LAST:
+ break;
+ default:
+ break;
+ }
+
+ if (function != META_BUTTON_FUNCTION_LAST)
+ return button_states[function];
+
+ return META_BUTTON_STATE_LAST;
+}
+
+static void
meta_theme_metacity_draw_frame (MetaThemeImpl *impl,
MetaFrameStyle *style,
MetaStyleInfo *style_info,
@@ -5295,7 +5470,7 @@ meta_theme_metacity_draw_frame (MetaThemeImpl *impl,
const MetaFrameGeometry *fgeom,
PangoLayout *title_layout,
MetaFrameFlags flags,
- MetaButtonState button_states[META_BUTTON_TYPE_LAST],
+ MetaButtonState button_states[META_BUTTON_FUNCTION_LAST],
GdkPixbuf *mini_icon,
GdkPixbuf *icon)
{
diff --git a/libmetacity/meta-theme.c b/libmetacity/meta-theme.c
index 17e96c1..3643b51 100644
--- a/libmetacity/meta-theme.c
+++ b/libmetacity/meta-theme.c
@@ -655,7 +655,7 @@ meta_theme_draw_frame (MetaTheme *theme,
gint client_width,
gint client_height,
const gchar *title,
- MetaButtonState button_states[META_BUTTON_TYPE_LAST],
+ MetaButtonState button_states[META_BUTTON_FUNCTION_LAST],
GdkPixbuf *mini_icon,
GdkPixbuf *icon)
{
diff --git a/libmetacity/meta-theme.h b/libmetacity/meta-theme.h
index bc2fa21..d515f89 100644
--- a/libmetacity/meta-theme.h
+++ b/libmetacity/meta-theme.h
@@ -186,7 +186,7 @@ void meta_theme_draw_frame (MetaTheme *theme,
gint client_width,
gint client_height,
const gchar *title,
- MetaButtonState
button_states[META_BUTTON_TYPE_LAST],
+ MetaButtonState
button_states[META_BUTTON_FUNCTION_LAST],
GdkPixbuf *mini_icon,
GdkPixbuf *icon);
diff --git a/src/ui/frames.c b/src/ui/frames.c
index dfa7011..c37a09a 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -2278,12 +2278,12 @@ meta_frames_paint (MetaFrames *frames,
GdkPixbuf *mini_icon;
GdkPixbuf *icon;
int w, h;
- MetaButtonState button_states[META_BUTTON_TYPE_LAST];
+ MetaButtonState button_states[META_BUTTON_FUNCTION_LAST];
Window grab_frame;
int i;
MetaGrabOp grab_op;
- for (i = 0; i < META_BUTTON_TYPE_LAST; i++)
+ for (i = 0; i < META_BUTTON_FUNCTION_LAST; i++)
button_states[i] = META_BUTTON_STATE_NORMAL;
grab_frame = meta_core_get_grab_frame (frames->xdisplay);
@@ -2296,75 +2296,75 @@ meta_frames_paint (MetaFrames *frames,
{
case META_FRAME_CONTROL_MENU:
if (grab_op == META_GRAB_OP_CLICKING_MENU)
- button_states[META_BUTTON_TYPE_MENU] = META_BUTTON_STATE_PRESSED;
+ button_states[META_BUTTON_FUNCTION_MENU] = META_BUTTON_STATE_PRESSED;
else
- button_states[META_BUTTON_TYPE_MENU] = META_BUTTON_STATE_PRELIGHT;
+ button_states[META_BUTTON_FUNCTION_MENU] = META_BUTTON_STATE_PRELIGHT;
break;
case META_FRAME_CONTROL_APPMENU:
if (grab_op == META_GRAB_OP_CLICKING_MENU)
- button_states[META_BUTTON_TYPE_APPMENU] = META_BUTTON_STATE_PRESSED;
+ button_states[META_BUTTON_FUNCTION_APPMENU] = META_BUTTON_STATE_PRESSED;
else
- button_states[META_BUTTON_TYPE_APPMENU] = META_BUTTON_STATE_PRELIGHT;
+ button_states[META_BUTTON_FUNCTION_APPMENU] = META_BUTTON_STATE_PRELIGHT;
break;
case META_FRAME_CONTROL_MINIMIZE:
if (grab_op == META_GRAB_OP_CLICKING_MINIMIZE)
- button_states[META_BUTTON_TYPE_MINIMIZE] = META_BUTTON_STATE_PRESSED;
+ button_states[META_BUTTON_FUNCTION_MINIMIZE] = META_BUTTON_STATE_PRESSED;
else
- button_states[META_BUTTON_TYPE_MINIMIZE] = META_BUTTON_STATE_PRELIGHT;
+ button_states[META_BUTTON_FUNCTION_MINIMIZE] = META_BUTTON_STATE_PRELIGHT;
break;
case META_FRAME_CONTROL_MAXIMIZE:
if (grab_op == META_GRAB_OP_CLICKING_MAXIMIZE)
- button_states[META_BUTTON_TYPE_MAXIMIZE] = META_BUTTON_STATE_PRESSED;
+ button_states[META_BUTTON_FUNCTION_MAXIMIZE] = META_BUTTON_STATE_PRESSED;
else
- button_states[META_BUTTON_TYPE_MAXIMIZE] = META_BUTTON_STATE_PRELIGHT;
+ button_states[META_BUTTON_FUNCTION_MAXIMIZE] = META_BUTTON_STATE_PRELIGHT;
break;
case META_FRAME_CONTROL_UNMAXIMIZE:
if (grab_op == META_GRAB_OP_CLICKING_UNMAXIMIZE)
- button_states[META_BUTTON_TYPE_MAXIMIZE] = META_BUTTON_STATE_PRESSED;
+ button_states[META_BUTTON_FUNCTION_MAXIMIZE] = META_BUTTON_STATE_PRESSED;
else
- button_states[META_BUTTON_TYPE_MAXIMIZE] = META_BUTTON_STATE_PRELIGHT;
+ button_states[META_BUTTON_FUNCTION_MAXIMIZE] = META_BUTTON_STATE_PRELIGHT;
break;
case META_FRAME_CONTROL_SHADE:
if (grab_op == META_GRAB_OP_CLICKING_SHADE)
- button_states[META_BUTTON_TYPE_SHADE] = META_BUTTON_STATE_PRESSED;
+ button_states[META_BUTTON_FUNCTION_SHADE] = META_BUTTON_STATE_PRESSED;
else
- button_states[META_BUTTON_TYPE_SHADE] = META_BUTTON_STATE_PRELIGHT;
+ button_states[META_BUTTON_FUNCTION_SHADE] = META_BUTTON_STATE_PRELIGHT;
break;
case META_FRAME_CONTROL_UNSHADE:
if (grab_op == META_GRAB_OP_CLICKING_UNSHADE)
- button_states[META_BUTTON_TYPE_UNSHADE] = META_BUTTON_STATE_PRESSED;
+ button_states[META_BUTTON_FUNCTION_UNSHADE] = META_BUTTON_STATE_PRESSED;
else
- button_states[META_BUTTON_TYPE_UNSHADE] = META_BUTTON_STATE_PRELIGHT;
+ button_states[META_BUTTON_FUNCTION_UNSHADE] = META_BUTTON_STATE_PRELIGHT;
break;
case META_FRAME_CONTROL_ABOVE:
if (grab_op == META_GRAB_OP_CLICKING_ABOVE)
- button_states[META_BUTTON_TYPE_ABOVE] = META_BUTTON_STATE_PRESSED;
+ button_states[META_BUTTON_FUNCTION_ABOVE] = META_BUTTON_STATE_PRESSED;
else
- button_states[META_BUTTON_TYPE_ABOVE] = META_BUTTON_STATE_PRELIGHT;
+ button_states[META_BUTTON_FUNCTION_ABOVE] = META_BUTTON_STATE_PRELIGHT;
break;
case META_FRAME_CONTROL_UNABOVE:
if (grab_op == META_GRAB_OP_CLICKING_UNABOVE)
- button_states[META_BUTTON_TYPE_UNABOVE] = META_BUTTON_STATE_PRESSED;
+ button_states[META_BUTTON_FUNCTION_UNABOVE] = META_BUTTON_STATE_PRESSED;
else
- button_states[META_BUTTON_TYPE_UNABOVE] = META_BUTTON_STATE_PRELIGHT;
+ button_states[META_BUTTON_FUNCTION_UNABOVE] = META_BUTTON_STATE_PRELIGHT;
break;
case META_FRAME_CONTROL_STICK:
if (grab_op == META_GRAB_OP_CLICKING_STICK)
- button_states[META_BUTTON_TYPE_STICK] = META_BUTTON_STATE_PRESSED;
+ button_states[META_BUTTON_FUNCTION_STICK] = META_BUTTON_STATE_PRESSED;
else
- button_states[META_BUTTON_TYPE_STICK] = META_BUTTON_STATE_PRELIGHT;
+ button_states[META_BUTTON_FUNCTION_STICK] = META_BUTTON_STATE_PRELIGHT;
break;
case META_FRAME_CONTROL_UNSTICK:
if (grab_op == META_GRAB_OP_CLICKING_UNSTICK)
- button_states[META_BUTTON_TYPE_UNSTICK] = META_BUTTON_STATE_PRESSED;
+ button_states[META_BUTTON_FUNCTION_UNSTICK] = META_BUTTON_STATE_PRESSED;
else
- button_states[META_BUTTON_TYPE_UNSTICK] = META_BUTTON_STATE_PRELIGHT;
+ button_states[META_BUTTON_FUNCTION_UNSTICK] = META_BUTTON_STATE_PRELIGHT;
break;
case META_FRAME_CONTROL_DELETE:
if (grab_op == META_GRAB_OP_CLICKING_DELETE)
- button_states[META_BUTTON_TYPE_CLOSE] = META_BUTTON_STATE_PRESSED;
+ button_states[META_BUTTON_FUNCTION_CLOSE] = META_BUTTON_STATE_PRESSED;
else
- button_states[META_BUTTON_TYPE_CLOSE] = META_BUTTON_STATE_PRELIGHT;
+ button_states[META_BUTTON_FUNCTION_CLOSE] = META_BUTTON_STATE_PRELIGHT;
break;
case META_FRAME_CONTROL_NONE:
case META_FRAME_CONTROL_TITLE:
diff --git a/theme-viewer/theme-viewer-window.c b/theme-viewer/theme-viewer-window.c
index 35f0fc4..ad56ed4 100644
--- a/theme-viewer/theme-viewer-window.c
+++ b/theme-viewer/theme-viewer-window.c
@@ -62,7 +62,7 @@ struct _ThemeViewerWindow
MetaFrameBorders borders;
- MetaButtonState button_states[META_BUTTON_TYPE_LAST];
+ MetaButtonState button_states[META_BUTTON_FUNCTION_LAST];
gboolean button_pressed;
@@ -337,7 +337,7 @@ update_button_state (GtkWidget *widget,
gint width;
gint height;
MetaFrameGeometry fgeom;
- MetaButtonType type;
+ MetaButtonFunction function;
guint i;
gdk_window_get_device_position (gtk_widget_get_window (widget),
@@ -353,41 +353,41 @@ update_button_state (GtkWidget *widget,
y -= PADDING;
if (point_in_rect (x, y, fgeom.menu_rect.clickable))
- type = META_BUTTON_TYPE_MENU;
+ function = META_BUTTON_FUNCTION_MENU;
if (point_in_rect (x, y, fgeom.appmenu_rect.clickable))
- type = META_BUTTON_TYPE_APPMENU;
+ function = META_BUTTON_FUNCTION_APPMENU;
if (point_in_rect (x, y, fgeom.min_rect.clickable))
- type = META_BUTTON_TYPE_MINIMIZE;
+ function = META_BUTTON_FUNCTION_MINIMIZE;
if (point_in_rect (x, y, fgeom.max_rect.clickable))
- type = META_BUTTON_TYPE_MAXIMIZE;
+ function = META_BUTTON_FUNCTION_MAXIMIZE;
if (point_in_rect (x, y, fgeom.close_rect.clickable))
- type = META_BUTTON_TYPE_CLOSE;
+ function = META_BUTTON_FUNCTION_CLOSE;
if (point_in_rect (x, y, fgeom.shade_rect.clickable))
- type = META_BUTTON_TYPE_SHADE;
+ function = META_BUTTON_FUNCTION_SHADE;
if (point_in_rect (x, y, fgeom.unshade_rect.clickable))
- type = META_BUTTON_TYPE_UNSHADE;
+ function = META_BUTTON_FUNCTION_UNSHADE;
if (point_in_rect (x, y, fgeom.above_rect.clickable))
- type = META_BUTTON_TYPE_ABOVE;
+ function = META_BUTTON_FUNCTION_ABOVE;
if (point_in_rect (x, y, fgeom.unabove_rect.clickable))
- type = META_BUTTON_TYPE_UNABOVE;
+ function = META_BUTTON_FUNCTION_UNABOVE;
if (point_in_rect (x, y, fgeom.stick_rect.clickable))
- type = META_BUTTON_TYPE_STICK;
+ function = META_BUTTON_FUNCTION_STICK;
if (point_in_rect (x, y, fgeom.unstick_rect.clickable))
- type = META_BUTTON_TYPE_UNSTICK;
+ function = META_BUTTON_FUNCTION_UNSTICK;
- for (i = 0; i < META_BUTTON_TYPE_LAST; i++)
+ for (i = 0; i < META_BUTTON_FUNCTION_LAST; i++)
{
- if (i == type)
+ if (i == function)
{
if (window->button_pressed)
window->button_states[i] = META_BUTTON_STATE_PRESSED;
@@ -414,7 +414,7 @@ update_button_layout (ThemeViewerWindow *window)
meta_theme_set_button_layout (window->theme, text, FALSE);
- for (i = 0; i < META_BUTTON_TYPE_LAST; i++)
+ for (i = 0; i < META_BUTTON_FUNCTION_LAST; i++)
window->button_states[i] = META_BUTTON_STATE_NORMAL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]