]> spindle.queued.net Git - midori/commitdiff
Support custom sizes of icons in res_server
authorChristian Dywan <christian@twotoasts.de>
Fri, 15 May 2009 21:08:52 +0000 (23:08 +0200)
committerChristian Dywan <christian@twotoasts.de>
Fri, 15 May 2009 21:08:52 +0000 (23:08 +0200)
data/speeddial-head.html
midori/sokoke.c

index 48ee2aff07bcbf0e8e747dec6a2edae8f7ebc9ff..842f6472987adbf0fc4de7cedde37fd7b80a20d8 100644 (file)
 
     .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);
     }
index 2909821c9147c71dc487c60769ad486b371dac0c..301f35295f8ea03e15a4cd1d9e9775102a8981c8 100644 (file)
@@ -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,