1
From a5442fe19432509eda44901093b45e97f72e04c0 Mon Sep 17 00:00:00 2001
2
From: Sam Spilsbury <smspillaz@gmail.com>
3
Date: Thu, 13 Jan 2011 11:59:40 +0800
4
Subject: [PATCH] Add UXD shadows and borders
7
src/ui/theme-parser.c | 520 ++++++++++++++++++++------------
8
src/ui/theme.c | 63 ++++
9
src/ui/theme.h | 112 ++++++--
10
3 files changed, 482 insertions(+), 215 deletions(-)
12
Index: metacity-2.34.1/src/ui/theme-parser.c
13
===================================================================
14
--- metacity-2.34.1.orig/src/ui/theme-parser.c 2011-04-23 12:10:04.000000000 -0400
15
+++ metacity-2.34.1/src/ui/theme-parser.c 2011-08-18 00:02:30.689002059 -0400
23
STATE_FRAME_STYLE_SET,
29
+static void parse_shadow_element (GMarkupParseContext *context,
30
+ const gchar *element_name,
31
+ const gchar **attribute_names,
32
+ const gchar **attribute_values,
36
+static void parse_padding_element (GMarkupParseContext *context,
37
+ const gchar *element_name,
38
+ const gchar **attribute_names,
39
+ const gchar **attribute_values,
43
static void parse_menu_icon_element (GMarkupParseContext *context,
44
const gchar *element_name,
45
const gchar **attribute_names,
46
@@ -2935,9 +2951,76 @@
47
meta_draw_op_list_ref (op_list);
48
info->op_list = op_list;
52
push_state (info, STATE_BUTTON);
54
+ else if (ELEMENT_IS ("shadow"))
56
+ const char *shadow_radius = NULL;
57
+ const char *shadow_opacity = NULL;
58
+ const char *shadow_color = NULL;
59
+ const char *shadow_x_offset = NULL;
60
+ const char *shadow_y_offset = NULL;
61
+ double shadow_radius_v, shadow_opacity_v;
62
+ int shadow_x_offset_v, shadow_y_offset_v;
63
+ MetaColorSpec *shadow_color_v;
65
+ if (!locate_attributes (context, element_name, attribute_names, attribute_values,
67
+ "radius", &shadow_radius,
68
+ "opacity", &shadow_opacity,
69
+ "color", &shadow_color,
70
+ "x_offset", &shadow_x_offset,
71
+ "y_offset", &shadow_y_offset,
75
+ parse_double (shadow_radius, &shadow_radius_v, context, error);
76
+ parse_double (shadow_opacity, &shadow_opacity_v, context, error);
77
+ parse_positive_integer (shadow_x_offset, &shadow_x_offset_v, context, info->theme, error);
78
+ parse_positive_integer (shadow_y_offset, &shadow_y_offset_v, context, info->theme, error);
79
+ shadow_color_v = parse_color (info->theme, shadow_color, error);
81
+ if (!info->style->shadow_properties)
82
+ info->style->shadow_properties = meta_shadow_properties_new ();
84
+ info->style->shadow_properties->unity_shadow_radius = shadow_radius_v;
85
+ info->style->shadow_properties->unity_shadow_opacity = shadow_opacity_v;
86
+ info->style->shadow_properties->unity_shadow_x_offset = shadow_x_offset_v;
87
+ info->style->shadow_properties->unity_shadow_y_offset = shadow_y_offset_v;
88
+ info->style->shadow_properties->unity_shadow_color = shadow_color_v;
90
+ push_state (info, STATE_SHADOW);
93
+ else if (ELEMENT_IS ("padding"))
95
+ const char *left = NULL;
96
+ const char *bottom = NULL;
97
+ const char *right = NULL;
98
+ int left_v, right_v, bottom_v;
100
+ if (!locate_attributes (context, element_name, attribute_names, attribute_values,
108
+ parse_positive_integer (left, &left_v, context, info->theme, error);
109
+ parse_positive_integer (right, &right_v, context, info->theme, error);
110
+ parse_positive_integer (bottom, &bottom_v, context, info->theme, error);
112
+ if (!info->style->invisible_grab_area_properties)
113
+ info->style->invisible_grab_area_properties = meta_invisible_grab_area_properties_new ();
115
+ info->style->invisible_grab_area_properties->left = left_v;
116
+ info->style->invisible_grab_area_properties->right = right_v;
117
+ info->style->invisible_grab_area_properties->bottom = bottom_v;
119
+ push_state (info, STATE_PADDING);
123
set_error (error, context,
124
@@ -3216,6 +3299,38 @@
128
+parse_shadow_element (GMarkupParseContext *context,
129
+ const gchar *element_name,
130
+ const gchar **attribute_names,
131
+ const gchar **attribute_values,
135
+ g_return_if_fail (peek_state (info) == STATE_SHADOW);
137
+ set_error (error, context,
138
+ G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
139
+ _("Element <%s> is not allowed below <%s>"),
140
+ element_name, "shadow");
144
+parse_padding_element (GMarkupParseContext *context,
145
+ const gchar *element_name,
146
+ const gchar **attribute_names,
147
+ const gchar **attribute_values,
151
+ g_return_if_fail (peek_state (info) == STATE_PADDING);
153
+ set_error (error, context,
154
+ G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
155
+ _("Element <%s> is not allowed below <%s>"),
156
+ element_name, "padding");
160
parse_menu_icon_element (GMarkupParseContext *context,
161
const gchar *element_name,
162
const gchar **attribute_names,
163
@@ -3366,6 +3481,16 @@
164
attribute_names, attribute_values,
168
+ parse_shadow_element (context, element_name,
169
+ attribute_names, attribute_values,
172
+ case STATE_PADDING:
173
+ parse_padding_element (context, element_name,
174
+ attribute_names, attribute_values,
177
case STATE_MENU_ICON:
178
parse_menu_icon_element (context, element_name,
179
attribute_names, attribute_values,
180
@@ -3635,6 +3760,14 @@
185
+ g_assert (info->style);
188
+ case STATE_PADDING:
189
+ g_assert (info->style);
192
case STATE_MENU_ICON:
193
g_assert (info->theme);
194
if (info->op_list != NULL)
195
@@ -3859,6 +3992,12 @@
200
+ NO_TEXT ("shadow");
202
+ case STATE_PADDING:
203
+ NO_TEXT ("padding");
205
case STATE_MENU_ICON:
206
NO_TEXT ("menu_icon");
208
Index: metacity-2.34.1/src/ui/theme.c
209
===================================================================
210
--- metacity-2.34.1.orig/src/ui/theme.c 2011-03-08 04:31:53.000000000 -0500
211
+++ metacity-2.34.1/src/ui/theme.c 2011-08-18 00:02:30.699002293 -0400
212
@@ -1088,6 +1088,51 @@
216
+MetaShadowProperties*
217
+meta_shadow_properties_new (void)
219
+ MetaShadowProperties *properties;
221
+ properties = g_new0 (MetaShadowProperties, 1);
225
+ properties->unity_shadow_radius = 0.0f;
226
+ properties->unity_shadow_x_offset = 0;
227
+ properties->unity_shadow_y_offset = 0;
228
+ properties->unity_shadow_color = NULL;
235
+meta_shadow_properties_free (MetaShadowProperties *properties)
237
+ g_return_if_fail (properties != NULL);
239
+ meta_color_spec_free (properties->unity_shadow_color);
240
+ g_free (properties);
243
+MetaInvisibleGrabAreaProperties*
244
+meta_invisible_grab_area_properties_new (void)
246
+ MetaInvisibleGrabAreaProperties *properties;
248
+ properties = g_new0 (MetaInvisibleGrabAreaProperties, 1);
254
+meta_invisible_grab_area_properties_free (MetaInvisibleGrabAreaProperties *properties)
256
+ g_return_if_fail (properties != NULL);
258
+ g_free (properties);
262
meta_color_spec_new (MetaColorSpecType type)
264
@@ -4186,6 +4231,12 @@
266
meta_frame_style_unref (style->parent);
268
+ if (style->shadow_properties)
269
+ meta_shadow_properties_free (style->shadow_properties);
271
+ if (style->invisible_grab_area_properties)
272
+ meta_invisible_grab_area_properties_free (style->invisible_grab_area_properties);
274
DEBUG_FILL_STRUCT (style);
277
@@ -4680,6 +4731,18 @@
278
button_states, mini_icon, icon);
281
+MetaShadowProperties *
282
+meta_frame_style_get_shadow_properties (MetaFrameStyle *style)
284
+ return style->shadow_properties;
288
+MetaInvisibleGrabAreaProperties * meta_frame_style_get_invisible_grab_area_properties (MetaFrameStyle *style)
290
+ return style->invisible_grab_area_properties;
294
meta_frame_style_set_new (MetaFrameStyleSet *parent)
296
Index: metacity-2.34.1/src/ui/theme.h
297
===================================================================
298
--- metacity-2.34.1.orig/src/ui/theme.h 2011-03-08 04:31:53.000000000 -0500
299
+++ metacity-2.34.1/src/ui/theme.h 2011-08-18 00:02:30.699002293 -0400
301
typedef struct _MetaDrawOp MetaDrawOp;
302
typedef struct _MetaDrawOpList MetaDrawOpList;
303
typedef struct _MetaGradientSpec MetaGradientSpec;
304
-typedef struct _MetaAlphaGradientSpec MetaAlphaGradientSpec;
305
+typedef struct _MetaAlphaGradientSpec MetaAlphaGradientSpec;
306
typedef struct _MetaColorSpec MetaColorSpec;
307
typedef struct _MetaFrameLayout MetaFrameLayout;
308
typedef struct _MetaButtonSpace MetaButtonSpace;
310
typedef struct _MetaTheme MetaTheme;
311
typedef struct _MetaPositionExprEnv MetaPositionExprEnv;
312
typedef struct _MetaDrawInfo MetaDrawInfo;
313
+typedef struct _MetaShadowProperties MetaShadowProperties;
314
+typedef struct _MetaInvisibleGrabAreaProperties MetaInvisibleGrabAreaProperties;
316
+struct _MetaShadowProperties
319
+ * Radius of the shadow
321
+ double unity_shadow_radius;
324
+ * Opacity of the shadow
326
+ double unity_shadow_opacity;
329
+ * Color of the shadow
331
+ MetaColorSpec *unity_shadow_color;
335
+ guint8 unity_shadow_x_offset;
339
+ guint8 unity_shadow_y_offset;
342
+struct _MetaInvisibleGrabAreaProperties
362
#define META_THEME_ERROR (g_quark_from_static_string ("meta-theme-error"))
365
* Transparency of the window background. 0=transparent; 255=opaque.
367
guint8 window_background_alpha;
371
+ MetaShadowProperties *shadow_properties;
373
+ * Padding (eg invisible grab area)
375
+ MetaInvisibleGrabAreaProperties *invisible_grab_area_properties;
380
@@ -951,6 +1008,11 @@
382
void meta_alpha_gradient_spec_free (MetaAlphaGradientSpec *spec);
384
+MetaShadowProperties* meta_shadow_properties_new (void);
385
+void meta_shadow_properties_free (MetaShadowProperties *);
387
+MetaInvisibleGrabAreaProperties* meta_invisible_grab_area_properties_new (void);
388
+void meta_invisible_grab_area_properties_free (MetaInvisibleGrabAreaProperties *);
390
MetaFrameStyle* meta_frame_style_new (MetaFrameStyle *parent);
391
void meta_frame_style_ref (MetaFrameStyle *style);
393
GdkPixbuf *mini_icon,
396
+MetaShadowProperties * meta_frame_style_get_shadow_properties (MetaFrameStyle *style);
397
+MetaInvisibleGrabAreaProperties * meta_frame_style_get_invisible_grab_area_properties (MetaFrameStyle *style);
399
gboolean meta_frame_style_validate (MetaFrameStyle *style,
400
guint current_theme_version,