[nautilus] Set icons from extensions on the context menu GtkActions
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] Set icons from extensions on the context menu GtkActions
- Date: Mon, 19 Dec 2011 10:47:24 +0000 (UTC)
commit 85af4ef2e58b45dcd40f6ba692b12e73c6cf6ffd
Author: Pierre Wieser <pwieser trychlos org>
Date: Mon Dec 19 10:37:59 2011 +0100
Set icons from extensions on the context menu GtkActions
This way, if icons are set to display in e.g. menus, extensions one will
be properly shown.
https://bugzilla.gnome.org/show_bug.cgi?id=665822
libnautilus-private/nautilus-ui-utilities.c | 33 ++++++++++++++++++++++-----
libnautilus-private/nautilus-ui-utilities.h | 2 +
src/nautilus-view.c | 31 ++++---------------------
3 files changed, 34 insertions(+), 32 deletions(-)
---
diff --git a/libnautilus-private/nautilus-ui-utilities.c b/libnautilus-private/nautilus-ui-utilities.c
index cf812f2..1c547d3 100644
--- a/libnautilus-private/nautilus-ui-utilities.c
+++ b/libnautilus-private/nautilus-ui-utilities.c
@@ -120,7 +120,7 @@ nautilus_action_from_menu_item (NautilusMenuItem *item)
char *name, *label, *tip, *icon_name;
gboolean sensitive, priority;
GtkAction *action;
- GIcon *icon;
+ GdkPixbuf *pixbuf;
g_object_get (G_OBJECT (item),
"name", &name, "label", &label,
@@ -132,13 +132,14 @@ nautilus_action_from_menu_item (NautilusMenuItem *item)
action = gtk_action_new (name,
label,
tip,
- icon_name);
+ NULL);
if (icon_name != NULL) {
- icon = g_themed_icon_new_with_default_fallbacks (icon_name);
- g_object_set_data_full (G_OBJECT (action), "menu-icon",
- icon,
- g_object_unref);
+ pixbuf = nautilus_ui_get_menu_icon (icon_name);
+ if (pixbuf != NULL) {
+ gtk_action_set_gicon (action, G_ICON (pixbuf));
+ g_object_unref (pixbuf);
+ }
}
gtk_action_set_sensitive (action, sensitive);
@@ -176,3 +177,23 @@ nautilus_event_should_open_in_new_tab (void)
return FALSE;
}
+
+GdkPixbuf *
+nautilus_ui_get_menu_icon (const char *icon_name)
+{
+ NautilusIconInfo *info;
+ GdkPixbuf *pixbuf;
+ int size;
+
+ size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
+
+ if (g_path_is_absolute (icon_name)) {
+ info = nautilus_icon_info_lookup_from_path (icon_name, size);
+ } else {
+ info = nautilus_icon_info_lookup_from_name (icon_name, size);
+ }
+ pixbuf = nautilus_icon_info_get_pixbuf_nodefault_at_size (info, size);
+ g_object_unref (info);
+
+ return pixbuf;
+}
diff --git a/libnautilus-private/nautilus-ui-utilities.h b/libnautilus-private/nautilus-ui-utilities.h
index 0338f6d..c22c3a0 100644
--- a/libnautilus-private/nautilus-ui-utilities.h
+++ b/libnautilus-private/nautilus-ui-utilities.h
@@ -41,4 +41,6 @@ const char *nautilus_ui_string_get (const char *filename)
gboolean nautilus_event_should_open_in_new_tab (void);
+GdkPixbuf * nautilus_ui_get_menu_icon (const char *icon_name);
+
#endif /* NAUTILUS_UI_UTILITIES_H */
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index 1f75ce6..78ffb35 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -4600,26 +4600,6 @@ extension_action_callback (GtkAction *action,
}
static GdkPixbuf *
-get_menu_icon (const char *icon_name)
-{
- NautilusIconInfo *info;
- GdkPixbuf *pixbuf;
- int size;
-
- size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
-
- if (g_path_is_absolute (icon_name)) {
- info = nautilus_icon_info_lookup_from_path (icon_name, size);
- } else {
- info = nautilus_icon_info_lookup_from_name (icon_name, size);
- }
- pixbuf = nautilus_icon_info_get_pixbuf_nodefault_at_size (info, size);
- g_object_unref (info);
-
- return pixbuf;
-}
-
-static GdkPixbuf *
get_menu_icon_for_file (NautilusFile *file)
{
NautilusIconInfo *info;
@@ -4656,14 +4636,13 @@ add_extension_action_for_files (NautilusView *view,
action = gtk_action_new (name,
label,
tip,
- icon);
+ NULL);
if (icon != NULL) {
- pixbuf = get_menu_icon (icon);
+ pixbuf = nautilus_ui_get_menu_icon (icon);
if (pixbuf != NULL) {
- g_object_set_data_full (G_OBJECT (action), "menu-icon",
- pixbuf,
- g_object_unref);
+ gtk_action_set_gicon (action, G_ICON (pixbuf));
+ g_object_unref (pixbuf);
}
}
@@ -7131,7 +7110,7 @@ connect_proxy (NautilusView *view,
if (strcmp (gtk_action_get_name (action), NAUTILUS_ACTION_NEW_EMPTY_DOCUMENT) == 0 &&
GTK_IS_IMAGE_MENU_ITEM (proxy)) {
- pixbuf = get_menu_icon ("text-x-generic");
+ pixbuf = nautilus_ui_get_menu_icon ("text-x-generic");
if (pixbuf != NULL) {
image = gtk_image_new_from_pixbuf (pixbuf);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), image);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]