summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas James Alexander Thurman <tthurman@src.gnome.org>2006-05-06 15:43:16 +0000
committerThomas James Alexander Thurman <tthurman@src.gnome.org>2006-05-06 15:43:16 +0000
commit245db41cf8469b889d2a77475aadba640a8b7c64 (patch)
treedcb455844165bb0e40db684f933fbc6c1affc376
parent9d4494489db90209bcdb7d104189d26ab7c58c60 (diff)
downloadmetacity-245db41cf8469b889d2a77475aadba640a8b7c64.tar.gz
#113163: almost a complete fix; still need to recalc on theme changes
-rw-r--r--src/iconcache.c23
-rw-r--r--src/theme-parser.c65
-rw-r--r--src/theme.c5
-rw-r--r--src/theme.h3
4 files changed, 82 insertions, 14 deletions
diff --git a/src/iconcache.c b/src/iconcache.c
index eca5db07..0b240f3a 100644
--- a/src/iconcache.c
+++ b/src/iconcache.c
@@ -23,6 +23,7 @@
#include "iconcache.h"
#include "ui.h"
#include "errors.h"
+#include "theme.h"
#include <X11/Xatom.h>
@@ -828,13 +829,21 @@ meta_read_icons (MetaScreen *screen,
if (icon_cache->want_fallback &&
icon_cache->origin < USING_FALLBACK_ICON)
{
- get_fallback_icons (screen,
- iconp,
- ideal_width,
- ideal_height,
- mini_iconp,
- ideal_mini_width,
- ideal_mini_height);
+ MetaTheme *theme = meta_theme_get_current ();
+
+ if (theme->fallback_icon==NULL || theme->fallback_mini_icon==NULL)
+ {
+ get_fallback_icons (screen,
+ iconp,
+ ideal_width,
+ ideal_height,
+ mini_iconp,
+ ideal_mini_width,
+ ideal_mini_height);
+ }
+
+ if (theme->fallback_icon!=NULL) *iconp = theme->fallback_icon;
+ if (theme->fallback_mini_icon!=NULL) *mini_iconp = theme->fallback_mini_icon;
replace_cache (icon_cache, USING_FALLBACK_ICON,
*iconp, *mini_iconp);
diff --git a/src/theme-parser.c b/src/theme-parser.c
index dfbb05d8..aa299e71 100644
--- a/src/theme-parser.c
+++ b/src/theme-parser.c
@@ -71,7 +71,9 @@ typedef enum
/* assigning style sets to windows */
STATE_WINDOW,
/* and menu icons */
- STATE_MENU_ICON
+ STATE_MENU_ICON,
+ /* fallback icons */
+ STATE_FALLBACK
} ParseState;
typedef struct
@@ -1236,7 +1238,45 @@ parse_toplevel_element (GMarkupParseContext *context,
push_state (info, STATE_MENU_ICON);
}
- else
+ else if (ELEMENT_IS ("fallback"))
+ {
+ const char *icon = NULL;
+ const char *mini_icon = NULL;
+
+ if (!locate_attributes (context, element_name, attribute_names, attribute_values,
+ error,
+ "icon", &icon,
+ "mini_icon", &mini_icon,
+ NULL))
+ return;
+
+ if (icon)
+ {
+ if (info->theme->fallback_icon != NULL)
+ {
+ set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
+ _("Theme already has a fallback icon"));
+ return;
+ }
+
+ info->theme->fallback_icon = meta_theme_load_image(info->theme, icon, 64, error);
+ }
+
+ if (mini_icon)
+ {
+ if (info->theme->fallback_mini_icon != NULL)
+ {
+ set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
+ _("Theme already has a fallback mini_icon"));
+ return;
+ }
+
+ info->theme->fallback_mini_icon = meta_theme_load_image(info->theme, mini_icon, 16, error);
+ }
+
+ push_state (info, STATE_FALLBACK);
+ }
+ else
{
set_error (error, context,
G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
@@ -2370,9 +2410,12 @@ parse_draw_op_element (GMarkupParseContext *context,
}
/* Check last so we don't have to free it when other
- * stuff fails
+ * stuff fails.
+ *
+ * If it's a theme image, ask for it at 64px, which is
+ * the largest possible. We scale it anyway.
*/
- pixbuf = meta_theme_load_image (info->theme, filename, error);
+ pixbuf = meta_theme_load_image (info->theme, filename, 64, error);
if (pixbuf == NULL)
{
@@ -3824,6 +3867,11 @@ start_element_handler (GMarkupParseContext *context,
_("Element <%s> is not allowed inside a <%s> element"),
element_name, "window");
break;
+ case STATE_FALLBACK:
+ set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
+ _("Element <%s> is not allowed inside a <%s> element"),
+ element_name, "fallback");
+ break;
}
}
@@ -4110,6 +4158,10 @@ end_element_handler (GMarkupParseContext *context,
pop_state (info);
g_assert (peek_state (info) == STATE_THEME);
break;
+ case STATE_FALLBACK:
+ pop_state (info);
+ g_assert (peek_state (info) == STATE_THEME);
+ break;
}
}
@@ -4302,6 +4354,9 @@ text_handler (GMarkupParseContext *context,
case STATE_WINDOW:
NO_TEXT ("window");
break;
+ case STATE_FALLBACK:
+ NO_TEXT ("fallback");
+ break;
}
}
@@ -4477,7 +4532,7 @@ meta_theme_load (const char *theme_name,
g_free (text);
info.theme->format_version = info.format_version;
-
+
if (error)
{
g_propagate_error (err, error);
diff --git a/src/theme.c b/src/theme.c
index a391d727..aa38bf96 100644
--- a/src/theme.c
+++ b/src/theme.c
@@ -3987,7 +3987,7 @@ meta_frame_style_draw (MetaFrameStyle *style,
GdkRectangle left_edge, right_edge, bottom_edge;
PangoRectangle extents;
MetaDrawInfo draw_info;
-
+
titlebar_rect.x = 0;
titlebar_rect.y = 0;
titlebar_rect.width = fgeom->width;
@@ -4613,6 +4613,7 @@ meta_theme_validate (MetaTheme *theme,
GdkPixbuf*
meta_theme_load_image (MetaTheme *theme,
const char *filename,
+ guint size_of_theme_icons,
GError **error)
{
GdkPixbuf *pixbuf;
@@ -4629,7 +4630,7 @@ meta_theme_load_image (MetaTheme *theme,
pixbuf = gtk_icon_theme_load_icon (
gtk_icon_theme_get_default (),
filename+6,
- 48,
+ size_of_theme_icons,
0,
error);
if (pixbuf == NULL) return NULL;
diff --git a/src/theme.h b/src/theme.h
index a0f35105..32f31f0e 100644
--- a/src/theme.h
+++ b/src/theme.h
@@ -575,6 +575,8 @@ struct _MetaTheme
GHashTable *style_sets_by_name;
MetaFrameStyleSet *style_sets_by_type[META_FRAME_TYPE_LAST];
MetaDrawOpList *menu_icons[META_MENU_ICON_TYPE_LAST][N_GTK_STATES];
+
+ GdkPixbuf *fallback_icon, *fallback_mini_icon;
};
struct _MetaPositionExprEnv
@@ -722,6 +724,7 @@ gboolean meta_theme_validate (MetaTheme *theme,
GError **error);
GdkPixbuf* meta_theme_load_image (MetaTheme *theme,
const char *filename,
+ guint size_of_theme_icons,
GError **error);
MetaFrameStyle* meta_theme_get_frame_style (MetaTheme *theme,