summaryrefslogtreecommitdiff
path: root/thunar
diff options
context:
space:
mode:
authorAlexander Schwinn <alexxcons@xfce.org>2020-05-26 01:29:09 +0200
committerAlexander Schwinn <alexxcons@xfce.org>2020-06-08 09:49:17 +0200
commitbf92f7f5080cfe90f92f1edc53062f4ac6221805 (patch)
tree4c03f2bd437b1b2430f1e288cb21d940d1931717 /thunar
parent9326856ced8f356255b8e8f29d9bfbb4e7466a2e (diff)
downloadthunar-bf92f7f5080cfe90f92f1edc53062f4ac6221805.tar.gz
re-introduce "paste into folder", simplify related code (Issue #293)
Diffstat (limited to 'thunar')
-rw-r--r--thunar/thunar-launcher.c99
-rw-r--r--thunar/thunar-launcher.h2
-rw-r--r--thunar/thunar-location-buttons.c2
-rw-r--r--thunar/thunar-menu.c7
-rw-r--r--thunar/thunar-menu.h5
-rw-r--r--thunar/thunar-renamer-dialog.c2
-rw-r--r--thunar/thunar-standard-view.c2
7 files changed, 52 insertions, 67 deletions
diff --git a/thunar/thunar-launcher.c b/thunar/thunar-launcher.c
index c6e539fe..88e6011d 100644
--- a/thunar/thunar-launcher.c
+++ b/thunar/thunar-launcher.c
@@ -138,6 +138,7 @@ static void thunar_launcher_action_trash_delete (Thuna
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 (ThunarLauncher *launcher);
static void thunar_launcher_action_paste_into_folder (ThunarLauncher *launcher);
static void thunar_launcher_sendto_device (ThunarLauncher *launcher,
ThunarDevice *device);
@@ -151,9 +152,8 @@ static void thunar_launcher_action_create_folder (Thuna
static void thunar_launcher_action_create_document (ThunarLauncher *launcher,
GtkWidget *menu_item);
static GtkWidget *thunar_launcher_create_document_submenu_new(ThunarLauncher *launcher);
-static GtkWidget *thunar_launcher_append_paste_item (ThunarLauncher *launcher,
- GtkMenuShell *menu,
- gboolean force);
+
+
struct _ThunarLauncherClass
{
@@ -228,8 +228,8 @@ static XfceGtkActionEntry thunar_launcher_action_entries[] =
{ THUNAR_LAUNCHER_ACTION_DELETE, "<Actions>/ThunarLauncher/delete-3", "<Shift>KP_Delete", XFCE_GTK_IMAGE_MENU_ITEM, NULL, NULL, NULL, 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", "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_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), },
+ { THUNAR_LAUNCHER_ACTION_PASTE_INTO_FOLDER,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), },
};
@@ -1181,51 +1181,6 @@ 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
@@ -1249,6 +1204,7 @@ thunar_launcher_append_menu_item (ThunarLauncher *launcher,
const XfceGtkActionEntry *action_entry = get_action_entry (action);
gboolean show_delete_item;
gboolean can_be_used;
+ ThunarClipboardManager *clipboard;
_thunar_return_val_if_fail (THUNAR_IS_LAUNCHER (launcher), NULL);
_thunar_return_val_if_fail (action_entry != NULL, NULL);
@@ -1431,8 +1387,23 @@ thunar_launcher_append_menu_item (ThunarLauncher *launcher,
gtk_widget_set_sensitive (item, can_be_used);
return item;
+ case THUNAR_LAUNCHER_ACTION_PASTE_INTO_FOLDER:
+ if (!launcher->single_folder_selected)
+ return NULL;
+ clipboard = thunar_clipboard_manager_get_for_display (gtk_widget_get_display (launcher->widget));
+ 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));
+ g_object_unref (clipboard);
+ return item;
+
case THUNAR_LAUNCHER_ACTION_PASTE:
- return thunar_launcher_append_paste_item (launcher, menu, FALSE);
+ if (launcher->single_folder_selected && !launcher->current_directory_selected)
+ return thunar_launcher_append_menu_item (launcher, menu, THUNAR_LAUNCHER_ACTION_PASTE_INTO_FOLDER, force);
+ clipboard = thunar_clipboard_manager_get_for_display (gtk_widget_get_display (launcher->widget));
+ 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;
default:
return xfce_gtk_menu_item_new_from_action_entry (action_entry, G_OBJECT (launcher), GTK_MENU_SHELL (menu));
@@ -2443,23 +2414,31 @@ thunar_launcher_action_copy (ThunarLauncher *launcher)
static void
+thunar_launcher_action_paste (ThunarLauncher *launcher)
+{
+ ThunarClipboardManager *clipboard;
+
+ _thunar_return_if_fail (THUNAR_IS_LAUNCHER (launcher));
+
+ clipboard = thunar_clipboard_manager_get_for_display (gtk_widget_get_display (launcher->widget));
+ thunar_clipboard_manager_paste_files (clipboard, thunar_file_get_file (launcher->current_directory), launcher->widget, launcher->select_files_closure);
+ 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 */
+ if (!launcher->single_folder_selected)
+ return;
- /* 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);
+ thunar_clipboard_manager_paste_files (clipboard, thunar_file_get_file (launcher->single_folder), launcher->widget, launcher->select_files_closure);
g_object_unref (G_OBJECT (clipboard));
}
diff --git a/thunar/thunar-launcher.h b/thunar/thunar-launcher.h
index 10820d05..c33a3ae6 100644
--- a/thunar/thunar-launcher.h
+++ b/thunar/thunar-launcher.h
@@ -58,7 +58,7 @@ typedef enum
THUNAR_LAUNCHER_ACTION_DELETE,
THUNAR_LAUNCHER_ACTION_TRASH_DELETE,
THUNAR_LAUNCHER_ACTION_PASTE,
- THUNAR_LAUNCHER_ACTION_PASTE_ALT,
+ THUNAR_LAUNCHER_ACTION_PASTE_INTO_FOLDER,
THUNAR_LAUNCHER_ACTION_COPY,
THUNAR_LAUNCHER_ACTION_CUT,
} ThunarLauncherAction;
diff --git a/thunar/thunar-location-buttons.c b/thunar/thunar-location-buttons.c
index 305eacb6..f293b5de 100644
--- a/thunar/thunar-location-buttons.c
+++ b/thunar/thunar-location-buttons.c
@@ -1206,7 +1206,7 @@ thunar_location_buttons_context_menu (ThunarLocationButton *button,
g_object_set (G_OBJECT (buttons->launcher), "selected-files", files, NULL);
g_list_free (files);
is_current_directory = g_file_equal (thunar_file_get_file (file), thunar_file_get_file (buttons->current_directory));
- context_menu = g_object_new (THUNAR_TYPE_MENU, "menu-type", THUNAR_MENU_TYPE_CONTEXT,
+ context_menu = g_object_new (THUNAR_TYPE_MENU, "menu-type", THUNAR_MENU_TYPE_CONTEXT_LOCATION_BUTTONS,
"launcher", buttons->launcher,
"force-section-open", TRUE,
"change_directory-support-disabled", is_current_directory, NULL);
diff --git a/thunar/thunar-menu.c b/thunar/thunar-menu.c
index 4363ccc8..82569103 100644
--- a/thunar/thunar-menu.c
+++ b/thunar/thunar-menu.c
@@ -97,7 +97,7 @@ thunar_menu_class_init (ThunarMenuClass *klass)
g_param_spec_int ("menu-type",
"menu-type",
"menu-type",
- 0, 1, 0, // min, max, default
+ 0, N_THUNAR_MENU_TYPE - 1, 0, // min, max, default
G_PARAM_WRITABLE
| G_PARAM_CONSTRUCT_ONLY));
@@ -264,7 +264,10 @@ thunar_menu_add_sections (ThunarMenu *menu,
if (menu_sections & THUNAR_MENU_SECTION_COPY_PASTE)
{
item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_COPY, is_window_menu) != NULL);
- item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_PASTE, is_window_menu) != NULL);
+ if (menu->type == THUNAR_MENU_TYPE_CONTEXT_LOCATION_BUTTONS)
+ item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_PASTE_INTO_FOLDER, is_window_menu) != NULL);
+ else
+ item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_PASTE, is_window_menu) != NULL);
}
if (item_added)
xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (menu));
diff --git a/thunar/thunar-menu.h b/thunar/thunar-menu.h
index 16272592..abde379c 100644
--- a/thunar/thunar-menu.h
+++ b/thunar/thunar-menu.h
@@ -38,7 +38,10 @@ typedef struct _ThunarMenu ThunarMenu;
typedef enum
{
THUNAR_MENU_TYPE_WINDOW,
- THUNAR_MENU_TYPE_CONTEXT,
+ THUNAR_MENU_TYPE_CONTEXT_STANDARD_VIEW,
+ THUNAR_MENU_TYPE_CONTEXT_LOCATION_BUTTONS,
+ THUNAR_MENU_TYPE_CONTEXT_RENAMER,
+ N_THUNAR_MENU_TYPE,
} ThunarMenuType;
/* Bundles of #GtkMenuItems, which can be created by this widget */
diff --git a/thunar/thunar-renamer-dialog.c b/thunar/thunar-renamer-dialog.c
index 0e4fb86c..fe2f415a 100644
--- a/thunar/thunar-renamer-dialog.c
+++ b/thunar/thunar-renamer-dialog.c
@@ -890,7 +890,7 @@ thunar_renamer_dialog_context_menu (ThunarRenamerDialog *renamer_dialog)
items = thunarx_renamer_get_menu_items (renamer, GTK_WINDOW (renamer_dialog), renamer_dialog->selected_files);
}
- menu = g_object_new (THUNAR_TYPE_MENU, "menu-type", THUNAR_MENU_TYPE_CONTEXT,
+ menu = g_object_new (THUNAR_TYPE_MENU, "menu-type", THUNAR_MENU_TYPE_CONTEXT_RENAMER,
"launcher", renamer_dialog->launcher,
"tab-support-disabled", TRUE,
"change_directory-support-disabled", TRUE, NULL);
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index 75349322..b1c30ef7 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -3432,7 +3432,7 @@ thunar_standard_view_context_menu (ThunarStandardView *standard_view)
window = gtk_widget_get_toplevel (GTK_WIDGET (standard_view));
- context_menu = g_object_new (THUNAR_TYPE_MENU, "menu-type", THUNAR_MENU_TYPE_CONTEXT,
+ context_menu = g_object_new (THUNAR_TYPE_MENU, "menu-type", THUNAR_MENU_TYPE_CONTEXT_STANDARD_VIEW,
"launcher", thunar_window_get_launcher (THUNAR_WINDOW (window)), NULL);
if (selected_items != NULL)
{