Commit 8cccd6a7 authored by Andre Miranda's avatar Andre Miranda

Simplify icon handling of ThunarxMenuItem

parent a1cfb2ba
......@@ -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);
......
......@@ -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))
......
......@@ -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,
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment