[Xfce4-commits] <midori:master> Add katze_item_get_pixbuf and use in panels
Christian Dywan
noreply at xfce.org
Sun May 13 02:24:02 CEST 2012
Updating branch refs/heads/master
to cf1321fe215155be59250edef3dbac2c593359f9 (commit)
from 94c6fca20f40e21910ef42b9eaeb62859deca994 (commit)
commit cf1321fe215155be59250edef3dbac2c593359f9
Author: Christian Dywan <christian at twotoasts.de>
Date: Sun May 13 01:53:19 2012 +0200
Add katze_item_get_pixbuf and use in panels
katze/katze-item.c | 43 ++++++++++++++++++++++++++++++++++++-------
katze/katze-item.h | 4 ++++
panels/midori-bookmarks.c | 2 ++
panels/midori-history.c | 2 ++
4 files changed, 44 insertions(+), 7 deletions(-)
diff --git a/katze/katze-item.c b/katze/katze-item.c
index 36446b7..43ed856 100644
--- a/katze/katze-item.c
+++ b/katze/katze-item.c
@@ -424,6 +424,40 @@ katze_item_set_icon (KatzeItem* item,
}
/**
+ * katze_item_get_pixbuf:
+ * @item: a #KatzeItem
+ * @widget: a #GtkWidget, or %NULL
+ *
+ * Retrieves a #GdkPixbuf fit to display @item.
+ *
+ * Return value: the icon of the item
+ *
+ * Since: 0.4.6
+ **/
+GdkPixbuf*
+katze_item_get_pixbuf (KatzeItem* item,
+ GtkWidget* widget)
+{
+ GdkPixbuf* pixbuf;
+
+ g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
+
+ if (item->uri == NULL)
+ return NULL;
+
+ #if WEBKIT_CHECK_VERSION (1, 8, 0)
+ /* FIXME: Don't hard-code icon size */
+ if ((pixbuf = webkit_favicon_database_try_get_favicon_pixbuf (
+ webkit_get_favicon_database (), item->uri, 16, 16)))
+ return pixbuf;
+ #else
+ if ((pixbuf = g_object_get_data (G_OBJECT (item), "pixbuf")))
+ return pixbuf;
+ #endif
+ return NULL;
+}
+
+/**
* katze_item_get_image:
* @item: a #KatzeItem
*
@@ -444,13 +478,8 @@ katze_item_get_image (KatzeItem* item)
if (KATZE_ITEM_IS_FOLDER (item))
image = gtk_image_new_from_stock (GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU);
- #if WEBKIT_CHECK_VERSION (1, 8, 0)
- /* FIXME: Don't hard-code icon size */
- else if ((pixbuf = webkit_favicon_database_try_get_favicon_pixbuf (
- webkit_get_favicon_database (), item->uri, 16, 16)))
- image = gtk_image_new_from_pixbuf (pixbuf);
- #endif
- else if ((pixbuf = g_object_get_data (G_OBJECT (item), "pixbuf")))
+ /* FIXME: Pass widget for icon size */
+ else if ((pixbuf = katze_item_get_pixbuf (item, NULL)))
image = gtk_image_new_from_pixbuf (pixbuf);
else if ((icon = katze_item_get_icon (item)) && !strchr (icon, '/'))
image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU);
diff --git a/katze/katze-item.h b/katze/katze-item.h
index ceb7f3c..0bd44fd 100644
--- a/katze/katze-item.h
+++ b/katze/katze-item.h
@@ -91,6 +91,10 @@ void
katze_item_set_icon (KatzeItem* item,
const gchar* icon);
+GdkPixbuf*
+katze_item_get_pixbuf (KatzeItem* item,
+ GtkWidget* widget);
+
GtkWidget*
katze_item_get_image (KatzeItem* item);
diff --git a/panels/midori-bookmarks.c b/panels/midori-bookmarks.c
index d6dfa29..099e9d8 100644
--- a/panels/midori-bookmarks.c
+++ b/panels/midori-bookmarks.c
@@ -563,6 +563,8 @@ midori_bookmarks_treeview_render_icon_cb (GtkTreeViewColumn* column,
if (KATZE_ITEM_IS_FOLDER (item))
pixbuf = gtk_widget_render_icon (treeview, GTK_STOCK_DIRECTORY,
GTK_ICON_SIZE_MENU, NULL);
+ else if ((pixbuf = katze_item_get_pixbuf (item, treeview)))
+ ;
else if (KATZE_ITEM_IS_BOOKMARK (item))
pixbuf = katze_load_cached_icon (katze_item_get_uri (item), treeview);
g_object_set (renderer, "pixbuf", pixbuf, NULL);
diff --git a/panels/midori-history.c b/panels/midori-history.c
index f54a2b8..7ec1717 100644
--- a/panels/midori-history.c
+++ b/panels/midori-history.c
@@ -594,6 +594,8 @@ midori_history_treeview_render_icon_cb (GtkTreeViewColumn* column,
if (!item)
pixbuf = NULL;
+ else if ((pixbuf = katze_item_get_pixbuf (item, treeview)))
+ ;
else if (katze_item_get_uri (item))
pixbuf = katze_load_cached_icon (katze_item_get_uri (item), treeview);
else
More information about the Xfce4-commits
mailing list