[metacity] theme: move meta_theme_get_frame_style to libmetacity
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] theme: move meta_theme_get_frame_style to libmetacity
- Date: Wed, 3 Feb 2016 23:05:44 +0000 (UTC)
commit c7200decbb68e73963b7cf1b3b6434d0b119a91e
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Wed Feb 3 22:03:52 2016 +0200
theme: move meta_theme_get_frame_style to libmetacity
libmetacity/meta-theme.c | 92 ++++++++++++++++++++++++++++++++++++--
libmetacity/meta-theme.h | 7 ++-
src/ui/theme-private.h | 6 ---
src/ui/theme.c | 111 ++--------------------------------------------
4 files changed, 96 insertions(+), 120 deletions(-)
---
diff --git a/libmetacity/meta-theme.c b/libmetacity/meta-theme.c
index 32e17e0..bad12d5 100644
--- a/libmetacity/meta-theme.c
+++ b/libmetacity/meta-theme.c
@@ -298,11 +298,95 @@ meta_theme_get_name (MetaTheme *theme)
return META_THEME_IMPL_GET_CLASS (theme->impl)->get_name (theme->impl);
}
-MetaFrameStyleSet *
-meta_theme_get_style_set (MetaTheme *theme,
- MetaFrameType type)
+MetaFrameStyle *
+meta_theme_get_frame_style (MetaTheme *theme,
+ MetaFrameType type,
+ MetaFrameFlags flags)
{
- return meta_theme_impl_get_style_set (theme->impl, type);
+ MetaFrameState state;
+ MetaFrameResize resize;
+ MetaFrameFocus focus;
+ MetaFrameStyle *style;
+ MetaFrameStyleSet *style_set;
+
+ g_return_val_if_fail (type < META_FRAME_TYPE_LAST, NULL);
+
+ style_set = meta_theme_impl_get_style_set (theme->impl, type);
+
+ if (style_set == NULL && type == META_FRAME_TYPE_ATTACHED)
+ style_set = meta_theme_impl_get_style_set (theme->impl, META_FRAME_TYPE_BORDER);
+
+ /* Right now the parser forces a style set for all other types,
+ * but this fallback code is here in case I take that out.
+ */
+ if (style_set == NULL)
+ style_set = meta_theme_impl_get_style_set (theme->impl, META_FRAME_TYPE_NORMAL);
+
+ if (style_set == NULL)
+ return NULL;
+
+ switch (flags & (META_FRAME_MAXIMIZED | META_FRAME_SHADED | META_FRAME_TILED_LEFT |
META_FRAME_TILED_RIGHT))
+ {
+ case 0:
+ state = META_FRAME_STATE_NORMAL;
+ break;
+ case META_FRAME_MAXIMIZED:
+ state = META_FRAME_STATE_MAXIMIZED;
+ break;
+ case META_FRAME_TILED_LEFT:
+ state = META_FRAME_STATE_TILED_LEFT;
+ break;
+ case META_FRAME_TILED_RIGHT:
+ state = META_FRAME_STATE_TILED_RIGHT;
+ break;
+ case META_FRAME_SHADED:
+ state = META_FRAME_STATE_SHADED;
+ break;
+ case (META_FRAME_MAXIMIZED | META_FRAME_SHADED):
+ state = META_FRAME_STATE_MAXIMIZED_AND_SHADED;
+ break;
+ case (META_FRAME_TILED_LEFT | META_FRAME_SHADED):
+ state = META_FRAME_STATE_TILED_LEFT_AND_SHADED;
+ break;
+ case (META_FRAME_TILED_RIGHT | META_FRAME_SHADED):
+ state = META_FRAME_STATE_TILED_RIGHT_AND_SHADED;
+ break;
+ default:
+ g_assert_not_reached ();
+ state = META_FRAME_STATE_LAST; /* compiler */
+ break;
+ }
+
+ switch (flags & (META_FRAME_ALLOWS_VERTICAL_RESIZE | META_FRAME_ALLOWS_HORIZONTAL_RESIZE))
+ {
+ case 0:
+ resize = META_FRAME_RESIZE_NONE;
+ break;
+ case META_FRAME_ALLOWS_VERTICAL_RESIZE:
+ resize = META_FRAME_RESIZE_VERTICAL;
+ break;
+ case META_FRAME_ALLOWS_HORIZONTAL_RESIZE:
+ resize = META_FRAME_RESIZE_HORIZONTAL;
+ break;
+ case (META_FRAME_ALLOWS_VERTICAL_RESIZE | META_FRAME_ALLOWS_HORIZONTAL_RESIZE):
+ resize = META_FRAME_RESIZE_BOTH;
+ break;
+ default:
+ g_assert_not_reached ();
+ resize = META_FRAME_RESIZE_LAST; /* compiler */
+ break;
+ }
+
+ /* re invert the styles used for focus/unfocussed while flashing a frame */
+ if (((flags & META_FRAME_HAS_FOCUS) && !(flags & META_FRAME_IS_FLASHING))
+ || (!(flags & META_FRAME_HAS_FOCUS) && (flags & META_FRAME_IS_FLASHING)))
+ focus = META_FRAME_FOCUS_YES;
+ else
+ focus = META_FRAME_FOCUS_NO;
+
+ style = meta_frame_style_set_get_style (style_set, state, resize, focus);
+
+ return style;
}
gboolean
diff --git a/libmetacity/meta-theme.h b/libmetacity/meta-theme.h
index bf57192..ca7a21b 100644
--- a/libmetacity/meta-theme.h
+++ b/libmetacity/meta-theme.h
@@ -24,13 +24,13 @@
#include <libmetacity/meta-button-layout.h>
#include <libmetacity/meta-frame-borders.h>
#include <libmetacity/meta-frame-enums.h>
+#include <libmetacity/meta-frame-style.h>
#include <libmetacity/meta-style-info.h>
G_BEGIN_DECLS
typedef struct _MetaButtonSpace MetaButtonSpace;
typedef struct _MetaFrameGeometry MetaFrameGeometry;
-typedef struct _MetaFrameStyleSet MetaFrameStyleSet;
#define META_TYPE_THEME meta_theme_get_type ()
G_DECLARE_FINAL_TYPE (MetaTheme, meta_theme, META, THEME, GObject)
@@ -179,8 +179,9 @@ MetaThemeType meta_theme_get_theme_type (MetaTheme
gchar *meta_theme_get_name (MetaTheme *theme);
-MetaFrameStyleSet *meta_theme_get_style_set (MetaTheme *theme,
- MetaFrameType type);
+MetaFrameStyle *meta_theme_get_frame_style (MetaTheme *theme,
+ MetaFrameType type,
+ MetaFrameFlags flags);
gboolean meta_theme_allows_shade_stick_above_buttons (MetaTheme *theme);
diff --git a/src/ui/theme-private.h b/src/ui/theme-private.h
index 0db12f8..cf086dc 100644
--- a/src/ui/theme-private.h
+++ b/src/ui/theme-private.h
@@ -18,16 +18,10 @@
#ifndef META_THEME_PRIVATE_H
#define META_THEME_PRIVATE_H
-#include <libmetacity/meta-frame-style.h>
-
#include "theme.h"
G_BEGIN_DECLS
-MetaFrameStyle *meta_theme_get_frame_style (MetaTheme *theme,
- MetaFrameType type,
- MetaFrameFlags flags);
-
PangoFontDescription *meta_style_info_create_font_desc (MetaTheme *theme,
MetaStyleInfo *style_info);
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 9e5bb21..037e481 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -1569,109 +1569,6 @@ meta_theme_set_current (const gchar *name,
}
}
-static MetaFrameStyle*
-theme_get_style (MetaTheme *theme,
- MetaFrameType type,
- MetaFrameFlags flags)
-{
- MetaFrameState state;
- MetaFrameResize resize;
- MetaFrameFocus focus;
- MetaFrameStyle *style;
- MetaFrameStyleSet *style_set;
-
- style_set = meta_theme_get_style_set (theme, type);
-
- if (style_set == NULL && type == META_FRAME_TYPE_ATTACHED)
- style_set = meta_theme_get_style_set (theme, META_FRAME_TYPE_BORDER);
-
- /* Right now the parser forces a style set for all other types,
- * but this fallback code is here in case I take that out.
- */
- if (style_set == NULL)
- style_set = meta_theme_get_style_set (theme, META_FRAME_TYPE_NORMAL);
-
- if (style_set == NULL)
- return NULL;
-
- switch (flags & (META_FRAME_MAXIMIZED | META_FRAME_SHADED | META_FRAME_TILED_LEFT |
META_FRAME_TILED_RIGHT))
- {
- case 0:
- state = META_FRAME_STATE_NORMAL;
- break;
- case META_FRAME_MAXIMIZED:
- state = META_FRAME_STATE_MAXIMIZED;
- break;
- case META_FRAME_TILED_LEFT:
- state = META_FRAME_STATE_TILED_LEFT;
- break;
- case META_FRAME_TILED_RIGHT:
- state = META_FRAME_STATE_TILED_RIGHT;
- break;
- case META_FRAME_SHADED:
- state = META_FRAME_STATE_SHADED;
- break;
- case (META_FRAME_MAXIMIZED | META_FRAME_SHADED):
- state = META_FRAME_STATE_MAXIMIZED_AND_SHADED;
- break;
- case (META_FRAME_TILED_LEFT | META_FRAME_SHADED):
- state = META_FRAME_STATE_TILED_LEFT_AND_SHADED;
- break;
- case (META_FRAME_TILED_RIGHT | META_FRAME_SHADED):
- state = META_FRAME_STATE_TILED_RIGHT_AND_SHADED;
- break;
- default:
- g_assert_not_reached ();
- state = META_FRAME_STATE_LAST; /* compiler */
- break;
- }
-
- switch (flags & (META_FRAME_ALLOWS_VERTICAL_RESIZE | META_FRAME_ALLOWS_HORIZONTAL_RESIZE))
- {
- case 0:
- resize = META_FRAME_RESIZE_NONE;
- break;
- case META_FRAME_ALLOWS_VERTICAL_RESIZE:
- resize = META_FRAME_RESIZE_VERTICAL;
- break;
- case META_FRAME_ALLOWS_HORIZONTAL_RESIZE:
- resize = META_FRAME_RESIZE_HORIZONTAL;
- break;
- case (META_FRAME_ALLOWS_VERTICAL_RESIZE | META_FRAME_ALLOWS_HORIZONTAL_RESIZE):
- resize = META_FRAME_RESIZE_BOTH;
- break;
- default:
- g_assert_not_reached ();
- resize = META_FRAME_RESIZE_LAST; /* compiler */
- break;
- }
-
- /* re invert the styles used for focus/unfocussed while flashing a frame */
- if (((flags & META_FRAME_HAS_FOCUS) && !(flags & META_FRAME_IS_FLASHING))
- || (!(flags & META_FRAME_HAS_FOCUS) && (flags & META_FRAME_IS_FLASHING)))
- focus = META_FRAME_FOCUS_YES;
- else
- focus = META_FRAME_FOCUS_NO;
-
- style = meta_frame_style_set_get_style (style_set, state, resize, focus);
-
- return style;
-}
-
-MetaFrameStyle*
-meta_theme_get_frame_style (MetaTheme *theme,
- MetaFrameType type,
- MetaFrameFlags flags)
-{
- MetaFrameStyle *style;
-
- g_return_val_if_fail (type < META_FRAME_TYPE_LAST, NULL);
-
- style = theme_get_style (theme, type, flags);
-
- return style;
-}
-
double
meta_theme_get_title_scale (MetaTheme *theme,
MetaFrameType type,
@@ -1681,7 +1578,7 @@ meta_theme_get_title_scale (MetaTheme *theme,
g_return_val_if_fail (type < META_FRAME_TYPE_LAST, 1.0);
- style = theme_get_style (theme, type, flags);
+ style = meta_theme_get_frame_style (theme, type, flags);
/* Parser is not supposed to allow this currently */
if (style == NULL)
@@ -1736,7 +1633,7 @@ meta_theme_draw_frame (MetaTheme *theme,
g_return_if_fail (type < META_FRAME_TYPE_LAST);
- style = theme_get_style (theme, type, flags);
+ style = meta_theme_get_frame_style (theme, type, flags);
/* Parser is not supposed to allow this currently */
if (style == NULL)
@@ -1791,7 +1688,7 @@ meta_theme_get_frame_borders (MetaTheme *theme,
g_return_if_fail (type < META_FRAME_TYPE_LAST);
- style = theme_get_style (theme, type, flags);
+ style = meta_theme_get_frame_style (theme, type, flags);
meta_frame_borders_clear (borders);
@@ -1823,7 +1720,7 @@ meta_theme_calc_geometry (MetaTheme *theme,
g_return_if_fail (type < META_FRAME_TYPE_LAST);
- style = theme_get_style (theme, type, flags);
+ style = meta_theme_get_frame_style (theme, type, flags);
/* Parser is not supposed to allow this currently */
if (style == NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]