summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2010-12-10 01:24:30 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2010-12-10 01:24:30 +0800
commitfb53349746df664bf227f70568953d09958b9049 (patch)
treef73cfddf88a3e97642f461cf3dfa891fd006980c /src/ui
parent120c7790d6c5a837372ef1e0105e89ac674facd8 (diff)
downloadmetacity-fb53349746df664bf227f70568953d09958b9049.tar.gz
metacity-fb53349746df664bf227f70568953d09958b9049.tar.bz2
Add the ability to parse <shadow> and <padding> tags in <frame-style>
Diffstat (limited to 'src/ui')
-rwxr-xr-x[-rw-r--r--]src/ui/draw-workspace.c0
-rwxr-xr-x[-rw-r--r--]src/ui/draw-workspace.h0
-rwxr-xr-x[-rw-r--r--]src/ui/fixedtip.c0
-rwxr-xr-x[-rw-r--r--]src/ui/fixedtip.h0
-rwxr-xr-x[-rw-r--r--]src/ui/frames.c0
-rwxr-xr-x[-rw-r--r--]src/ui/frames.h0
-rwxr-xr-x[-rw-r--r--]src/ui/gradient.c0
-rwxr-xr-x[-rw-r--r--]src/ui/gradient.h0
-rwxr-xr-x[-rw-r--r--]src/ui/menu.c0
-rwxr-xr-x[-rw-r--r--]src/ui/menu.h0
-rwxr-xr-x[-rw-r--r--]src/ui/metaaccellabel.c0
-rwxr-xr-x[-rw-r--r--]src/ui/metaaccellabel.h0
-rwxr-xr-x[-rw-r--r--]src/ui/preview-widget.c0
-rwxr-xr-x[-rw-r--r--]src/ui/preview-widget.h0
-rwxr-xr-x[-rw-r--r--]src/ui/resizepopup.c0
-rwxr-xr-x[-rw-r--r--]src/ui/tabpopup.c0
-rwxr-xr-x[-rw-r--r--]src/ui/testgradient.c0
-rwxr-xr-x[-rw-r--r--]src/ui/theme-parser.c140
-rwxr-xr-x[-rw-r--r--]src/ui/theme-parser.h0
-rwxr-xr-x[-rw-r--r--]src/ui/theme-viewer.c0
-rwxr-xr-x[-rw-r--r--]src/ui/theme.c63
-rwxr-xr-x[-rw-r--r--]src/ui/theme.h58
-rwxr-xr-x[-rw-r--r--]src/ui/themewidget.c0
-rwxr-xr-x[-rw-r--r--]src/ui/themewidget.h0
-rwxr-xr-x[-rw-r--r--]src/ui/ui.c0
25 files changed, 260 insertions, 1 deletions
diff --git a/src/ui/draw-workspace.c b/src/ui/draw-workspace.c
index 9dc491f..9dc491f 100644..100755
--- a/src/ui/draw-workspace.c
+++ b/src/ui/draw-workspace.c
diff --git a/src/ui/draw-workspace.h b/src/ui/draw-workspace.h
index 10018aa..10018aa 100644..100755
--- a/src/ui/draw-workspace.h
+++ b/src/ui/draw-workspace.h
diff --git a/src/ui/fixedtip.c b/src/ui/fixedtip.c
index be25390..be25390 100644..100755
--- a/src/ui/fixedtip.c
+++ b/src/ui/fixedtip.c
diff --git a/src/ui/fixedtip.h b/src/ui/fixedtip.h
index c196389..c196389 100644..100755
--- a/src/ui/fixedtip.h
+++ b/src/ui/fixedtip.h
diff --git a/src/ui/frames.c b/src/ui/frames.c
index d8fe3cd..d8fe3cd 100644..100755
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
diff --git a/src/ui/frames.h b/src/ui/frames.h
index ad8d361..ad8d361 100644..100755
--- a/src/ui/frames.h
+++ b/src/ui/frames.h
diff --git a/src/ui/gradient.c b/src/ui/gradient.c
index 6790623..6790623 100644..100755
--- a/src/ui/gradient.c
+++ b/src/ui/gradient.c
diff --git a/src/ui/gradient.h b/src/ui/gradient.h
index 16b3985..16b3985 100644..100755
--- a/src/ui/gradient.h
+++ b/src/ui/gradient.h
diff --git a/src/ui/menu.c b/src/ui/menu.c
index 7060733..7060733 100644..100755
--- a/src/ui/menu.c
+++ b/src/ui/menu.c
diff --git a/src/ui/menu.h b/src/ui/menu.h
index 39bb7fa..39bb7fa 100644..100755
--- a/src/ui/menu.h
+++ b/src/ui/menu.h
diff --git a/src/ui/metaaccellabel.c b/src/ui/metaaccellabel.c
index f4f06ac..f4f06ac 100644..100755
--- a/src/ui/metaaccellabel.c
+++ b/src/ui/metaaccellabel.c
diff --git a/src/ui/metaaccellabel.h b/src/ui/metaaccellabel.h
index 0a3b563..0a3b563 100644..100755
--- a/src/ui/metaaccellabel.h
+++ b/src/ui/metaaccellabel.h
diff --git a/src/ui/preview-widget.c b/src/ui/preview-widget.c
index 26b2756..26b2756 100644..100755
--- a/src/ui/preview-widget.c
+++ b/src/ui/preview-widget.c
diff --git a/src/ui/preview-widget.h b/src/ui/preview-widget.h
index 924b011..924b011 100644..100755
--- a/src/ui/preview-widget.h
+++ b/src/ui/preview-widget.h
diff --git a/src/ui/resizepopup.c b/src/ui/resizepopup.c
index 11698e8..11698e8 100644..100755
--- a/src/ui/resizepopup.c
+++ b/src/ui/resizepopup.c
diff --git a/src/ui/tabpopup.c b/src/ui/tabpopup.c
index 544bb01..544bb01 100644..100755
--- a/src/ui/tabpopup.c
+++ b/src/ui/tabpopup.c
diff --git a/src/ui/testgradient.c b/src/ui/testgradient.c
index 89d0d22..89d0d22 100644..100755
--- a/src/ui/testgradient.c
+++ b/src/ui/testgradient.c
diff --git a/src/ui/theme-parser.c b/src/ui/theme-parser.c
index c56e318..945ed44 100644..100755
--- a/src/ui/theme-parser.c
+++ b/src/ui/theme-parser.c
@@ -67,6 +67,8 @@ typedef enum
STATE_FRAME_STYLE,
STATE_PIECE,
STATE_BUTTON,
+ STATE_SHADOW,
+ STATE_PADDING,
/* style set */
STATE_FRAME_STYLE_SET,
STATE_FRAME,
@@ -173,6 +175,20 @@ static void parse_button_element (GMarkupParseContext *context,
ParseInfo *info,
GError **error);
+static void parse_shadow_element (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ ParseInfo *info,
+ GError **error);
+
+static void parse_padding_element (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ ParseInfo *info,
+ GError **error);
+
static void parse_menu_icon_element (GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
@@ -2927,6 +2943,73 @@ parse_style_element (GMarkupParseContext *context,
push_state (info, STATE_BUTTON);
}
+ else if (ELEMENT_IS ("shadow"))
+ {
+ const char *shadow_radius = NULL;
+ const char *shadow_color = NULL;
+ const char *shadow_x_offset = NULL;
+ const char *shadow_y_offset = NULL;
+ double shadow_radius_v;
+ int shadow_x_offset_v, shadow_y_offset_v;
+ MetaColorSpec *shadow_color_v;
+
+ if (!locate_attributes (context, element_name, attribute_names, attribute_values,
+ error,
+ "radius", &shadow_radius,
+ "color", &shadow_color,
+ "x_offset", &shadow_x_offset,
+ "y_offset", &shadow_y_offset,
+ NULL))
+ return;
+
+ parse_double (shadow_radius, &shadow_radius_v, context, error);
+ parse_positive_integer (shadow_x_offset, &shadow_x_offset_v, context, info->theme, error);
+ parse_positive_integer (shadow_y_offset, &shadow_y_offset_v, context, info->theme, error);
+ shadow_color_v = parse_color (info->theme, shadow_color, error);
+
+ fprintf (stderr, "shadow radius is %f x off is %i y off %i\n", shadow_radius_v, shadow_x_offset_v, shadow_y_offset_v);
+
+ if (!info->style->shadow_properties)
+ info->style->shadow_properties = meta_shadow_properties_new ();
+
+ info->style->shadow_properties->unity_shadow_radius = shadow_radius_v;
+ info->style->shadow_properties->unity_shadow_x_offset = shadow_x_offset_v;
+ info->style->shadow_properties->unity_shadow_y_offset = shadow_y_offset_v;
+ info->style->shadow_properties->unity_shadow_color = shadow_color_v;
+
+ push_state (info, STATE_SHADOW);
+
+ }
+ else if (ELEMENT_IS ("padding"))
+ {
+ const char *left = NULL;
+ const char *bottom = NULL;
+ const char *right = NULL;
+ int left_v, right_v, bottom_v;
+
+ if (!locate_attributes (context, element_name, attribute_names, attribute_values,
+ error,
+ "left", &left,
+ "right", &right,
+ "bottom", &bottom,
+ NULL))
+ return;
+
+ parse_positive_integer (left, &left_v, context, info->theme, error);
+ parse_positive_integer (right, &right_v, context, info->theme, error);
+ parse_positive_integer (bottom, &bottom_v, context, info->theme, error);
+
+ fprintf (stderr, "padding is left %i right %i bottom %i \n", left_v, right_v, bottom_v);
+
+ if (!info->style->invisible_grab_area_properties)
+ info->style->invisible_grab_area_properties = meta_invisible_grab_area_properties_new ();
+
+ info->style->invisible_grab_area_properties->left = left_v;
+ info->style->invisible_grab_area_properties->right = right_v;
+ info->style->invisible_grab_area_properties->bottom = bottom_v;
+
+ push_state (info, STATE_PADDING);
+ }
else
{
set_error (error, context,
@@ -3205,6 +3288,38 @@ parse_button_element (GMarkupParseContext *context,
}
static void
+parse_shadow_element (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ ParseInfo *info,
+ GError **error)
+{
+ g_return_if_fail (peek_state (info) == STATE_SHADOW);
+
+ set_error (error, context,
+ G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
+ _("Element <%s> is not allowed below <%s>"),
+ element_name, "shadow");
+}
+
+static void
+parse_padding_element (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ ParseInfo *info,
+ GError **error)
+{
+ g_return_if_fail (peek_state (info) == STATE_PADDING);
+
+ set_error (error, context,
+ G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
+ _("Element <%s> is not allowed below <%s>"),
+ element_name, "padding");
+}
+
+static void
parse_menu_icon_element (GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
@@ -3263,7 +3378,6 @@ start_element_handler (GMarkupParseContext *context,
info->theme->filename = g_strdup (info->theme_file);
info->theme->dirname = g_strdup (info->theme_dir);
info->theme->format_version = info->format_version;
-
push_state (info, STATE_THEME);
}
else
@@ -3355,6 +3469,16 @@ start_element_handler (GMarkupParseContext *context,
attribute_names, attribute_values,
info, error);
break;
+ case STATE_SHADOW:
+ parse_shadow_element (context, element_name,
+ attribute_names, attribute_values,
+ info, error);
+ break;
+ case STATE_PADDING:
+ parse_padding_element (context, element_name,
+ attribute_names, attribute_values,
+ info, error);
+ break;
case STATE_MENU_ICON:
parse_menu_icon_element (context, element_name,
attribute_names, attribute_values,
@@ -3624,6 +3748,14 @@ end_element_handler (GMarkupParseContext *context,
}
pop_state (info);
break;
+ case STATE_SHADOW:
+ g_assert (info->style);
+ pop_state (info);
+ break;
+ case STATE_PADDING:
+ g_assert (info->style);
+ pop_state (info);
+ break;
case STATE_MENU_ICON:
g_assert (info->theme);
if (info->op_list != NULL)
@@ -3848,6 +3980,12 @@ text_handler (GMarkupParseContext *context,
case STATE_BUTTON:
NO_TEXT ("button");
break;
+ case STATE_SHADOW:
+ NO_TEXT ("shadow");
+ break;
+ case STATE_PADDING:
+ NO_TEXT ("padding");
+ break;
case STATE_MENU_ICON:
NO_TEXT ("menu_icon");
break;
diff --git a/src/ui/theme-parser.h b/src/ui/theme-parser.h
index 035d700..035d700 100644..100755
--- a/src/ui/theme-parser.h
+++ b/src/ui/theme-parser.h
diff --git a/src/ui/theme-viewer.c b/src/ui/theme-viewer.c
index b1fd496..b1fd496 100644..100755
--- a/src/ui/theme-viewer.c
+++ b/src/ui/theme-viewer.c
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 1397fc6..dfa5e9f 100644..100755
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -1051,6 +1051,51 @@ meta_alpha_gradient_spec_free (MetaAlphaGradientSpec *spec)
g_free (spec);
}
+MetaShadowProperties*
+meta_shadow_properties_new (void)
+{
+ MetaShadowProperties *properties;
+
+ properties = g_new0 (MetaShadowProperties, 1);
+
+ if (properties)
+ {
+ properties->unity_shadow_radius = 0.0f;
+ properties->unity_shadow_x_offset = 0;
+ properties->unity_shadow_y_offset = 0;
+ properties->unity_shadow_color = NULL;
+ }
+
+ return properties;
+}
+
+void
+meta_shadow_properties_free (MetaShadowProperties *properties)
+{
+ g_return_if_fail (properties != NULL);
+
+ meta_color_spec_free (properties->unity_shadow_color);
+ g_free (properties);
+}
+
+MetaInvisibleGrabAreaProperties*
+meta_invisible_grab_area_properties_new (void)
+{
+ MetaInvisibleGrabAreaProperties *properties;
+
+ properties = g_new0 (MetaInvisibleGrabAreaProperties, 1);
+
+ return properties;
+}
+
+void
+meta_invisible_grab_area_properties_free (MetaInvisibleGrabAreaProperties *properties)
+{
+ g_return_if_fail (properties != NULL);
+
+ g_free (properties);
+}
+
MetaColorSpec*
meta_color_spec_new (MetaColorSpecType type)
{
@@ -4149,6 +4194,12 @@ meta_frame_style_unref (MetaFrameStyle *style)
if (style->parent)
meta_frame_style_unref (style->parent);
+ if (style->shadow_properties)
+ meta_shadow_properties_free (style->shadow_properties);
+
+ if (style->invisible_grab_area_properties)
+ meta_invisible_grab_area_properties_free (style->invisible_grab_area_properties);
+
DEBUG_FILL_STRUCT (style);
g_free (style);
}
@@ -4581,6 +4632,18 @@ meta_frame_style_draw (MetaFrameStyle *style,
button_states, mini_icon, icon);
}
+MetaShadowProperties *
+meta_frame_style_get_shadow_properties (MetaFrameStyle *style)
+{
+ return style->shadow_properties;
+}
+
+
+MetaInvisibleGrabAreaProperties * meta_frame_style_get_invisible_grab_area_properties (MetaFrameStyle *style)
+{
+ return style->invisible_grab_area_properties;
+}
+
MetaFrameStyleSet*
meta_frame_style_set_new (MetaFrameStyleSet *parent)
{
diff --git a/src/ui/theme.h b/src/ui/theme.h
index ddf777d..5d65962 100644..100755
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -42,6 +42,48 @@ typedef struct _MetaFrameGeometry MetaFrameGeometry;
typedef struct _MetaTheme MetaTheme;
typedef struct _MetaPositionExprEnv MetaPositionExprEnv;
typedef struct _MetaDrawInfo MetaDrawInfo;
+typedef struct _MetaShadowProperties MetaShadowProperties;
+typedef struct _MetaInvisibleGrabAreaProperties MetaInvisibleGrabAreaProperties;
+
+struct _MetaShadowProperties
+{
+ /**
+ * Radius of the shadow
+ */
+ double unity_shadow_radius;
+ /**
+ * Color of the shadow
+ */
+ MetaColorSpec *unity_shadow_color;
+ /**
+ * Shadow X Offset
+ */
+ guint8 unity_shadow_x_offset;
+ /**
+ * Shadow Y Offset
+ */
+ guint8 unity_shadow_y_offset;
+};
+
+struct _MetaInvisibleGrabAreaProperties
+{
+ /**
+ * Left padding
+ */
+ guint8 left;
+ /**
+ * Right padding
+ */
+ guint8 right;
+ /**
+ * Bottom padding
+ */
+ guint8 bottom;
+ /**
+ * Top padding
+ */
+ guint8 top;
+};
#define META_THEME_ERROR (g_quark_from_static_string ("meta-theme-error"))
@@ -693,6 +735,15 @@ struct _MetaFrameStyle
* Transparency of the window background. 0=transparent; 255=opaque.
*/
guint8 window_background_alpha;
+ /**
+ * Shadow
+ */
+ MetaShadowProperties *shadow_properties;
+ /**
+ * Padding (eg invisible grab area)
+ */
+ MetaInvisibleGrabAreaProperties *invisible_grab_area_properties;
+
};
/* Kinds of frame...
@@ -946,6 +997,11 @@ MetaAlphaGradientSpec* meta_alpha_gradient_spec_new (MetaGradientType typ
int n_alphas);
void meta_alpha_gradient_spec_free (MetaAlphaGradientSpec *spec);
+MetaShadowProperties* meta_shadow_properties_new (void);
+void meta_shadow_properties_free (MetaShadowProperties *);
+
+MetaInvisibleGrabAreaProperties* meta_invisible_grab_area_properties_new (void);
+void meta_invisible_grab_area_properties_free (MetaInvisibleGrabAreaProperties *);
MetaFrameStyle* meta_frame_style_new (MetaFrameStyle *parent);
void meta_frame_style_ref (MetaFrameStyle *style);
@@ -983,6 +1039,8 @@ void meta_frame_style_draw_with_style (MetaFrameStyle *style,
GdkPixbuf *mini_icon,
GdkPixbuf *icon);
+MetaShadowProperties * meta_frame_style_get_shadow_properties (MetaFrameStyle *style);
+MetaInvisibleGrabAreaProperties * meta_frame_style_get_invisible_grab_area_properties (MetaFrameStyle *style);
gboolean meta_frame_style_validate (MetaFrameStyle *style,
guint current_theme_version,
diff --git a/src/ui/themewidget.c b/src/ui/themewidget.c
index 7ee9db0..7ee9db0 100644..100755
--- a/src/ui/themewidget.c
+++ b/src/ui/themewidget.c
diff --git a/src/ui/themewidget.h b/src/ui/themewidget.h
index a94584a..a94584a 100644..100755
--- a/src/ui/themewidget.h
+++ b/src/ui/themewidget.h
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 960e702..960e702 100644..100755
--- a/src/ui/ui.c
+++ b/src/ui/ui.c