summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas James Alexander Thurman <tthurman@src.gnome.org>2006-06-16 01:45:02 +0000
committerThomas James Alexander Thurman <tthurman@src.gnome.org>2006-06-16 01:45:02 +0000
commit4ace093d0e37b3c9a86adcfaef37eb93b0a06236 (patch)
tree8aa0e0a7151b9dcf8ee862ac75f8d5c233dc20b6
parent40775ab8474042166fea14c09fc3827860d719b6 (diff)
downloadmetacity-4ace093d0e37b3c9a86adcfaef37eb93b0a06236.tar.gz
buttons appear correctly on v1 themes again; v2 button keywords don't work in v1 themes
-rw-r--r--src/theme-parser.c2
-rw-r--r--src/theme.c123
-rw-r--r--src/theme.h7
3 files changed, 87 insertions, 45 deletions
diff --git a/src/theme-parser.c b/src/theme-parser.c
index 397212ba..3d8b0bd7 100644
--- a/src/theme-parser.c
+++ b/src/theme-parser.c
@@ -3383,7 +3383,7 @@ parse_style_element (GMarkupParseContext *context,
return;
}
- info->button_type = meta_button_type_from_string (function);
+ info->button_type = meta_button_type_from_string (function, info->theme);
if (info->button_type == META_BUTTON_TYPE_LAST)
{
set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
diff --git a/src/theme.c b/src/theme.c
index eccb50c1..37f05172 100644
--- a/src/theme.c
+++ b/src/theme.c
@@ -394,8 +394,51 @@ meta_frame_layout_get_borders (const MetaFrameLayout *layout,
static GdkRectangle*
rect_for_function (MetaFrameGeometry *fgeom,
MetaFrameFlags flags,
- MetaButtonFunction function)
+ MetaButtonFunction function,
+ MetaTheme *theme)
{
+
+ /* Firstly, check version-specific things. */
+
+ if (META_THEME_ALLOWS(theme, META_THEME_SHADE_STICK_ABOVE_BUTTONS))
+ {
+ switch (function)
+ {
+ case META_BUTTON_FUNCTION_SHADE:
+ if ((flags & META_FRAME_ALLOWS_SHADE) && !(flags & META_FRAME_SHADED))
+ return &fgeom->shade_rect;
+ else
+ return NULL;
+ case META_BUTTON_FUNCTION_ABOVE:
+ if (!(flags & META_FRAME_ABOVE))
+ return &fgeom->above_rect;
+ else
+ return NULL;
+ case META_BUTTON_FUNCTION_STICK:
+ if (!(flags & META_FRAME_STUCK))
+ return &fgeom->stick_rect;
+ else
+ return NULL;
+ case META_BUTTON_FUNCTION_UNSHADE:
+ if ((flags & META_FRAME_ALLOWS_SHADE) && (flags & META_FRAME_SHADED))
+ return &fgeom->unshade_rect;
+ else
+ return NULL;
+ case META_BUTTON_FUNCTION_UNABOVE:
+ if (flags & META_FRAME_ABOVE)
+ return &fgeom->unabove_rect;
+ else
+ return NULL;
+ case META_BUTTON_FUNCTION_UNSTICK:
+ if (flags & META_FRAME_STUCK)
+ return &fgeom->unstick_rect;
+ default:
+ /* just go on to the next switch block */;
+ }
+ }
+
+ /* now consider the buttons which exist in all versions */
+
switch (function)
{
case META_BUTTON_FUNCTION_MENU:
@@ -418,32 +461,19 @@ rect_for_function (MetaFrameGeometry *fgeom,
return &fgeom->close_rect;
else
return NULL;
+ case META_BUTTON_FUNCTION_STICK:
case META_BUTTON_FUNCTION_SHADE:
- if ((flags & META_FRAME_ALLOWS_SHADE) && !(flags & META_FRAME_SHADED))
- return &fgeom->shade_rect;
- else
- return NULL;
case META_BUTTON_FUNCTION_ABOVE:
- if (!(flags & META_FRAME_ABOVE))
- return &fgeom->above_rect;
- else
- return NULL;
- case META_BUTTON_FUNCTION_STICK:
- if (!(flags & META_FRAME_STUCK))
- return &fgeom->stick_rect;
+ case META_BUTTON_FUNCTION_UNSTICK:
case META_BUTTON_FUNCTION_UNSHADE:
- if ((flags & META_FRAME_ALLOWS_SHADE) && (flags & META_FRAME_SHADED))
- return &fgeom->unshade_rect;
- else
- return NULL;
case META_BUTTON_FUNCTION_UNABOVE:
- if (flags & META_FRAME_ABOVE)
- return &fgeom->unabove_rect;
- else
- return NULL;
- case META_BUTTON_FUNCTION_UNSTICK:
- if (flags & META_FRAME_STUCK)
- return &fgeom->unstick_rect;
+ /* we are being asked for a >v1 button which hasn't been handled yet,
+ * so obviously we're not in a theme which supports that version.
+ * therefore, we don't show the button. return NULL and all will
+ * be well.
+ */
+ return NULL;
+
case META_BUTTON_FUNCTION_LAST:
return NULL;
}
@@ -494,7 +524,8 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
int client_width,
int client_height,
const MetaButtonLayout *button_layout,
- MetaFrameGeometry *fgeom)
+ MetaFrameGeometry *fgeom,
+ MetaTheme *theme)
{
int i, n_left, n_right;
int x;
@@ -573,7 +604,8 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
if (button_layout->left_buttons[i] != META_BUTTON_FUNCTION_LAST && !layout->hide_buttons)
{
left_func_rects[n_left] = rect_for_function (fgeom, flags,
- button_layout->left_buttons[i]);
+ button_layout->left_buttons[i],
+ theme);
if (left_func_rects[n_left] != NULL)
++n_left;
}
@@ -581,7 +613,8 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
if (button_layout->right_buttons[i] != META_BUTTON_FUNCTION_LAST && !layout->hide_buttons)
{
right_func_rects[n_right] = rect_for_function (fgeom, flags,
- button_layout->right_buttons[i]);
+ button_layout->right_buttons[i],
+ theme);
if (right_func_rects[n_right] != NULL)
++n_right;
}
@@ -4767,7 +4800,8 @@ meta_theme_draw_frame (MetaTheme *theme,
flags,
client_width, client_height,
button_layout,
- &fgeom);
+ &fgeom,
+ theme);
meta_frame_style_draw (style,
widget,
@@ -4843,7 +4877,8 @@ meta_theme_calc_geometry (MetaTheme *theme,
flags,
client_width, client_height,
button_layout,
- fgeom);
+ fgeom,
+ theme);
}
MetaFrameLayout*
@@ -5225,8 +5260,24 @@ meta_button_state_to_string (MetaButtonState state)
}
MetaButtonType
-meta_button_type_from_string (const char *str)
-{
+meta_button_type_from_string (const char *str, MetaTheme *theme)
+{
+ if (META_THEME_ALLOWS(theme, META_THEME_SHADE_STICK_ABOVE_BUTTONS))
+ {
+ if (strcmp ("shade", str) == 0)
+ return META_BUTTON_TYPE_SHADE;
+ else if (strcmp ("above", str) == 0)
+ return META_BUTTON_TYPE_ABOVE;
+ else if (strcmp ("stick", str) == 0)
+ return META_BUTTON_TYPE_STICK;
+ else if (strcmp ("unshade", str) == 0)
+ return META_BUTTON_TYPE_UNSHADE;
+ else if (strcmp ("unabove", str) == 0)
+ return META_BUTTON_TYPE_UNABOVE;
+ else if (strcmp ("unstick", str) == 0)
+ return META_BUTTON_TYPE_UNSTICK;
+ }
+
if (strcmp ("close", str) == 0)
return META_BUTTON_TYPE_CLOSE;
else if (strcmp ("maximize", str) == 0)
@@ -5235,18 +5286,6 @@ meta_button_type_from_string (const char *str)
return META_BUTTON_TYPE_MINIMIZE;
else if (strcmp ("menu", str) == 0)
return META_BUTTON_TYPE_MENU;
- else if (strcmp ("shade", str) == 0)
- return META_BUTTON_TYPE_SHADE;
- else if (strcmp ("above", str) == 0)
- return META_BUTTON_TYPE_ABOVE;
- else if (strcmp ("stick", str) == 0)
- return META_BUTTON_TYPE_STICK;
- else if (strcmp ("unshade", str) == 0)
- return META_BUTTON_TYPE_UNSHADE;
- else if (strcmp ("unabove", str) == 0)
- return META_BUTTON_TYPE_UNABOVE;
- else if (strcmp ("unstick", str) == 0)
- return META_BUTTON_TYPE_UNSTICK;
else if (strcmp ("left_left_background", str) == 0)
return META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND;
else if (strcmp ("left_middle_background", str) == 0)
diff --git a/src/theme.h b/src/theme.h
index 196451b0..78441e4f 100644
--- a/src/theme.h
+++ b/src/theme.h
@@ -620,7 +620,8 @@ void meta_frame_layout_calc_geometry (const MetaFrameLayout *layout
int client_width,
int client_height,
const MetaButtonLayout *button_layout,
- MetaFrameGeometry *fgeom);
+ MetaFrameGeometry *fgeom,
+ MetaTheme *theme);
gboolean meta_frame_layout_validate (const MetaFrameLayout *layout,
GError **error);
@@ -833,7 +834,8 @@ MetaGtkColorComponent meta_color_component_from_string (const char *s
const char* meta_color_component_to_string (MetaGtkColorComponent component);
MetaButtonState meta_button_state_from_string (const char *str);
const char* meta_button_state_to_string (MetaButtonState state);
-MetaButtonType meta_button_type_from_string (const char *str);
+MetaButtonType meta_button_type_from_string (const char *str,
+ MetaTheme *theme);
const char* meta_button_type_to_string (MetaButtonType type);
MetaFramePiece meta_frame_piece_from_string (const char *str);
const char* meta_frame_piece_to_string (MetaFramePiece piece);
@@ -861,6 +863,7 @@ guint meta_theme_earliest_version_with_button (MetaButtonType type);
#define META_THEME_ALLOWS(theme, feature) (theme->format_version >= feature)
/* What version of the theme file format were various features introduced in? */
+#define META_THEME_SHADE_STICK_ABOVE_BUTTONS 2
#define META_THEME_UBIQUITOUS_CONSTANTS 2
#define META_THEME_VARIED_ROUND_CORNERS 2
#define META_THEME_IMAGES_FROM_ICON_THEMES 2