From 1d62ad681406bcbfffcf0b57658a5958877cb46b Mon Sep 17 00:00:00 2001 From: Alexander Schwinn <alexxcons@xfce.org> Date: Wed, 5 Aug 2020 22:47:41 +0200 Subject: [PATCH] thunar-launcher: Improve decision making on show "create file/folder" Introduced possibility to differ between: 1: nothing is selected --> use current folder 2: current folder is selected --> use selected folder (Required for tree-view support, where it is possible to select the current folder) --- thunar/thunar-launcher.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/thunar/thunar-launcher.c b/thunar/thunar-launcher.c index 776610ed4..b58564111 100644 --- a/thunar/thunar-launcher.c +++ b/thunar/thunar-launcher.c @@ -1212,6 +1212,7 @@ thunar_launcher_append_menu_item (ThunarLauncher *launcher, gboolean show_delete_item; gboolean show_item; ThunarClipboardManager *clipboard; + ThunarFile *parent; _thunar_return_val_if_fail (THUNAR_IS_LAUNCHER (launcher), NULL); _thunar_return_val_if_fail (action_entry != NULL, NULL); @@ -1357,19 +1358,27 @@ thunar_launcher_append_menu_item (ThunarLauncher *launcher, return NULL; case THUNAR_LAUNCHER_ACTION_CREATE_FOLDER: - if (thunar_file_is_trashed (launcher->current_directory)) + if (launcher->files_are_selected && launcher->single_directory_to_process) + parent = launcher->single_folder; + else + parent = launcher->current_directory; + if (thunar_file_is_trashed (parent)) return NULL; item = xfce_gtk_menu_item_new_from_action_entry (action_entry, G_OBJECT (launcher), GTK_MENU_SHELL (menu)); - gtk_widget_set_sensitive (item, thunar_file_is_writable (launcher->current_directory)); + gtk_widget_set_sensitive (item, thunar_file_is_writable (parent)); return item; case THUNAR_LAUNCHER_ACTION_CREATE_DOCUMENT: - if (thunar_file_is_trashed (launcher->current_directory)) + if (launcher->files_are_selected && launcher->single_directory_to_process) + parent = launcher->single_folder; + else + parent = launcher->current_directory; + if (thunar_file_is_trashed (parent)) return NULL; item = xfce_gtk_menu_item_new_from_action_entry (action_entry, G_OBJECT (launcher), GTK_MENU_SHELL (menu)); submenu = thunar_launcher_create_document_submenu_new (launcher); gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu); - gtk_widget_set_sensitive (item, thunar_file_is_writable (launcher->current_directory)); + gtk_widget_set_sensitive (item, thunar_file_is_writable (parent)); return item; case THUNAR_LAUNCHER_ACTION_CUT: @@ -2143,7 +2152,10 @@ thunar_launcher_action_create_folder (ThunarLauncher *launcher) 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); + if (launcher->files_are_selected && launcher->single_directory_to_process) + path_list.data = g_file_resolve_relative_path (thunar_file_get_file (launcher->single_folder), name); + else + 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 */ @@ -2206,7 +2218,10 @@ thunar_launcher_action_create_document (ThunarLauncher *launcher, if (G_LIKELY (launcher->parent_folder != NULL)) { /* fake the target path list */ - target_path_list.data = g_file_get_child (thunar_file_get_file (launcher->current_directory), name); + if (launcher->files_are_selected && launcher->single_directory_to_process) + target_path_list.data = g_file_get_child (thunar_file_get_file (launcher->single_folder), name); + else + target_path_list.data = g_file_get_child (thunar_file_get_file (launcher->current_directory), name); target_path_list.next = NULL; target_path_list.prev = NULL; -- GitLab