summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Schwinn <alexxcons@xfce.org>2020-05-17 02:56:10 +0200
committerAlexander Schwinn <alexxcons@xfce.org>2020-05-17 22:30:59 +0200
commit4a4ae621dcee6bef3a4aade98645624e4676f04c (patch)
tree50f9db3b7c925bb375ab88a593981646550cfeba
parent408529755ec7f499c72ad69ca1a924b9ab1751b6 (diff)
downloadthunar-4a4ae621dcee6bef3a4aade98645624e4676f04c.tar.gz
moved all actions which can be re-used by other widgets from
standard-view to launcher (Bug #16654) - Make use of XfceGtkActionEntries
-rw-r--r--thunar/thunar-launcher.c528
-rw-r--r--thunar/thunar-launcher.h13
-rw-r--r--thunar/thunar-standard-view.c1011
-rw-r--r--thunar/thunar-standard-view.h1
4 files changed, 569 insertions, 984 deletions
diff --git a/thunar/thunar-launcher.c b/thunar/thunar-launcher.c
index 7e9ce2d1..eb97d995 100644
--- a/thunar/thunar-launcher.c
+++ b/thunar/thunar-launcher.c
@@ -33,16 +33,24 @@
#include <thunar/thunar-application.h>
#include <thunar/thunar-browser.h>
#include <thunar/thunar-chooser-dialog.h>
+#include <thunar/thunar-clipboard-manager.h>
+#include <thunar/thunar-create-dialog.h>
#include <thunar/thunar-dialogs.h>
#include <thunar/thunar-file-monitor.h>
#include <thunar/thunar-gio-extensions.h>
#include <thunar/thunar-gobject-extensions.h>
#include <thunar/thunar-gtk-extensions.h>
+#include <thunar/thunar-icon-factory.h>
+#include <thunar/thunar-io-scan-directory.h>
#include <thunar/thunar-launcher.h>
#include <thunar/thunar-launcher-ui.h>
#include <thunar/thunar-preferences.h>
#include <thunar/thunar-private.h>
+#include <thunar/thunar-properties-dialog.h>
+#include <thunar/thunar-renamer-dialog.h>
#include <thunar/thunar-sendto-model.h>
+#include <thunar/thunar-shortcuts-pane.h>
+#include <thunar/thunar-simple-job.h>
#include <thunar/thunar-device-monitor.h>
#include <thunar/thunar-util.h>
#include <thunar/thunar-window.h>
@@ -122,9 +130,20 @@ static void thunar_launcher_action_open_in_new_tabs (Thuna
static void thunar_launcher_action_open_in_new_windows (ThunarLauncher *launcher);
static void thunar_launcher_action_open_with_other (ThunarLauncher *launcher);
static void thunar_launcher_action_sendto_desktop (ThunarLauncher *launcher);
+static void thunar_launcher_action_properties (ThunarLauncher *launcher);
static void thunar_launcher_action_sendto_device (ThunarLauncher *launcher,
GObject *object);
+static void thunar_launcher_action_make_link (ThunarLauncher *launcher);
+static void thunar_launcher_action_duplicate (ThunarLauncher *launcher);
+static void thunar_launcher_action_rename (ThunarLauncher *launcher);
+static void thunar_launcher_action_restore (ThunarLauncher *launcher);
+static void thunar_launcher_action_move_to_trash (ThunarLauncher *launcher);
+static void thunar_launcher_action_delete (ThunarLauncher *launcher);
+static void thunar_launcher_action_trash_delete (ThunarLauncher *launcher);
static void thunar_launcher_action_empty_trash (ThunarLauncher *launcher);
+static void thunar_launcher_action_cut (ThunarLauncher *launcher);
+static void thunar_launcher_action_copy (ThunarLauncher *launcher);
+static void thunar_launcher_action_paste_into_folder (ThunarLauncher *launcher);
static void thunar_launcher_sendto_device (ThunarLauncher *launcher,
ThunarDevice *device);
static void thunar_launcher_sendto_mount_finish (ThunarDevice *device,
@@ -133,7 +152,10 @@ static void thunar_launcher_sendto_mount_finish (Thuna
static GtkWidget *thunar_launcher_build_sendto_submenu (ThunarLauncher *launcher);
static void thunar_launcher_menu_item_activated (ThunarLauncher *launcher,
GtkWidget *menu_item);
-
+static void thunar_launcher_action_create_folder (ThunarLauncher *launcher);
+static GtkWidget *thunar_launcher_append_paste_item (ThunarLauncher *launcher,
+ GtkMenuShell *menu,
+ gboolean force);
struct _ThunarLauncherClass
{
@@ -216,7 +238,24 @@ static XfceGtkActionEntry thunar_launcher_action_entries[] =
/* Waiting for https://gitlab.gnome.org/GNOME/gtk/issues/2375 to be able to fix that */
{ THUNAR_LAUNCHER_ACTION_SENDTO_MENU, "<Actions>/ThunarWindow/sendto-menu", "", XFCE_GTK_MENU_ITEM, N_ ("_Send To"), NULL, NULL, NULL, },
{ THUNAR_LAUNCHER_ACTION_SENDTO_DESKTOP, "<Actions>/ThunarLauncher/sendto-desktop", "", XFCE_GTK_MENU_ITEM, NULL, NULL, "user-desktop", G_CALLBACK (thunar_launcher_action_sendto_desktop), },
+ { THUNAR_LAUNCHER_ACTION_PROPERTIES, "<Actions>/ThunarStandardView/properties", "<Alt>Return", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("_Properties..."), N_ ("View the properties of the selected file"), "document-properties", G_CALLBACK (thunar_launcher_action_properties), },
+ { THUNAR_LAUNCHER_ACTION_MAKE_LINK, "<Actions>/ThunarStandardView/make-link", "", XFCE_GTK_MENU_ITEM, N_ ("Ma_ke Link"), NULL, NULL, G_CALLBACK (thunar_launcher_action_make_link), },
+ { THUNAR_LAUNCHER_ACTION_DUPLICATE, "<Actions>/ThunarStandardView/duplicate", "", XFCE_GTK_MENU_ITEM, N_ ("Du_plicate"), NULL, NULL, G_CALLBACK (thunar_launcher_action_duplicate), },
+ { THUNAR_LAUNCHER_ACTION_RENAME, "<Actions>/ThunarStandardView/rename", "F2", XFCE_GTK_MENU_ITEM, N_ ("_Rename..."), NULL, NULL, G_CALLBACK (thunar_launcher_action_rename), },
{ THUNAR_LAUNCHER_ACTION_EMPTY_TRASH, "<Actions>/ThunarWindow/empty-trash", "", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("_Empty Trash"), N_ ("Delete all files and folders in the Trash"), NULL, G_CALLBACK (thunar_launcher_action_empty_trash), },
+ { THUNAR_LAUNCHER_ACTION_CREATE_FOLDER, "<Actions>/ThunarStandardView/create-folder", "<Primary><shift>N", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Create _Folder..."), N_ ("Create an empty folder within the current folder"), "folder-new", G_CALLBACK (thunar_launcher_action_create_folder), },
+
+ { THUNAR_LAUNCHER_ACTION_RESTORE, "<Actions>/ThunarLauncher/restore", "", XFCE_GTK_MENU_ITEM, N_ ("_Restore"), NULL, NULL, G_CALLBACK (thunar_launcher_action_restore), },
+ { THUNAR_LAUNCHER_ACTION_MOVE_TO_TRASH, "<Actions>/ThunarLauncher/move-to-trash", "", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Mo_ve to Trash"), NULL, "user-trash", G_CALLBACK (thunar_launcher_action_move_to_trash), },
+ { THUNAR_LAUNCHER_ACTION_DELETE, "<Actions>/ThunarLauncher/delete", "", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("_Delete"), NULL, "edit-delete", G_CALLBACK (thunar_launcher_action_delete), },
+ { THUNAR_LAUNCHER_ACTION_TRASH_DELETE, "<Actions>/ThunarLauncher/trash-delete", "Delete", XFCE_GTK_IMAGE_MENU_ITEM, NULL, NULL, NULL, G_CALLBACK (thunar_launcher_action_trash_delete), },
+ { THUNAR_LAUNCHER_ACTION_TRASH_DELETE, "<Actions>/ThunarLauncher/trash-delete-2", "<Shift>Delete", XFCE_GTK_IMAGE_MENU_ITEM, NULL, NULL, NULL, G_CALLBACK (thunar_launcher_action_trash_delete), },
+ { THUNAR_LAUNCHER_ACTION_TRASH_DELETE, "<Actions>/ThunarLauncher/trash-delete-3", "KP_Delete", XFCE_GTK_IMAGE_MENU_ITEM, NULL, NULL, NULL, G_CALLBACK (thunar_launcher_action_trash_delete), },
+ { THUNAR_LAUNCHER_ACTION_TRASH_DELETE, "<Actions>/ThunarLauncher/trash-delete-4", "<Shift>KP_Delete", XFCE_GTK_IMAGE_MENU_ITEM, NULL, NULL, NULL, G_CALLBACK (thunar_launcher_action_trash_delete), },
+ { THUNAR_LAUNCHER_ACTION_PASTE, "<Actions>/ThunarLauncher/paste", "<Primary>V", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("_Paste"), N_ ("Move or copy files previously selected by a Cut or Copy command"), "edit-paste", G_CALLBACK (thunar_launcher_action_paste_into_folder), },
+ { THUNAR_LAUNCHER_ACTION_PASTE_ALT, NULL, "", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("_Paste Into Folder"), N_ ("Move or copy files previously selected by a Cut or Copy command into the selected folder"), "edit-paste", G_CALLBACK (thunar_launcher_action_paste_into_folder), },
+ { THUNAR_LAUNCHER_ACTION_COPY, "<Actions>/ThunarLauncher/copy", "<Primary>C", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("_Copy"), N_ ("Prepare the selected files to be copied with a Paste command"), "edit-copy", G_CALLBACK (thunar_launcher_action_copy), },
+ { THUNAR_LAUNCHER_ACTION_CUT, "<Actions>/ThunarLauncher/cut", "<Primary>X", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Cu_t"), N_ ("Prepare the selected files to be moved with a Paste command"), "edit-cut", G_CALLBACK (thunar_launcher_action_cut), },
};
#define get_action_entry(id) xfce_gtk_get_action_entry_by_id(thunar_launcher_action_entries,G_N_ELEMENTS(thunar_launcher_action_entries),id)
@@ -1273,6 +1312,51 @@ thunar_launcher_show_trash (ThunarLauncher *launcher)
/**
+ * thunar_launcher_append_paste_item:
+ * @launcher : a #ThunarLauncher instance
+ * @menu : #GtkMenuShell on which the paste item should be appended
+ * @force : Append a 'paste' #GtkMenuItem, even if multiple folders are selected
+ *
+ * Will append a 'paste' #GtkMenuItem to the provided #GtkMenuShell
+ *
+ * Return value: (transfer full): The new #GtkMenuItem, or NULL
+ **/
+static GtkWidget*
+thunar_launcher_append_paste_item (ThunarLauncher *launcher,
+ GtkMenuShell *menu,
+ gboolean force)
+{
+ GtkWidget *item = NULL;
+ ThunarClipboardManager *clipboard;
+ const XfceGtkActionEntry *action_entry = get_action_entry (THUNAR_LAUNCHER_ACTION_PASTE);
+
+ _thunar_return_val_if_fail (THUNAR_IS_LAUNCHER (launcher), NULL);
+ _thunar_return_val_if_fail (action_entry != NULL, NULL);
+
+ if (!force && !launcher->single_folder_selected)
+ return NULL;
+
+ /* grab a reference on the clipboard manager for this display */
+ clipboard = thunar_clipboard_manager_get_for_display (gtk_widget_get_display (launcher->widget));
+
+ /* Some single folder is selected, but its not the current directory */
+ if (launcher->single_folder_selected && !launcher->current_directory_selected)
+ {
+ item = xfce_gtk_menu_item_new_from_action_entry (action_entry, G_OBJECT (launcher), GTK_MENU_SHELL (menu));
+ gtk_widget_set_sensitive (item, thunar_clipboard_manager_get_can_paste (clipboard) && thunar_file_is_writable (launcher->single_folder));
+ }
+ else
+ {
+ item = xfce_gtk_menu_item_new_from_action_entry (action_entry, G_OBJECT (launcher), GTK_MENU_SHELL (menu));
+ gtk_widget_set_sensitive (item, thunar_clipboard_manager_get_can_paste (clipboard) && thunar_file_is_writable (launcher->current_directory));
+ }
+ g_object_unref (clipboard);
+ return item;
+}
+
+
+
+/**
* thunar_launcher_append_menu_item:
* @launcher : Instance of a #ThunarLauncher
* @menu : #GtkMenuShell to which the item should be added
@@ -1345,6 +1429,91 @@ thunar_launcher_append_menu_item (ThunarLauncher *launcher,
gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
return item;
+ case THUNAR_LAUNCHER_ACTION_MAKE_LINK:
+ can_be_used = thunar_file_is_writable (launcher->current_directory) &&
+ launcher->current_directory_selected == FALSE &&
+ thunar_file_is_trashed (launcher->current_directory) == FALSE;;
+ if (!can_be_used && !force)
+ return NULL;
+
+ label_text = ngettext ("Ma_ke Link", "Ma_ke Links", launcher->n_selected_files);
+ tooltip_text = ngettext ("Create a symbolic link for the selected file",
+ "Create a symbolic link for each selected file", launcher->n_selected_files);
+ item = xfce_gtk_menu_item_new (label_text, tooltip_text, action_entry->accel_path, action_entry->callback,
+ G_OBJECT (launcher), menu);
+ gtk_widget_set_sensitive (item, can_be_used);
+ return item;
+
+ case THUNAR_LAUNCHER_ACTION_DUPLICATE:
+ can_be_used = thunar_file_is_writable (launcher->current_directory) &&
+ launcher->current_directory_selected == FALSE &&
+ thunar_file_is_trashed (launcher->current_directory) == FALSE;
+ if (!can_be_used && !force)
+ return NULL;
+ item = xfce_gtk_menu_item_new (action_entry->menu_item_label_text, action_entry->menu_item_tooltip_text,
+ action_entry->accel_path, action_entry->callback, G_OBJECT (launcher), menu);
+ gtk_widget_set_sensitive (item, can_be_used);
+ return item;
+
+ case THUNAR_LAUNCHER_ACTION_RENAME:
+ can_be_used = thunar_file_is_writable (launcher->current_directory) &&
+ launcher->current_directory_selected == FALSE &&
+ thunar_file_is_trashed (launcher->current_directory) == FALSE;
+ if (!can_be_used && !force)
+ return NULL;
+ tooltip_text = ngettext ("Rename the selected file",
+ "Rename the selected files", launcher->n_selected_files);
+ item = xfce_gtk_menu_item_new (action_entry->menu_item_label_text, tooltip_text, action_entry->accel_path,
+ action_entry->callback, G_OBJECT (launcher), menu);
+ gtk_widget_set_sensitive (item, can_be_used);
+ return item;
+
+ case THUNAR_LAUNCHER_ACTION_RESTORE:
+ if (launcher->current_directory_selected == FALSE && thunar_file_is_trashed (launcher->current_directory))
+ {
+ tooltip_text = ngettext ("Restore the selected file to its original location",
+ "Restore the selected files to its original location", launcher->n_selected_files);
+ item = xfce_gtk_menu_item_new (action_entry->menu_item_label_text, tooltip_text, action_entry->accel_path,
+ action_entry->callback, G_OBJECT (launcher), menu);
+ gtk_widget_set_sensitive (item, thunar_file_is_writable (launcher->current_directory));
+ return item;
+ }
+ return NULL;
+
+ case THUNAR_LAUNCHER_ACTION_MOVE_TO_TRASH:
+ if (!thunar_launcher_show_trash (launcher))
+ return NULL;
+
+ can_be_used = launcher->parent_folder != NULL &&
+ !launcher->current_directory_selected;
+ if (!can_be_used && !force)
+ return NULL;
+
+ tooltip_text = ngettext ("Move the selected file to the Trash",
+ "Move the selected files to the Trash", launcher->n_selected_files);
+ item = xfce_gtk_image_menu_item_new_from_icon_name (action_entry->menu_item_label_text, tooltip_text, action_entry->accel_path,
+ action_entry->callback, G_OBJECT (launcher), action_entry->menu_item_icon_name, menu);
+ gtk_widget_set_sensitive (item, can_be_used);
+ return item;
+
+
+ case THUNAR_LAUNCHER_ACTION_DELETE:
+ g_object_get (G_OBJECT (launcher->preferences), "misc-show-delete-action", &show_delete_item, NULL);
+ if (thunar_launcher_show_trash (launcher) && !show_delete_item)
+ return NULL;
+
+ can_be_used = launcher->parent_folder != NULL &&
+ !launcher->current_directory_selected;
+ if (!can_be_used && !force)
+ return NULL;
+
+ tooltip_text = ngettext ("Permanently delete the selected file",
+ "Permanently delete the selected files", launcher->n_selected_files);
+ item = xfce_gtk_image_menu_item_new_from_icon_name (action_entry->menu_item_label_text, tooltip_text, action_entry->accel_path,
+ action_entry->callback, G_OBJECT (launcher), action_entry->menu_item_icon_name, menu);
+ gtk_widget_set_sensitive (item, can_be_used);
+ return item;
+
case THUNAR_LAUNCHER_ACTION_EMPTY_TRASH:
if (launcher->single_folder_selected == TRUE)
{
@@ -1357,6 +1526,38 @@ thunar_launcher_append_menu_item (ThunarLauncher *launcher,
}
return NULL;
+ case THUNAR_LAUNCHER_ACTION_CREATE_FOLDER:
+ if (thunar_file_is_trashed (launcher->current_directory))
+ return NULL;
+ return xfce_gtk_menu_item_new_from_action_entry (action_entry, G_OBJECT (launcher), GTK_MENU_SHELL (menu));
+
+
+ case THUNAR_LAUNCHER_ACTION_CUT:
+ can_be_used = launcher->current_directory_selected == FALSE &&
+ launcher->parent_folder != NULL;
+ if (!can_be_used && !force)
+ return NULL;
+ tooltip_text = ngettext ("Prepare the selected file to be moved with a Paste command",
+ "Prepare the selected files to be moved with a Paste command", launcher->n_selected_files);
+ item = xfce_gtk_image_menu_item_new_from_icon_name (action_entry->menu_item_label_text, tooltip_text, action_entry->accel_path,
+ action_entry->callback, G_OBJECT (launcher), action_entry->menu_item_icon_name, menu);
+ gtk_widget_set_sensitive (item, can_be_used);
+ return item;
+
+ case THUNAR_LAUNCHER_ACTION_COPY:
+ can_be_used = launcher->current_directory_selected == FALSE;
+ if (!can_be_used && !force)
+ return NULL;
+ tooltip_text = ngettext ("Prepare the selected file to be copied with a Paste command",
+ "Prepare the selected files to be copied with a Paste command", launcher->n_selected_files);
+ item = xfce_gtk_image_menu_item_new_from_icon_name (action_entry->menu_item_label_text, tooltip_text, action_entry->accel_path,
+ action_entry->callback, G_OBJECT (launcher), action_entry->menu_item_icon_name, menu);
+ gtk_widget_set_sensitive (item, can_be_used);
+ return item;
+
+ case THUNAR_LAUNCHER_ACTION_PASTE:
+ return thunar_launcher_append_paste_item (launcher, menu, FALSE);
+
default:
return xfce_gtk_menu_item_new_from_action_entry (action_entry, G_OBJECT (launcher), GTK_MENU_SHELL (menu));
}
@@ -1616,6 +1817,234 @@ thunar_launcher_build_sendto_submenu (ThunarLauncher *launcher)
static void
+thunar_launcher_action_properties (ThunarLauncher *launcher)
+{
+ GtkWidget *toplevel;
+ GtkWidget *dialog;
+
+ _thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher));
+
+ /* popup the files dialog */
+ toplevel = gtk_widget_get_toplevel (launcher->widget);
+ if (G_LIKELY (toplevel != NULL))
+ {
+ dialog = thunar_properties_dialog_new (GTK_WINDOW (toplevel));
+
+ /* check if no files are currently selected */
+ if (launcher->selected_files == NULL)
+ {
+ /* if we don't have any files selected, we just popup the properties dialog for the current folder. */
+ thunar_properties_dialog_set_file (THUNAR_PROPERTIES_DIALOG (dialog), launcher->current_directory);
+ }
+ else
+ {
+ /* popup the properties dialog for all file(s) */
+ thunar_properties_dialog_set_files (THUNAR_PROPERTIES_DIALOG (dialog), launcher->selected_files);
+ }
+ gtk_widget_show (dialog);
+ }
+}
+
+
+
+static void
+thunar_launcher_action_make_link (ThunarLauncher *launcher)
+{
+ ThunarApplication *application;
+ GList *g_files = NULL;
+ GList *lp;
+
+ _thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher));
+
+ if (G_UNLIKELY (launcher->current_directory == NULL))
+ return;
+ if (launcher->current_directory_selected == TRUE || thunar_file_is_trashed (launcher->current_directory))
+ return;
+
+ for (lp = launcher->selected_files; lp != NULL; lp = lp->next)
+ {
+ g_files = g_list_append (g_files, thunar_file_get_file (lp->data));
+ }
+ /* link the selected files into the current directory, which effectively
+ * creates new unique links for the files.
+ */
+ application = thunar_application_get ();
+ thunar_application_link_into (application, launcher->widget, g_files,
+ thunar_file_get_file (launcher->current_directory), launcher->select_files_closure);
+ g_object_unref (G_OBJECT (application));
+ g_list_free (g_files);
+}
+
+
+
+static void
+thunar_launcher_action_duplicate (ThunarLauncher *launcher)
+{
+ ThunarApplication *application;
+ GList *selected_files;
+
+ _thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher));
+
+ if (G_UNLIKELY (launcher->current_directory == NULL))
+ return;
+ if (launcher->current_directory_selected == TRUE || thunar_file_is_trashed (launcher->current_directory))
+ return;
+
+ /* determine the selected files for the view */
+ selected_files = thunar_file_list_to_thunar_g_file_list (launcher->selected_files);
+ if (G_LIKELY (selected_files != NULL))
+ {
+ /* copy the selected files into the current directory, which effectively
+ * creates duplicates of the files.
+ */
+ application = thunar_application_get ();
+ thunar_application_copy_into (application, launcher->widget, selected_files,
+ thunar_file_get_file (launcher->current_directory), launcher->select_files_closure);
+ g_object_unref (G_OBJECT (application));
+
+ /* clean up */
+ thunar_g_file_list_free (selected_files);
+ }
+}
+
+
+
+static void
+thunar_launcher_rename_error (ExoJob *job,
+ GError *error,
+ GtkWidget *widget)
+{
+ GArray *param_values;
+ ThunarFile *file;
+
+ _thunar_return_if_fail (EXO_IS_JOB (job));
+ _thunar_return_if_fail (error != NULL);
+
+ param_values = thunar_simple_job_get_param_values (THUNAR_SIMPLE_JOB (job));
+ file = g_value_get_object (&g_array_index (param_values, GValue, 0));
+
+ thunar_dialogs_show_error (GTK_WIDGET (widget), error,
+ _("Failed to rename \"%s\""),
+ thunar_file_get_display_name (file));
+ g_object_unref (file);
+}
+
+
+
+static void
+thunar_launcher_rename_finished (ExoJob *job,
+ GtkWidget *widget)
+{
+ _thunar_return_if_fail (EXO_IS_JOB (job));
+
+ /* destroy the job */
+ g_signal_handlers_disconnect_matched (job, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, widget);
+ g_object_unref (job);
+}
+
+
+
+static void
+thunar_launcher_action_rename (ThunarLauncher *launcher)
+{
+ ThunarJob *job;
+ GtkWidget *window;
+
+ _thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher));
+
+ if (launcher->selected_files == NULL || g_list_length (launcher->selected_files) == 0)
+ return;
+ if (launcher->current_directory_selected == TRUE || thunar_file_is_trashed (launcher->current_directory))
+ return;
+
+ /* get the window */
+ window = gtk_widget_get_toplevel (launcher->widget);
+
+ /* start renaming if we have exactly one selected file */
+ if (g_list_length (launcher->selected_files) == 1)
+ {
+ /* run the rename dialog */
+ job = thunar_dialogs_show_rename_file (GTK_WINDOW (window), THUNAR_FILE (launcher->selected_files->data));
+ if (G_LIKELY (job != NULL))
+ {
+ g_signal_connect (job, "error", G_CALLBACK (thunar_launcher_rename_error), launcher->widget);
+ g_signal_connect (job, "finished", G_CALLBACK (thunar_launcher_rename_finished), launcher->widget);
+ }
+ }
+ else
+ {
+ /* display the bulk rename dialog */
+ thunar_show_renamer_dialog (GTK_WIDGET (window), launcher->current_directory, launcher->selected_files, FALSE, NULL);
+ }
+}
+
+
+
+static void
+thunar_launcher_action_restore (ThunarLauncher *launcher)
+{
+ ThunarApplication *application;
+
+ _thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher));
+
+ if (launcher->current_directory_selected == TRUE || !thunar_file_is_trashed (launcher->current_directory))
+ return;
+
+ /* restore the selected files */
+ application = thunar_application_get ();
+ thunar_application_restore_files (application, launcher->widget, launcher->selected_files, NULL);
+ g_object_unref (G_OBJECT (application));
+}
+
+
+static void
+thunar_launcher_action_move_to_trash (ThunarLauncher *launcher)
+{
+ ThunarApplication *application;
+
+ _thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher));
+
+ if (launcher->parent_folder == NULL || launcher->current_directory_selected)
+ return;
+
+ application = thunar_application_get ();
+ thunar_application_unlink_files (application, launcher->widget, launcher->selected_files, FALSE);
+ g_object_unref (G_OBJECT (application));
+}
+
+
+
+static void
+thunar_launcher_action_delete (ThunarLauncher *launcher)
+{
+ ThunarApplication *application;
+
+ _thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher));
+
+ if (launcher->parent_folder == NULL || launcher->current_directory_selected)
+ return;
+
+ application = thunar_application_get ();
+ thunar_application_unlink_files (application, launcher->widget, launcher->selected_files, TRUE);
+ g_object_unref (G_OBJECT (application));
+}
+
+
+
+static void
+thunar_launcher_action_trash_delete (ThunarLauncher *launcher)
+{
+ _thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher));
+
+ if (thunar_g_vfs_is_uri_scheme_supported ("trash"))
+ thunar_launcher_action_move_to_trash (launcher);
+ else
+ thunar_launcher_action_delete (launcher);
+}
+
+
+
+static void
thunar_launcher_action_empty_trash (ThunarLauncher *launcher)
{
ThunarApplication *application;
@@ -1634,6 +2063,103 @@ thunar_launcher_action_empty_trash (ThunarLauncher *launcher)
+static void
+thunar_launcher_action_create_folder (ThunarLauncher *launcher)
+{
+ ThunarApplication *application;
+ GList path_list;
+ gchar *name;
+
+ _thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher));
+ _thunar_return_if_fail (launcher->single_folder_selected);
+ _thunar_return_if_fail (launcher->single_folder != NULL);
+
+ if (thunar_file_is_trashed (launcher->single_folder))
+ return;
+
+ /* ask the user to enter a name for the new folder */
+ name = thunar_show_create_dialog (launcher->widget,
+ "inode/directory",
+ _("New Folder"),
+ _("Create New Folder"));
+ if (G_LIKELY (name != NULL))
+ {
+ /* fake the path list */
+ path_list.data = g_file_resolve_relative_path (thunar_file_get_file (launcher->current_directory), name);
+ path_list.next = path_list.prev = NULL;
+
+ /* launch the operation */
+ application = thunar_application_get ();
+ thunar_application_mkdir (application, launcher->widget, &path_list, launcher->select_files_closure);
+ g_object_unref (G_OBJECT (application));
+
+ /* release the path */
+ g_object_unref (path_list.data);
+
+ /* release the file name */
+ g_free (name);
+ }
+}
+
+
+
+static void
+thunar_launcher_action_cut (ThunarLauncher *launcher)
+{
+ ThunarClipboardManager *clipboard;
+
+ _thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher));
+
+ if (launcher->current_directory_selected || launcher->parent_folder == NULL)
+ return;
+
+ clipboard = thunar_clipboard_manager_get_for_display (gtk_widget_get_display (launcher->widget));
+ thunar_clipboard_manager_cut_files (clipboard, launcher->selected_files);
+ g_object_unref (G_OBJECT (clipboard));
+}
+
+
+
+static void
+thunar_launcher_action_copy (ThunarLauncher *launcher)
+{
+ ThunarClipboardManager *clipboard;
+
+ _thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher));
+
+ if (launcher->current_directory_selected)
+ return;
+
+ clipboard = thunar_clipboard_manager_get_for_display (gtk_widget_get_display (launcher->widget));
+ thunar_clipboard_manager_copy_files (clipboard, launcher->selected_files);
+ g_object_unref (G_OBJECT (clipboard));
+}
+
+
+
+static void
+thunar_launcher_action_paste_into_folder (ThunarLauncher *launcher)
+{
+ ThunarClipboardManager *clipboard;
+ ThunarFile *folder_to_paste;
+
+ _thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher));
+
+ if (launcher->current_directory_selected)
+ folder_to_paste = launcher->current_directory;
+ else if (launcher->single_folder_selected)
+ folder_to_paste = launcher->single_folder;
+ else
+ folder_to_paste = launcher->current_directory; /* Fallback if e.g. non directory files, or many folders are selected */
+
+ /* paste files from the clipboard to the folder */
+ clipboard = thunar_clipboard_manager_get_for_display (gtk_widget_get_display (launcher->widget));
+ thunar_clipboard_manager_paste_files (clipboard, thunar_file_get_file (folder_to_paste), launcher->widget, launcher->select_files_closure);
+ g_object_unref (G_OBJECT (clipboard));
+}
+
+
+
static GtkWidget*
thunar_launcher_build_application_submenu (ThunarLauncher *launcher,
GList *applications)
diff --git a/thunar/thunar-launcher.h b/thunar/thunar-launcher.h
index 6aa27cb2..c9909679 100644
--- a/thunar/thunar-launcher.h
+++ b/thunar/thunar-launcher.h
@@ -45,7 +45,20 @@ typedef enum
THUNAR_LAUNCHER_ACTION_OPEN_WITH_OTHER,
THUNAR_LAUNCHER_ACTION_SENDTO_MENU,
THUNAR_LAUNCHER_ACTION_SENDTO_DESKTOP,
+ THUNAR_LAUNCHER_ACTION_PROPERTIES,
+ THUNAR_LAUNCHER_ACTION_MAKE_LINK,
+ THUNAR_LAUNCHER_ACTION_DUPLICATE,
+ THUNAR_LAUNCHER_ACTION_RENAME,
THUNAR_LAUNCHER_ACTION_EMPTY_TRASH,
+ THUNAR_LAUNCHER_ACTION_CREATE_FOLDER,
+ THUNAR_LAUNCHER_ACTION_RESTORE,
+ THUNAR_LAUNCHER_ACTION_MOVE_TO_TRASH,
+ THUNAR_LAUNCHER_ACTION_DELETE,
+ THUNAR_LAUNCHER_ACTION_TRASH_DELETE,
+ THUNAR_LAUNCHER_ACTION_PASTE,
+ THUNAR_LAUNCHER_ACTION_PASTE_ALT,
+ THUNAR_LAUNCHER_ACTION_COPY,
+ THUNAR_LAUNCHER_ACTION_CUT,
} ThunarLauncherAction;
typedef enum
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index c9f0e1b3..6538eed3 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -42,8 +42,8 @@
#include <thunar/thunar-gtk-extensions.h>
#include <thunar/thunar-history.h>
#include <thunar/thunar-icon-renderer.h>
+#include <thunar/thunar-launcher.h>
#include <thunar/thunar-marshal.h>
-#include <thunar/thunar-menu-util.h>
#include <thunar/thunar-pango-extensions.h>
#include <thunar/thunar-private.h>
#include <thunar/thunar-properties-dialog.h>
@@ -51,7 +51,6 @@
#include <thunar/thunar-simple-job.h>
#include <thunar/thunar-standard-view.h>
#include <thunar/thunar-standard-view-ui.h>
-#include <thunar/thunar-templates-action.h>
#include <thunar/thunar-thumbnailer.h>
#include <thunar/thunar-util.h>
@@ -81,7 +80,6 @@ enum
/* Signal identifiers */
enum
{
- DELETE_SELECTED_FILES,
START_OPEN_LOCATION,
LAST_SIGNAL,
};
@@ -148,7 +146,6 @@ static void thunar_standard_view_scroll_to_file (Thu
gboolean use_align,
gfloat row_align,
gfloat col_align);
-static gboolean thunar_standard_view_delete_selected_files (ThunarStandardView *standard_view);
static GdkDragAction thunar_standard_view_get_dest_actions (ThunarStandardView *standard_view,
GdkDragContext *context,
gint x,
@@ -159,47 +156,17 @@ static ThunarFile *thunar_standard_view_get_drop_file (Thu
gint x,
gint y,
GtkTreePath **path_return);
-static void thunar_standard_view_merge_custom_actions (ThunarStandardView *standard_view);
static void thunar_standard_view_update_statusbar_text (ThunarStandardView *standard_view);
static void thunar_standard_view_current_directory_destroy (ThunarFile *current_directory,
ThunarStandardView *standard_view);
static void thunar_standard_view_current_directory_changed (ThunarFile *current_directory,
ThunarStandardView *standard_view);
-static void thunar_standard_view_action_create_empty_file (GtkAction *action,
- ThunarStandardView *standard_view);
-static void thunar_standard_view_action_create_folder (GtkAction *action,
- ThunarStandardView *standard_view);
-static void thunar_standard_view_action_create_template (GtkAction *action,
- const ThunarFile *file,
- ThunarStandardView *standard_view);
-static void thunar_standard_view_action_properties (GtkAction *action,
- ThunarStandardView *standard_view);
-static void thunar_standard_view_action_cut (GtkAction *action,
- ThunarStandardView *standard_view);
-static void thunar_standard_view_action_copy (GtkAction *action,
- ThunarStandardView *standard_view);
-static void thunar_standard_view_action_paste (GtkAction *action,
- ThunarStandardView *standard_view);
-static void thunar_standard_view_action_move_to_trash (GtkAction *action,
- ThunarStandardView *standard_view);
-static void thunar_standard_view_action_delete (GtkAction *action,
- ThunarStandardView *standard_view);
-static void thunar_standard_view_action_paste_into_folder (GtkAction *action,
- ThunarStandardView *standard_view);
static void thunar_standard_view_action_select_all_files (GtkAction *action,
ThunarStandardView *standard_view);
static void thunar_standard_view_action_select_by_pattern (GtkAction *action,
ThunarStandardView *standard_view);
static void thunar_standard_view_action_selection_invert (GtkAction *action,
ThunarStandardView *standard_view);
-static void thunar_standard_view_action_duplicate (GtkAction *action,
- ThunarStandardView *standard_view);
-static void thunar_standard_view_action_make_link (GtkAction *action,
- ThunarStandardView *standard_view);
-static void thunar_standard_view_action_rename (GtkAction *action,
- ThunarStandardView *standard_view);
-static void thunar_standard_view_action_restore (GtkAction *action,
- ThunarStandardView *standard_view);
static GClosure *thunar_standard_view_new_files_closure (ThunarStandardView *standard_view,
GtkWidget *source_view);
static void thunar_standard_view_new_files (ThunarStandardView *standard_view,
@@ -325,9 +292,6 @@ struct _ThunarStandardViewPrivate
/* history of the current view */
ThunarHistory *history;
- /* support for file manager extensions */
- ThunarxProviderFactory *provider_factory;
-
/* zoom-level support */
ThunarZoomLevel zoom_level;
@@ -338,10 +302,6 @@ struct _ThunarStandardViewPrivate
gchar *statusbar_text;
guint statusbar_text_idle_id;
- /* custom menu actions support */
- GtkActionGroup *custom_actions;
- gint custom_merge_id;
-
/* right-click drag/popup support */
GList *drag_g_file_list;
guint drag_scroll_timer_id;
@@ -400,21 +360,21 @@ static const GtkActionEntry action_entries[] =
{
{ "file-context-menu", NULL, N_ ("File Context Menu"), NULL, NULL, NULL, },
{ "folder-context-menu", NULL, N_ ("Folder Context Menu"), NULL, NULL, NULL, },
- { "create-folder", "folder-new", N_ ("Create _Folder..."), "<control><shift>N", N_ ("Create an empty folder within the current folder"), G_CALLBACK (thunar_standard_view_action_create_folder), },
- { "properties", "document-properties", N_ ("_Properties..."), "<alt>Return", N_ ("View the properties of the selected file"), G_CALLBACK (thunar_standard_view_action_properties), },
- { "cut", "edit-cut", N_ ("Cu_t"), "<control>X", NULL, G_CALLBACK (thunar_standard_view_action_cut), },
- { "copy", "edit-copy", N_ ("_Copy"), "<control>C", NULL, G_CALLBACK (thunar_standard_view_action_copy), },
- { "paste", "edit-paste", N_ ("_Paste"), "<control>V", N_ ("Move or copy files previously selected by a Cut or Copy command"), G_CALLBACK (thunar_standard_view_action_paste), },
- { "move-to-trash", "user-trash", N_ ("Mo_ve to Trash"), NULL, NULL, G_CALLBACK (thunar_standard_view_action_move_to_trash), },
- { "delete", "edit-delete", N_ ("_Delete"), NULL, NULL, G_CALLBACK (thunar_standard_view_action_delete), },
- { "paste-into-folder", "edit-paste", N_ ("Paste Into Folder"), NULL, N_ ("Move or copy files previously selected by a Cut or Copy command into the selected folder"), G_CALLBACK (thunar_standard_view_action_paste_into_folder), },
- { "select-all-files", NULL, N_ ("Select _all Files"), NULL, N_ ("Select all files in this window"), G_CALLBACK (thunar_standard_view_action_select_all_files), },
- { "select-by-pattern", NULL, N_ ("Select _by Pattern..."), "<control>S", N_ ("Select all files that match a certain pattern"), G_CALLBACK (thunar_standard_view_action_select_by_pattern), },
- { "invert-selection", NULL, N_ ("_Invert Selection"), NULL, N_ ("Select all files but not those currently selected"), G_CALLBACK (thunar_standard_view_action_selection_invert), },
- { "duplicate", NULL, N_ ("Du_plicate"), NULL, NULL, G_CALLBACK (thunar_standard_view_action_duplicate), },
- { "make-link", NULL, N_ ("Ma_ke Link"), NULL, NULL, G_CALLBACK (thunar_standard_view_action_make_link), },
- { "rename", NULL, N_ ("_Rename..."), "F2", NULL, G_CALLBACK (thunar_standard_view_action_rename), },
- { "restore", NULL, N_ ("_Restore"), NULL, NULL, G_CALLBACK (thunar_standard_view_action_restore), },
+ { "create-folder", "folder-new", N_ ("Create _Folder..."), "<control><shift>N", N_ ("Create an empty folder within the current folder"), G_CALLBACK (NULL), },
+ { "properties", "document-properties", N_ ("_Properties..."), "<alt>Return", N_ ("View the properties of the selected file"), G_CALLBACK (NULL), },
+ { "cut", "edit-cut", N_ ("Cu_t"), "<control>X", NULL, G_CALLBACK (NULL), },
+ { "copy", "edit-copy", N_ ("_Copy"), "<control>C", NULL, G_CALLBACK (NULL), },
+ { "paste", "edit-paste", N_ ("_Paste"), "<control>V", N_ ("Move or copy files previously selected by a Cut or Copy command"), G_CALLBACK (NULL), },
+ { "move-to-trash", "user-trash", N_ ("Mo_ve to Trash"), NULL, NULL, G_CALLBACK (NULL), },
+ { "delete", "edit-delete", N_ ("_Delete"), NULL, NULL, G_CALLBACK (NULL), },
+ { "paste-into-folder", "edit-paste", N_ ("Paste Into Folder"), NULL, N_ ("Move or copy files previously selected by a Cut or Copy command into the selected folder"), G_CALLBACK (NULL), },
+ { "select-all-files", NULL, N_ ("Select _all Files"), NULL, N_ ("Select all files in this window"), G_CALLBACK (NULL), },
+ { "select-by-pattern", NULL, N_ ("Select _by Pattern..."), "<control>S", N_ ("Select all files that match a certain pattern"), G_CALLBACK (NULL), },
+ { "invert-selection", NULL, N_ ("_Invert Selection"), NULL, N_ ("Select all files but not those currently selected"), G_CALLBACK (NULL), },
+ { "duplicate", NULL, N_ ("Du_plicate"), NULL, NULL, G_CALLBACK (NULL), },
+ { "make-link", NULL, N_ ("Ma_ke Link"), NULL, NULL, G_CALLBACK (NULL), },
+ { "rename", NULL, N_ ("_Rename..."), "F2", NULL, G_CALLBACK (NULL), },
+ { "restore", NULL, N_ ("_Restore"), NULL, NULL, G_CALLBACK (NULL), },
};
/* Target types for dragging from the view */
@@ -450,7 +410,6 @@ static void
thunar_standard_view_class_init (ThunarStandardViewClass *klass)
{
GtkWidgetClass *gtkwidget_class;
- GtkBindingSet *binding_set;
GObjectClass *gobject_class;
gpointer g_iface;
@@ -467,7 +426,6 @@ thunar_standard_view_class_init (ThunarStandardViewClass *klass)
gtkwidget_class->grab_focus = thunar_standard_view_grab_focus;
gtkwidget_class->draw = thunar_standard_view_draw;
- klass->delete_selected_files = thunar_standard_view_delete_selected_files;
klass->connect_ui_manager = (gpointer) exo_noop;
klass->disconnect_ui_manager = (gpointer) exo_noop;
@@ -578,30 +536,6 @@ thunar_standard_view_class_init (ThunarStandardViewClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
-
- /**
- * ThunarStandardView::delete-selected-files:
- * @standard_view : a #ThunarStandardView.
- *
- * Emitted whenever the user presses the Delete key. This
- * is an internal signal used to bind the action to keys.
- **/
- standard_view_signals[DELETE_SELECTED_FILES] =
- g_signal_new (I_("delete-selected-files"),
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (ThunarStandardViewClass, delete_selected_files),
- g_signal_accumulator_true_handled, NULL,
- _thunar_marshal_BOOLEAN__VOID,
- G_TYPE_BOOLEAN, 0);
-
- /* setup the key bindings for the standard views */
- binding_set = gtk_binding_set_by_class (klass);
- gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_CONTROL_MASK, "delete-selected-files", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, 0, "delete-selected-files", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, GDK_SHIFT_MASK, "delete-selected-files", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, 0, "delete-selected-files", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, GDK_SHIFT_MASK, "delete-selected-files", 0);
}
@@ -654,9 +588,6 @@ thunar_standard_view_init (ThunarStandardView *standard_view)
/* grab a reference on the preferences */
standard_view->preferences = thunar_preferences_get ();
- /* grab a reference on the provider factory */
- standard_view->priv->provider_factory = thunarx_provider_factory_get_default ();
-
/* create a thumbnailer */
standard_view->priv->thumbnailer = thunar_thumbnailer_get ();
g_signal_connect (G_OBJECT (standard_view->priv->thumbnailer), "request-finished", G_CALLBACK (thunar_standard_view_finished_thumbnailing), standard_view);
@@ -694,11 +625,11 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
G_GNUC_END_IGNORE_DEPRECATIONS
/* add the "Create Document" sub menu action */
- standard_view->priv->action_create_document = thunar_templates_action_new ("create-document", _("Create _Document"));
+ //standard_view->priv->action_create_document = thunar_templates_action_new ("create-document", _("Create _Document"));
g_signal_connect (G_OBJECT (standard_view->priv->action_create_document), "create-empty-file",
- G_CALLBACK (thunar_standard_view_action_create_empty_file), standard_view);
+ G_CALLBACK (NULL), standard_view);
g_signal_connect (G_OBJECT (standard_view->priv->action_create_document), "create-template",
- G_CALLBACK (thunar_standard_view_action_create_template), standard_view);
+ G_CALLBACK (NULL), standard_view);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_action_group_add_action (standard_view->action_group, standard_view->priv->action_create_document);
G_GNUC_END_IGNORE_DEPRECATIONS
@@ -896,7 +827,6 @@ thunar_standard_view_finalize (GObject *object)
_thunar_assert (standard_view->loading_binding == NULL);
_thunar_assert (standard_view->icon_factory == NULL);
_thunar_assert (standard_view->ui_manager == NULL);
- _thunar_assert (standard_view->clipboard == NULL);
/* release the thumbnailer */
g_signal_handlers_disconnect_by_func (standard_view->priv->thumbnailer, thunar_standard_view_finished_thumbnailing, standard_view);
@@ -909,9 +839,6 @@ thunar_standard_view_finalize (GObject *object)
/* release the selected_files list (if any) */
thunar_g_file_list_free (standard_view->priv->selected_files);
- /* release our reference on the provider factory */
- g_object_unref (G_OBJECT (standard_view->priv->provider_factory));
-
/* release the drag path list (just in case the drag-end wasn't fired before) */
thunar_g_file_list_free (standard_view->priv->drag_g_file_list);
@@ -1081,19 +1008,10 @@ thunar_standard_view_realize (GtkWidget *widget)
{
ThunarStandardView *standard_view = THUNAR_STANDARD_VIEW (widget);
GtkIconTheme *icon_theme;
- GdkDisplay *display;
/* let the GtkWidget do its work */
GTK_WIDGET_CLASS (thunar_standard_view_parent_class)->realize (widget);
- /* query the clipboard manager for the display */
- display = gtk_widget_get_display (widget);
- standard_view->clipboard = thunar_clipboard_manager_get_for_display (display);
-
- /* we need update the selection state based on the clipboard content */
- g_signal_connect_swapped (G_OBJECT (standard_view->clipboard), "changed",
- G_CALLBACK (thunar_standard_view_selection_changed), standard_view);
-
/* determine the icon factory for the screen on which we are realized */
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
standard_view->icon_factory = thunar_icon_factory_get_for_icon_theme (icon_theme);
@@ -1117,18 +1035,11 @@ thunar_standard_view_unrealize (GtkWidget *widget)
{
ThunarStandardView *standard_view = THUNAR_STANDARD_VIEW (widget);
- /* disconnect the clipboard changed handler */
- g_signal_handlers_disconnect_by_func (G_OBJECT (standard_view->clipboard), thunar_standard_view_selection_changed, standard_view);
-
/* drop the reference on the icon factory */
g_signal_handlers_disconnect_by_func (G_OBJECT (standard_view->icon_factory), gtk_widget_queue_draw, standard_view);
g_object_unref (G_OBJECT (standard_view->icon_factory));
standard_view->icon_factory = NULL;
- /* drop the reference on the clipboard manager */
- g_object_unref (G_OBJECT (standard_view->clipboard));
- standard_view->clipboard = NULL;
-
/* let the GtkWidget do its work */
GTK_WIDGET_CLASS (thunar_standard_view_parent_class)->unrealize (widget);
}
@@ -1270,21 +1181,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/* disconnect from the previous UI manager */
if (G_LIKELY (standard_view->ui_manager != NULL))
{
- /* remove any registered custom menu actions */
- if (G_LIKELY (standard_view->priv->custom_merge_id != 0))
- {
- gtk_ui_manager_remove_ui (standard_view->ui_manager, standard_view->priv->custom_merge_id);
- standard_view->priv->custom_merge_id = 0;
- }
-
- /* drop the previous custom action group */
- if (G_LIKELY (standard_view->priv->custom_actions != NULL))
- {
- gtk_ui_manager_remove_action_group (standard_view->ui_manager, standard_view->priv->custom_actions);
- g_object_unref (G_OBJECT (standard_view->priv->custom_actions));
- standard_view->priv->custom_actions = NULL;
- }
-
/* drop our action group from the previous UI manager */
gtk_ui_manager_remove_action_group (standard_view->ui_manager, standard_view->action_group);
@@ -1336,6 +1232,15 @@ G_GNUC_END_IGNORE_DEPRECATIONS
+static void
+thunar_standard_view_set_selected_files_view (ThunarView *view,
+ GList *selected_files)
+{
+ thunar_standard_view_set_selected_files_component (THUNAR_COMPONENT (view), selected_files);
+}
+
+
+
static ThunarFile*
thunar_standard_view_get_current_directory (ThunarNavigator *navigator)
{
@@ -1441,7 +1346,6 @@ thunar_standard_view_set_current_directory (ThunarNavigator *navigator,
{
ThunarStandardView *standard_view = THUNAR_STANDARD_VIEW (navigator);
ThunarFolder *folder;
- gboolean trashed;
_thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
_thunar_return_if_fail (current_directory == NULL || THUNAR_IS_FILE (current_directory));
@@ -1524,21 +1428,6 @@ thunar_standard_view_set_current_directory (ThunarNavigator *navigator,
/* reconnect our model to the view */
g_object_set (G_OBJECT (gtk_bin_get_child (GTK_BIN (standard_view))), "model", standard_view->model, NULL);
- /* check if the new directory is in the trash */
- trashed = thunar_file_is_trashed (current_directory);
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- /* update the "Create Folder"/"Create Document" actions */
- gtk_action_set_visible (standard_view->priv->action_create_folder, !trashed);
- gtk_action_set_visible (standard_view->priv->action_create_document, !trashed);
-
- /* update the "Rename" action */
- gtk_action_set_visible (standard_view->priv->action_rename, !trashed);
-
- /* update the "Restore" action */
- gtk_action_set_visible (standard_view->priv->action_restore, trashed);
-G_GNUC_END_IGNORE_DEPRECATIONS
-
/* schedule a thumbnail timeout */
/* NOTE: quickly after this we always trigger a size allocate wich will handle this */
@@ -1897,54 +1786,6 @@ thunar_standard_view_scroll_to_file (ThunarView *view,
-static gboolean
-thunar_standard_view_delete_selected_files (ThunarStandardView *standard_view)
-{
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- GtkAction *action = GTK_ACTION (standard_view->priv->action_move_to_trash);
-G_GNUC_END_IGNORE_DEPRECATIONS
- const gchar *accel_path;
- GtkAccelKey key;
-
- _thunar_return_val_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view), FALSE);
-
- if (thunar_g_vfs_is_uri_scheme_supported ("trash"))
- {
- /* Check if there is a user defined accelerator for the delete action,
- * if there is, skip events from the hard-coded keys which are set in
- * the class of the standard view. See bug #4173.
- *
- * The trick here is that if a custom accelerator is set by the user,
- * this function is never called. If a hardcoded key combination is
- * pressed and a custom accelerator is set, accel_key || accel_mods
- * are no 0. */
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- accel_path = gtk_action_get_accel_path (action);
-G_GNUC_END_IGNORE_DEPRECATIONS
- if (accel_path != NULL
- && gtk_accel_map_lookup_entry (accel_path, &key)
- && (key.accel_key != 0 || key.accel_mods != 0))
- return FALSE;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- /* just emit the "activate" signal on the "move-trash" action */
- gtk_action_activate (action);
-G_GNUC_END_IGNORE_DEPRECATIONS
- }
- else
- {
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- /* do a permanent delete */
- gtk_action_activate (GTK_ACTION (standard_view->priv->action_delete));
-G_GNUC_END_IGNORE_DEPRECATIONS
- }
-
- /* ...and we're done */
- return TRUE;
-}
-
-
-
static GdkDragAction
thunar_standard_view_get_dest_actions (ThunarStandardView *standard_view,
GdkDragContext *context,
@@ -2058,128 +1899,6 @@ thunar_standard_view_get_drop_file (ThunarStandardView *standard_view,
-static void
-thunar_standard_view_merge_custom_actions (ThunarStandardView *standard_view)
-{
- GtkTreeIter iter;
- ThunarFile *file = NULL;
- GtkWidget *window;
- GList *providers;
- GList *items = NULL;
- GList *files = NULL;
- GList *tmp;
- GList *lp;
- GList *selected_items;
- gchar *path;
-
- /* we cannot add anything if we aren't connected to any UI manager */
- if (G_UNLIKELY (standard_view->ui_manager == NULL))
- return;
-
- /* determine the toplevel window we belong to */
- window = gtk_widget_get_toplevel (GTK_WIDGET (standard_view));
-
- /* get the selected items */
- selected_items = (*THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->get_selected_items) (standard_view);
-
- /* load the menu providers from the provider factory */
- providers = thunarx_provider_factory_list_providers (standard_view->priv->provider_factory, THUNARX_TYPE_MENU_PROVIDER);
- if (G_LIKELY (providers != NULL))
- {
- /* determine the list of selected files or the current folder */
- if (G_LIKELY (selected_items != NULL))
- {
- for (lp = selected_items; lp != NULL; lp = lp->next)
- {
- gtk_tree_model_get_iter (GTK_TREE_MODEL (standard_view->model), &iter, lp->data);
- file = thunar_list_model_get_file (standard_view->model, &iter);
- files = g_list_prepend (files, file);
- }
- files = g_list_reverse (files);
- }
- else
- {
- /* grab a reference to the current directory of the view */
- file = thunar_navigator_get_current_directory (THUNAR_NAVIGATOR (standard_view));
- }
-
- /* load the menu items offered by the menu providers */
- for (lp = providers; lp != NULL; lp = lp->next)
- {
- if (G_LIKELY (files != NULL))
- tmp = thunarx_menu_provider_get_file_menu_items (lp->data, window, files);
- else if (G_LIKELY (file != NULL))
- tmp = thunarx_menu_provider_get_folder_menu_items (lp->data, window, THUNARX_FILE_INFO (file));
- else
- tmp = NULL;
- items = g_list_concat (items, tmp);
- g_object_unref (G_OBJECT (lp->data));
- }
- g_list_free (providers);
-
- /* cleanup the selected files list (if any) */
- if (G_LIKELY (files != NULL))
- thunar_g_file_list_free (files);
- }
-
- /* remove the previously determined menu actions from the UI manager */
- if (G_LIKELY (standard_view->priv->custom_merge_id != 0))
- {
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gtk_ui_manager_remove_ui (standard_view->ui_manager, standard_view->priv->custom_merge_id);
- gtk_ui_manager_ensure_update (standard_view->ui_manager);
-G_GNUC_END_IGNORE_DEPRECATIONS
- standard_view->priv->custom_merge_id = 0;
- }
-
- /* drop any previous custom action group */
- if (G_LIKELY (standard_view->priv->custom_actions != NULL))
- {
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gtk_ui_manager_remove_action_group (standard_view->ui_manager, standard_view->priv->custom_actions);
-G_GNUC_END_IGNORE_DEPRECATIONS
- g_object_unref (G_OBJECT (standard_view->priv->custom_actions));
- standard_view->priv->custom_actions = NULL;
- }
-
- /* add the actions specified by the menu providers */
- if (G_LIKELY (items != NULL))
- {
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- /* allocate the action group and the merge id for the custom actions */
- standard_view->priv->custom_actions = gtk_action_group_new ("thunar-standard-view-custom-actions");
- standard_view->priv->custom_merge_id = gtk_ui_manager_new_merge_id (standard_view->ui_manager);
- gtk_ui_manager_insert_action_group (standard_view->ui_manager, standard_view->priv->custom_actions, -1);
-G_GNUC_END_IGNORE_DEPRECATIONS
-
- if (G_LIKELY (selected_items != NULL))
- {
- /* add to the file context menu */
- path = "/file-context-menu/placeholder-custom-actions";
- }
- else
- {
- /* add to the folder context menu */
- path = "/folder-context-menu/placeholder-custom-actions";
- }
-
- thunar_menu_util_add_items_to_ui_manager (standard_view->ui_manager,
- standard_view->priv->custom_actions,
- standard_view->priv->custom_merge_id,
- path, items);
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- /* be sure to update the UI manager to avoid flickering */
- gtk_ui_manager_ensure_update (standard_view->ui_manager);
-G_GNUC_END_IGNORE_DEPRECATIONS
-
- /* cleanup */
- g_list_free (items);
- }
-}
-
-
-
static gboolean
thunar_standard_view_update_statusbar_text_idle (gpointer data)
{
@@ -2341,332 +2060,6 @@ thunar_standard_view_current_directory_changed (ThunarFile *current_dire
static void
-thunar_standard_view_action_create_empty_file (GtkAction *action,
- ThunarStandardView *standard_view)
-{
- ThunarApplication *application;
- ThunarFile *current_directory;
- GList path_list;
- gchar *name;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (GTK_IS_ACTION (action));
-G_GNUC_END_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
-
- /* ask the user to enter a name for the new empty file */
- name = thunar_show_create_dialog (GTK_WIDGET (standard_view),
- "text/plain",
- _("New Empty File"),
- _("New Empty File..."));
- if (G_LIKELY (name != NULL))
- {
- /* determine the ThunarFile for the current directory */
- current_directory = thunar_navigator_get_current_directory (THUNAR_NAVIGATOR (standard_view));
- if (G_LIKELY (current_directory != NULL))
- {
- /* fake the path list */
- path_list.data = g_file_resolve_relative_path (thunar_file_get_file (current_directory), name);
- path_list.next = path_list.prev = NULL;
-
- /* launch the operation */
- application = thunar_application_get ();
- thunar_application_creat (application, GTK_WIDGET (standard_view), &path_list, NULL,
- thunar_standard_view_new_files_closure (standard_view, NULL));
- g_object_unref (application);
-
- /* release the path */
- g_object_unref (path_list.data);
- }
-
- /* release the file name in the local encoding */
- g_free (name);
- }
-}
-
-
-
-static void
-thunar_standard_view_action_create_folder (GtkAction *action,
- ThunarStandardView *standard_view)
-{
- ThunarApplication *application;
- ThunarFile *current_directory;
- GList path_list;
- gchar *name;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (GTK_IS_ACTION (action));
-G_GNUC_END_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
-
- /* ask the user to enter a name for the new folder */
- name = thunar_show_create_dialog (GTK_WIDGET (standard_view),
- "inode/directory",
- _("New Folder"),
- _("Create New Folder"));
- if (G_LIKELY (name != NULL))
- {
- /* determine the ThunarFile for the current directory */
- current_directory = thunar_navigator_get_current_directory (THUNAR_NAVIGATOR (standard_view));
- if (G_LIKELY (current_directory != NULL))
- {
- /* fake the path list */
- path_list.data = g_file_resolve_relative_path (thunar_file_get_file (current_directory), name);
- path_list.next = path_list.prev = NULL;
-
- /* launch the operation */
- application = thunar_application_get ();
- thunar_application_mkdir (application, GTK_WIDGET (standard_view), &path_list,
- thunar_standard_view_new_files_closure (standard_view, NULL));
- g_object_unref (G_OBJECT (application));
-
- /* release the path */
- g_object_unref (path_list.data);
- }
-
- /* release the file name */
- g_free (name);
- }
-}
-
-
-
-static void
-thunar_standard_view_action_create_template (GtkAction *action,
- const ThunarFile *file,
- ThunarStandardView *standard_view)
-{
- ThunarApplication *application;
- ThunarFile *current_directory;
- GList target_path_list;
- gchar *name;
- gchar *title;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (GTK_IS_ACTION (action));
-G_GNUC_END_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (THUNAR_IS_FILE (file));
- _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
-
- /* generate a title for the create dialog */
- title = g_strdup_printf (_("Create Document from template \"%s\""),
- thunar_file_get_display_name (file));
-
- /* ask the user to enter a name for the new document */
- name = thunar_show_create_dialog (GTK_WIDGET (standard_view),
- thunar_file_get_content_type (THUNAR_FILE (file)),
- thunar_file_get_display_name (file),
- title);
- if (G_LIKELY (name != NULL))
- {
- /* determine the ThunarFile for the current directory */
- current_directory = thunar_navigator_get_current_directory (THUNAR_NAVIGATOR (standard_view));
- if (G_LIKELY (current_directory != NULL))
- {
- /* fake the target path list */
- target_path_list.data = g_file_get_child (thunar_file_get_file (current_directory), name);
- target_path_list.next = NULL;
- target_path_list.prev = NULL;
-
- /* launch the operation */
- application = thunar_application_get ();
- thunar_application_creat (application, GTK_WIDGET (standard_view), &target_path_list,
- thunar_file_get_file (file),
- thunar_standard_view_new_files_closure (standard_view, NULL));
- g_object_unref (G_OBJECT (application));
-
- /* release the target path */
- g_object_unref (target_path_list.data);
- }
-
- /* release the file name */
- g_free (name);
- }
-
- /* cleanup */
- g_free (title);
-}
-
-
-
-static void
-thunar_standard_view_action_properties (GtkAction *action,
- ThunarStandardView *standard_view)
-{
- ThunarFile *directory;
- GtkWidget *toplevel;
- GtkWidget *dialog;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (GTK_IS_ACTION (action));
-G_GNUC_END_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
-
- /* popup the files dialog */
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (standard_view));
- if (G_LIKELY (toplevel != NULL))
- {
- dialog = thunar_properties_dialog_new (GTK_WINDOW (toplevel));
-
- /* check if no files are currently selected */
- if (standard_view->priv->selected_files == NULL)
- {
- /* if we don't have any files selected, we just popup
- * the properties dialog for the current folder.
- */
- directory = thunar_navigator_get_current_directory (THUNAR_NAVIGATOR (standard_view));
- thunar_properties_dialog_set_file (THUNAR_PROPERTIES_DIALOG (dialog), directory);
- }
- else
- {
- /* popup the properties dialog for all file(s) */
- thunar_properties_dialog_set_files (THUNAR_PROPERTIES_DIALOG (dialog),
- standard_view->priv->selected_files);
- }
-
- gtk_widget_show (dialog);
- }
-}
-
-
-
-static void
-thunar_standard_view_action_cut (GtkAction *action,
- ThunarStandardView *standard_view)
-{
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (GTK_IS_ACTION (action));
-G_GNUC_END_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
- _thunar_return_if_fail (THUNAR_IS_CLIPBOARD_MANAGER (standard_view->clipboard));
-
- thunar_clipboard_manager_cut_files (standard_view->clipboard, standard_view->priv->selected_files);
-}
-
-
-
-static void
-thunar_standard_view_action_copy (GtkAction *action,
- ThunarStandardView *standard_view)
-{
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (GTK_IS_ACTION (action));
-G_GNUC_END_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
- _thunar_return_if_fail (THUNAR_IS_CLIPBOARD_MANAGER (standard_view->clipboard));
-
- thunar_clipboard_manager_copy_files (standard_view->clipboard, standard_view->priv->selected_files);
-}
-
-
-
-static void
-thunar_standard_view_action_paste (GtkAction *action,
- ThunarStandardView *standard_view)
-{
- ThunarFile *current_directory;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (GTK_IS_ACTION (action));
-G_GNUC_END_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
-
- current_directory = thunar_navigator_get_current_directory (THUNAR_NAVIGATOR (standard_view));
- if (G_LIKELY (current_directory != NULL))
- {
- thunar_clipboard_manager_paste_files (standard_view->clipboard, thunar_file_get_file (current_directory),
- GTK_WIDGET (standard_view), thunar_standard_view_new_files_closure (standard_view, NULL));
- }
-}
-
-
-
-static void
-thunar_standard_view_unlink_selection (ThunarStandardView *standard_view,
- gboolean permanently)
-{
- ThunarApplication *application;
-
- _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
-
- /* delete the selected files */
- application = thunar_application_get ();
- thunar_application_unlink_files (application, GTK_WIDGET (standard_view),
- standard_view->priv->selected_files,
- permanently);
- g_object_unref (G_OBJECT (application));
-
- /* do not select new files */
- thunar_component_set_selected_files (THUNAR_COMPONENT (standard_view), NULL);
-}
-
-
-
-static void
-thunar_standard_view_action_move_to_trash (GtkAction *action,
- ThunarStandardView *standard_view)
-{
- gboolean permanently;
- GdkModifierType state;
- const gchar *accel_path;
- GtkAccelKey key;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (GTK_IS_ACTION (action));
-G_GNUC_END_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
-
- /* check if we should permanently delete the files (user holds shift) */
- permanently = (gtk_get_current_event_state (&state) && (state & GDK_SHIFT_MASK) != 0);
- if (permanently)
- {
- /* look if the user has set a custom accelerator (accel_key != 0)
- * that contains a shift modifier */
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- accel_path = gtk_action_get_accel_path (action);
-G_GNUC_END_IGNORE_DEPRECATIONS
- if (accel_path != NULL
- && gtk_accel_map_lookup_entry (accel_path, &key)
- && key.accel_key != 0
- && (key.accel_mods & GDK_SHIFT_MASK) != 0)
- permanently = FALSE;
- }
-
- thunar_standard_view_unlink_selection (standard_view, permanently);
-}
-
-
-
-static void
-thunar_standard_view_action_delete (GtkAction *action,
- ThunarStandardView *standard_view)
-{
- thunar_standard_view_unlink_selection (standard_view, TRUE);
-}
-
-
-
-static void
-thunar_standard_view_action_paste_into_folder (GtkAction *action,
- ThunarStandardView *standard_view)
-{
- ThunarFile *file;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (GTK_IS_ACTION (action));
-G_GNUC_END_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
-
- /* determine the first selected file and verify that it's a folder */
- file = g_list_nth_data (standard_view->priv->selected_files, 0);
- if (G_LIKELY (file != NULL && thunar_file_is_directory (file)))
- thunar_clipboard_manager_paste_files (standard_view->clipboard, thunar_file_get_file (file), GTK_WIDGET (standard_view), NULL);
-}
-
-
-
-static void
thunar_standard_view_action_select_all_files (GtkAction *action,
ThunarStandardView *standard_view)
{
@@ -2802,221 +2195,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
-static void
-thunar_standard_view_action_duplicate (GtkAction *action,
- ThunarStandardView *standard_view)
-{
- ThunarApplication *application;
- ThunarFile *current_directory;
- GClosure *new_files_closure;
- GList *selected_files;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (GTK_IS_ACTION (action));
-G_GNUC_END_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
-
- /* determine the file for the current directory */
- current_directory = thunar_navigator_get_current_directory (THUNAR_NAVIGATOR (standard_view));
- if (G_LIKELY (current_directory != NULL))
- {
- /* determine the selected files for the view */
- selected_files = thunar_file_list_to_thunar_g_file_list (standard_view->priv->selected_files);
- if (G_LIKELY (selected_files != NULL))
- {
- /* copy the selected files into the current directory, which effectively
- * creates duplicates of the files.
- */
- application = thunar_application_get ();
- new_files_closure = thunar_standard_view_new_files_closure (standard_view, NULL);
- thunar_application_copy_into (application, GTK_WIDGET (standard_view), selected_files,
- thunar_file_get_file (current_directory), new_files_closure);
- g_object_unref (G_OBJECT (application));
-
- /* clean up */
- thunar_g_file_list_free (selected_files);
- }
- }
-}
-
-
-
-static void
-thunar_standard_view_action_make_link (GtkAction *action,
- ThunarStandardView *standard_view)
-{
- ThunarApplication *application;
- ThunarFile *current_directory;
- GClosure *new_files_closure;
- GList *selected_files;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (GTK_IS_ACTION (action));
-G_GNUC_END_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
-
- /* determine the file for the current directory */
- current_directory = thunar_navigator_get_current_directory (THUNAR_NAVIGATOR (standard_view));
- if (G_LIKELY (current_directory != NULL))
- {
- /* determine the selected paths for the view */
- selected_files = thunar_file_list_to_thunar_g_file_list (standard_view->priv->selected_files);
- if (G_LIKELY (selected_files != NULL))
- {
- /* link the selected files into the current directory, which effectively
- * creates new unique links for the files.
- */
- application = thunar_application_get ();
- new_files_closure = thunar_standard_view_new_files_closure (standard_view, NULL);
- thunar_application_link_into (application, GTK_WIDGET (standard_view), selected_files,
- thunar_file_get_file (current_directory), new_files_closure);
- g_object_unref (G_OBJECT (application));
-
- /* clean up */
- thunar_g_file_list_free (selected_files);
- }
- }
-}
-
-
-
-static void
-thunar_standard_view_rename_error (ExoJob *job,
- GError *error,
- ThunarStandardView *standard_view)
-{
- GArray *param_values;
- ThunarFile *file;
-
- _thunar_return_if_fail (EXO_IS_JOB (job));
- _thunar_return_if_fail (error != NULL);
- _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
-
- param_values = thunar_simple_job_get_param_values (THUNAR_SIMPLE_JOB (job));
- file = g_value_get_object (&g_array_index (param_values, GValue, 0));
-
- /* display an error message */
- thunar_dialogs_show_error (GTK_WIDGET (standard_view), error,
- _("Failed to rename \"%s\""),
- thunar_file_get_display_name (file));
-}
-
-
-
-static void
-thunar_standard_view_rename_finished (ExoJob *job,
- ThunarStandardView *standard_view)
-{
- GArray *param_values;
- ThunarFile *file;
-
- _thunar_return_if_fail (EXO_IS_JOB (job));
- _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
-
- param_values = thunar_simple_job_get_param_values (THUNAR_SIMPLE_JOB (job));
- file = g_value_get_object (&g_array_index (param_values, GValue, 0));
-
- /* make sure the file is still visible */
- thunar_view_scroll_to_file (THUNAR_VIEW (standard_view), file, TRUE, FALSE, 0.0f, 0.0f);
-
- /* update the selection, so we get updated actions, statusbar,
- * etc. with the new file name and probably new mime type.
- */
- thunar_standard_view_selection_changed (standard_view);
-
- /* destroy the job */
- g_signal_handlers_disconnect_matched (job, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, standard_view);
- g_object_unref (job);
-}
-
-
-
-static void
-thunar_standard_view_action_rename (GtkAction *action,
- ThunarStandardView *standard_view)
-{
- ThunarFile *file;
- GtkWidget *window;
- ThunarJob *job;
- GdkModifierType state;
- gboolean force_bulk_renamer;
- const gchar *accel_path;
- GtkAccelKey key;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (GTK_IS_ACTION (action));
-G_GNUC_END_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
-
- /* leave if no files are selected */
- if (G_UNLIKELY (standard_view->priv->selected_files == NULL))
- return;
-
- /* open the bulk renamer also with one file selected and shift */
- force_bulk_renamer = (gtk_get_current_event_state (&state) && (state & GDK_SHIFT_MASK) != 0);
- if (G_UNLIKELY (force_bulk_renamer))
- {
- /* Check if the user defined a custom accelerator that includes the
- * shift button. If he or she has, we won't force the bulk renamer. */
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- accel_path = gtk_action_get_accel_path (action);
-G_GNUC_END_IGNORE_DEPRECATIONS
- if (accel_path != NULL
- && gtk_accel_map_lookup_entry (accel_path, &key)
- && (key.accel_mods & GDK_SHIFT_MASK) != 0)
- force_bulk_renamer = FALSE;
- }
-
- /* start renaming if we have exactly one selected file */
- if (!force_bulk_renamer
- && standard_view->priv->selected_files->next == NULL)
- {
- /* get the window */
- window = gtk_widget_get_toplevel (GTK_WIDGET (standard_view));
-
- /* get the file */
- file = THUNAR_FILE (standard_view->priv->selected_files->data);
-
- /* run the rename dialog */
- job = thunar_dialogs_show_rename_file (GTK_WINDOW (window), file);
- if (G_LIKELY (job != NULL))
- {
- g_signal_connect (job, "error", G_CALLBACK (thunar_standard_view_rename_error), standard_view);
- g_signal_connect (job, "finished", G_CALLBACK (thunar_standard_view_rename_finished), standard_view);
- }
- }
- else
- {
- /* determine the current directory of the view */
- file = thunar_navigator_get_current_directory (THUNAR_NAVIGATOR (standard_view));
-
- /* display the bulk rename dialog */
- thunar_show_renamer_dialog (GTK_WIDGET (standard_view), file, standard_view->priv->selected_files, FALSE, NULL);
- }
-}
-
-
-
-static void
-thunar_standard_view_action_restore (GtkAction *action,
- ThunarStandardView *standard_view)
-{
- ThunarApplication *application;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (GTK_IS_ACTION (action));
-G_GNUC_END_IGNORE_DEPRECATIONS
- _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
-
- /* restore the selected files */
- application = thunar_application_get ();
- thunar_application_restore_files (application, GTK_WIDGET (standard_view), standard_view->priv->selected_files,
- thunar_standard_view_new_files_closure (standard_view, NULL));
- g_object_unref (G_OBJECT (application));
-}
-
-
-
static GClosure*
thunar_standard_view_new_files_closure (ThunarStandardView *standard_view,
GtkWidget *source_view)
@@ -4512,17 +3690,7 @@ void
thunar_standard_view_selection_changed (ThunarStandardView *standard_view)
{
GtkTreeIter iter;
- ThunarFile *current_directory;
- gboolean can_paste_into_folder;
- gboolean restorable;
- gboolean trashable;
- gboolean pastable;
- gboolean writable;
- gboolean trashed;
- gboolean hide_trash_action;
- gboolean show_delete_action;
GList *lp, *selected_files;
- gint n_selected_files = 0;
_thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
@@ -4539,9 +3707,7 @@ thunar_standard_view_selection_changed (ThunarStandardView *standard_view)
/* determine the new list of selected files (replacing GtkTreePath's with ThunarFile's) */
selected_files = (*THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->get_selected_items) (standard_view);
- restorable = (selected_files != NULL);
- trashable = (selected_files != NULL);
- for (lp = selected_files; lp != NULL; lp = lp->next, ++n_selected_files)
+ for (lp = selected_files; lp != NULL; lp = lp->next)
{
/* determine the iterator for the path */
gtk_tree_model_get_iter (GTK_TREE_MODEL (standard_view->model), &iter, lp->data);
@@ -4551,133 +3717,14 @@ thunar_standard_view_selection_changed (ThunarStandardView *standard_view)
/* ...and replace it with the file */
lp->data = thunar_list_model_get_file (standard_view->model, &iter);
-
- /* enable "Restore" if we have only trashed files (atleast one file) */
- if (!thunar_file_is_trashed (lp->data))
- restorable = FALSE;
-
- /* enable "Move to Trash" if files can be trashed */
- if (!thunar_file_can_be_trashed (lp->data))
- trashable = FALSE;
}
/* and setup the new selected files list */
standard_view->priv->selected_files = selected_files;
- /* check whether the folder displayed by the view is writable/in the trash */
- current_directory = thunar_navigator_get_current_directory (THUNAR_NAVIGATOR (standard_view));
- writable = (current_directory != NULL && thunar_file_is_writable (current_directory));
- trashed = (current_directory != NULL && thunar_file_is_trashed (current_directory));
-
- /* if moving to trash is not applicable, replace it with the delete action
- * but only if the directory is writable -- keep "move to trash" otherwise */
- hide_trash_action = writable && (trashed || !trashable || !thunar_g_vfs_is_uri_scheme_supported ("trash"));
-
- g_object_get (G_OBJECT (standard_view->preferences), "misc-show-delete-action", &show_delete_action, NULL);
-
- /* check whether the clipboard contains data that can be pasted here */
- pastable = (standard_view->clipboard != NULL && thunar_clipboard_manager_get_can_paste (standard_view->clipboard));
-
- /* check whether the only selected file is
- * folder to which we can paste to */
- can_paste_into_folder = (n_selected_files == 1)
- && thunar_file_is_directory (selected_files->data)
- && thunar_file_is_writable (selected_files->data);
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- /* update the "Create Folder"/"Create Document" actions */
- gtk_action_set_sensitive (standard_view->priv->action_create_folder, !trashed && writable);
- gtk_action_set_sensitive (standard_view->priv->action_create_document, !trashed && writable);
-
- /* update the "Properties" action */
- gtk_action_set_sensitive (standard_view->priv->action_properties,
- current_directory != NULL || n_selected_files > 0);
-G_GNUC_END_IGNORE_DEPRECATIONS
-
- /* update the "Cut" action */
- g_object_set (G_OBJECT (standard_view->priv->action_cut),
- "sensitive", (n_selected_files > 0) && writable,
- "tooltip", ngettext ("Prepare the selected file to be moved with a Paste command",
- "Prepare the selected files to be moved with a Paste command",
- n_selected_files),
- NULL);
-
- /* update the "Copy" action */
- g_object_set (G_OBJECT (standard_view->priv->action_copy),
- "sensitive", (n_selected_files > 0),
- "tooltip", ngettext ("Prepare the selected file to be copied with a Paste command",
- "Prepare the selected files to be copied with a Paste command",
- n_selected_files),
- NULL);
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- /* update the "Paste" action */
- gtk_action_set_sensitive (standard_view->priv->action_paste, writable && pastable);
-G_GNUC_END_IGNORE_DEPRECATIONS
-
- /* update the "Move to Trash" action */
- g_object_set (G_OBJECT (standard_view->priv->action_move_to_trash),
- "sensitive", (n_selected_files > 0) && writable,
- "visible", !hide_trash_action,
- "tooltip", ngettext ("Move the selected file to the Trash",
- "Move the selected files to the Trash",
- n_selected_files),
- NULL);
-
- /* update the "Delete" action */
- g_object_set (G_OBJECT (standard_view->priv->action_delete),
- "sensitive", (n_selected_files > 0) && writable,
- "visible", hide_trash_action || show_delete_action,
- "tooltip", ngettext ("Permanently delete the selected file",
- "Permanently delete the selected files",
- n_selected_files),
- NULL);
-
- /* update the "Paste Into Folder" action */
- g_object_set (G_OBJECT (standard_view->priv->action_paste_into_folder),
- "sensitive", pastable,
- "visible", can_paste_into_folder,
- NULL);
-
- /* update the "Duplicate File(s)" action */
- g_object_set (G_OBJECT (standard_view->priv->action_duplicate),
- "sensitive", (n_selected_files > 0) && !restorable && writable,
- "tooltip", ngettext ("Duplicate the selected file",
- "Duplicate each selected file",
- n_selected_files),
- NULL);
-
- /* update the "Make Link(s)" action */
- g_object_set (G_OBJECT (standard_view->priv->action_make_link),
- "label", ngettext ("Ma_ke Link", "Ma_ke Links", n_selected_files),
- "sensitive", (n_selected_files > 0) && !restorable && writable,
- "tooltip", ngettext ("Create a symbolic link for the selected file",
- "Create a symbolic link for each selected file",
- n_selected_files),
- NULL);
-
- /* update the "Rename" action */
- g_object_set (G_OBJECT (standard_view->priv->action_rename),
- "sensitive", (n_selected_files > 0 && !restorable && writable),
- "tooltip", ngettext ("Rename the selected file",
- "Rename the selected files",
- n_selected_files),
- NULL);
-
- /* update the "Restore" action */
- g_object_set (G_OBJECT (standard_view->priv->action_restore),
- "sensitive", (n_selected_files > 0 && restorable),
- "tooltip", ngettext ("Restore the selected file",
- "Restore the selected files",
- n_selected_files),
- NULL);
-
/* update the statusbar text */
thunar_standard_view_update_statusbar_text (standard_view);
- /* merge the custom actions */
- thunar_standard_view_merge_custom_actions (standard_view);
-
/* emit notification for "selected-files" */
g_object_notify_by_pspec (G_OBJECT (standard_view), standard_view_props[PROP_SELECTED_FILES]);
}
diff --git a/thunar/thunar-standard-view.h b/thunar/thunar-standard-view.h
index 3d2ee4e6..df67dcc8 100644
--- a/thunar/thunar-standard-view.h
+++ b/thunar/thunar-standard-view.h
@@ -125,7 +125,6 @@ struct _ThunarStandardView
ThunarPreferences *preferences;
- ThunarClipboardManager *clipboard;
ThunarListModel *model;
GtkActionGroup *action_group;