summarylogtreecommitdiffstats
path: root/notrash.patch
blob: 3e6260a72519c1ad173c8dcdf7f96c288635fedd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
diff -rudp thunar-4.16.10.orig/thunar/thunar-application.c thunar-4.16.10/thunar/thunar-application.c
--- thunar-4.16.10.orig/thunar/thunar-application.c	2021-10-15 22:57:55.000000000 -0400
+++ thunar-4.16.10/thunar/thunar-application.c	2021-10-15 23:01:06.000000000 -0400
@@ -2146,9 +2146,16 @@ thunar_application_unlink_files (ThunarA
   gchar     *message;
   guint      n_path_list = 0;
   gint       response;
+  gboolean   isTrashEnabled;
 
   _thunar_return_if_fail (parent == NULL || GDK_IS_SCREEN (parent) || GTK_IS_WIDGET (parent));
   _thunar_return_if_fail (THUNAR_IS_APPLICATION (application));
+  
+  g_object_get (G_OBJECT (application->preferences), "misc-enable-trash", &isTrashEnabled, NULL);
+  if (!isTrashEnabled) 
+    {
+      permanently = TRUE;
+    }
 
   /* determine the paths for the files */
   for (lp = g_list_last (file_list); lp != NULL; lp = lp->prev, ++n_path_list)
@@ -2170,8 +2177,8 @@ thunar_application_unlink_files (ThunarA
   if (G_UNLIKELY (permanently))
     {
       /* parse the parent pointer */
-      screen = thunar_util_parse_parent (parent, &window);
-
+      screen = thunar_util_parse_parent (parent, &window);     
+       
       /* generate the question to confirm the delete operation */
       if (G_LIKELY (n_path_list == 1))
         {
diff -rudp thunar-4.16.10.orig/thunar/thunar-preferences.c thunar-4.16.10/thunar/thunar-preferences.c
--- thunar-4.16.10.orig/thunar/thunar-preferences.c	2021-10-15 22:57:55.000000000 -0400
+++ thunar-4.16.10/thunar/thunar-preferences.c	2021-10-15 23:06:04.000000000 -0400
@@ -78,6 +78,7 @@ enum
   PROP_MISC_CASE_SENSITIVE,
   PROP_MISC_DATE_STYLE,
   PROP_MISC_DATE_CUSTOM_STYLE,
+  PROP_MISC_ENABLE_TRASH,
   PROP_EXEC_SHELL_SCRIPTS_BY_DEFAULT,
   PROP_MISC_FOLDERS_FIRST,
   PROP_MISC_FULL_PATH_IN_TITLE,
@@ -870,6 +871,18 @@ thunar_preferences_class_init (ThunarPre
                          THUNAR_ICON_SIZE_16,
                          EXO_PARAM_READWRITE);
 
+  /**
+   * ThunarPreferences:misc-enable-trash:
+   *
+   * If trash is disabled, files will be deleted permanently.
+   **/
+  preferences_props[PROP_MISC_ENABLE_TRASH] =
+      g_param_spec_boolean ("misc-enable-trash",
+                            "misc-enable-trash",
+                            NULL,
+                            TRUE,
+                            EXO_PARAM_READWRITE);
+
   /* install all properties */
   g_object_class_install_properties (gobject_class, N_PROPERTIES, preferences_props);
 }
diff -rudp thunar-4.16.10.orig/thunar/thunar-preferences-dialog.c thunar-4.16.10/thunar/thunar-preferences-dialog.c
--- thunar-4.16.10.orig/thunar/thunar-preferences-dialog.c	2021-10-15 22:57:55.000000000 -0400
+++ thunar-4.16.10/thunar/thunar-preferences-dialog.c	2021-10-15 23:19:19.000000000 -0400
@@ -856,6 +856,12 @@ thunar_preferences_dialog_init (ThunarPr
   thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), combo);
   gtk_widget_show (combo);
 
+  button = gtk_check_button_new_with_mnemonic (_("Move items to Trash on _deletion."));
+  exo_mutual_binding_new (G_OBJECT (dialog->preferences), "misc-enable-trash", G_OBJECT (button), "active");
+  gtk_widget_set_tooltip_text (button, _( "By default, items are sent to the Trash on deletion. By disabling this option, items will be removed on deletion and will be lost forever. (DANGEROUS)"));
+  gtk_grid_attach (GTK_GRID (grid), button, 0, 2, 1, 1);
+  gtk_widget_show (button);
+
   frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
   gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
   gtk_widget_show (frame);
diff -rudp thunar-4.16.10.orig/thunar/thunar-shortcuts-model.c thunar-4.16.10/thunar/thunar-shortcuts-model.c
--- thunar-4.16.10.orig/thunar/thunar-shortcuts-model.c	2021-10-15 22:57:55.000000000 -0400
+++ thunar-4.16.10/thunar/thunar-shortcuts-model.c	2021-10-15 23:01:06.000000000 -0400
@@ -1068,6 +1068,8 @@ thunar_shortcuts_model_shortcut_places (
   GFile          *desktop;
   GFile          *trash;
   ThunarFile     *file;
+  gboolean	  isTrashEnabled;
+  ThunarPreferences *preferences;
 
   /* add the places heading */
   shortcut = g_slice_new0 (ThunarShortcut);
@@ -1110,9 +1112,13 @@ thunar_shortcuts_model_shortcut_places (
     }
   g_object_unref (desktop);
   g_object_unref (home);
+  
+  preferences = thunar_preferences_get();
+  g_object_get (G_OBJECT (preferences), "misc-enable-trash", &isTrashEnabled, NULL);
+  g_object_unref(preferences);
 
   /* append the trash icon if the trash is supported */
-  if (thunar_g_vfs_is_uri_scheme_supported ("trash"))
+  if (isTrashEnabled && thunar_g_vfs_is_uri_scheme_supported ("trash"))
     {
       trash = thunar_g_file_new_for_trash ();
       file = thunar_file_get (trash, NULL);
diff -rudp thunar-4.16.10.orig/thunar/thunar-tree-model.c thunar-4.16.10/thunar/thunar-tree-model.c
--- thunar-4.16.10.orig/thunar/thunar-tree-model.c	2021-10-15 22:57:55.000000000 -0400
+++ thunar-4.16.10/thunar/thunar-tree-model.c	2021-10-15 23:01:06.000000000 -0400
@@ -288,12 +288,18 @@ thunar_tree_model_init (ThunarTreeModel
   GList               *devices;
   GList               *lp;
   GNode               *node;
-
+  ThunarPreferences   *preferences;
+  gboolean            isTrashEnabled;
+  
   /* generate a unique stamp if we're in debug mode */
 #ifndef NDEBUG
   model->stamp = g_random_int ();
 #endif
 
+  preferences = thunar_preferences_get();
+  g_object_get (G_OBJECT (preferences), "misc-enable-trash", &isTrashEnabled, NULL);
+  g_object_unref(preferences);
+
   /* initialize the model data */
   model->sort_case_sensitive = TRUE;
   model->visible_func = (ThunarTreeModelVisibleFunc) (void (*)(void)) exo_noop_true;
@@ -327,7 +333,7 @@ thunar_tree_model_init (ThunarTreeModel
   system_paths = g_list_append (system_paths, g_object_ref (home));
 
   /* append the trash icon if the trash is supported */
-  if (thunar_g_vfs_is_uri_scheme_supported ("trash"))
+  if (isTrashEnabled && thunar_g_vfs_is_uri_scheme_supported ("trash"))
     system_paths = g_list_append (system_paths, thunar_g_file_new_for_trash ());
 
   /* append the root file system */