X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fmodest-icon-factory.c;h=37c079777ed0367582aefa804d026c401d646c07;hb=5693fd444e26227f43b12bd11d8b67d39bffc87e;hp=95b7a966e8da855756d919f55747d84e80d515cf;hpb=702b748360f6de61e0780c36a98065d19a495c83;p=modest diff --git a/src/modest-icon-factory.c b/src/modest-icon-factory.c index 95b7a96..37c0797 100644 --- a/src/modest-icon-factory.c +++ b/src/modest-icon-factory.c @@ -53,8 +53,8 @@ void modest_icon_factory_init (void) { if (icon_hash) { - g_warning ("modest_icon_factory_init " - "should be called only once"); + g_printerr ("modest: modest_icon_factory_init " + "should be called only once\n"); return; } @@ -69,9 +69,9 @@ void modest_icon_factory_uninit (void) { if (!icon_hash) { - g_warning ("modest_icon_factory_uninit " + g_printerr ("modest: modest_icon_factory_uninit " "must only be called with initialized " - "ModestIconFactories"); + "ModestIconFactories\n"); return; } @@ -89,7 +89,7 @@ modest_icon_factory_get_icon (const gchar *name) gpointer orig_key; if (!icon_hash) { - g_warning ("ModestIconFactory must be initialized first"); + g_printerr ("modest: ModestIconFactory must be initialized first\n"); return NULL; } @@ -100,7 +100,7 @@ modest_icon_factory_get_icon (const gchar *name) (gpointer*)&pixbuf)) { pixbuf = gdk_pixbuf_new_from_file (name, &err); if (!pixbuf) { - g_warning (err->message); + g_printerr ("modest: error in icon factory: %s\n", err->message); g_error_free (err); } /* if we cannot find it, we still insert, so we get the error @@ -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; +}