[Xfce4-commits] [xfce/thunar] 04/04: Simplify icon handling of ThunarxMenuItem
noreply at xfce.org
noreply at xfce.org
Thu Nov 2 04:40:38 CET 2017
This is an automated email from the git hooks/post-receive script.
a n d r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository xfce/thunar.
commit 8cccd6a764deef358b288433da5d5c0d52fdcb3e
Author: Andre Miranda <andreldm at xfce.org>
Date: Tue Oct 31 23:14:44 2017 -0300
Simplify icon handling of ThunarxMenuItem
---
thunar/thunar-dnd.c | 2 +-
thunar/thunar-icon-factory.c | 20 ++++++++------------
thunar/thunar-icon-factory.h | 3 +--
thunar/thunar-icon-renderer.c | 2 +-
thunar/thunar-renamer-dialog.c | 2 +-
thunar/thunar-shortcuts-view.c | 2 +-
thunar/thunar-standard-view.c | 2 +-
thunar/thunar-tree-view.c | 2 +-
thunar/thunar-util.c | 25 ++++++-------------------
thunar/thunar-util.h | 3 +--
thunar/thunar-window.c | 4 ++--
11 files changed, 24 insertions(+), 43 deletions(-)
diff --git a/thunar/thunar-dnd.c b/thunar/thunar-dnd.c
index 663156d..e263a6e 100644
--- a/thunar/thunar-dnd.c
+++ b/thunar/thunar-dnd.c
@@ -155,7 +155,7 @@ thunar_dnd_ask (GtkWidget *widget,
/* add menu items for all items */
for (lp = items; lp != NULL; lp = lp->next)
{
- action = thunar_util_action_from_menu_item (G_OBJECT (lp->data), window);
+ action = thunar_util_action_from_menu_item (G_OBJECT (lp->data));
/* add a menu item for the action */
item = gtk_action_create_menu_item (action);
diff --git a/thunar/thunar-icon-factory.c b/thunar/thunar-icon-factory.c
index 0631221..fd6bdc3 100644
--- a/thunar/thunar-icon-factory.c
+++ b/thunar/thunar-icon-factory.c
@@ -79,8 +79,7 @@ static GdkPixbuf *thunar_icon_factory_load_from_file (ThunarIconFactory
static GdkPixbuf *thunar_icon_factory_lookup_icon (ThunarIconFactory *factory,
const gchar *name,
gint size,
- gboolean wants_default,
- gboolean force_size);
+ gboolean wants_default);
static guint thunar_icon_key_hash (gconstpointer data);
static gboolean thunar_icon_key_equal (gconstpointer a,
gconstpointer b);
@@ -469,8 +468,7 @@ static GdkPixbuf*
thunar_icon_factory_lookup_icon (ThunarIconFactory *factory,
const gchar *name,
gint size,
- gboolean wants_default,
- gboolean force_size)
+ gboolean wants_default)
{
ThunarIconKey lookup_key;
ThunarIconKey *key;
@@ -501,8 +499,7 @@ thunar_icon_factory_lookup_icon (ThunarIconFactory *factory,
name = "folder";
/* check if the icon theme contains an icon of that name */
- icon_info = gtk_icon_theme_lookup_icon (factory->icon_theme, name, size,
- force_size ? GTK_ICON_LOOKUP_FORCE_SIZE : 0);
+ icon_info = gtk_icon_theme_lookup_icon (factory->icon_theme, name, size, GTK_ICON_LOOKUP_FORCE_SIZE);
if (G_LIKELY (icon_info != NULL))
{
/* try to load the pixbuf from the icon info */
@@ -606,7 +603,7 @@ static GdkPixbuf*
thunar_icon_factory_load_fallback (ThunarIconFactory *factory,
gint size)
{
- return thunar_icon_factory_lookup_icon (factory, "text-x-generic", size, FALSE, TRUE);
+ return thunar_icon_factory_lookup_icon (factory, "text-x-generic", size, FALSE);
}
@@ -752,8 +749,7 @@ GdkPixbuf*
thunar_icon_factory_load_icon (ThunarIconFactory *factory,
const gchar *name,
gint size,
- gboolean wants_default,
- gboolean force_size)
+ gboolean wants_default)
{
_thunar_return_val_if_fail (THUNAR_IS_ICON_FACTORY (factory), NULL);
_thunar_return_val_if_fail (size > 0, NULL);
@@ -771,7 +767,7 @@ thunar_icon_factory_load_icon (ThunarIconFactory *factory,
}
/* lookup the icon */
- return thunar_icon_factory_lookup_icon (factory, name, size, wants_default, force_size);
+ return thunar_icon_factory_lookup_icon (factory, name, size, wants_default);
}
@@ -823,7 +819,7 @@ thunar_icon_factory_load_file_icon (ThunarIconFactory *factory,
if (custom_icon != NULL)
{
/* try to load the icon */
- icon = thunar_icon_factory_lookup_icon (factory, custom_icon, icon_size, FALSE, TRUE);
+ icon = thunar_icon_factory_lookup_icon (factory, custom_icon, icon_size, FALSE);
if (G_LIKELY (icon != NULL))
return icon;
}
@@ -897,7 +893,7 @@ thunar_icon_factory_load_file_icon (ThunarIconFactory *factory,
if (G_LIKELY (icon == NULL))
{
icon_name = thunar_file_get_icon_name (file, icon_state, factory->icon_theme);
- icon = thunar_icon_factory_load_icon (factory, icon_name, icon_size, TRUE, TRUE);
+ icon = thunar_icon_factory_load_icon (factory, icon_name, icon_size, TRUE);
}
if (G_LIKELY (icon != NULL))
diff --git a/thunar/thunar-icon-factory.h b/thunar/thunar-icon-factory.h
index cf29a71..a7137ab 100644
--- a/thunar/thunar-icon-factory.h
+++ b/thunar/thunar-icon-factory.h
@@ -54,8 +54,7 @@ gboolean thunar_icon_factory_get_show_thumbnail (const ThunarIconF
GdkPixbuf *thunar_icon_factory_load_icon (ThunarIconFactory *factory,
const gchar *name,
gint size,
- gboolean wants_default,
- gboolean force_size);
+ gboolean wants_default);
GdkPixbuf *thunar_icon_factory_load_file_icon (ThunarIconFactory *factory,
ThunarFile *file,
diff --git a/thunar/thunar-icon-renderer.c b/thunar/thunar-icon-renderer.c
index fe41170..1561dc7 100644
--- a/thunar/thunar-icon-renderer.c
+++ b/thunar/thunar-icon-renderer.c
@@ -497,7 +497,7 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer,
emblem_size = MIN ((2 * icon_renderer->size) / 3, 32);
/* check if we have the emblem in the icon theme */
- emblem = thunar_icon_factory_load_icon (icon_factory, lp->data, emblem_size, FALSE, TRUE);
+ emblem = thunar_icon_factory_load_icon (icon_factory, lp->data, emblem_size, FALSE);
if (G_UNLIKELY (emblem == NULL))
continue;
diff --git a/thunar/thunar-renamer-dialog.c b/thunar/thunar-renamer-dialog.c
index 39da1a4..08716bb 100644
--- a/thunar/thunar-renamer-dialog.c
+++ b/thunar/thunar-renamer-dialog.c
@@ -877,7 +877,7 @@ thunar_renamer_dialog_context_menu (ThunarRenamerDialog *renamer_dialog,
/* add the items to the UI manager */
for (lp = items; lp != NULL; lp = lp->next)
{
- action = thunar_util_action_from_menu_item (G_OBJECT (lp->data), GTK_WIDGET (renamer_dialog));
+ action = thunar_util_action_from_menu_item (G_OBJECT (lp->data));
/* add the action to the action group */
gtk_action_group_add_action (renamer_actions, action);
diff --git a/thunar/thunar-shortcuts-view.c b/thunar/thunar-shortcuts-view.c
index 06b5e6f..0685246 100644
--- a/thunar/thunar-shortcuts-view.c
+++ b/thunar/thunar-shortcuts-view.c
@@ -1244,7 +1244,7 @@ thunar_shortcuts_view_context_menu (ThunarShortcutsView *view,
/* add the menu items to the menu */
for (lp = items; lp != NULL; lp = lp->next)
{
- action = thunar_util_action_from_menu_item (G_OBJECT (lp->data), window);
+ action = thunar_util_action_from_menu_item (G_OBJECT (lp->data));
item = gtk_action_create_menu_item (action);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index 4cfe3e4..165507b 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -2078,7 +2078,7 @@ thunar_standard_view_merge_custom_actions (ThunarStandardView *standard_view,
/* add the menu items to the UI manager */
for (lp = items; lp != NULL; lp = lp->next)
{
- action = thunar_util_action_from_menu_item (G_OBJECT (lp->data), window);
+ action = thunar_util_action_from_menu_item (G_OBJECT (lp->data));
/* add the action to the action group */
gtk_action_group_add_action (standard_view->priv->custom_actions, action);
diff --git a/thunar/thunar-tree-view.c b/thunar/thunar-tree-view.c
index 4856356..b5a6533 100644
--- a/thunar/thunar-tree-view.c
+++ b/thunar/thunar-tree-view.c
@@ -1518,7 +1518,7 @@ thunar_tree_view_context_menu (ThunarTreeView *view,
/* add the menu items to the menu */
for (lp = items; lp != NULL; lp = lp->next)
{
- action = thunar_util_action_from_menu_item (G_OBJECT (lp->data), window);
+ action = thunar_util_action_from_menu_item (G_OBJECT (lp->data));
item = gtk_action_create_menu_item (action);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
diff --git a/thunar/thunar-util.c b/thunar/thunar-util.c
index c769dbc..0784e5c 100644
--- a/thunar/thunar-util.c
+++ b/thunar/thunar-util.c
@@ -54,9 +54,9 @@
#include <glib/gwin32.h>
#endif
-#include <thunar/thunar-icon-factory.h>
#include <thunar/thunar-private.h>
#include <thunar/thunar-util.h>
+#include <thunarx/thunarx.h>
#include <glib.h>
#include <glib/gstdio.h>
@@ -623,15 +623,11 @@ extension_action_callback (GtkAction *action,
GtkAction *
-thunar_util_action_from_menu_item (GObject *item,
- GtkWidget *parent_widget)
+thunar_util_action_from_menu_item (GObject *item)
{
gchar *name, *label, *tooltip, *icon_name;
- gboolean sensitive, priority;
- GtkAction *action;
- GdkPixbuf *icon;
- GtkIconTheme *icon_theme;
- ThunarIconFactory *icon_factory;
+ gboolean sensitive, priority;
+ GtkAction *action;
g_return_val_if_fail (THUNARX_IS_MENU_ITEM (item), NULL);
@@ -646,18 +642,9 @@ thunar_util_action_from_menu_item (GObject *item,
action = gtk_action_new (name, label, tooltip, NULL);
- if (icon_name != NULL && parent_widget != NULL)
+ if (icon_name != NULL)
{
- icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (parent_widget));
- icon_factory = thunar_icon_factory_get_for_icon_theme (icon_theme);
- icon = thunar_icon_factory_load_icon (icon_factory, icon_name, GTK_ICON_SIZE_MENU, TRUE, FALSE);
- if (icon != NULL)
- {
- gtk_action_set_gicon (action, G_ICON (icon));
- g_object_unref (icon);
- }
-
- g_object_unref (G_OBJECT (icon_factory));
+ gtk_action_set_icon_name (action, icon_name);
}
gtk_action_set_sensitive (action, sensitive);
diff --git a/thunar/thunar-util.h b/thunar/thunar-util.h
index 68220d6..eee56be 100644
--- a/thunar/thunar-util.h
+++ b/thunar/thunar-util.h
@@ -55,8 +55,7 @@ gchar *thunar_util_change_working_directory (const gchar *new_directory)
void thunar_setup_display_cb (gpointer data);
-GtkAction *thunar_util_action_from_menu_item (GObject *item,
- GtkWidget *parent_widget) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+GtkAction *thunar_util_action_from_menu_item (GObject *item) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
G_END_DECLS;
diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index 34b6af3..462eceb 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -1967,7 +1967,7 @@ thunar_window_merge_custom_preferences (ThunarWindow *window)
for (ap = items; ap != NULL; ap = ap->next)
{
/* add the action to the action group */
- action = thunar_util_action_from_menu_item (G_OBJECT (ap->data), GTK_WIDGET (window));
+ action = thunar_util_action_from_menu_item (G_OBJECT (ap->data));
gtk_action_group_add_action (window->action_group, action);
/* add the action to the UI manager */
@@ -3441,7 +3441,7 @@ thunar_window_update_custom_actions (ThunarView *view,
if (G_UNLIKELY (lp->data == NULL))
continue;
- action = thunar_util_action_from_menu_item (G_OBJECT (lp->data), GTK_WIDGET (window));
+ action = thunar_util_action_from_menu_item (G_OBJECT (lp->data));
/* add the action to the action group */
gtk_action_group_add_action_with_accel (window->custom_actions,
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list