Commit 47fe1cbc authored by Andre Miranda's avatar Andre Miranda

Eschew GtkAction from Thunarx API

Instead use the new ThunarxMenuItem class and keep all
the deprecated stuff internally, away from the extensions
API.
parent 6d4931b7
......@@ -190,7 +190,7 @@
<title>Names</title>
<para>
Most objects created by the extensions need names, e.g. the <link linkend="GtkAction"><type>GtkAction</type></link>s
Most objects created by the extensions need names, e.g. the <link linkend="ThunarxMenuItem"><type>ThunarxMenuItem</type></link>s
returned from the <link linkend="ThunarxMenuProvider"><type>ThunarxMenuProvider</type></link>s. These names must be
namespaced with the name of the extension. For example the main action returned from the
<application>TexOpenTerminal</application> extension (which can be found in the <filename
......
#include <thunarx/thunarx.h>
thunarx_file_info_get_type
thunarx_menu_item_get_type
thunarx_menu_provider_get_type
thunarx_preferences_provider_get_type
thunarx_property_page_get_type
......
......@@ -41,7 +41,7 @@ static GList *tex_open_terminal_get_file_actions (ThunarxMenuProvider *pr
static GList *tex_open_terminal_get_folder_actions (ThunarxMenuProvider *provider,
GtkWidget *window,
ThunarxFileInfo *folder);
static void tex_open_terminal_activated (GtkAction *action,
static void tex_open_terminal_activated (ThunarxMenuItem *item,
GtkWidget *window);
......@@ -110,10 +110,10 @@ tex_open_terminal_get_folder_actions (ThunarxMenuProvider *provider,
GtkWidget *window,
ThunarxFileInfo *folder)
{
GtkAction *action = NULL;
gchar *scheme;
gchar *path;
gchar *uri;
ThunarxMenuItem *item = NULL;
gchar *scheme;
gchar *path;
gchar *uri;
/* determine the uri scheme of the folder and check if we support it */
scheme = thunarx_file_info_get_uri_scheme (folder);
......@@ -127,33 +127,33 @@ tex_open_terminal_get_folder_actions (ThunarxMenuProvider *provider,
/* check if we have a valid path here */
if (G_LIKELY (path != NULL))
{
action = gtk_action_new ("TexOpenTerminal::open-terminal-here", "Open Terminal Here", "Open Terminal in this folder", NULL);
g_signal_connect (G_OBJECT (action), "activate", G_CALLBACK (tex_open_terminal_activated), window);
g_object_set_data_full (G_OBJECT (action), "open-terminal-here-path", path, g_free);
item = thunarx_menu_item_new ("TexOpenTerminal::open-terminal-here", "Open Terminal Here", "Open Terminal in this folder", "utilities-terminal");
g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (tex_open_terminal_activated), window);
g_object_set_data_full (G_OBJECT (item), "open-terminal-here-path", path, g_free);
}
}
g_free (scheme);
return (action != NULL) ? g_list_prepend (NULL, action) : NULL;
return (item != NULL) ? g_list_prepend (NULL, item) : NULL;
}
static void
tex_open_terminal_activated (GtkAction *action,
GtkWidget *window)
tex_open_terminal_activated (ThunarxMenuItem *item,
GtkWidget *window)
{
const gchar *path;
GError *error = NULL;
gchar *command;
/* determine the folder path */
path = g_object_get_data (G_OBJECT (action), "open-terminal-here-path");
path = g_object_get_data (G_OBJECT (item), "open-terminal-here-path");
if (G_UNLIKELY (path == NULL))
return;
/* build up the command line for the terminal */
command = g_strdup_printf ("Terminal --working-directory \"%s\"", path);
command = g_strdup_printf ("exo-open --launch TerminalEmulator --working-directory \"%s\"", path);
/* try to run the terminal command */
if (!xfce_spawn_command_line_on_screen (gtk_widget_get_screen (window), command, FALSE, FALSE, &error))
......@@ -166,5 +166,3 @@ tex_open_terminal_activated (GtkAction *action,
/* cleanup */
g_free (command);
}
......@@ -48,7 +48,7 @@ static GList *thunar_uca_provider_get_folder_actions (ThunarxMenuProvider
GtkWidget *window,
ThunarxFileInfo *folder);
static void thunar_uca_provider_activated (ThunarUcaProvider *uca_provider,
GtkAction *action);
ThunarxMenuItem *item);
static void thunar_uca_provider_child_watch (ThunarUcaProvider *uca_provider,
gint exit_status);
static void thunar_uca_provider_child_watch_destroy (gpointer user_data,
......@@ -175,15 +175,15 @@ static GList*
thunar_uca_provider_get_actions (ThunarxPreferencesProvider *preferences_provider,
GtkWidget *window)
{
GtkAction *action;
GClosure *closure;
ThunarxMenuItem *item;
GClosure *closure;
action = gtk_action_new ("ThunarUca::manage-actions", _("Configure c_ustom actions..."),
_("Setup custom actions that will appear in the file managers context menus"), NULL);
item = thunarx_menu_item_new ("ThunarUca::manage-actions", _("Configure c_ustom actions..."),
_("Setup custom actions that will appear in the file managers context menus"), NULL);
closure = g_cclosure_new_object_swap (G_CALLBACK (manage_actions), G_OBJECT (window));
g_signal_connect_closure (G_OBJECT (action), "activate", closure, TRUE);
g_signal_connect_closure (G_OBJECT (item), "activate", closure, TRUE);
return g_list_prepend (NULL, action);
return g_list_prepend (NULL, item);
}
......@@ -197,7 +197,7 @@ thunar_uca_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
ThunarUcaProvider *uca_provider = THUNAR_UCA_PROVIDER (menu_provider);
ThunarUcaContext *uca_context = NULL;
GtkTreeIter iter;
GtkAction *action;
ThunarxMenuItem *item;
GList *actions = NULL;
GList *paths;
GList *lp;
......@@ -205,7 +205,8 @@ thunar_uca_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
gchar *label;
gchar *unique_id;
gchar *name;
GIcon *gicon;
gchar *icon_name = NULL;
GIcon *gicon = NULL;
paths = thunar_uca_model_match (uca_provider->model, files);
for (lp = g_list_last (paths); lp != NULL; lp = lp->prev)
......@@ -224,13 +225,15 @@ thunar_uca_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
/* generate a unique action name */
name = g_strdup_printf ("uca-action-%s", unique_id);
if (gicon != NULL)
icon_name = g_icon_to_string (gicon);
/* create the new action with the given parameters */
action = gtk_action_new (name, label, tooltip, NULL);
gtk_action_set_gicon (action, gicon);
item = thunarx_menu_item_new (name, label, tooltip, icon_name);
/* grab a tree row reference on the given path */
row = gtk_tree_row_reference_new (GTK_TREE_MODEL (uca_provider->model), lp->data);
g_object_set_qdata_full (G_OBJECT (action), thunar_uca_row_quark, row,
g_object_set_qdata_full (G_OBJECT (item), thunar_uca_row_quark, row,
(GDestroyNotify) gtk_tree_row_reference_free);
/* allocate a new context on-demand */
......@@ -238,20 +241,21 @@ thunar_uca_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
uca_context = thunar_uca_context_new (window, files);
else
uca_context = thunar_uca_context_ref (uca_context);
g_object_set_qdata_full (G_OBJECT (action), thunar_uca_context_quark, uca_context, (GDestroyNotify) thunar_uca_context_unref);
g_object_set_qdata_full (G_OBJECT (item), thunar_uca_context_quark, uca_context, (GDestroyNotify) thunar_uca_context_unref);
/* connect the "activate" signal */
g_signal_connect_data (G_OBJECT (action), "activate", G_CALLBACK (thunar_uca_provider_activated),
g_signal_connect_data (G_OBJECT (item), "activate", G_CALLBACK (thunar_uca_provider_activated),
g_object_ref (G_OBJECT (uca_provider)), (GClosureNotify) g_object_unref,
G_CONNECT_SWAPPED);
/* add the action to the return list */
actions = g_list_prepend (actions, action);
actions = g_list_prepend (actions, item);
/* cleanup */
g_free (tooltip);
g_free (label);
g_free (name);
g_free (icon_name);
g_free (unique_id);
if (gicon != NULL)
......@@ -296,7 +300,7 @@ thunar_uca_provider_get_folder_actions (ThunarxMenuProvider *menu_provider,
static void
thunar_uca_provider_activated (ThunarUcaProvider *uca_provider,
GtkAction *action)
ThunarxMenuItem *item)
{
GtkTreeRowReference *row;
ThunarUcaContext *uca_context;
......@@ -318,10 +322,10 @@ thunar_uca_provider_activated (ThunarUcaProvider *uca_provider,
GClosure *child_watch;
g_return_if_fail (THUNAR_UCA_IS_PROVIDER (uca_provider));
g_return_if_fail (GTK_IS_ACTION (action));
g_return_if_fail (THUNARX_IS_MENU_ITEM (item));
/* check if the row reference is still valid */
row = g_object_get_qdata (G_OBJECT (action), thunar_uca_row_quark);
row = g_object_get_qdata (G_OBJECT (item), thunar_uca_row_quark);
if (G_UNLIKELY (!gtk_tree_row_reference_valid (row)))
return;
......@@ -331,7 +335,7 @@ thunar_uca_provider_activated (ThunarUcaProvider *uca_provider,
gtk_tree_path_free (path);
/* determine the files and the window for the action */
uca_context = g_object_get_qdata (G_OBJECT (action), thunar_uca_context_quark);
uca_context = g_object_get_qdata (G_OBJECT (item), thunar_uca_context_quark);
window = thunar_uca_context_get_window (uca_context);
files = thunar_uca_context_get_files (uca_context);
......@@ -354,7 +358,7 @@ thunar_uca_provider_activated (ThunarUcaProvider *uca_provider,
if (G_LIKELY (filename != NULL))
{
/* if this is a folder action, we just use the filename as working directory */
if (g_object_get_qdata (G_OBJECT (action), thunar_uca_folder_quark) != NULL)
if (g_object_get_qdata (G_OBJECT (item), thunar_uca_folder_quark) != NULL)
{
working_directory = filename;
filename = NULL;
......@@ -412,7 +416,7 @@ thunar_uca_provider_activated (ThunarUcaProvider *uca_provider,
/* present error message to the user */
if (G_UNLIKELY (!succeed))
{
g_object_get (G_OBJECT (action), "label", &label, NULL);
g_object_get (G_OBJECT (item), "label", &label, NULL);
dialog = gtk_message_dialog_new ((GtkWindow *) window,
GTK_DIALOG_DESTROY_WITH_PARENT
| GTK_DIALOG_MODAL,
......
......@@ -46,7 +46,7 @@ static void twp_provider_finalize (GObject *objec
static GList *twp_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
GtkWidget *window,
GList *files);
static void twp_action_set_wallpaper (GtkAction *action,
static void twp_action_set_wallpaper (ThunarxMenuItem *item,
gpointer user_data);
static gint twp_get_active_workspace_number (GdkScreen *screen);
......@@ -129,15 +129,15 @@ twp_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
GtkWidget *window,
GList *files)
{
GtkWidget *action = NULL;
GFile *location;
GList *actions = NULL;
gchar *mime_type;
gchar selection_name[100];
Atom xfce_selection_atom;
Atom nautilus_selection_atom;
GdkScreen *gdk_screen = gdk_screen_get_default();
gint xscreen = gdk_screen_get_number(gdk_screen);
ThunarxMenuItem *item = NULL;
GFile *location;
GList *actions = NULL;
gchar *mime_type;
gchar selection_name[100];
Atom xfce_selection_atom;
Atom nautilus_selection_atom;
GdkScreen *gdk_screen = gdk_screen_get_default();
gint xscreen = gdk_screen_get_number(gdk_screen);
desktop_type = DESKTOP_TYPE_NONE;
......@@ -168,14 +168,10 @@ twp_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
|| thunarx_file_info_has_mime_type (files->data, "image/svg+xml")
|| thunarx_file_info_has_mime_type (files->data, "image/svg+xml-compressed")))
{
action = g_object_new (GTK_TYPE_ACTION,
"name", "Twp::setwallpaper",
"icon-name", "preferences-desktop-wallpaper",
"label", _("Set as wallpaper"),
NULL);
g_signal_connect (action, "activate", G_CALLBACK (twp_action_set_wallpaper), files->data);
actions = g_list_append (actions, action);
item = thunarx_menu_item_new ("Twp::setwallpaper", _("Set as wallpaper"), NULL, "preferences-desktop-wallpaper");
g_signal_connect (item, "activate", G_CALLBACK (twp_action_set_wallpaper), files->data);
actions = g_list_append (actions, item);
}
g_free(mime_type);
}
......@@ -200,17 +196,12 @@ twp_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
}
}
if ((desktop_type == DESKTOP_TYPE_NONE) && (action != NULL))
{
/* gtk_widget_set_sensitive (action, FALSE); */
}
return actions;
}
static void
twp_action_set_wallpaper (GtkAction *action,
gpointer user_data)
twp_action_set_wallpaper (ThunarxMenuItem *item,
gpointer user_data)
{
ThunarxFileInfo *file_info = user_data;
GdkDisplay *display = gdk_display_get_default();
......
......@@ -79,7 +79,8 @@ 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 wants_default,
gboolean force_size);
static guint thunar_icon_key_hash (gconstpointer data);
static gboolean thunar_icon_key_equal (gconstpointer a,
gconstpointer b);
......@@ -468,7 +469,8 @@ static GdkPixbuf*
thunar_icon_factory_lookup_icon (ThunarIconFactory *factory,
const gchar *name,
gint size,
gboolean wants_default)
gboolean wants_default,
gboolean force_size)
{
ThunarIconKey lookup_key;
ThunarIconKey *key;
......@@ -499,7 +501,8 @@ 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, GTK_ICON_LOOKUP_FORCE_SIZE);
icon_info = gtk_icon_theme_lookup_icon (factory->icon_theme, name, size,
force_size ? GTK_ICON_LOOKUP_FORCE_SIZE : 0);
if (G_LIKELY (icon_info != NULL))
{
/* try to load the pixbuf from the icon info */
......@@ -603,7 +606,7 @@ static GdkPixbuf*
thunar_icon_factory_load_fallback (ThunarIconFactory *factory,
gint size)
{
return thunar_icon_factory_lookup_icon (factory, "text-x-generic", size, FALSE);
return thunar_icon_factory_lookup_icon (factory, "text-x-generic", size, FALSE, TRUE);
}
......@@ -749,7 +752,8 @@ GdkPixbuf*
thunar_icon_factory_load_icon (ThunarIconFactory *factory,
const gchar *name,
gint size,
gboolean wants_default)
gboolean wants_default,
gboolean force_size)
{
_thunar_return_val_if_fail (THUNAR_IS_ICON_FACTORY (factory), NULL);
_thunar_return_val_if_fail (size > 0, NULL);
......@@ -767,7 +771,7 @@ thunar_icon_factory_load_icon (ThunarIconFactory *factory,
}
/* lookup the icon */
return thunar_icon_factory_lookup_icon (factory, name, size, wants_default);
return thunar_icon_factory_lookup_icon (factory, name, size, wants_default, force_size);
}
......@@ -819,7 +823,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);
icon = thunar_icon_factory_lookup_icon (factory, custom_icon, icon_size, FALSE, TRUE);
if (G_LIKELY (icon != NULL))
return icon;
}
......@@ -893,7 +897,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);
icon = thunar_icon_factory_load_icon (factory, icon_name, icon_size, TRUE, TRUE);
}
if (G_LIKELY (icon != NULL))
......
......@@ -54,7 +54,8 @@ 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 wants_default,
gboolean force_size);
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);
emblem = thunar_icon_factory_load_icon (icon_factory, lp->data, emblem_size, FALSE, TRUE);
if (G_UNLIKELY (emblem == NULL))
continue;
......
......@@ -1994,14 +1994,16 @@ static void
thunar_standard_view_merge_custom_actions (ThunarStandardView *standard_view,
GList *selected_items)
{
GtkTreeIter iter;
ThunarFile *file = NULL;
GtkWidget *window;
GList *providers;
GList *actions = NULL;
GList *files = NULL;
GList *tmp;
GList *lp;
GtkTreeIter iter;
ThunarFile *file = NULL;
GtkWidget *window;
GList *providers;
GList *actions = NULL;
GList *files = NULL;
GList *tmp;
GList *lp;
GtkAction *action;
ThunarxMenuItem *item;
/* we cannot add anything if we aren't connected to any UI manager */
if (G_UNLIKELY (standard_view->ui_manager == NULL))
......@@ -2077,8 +2079,11 @@ thunar_standard_view_merge_custom_actions (ThunarStandardView *standard_view,
/* add the actions to the UI manager */
for (lp = actions; lp != NULL; lp = lp->next)
{
item = THUNARX_MENU_ITEM (lp->data);
action = thunar_util_action_from_menu_item (item, GTK_WIDGET (window));
/* add the action to the action group */
gtk_action_group_add_action (standard_view->priv->custom_actions, GTK_ACTION (lp->data));
gtk_action_group_add_action (standard_view->priv->custom_actions, action);
/* add the action to the UI manager */
if (G_LIKELY (selected_items != NULL))
......@@ -2087,8 +2092,8 @@ thunar_standard_view_merge_custom_actions (ThunarStandardView *standard_view,
gtk_ui_manager_add_ui (standard_view->ui_manager,
standard_view->priv->custom_merge_id,
"/file-context-menu/placeholder-custom-actions",
gtk_action_get_name (GTK_ACTION (lp->data)),
gtk_action_get_name (GTK_ACTION (lp->data)),
gtk_action_get_name (GTK_ACTION (action)),
gtk_action_get_name (GTK_ACTION (action)),
GTK_UI_MANAGER_MENUITEM, FALSE);
}
else
......@@ -2097,13 +2102,14 @@ thunar_standard_view_merge_custom_actions (ThunarStandardView *standard_view,
gtk_ui_manager_add_ui (standard_view->ui_manager,
standard_view->priv->custom_merge_id,
"/folder-context-menu/placeholder-custom-actions",
gtk_action_get_name (GTK_ACTION (lp->data)),
gtk_action_get_name (GTK_ACTION (lp->data)),
gtk_action_get_name (GTK_ACTION (action)),
gtk_action_get_name (GTK_ACTION (action)),
GTK_UI_MANAGER_MENUITEM, FALSE);
}
/* release the reference on the action */
g_object_unref (G_OBJECT (lp->data));
/* release the reference on item and action */
g_object_unref (item);
g_object_unref (action);
}
/* be sure to update the UI manager to avoid flickering */
......
......@@ -54,6 +54,7 @@
#include <glib/gwin32.h>
#endif
#include <thunar/thunar-icon-factory.h>
#include <thunar/thunar-private.h>
#include <thunar/thunar-util.h>
......@@ -609,3 +610,66 @@ thunar_setup_display_cb (gpointer data)
{
g_setenv ("DISPLAY", (char *) data, TRUE);
}
static void
extension_action_callback (GtkAction *action,
gpointer callback_data)
{
thunarx_menu_item_activate (THUNARX_MENU_ITEM (callback_data));
}
GtkAction *
thunar_util_action_from_menu_item (ThunarxMenuItem *item,
GtkWidget *parent_widget)
{
gchar *name, *label, *tooltip, *icon_name;
gboolean sensitive, priority;
GtkAction *action;
GdkPixbuf *icon;
GtkIconTheme *icon_theme;
ThunarIconFactory *icon_factory;
g_object_get (G_OBJECT (item),
"name", &name,
"label", &label,
"tooltip", &tooltip,
"icon", &icon_name,
"sensitive", &sensitive,
"priority", &priority,
NULL);
action = gtk_action_new (name, label, tooltip, NULL);
if (icon_name != NULL && parent_widget != 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_sensitive (action, sensitive);
g_object_set (action, "is-important", priority, NULL);
g_signal_connect_data (action, "activate",
G_CALLBACK (extension_action_callback),
g_object_ref (item),
(GClosureNotify)g_object_unref, 0);
g_free (name);
g_free (label);
g_free (tooltip);
g_free (icon_name);
return action;
}
......@@ -24,6 +24,8 @@
#include <thunar/thunar-enum-types.h>
#include <thunarx/thunarx-menu-item.h>
G_BEGIN_DECLS;
typedef void (*ThunarBookmarksFunc) (GFile *file,
......@@ -55,6 +57,9 @@ gchar *thunar_util_change_working_directory (const gchar *new_directory)
void thunar_setup_display_cb (gpointer data);
GtkAction *thunar_util_action_from_menu_item (ThunarxMenuItem *item,
GtkWidget *parent_widget) G_GNUC_WARN_UNUSED_RESULT;
G_END_DECLS;
#endif /* !__THUNAR_UTIL_H__ */
......@@ -1944,9 +1944,11 @@ thunar_window_install_sidepane (ThunarWindow *window,
static void
thunar_window_merge_custom_preferences (ThunarWindow *window)
{
GList *providers;
GList *actions;
GList *ap, *pp;
GList *providers;
GList *actions;
GList *ap, *pp;
GtkAction *action;
ThunarxMenuItem *item;
_thunar_return_if_fail (THUNAR_IS_WINDOW (window));
_thunar_return_if_fail (window->custom_preferences_merge_id == 0);
......@@ -1966,18 +1968,21 @@ thunar_window_merge_custom_preferences (ThunarWindow *window)
for (ap = actions; ap != NULL; ap = ap->next)
{
/* add the action to the action group */
gtk_action_group_add_action (window->action_group, GTK_ACTION (ap->data));
item = THUNARX_MENU_ITEM (ap->data);
action = thunar_util_action_from_menu_item (item, GTK_WIDGET (window));
gtk_action_group_add_action (window->action_group, action);
/* add the action to the UI manager */
gtk_ui_manager_add_ui (window->ui_manager,
window->custom_preferences_merge_id,
"/main-menu/edit-menu/placeholder-custom-preferences",
gtk_action_get_name (GTK_ACTION (ap->data)),
gtk_action_get_name (GTK_ACTION (ap->data)),
gtk_action_get_name (GTK_ACTION (action)),
gtk_action_get_name (GTK_ACTION (action)),
GTK_UI_MANAGER_MENUITEM, FALSE);
/* release the reference on the action */
g_object_unref (G_OBJECT (ap->data));
/* release the references on item and action */
g_object_unref (G_OBJECT (item));
g_object_unref (G_OBJECT (action));
}
/* release the reference on the provider */
......@@ -3352,12 +3357,14 @@ thunar_window_update_custom_actions (ThunarView *view,
GParamSpec *pspec,
ThunarWindow *window)
{
ThunarFile *folder;
GList *selected_files;
GList *actions = NULL;
GList *lp;
GList *providers;
GList *tmp;
ThunarFile *folder;
GList *selected_files;
GList *actions = NULL;
GList *lp;
GList *providers;
GList *tmp;
GtkAction *action;
ThunarxMenuItem *item;
_thunar_return_if_fail (THUNAR_IS_VIEW (view));
_thunar_return_if_fail (THUNAR_IS_WINDOW (window));
......@@ -3434,21 +3441,28 @@ thunar_window_update_custom_actions (ThunarView *view,
/* add the actions to the UI manager */
for (lp = actions; lp != NULL; lp = lp->next)
{
if (G_UNLIKELY (lp->data == NULL))
continue;
item = THUNARX_MENU_ITEM (lp->data);
action = thunar_util_action_from_menu_item (item, GTK_WIDGET (window));
/* add the action to the action group */
gtk_action_group_add_action_with_accel (window->custom_actions,
GTK_ACTION (lp->data),
action,
NULL);
/* add to the file context menu */
gtk_ui_manager_add_ui (window->ui_manager,
window->custom_merge_id,
"/main-menu/file-menu/placeholder-custom-actions",
gtk_action_get_name (GTK_ACTION (lp->data)),
gtk_action_get_name (GTK_ACTION (lp->data)),
gtk_action_get_name (GTK_ACTION (action)),
gtk_action_get_name (GTK_ACTION (action)),
GTK_UI_MANAGER_MENUITEM, FALSE);
/* release the reference on the action */
g_object_unref (G_OBJECT (lp->data));
/* release the references on item and action */
g_object_unref (item);
g_object_unref (action);
}
/* cleanup */
......
......@@ -9,6 +9,7 @@ libthunarx_headers = \
thunarx.h \
thunarx-config.h \
thunarx-file-info.h \
thunarx-menu-item.h \
thunarx-menu-provider.h \
thunarx-preferences-provider.h \
thunarx-property-page.h \
......@@ -31,6 +32,7 @@ libthunarx_3_la_SOURCES = \
$(libthunarx_headers) \
thunarx-config.c \
thunarx-file-info.c \
thunarx-menu-item.c \
thunarx-menu-provider.c \
thunarx-preferences-provider.c \
thunarx-private.c \
......
This diff is collapsed.
/*-
* Copyright (c) 2017 Andre Miranda <andreldm@xfce.org>
*
* This program is free software; you can redistribute it and/or modify it