[Xfce4-commits] <midori:master> Pass proxy widget to katze_item_get_image
Christian Dywan
noreply at xfce.org
Sun Dec 16 19:52:01 CET 2012
Updating branch refs/heads/master
to 6f9898fe6ebbf5a5fb280755503640e987df5716 (commit)
from be77659d756843d230cf1bb859d7314f8e701ccf (commit)
commit 6f9898fe6ebbf5a5fb280755503640e987df5716
Author: Christian Dywan <christian at twotoasts.de>
Date: Sun Dec 16 19:37:48 2012 +0100
Pass proxy widget to katze_item_get_image
katze/katze-arrayaction.c | 13 +++++--------
katze/katze-item.c | 18 +++++++++---------
katze/katze-item.h | 3 ++-
midori/midori-view.c | 2 +-
4 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/katze/katze-arrayaction.c b/katze/katze-arrayaction.c
index 6b19659..9936134 100644
--- a/katze/katze-arrayaction.c
+++ b/katze/katze-arrayaction.c
@@ -390,7 +390,7 @@ katze_array_action_generate_menu (KatzeArrayAction* array_action,
}
menuitem = katze_image_menu_item_new_ellipsized (
katze_item_get_name (item));
- image = katze_item_get_image (item);
+ image = katze_item_get_image (item, menuitem);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
gtk_image_menu_item_set_always_show_image (
GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
@@ -590,14 +590,12 @@ katze_array_action_item_notify_cb (KatzeItem* item,
}
else if (KATZE_ITEM_IS_BOOKMARK (item) && !strcmp (property, "uri"))
{
- image = katze_item_get_image (item);
- gtk_widget_show (image);
+ image = katze_item_get_image (item, GTK_WIDGET (toolitem));
gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (toolitem), image);
}
else if (!strcmp (property, "icon"))
{
- image = katze_item_get_image (item);
- gtk_widget_show (image);
+ image = katze_item_get_image (item, GTK_WIDGET (toolitem));
gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (toolitem), image);
}
}
@@ -613,7 +611,7 @@ katze_array_action_proxy_create_menu_proxy_cb (GtkWidget* proxy,
array_action = g_object_get_data (G_OBJECT (proxy), "KatzeArrayAction");
menuitem = katze_image_menu_item_new_ellipsized (
katze_item_get_name (item));
- image = katze_item_get_image (item);
+ image = katze_item_get_image (item, menuitem);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
gtk_image_menu_item_set_always_show_image (
GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
@@ -685,8 +683,7 @@ katze_array_action_create_tool_item_for (KatzeArrayAction* array_action,
toolitem = gtk_tool_button_new (NULL, "");
g_signal_connect (toolitem, "create-menu-proxy",
G_CALLBACK (katze_array_action_proxy_create_menu_proxy_cb), item);
- image = katze_item_get_image (item);
- gtk_widget_show (image);
+ image = katze_item_get_image (item, GTK_WIDGET (toolitem));
gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (toolitem), image);
label = gtk_label_new (NULL);
/* FIXME: Should text direction be respected here? */
diff --git a/katze/katze-item.c b/katze/katze-item.c
index 45ab4fe..9365b18 100644
--- a/katze/katze-item.c
+++ b/katze/katze-item.c
@@ -461,29 +461,29 @@ katze_item_get_pixbuf (KatzeItem* item,
/**
* katze_item_get_image:
* @item: a #KatzeItem
+ * @widget: a #GtkWidget, or %NULL
*
* Retrieves a #GtkImage fit to display @item.
*
* Return value: the icon of the item
*
* Since: 0.4.4
+ * Since 0.4.8 a @widget was added and the image is visible.
**/
GtkWidget*
-katze_item_get_image (KatzeItem* item)
+katze_item_get_image (KatzeItem* item,
+ GtkWidget* widget)
{
GtkWidget* image;
GdkPixbuf* pixbuf;
- const gchar* icon;
g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
- if (KATZE_ITEM_IS_FOLDER (item))
- image = gtk_image_new_from_stock (GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU);
- /* FIXME: Pass widget for icon size */
- else if ((pixbuf = katze_item_get_pixbuf (item, NULL)))
- image = gtk_image_new_from_pixbuf (pixbuf);
- else
- image = gtk_image_new_from_stock (GTK_STOCK_FILE, GTK_ICON_SIZE_MENU);
+ pixbuf = katze_item_get_pixbuf (item, widget);
+ image = gtk_image_new_from_pixbuf (pixbuf);
+ gtk_widget_show (image);
+ if (pixbuf != NULL)
+ g_object_unref (pixbuf);
return image;
}
diff --git a/katze/katze-item.h b/katze/katze-item.h
index 0bd44fd..7087680 100644
--- a/katze/katze-item.h
+++ b/katze/katze-item.h
@@ -96,7 +96,8 @@ katze_item_get_pixbuf (KatzeItem* item,
GtkWidget* widget);
GtkWidget*
-katze_item_get_image (KatzeItem* item);
+katze_item_get_image (KatzeItem* item,
+ GtkWidget* widget);
const gchar*
katze_item_get_token (KatzeItem* item);
diff --git a/midori/midori-view.c b/midori/midori-view.c
index dbac434..80eb13f 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -438,7 +438,7 @@ midori_view_apply_icon (MidoriView* view,
#endif
if (view->menu_item)
{
- GtkWidget* image = katze_item_get_image (view->item);
+ GtkWidget* image = katze_item_get_image (view->item, view->web_view);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (view->menu_item), image);
}
}
More information about the Xfce4-commits
mailing list