From 4c2a3f5bb70804158ac2a18a744278f68e70fd8c Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Fri, 15 May 2009 23:08:52 +0200 Subject: [PATCH] Support custom sizes of icons in res_server --- data/speeddial-head.html | 3 +-- midori/sokoke.c | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/data/speeddial-head.html b/data/speeddial-head.html index 48ee2aff..842f6472 100644 --- a/data/speeddial-head.html +++ b/data/speeddial-head.html @@ -153,8 +153,7 @@ .activated p { cursor: text; - background: url({stock}/gtk-edit) 98% 70% no-repeat; - -webkit-background-size: 16px 15px; + background: url({stock}/16/gtk-edit) 98% 70% no-repeat; opacity: 0.6; color: rgba(0,0,0,1); } diff --git a/midori/sokoke.c b/midori/sokoke.c index 2909821c..301f3529 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -1008,12 +1008,33 @@ res_server_handler_cb (SoupServer* res_server, else if (g_str_has_prefix (path, "/stock/")) { GtkIconTheme* icon_theme = gtk_icon_theme_get_default (); - const gchar* icon_name = &path[7]; - GdkPixbuf* icon = gtk_icon_theme_load_icon (icon_theme, icon_name, - strstr (icon_name, "dialog") ? 48 : 22, 0, NULL); + const gchar* icon_name = &path[7] ? &path[7] : ""; + gint icon_size = 22; + GdkPixbuf* icon; gchar* contents; gsize length; + if (g_ascii_isalpha (icon_name[0])) + icon_size = strstr (icon_name, "dialog") ? 48 : 22; + else if (g_ascii_isdigit (icon_name[0])) + { + guint i = 0; + while (icon_name[i]) + if (icon_name[i++] == '/') + { + gchar* size = g_strndup (icon_name, i - 1); + icon_size = atoi (size); + g_free (size); + icon_name = &icon_name[i]; + } + } + + icon = gtk_icon_theme_load_icon (icon_theme, icon_name, + icon_size, 0, NULL); + if (!icon) + icon = gtk_icon_theme_load_icon (icon_theme, "gtk-missing-image", + icon_size, 0, NULL); + gdk_pixbuf_save_to_buffer (icon, &contents, &length, "png", NULL, NULL); g_object_unref (icon); soup_message_set_response (msg, "image/png", SOUP_MEMORY_TAKE, -- 2.39.5