From: Dirk-Jan C. Binnema Date: Mon, 7 Aug 2006 12:24:37 +0000 (+0000) Subject: * rudimentary support for scaled icons (not cached yet) X-Git-Tag: git_migration_finished~4426 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=5693fd444e26227f43b12bd11d8b67d39bffc87e * rudimentary support for scaled icons (not cached yet) pmo-trunk-r452 --- diff --git a/src/modest-icon-factory.c b/src/modest-icon-factory.c index a17402c..37c0797 100644 --- a/src/modest-icon-factory.c +++ b/src/modest-icon-factory.c @@ -110,3 +110,30 @@ modest_icon_factory_get_icon (const gchar *name) } return pixbuf; } + + +GdkPixbuf* +modest_icon_factory_get_icon_at_size (const gchar *name, int width, int height) +{ + /* FIXME, somehow, cache scaled icons as well... */ + GError *err = NULL; + GdkPixbuf *pixbuf = NULL; + + if (!icon_hash) { + g_printerr ("modest: ModestIconFactory must be initialized first\n"); + return NULL; + } + + pixbuf = gdk_pixbuf_new_from_file_at_size (name, width, height, &err); + if (!pixbuf) { + g_printerr ("modest: error in icon factory: %s\n", err->message); + g_error_free (err); + } + + /* we insert it, so it will be freed... FIXME... */ + if (pixbuf) + g_hash_table_insert (icon_hash, g_strdup_printf ("%s-%d-%d",name,width,height), + (gpointer)pixbuf); + + return pixbuf; +} diff --git a/src/modest-icon-factory.h b/src/modest-icon-factory.h index d848fef..d1f45e4 100644 --- a/src/modest-icon-factory.h +++ b/src/modest-icon-factory.h @@ -63,4 +63,20 @@ void modest_icon_factory_uninit (void); */ GdkPixbuf* modest_icon_factory_get_icon (const gchar *name); +/** + * modest_icon_factory_get_icon_at_size: + * @name: the filename of a certain icon + * @width: the desired width of the icon + * @height: the desired height of the icon + * + * Returns: a GdkPixBuf for this icon, or NULL in case of error + * You should NOT unref or modify the pixbuf in any way + */ +GdkPixbuf* modest_icon_factory_get_icon_at_size (const gchar *name, int width, int height); + +/* FIXME */ +#define modest_icon_factory_get_small_icon(n) modest_icon_factory_get_icon_at_size(n,16,16) +#define modest_icon_factory_get_big_icon(n) modest_icon_factory_get_icon_at_size(n,24,24) + + #endif /*__MODEST_ICON_FACTORY_H__ */