Updating branch refs/heads/master
         to 4832cab6f92470786cb6b38551d0021f12e245b0 (commit)
       from 251775c5c8decbba27fc5587feac405c6dad4273 (commit)

commit 4832cab6f92470786cb6b38551d0021f12e245b0
Author: Nick Schermer <n...@xfce.org>
Date:   Tue Oct 30 21:52:01 2012 +0100

    Add menu item for permanent delete.
    
    Rename the old delete action to "Move to Trash" and add
    permanent delete action. THe action still requests if
    you //really// want to, but it got a bit easier.

 thunar/thunar-standard-view-ui.xml |    4 ++
 thunar/thunar-standard-view.c      |   43 +++++++++++++++++++++++----
 thunar/thunar-tree-view.c          |   58 ++++++++++++++++++++++++++++++++---
 3 files changed, 94 insertions(+), 11 deletions(-)

diff --git a/thunar/thunar-standard-view-ui.xml 
b/thunar/thunar-standard-view-ui.xml
index 0678924..b91d60e 100644
--- a/thunar/thunar-standard-view-ui.xml
+++ b/thunar/thunar-standard-view-ui.xml
@@ -26,6 +26,8 @@
         <menuitem action="cut" />
         <menuitem action="copy" />
         <menuitem action="paste" />
+        <separator />
+        <menuitem action="move-to-trash" />
         <menuitem action="delete" />
       </placeholder>
       <placeholder name="placeholder-edit-select-actions">
@@ -54,6 +56,8 @@
       <menuitem action="cut" />
       <menuitem action="copy" />
       <menuitem action="paste-into-folder" />
+      <separator />
+      <menuitem action="move-to-trash" />
       <menuitem action="delete" />
     </placeholder>
     <placeholder name="placeholder-edit-actions">
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index 4e487df..4323a9c 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -40,6 +40,7 @@
 #include <thunar/thunar-gio-extensions.h>
 #include <thunar/thunar-gobject-extensions.h>
 #include <thunar/thunar-gtk-extensions.h>
+#include <thunar/thunar-stock.h>
 #include <thunar/thunar-icon-renderer.h>
 #include <thunar/thunar-marshal.h>
 #include <thunar/thunar-private.h>
@@ -180,7 +181,9 @@ static void                 
thunar_standard_view_action_copy                (Gtk
                                                                              
ThunarStandardView       *standard_view);
 static void                 thunar_standard_view_action_paste               
(GtkAction                *action,
                                                                              
ThunarStandardView       *standard_view);
-static void                 thunar_standard_view_action_delete              
(GtkAction                *action,
+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);
@@ -297,6 +300,7 @@ struct _ThunarStandardViewPrivate
   GtkAction              *action_cut;
   GtkAction              *action_copy;
   GtkAction              *action_paste;
+  GtkAction              *action_move_to_trash;
   GtkAction              *action_delete;
   GtkAction              *action_paste_into_folder;
   GtkAction              *action_duplicate;
@@ -380,6 +384,7 @@ static const GtkActionEntry action_entries[] =
   { "cut", GTK_STOCK_CUT, N_ ("Cu_t"), NULL, NULL, G_CALLBACK 
(thunar_standard_view_action_cut), },
   { "copy", GTK_STOCK_COPY, N_ ("_Copy"), NULL, NULL, G_CALLBACK 
(thunar_standard_view_action_copy), },
   { "paste", GTK_STOCK_PASTE, N_ ("_Paste"), NULL, N_ ("Move or copy files 
previously selected by a Cut or Copy command"), G_CALLBACK 
(thunar_standard_view_action_paste), },
+  { "move-to-trash", THUNAR_STOCK_TRASH_FULL, N_ ("Mo_ve to Tash"), NULL, 
NULL, G_CALLBACK (thunar_standard_view_action_move_to_trash), },
   { "delete", GTK_STOCK_DELETE, N_ ("_Delete"), NULL, NULL, G_CALLBACK 
(thunar_standard_view_action_delete), },
   { "paste-into-folder", GTK_STOCK_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), },
@@ -621,6 +626,7 @@ thunar_standard_view_init (ThunarStandardView 
*standard_view)
   standard_view->priv->action_cut = gtk_action_group_get_action 
(standard_view->action_group, "cut");
   standard_view->priv->action_copy = gtk_action_group_get_action 
(standard_view->action_group, "copy");
   standard_view->priv->action_paste = gtk_action_group_get_action 
(standard_view->action_group, "paste");
+  standard_view->priv->action_move_to_trash = gtk_action_group_get_action 
(standard_view->action_group, "move-to-trash");
   standard_view->priv->action_delete = gtk_action_group_get_action 
(standard_view->action_group, "delete");
   standard_view->priv->action_paste_into_folder = gtk_action_group_get_action 
(standard_view->action_group, "paste-into-folder");
   standard_view->priv->action_duplicate = gtk_action_group_get_action 
(standard_view->action_group, "duplicate");
@@ -1767,7 +1773,7 @@ thunar_standard_view_scroll_to_file (ThunarView *view,
 static gboolean
 thunar_standard_view_delete_selected_files (ThunarStandardView *standard_view)
 {
-  GtkAction       *action = GTK_ACTION (standard_view->priv->action_delete);
+  GtkAction       *action = GTK_ACTION 
(standard_view->priv->action_move_to_trash);
   const gchar     *accel_path;
   GtkAccelKey      key;
 
@@ -2374,8 +2380,8 @@ thunar_standard_view_action_paste (GtkAction          
*action,
 
 
 static void
-thunar_standard_view_action_delete (GtkAction          *action,
-                                    ThunarStandardView *standard_view)
+thunar_standard_view_action_move_to_trash (GtkAction          *action,
+                                           ThunarStandardView *standard_view)
 {
   ThunarApplication *application;
   gboolean           permanently;
@@ -2409,6 +2415,23 @@ thunar_standard_view_action_delete (GtkAction          
*action,
 
 
 static void
+thunar_standard_view_action_delete (GtkAction          *action,
+                                    ThunarStandardView *standard_view)
+{
+  ThunarApplication *application;
+
+  _thunar_return_if_fail (GTK_IS_ACTION (action));
+  _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, TRUE);
+  g_object_unref (G_OBJECT (application));
+}
+
+
+
+static void
 thunar_standard_view_action_paste_into_folder (GtkAction          *action,
                                                ThunarStandardView 
*standard_view)
 {
@@ -4057,11 +4080,19 @@ thunar_standard_view_selection_changed 
(ThunarStandardView *standard_view)
   /* update the "Paste" action */
   gtk_action_set_sensitive (standard_view->priv->action_paste, writable && 
pastable);
 
+  /* update the "Move to Trash" action */
+  g_object_set (G_OBJECT (standard_view->priv->action_move_to_trash),
+                "sensitive", (n_selected_files > 0) && writable,
+                "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,
-                "tooltip", ngettext ("Delete the selected file",
-                                     "Delete the selected files",
+                "tooltip", ngettext ("Permanently delete the selected file",
+                                     "Permanently delete the selected files",
                                      n_selected_files),
                 NULL);
 
diff --git a/thunar/thunar-tree-view.c b/thunar/thunar-tree-view.c
index 83b4d35..b652270 100644
--- a/thunar/thunar-tree-view.c
+++ b/thunar/thunar-tree-view.c
@@ -36,6 +36,7 @@
 #include <thunar/thunar-marshal.h>
 #include <thunar/thunar-preferences.h>
 #include <thunar/thunar-private.h>
+#include <thunar/thunar-stock.h>
 #include <thunar/thunar-properties-dialog.h>
 #include <thunar/thunar-shortcuts-icon-renderer.h>
 #include <thunar/thunar-simple-job.h>
@@ -146,6 +147,7 @@ static ThunarDevice            
*thunar_tree_view_get_selected_device          (T
 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);
@@ -1063,12 +1065,12 @@ thunar_tree_view_delete_selected_files (ThunarTreeView 
*view)
   /* 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. */
-  if (gtk_accel_map_lookup_entry ("<Actions>/ThunarStandardView/delete", &key)
+  if (gtk_accel_map_lookup_entry 
("<Actions>/ThunarStandardView/move-to-trash", &key)
       && (key.accel_key != 0 || key.accel_mods != 0))
     return FALSE;
 
   /* ask the user whether to delete the folder... */
-  thunar_tree_view_action_delete (view);
+  thunar_tree_view_action_move_to_trash (view);
 
   /* ...and we're done */
   return TRUE;
@@ -1117,14 +1119,14 @@ thunar_tree_view_context_menu (ThunarTreeView *view,
   gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
   
   /* append the "Open in New Tab" menu action */
-  item = gtk_image_menu_item_new_with_mnemonic (_("Open in New Tab"));
+  item = gtk_image_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_image_menu_item_new_with_mnemonic (_("Open in New Window"));
+  item = gtk_image_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));
@@ -1256,6 +1258,22 @@ thunar_tree_view_context_menu (ThunarTreeView *view,
           /* 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);
+
+          /* append the "Delete" menu action */
+          item = gtk_image_menu_item_new_with_mnemonic (_("Mo_ve to Trash"));
+          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)));
+          gtk_widget_show (item);
+
+          /* set the stock icon */
+          image = gtk_image_new_from_stock (THUNAR_STOCK_TRASH_FULL, 
GTK_ICON_SIZE_MENU);
+          gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+
           /* append the "Delete" menu action */
           item = gtk_image_menu_item_new_with_mnemonic (_("_Delete"));
           g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK 
(thunar_tree_view_action_delete), view);
@@ -1653,7 +1671,7 @@ thunar_tree_view_action_cut (ThunarTreeView *view)
 
 
 static void
-thunar_tree_view_action_delete (ThunarTreeView *view)
+thunar_tree_view_action_move_to_trash (ThunarTreeView *view)
 {
   ThunarApplication *application;
   ThunarFile        *file;
@@ -1688,6 +1706,36 @@ thunar_tree_view_action_delete (ThunarTreeView *view)
 
 
 static void
+thunar_tree_view_action_delete (ThunarTreeView *view)
+{
+  ThunarApplication *application;
+  ThunarFile        *file;
+  GList              file_list;
+
+  _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))
+    {
+      /* fake a file list */
+      file_list.data = file;
+      file_list.next = NULL;
+      file_list.prev = NULL;
+
+      /* delete the file */
+      application = thunar_application_get ();
+      thunar_application_unlink_files (application, GTK_WIDGET (view), 
&file_list, TRUE);
+      g_object_unref (G_OBJECT (application));
+
+      /* release the file */
+      g_object_unref (G_OBJECT (file));
+    }
+}
+
+
+
+static void
 thunar_tree_view_rename_error (ExoJob         *job,
                                GError         *error,
                                ThunarTreeView *view)
_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
https://mail.xfce.org/mailman/listinfo/xfce4-commits

Reply via email to