From f5aa97381f4f82abef69d61b4816233f64c1c8bd Mon Sep 17 00:00:00 2001
From: Alexander Schwinn <alexxcons@xfce.org>
Date: Wed, 5 Aug 2020 22:52:41 +0200
Subject: [PATCH] Use thunar-menu and launcher in tree-view (Issue# 349)

Instead of creating a foreign menu
---
 thunar/thunar-gio-extensions.c |  34 ++
 thunar/thunar-gio-extensions.h |   2 +
 thunar/thunar-launcher.c       |  68 +--
 thunar/thunar-menu.c           |  27 +-
 thunar/thunar-menu.h           |   1 +
 thunar/thunar-tree-view.c      | 737 ++++-----------------------------
 6 files changed, 182 insertions(+), 687 deletions(-)

diff --git a/thunar/thunar-gio-extensions.c b/thunar/thunar-gio-extensions.c
index 15a548293..0544593e7 100644
--- a/thunar/thunar-gio-extensions.c
+++ b/thunar/thunar-gio-extensions.c
@@ -148,6 +148,40 @@ thunar_g_file_is_trash (GFile *file)
 
 
 
+gboolean
+thunar_g_file_is_computer (GFile *file)
+{
+  char *uri;
+  gboolean is_computer = FALSE;
+
+  _thunar_return_val_if_fail (G_IS_FILE (file), FALSE);
+
+  uri = g_file_get_uri (file);
+  is_computer = g_strcmp0 (uri, "computer:///") == 0;
+  g_free (uri);
+
+  return is_computer;
+}
+
+
+
+gboolean
+thunar_g_file_is_network (GFile *file)
+{
+  char *uri;
+  gboolean is_network = FALSE;
+
+  _thunar_return_val_if_fail (G_IS_FILE (file), FALSE);
+
+  uri = g_file_get_uri (file);
+  is_network = g_strcmp0 (uri, "network:///") == 0;
+  g_free (uri);
+
+  return is_network;
+}
+
+
+
 GKeyFile *
 thunar_g_file_query_key_file (GFile              *file,
                               GCancellable       *cancellable,
diff --git a/thunar/thunar-gio-extensions.h b/thunar/thunar-gio-extensions.h
index 439d5d568..d4fd1fea0 100644
--- a/thunar/thunar-gio-extensions.h
+++ b/thunar/thunar-gio-extensions.h
@@ -36,6 +36,8 @@ gboolean  thunar_g_file_is_root                  (GFile                *file);
 gboolean  thunar_g_file_is_trashed               (GFile                *file);
 gboolean  thunar_g_file_is_home                  (GFile                *file);
 gboolean  thunar_g_file_is_trash                 (GFile                *file);
+gboolean  thunar_g_file_is_computer              (GFile                *file);
+gboolean  thunar_g_file_is_network               (GFile                *file);
 
 GKeyFile *thunar_g_file_query_key_file           (GFile                *file,
                                                   GCancellable         *cancellable,
diff --git a/thunar/thunar-launcher.c b/thunar/thunar-launcher.c
index b58564111..90b47de37 100644
--- a/thunar/thunar-launcher.c
+++ b/thunar/thunar-launcher.c
@@ -96,6 +96,7 @@ enum
   PROP_SELECTED_FILES,
   PROP_WIDGET,
   PROP_SELECT_FILES_CLOSURE,
+  PROP_SELECTED_DEVICE,
   N_PROPERTIES
 };
 
@@ -192,6 +193,7 @@ struct _ThunarLauncher
 
   ThunarFile             *current_directory;
   GList                  *files_to_process;
+  ThunarDevice           *device_to_process;
 
   gint                    n_files_to_process;
   gint                    n_directories_to_process;
@@ -313,6 +315,17 @@ thunar_launcher_class_init (ThunarLauncherClass *klass)
                            G_PARAM_WRITABLE
                            | G_PARAM_CONSTRUCT_ONLY);
 
+  /**
+   * ThunarLauncher:select-device:
+   *
+   * The #ThunarDevice which currently is selected (or NULL if no #ThunarDevice is selected)
+   **/
+  launcher_props[PROP_SELECTED_DEVICE] =
+     g_param_spec_pointer ("selected-device",
+                           "selected-device",
+                           "selected-device",
+                           G_PARAM_WRITABLE);
+
   /* Override ThunarNavigator's properties */
   g_iface = g_type_default_interface_peek (THUNAR_TYPE_NAVIGATOR);
   launcher_props[PROP_CURRENT_DIRECTORY] =
@@ -354,6 +367,7 @@ thunar_launcher_init (ThunarLauncher *launcher)
 {
   launcher->files_to_process = NULL;
   launcher->select_files_closure = NULL;
+  launcher->device_to_process = NULL;
 
   /* grab a reference on the preferences */
   launcher->preferences = thunar_preferences_get ();
@@ -446,6 +460,10 @@ thunar_launcher_set_property (GObject      *object,
       launcher->select_files_closure = g_value_get_pointer (value);
       break;
 
+    case PROP_SELECTED_DEVICE:
+      launcher->device_to_process = g_value_get_pointer (value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -498,8 +516,13 @@ thunar_launcher_set_selected_files (ThunarComponent *component,
   ThunarLauncher *launcher = THUNAR_LAUNCHER (component);
   GList          *lp;
 
+  /* That happens at startup for some reason */
+  if (launcher->current_directory == NULL)
+    return;
+
   /* disconnect from the previous files to process */
-  thunar_g_file_list_free (launcher->files_to_process);
+  if (launcher->files_to_process != NULL)
+    thunar_g_file_list_free (launcher->files_to_process);
   launcher->files_to_process = NULL;
 
   /* notify listeners */
@@ -507,32 +530,28 @@ thunar_launcher_set_selected_files (ThunarComponent *component,
 
   /* unref previous parent, if any */
   if (launcher->parent_folder != NULL)
-    {
-      g_object_unref (launcher->parent_folder);
-      launcher->parent_folder = NULL;
-    }
+    g_object_unref (launcher->parent_folder);
+  launcher->parent_folder = NULL;
 
   launcher->files_are_selected = TRUE;
-  if ((selected_files == NULL || g_list_length (selected_files) == 0))
+  if (selected_files == NULL || g_list_length (selected_files) == 0)
     launcher->files_are_selected = FALSE;
 
+  launcher->files_to_process_trashable = TRUE;
+  launcher->n_files_to_process         = 0;
+  launcher->n_directories_to_process   = 0;
+  launcher->n_executables_to_process   = 0;
+  launcher->n_regulars_to_process      = 0;
+  launcher->single_directory_to_process = FALSE;
+  launcher->single_folder = NULL;
+  launcher->parent_folder = NULL;
+
   /* if nothing is selected, the current directory is the folder to use for all menus */
   if (launcher->files_are_selected)
     launcher->files_to_process = thunar_g_file_list_copy (selected_files);
   else
     launcher->files_to_process = g_list_append (launcher->files_to_process, launcher->current_directory);
 
-
-  launcher->files_to_process_trashable    = TRUE;
-  launcher->n_files_to_process       = 0;
-  launcher->n_directories_to_process = 0;
-  launcher->n_executables_to_process = 0;
-  launcher->n_regulars_to_process    = 0;
-
-  /* That happens at startup for some reason */
-  if (launcher->current_directory == NULL)
-    return;
-
   /* determine the number of files/directories/executables */
   for (lp = launcher->files_to_process; lp != NULL; lp = lp->next, ++launcher->n_files_to_process)
     {
@@ -557,14 +576,12 @@ thunar_launcher_set_selected_files (ThunarComponent *component,
     }
 
   launcher->single_directory_to_process = (launcher->n_directories_to_process == 1 && launcher->n_files_to_process == 1);
-  launcher->single_folder = NULL;
   if (launcher->single_directory_to_process)
     {
       /* grab the folder of the first selected item */
       launcher->single_folder = THUNAR_FILE (launcher->files_to_process->data);
     }
 
-  launcher->parent_folder = NULL;
   if (launcher->files_to_process != NULL)
     {
       /* just grab the folder of the first selected item */
@@ -1213,12 +1230,13 @@ thunar_launcher_append_menu_item (ThunarLauncher       *launcher,
   gboolean                  show_item;
   ThunarClipboardManager   *clipboard;
   ThunarFile               *parent;
+  gint                      n;
 
   _thunar_return_val_if_fail (THUNAR_IS_LAUNCHER (launcher), NULL);
   _thunar_return_val_if_fail (action_entry != NULL, NULL);
 
   /* This may occur when the thunar-window is build */
-  if (G_UNLIKELY (launcher->files_to_process == NULL))
+  if (G_UNLIKELY (launcher->files_to_process == NULL) && launcher->device_to_process == NULL)
     return NULL;
 
   switch (action)
@@ -1232,18 +1250,20 @@ thunar_launcher_append_menu_item (ThunarLauncher       *launcher,
                                            action_entry->accel_path, action_entry->callback, G_OBJECT (launcher), action_entry->menu_item_icon_name, menu);
 
       case THUNAR_LAUNCHER_ACTION_OPEN_IN_TAB:
-        label_text = g_strdup_printf (ngettext ("Open in New _Tab", "Open in %d New _Tabs", launcher->n_files_to_process), launcher->n_files_to_process);
+        n = launcher->n_files_to_process > 0 ? launcher->n_files_to_process : 1;
+        label_text = g_strdup_printf (ngettext ("Open in New _Tab", "Open in %d New _Tabs", n), n);
         tooltip_text = g_strdup_printf (ngettext ("Open the selected directory in new tab",
-                                                  "Open the selected directories in %d new tabs", launcher->n_files_to_process), launcher->n_files_to_process);
+                                                  "Open the selected directories in %d new tabs", n), n);
         item = xfce_gtk_menu_item_new (label_text, tooltip_text, action_entry->accel_path, action_entry->callback, G_OBJECT (launcher), menu);
         g_free (tooltip_text);
         g_free (label_text);
         return item;
 
       case THUNAR_LAUNCHER_ACTION_OPEN_IN_WINDOW:
-        label_text = g_strdup_printf (ngettext ("Open in New _Window", "Open in %d New _Windows", launcher->n_files_to_process), launcher->n_files_to_process);
+        n = launcher->n_files_to_process > 0 ? launcher->n_files_to_process : 1;
+        label_text = g_strdup_printf (ngettext ("Open in New _Window", "Open in %d New _Windows", n), n);
         tooltip_text = g_strdup_printf (ngettext ("Open the selected directory in new window",
-                                                  "Open the selected directories in %d new windows",launcher->n_files_to_process), launcher->n_files_to_process);
+                                                  "Open the selected directories in %d new windows",n), n);
         item = xfce_gtk_menu_item_new (label_text, tooltip_text, action_entry->accel_path, action_entry->callback, G_OBJECT (launcher), menu);
         g_free (tooltip_text);
         g_free (label_text);
diff --git a/thunar/thunar-menu.c b/thunar/thunar-menu.c
index fe40f46c7..5aa76292b 100644
--- a/thunar/thunar-menu.c
+++ b/thunar/thunar-menu.c
@@ -249,7 +249,7 @@ thunar_menu_add_sections (ThunarMenu         *menu,
 {
   GtkWidget *window;
   gboolean   item_added;
-  gboolean   is_window_menu = menu->type == THUNAR_MENU_TYPE_WINDOW;
+  gboolean   force = menu->type == THUNAR_MENU_TYPE_WINDOW || menu->type == THUNAR_MENU_TYPE_CONTEXT_TREE_VIEW;
 
   _thunar_return_val_if_fail (THUNAR_IS_MENU (menu), FALSE);
 
@@ -268,21 +268,24 @@ thunar_menu_add_sections (ThunarMenu         *menu,
   if (menu_sections & THUNAR_MENU_SECTION_CREATE_NEW_FILES)
     {
       item_added = FALSE;
-      item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_CREATE_FOLDER, is_window_menu) != NULL);
-      item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_CREATE_DOCUMENT, is_window_menu) != NULL);
+      item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_CREATE_FOLDER, force) != NULL);
+
+      /* No document creation for tree-view */
+      if (menu->type != THUNAR_MENU_TYPE_CONTEXT_TREE_VIEW)
+        item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_CREATE_DOCUMENT, force) != NULL);
       if (item_added)
          xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (menu));
     }
   item_added = FALSE;
   if (menu_sections & THUNAR_MENU_SECTION_CUT)
-    item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_CUT, is_window_menu) != NULL);
+    item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_CUT, force) != NULL);
   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_COPY, force) != 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);
+        item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_PASTE_INTO_FOLDER, force) != NULL);
       else
-        item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_PASTE, is_window_menu) != NULL);
+        item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_PASTE, force) != NULL);
     }
   if (item_added)
      xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (menu));
@@ -290,8 +293,8 @@ thunar_menu_add_sections (ThunarMenu         *menu,
   if (menu_sections & THUNAR_MENU_SECTION_TRASH_DELETE)
     {
       item_added = FALSE;
-      item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_MOVE_TO_TRASH, is_window_menu) != NULL);
-      item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_DELETE, is_window_menu) != NULL);
+      item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_MOVE_TO_TRASH, force) != NULL);
+      item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_DELETE, force) != NULL);
       if (item_added)
          xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (menu));
     }
@@ -308,11 +311,11 @@ thunar_menu_add_sections (ThunarMenu         *menu,
 
   item_added = FALSE;
   if (menu_sections & THUNAR_MENU_SECTION_DUPLICATE)
-    item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_DUPLICATE, is_window_menu) != NULL);
+    item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_DUPLICATE, force) != NULL);
   if (menu_sections & THUNAR_MENU_SECTION_MAKELINK)
-    item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_MAKE_LINK, is_window_menu) != NULL);
+    item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_MAKE_LINK, force) != NULL);
   if (menu_sections & THUNAR_MENU_SECTION_RENAME)
-    item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_RENAME, is_window_menu) != NULL);
+    item_added |= (thunar_launcher_append_menu_item (menu->launcher, GTK_MENU_SHELL (menu), THUNAR_LAUNCHER_ACTION_RENAME, force) != 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 abde379ce..d9f7b84b3 100644
--- a/thunar/thunar-menu.h
+++ b/thunar/thunar-menu.h
@@ -41,6 +41,7 @@ typedef enum
   THUNAR_MENU_TYPE_CONTEXT_STANDARD_VIEW,
   THUNAR_MENU_TYPE_CONTEXT_LOCATION_BUTTONS,
   THUNAR_MENU_TYPE_CONTEXT_RENAMER,
+  THUNAR_MENU_TYPE_CONTEXT_TREE_VIEW,
   N_THUNAR_MENU_TYPE,
 } ThunarMenuType;
 
diff --git a/thunar/thunar-tree-view.c b/thunar/thunar-tree-view.c
index 886553598..dec5c37a5 100644
--- a/thunar/thunar-tree-view.c
+++ b/thunar/thunar-tree-view.c
@@ -34,6 +34,7 @@
 #include <thunar/thunar-gtk-extensions.h>
 #include <thunar/thunar-job.h>
 #include <thunar/thunar-marshal.h>
+#include <thunar/thunar-menu.h>
 #include <thunar/thunar-preferences.h>
 #include <thunar/thunar-private.h>
 #include <thunar/thunar-properties-dialog.h>
@@ -142,15 +143,10 @@ static ThunarFile              *thunar_tree_view_get_selected_file            (T
 static ThunarDevice            *thunar_tree_view_get_selected_device          (ThunarTreeView          *view);
 static void                     thunar_tree_view_action_unlink_selected_folder(ThunarTreeView          *view,
                                                                                gboolean                 permanently);
-static void                     thunar_tree_view_action_copy                  (ThunarTreeView          *view);
-static void                     thunar_tree_view_action_create_folder         (ThunarTreeView          *view);
-static void                     thunar_tree_view_action_cut                   (ThunarTreeView          *view);
 static void                     thunar_tree_view_action_move_to_trash         (ThunarTreeView          *view);
 static void                     thunar_tree_view_action_delete                (ThunarTreeView          *view);
-static void                     thunar_tree_view_action_rename                (ThunarTreeView          *view);
 static void                     thunar_tree_view_action_eject                 (ThunarTreeView          *view);
 static void                     thunar_tree_view_action_unmount               (ThunarTreeView          *view);
-static void                     thunar_tree_view_action_empty_trash           (ThunarTreeView          *view);
 static void                     thunar_tree_view_action_mount                 (ThunarTreeView          *view);
 static void                     thunar_tree_view_mount_finish                 (ThunarDevice            *device,
                                                                                const GError            *error,
@@ -160,12 +156,6 @@ static void                     thunar_tree_view_mount                        (T
                                                                                guint                    open_in);
 static void                     thunar_tree_view_action_open                  (ThunarTreeView          *view);
 static void                     thunar_tree_view_open_selection               (ThunarTreeView          *view);
-static void                     thunar_tree_view_action_open_in_new_window    (ThunarTreeView          *view);
-static void                     thunar_tree_view_action_open_in_new_tab       (ThunarTreeView          *view);
-static void                     thunar_tree_view_open_selection_in_new_window (ThunarTreeView          *view);
-static void                     thunar_tree_view_open_selection_in_new_tab    (ThunarTreeView          *view);
-static void                     thunar_tree_view_action_paste_into_folder     (ThunarTreeView          *view);
-static void                     thunar_tree_view_action_properties            (ThunarTreeView          *view);
 static GClosure                *thunar_tree_view_new_files_closure            (ThunarTreeView          *view);
 static void                     thunar_tree_view_new_files                    (ThunarJob               *job,
                                                                                GList                   *path_list,
@@ -234,6 +224,9 @@ struct _ThunarTreeView
    */
   GtkTreePath            *select_path;
 
+  /* used to create menu items for the context menu */
+  ThunarLauncher         *launcher;
+
   /* the currently pressed mouse button, set in the
    * button-press-event handler if the associated
    * button-release-event should activate.
@@ -448,6 +441,11 @@ thunar_tree_view_init (ThunarTreeView *view)
   /* enable drop support for the tree view */
   gtk_drag_dest_set (GTK_WIDGET (view), 0, drop_targets, G_N_ELEMENTS (drop_targets),
                      GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_MOVE);
+
+  view->launcher =  g_object_new (THUNAR_TYPE_LAUNCHER, "widget", GTK_WIDGET (view), NULL);
+  g_signal_connect_swapped (G_OBJECT (view->launcher), "change-directory", G_CALLBACK (thunar_tree_view_action_open), view);
+  g_signal_connect_swapped (G_OBJECT (view->launcher), "open-new-tab", G_CALLBACK (thunar_navigator_open_new_tab), view);
+  exo_binding_new (G_OBJECT (view), "current-directory", G_OBJECT (view->launcher), "current-directory");
 }
 
 
@@ -815,10 +813,7 @@ thunar_tree_view_button_release_event (GtkWidget      *widget,
           if ((event->state & GDK_CONTROL_MASK) != 0)
             in_tab = !in_tab;
 
-          if (in_tab)
-            thunar_tree_view_action_open_in_new_tab (view);
-          else
-            thunar_tree_view_action_open_in_new_window (view);
+          thunar_launcher_open_selected_folders (view->launcher, in_tab);
 
           /* set the cursor back to the previously selected item */
           if (view->select_path != NULL)
@@ -1261,16 +1256,12 @@ thunar_tree_view_context_menu (ThunarTreeView *view,
                                GtkTreeIter    *iter)
 {
   ThunarDevice *device;
-  ThunarFile   *parent_file;
   ThunarFile   *file;
-  GtkWidget    *image;
-  GtkWidget    *menu;
+  GList        *files;
+  ThunarMenu   *context_menu;
   GtkWidget    *item;
   GtkWidget    *window;
-  GIcon        *icon;
-  GList        *providers, *lp;
-  GList        *items = NULL, *tmp;
-  gboolean      show_delete_action;
+  gboolean      file_is_available;
 
   /* verify that we're connected to the clipboard manager */
   if (G_UNLIKELY (view->clipboard == NULL))
@@ -1282,316 +1273,105 @@ thunar_tree_view_context_menu (ThunarTreeView *view,
                       THUNAR_TREE_MODEL_COLUMN_DEVICE, &device,
                       -1);
 
-  /* prepare the popup menu */
-  menu = gtk_menu_new ();
-
-  /* append the "Open" menu action */
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-  item = gtk_image_menu_item_new_with_mnemonic (_("_Open"));
-G_GNUC_END_IGNORE_DEPRECATIONS
-  g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_open), view);
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-  gtk_widget_set_sensitive (item, (file != NULL || device != NULL));
-  gtk_widget_show (item);
-
-  /* set the icon */
-  image = gtk_image_new_from_icon_name ("document-open", GTK_ICON_SIZE_MENU);
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-G_GNUC_END_IGNORE_DEPRECATIONS
-
-  /* append the "Open in New Tab" menu action */
-  item = gtk_menu_item_new_with_mnemonic (_("Open in New _Tab"));
-  g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_open_in_new_tab), view);
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-  gtk_widget_set_sensitive (item, (file != NULL || device != NULL));
-  gtk_widget_show (item);
-
-  /* append the "Open in New Window" menu action */
-  item = gtk_menu_item_new_with_mnemonic (_("Open in New _Window"));
-  g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_open_in_new_window), view);
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-  gtk_widget_set_sensitive (item, (file != NULL || device != NULL));
-  gtk_widget_show (item);
-
-  /* append a separator item */
-  item = gtk_separator_menu_item_new ();
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-  gtk_widget_show (item);
+  context_menu = g_object_new (THUNAR_TYPE_MENU, "menu-type", THUNAR_MENU_TYPE_CONTEXT_TREE_VIEW,
+                                                 "launcher", view->launcher,
+                                                 "force-section-open", TRUE, NULL);
 
-  if (G_UNLIKELY (device != NULL))
+  g_object_set (G_OBJECT (view->launcher), "selected-device", device, NULL);
+
+  file_is_available = (device == NULL || thunar_device_is_mounted (device));
+  if (file_is_available)
     {
-      if (thunar_device_get_kind (device) == THUNAR_DEVICE_KIND_VOLUME)
-        {
-          /* append the "Mount" menu action */
-          item = gtk_menu_item_new_with_mnemonic (_("_Mount"));
-          gtk_widget_set_visible (item, thunar_device_can_mount (device));
-          g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_mount), view);
-          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
-          /* append the "Unmount" menu action */
-          item = gtk_menu_item_new_with_mnemonic (_("_Unmount"));
-          gtk_widget_set_visible (item, thunar_device_can_unmount (device));
-          g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_unmount), view);
-          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+      files = g_list_append (NULL, file);
+      g_object_set (G_OBJECT (view->launcher), "selected-files", files, "current-directory", view->current_directory, NULL);
+      g_list_free (files);
 
-          /* append the "Eject" menu action */
-          item = gtk_menu_item_new_with_mnemonic (_("_Eject"));
-          g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_eject), view);
-          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-          gtk_widget_set_sensitive (item, thunar_device_can_eject (device));
-          gtk_widget_show (item);
+      if(thunar_g_file_is_trash    (thunar_file_get_file (file)) ||
+         thunar_g_file_is_computer (thunar_file_get_file (file)) ||
+         thunar_g_file_is_network  (thunar_file_get_file (file)))
+        {
+          thunar_launcher_append_menu_item (view->launcher, GTK_MENU_SHELL (context_menu), THUNAR_LAUNCHER_ACTION_OPEN, TRUE);
+          thunar_launcher_append_menu_item (view->launcher, GTK_MENU_SHELL (context_menu), THUNAR_LAUNCHER_ACTION_OPEN_IN_TAB, TRUE);
+          thunar_launcher_append_menu_item (view->launcher, GTK_MENU_SHELL (context_menu), THUNAR_LAUNCHER_ACTION_OPEN_IN_WINDOW, TRUE);
+          xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (context_menu));
+          thunar_menu_add_sections (context_menu, THUNAR_MENU_SECTION_EMPTY_TRASH);
         }
       else
         {
-          /* append the "Unmount" menu action */
-          item = gtk_menu_item_new_with_mnemonic (_("_Unmount"));
-          gtk_widget_set_sensitive (item, thunar_device_can_eject (device));
-          g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_eject), view);
-          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-          gtk_widget_show (item);
+          thunar_menu_add_sections (context_menu, THUNAR_MENU_SECTION_OPEN);
+          thunar_menu_add_sections (context_menu, THUNAR_MENU_SECTION_SENDTO
+                                                | THUNAR_MENU_SECTION_CREATE_NEW_FILES
+                                                | THUNAR_MENU_SECTION_CUT
+                                                | THUNAR_MENU_SECTION_COPY_PASTE
+                                                | THUNAR_MENU_SECTION_TRASH_DELETE
+                                                | THUNAR_MENU_SECTION_RESTORE
+                                                | THUNAR_MENU_SECTION_RENAME
+                                                | THUNAR_MENU_SECTION_CUSTOM_ACTIONS);
         }
-
-      /* append a menu separator */
-      item = gtk_separator_menu_item_new ();
-      gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-      gtk_widget_show (item);
     }
-
-  if (G_UNLIKELY (file == NULL))
+  else
     {
-      /* do nothing */
+      g_object_set (G_OBJECT (view->launcher), "selected-files", NULL, "current-directory", NULL, NULL);
+      thunar_launcher_append_menu_item (view->launcher, GTK_MENU_SHELL (context_menu), THUNAR_LAUNCHER_ACTION_OPEN, TRUE);
+      thunar_launcher_append_menu_item (view->launcher, GTK_MENU_SHELL (context_menu), THUNAR_LAUNCHER_ACTION_OPEN_IN_TAB, TRUE);
+      thunar_launcher_append_menu_item (view->launcher, GTK_MENU_SHELL (context_menu), THUNAR_LAUNCHER_ACTION_OPEN_IN_WINDOW, TRUE);
+      xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (context_menu));
     }
-  else if (G_UNLIKELY (thunar_g_file_is_trash (thunar_file_get_file (file))))
-    {
-      /* append the "Empty Trash" menu action */
-      item = gtk_menu_item_new_with_mnemonic (_("_Empty Trash"));
-      gtk_widget_set_sensitive (item, (thunar_file_get_item_count (file) > 0));
-      g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_empty_trash), view);
-      gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-      gtk_widget_show (item);
 
-      /* append a menu separator */
-      item = gtk_separator_menu_item_new ();
-      gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-      gtk_widget_show (item);
-    }
-  else
+  if (device != NULL)
     {
-      /* check if we have a non-trashed resource */
-      if (G_LIKELY (!thunar_file_is_trashed (file)))
-        {
-          /* append the "Create Folder" menu action */
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-          item = gtk_image_menu_item_new_with_mnemonic (_("Create _Folder..."));
-G_GNUC_END_IGNORE_DEPRECATIONS
-          gtk_widget_set_sensitive (item, thunar_file_is_writable (file));
-          g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_create_folder), view);
-          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-          gtk_widget_show (item);
-
-          /* set the icon */
-          icon = g_themed_icon_new ("folder-new");
-          image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-          gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-G_GNUC_END_IGNORE_DEPRECATIONS
-          g_object_unref (icon);
-
-          /* append a separator item */
-          item = gtk_separator_menu_item_new ();
-          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-          gtk_widget_show (item);
-        }
-
-      /* "Cut" and "Copy" don't make much sense for devices */
-      if (G_LIKELY (device == NULL))
-        {
-          /* determine the parent file (required to determine "Cut" sensitivity) */
-          parent_file = thunar_file_get_parent (file, NULL);
-
-          /* append the "Cut" menu action */
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-          item = gtk_image_menu_item_new_with_mnemonic (_("Cu_t"));
-G_GNUC_END_IGNORE_DEPRECATIONS
-          g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_cut), view);
-          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-          gtk_widget_set_sensitive (item, (parent_file != NULL && thunar_file_is_writable (parent_file)));
-          gtk_widget_show (item);
-
-          /* set the icon */
-          image = gtk_image_new_from_icon_name ("edit-cut", GTK_ICON_SIZE_MENU);
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-          gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-G_GNUC_END_IGNORE_DEPRECATIONS
-
-          /* append the "Copy" menu action */
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-          item = gtk_image_menu_item_new_with_mnemonic (_("_Copy"));
-G_GNUC_END_IGNORE_DEPRECATIONS
-          g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_copy), view);
-          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-          gtk_widget_set_sensitive (item, (parent_file != NULL));
-          gtk_widget_show (item);
-
-          /* set the icon */
-          image = gtk_image_new_from_icon_name ("edit-copy", GTK_ICON_SIZE_MENU);
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-          gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-G_GNUC_END_IGNORE_DEPRECATIONS
-
-          /* cleanup */
-          if (G_LIKELY (parent_file != NULL))
-            g_object_unref (G_OBJECT (parent_file));
-        }
-
-      /* append the "Paste Into Folder" menu action */
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-      item = gtk_image_menu_item_new_with_mnemonic (_("_Paste Into Folder"));
-G_GNUC_END_IGNORE_DEPRECATIONS
-      g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_paste_into_folder), view);
-      gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-      gtk_widget_set_sensitive (item, (thunar_file_is_writable (file) && thunar_clipboard_manager_get_can_paste (view->clipboard)));
-      gtk_widget_show (item);
-
-      /* set the icon */
-      image = gtk_image_new_from_icon_name ("edit-paste", GTK_ICON_SIZE_MENU);
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-      gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-G_GNUC_END_IGNORE_DEPRECATIONS
-
-
-      /* "Delete" and "Rename" don't make much sense for devices */
-      if (G_LIKELY (device == NULL))
+      if (thunar_device_get_kind (device) == THUNAR_DEVICE_KIND_VOLUME)
         {
-          g_object_get (G_OBJECT (view->preferences), "misc-show-delete-action", &show_delete_action, NULL);
-
-          /* determine the parent file (required to determine "Delete" sensitivity) */
-          parent_file = thunar_file_get_parent (file, NULL);
-
-          /* append a separator item */
-          item = gtk_separator_menu_item_new ();
-          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-          gtk_widget_show (item);
-
-          if (thunar_g_vfs_is_uri_scheme_supported ("trash"))
+          if (thunar_device_is_mounted(device) == FALSE)
             {
-              /* append the "Move to Tash" menu action */
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-              item = gtk_image_menu_item_new_with_mnemonic (_("Mo_ve to Trash"));
-G_GNUC_END_IGNORE_DEPRECATIONS
-              g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_move_to_trash), view);
-              gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-              gtk_widget_set_sensitive (item, (parent_file != NULL && thunar_file_is_writable (parent_file) && thunar_file_can_be_trashed (file)));
-              gtk_widget_show (item);
-
-              /* set the icon */
-              image = gtk_image_new_from_icon_name ("user-trash", GTK_ICON_SIZE_MENU);
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-              gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-G_GNUC_END_IGNORE_DEPRECATIONS
+              /* append the "Mount" menu action */
+              item = gtk_menu_item_new_with_mnemonic (_("_Mount"));
+              gtk_widget_set_visible (item, thunar_device_can_mount (device));
+              g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_mount), view);
+              gtk_menu_shell_append (GTK_MENU_SHELL (context_menu), item);
             }
-
-          if (!thunar_g_vfs_is_uri_scheme_supported ("trash")
-              || show_delete_action || thunar_file_is_trashed (file))
+          else
             {
-              /* append the "Delete" menu action */
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-              item = gtk_image_menu_item_new_with_mnemonic (_("_Delete"));
-G_GNUC_END_IGNORE_DEPRECATIONS
-              g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_delete), view);
-              gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-              gtk_widget_set_sensitive (item, (parent_file != NULL && thunar_file_is_writable (parent_file)));
-              gtk_widget_show (item);
-
-              /* set the icon */
-              image = gtk_image_new_from_icon_name ("edit-delete", GTK_ICON_SIZE_MENU);
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-              gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-G_GNUC_END_IGNORE_DEPRECATIONS
+              /* append the "Unmount" menu action */
+              item = gtk_menu_item_new_with_mnemonic (_("_Unmount"));
+              gtk_widget_set_visible (item, thunar_device_can_unmount (device));
+              g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_unmount), view);
+              gtk_menu_shell_append (GTK_MENU_SHELL (context_menu), item);
             }
 
-          /* cleanup */
-          if (G_LIKELY (parent_file != NULL))
-            g_object_unref (G_OBJECT (parent_file));
-
-          /* don't show the "Rename" action in the trash */
-          if (G_LIKELY (!thunar_file_is_trashed (file)))
+          /* append the "Eject" menu action */
+          item = gtk_menu_item_new_with_mnemonic (_("_Eject"));
+          g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_eject), view);
+          gtk_menu_shell_append (GTK_MENU_SHELL (context_menu), item);
+          gtk_widget_set_sensitive (item, thunar_device_can_eject (device));
+          gtk_widget_show (item);
+        }
+      else
+        {
+          if (thunar_device_is_mounted(device) == TRUE)
             {
-              /* append a separator item */
-              item = gtk_separator_menu_item_new ();
-              gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-              gtk_widget_show (item);
-
-              /* append the "Rename" menu action */
-              item = gtk_menu_item_new_with_mnemonic (_("_Rename..."));
-              g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_rename), view);
-              gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-              gtk_widget_set_sensitive (item, thunar_file_is_writable (file));
+              /* append the "Unmount" menu action */
+              item = gtk_menu_item_new_with_mnemonic (_("_Unmount"));
+              gtk_widget_set_sensitive (item, thunar_device_can_eject (device));
+              g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_eject), view);
+              gtk_menu_shell_append (GTK_MENU_SHELL (context_menu), item);
               gtk_widget_show (item);
             }
         }
 
-      /* append a separator item */
+      /* append a menu separator */
       item = gtk_separator_menu_item_new ();
-      gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+      gtk_menu_shell_append (GTK_MENU_SHELL (context_menu), item);
       gtk_widget_show (item);
-
-      /* add the providers menu for non-trashed items */
-      if (G_LIKELY (!thunar_file_is_trashed (file)))
-        {
-          /* load the menu providers from the provider factory */
-          providers = thunarx_provider_factory_list_providers (view->provider_factory, THUNARX_TYPE_MENU_PROVIDER);
-          if (G_LIKELY (providers != NULL))
-            {
-              /* determine the toplevel window we belong to */
-              window = gtk_widget_get_toplevel (GTK_WIDGET (view));
-
-              /* load the menu items offered by the menu providers */
-              for (lp = providers; lp != NULL; lp = lp->next)
-                {
-                  tmp = thunarx_menu_provider_get_folder_menu_items (lp->data, window, THUNARX_FILE_INFO (file));
-                  items = g_list_concat (items, tmp);
-                  g_object_unref (G_OBJECT (lp->data));
-                }
-              g_list_free (providers);
-
-              /* add the menu items to the menu */
-              for (lp = items; lp != NULL; lp = lp->next)
-                thunar_gtk_menu_thunarx_menu_item_new (lp->data, GTK_MENU_SHELL (menu));
-
-              /* add a separator to the end of the menu */
-              if (G_LIKELY (lp != items))
-                {
-                  /* append a menu separator */
-                  item = gtk_separator_menu_item_new ();
-                  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-                  gtk_widget_show (item);
-                }
-
-              /* cleanup */
-              g_list_free (items);
-            }
-        }
     }
 
-  /* append the "Properties" menu action */
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-  item = gtk_image_menu_item_new_with_mnemonic (_("P_roperties..."));
-G_GNUC_END_IGNORE_DEPRECATIONS
-  g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_properties), view);
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-  gtk_widget_set_sensitive (item, (file != NULL));
-  gtk_widget_show (item);
+  thunar_menu_add_sections (context_menu, THUNAR_MENU_SECTION_PROPERTIES);
 
-  /* set the icon */
-  image = gtk_image_new_from_icon_name ("document-properties", GTK_ICON_SIZE_MENU);
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-G_GNUC_END_IGNORE_DEPRECATIONS
-
-  /* run the menu (taking over the floating reference on the menu) */
-  thunar_gtk_menu_run (GTK_MENU (menu));
+  thunar_menu_hide_accel_labels (context_menu);
+  gtk_widget_show_all (GTK_WIDGET (context_menu));
+  window = gtk_widget_get_toplevel (GTK_WIDGET (view));
+  thunar_window_redirect_menu_tooltips_to_statusbar (THUNAR_WINDOW (window), GTK_MENU (context_menu));
+  thunar_gtk_menu_run (GTK_MENU (context_menu));
 
   /* cleanup */
   if (G_UNLIKELY (device != NULL))
@@ -1723,112 +1503,6 @@ thunar_tree_view_get_selected_device (ThunarTreeView *view)
 
 
 
-static void
-thunar_tree_view_action_copy (ThunarTreeView *view)
-{
-  ThunarFile *file;
-  GList       list;
-
-  _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view));
-
-  /* verify that we're connected to the clipboard */
-  if (G_UNLIKELY (view->clipboard == NULL))
-    return;
-
-  /* determine the selected file */
-  file = thunar_tree_view_get_selected_file (view);
-  if (G_LIKELY (file != NULL))
-    {
-      /* fake a file list */
-      list.data = file;
-      list.next = NULL;
-      list.prev = NULL;
-
-      /* copy the selected to the clipboard */
-      thunar_clipboard_manager_copy_files (view->clipboard, &list);
-
-      /* release the file reference */
-      g_object_unref (G_OBJECT (file));
-    }
-}
-
-
-
-static void
-thunar_tree_view_action_create_folder (ThunarTreeView *view)
-{
-  ThunarApplication *application;
-  ThunarFile        *directory;
-  GList              path_list;
-  gchar             *name;
-
-  _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view));
-
-  /* determine the selected directory */
-  directory = thunar_tree_view_get_selected_file (view);
-  if (G_UNLIKELY (directory == NULL))
-    return;
-
-  /* ask the user to enter a name for the new folder */
-  name = thunar_dialogs_show_create (GTK_WIDGET (view),
-                                     "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 (directory), name);
-      path_list.next = path_list.prev = NULL;
-
-      /* launch the operation */
-      application = thunar_application_get ();
-      thunar_application_mkdir (application, GTK_WIDGET (view), &path_list, thunar_tree_view_new_files_closure (view));
-      g_object_unref (G_OBJECT (application));
-
-      /* release the path */
-      g_object_unref (path_list.data);
-
-      /* release the file name */
-      g_free (name);
-    }
-
-  /* cleanup */
-  g_object_unref (G_OBJECT (directory));
-}
-
-
-
-static void
-thunar_tree_view_action_cut (ThunarTreeView *view)
-{
-  ThunarFile *file;
-  GList       list;
-
-  _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view));
-
-  /* verify that we're connected to the clipboard */
-  if (G_UNLIKELY (view->clipboard == NULL))
-    return;
-
-  /* determine the selected file */
-  file = thunar_tree_view_get_selected_file (view);
-  if (G_LIKELY (file != NULL))
-    {
-      /* fake a file list */
-      list.data = file;
-      list.next = NULL;
-      list.prev = NULL;
-
-      /* cut the selected to the clipboard */
-      thunar_clipboard_manager_cut_files (view->clipboard, &list);
-
-      /* release the file reference */
-      g_object_unref (G_OBJECT (file));
-    }
-}
-
-
-
 static void
 thunar_tree_view_action_unlink_selected_folder (ThunarTreeView *view,
                                                 gboolean        permanently)
@@ -1879,73 +1553,6 @@ thunar_tree_view_action_delete (ThunarTreeView *view)
 
 
 
-static void
-thunar_tree_view_rename_error (ExoJob         *job,
-                               GError         *error,
-                               ThunarTreeView *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_TREE_VIEW (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 (view), error, _("Failed to rename \"%s\""),
-                             thunar_file_get_display_name (file));
-}
-
-
-
-static void
-thunar_tree_view_rename_finished (ExoJob         *job,
-                                  ThunarTreeView *view)
-{
-  _thunar_return_if_fail (EXO_IS_JOB (job));
-  _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view));
-
-  /* destroy the job */
-  g_signal_handlers_disconnect_matched (job, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view);
-  g_object_unref (job);
-}
-
-
-
-static void
-thunar_tree_view_action_rename (ThunarTreeView *view)
-{
-  ThunarFile *file;
-  GtkWidget  *window;
-  ThunarJob  *job;
-
-  _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view));
-
-  /* determine the selected file */
-  file = thunar_tree_view_get_selected_file (view);
-  if (G_LIKELY (file != NULL))
-    {
-      /* get the toplevel window */
-      window = gtk_widget_get_toplevel (GTK_WIDGET (view));
-
-      /* 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_tree_view_rename_error), view);
-          g_signal_connect (job, "finished", G_CALLBACK (thunar_tree_view_rename_finished), view);
-        }
-
-      /* release the file */
-      g_object_unref (file);
-    }
-}
-
-
-
 static void
 thunar_tree_view_action_eject_finish (ThunarDevice *device,
                                       const GError *error,
@@ -2056,21 +1663,6 @@ thunar_tree_view_action_unmount (ThunarTreeView *view)
 
 
 
-static void
-thunar_tree_view_action_empty_trash (ThunarTreeView *view)
-{
-  ThunarApplication *application;
-
-  _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view));
-
-  /* empty the trash bin (asking the user first) */
-  application = thunar_application_get ();
-  thunar_application_empty_trash (application, GTK_WIDGET (view), NULL);
-  g_object_unref (G_OBJECT (application));
-}
-
-
-
 static void
 thunar_tree_view_action_mount (ThunarTreeView *view)
 {
@@ -2104,11 +1696,11 @@ thunar_tree_view_mount_finish (ThunarDevice *device,
           switch (data->open_in)
             {
             case OPEN_IN_WINDOW:
-              thunar_tree_view_open_selection_in_new_window (data->view);
+              thunar_launcher_open_selected_folders (data->view->launcher, FALSE);
               break;
 
             case OPEN_IN_TAB:
-              thunar_tree_view_open_selection_in_new_tab (data->view);
+              thunar_launcher_open_selected_folders (data->view->launcher, TRUE);
               break;
 
             default:
@@ -2219,163 +1811,6 @@ thunar_tree_view_open_selection (ThunarTreeView *view)
 
 
 
-static void
-thunar_tree_view_action_open_in_new_window (ThunarTreeView *view)
-{
-  ThunarFile   *file;
-  ThunarDevice *device;
-
-  _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view));
-
-  /* determine the selected device and file */
-  device = thunar_tree_view_get_selected_device (view);
-  file = thunar_tree_view_get_selected_file (view);
-
-  if (device != NULL)
-    {
-      if (thunar_device_is_mounted (device))
-        thunar_tree_view_open_selection_in_new_window (view);
-      else
-        thunar_tree_view_mount (view, TRUE, OPEN_IN_WINDOW);
-
-      g_object_unref (device);
-    }
-  else if (file != NULL)
-    {
-      thunar_tree_view_open_selection_in_new_window (view);
-      g_object_unref (file);
-    }
-}
-
-
-
-static void
-thunar_tree_view_action_open_in_new_tab (ThunarTreeView *view)
-{
-  ThunarFile   *file;
-  ThunarDevice *device;
-
-  _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view));
-
-  /* determine the selected device and file */
-  device = thunar_tree_view_get_selected_device (view);
-  file = thunar_tree_view_get_selected_file (view);
-
-  if (device != NULL)
-    {
-      if (thunar_device_is_mounted (device))
-        thunar_tree_view_open_selection_in_new_tab (view);
-      else
-        thunar_tree_view_mount (view, TRUE, OPEN_IN_TAB);
-
-      g_object_unref (device);
-    }
-  else if (file != NULL)
-    {
-      thunar_tree_view_open_selection_in_new_tab (view);
-      g_object_unref (file);
-    }
-}
-
-
-
-static void
-thunar_tree_view_open_selection_in_new_window (ThunarTreeView *view)
-{
-  ThunarApplication *application;
-  ThunarFile        *file;
-
-  _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view));
-
-  /* determine the selected file */
-  file = thunar_tree_view_get_selected_file (view);
-  if (G_LIKELY (file != NULL))
-    {
-      /* open a new window for the selected folder */
-      application = thunar_application_get ();
-      thunar_application_open_window (application, file,
-                                      gtk_widget_get_screen (GTK_WIDGET (view)), NULL, TRUE);
-      g_object_unref (application);
-      g_object_unref (file);
-    }
-}
-
-
-
-static void
-thunar_tree_view_open_selection_in_new_tab (ThunarTreeView *view)
-{
-  ThunarFile *file;
-
-  _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view));
-
-  /* determine the selected file */
-  file = thunar_tree_view_get_selected_file (view);
-  if (G_LIKELY (file != NULL))
-    {
-      /* open a new tab for the selected folder */
-      thunar_navigator_open_new_tab (THUNAR_NAVIGATOR (view), file);
-      g_object_unref (file);
-    }
-}
-
-
-
-static void
-thunar_tree_view_action_paste_into_folder (ThunarTreeView *view)
-{
-  ThunarFile *file;
-
-  _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view));
-
-  /* verify that we're connected to the clipboard */
-  if (G_UNLIKELY (view->clipboard == NULL))
-    return;
-
-  /* determine the selected folder */
-  file = thunar_tree_view_get_selected_file (view);
-  if (G_LIKELY (file != NULL))
-    {
-      /* paste the files from the clipboard to the selected folder */
-      thunar_clipboard_manager_paste_files (view->clipboard, thunar_file_get_file (file), GTK_WIDGET (view), NULL);
-
-      /* release the file reference */
-      g_object_unref (G_OBJECT (file));
-    }
-}
-
-
-
-static void
-thunar_tree_view_action_properties (ThunarTreeView *view)
-{
-  ThunarFile *file;
-  GtkWidget  *dialog;
-  GtkWidget  *toplevel;
-
-  _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view));
-
-  /* determine the selected file */
-  file = thunar_tree_view_get_selected_file (view);
-  if (G_LIKELY (file != NULL))
-    {
-      /* determine the toplevel window */
-      toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
-      if (G_LIKELY (toplevel != NULL && gtk_widget_is_toplevel (toplevel)))
-        {
-          /* popup the properties dialog */
-          dialog = thunar_properties_dialog_new (GTK_WINDOW (toplevel));
-          thunar_properties_dialog_set_file (THUNAR_PROPERTIES_DIALOG (dialog), file);
-          gtk_widget_show (dialog);
-        }
-
-      /* release the file */
-      g_object_unref (G_OBJECT (file));
-    }
-}
-
-
-
 static GClosure*
 thunar_tree_view_new_files_closure (ThunarTreeView *view)
 {
-- 
GitLab