diff options
-rwxr-xr-x | src/ui/theme-parser.c | 394 | ||||
-rwxr-xr-x | src/ui/theme.h | 54 |
2 files changed, 227 insertions, 221 deletions
diff --git a/src/ui/theme-parser.c b/src/ui/theme-parser.c index 945ed44..aef6cee 100755 --- a/src/ui/theme-parser.c +++ b/src/ui/theme-parser.c @@ -87,7 +87,7 @@ typedef struct char *theme_file; /* theme filename */ char *theme_dir; /* dir the theme is inside */ MetaTheme *theme; /* theme being parsed */ - guint format_version; /* version of format of theme file */ + guint format_version; /* version of format of theme file */ char *name; /* name of named thing being parsed */ MetaFrameLayout *layout; /* layout being parsed if any */ MetaDrawOpList *op_list; /* op list being parsed if any */ @@ -236,7 +236,7 @@ set_error (GError **err, int line, ch; va_list args; char *str; - + g_markup_parse_context_get_position (context, &line, &ch); va_start (args, format); @@ -292,7 +292,7 @@ parse_info_free (ParseInfo *info) g_free (info->theme_dir); g_slist_free (info->states); - + if (info->theme) meta_theme_free (info->theme); @@ -304,7 +304,7 @@ parse_info_free (ParseInfo *info) if (info->op) meta_draw_op_free (info->op); - + if (info->style) meta_frame_style_unref (info->style); @@ -323,7 +323,7 @@ static void pop_state (ParseInfo *info) { g_return_if_fail (info->states != NULL); - + info->states = g_slist_remove (info->states, info->states->data); } @@ -379,7 +379,7 @@ locate_attributes (GMarkupParseContext *context, if (attrs[0].required) attrs[0].name++; /* skip past it */ *first_attribute_retloc = NULL; - + va_start (args, first_attribute_retloc); name = va_arg (args, const char*); @@ -390,7 +390,7 @@ locate_attributes (GMarkupParseContext *context, g_return_val_if_fail (retloc != NULL, FALSE); g_assert (n_attrs < MAX_ATTRS); - + attrs[n_attrs].name = name; attrs[n_attrs].retloc = retloc; attrs[n_attrs].required = attrs[n_attrs].name[0]=='!'; @@ -398,7 +398,7 @@ locate_attributes (GMarkupParseContext *context, attrs[n_attrs].name++; /* skip past it */ n_attrs += 1; - *retloc = NULL; + *retloc = NULL; name = va_arg (args, const char*); retloc = va_arg (args, const char**); @@ -422,7 +422,7 @@ locate_attributes (GMarkupParseContext *context, if (*retloc != NULL) { - + set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, @@ -446,7 +446,7 @@ locate_attributes (GMarkupParseContext *context, { g_warning ("It could have been %s.\n", attrs[j++].name); } - + set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, @@ -514,9 +514,9 @@ parse_positive_integer (const char *str, int j; *val = 0; - + end = NULL; - + /* Is str a constant? */ if (META_THEME_ALLOWS (theme, META_THEME_UBIQUITOUS_CONSTANTS) && @@ -566,7 +566,7 @@ parse_positive_integer (const char *str, l, MAX_REASONABLE); return FALSE; } - + *val = (int) l; return TRUE; @@ -581,9 +581,9 @@ parse_double (const char *str, char *end; *val = 0; - + end = NULL; - + *val = g_ascii_strtod (str, &end); if (end == NULL || end == str) @@ -625,7 +625,7 @@ parse_boolean (const char *str, str); return FALSE; } - + return TRUE; } @@ -653,14 +653,14 @@ parse_rounding (const char *str, str); return FALSE; } - + result = parse_positive_integer (str, &tmp, context, theme, error); *val = tmp; - return result; + return result; } - + return TRUE; } @@ -696,7 +696,7 @@ parse_alpha (const char *str, MetaAlphaGradientSpec *spec; *spec_ret = NULL; - + split = g_strsplit (str, ":", -1); i = 0; @@ -710,7 +710,7 @@ parse_alpha (const char *str, str); g_strfreev (split); - + return FALSE; } @@ -726,13 +726,13 @@ parse_alpha (const char *str, while (i < n_alphas) { double v; - + if (!parse_double (split[i], &v, context, error)) { /* clear up, but don't set error: it was set by parse_double */ g_strfreev (split); meta_alpha_gradient_spec_free (spec); - + return FALSE; } @@ -743,20 +743,20 @@ parse_alpha (const char *str, v); g_strfreev (split); - meta_alpha_gradient_spec_free (spec); - + meta_alpha_gradient_spec_free (spec); + return FALSE; } spec->alphas[i] = (unsigned char) (v * 255); - + ++i; - } + } g_strfreev (split); - + *spec_ret = spec; - + return TRUE; } @@ -772,10 +772,10 @@ parse_color (MetaTheme *theme, { if (referent) return meta_color_spec_new_from_string (referent, err); - + /* no need to free referent: it's a pointer into the actual hash table */ } - + return meta_color_spec_new_from_string (str, err); } @@ -786,7 +786,7 @@ parse_title_scale (const char *str, GError **error) { double factor; - + if (strcmp (str, "xx-small") == 0) factor = PANGO_SCALE_XX_SMALL; else if (strcmp (str, "x-small") == 0) @@ -810,7 +810,7 @@ parse_title_scale (const char *str, } *val = factor; - + return TRUE; } @@ -839,7 +839,7 @@ parse_toplevel_element (GMarkupParseContext *context, const char *value; int ival = 0; double dval = 0.0; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!name", &name, "!value", &value, @@ -938,14 +938,14 @@ parse_toplevel_element (GMarkupParseContext *context, if (rounded_top_right && !parse_rounding (rounded_top_right, &rounded_top_right_val, context, info->theme, error)) return; if (rounded_bottom_left && !parse_rounding (rounded_bottom_left, &rounded_bottom_left_val, context, info->theme, error)) - return; + return; if (rounded_bottom_right && !parse_rounding (rounded_bottom_right, &rounded_bottom_right_val, context, info->theme, error)) return; - + title_scale_val = 1.0; if (title_scale && !parse_title_scale (title_scale, &title_scale_val, context, error)) return; - + if (meta_theme_lookup_layout (info->theme, name)) { set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, @@ -994,7 +994,7 @@ parse_toplevel_element (GMarkupParseContext *context, if (rounded_bottom_right) info->layout->bottom_right_corner_rounded_radius = rounded_bottom_right_val; - + meta_theme_insert_layout (info->theme, name, info->layout); push_state (info, STATE_FRAME_GEOMETRY); @@ -1104,16 +1104,16 @@ parse_toplevel_element (GMarkupParseContext *context, if (alpha != NULL) { - + gboolean success; MetaAlphaGradientSpec *alpha_vector; - + g_clear_error (error); /* fortunately, we already have a routine to parse alpha values, * though it produces a vector of them, which is a superset of * what we want. */ - success = parse_alpha (alpha, &alpha_vector, context, error); + success = parse_alpha (alpha, &alpha_vector, context, error); if (!success) return; @@ -1228,7 +1228,7 @@ parse_toplevel_element (GMarkupParseContext *context, * for backwards compatibility. */ g_assert (info->op_list == NULL); - + push_state (info, STATE_MENU_ICON); } else if (ELEMENT_IS ("fallback")) @@ -1322,7 +1322,7 @@ parse_distance (GMarkupParseContext *context, const char *name; const char *value; int val; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!name", &name, "!value", &value, @@ -1351,13 +1351,13 @@ parse_distance (GMarkupParseContext *context, else if (strcmp (name, "button_width") == 0) { info->layout->button_width = val; - + if (!(info->layout->button_sizing == META_BUTTON_SIZING_LAST || info->layout->button_sizing == META_BUTTON_SIZING_FIXED)) { set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, _("Cannot specify both \"button_width\"/\"button_height\" and \"aspect_ratio\" for buttons")); - return; + return; } info->layout->button_sizing = META_BUTTON_SIZING_FIXED; @@ -1365,13 +1365,13 @@ parse_distance (GMarkupParseContext *context, else if (strcmp (name, "button_height") == 0) { info->layout->button_height = val; - + if (!(info->layout->button_sizing == META_BUTTON_SIZING_LAST || info->layout->button_sizing == META_BUTTON_SIZING_FIXED)) { set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, _("Cannot specify both \"button_width\"/\"button_height\" and \"aspect_ratio\" for buttons")); - return; + return; } info->layout->button_sizing = META_BUTTON_SIZING_FIXED; @@ -1395,7 +1395,7 @@ parse_aspect_ratio (GMarkupParseContext *context, const char *name; const char *value; double val; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!name", &name, "!value", &value, @@ -1407,7 +1407,7 @@ parse_aspect_ratio (GMarkupParseContext *context, return; g_assert (info->layout); - + if (strcmp (name, "button") == 0) { info->layout->button_aspect = val; @@ -1418,7 +1418,7 @@ parse_aspect_ratio (GMarkupParseContext *context, _("Cannot specify both \"button_width\"/\"button_height\" and \"aspect_ratio\" for buttons")); return; } - + info->layout->button_sizing = META_BUTTON_SIZING_ASPECT; } else @@ -1447,7 +1447,7 @@ parse_border (GMarkupParseContext *context, int left_val; int right_val; GtkBorder *border; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!name", &name, @@ -1457,7 +1457,7 @@ parse_border (GMarkupParseContext *context, "!right", &right, NULL)) return; - + top_val = 0; if (!parse_positive_integer (top, &top_val, context, info->theme, error)) return; @@ -1473,11 +1473,11 @@ parse_border (GMarkupParseContext *context, right_val = 0; if (!parse_positive_integer (right, &right_val, context, info->theme, error)) return; - + g_assert (info->layout); border = NULL; - + if (strcmp (name, "title_border") == 0) border = &info->layout->title_border; else if (strcmp (name, "button_border") == 0) @@ -1553,7 +1553,7 @@ check_expression (PosToken *tokens, * it's possible we should instead guarantee that widths and heights * are at least 1. */ - + env.rect = meta_rect (0, 0, 0, 0); if (has_object) { @@ -1572,13 +1572,13 @@ check_expression (PosToken *tokens, env.bottom_height = 0; env.title_width = 0; env.title_height = 0; - + env.icon_width = 0; env.icon_height = 0; env.mini_icon_width = 0; env.mini_icon_height = 0; env.theme = theme; - + if (!meta_parse_position_expression (tokens, n_tokens, &env, &x, &y, @@ -1599,7 +1599,7 @@ parse_draw_op_element (GMarkupParseContext *context, const gchar **attribute_values, ParseInfo *info, GError **error) -{ +{ g_return_if_fail (peek_state (info) == STATE_DRAW_OPS); if (ELEMENT_IS ("line")) @@ -1617,7 +1617,7 @@ parse_draw_op_element (GMarkupParseContext *context, int dash_on_val; int dash_off_val; int width_val; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!color", &color, @@ -1638,11 +1638,11 @@ parse_draw_op_element (GMarkupParseContext *context, if (!check_expression (x2, FALSE, info->theme, context, error)) return; - + if (!check_expression (y2, FALSE, info->theme, context, error)) return; #endif - + dash_on_val = 0; if (dash_on_length && !parse_positive_integer (dash_on_length, &dash_on_val, context, info->theme, error)) @@ -1667,7 +1667,7 @@ parse_draw_op_element (GMarkupParseContext *context, add_context_to_error (error, context); return; } - + op = meta_draw_op_new (META_DRAW_LINE); op->data.line.color_spec = color_spec; @@ -1690,7 +1690,7 @@ parse_draw_op_element (GMarkupParseContext *context, op->data.line.dash_off_length = dash_off_val; g_assert (info->op_list); - + meta_draw_op_list_append (info->op_list, op); push_state (info, STATE_LINE); @@ -1706,7 +1706,7 @@ parse_draw_op_element (GMarkupParseContext *context, const char *filled; gboolean filled_val; MetaColorSpec *color_spec; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!color", &color, @@ -1725,7 +1725,7 @@ parse_draw_op_element (GMarkupParseContext *context, if (!check_expression (width, FALSE, info->theme, context, error)) return; - + if (!check_expression (height, FALSE, info->theme, context, error)) return; #endif @@ -1733,7 +1733,7 @@ parse_draw_op_element (GMarkupParseContext *context, filled_val = FALSE; if (filled && !parse_boolean (filled, &filled_val, context, error)) return; - + /* Check last so we don't have to free it when other * stuff fails */ @@ -1743,20 +1743,20 @@ parse_draw_op_element (GMarkupParseContext *context, add_context_to_error (error, context); return; } - + op = meta_draw_op_new (META_DRAW_RECTANGLE); op->data.rectangle.color_spec = color_spec; op->data.rectangle.x = meta_draw_spec_new (info->theme, x, NULL); op->data.rectangle.y = meta_draw_spec_new (info->theme, y, NULL); op->data.rectangle.width = meta_draw_spec_new (info->theme, width, NULL); - op->data.rectangle.height = meta_draw_spec_new (info->theme, + op->data.rectangle.height = meta_draw_spec_new (info->theme, height, NULL); op->data.rectangle.filled = filled_val; g_assert (info->op_list); - + meta_draw_op_list_append (info->op_list, op); push_state (info, STATE_RECTANGLE); @@ -1778,7 +1778,7 @@ parse_draw_op_element (GMarkupParseContext *context, double start_angle_val; double extent_angle_val; MetaColorSpec *color_spec; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!color", &color, @@ -1825,7 +1825,7 @@ parse_draw_op_element (GMarkupParseContext *context, } } -#if 0 +#if 0 if (!check_expression (x, FALSE, info->theme, context, error)) return; @@ -1834,7 +1834,7 @@ parse_draw_op_element (GMarkupParseContext *context, if (!check_expression (width, FALSE, info->theme, context, error)) return; - + if (!check_expression (height, FALSE, info->theme, context, error)) return; #endif @@ -1843,7 +1843,7 @@ parse_draw_op_element (GMarkupParseContext *context, { if (!parse_angle (from, &start_angle_val, context, error)) return; - + start_angle_val = (180-start_angle_val)/360.0; } else @@ -1851,12 +1851,12 @@ parse_draw_op_element (GMarkupParseContext *context, if (!parse_angle (start_angle, &start_angle_val, context, error)) return; } - + if (extent_angle == NULL) { if (!parse_angle (to, &extent_angle_val, context, error)) return; - + extent_angle_val = ((180-extent_angle_val)/360.0) - start_angle_val; } else @@ -1864,11 +1864,11 @@ parse_draw_op_element (GMarkupParseContext *context, if (!parse_angle (extent_angle, &extent_angle_val, context, error)) return; } - + filled_val = FALSE; if (filled && !parse_boolean (filled, &filled_val, context, error)) return; - + /* Check last so we don't have to free it when other * stuff fails */ @@ -1878,7 +1878,7 @@ parse_draw_op_element (GMarkupParseContext *context, add_context_to_error (error, context); return; } - + op = meta_draw_op_new (META_DRAW_ARC); op->data.arc.color_spec = color_spec; @@ -1891,9 +1891,9 @@ parse_draw_op_element (GMarkupParseContext *context, op->data.arc.filled = filled_val; op->data.arc.start_angle = start_angle_val; op->data.arc.extent_angle = extent_angle_val; - + g_assert (info->op_list); - + meta_draw_op_list_append (info->op_list, op); push_state (info, STATE_ARC); @@ -1905,14 +1905,14 @@ parse_draw_op_element (GMarkupParseContext *context, const char *y; const char *width; const char *height; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!x", &x, "!y", &y, "!width", &width, "!height", &height, NULL)) return; - + #if 0 if (!check_expression (x, FALSE, info->theme, context, error)) return; @@ -1922,10 +1922,10 @@ parse_draw_op_element (GMarkupParseContext *context, if (!check_expression (width, FALSE, info->theme, context, error)) return; - + if (!check_expression (height, FALSE, info->theme, context, error)) return; -#endif +#endif op = meta_draw_op_new (META_DRAW_CLIP); op->data.clip.x = meta_draw_spec_new (info->theme, x, NULL); @@ -1934,7 +1934,7 @@ parse_draw_op_element (GMarkupParseContext *context, op->data.clip.height = meta_draw_spec_new (info->theme, height, NULL); g_assert (info->op_list); - + meta_draw_op_list_append (info->op_list, op); push_state (info, STATE_CLIP); @@ -1950,7 +1950,7 @@ parse_draw_op_element (GMarkupParseContext *context, const char *alpha; MetaAlphaGradientSpec *alpha_spec; MetaColorSpec *color_spec; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!color", &color, @@ -1969,14 +1969,14 @@ parse_draw_op_element (GMarkupParseContext *context, if (!check_expression (width, FALSE, info->theme, context, error)) return; - + if (!check_expression (height, FALSE, info->theme, context, error)) return; #endif alpha_spec = NULL; if (!parse_alpha (alpha, &alpha_spec, context, error)) return; - + /* Check last so we don't have to free it when other * stuff fails */ @@ -1985,11 +1985,11 @@ parse_draw_op_element (GMarkupParseContext *context, { if (alpha_spec) meta_alpha_gradient_spec_free (alpha_spec); - + add_context_to_error (error, context); return; } - + op = meta_draw_op_new (META_DRAW_TINT); op->data.tint.color_spec = color_spec; @@ -2001,7 +2001,7 @@ parse_draw_op_element (GMarkupParseContext *context, op->data.tint.height = meta_draw_spec_new (info->theme, height, NULL); g_assert (info->op_list); - + meta_draw_op_list_append (info->op_list, op); push_state (info, STATE_TINT); @@ -2016,7 +2016,7 @@ parse_draw_op_element (GMarkupParseContext *context, const char *alpha; MetaAlphaGradientSpec *alpha_spec; MetaGradientType type_val; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!type", &type, @@ -2035,11 +2035,11 @@ parse_draw_op_element (GMarkupParseContext *context, if (!check_expression (width, FALSE, info->theme, context, error)) return; - + if (!check_expression (height, FALSE, info->theme, context, error)) return; #endif - + type_val = meta_gradient_type_from_string (type); if (type_val == META_GRADIENT_LAST) { @@ -2052,13 +2052,13 @@ parse_draw_op_element (GMarkupParseContext *context, alpha_spec = NULL; if (alpha && !parse_alpha (alpha, &alpha_spec, context, error)) return; - + g_assert (info->op == NULL); info->op = meta_draw_op_new (META_DRAW_GRADIENT); info->op->data.gradient.x = meta_draw_spec_new (info->theme, x, NULL); info->op->data.gradient.y = meta_draw_spec_new (info->theme, y, NULL); - info->op->data.gradient.width = meta_draw_spec_new (info->theme, + info->op->data.gradient.width = meta_draw_spec_new (info->theme, width, NULL); info->op->data.gradient.height = meta_draw_spec_new (info->theme, height, NULL); @@ -2066,7 +2066,7 @@ parse_draw_op_element (GMarkupParseContext *context, info->op->data.gradient.gradient_spec = meta_gradient_spec_new (type_val); info->op->data.gradient.alpha_spec = alpha_spec; - + push_state (info, STATE_GRADIENT); /* op gets appended on close tag */ @@ -2089,7 +2089,7 @@ parse_draw_op_element (GMarkupParseContext *context, int h, w, c; int pixbuf_width, pixbuf_height, pixbuf_n_channels, pixbuf_rowstride; guchar *pixbuf_pixels; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!x", &x, "!y", &y, @@ -2099,8 +2099,8 @@ parse_draw_op_element (GMarkupParseContext *context, "fill_type", &fill_type, NULL)) return; - -#if 0 + +#if 0 if (!check_expression (x, TRUE, info->theme, context, error)) return; @@ -2109,7 +2109,7 @@ parse_draw_op_element (GMarkupParseContext *context, if (!check_expression (width, TRUE, info->theme, context, error)) return; - + if (!check_expression (height, TRUE, info->theme, context, error)) return; #endif @@ -2117,7 +2117,7 @@ parse_draw_op_element (GMarkupParseContext *context, if (fill_type) { fill_type_val = meta_image_fill_type_from_string (fill_type); - + if (((int) fill_type_val) == -1) { set_error (error, context, G_MARKUP_ERROR, @@ -2126,7 +2126,7 @@ parse_draw_op_element (GMarkupParseContext *context, fill_type, element_name); } } - + /* Check last so we don't have to free it when other * stuff fails. * @@ -2144,7 +2144,7 @@ parse_draw_op_element (GMarkupParseContext *context, if (colorize) { colorize_spec = parse_color (info->theme, colorize, error); - + if (colorize_spec == NULL) { add_context_to_error (error, context); @@ -2159,7 +2159,7 @@ parse_draw_op_element (GMarkupParseContext *context, g_object_unref (G_OBJECT (pixbuf)); return; } - + op = meta_draw_op_new (META_DRAW_IMAGE); op->data.image.pixbuf = pixbuf; @@ -2172,7 +2172,7 @@ parse_draw_op_element (GMarkupParseContext *context, op->data.image.alpha_spec = alpha_spec; op->data.image.fill_type = fill_type_val; - + /* Check for vertical & horizontal stripes */ pixbuf_n_channels = gdk_pixbuf_get_n_channels(pixbuf); pixbuf_width = gdk_pixbuf_get_width(pixbuf); @@ -2200,11 +2200,11 @@ parse_draw_op_element (GMarkupParseContext *context, if (h >= pixbuf_height) { - op->data.image.horizontal_stripes = TRUE; + op->data.image.horizontal_stripes = TRUE; } else { - op->data.image.horizontal_stripes = FALSE; + op->data.image.horizontal_stripes = FALSE; } /* Check for vertical stripes */ @@ -2227,15 +2227,15 @@ parse_draw_op_element (GMarkupParseContext *context, if (w >= pixbuf_width) { - op->data.image.vertical_stripes = TRUE; + op->data.image.vertical_stripes = TRUE; } else { - op->data.image.vertical_stripes = FALSE; + op->data.image.vertical_stripes = FALSE; } - + g_assert (info->op_list); - + meta_draw_op_list_append (info->op_list, op); push_state (info, STATE_IMAGE); @@ -2255,7 +2255,7 @@ parse_draw_op_element (GMarkupParseContext *context, GtkStateType state_val; GtkShadowType shadow_val; GtkArrowType arrow_val; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!state", &state, @@ -2276,7 +2276,7 @@ parse_draw_op_element (GMarkupParseContext *context, if (!check_expression (width, FALSE, info->theme, context, error)) return; - + if (!check_expression (height, FALSE, info->theme, context, error)) return; #endif @@ -2313,22 +2313,22 @@ parse_draw_op_element (GMarkupParseContext *context, arrow, element_name); return; } - + op = meta_draw_op_new (META_DRAW_GTK_ARROW); op->data.gtk_arrow.x = meta_draw_spec_new (info->theme, x, NULL); op->data.gtk_arrow.y = meta_draw_spec_new (info->theme, y, NULL); op->data.gtk_arrow.width = meta_draw_spec_new (info->theme, width, NULL); - op->data.gtk_arrow.height = meta_draw_spec_new (info->theme, + op->data.gtk_arrow.height = meta_draw_spec_new (info->theme, height, NULL); op->data.gtk_arrow.filled = filled_val; op->data.gtk_arrow.state = state_val; op->data.gtk_arrow.shadow = shadow_val; op->data.gtk_arrow.arrow = arrow_val; - + g_assert (info->op_list); - + meta_draw_op_list_append (info->op_list, op); push_state (info, STATE_GTK_ARROW); @@ -2344,7 +2344,7 @@ parse_draw_op_element (GMarkupParseContext *context, const char *height; GtkStateType state_val; GtkShadowType shadow_val; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!state", &state, @@ -2363,7 +2363,7 @@ parse_draw_op_element (GMarkupParseContext *context, if (!check_expression (width, FALSE, info->theme, context, error)) return; - + if (!check_expression (height, FALSE, info->theme, context, error)) return; #endif @@ -2386,7 +2386,7 @@ parse_draw_op_element (GMarkupParseContext *context, shadow, element_name); return; } - + op = meta_draw_op_new (META_DRAW_GTK_BOX); op->data.gtk_box.x = meta_draw_spec_new (info->theme, x, NULL); @@ -2396,9 +2396,9 @@ parse_draw_op_element (GMarkupParseContext *context, op->data.gtk_box.state = state_val; op->data.gtk_box.shadow = shadow_val; - + g_assert (info->op_list); - + meta_draw_op_list_append (info->op_list, op); push_state (info, STATE_GTK_BOX); @@ -2411,7 +2411,7 @@ parse_draw_op_element (GMarkupParseContext *context, const char *y1; const char *y2; GtkStateType state_val; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!state", &state, @@ -2439,7 +2439,7 @@ parse_draw_op_element (GMarkupParseContext *context, state, element_name); return; } - + op = meta_draw_op_new (META_DRAW_GTK_VLINE); op->data.gtk_vline.x = meta_draw_spec_new (info->theme, x, NULL); @@ -2447,9 +2447,9 @@ parse_draw_op_element (GMarkupParseContext *context, op->data.gtk_vline.y2 = meta_draw_spec_new (info->theme, y2, NULL); op->data.gtk_vline.state = state_val; - + g_assert (info->op_list); - + meta_draw_op_list_append (info->op_list, op); push_state (info, STATE_GTK_VLINE); @@ -2465,7 +2465,7 @@ parse_draw_op_element (GMarkupParseContext *context, const char *fill_type; MetaAlphaGradientSpec *alpha_spec; MetaImageFillType fill_type_val; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!x", &x, "!y", &y, @@ -2474,8 +2474,8 @@ parse_draw_op_element (GMarkupParseContext *context, "fill_type", &fill_type, NULL)) return; - -#if 0 + +#if 0 if (!check_expression (x, FALSE, info->theme, context, error)) return; @@ -2484,7 +2484,7 @@ parse_draw_op_element (GMarkupParseContext *context, if (!check_expression (width, FALSE, info->theme, context, error)) return; - + if (!check_expression (height, FALSE, info->theme, context, error)) return; #endif @@ -2501,13 +2501,13 @@ parse_draw_op_element (GMarkupParseContext *context, fill_type, element_name); } } - + alpha_spec = NULL; if (alpha && !parse_alpha (alpha, &alpha_spec, context, error)) return; - + op = meta_draw_op_new (META_DRAW_ICON); - + op->data.icon.x = meta_draw_spec_new (info->theme, x, NULL); op->data.icon.y = meta_draw_spec_new (info->theme, y, NULL); op->data.icon.width = meta_draw_spec_new (info->theme, width, NULL); @@ -2515,9 +2515,9 @@ parse_draw_op_element (GMarkupParseContext *context, op->data.icon.alpha_spec = alpha_spec; op->data.icon.fill_type = fill_type_val; - + g_assert (info->op_list); - + meta_draw_op_list_append (info->op_list, op); push_state (info, STATE_ICON); @@ -2529,7 +2529,7 @@ parse_draw_op_element (GMarkupParseContext *context, const char *x; const char *y; MetaColorSpec *color_spec; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!color", &color, @@ -2554,7 +2554,7 @@ parse_draw_op_element (GMarkupParseContext *context, add_context_to_error (error, context); return; } - + op = meta_draw_op_new (META_DRAW_TITLE); op->data.title.color_spec = color_spec; @@ -2563,7 +2563,7 @@ parse_draw_op_element (GMarkupParseContext *context, op->data.title.y = meta_draw_spec_new (info->theme, y, NULL); g_assert (info->op_list); - + meta_draw_op_list_append (info->op_list, op); push_state (info, STATE_TITLE); @@ -2577,7 +2577,7 @@ parse_draw_op_element (GMarkupParseContext *context, const char *width; const char *height; MetaDrawOpList *op_list; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "x", &x, "y", &y, @@ -2589,7 +2589,7 @@ parse_draw_op_element (GMarkupParseContext *context, /* x/y/width/height default to 0,0,width,height - should * probably do this for all the draw ops */ -#if 0 +#if 0 if (x && !check_expression (x, FALSE, info->theme, context, error)) return; @@ -2598,7 +2598,7 @@ parse_draw_op_element (GMarkupParseContext *context, if (width && !check_expression (width, FALSE, info->theme, context, error)) return; - + if (height && !check_expression (height, FALSE, info->theme, context, error)) return; #endif @@ -2615,7 +2615,7 @@ parse_draw_op_element (GMarkupParseContext *context, } g_assert (info->op_list); - + if (op_list == info->op_list || meta_draw_op_list_contains (op_list, info->op_list)) { @@ -2625,15 +2625,15 @@ parse_draw_op_element (GMarkupParseContext *context, name); return; } - + op = meta_draw_op_new (META_DRAW_OP_LIST); meta_draw_op_list_ref (op_list); - op->data.op_list.op_list = op_list; + op->data.op_list.op_list = op_list; op->data.op_list.x = meta_draw_spec_new (info->theme, x ? x : "0", NULL); op->data.op_list.y = meta_draw_spec_new (info->theme, y ? y : "0", NULL); - op->data.op_list.width = meta_draw_spec_new (info->theme, + op->data.op_list.width = meta_draw_spec_new (info->theme, width ? width : "width", NULL); op->data.op_list.height = meta_draw_spec_new (info->theme, @@ -2657,7 +2657,7 @@ parse_draw_op_element (GMarkupParseContext *context, const char *tile_width; const char *tile_height; MetaDrawOpList *op_list; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "x", &x, "y", &y, @@ -2677,7 +2677,7 @@ parse_draw_op_element (GMarkupParseContext *context, if (tile_yoffset && !check_expression (tile_yoffset, FALSE, info->theme, context, error)) return; - + /* x/y/width/height default to 0,0,width,height - should * probably do this for all the draw ops */ @@ -2689,7 +2689,7 @@ parse_draw_op_element (GMarkupParseContext *context, if (width && !check_expression (width, FALSE, info->theme, context, error)) return; - + if (height && !check_expression (height, FALSE, info->theme, context, error)) return; @@ -2698,7 +2698,7 @@ parse_draw_op_element (GMarkupParseContext *context, if (!check_expression (tile_height, FALSE, info->theme, context, error)) return; -#endif +#endif op_list = meta_theme_lookup_draw_op_list (info->theme, name); if (op_list == NULL) @@ -2711,7 +2711,7 @@ parse_draw_op_element (GMarkupParseContext *context, } g_assert (info->op_list); - + if (op_list == info->op_list || meta_draw_op_list_contains (op_list, info->op_list)) { @@ -2721,7 +2721,7 @@ parse_draw_op_element (GMarkupParseContext *context, name); return; } - + op = meta_draw_op_new (META_DRAW_TILE); meta_draw_op_list_ref (op_list); @@ -2743,8 +2743,8 @@ parse_draw_op_element (GMarkupParseContext *context, op->data.tile.tile_width = meta_draw_spec_new (info->theme, tile_width, NULL); op->data.tile.tile_height = meta_draw_spec_new (info->theme, tile_height, NULL); - op->data.tile.op_list = op_list; - + op->data.tile.op_list = op_list; + meta_draw_op_list_append (info->op_list, op); push_state (info, STATE_TILE); @@ -2792,7 +2792,7 @@ parse_gradient_element (GMarkupParseContext *context, info->op->data.gradient.gradient_spec->color_specs = g_slist_append (info->op->data.gradient.gradient_spec->color_specs, color_spec); - + push_state (info, STATE_COLOR); } else @@ -2815,12 +2815,12 @@ parse_style_element (GMarkupParseContext *context, g_return_if_fail (peek_state (info) == STATE_FRAME_STYLE); g_assert (info->style); - + if (ELEMENT_IS ("piece")) { const char *position = NULL; const char *draw_ops = NULL; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!position", &position, @@ -2836,7 +2836,7 @@ parse_style_element (GMarkupParseContext *context, position); return; } - + if (info->style->pieces[info->piece] != NULL) { set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, @@ -2846,7 +2846,7 @@ parse_style_element (GMarkupParseContext *context, } g_assert (info->op_list == NULL); - + if (draw_ops) { MetaDrawOpList *op_list; @@ -2865,7 +2865,7 @@ parse_style_element (GMarkupParseContext *context, meta_draw_op_list_ref (op_list); info->op_list = op_list; } - + push_state (info, STATE_PIECE); } else if (ELEMENT_IS ("button")) @@ -2873,7 +2873,7 @@ parse_style_element (GMarkupParseContext *context, const char *function = NULL; const char *state = NULL; const char *draw_ops = NULL; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!function", &function, @@ -2911,7 +2911,7 @@ parse_style_element (GMarkupParseContext *context, state); return; } - + if (info->style->buttons[info->button_type][info->button_state] != NULL) { set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, @@ -2921,7 +2921,7 @@ parse_style_element (GMarkupParseContext *context, } g_assert (info->op_list == NULL); - + if (draw_ops) { MetaDrawOpList *op_list; @@ -2940,22 +2940,24 @@ parse_style_element (GMarkupParseContext *context, meta_draw_op_list_ref (op_list); info->op_list = op_list; } - + push_state (info, STATE_BUTTON); } else if (ELEMENT_IS ("shadow")) { const char *shadow_radius = NULL; + const char *shadow_opacity = NULL; const char *shadow_color = NULL; const char *shadow_x_offset = NULL; const char *shadow_y_offset = NULL; - double shadow_radius_v; + double shadow_radius_v, shadow_opacity_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, + "opacity", &shadow_opacity, "color", &shadow_color, "x_offset", &shadow_x_offset, "y_offset", &shadow_y_offset, @@ -2963,16 +2965,16 @@ parse_style_element (GMarkupParseContext *context, return; parse_double (shadow_radius, &shadow_radius_v, context, error); + parse_double (shadow_opacity, &shadow_opacity_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_opacity = shadow_opacity_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; @@ -2986,7 +2988,7 @@ parse_style_element (GMarkupParseContext *context, 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, @@ -2999,8 +3001,6 @@ parse_style_element (GMarkupParseContext *context, 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 (); @@ -3039,7 +3039,7 @@ parse_style_set_element (GMarkupParseContext *context, MetaFrameState frame_state; MetaFrameResize frame_resize; MetaFrameStyle *frame_style; - + if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!focus", &focus, @@ -3057,7 +3057,7 @@ parse_style_set_element (GMarkupParseContext *context, focus); return; } - + frame_state = meta_frame_state_from_string (state); if (frame_state == META_FRAME_STATE_LAST) { @@ -3088,7 +3088,7 @@ parse_style_set_element (GMarkupParseContext *context, return; } - + frame_resize = meta_frame_resize_from_string (resize); if (frame_resize == META_FRAME_RESIZE_LAST) { @@ -3097,7 +3097,7 @@ parse_style_set_element (GMarkupParseContext *context, focus); return; } - + break; case META_FRAME_STATE_SHADED: @@ -3136,7 +3136,7 @@ parse_style_set_element (GMarkupParseContext *context, frame_resize = META_FRAME_RESIZE_BOTH; } break; - + default: if (resize != NULL) { @@ -3148,7 +3148,7 @@ parse_style_set_element (GMarkupParseContext *context, frame_resize = META_FRAME_RESIZE_LAST; } - + switch (frame_state) { case META_FRAME_STATE_NORMAL: @@ -3200,7 +3200,7 @@ parse_style_set_element (GMarkupParseContext *context, break; } - push_state (info, STATE_FRAME); + push_state (info, STATE_FRAME); } else { @@ -3230,7 +3230,7 @@ parse_piece_element (GMarkupParseContext *context, _("Can't have a two draw_ops for a <piece> element (theme specified a draw_ops attribute and also a <draw_ops> element, or specified two elements)")); return; } - + if (!check_no_attributes (context, element_name, attribute_names, attribute_values, error)) return; @@ -3258,7 +3258,7 @@ parse_button_element (GMarkupParseContext *context, GError **error) { g_return_if_fail (peek_state (info) == STATE_BUTTON); - + if (ELEMENT_IS ("draw_ops")) { if (info->op_list) @@ -3268,7 +3268,7 @@ parse_button_element (GMarkupParseContext *context, _("Can't have a two draw_ops for a <button> element (theme specified a draw_ops attribute and also a <draw_ops> element, or specified two elements)")); return; } - + if (!check_no_attributes (context, element_name, attribute_names, attribute_values, error)) return; @@ -3338,7 +3338,7 @@ parse_menu_icon_element (GMarkupParseContext *context, _("Can't have a two draw_ops for a <menu_icon> element (theme specified a draw_ops attribute and also a <draw_ops> element, or specified two elements)")); return; } - + if (!check_no_attributes (context, element_name, attribute_names, attribute_values, error)) return; @@ -3528,7 +3528,7 @@ end_element_handler (GMarkupParseContext *context, meta_theme_free (info->theme); info->theme = NULL; } - + pop_state (info); g_assert (peek_state (info) == STATE_START); break; @@ -3592,7 +3592,7 @@ end_element_handler (GMarkupParseContext *context, case STATE_DRAW_OPS: { g_assert (info->op_list); - + if (!meta_draw_op_list_validate (info->op_list, error)) { @@ -3806,10 +3806,10 @@ all_whitespace (const char *text, { const char *p; const char *end; - + p = text; end = text + text_len; - + while (p != end) { if (!g_ascii_isspace (*p)) @@ -3832,7 +3832,7 @@ text_handler (GMarkupParseContext *context, if (all_whitespace (text, text_len)) return; - + /* FIXME http://bugzilla.gnome.org/show_bug.cgi?id=70448 would * allow a nice cleanup here. */ @@ -4038,10 +4038,10 @@ meta_theme_load (const char *theme_name, length = 0; retval = NULL; context = NULL; - + theme_dir = NULL; theme_file = NULL; - + if (meta_is_debugging ()) { gchar *theme_filename = g_strdup_printf (METACITY_THEME_FILENAME_FORMAT, @@ -4049,11 +4049,11 @@ meta_theme_load (const char *theme_name, /* Try in themes in our source tree */ theme_dir = g_build_filename ("./themes", theme_name, NULL); - + theme_file = g_build_filename (theme_dir, theme_filename, NULL); - + error = NULL; if (!g_file_get_contents (theme_file, &text, @@ -4071,13 +4071,13 @@ meta_theme_load (const char *theme_name, g_free (theme_filename); } - + /* We try all supported versions from current to oldest */ for (version = THEME_VERSION; (version > 0) && (text == NULL); version--) { gchar *theme_filename = g_strdup_printf (METACITY_THEME_FILENAME_FORMAT, version); - + /* We try first in home dir, XDG_DATA_DIRS, then system dir for themes */ /* Try home dir for themes */ @@ -4086,7 +4086,7 @@ meta_theme_load (const char *theme_name, theme_name, THEME_SUBDIR, NULL); - + theme_file = g_build_filename (theme_dir, theme_filename, NULL); @@ -4149,7 +4149,7 @@ meta_theme_load (const char *theme_name, theme_name, THEME_SUBDIR, NULL); - + theme_file = g_build_filename (theme_dir, theme_filename, NULL); @@ -4186,13 +4186,13 @@ meta_theme_load (const char *theme_name, parse_info_init (&info); info.theme_name = theme_name; - + /* pass ownership to info so we free it with the info */ info.theme_file = theme_file; info.theme_dir = theme_dir; info.format_version = version + 1; - + context = g_markup_parse_context_new (&metacity_theme_parser, 0, &info, NULL); diff --git a/src/ui/theme.h b/src/ui/theme.h index 5d65962..88d3bf0 100755 --- a/src/ui/theme.h +++ b/src/ui/theme.h @@ -2,9 +2,9 @@ /* Metacity Theme Rendering */ -/* +/* * 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 @@ -14,7 +14,7 @@ * 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA @@ -34,7 +34,7 @@ typedef struct _MetaFrameStyleSet MetaFrameStyleSet; typedef struct _MetaDrawOp MetaDrawOp; typedef struct _MetaDrawOpList MetaDrawOpList; typedef struct _MetaGradientSpec MetaGradientSpec; -typedef struct _MetaAlphaGradientSpec MetaAlphaGradientSpec; +typedef struct _MetaAlphaGradientSpec MetaAlphaGradientSpec; typedef struct _MetaColorSpec MetaColorSpec; typedef struct _MetaFrameLayout MetaFrameLayout; typedef struct _MetaButtonSpace MetaButtonSpace; @@ -51,6 +51,12 @@ struct _MetaShadowProperties * Radius of the shadow */ double unity_shadow_radius; + + /** + * Opacity of the shadow + */ + double unity_shadow_opacity; + /** * Color of the shadow */ @@ -126,14 +132,14 @@ struct _MetaFrameLayout { /** Reference count. */ int refcount; - + /** Size of left side */ int left_width; /** Size of right side */ int right_width; /** Size of bottom side */ int bottom_height; - + /** Border of blue title region * \bug (blue?!) **/ @@ -141,12 +147,12 @@ struct _MetaFrameLayout /** Extra height for inside of title region, above the font height */ int title_vertical_pad; - + /** Right indent of buttons from edges of frame */ int right_titlebar_edge; /** Left indent of buttons from edges of frame */ int left_titlebar_edge; - + /** * Sizing rule of buttons, either META_BUTTON_SIZING_ASPECT * (in which case button_aspect will be honoured, and @@ -162,7 +168,7 @@ struct _MetaFrameLayout * Otherwise we figure out the height from the button_border. */ double button_aspect; - + /** Width of a button; set even when we are using aspect sizing */ int button_width; @@ -174,7 +180,7 @@ struct _MetaFrameLayout /** scale factor for title text */ double title_scale; - + /** Whether title text will be displayed */ guint has_title : 1; @@ -216,7 +222,7 @@ struct _MetaFrameGeometry int bottom_height; int width; - int height; + int height; GdkRectangle title_rect; @@ -228,7 +234,7 @@ struct _MetaFrameGeometry /* used for a memset hack */ #define ADDRESS_OF_BUTTON_RECTS(fgeom) (((char*)(fgeom)) + G_STRUCT_OFFSET (MetaFrameGeometry, close_rect)) #define LENGTH_OF_BUTTON_RECTS (G_STRUCT_OFFSET (MetaFrameGeometry, right_right_background) + sizeof (GdkRectangle) - G_STRUCT_OFFSET (MetaFrameGeometry, close_rect)) - + /* The button rects (if changed adjust memset hack) */ MetaButtonSpace close_rect; MetaButtonSpace max_rect; @@ -249,7 +255,7 @@ struct _MetaFrameGeometry GdkRectangle right_middle_backgrounds[MAX_MIDDLE_BACKGROUNDS]; GdkRectangle right_right_background; /* End of button rects (if changed adjust memset hack) */ - + /* Round corners */ guint top_left_corner_rounded_radius; guint top_right_corner_rounded_radius; @@ -349,14 +355,14 @@ typedef enum /** Clip to a rectangle */ META_DRAW_CLIP, - + /* Texture thingies */ /** Just a filled rectangle with alpha */ META_DRAW_TINT, META_DRAW_GRADIENT, META_DRAW_IMAGE, - + /** GTK theme engine stuff */ META_DRAW_GTK_ARROW, META_DRAW_GTK_BOX, @@ -442,7 +448,7 @@ typedef struct _MetaDrawSpec * otherwise it is zero. */ int value; - + /** A list of tokens in the expression. */ PosToken *tokens; @@ -500,7 +506,7 @@ struct _MetaDrawOp MetaDrawSpec *width; MetaDrawSpec *height; } clip; - + struct { MetaColorSpec *color_spec; MetaAlphaGradientSpec *alpha_spec; @@ -534,7 +540,7 @@ struct _MetaDrawOp unsigned int vertical_stripes : 1; unsigned int horizontal_stripes : 1; } image; - + struct { GtkStateType state; GtkShadowType shadow; @@ -560,7 +566,7 @@ struct _MetaDrawOp GtkStateType state; MetaDrawSpec *x; MetaDrawSpec *y1; - MetaDrawSpec *y2; + MetaDrawSpec *y2; } gtk_vline; struct { @@ -597,7 +603,7 @@ struct _MetaDrawOp MetaDrawSpec *tile_width; MetaDrawSpec *tile_height; } tile; - + } data; }; @@ -670,7 +676,7 @@ typedef enum * | rather than | * */ - + /* entire frame */ META_FRAME_PIECE_ENTIRE_BACKGROUND, /* entire titlebar background */ @@ -747,7 +753,7 @@ struct _MetaFrameStyle }; /* Kinds of frame... - * + * * normal -> noresize / vert only / horz only / both * focused / unfocused * max -> focused / unfocused @@ -759,7 +765,7 @@ struct _MetaFrameStyle * * 14 window states times 7 or 8 window types. Except some * window types never get a frame so that narrows it down a bit. - * + * */ typedef enum { @@ -1142,7 +1148,7 @@ void meta_theme_calc_geometry (MetaTheme *theme, int client_height, const MetaButtonLayout *button_layout, MetaFrameGeometry *fgeom); - + MetaFrameLayout* meta_theme_lookup_layout (MetaTheme *theme, const char *name); void meta_theme_insert_layout (MetaTheme *theme, |