summaryrefslogtreecommitdiff
path: root/0001-fix-crash-when-using-shortcut-for-select-all-after-s.patch
blob: ad527508cd6aaf420105aa5c7d6390f95c728f7d (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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
From 4fdfd08211392d8551ab1dd5f12353cf22077217 Mon Sep 17 00:00:00 2001
From: Alexander Schwinn <alexxcons@xfce.org>
Date: Mon, 27 Apr 2020 10:52:40 +0200
Subject: [PATCH] fix crash when using shortcut for "select all" after
 switching views

---
 thunar/thunar-standard-view.c | 57 +++++------------------------------
 thunar/thunar-standard-view.h | 15 ++-------
 thunar/thunar-window.c        | 44 +++++++++++++++++++++++++--
 thunar/thunar-window.h        |  3 ++
 4 files changed, 54 insertions(+), 65 deletions(-)

diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index fd2f2090..29061a39 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -160,9 +160,6 @@ static void                 thunar_standard_view_current_directory_changed  (Thu
 static GList               *thunar_standard_view_get_selected_files_view    (ThunarView               *view);
 static void                 thunar_standard_view_set_selected_files_view    (ThunarView               *view,
                                                                              GList                    *selected_files);
-static void                 thunar_standard_view_select_all_files           (ThunarView               *view);
-static void                 thunar_standard_view_select_by_pattern          (ThunarView               *view);
-static void                 thunar_standard_view_selection_invert           (ThunarView               *view);
 static GClosure            *thunar_standard_view_new_files_closure          (ThunarStandardView       *standard_view,
                                                                              GtkWidget                *source_view);
 static void                 thunar_standard_view_new_files                  (ThunarStandardView       *standard_view,
@@ -333,15 +330,6 @@ struct _ThunarStandardViewPrivate
   GtkTreePath            *selection_before_delete;
 };
 
-static XfceGtkActionEntry thunar_standard_view_action_entries[] =
-{
-    { THUNAR_STANDARD_VIEW_ACTION_SELECT_ALL_FILES,  "<Actions>/ThunarStandardView/select-all-files",   "<Primary>a", XFCE_GTK_MENU_ITEM, N_ ("Select _all Files"),     N_ ("Select all files in this window"),                   NULL, G_CALLBACK (thunar_standard_view_select_all_files), },
-    { THUNAR_STANDARD_VIEW_ACTION_SELECT_BY_PATTERN, "<Actions>/ThunarStandardView/select-by-pattern",  "<Primary>s", XFCE_GTK_MENU_ITEM, N_ ("Select _by Pattern..."), N_ ("Select all files that match a certain pattern"),     NULL, G_CALLBACK (thunar_standard_view_select_by_pattern), },
-    { THUNAR_STANDARD_VIEW_ACTION_INVERT_SELECTION,  "<Actions>/ThunarStandardView/invert-selection",   "",           XFCE_GTK_MENU_ITEM, N_ ("_Invert Selection"),     N_ ("Select all files but not those currently selected"), NULL, G_CALLBACK (thunar_standard_view_selection_invert), },
-};
-
-#define get_action_entry(id) xfce_gtk_get_action_entry_by_id(thunar_standard_view_action_entries,G_N_ELEMENTS(thunar_standard_view_action_entries),id)
-
 /* Target types for dragging from the view */
 static const GtkTargetEntry drag_targets[] =
 {
@@ -391,8 +379,6 @@ thunar_standard_view_class_init (ThunarStandardViewClass *klass)
   gtkwidget_class->grab_focus = thunar_standard_view_grab_focus;
   gtkwidget_class->draw = thunar_standard_view_draw;
 
-  xfce_gtk_translate_action_entries (thunar_standard_view_action_entries, G_N_ELEMENTS (thunar_standard_view_action_entries));
-
   /**
    * ThunarStandardView:loading:
    *
@@ -1903,11 +1889,9 @@ thunar_standard_view_current_directory_changed (ThunarFile         *current_dire
 
 
 
-static void
-thunar_standard_view_select_all_files (ThunarView *view)
+void
+thunar_standard_view_select_all_files (ThunarStandardView *standard_view)
 {
-  ThunarStandardView *standard_view = THUNAR_STANDARD_VIEW (view);
-
   _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
 
   /* grab the focus to the view */
@@ -1919,10 +1903,9 @@ thunar_standard_view_select_all_files (ThunarView *view)
 
 
 
-static void
-thunar_standard_view_select_by_pattern (ThunarView *view)
+void
+thunar_standard_view_select_by_pattern (ThunarStandardView *standard_view)
 {
-  ThunarStandardView *standard_view = THUNAR_STANDARD_VIEW (view);
   GtkWidget          *window;
   GtkWidget          *dialog;
   GtkWidget          *vbox;
@@ -2016,11 +1999,9 @@ thunar_standard_view_select_by_pattern (ThunarView *view)
 
 
 
-static void
-thunar_standard_view_selection_invert (ThunarView *view)
+void
+thunar_standard_view_selection_invert (ThunarStandardView *standard_view)
 {
-  ThunarStandardView *standard_view = THUNAR_STANDARD_VIEW (view);
-
   _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
 
   /* grab the focus to the view */
@@ -3643,28 +3624,6 @@ thunar_standard_view_append_menu_items (ThunarStandardView *standard_view,
 
 
 
-/**
- * thunar_standard_view_append_menu_item:
- * @standard_view  : Instance of a  #ThunarStandardView
- * @menu           : #GtkMenuShell to which the item should be added
- * @action         : #ThunarStandardViewAction to select which item should be added
- *
- * Adds the selected, widget specific #GtkMenuItem to the passed #GtkMenuShell
- *
- * Return value: (transfer none): The added #GtkMenuItem
- **/
-void
-thunar_standard_view_append_menu_item (ThunarStandardView      *standard_view,
-                                       GtkMenu                 *menu,
-                                       ThunarStandardViewAction action)
-{
-  _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
-
-  xfce_gtk_menu_item_new_from_action_entry (get_action_entry (action), G_OBJECT (standard_view), GTK_MENU_SHELL (menu));
-}
-
-
-
 /**
  * thunar_standard_view_append_accelerators:
  * @standard_view : a #ThunarStandardView.
@@ -3679,8 +3638,6 @@ thunar_standard_view_append_accelerators (ThunarStandardView *standard_view,
 {
   _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
 
-  xfce_gtk_accel_group_append (accel_group, thunar_standard_view_action_entries, G_N_ELEMENTS (thunar_standard_view_action_entries), standard_view);
-
-  /* as well append accelerators of derived widgets */
+  /* append accelerators of derived widgets */
   (*THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->append_accelerators) (standard_view, accel_group);
 }
diff --git a/thunar/thunar-standard-view.h b/thunar/thunar-standard-view.h
index 67d20894..c95778c1 100644
--- a/thunar/thunar-standard-view.h
+++ b/thunar/thunar-standard-view.h
@@ -40,15 +40,6 @@ typedef struct _ThunarStandardView        ThunarStandardView;
 #define THUNAR_IS_STANDARD_VIEW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNAR_TYPE_STANDARD_VIEW))
 #define THUNAR_STANDARD_VIEW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNAR_TYPE_STANDARD_VIEW, ThunarStandardViewClass))
 
-/* #XfceGtkActionEntrys provided by this widget */
-typedef enum
-{
-  THUNAR_STANDARD_VIEW_ACTION_SELECT_ALL_FILES,
-  THUNAR_STANDARD_VIEW_ACTION_SELECT_BY_PATTERN,
-  THUNAR_STANDARD_VIEW_ACTION_INVERT_SELECTION,
-
-} ThunarStandardViewAction;
-
 struct _ThunarStandardViewClass
 {
   GtkScrolledWindowClass __parent__;
@@ -157,11 +148,11 @@ ThunarHistory *thunar_standard_view_copy_history        (ThunarStandardView
 void           thunar_standard_view_append_menu_items   (ThunarStandardView       *standard_view,
                                                          GtkMenu                  *menu,
                                                          GtkAccelGroup            *accel_group);
-void           thunar_standard_view_append_menu_item    (ThunarStandardView       *standard_view,
-                                                         GtkMenu                  *menu,
-                                                         ThunarStandardViewAction  action);
 void           thunar_standard_view_append_accelerators (ThunarStandardView       *standard_view,
                                                          GtkAccelGroup            *accel_group);
+void           thunar_standard_view_select_all_files    (ThunarStandardView       *standard_view);
+void           thunar_standard_view_select_by_pattern   (ThunarStandardView       *standard_view);
+void           thunar_standard_view_selection_invert    (ThunarStandardView       *standard_view);
 
 G_END_DECLS;
 
diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index 20592b82..87ebcf66 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -156,6 +156,9 @@ static void      thunar_window_action_close_tab           (ThunarWindow
                                                            GtkWidget              *menu_item);
 static void      thunar_window_action_close_window        (ThunarWindow           *window,
                                                            GtkWidget              *menu_item);
+static void      thunar_window_action_select_all_files    (ThunarWindow           *window);
+static void      thunar_window_action_select_by_pattern   (ThunarWindow           *window);
+static void      thunar_window_action_selection_invert    (ThunarWindow           *window);
 static void      thunar_window_action_preferences         (ThunarWindow           *window,
                                                            GtkWidget              *menu_item);
 static void      thunar_window_action_reload              (ThunarWindow           *window,
@@ -339,6 +342,9 @@ static XfceGtkActionEntry thunar_window_action_entries[] =
     { THUNAR_WINDOW_ACTION_CLOSE_ALL_WINDOWS,              "<Actions>/ThunarWindow/close-all-windows",               "<Primary><Shift>w",    XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Close _All Windows"),     N_ ("Close all Thunar windows"),                                                     NULL,                      G_CALLBACK (thunar_window_action_close_all_windows),  },
 
     { THUNAR_WINDOW_ACTION_EDIT_MENU,                      "<Actions>/ThunarWindow/edit-menu",                       "",                     XFCE_GTK_MENU_ITEM,       N_ ("_Edit"),                  NULL,                                                                                NULL,                      NULL,                                                 },
+    { THUNAR_WINDOW_ACTION_SELECT_ALL_FILES,               "<Actions>/ThunarStandardView/select-all-files",          "<Primary>a",           XFCE_GTK_MENU_ITEM,       N_ ("Select _all Files"),      N_ ("Select all files in this window"),                                              NULL,                      G_CALLBACK (thunar_window_action_select_all_files),   },
+    { THUNAR_WINDOW_ACTION_SELECT_BY_PATTERN,              "<Actions>/ThunarStandardView/select-by-pattern",         "<Primary>s",           XFCE_GTK_MENU_ITEM,       N_ ("Select _by Pattern..."),  N_ ("Select all files that match a certain pattern"),                                NULL,                      G_CALLBACK (thunar_window_action_select_by_pattern),  },
+    { THUNAR_WINDOW_ACTION_INVERT_SELECTION,               "<Actions>/ThunarStandardView/invert-selection",          "",                     XFCE_GTK_MENU_ITEM,       N_ ("_Invert Selection"),      N_ ("Select all files but not those currently selected"),                            NULL,                      G_CALLBACK (thunar_window_action_selection_invert),   },
     { THUNAR_WINDOW_ACTION_PREFERENCES,                    "<Actions>/ThunarWindow/preferences",                     "",                     XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Pr_eferences..."),        N_ ("Edit Thunars Preferences"),                                                     "preferences-system",      G_CALLBACK (thunar_window_action_preferences),        },
 
     { THUNAR_WINDOW_ACTION_VIEW_MENU,                      "<Actions>/ThunarWindow/view-menu",                       "",                     XFCE_GTK_MENU_ITEM,       N_ ("_View"),                  NULL,                                                                                NULL,                      NULL,                                                 },
@@ -944,9 +950,9 @@ thunar_window_create_edit_menu (ThunarWindow     *window,
   thunar_menu_add_sections (submenu, THUNAR_MENU_SECTION_CUT
                                    | THUNAR_MENU_SECTION_COPY_PASTE
                                    | THUNAR_MENU_SECTION_TRASH_DELETE);
-  thunar_standard_view_append_menu_item (THUNAR_STANDARD_VIEW (window->view), GTK_MENU (submenu), THUNAR_STANDARD_VIEW_ACTION_SELECT_ALL_FILES);
-  thunar_standard_view_append_menu_item (THUNAR_STANDARD_VIEW (window->view), GTK_MENU (submenu), THUNAR_STANDARD_VIEW_ACTION_SELECT_BY_PATTERN);
-  thunar_standard_view_append_menu_item (THUNAR_STANDARD_VIEW (window->view), GTK_MENU (submenu), THUNAR_STANDARD_VIEW_ACTION_INVERT_SELECTION);
+  xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_SELECT_ALL_FILES), G_OBJECT (window), GTK_MENU_SHELL(submenu));
+  xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_SELECT_BY_PATTERN), G_OBJECT (window), GTK_MENU_SHELL(submenu));
+  xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_INVERT_SELECTION), G_OBJECT (window), GTK_MENU_SHELL(submenu));
   xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (submenu));
   thunar_menu_add_sections (submenu, THUNAR_MENU_SECTION_DUPLICATE
                                    | THUNAR_MENU_SECTION_MAKELINK
@@ -2447,6 +2453,38 @@ thunar_window_action_close_window (ThunarWindow *window,
 
 
 
+static void
+thunar_window_action_select_all_files (ThunarWindow *window)
+{
+  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
+
+  thunar_standard_view_select_all_files (THUNAR_STANDARD_VIEW (window->view));
+
+}
+
+
+
+static void
+thunar_window_action_select_by_pattern (ThunarWindow *window)
+{
+  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
+
+  thunar_standard_view_select_by_pattern (THUNAR_STANDARD_VIEW (window->view));
+}
+
+
+
+static void
+thunar_window_action_selection_invert (ThunarWindow *window)
+{
+  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
+
+  thunar_standard_view_selection_invert (THUNAR_STANDARD_VIEW (window->view));
+
+}
+
+
+
 static void
 thunar_window_action_preferences (ThunarWindow *window,
                                   GtkWidget    *menu_item)
diff --git a/thunar/thunar-window.h b/thunar/thunar-window.h
index 5b595d6f..e2e98bac 100644
--- a/thunar/thunar-window.h
+++ b/thunar/thunar-window.h
@@ -49,6 +49,9 @@ typedef enum
   THUNAR_WINDOW_ACTION_CLOSE_WINDOW,
   THUNAR_WINDOW_ACTION_CLOSE_ALL_WINDOWS,
   THUNAR_WINDOW_ACTION_EDIT_MENU,
+  THUNAR_WINDOW_ACTION_SELECT_ALL_FILES,
+  THUNAR_WINDOW_ACTION_SELECT_BY_PATTERN,
+  THUNAR_WINDOW_ACTION_INVERT_SELECTION,
   THUNAR_WINDOW_ACTION_PREFERENCES,
   THUNAR_WINDOW_ACTION_VIEW_MENU,
   THUNAR_WINDOW_ACTION_RELOAD,
-- 
2.26.2