summarylogtreecommitdiffstats
path: root/uca_num_files.patch
blob: 21497fbed6b4bea6929b5a6f1257f8d0be2363b1 (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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
diff -ru Thunar-1.6.15.orig/plugins/thunar-uca/thunar-uca-editor.c Thunar-1.6.15/plugins/thunar-uca/thunar-uca-editor.c
--- Thunar-1.6.15.orig/plugins/thunar-uca/thunar-uca-editor.c	2018-04-27 18:34:10.000000000 -0400
+++ Thunar-1.6.15/plugins/thunar-uca/thunar-uca-editor.c	2018-04-27 18:34:19.000000000 -0400
@@ -63,6 +63,8 @@
   GtkWidget   *sn_button;
   GtkWidget   *parameter_entry;
   GtkWidget   *patterns_entry;
+  GtkWidget   *upper_button;
+  GtkWidget   *lower_button;
   GtkWidget   *directories_button;
   GtkWidget   *audio_files_button;
   GtkWidget   *image_files_button;
@@ -102,6 +104,8 @@
   GtkWidget      *table;
   GtkWidget      *hbox;
   GtkWidget      *vbox;
+  GtkWidget	 *spin;
+  GtkAdjustment  *adj;
 
   /* configure the dialog properties */
   gtk_dialog_add_button (GTK_DIALOG (uca_editor), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
@@ -381,6 +385,25 @@
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), uca_editor->patterns_entry);
   gtk_widget_show (uca_editor->patterns_entry);
 
+  /* widgets for setting the upper and lower bounds */
+  label = gtk_label_new ("Minimum number of files:");
+  gtk_widget_show (label);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+  adj = (GtkAdjustment *) gtk_adjustment_new (-1.0, -1.0, 9999.0, 1.0, 1.0, 0.0);
+  spin = gtk_spin_button_new (adj, 1.0, 0);
+  gtk_widget_show (spin);
+  gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+  uca_editor->lower_button = spin;
+  
+  label = gtk_label_new ("Maximum number of files:");
+  gtk_widget_show (label);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+  adj = (GtkAdjustment *) gtk_adjustment_new (-1.0, -1.0, 9999.0, 1.0, 1.0, 0.0);
+  spin = gtk_spin_button_new (adj, 1.0, 0);
+  gtk_widget_show (spin);
+  gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+  uca_editor->upper_button = spin;
+
   /* set Atk label relation for the entry */
   object = gtk_widget_get_accessible (uca_editor->patterns_entry);
   relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label));
@@ -389,15 +412,15 @@
   g_object_unref (G_OBJECT (relation));
 
   align = g_object_new (GTK_TYPE_ALIGNMENT, "height-request", 0, NULL);
-  gtk_table_attach (GTK_TABLE (table), align, 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+  gtk_table_attach (GTK_TABLE (table), align, 0, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
   gtk_widget_show (align);
 
   label = g_object_new (GTK_TYPE_LABEL, "label", _("Appears if selection contains:"), "xalign", 0.0f, NULL);
-  gtk_table_attach (GTK_TABLE (table), label, 0, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
   gtk_widget_show (label);
 
   align = g_object_new (GTK_TYPE_ALIGNMENT, "left-padding", 18, NULL);
-  gtk_table_attach (GTK_TABLE (table), align, 0, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+  gtk_table_attach (GTK_TABLE (table), align, 0, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
   gtk_widget_show (align);
 
   itable = gtk_table_new (3, 2, TRUE);
@@ -431,11 +454,11 @@
   gtk_widget_show (uca_editor->other_files_button);
 
   align = g_object_new (GTK_TYPE_ALIGNMENT, "height-request", 12, NULL);
-  gtk_table_attach (GTK_TABLE (table), align, 0, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+  gtk_table_attach (GTK_TABLE (table), align, 0, 2, 6, 7, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
   gtk_widget_show (align);
 
   hbox = gtk_hbox_new (FALSE, 6);
-  gtk_table_attach (GTK_TABLE (table), hbox, 0, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+  gtk_table_attach (GTK_TABLE (table), hbox, 0, 2, 7, 8, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
   gtk_widget_show (hbox);
 
   image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DND);
@@ -746,6 +769,8 @@
 {
   ThunarUcaTypes types;
   gchar         *description;
+  gchar		*upper;
+  gchar		*lower;
   gchar         *patterns;
   gchar         *command;
   gchar         *icon_name;
@@ -759,6 +784,8 @@
   /* determine the current values from the model */
   gtk_tree_model_get (GTK_TREE_MODEL (uca_model), iter,
                       THUNAR_UCA_MODEL_COLUMN_DESCRIPTION, &description,
+		      THUNAR_UCA_MODEL_COLUMN_UPPER, &upper,
+		      THUNAR_UCA_MODEL_COLUMN_LOWER, &lower,
                       THUNAR_UCA_MODEL_COLUMN_PATTERNS, &patterns,
                       THUNAR_UCA_MODEL_COLUMN_COMMAND, &command,
                       THUNAR_UCA_MODEL_COLUMN_TYPES, &types,
@@ -778,10 +805,14 @@
   gtk_entry_set_text (GTK_ENTRY (uca_editor->patterns_entry), (patterns != NULL) ? patterns : "");
   gtk_entry_set_text (GTK_ENTRY (uca_editor->command_entry), (command != NULL) ? command : "");
   gtk_entry_set_text (GTK_ENTRY (uca_editor->name_entry), (name != NULL) ? name : "");
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (uca_editor->upper_button), (upper != NULL) ? g_strtod (upper, NULL) : -1.0);
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (uca_editor->lower_button), (lower != NULL) ? g_strtod (lower, NULL) : -1.0);
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (uca_editor->sn_button), startup_notify);
 
   /* cleanup */
   g_free (description);
+  g_free (upper);
+  g_free (lower);
   g_free (patterns);
   g_free (command);
   g_free (icon_name);
@@ -804,10 +835,16 @@
                         ThunarUcaModel  *uca_model,
                         GtkTreeIter     *iter)
 {
+  gchar    *upper_string;
+  gchar    *lower_string;
+
   g_return_if_fail (THUNAR_UCA_IS_EDITOR (uca_editor));
   g_return_if_fail (THUNAR_UCA_IS_MODEL (uca_model));
   g_return_if_fail (iter != NULL);
 
+  upper_string = g_strdup_printf ("%d", gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (uca_editor->upper_button)));
+  lower_string = g_strdup_printf ("%d", gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (uca_editor->lower_button)));
+
   thunar_uca_model_update (uca_model, iter,
                            gtk_entry_get_text (GTK_ENTRY (uca_editor->name_entry)),
                            NULL, /* don't touch the unique id */
@@ -816,6 +853,8 @@
                            gtk_entry_get_text (GTK_ENTRY (uca_editor->command_entry)),
                            gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (uca_editor->sn_button)),
                            gtk_entry_get_text (GTK_ENTRY (uca_editor->patterns_entry)),
+			   upper_string,
+			   lower_string,
                            thunar_uca_editor_get_types (uca_editor));
 }
 
diff -ru Thunar-1.6.15.orig/plugins/thunar-uca/thunar-uca-model.c Thunar-1.6.15/plugins/thunar-uca/thunar-uca-model.c
--- Thunar-1.6.15.orig/plugins/thunar-uca/thunar-uca-model.c	2018-04-27 18:34:10.000000000 -0400
+++ Thunar-1.6.15/plugins/thunar-uca/thunar-uca-model.c	2018-04-27 18:35:36.000000000 -0400
@@ -79,6 +79,8 @@
   PARSER_COMMAND,
   PARSER_STARTUP_NOTIFY,
   PARSER_PATTERNS,
+  PARSER_UPPER,
+  PARSER_LOWER,
   PARSER_DESCRIPTION,
   PARSER_DIRECTORIES,
   PARSER_AUDIO_FILES,
@@ -169,6 +171,8 @@
   gchar         *command;
   guint          startup_notify : 1;
   gchar        **patterns;
+  gchar		*upper;
+  gchar		*lower;
   ThunarUcaTypes types;
 
   /* derived attributes */
@@ -190,6 +194,8 @@
   GString        *command;
   GString        *patterns;
   GString        *description;
+  GString	 *upper;
+  GString	 *lower;
   gboolean        startup_notify;
   gboolean        description_use;
   guint           description_match;
@@ -343,7 +349,13 @@
 
     case THUNAR_UCA_MODEL_COLUMN_PATTERNS:
       return G_TYPE_STRING;
-
+  
+    case THUNAR_UCA_MODEL_COLUMN_UPPER:
+      return G_TYPE_STRING;
+    
+    case THUNAR_UCA_MODEL_COLUMN_LOWER:
+      return G_TYPE_STRING;
+    
     case THUNAR_UCA_MODEL_COLUMN_TYPES:
       return G_TYPE_UINT;
 
@@ -452,7 +464,15 @@
       str = g_strjoinv (";", item->patterns);
       g_value_take_string (value, str);
       break;
-
+    
+    case THUNAR_UCA_MODEL_COLUMN_UPPER:
+      g_value_set_static_string (value, item->upper);
+      break;
+    
+    case THUNAR_UCA_MODEL_COLUMN_LOWER:
+      g_value_set_static_string (value, item->lower);
+      break;
+    
     case THUNAR_UCA_MODEL_COLUMN_TYPES:
       g_value_set_uint (value, item->types);
       break;
@@ -585,6 +605,8 @@
   parser.icon_name = g_string_new (NULL);
   parser.command = g_string_new (NULL);
   parser.patterns = g_string_new (NULL);
+  parser.upper = g_string_new (NULL);
+  parser.lower = g_string_new (NULL);
   parser.description = g_string_new (NULL);
   parser.startup_notify = FALSE;
   parser.unique_id_generated = FALSE;
@@ -598,6 +620,8 @@
   /* cleanup */
   g_markup_parse_context_free (context);
   g_string_free (parser.description, TRUE);
+  g_string_free (parser.upper, TRUE);
+  g_string_free (parser.lower, TRUE);
   g_string_free (parser.patterns, TRUE);
   g_string_free (parser.command, TRUE);
   g_string_free (parser.icon_name, TRUE);
@@ -622,6 +646,8 @@
 {
   /* release the previous values... */
   g_strfreev (item->patterns);
+  g_free (item->upper);
+  g_free (item->lower);
   g_free (item->description);
   g_free (item->command);
   g_free (item->name);
@@ -679,6 +705,8 @@
           g_string_truncate (parser->unique_id, 0);
           g_string_truncate (parser->command, 0);
           g_string_truncate (parser->patterns, 0);
+	  g_string_truncate (parser->upper, 0);
+	  g_string_truncate (parser->lower, 0);
           g_string_truncate (parser->description, 0);
           xfce_stack_push (parser->stack, PARSER_ACTION);
         }
@@ -736,6 +764,16 @@
           g_string_truncate (parser->patterns, 0);
           xfce_stack_push (parser->stack, PARSER_PATTERNS);
         }
+      else if (strcmp (element_name, "upper") == 0)
+        {
+          g_string_truncate (parser->upper, 0);
+          xfce_stack_push (parser->stack, PARSER_UPPER);
+        }
+      else if (strcmp (element_name, "lower") == 0)
+        {
+          g_string_truncate (parser->lower, 0);
+          xfce_stack_push (parser->stack, PARSER_LOWER);
+        }
       else if (strcmp (element_name, "description") == 0)
         {
           for (n = 0; attribute_names[n] != NULL; ++n)
@@ -850,6 +888,8 @@
                                    parser->command->str,
                                    parser->startup_notify,
                                    parser->patterns->str,
+				   parser->upper->str,
+				   parser->lower->str,
                                    parser->types);
 
           /* check if a new id should've been generated */
@@ -884,7 +924,17 @@
       if (strcmp (element_name, "patterns") != 0)
         goto unknown_element;
       break;
-
+    
+    case PARSER_UPPER:
+      if (strcmp (element_name, "upper") != 0)
+        goto unknown_element;
+      break;
+    
+    case PARSER_LOWER:
+      if (strcmp (element_name, "lower") != 0)
+        goto unknown_element;
+      break;
+    
     case PARSER_DESCRIPTION:
       if (strcmp (element_name, "description") != 0)
         goto unknown_element;
@@ -970,7 +1020,15 @@
     case PARSER_PATTERNS:
       g_string_append_len (parser->patterns, text, text_len);
       break;
-
+    
+    case PARSER_UPPER:
+      g_string_append_len (parser->upper, text, text_len);
+      break;
+   
+    case PARSER_LOWER:
+      g_string_append_len (parser->lower, text, text_len);
+      break;
+    
     case PARSER_DESCRIPTION:
       if (parser->description_use)
         g_string_append_len (parser->description, text, text_len);
@@ -1099,6 +1157,7 @@
   GList              *lp;
   gint                n_files;
   gint                i, m, n;
+  gint                upper, lower;
   gchar              *path_test;
 
   g_return_val_if_fail (THUNAR_UCA_IS_MODEL (uca_model), NULL);
@@ -1143,7 +1202,16 @@
     {
       /* check if we can just ignore this item */
       item = (ThunarUcaModelItem *) lp->data;
-      if (!item->multiple_selection && n_files > 1)
+      upper = g_strtod(item->upper, NULL);
+      lower = g_strtod(item->lower, NULL);
+      
+      if (upper == -1)
+        upper = n_files;
+      
+      if (lower == -1)
+        lower = n_files;
+      
+      if (((!item->multiple_selection) && (n_files > 1)) || (n_files > upper) || (n_files < lower))
         continue;
 
       /* match the specified files */
@@ -1319,6 +1387,8 @@
                          const gchar    *command,
                          gboolean        startup_notify,
                          const gchar    *patterns,
+			 const gchar	*upper,
+			 const gchar	*lower,
                          ThunarUcaTypes  types)
 {
   ThunarUcaModelItem *item;
@@ -1339,6 +1409,10 @@
     item->icon_name = g_strdup (icon);
   if (G_LIKELY (command != NULL && *command != '\0'))
     item->command = g_strdup (command);
+  if (G_LIKELY (upper != NULL && *upper != '\0'))
+    item->upper = g_strdup (upper);
+  if (G_LIKELY (lower != NULL && *lower != '\0'))
+    item->lower = g_strdup (lower);
   if (G_LIKELY (description != NULL && *description != '\0'))
     item->description = g_strdup (description);
   item->types = types;
@@ -1439,12 +1513,16 @@
                                          "\t<unique-id>%s</unique-id>\n"
                                          "\t<command>%s</command>\n"
                                          "\t<description>%s</description>\n"
+					 "\t<upper>%s</upper>\n"
+					 "\t<lower>%s</lower>\n"
                                          "\t<patterns>%s</patterns>\n",
                                          (item->icon_name != NULL) ? item->icon_name : "",
                                          (item->name != NULL) ? item->name : "",
                                          (item->unique_id != NULL) ? item->unique_id : "",
                                          (item->command != NULL) ? item->command : "",
                                          (item->description != NULL) ? item->description : "",
+					 (item->upper != NULL) ? item->upper : "",
+					 (item->lower != NULL) ? item->lower : "",
                                          patterns);
       fprintf (fp, "%s", escaped);
       g_free (patterns);
diff -ru Thunar-1.6.15.orig/plugins/thunar-uca/thunar-uca-model.h Thunar-1.6.15/plugins/thunar-uca/thunar-uca-model.h
--- Thunar-1.6.15.orig/plugins/thunar-uca/thunar-uca-model.h	2018-04-27 18:34:10.000000000 -0400
+++ Thunar-1.6.15/plugins/thunar-uca/thunar-uca-model.h	2018-04-27 18:34:19.000000000 -0400
@@ -44,6 +44,8 @@
   THUNAR_UCA_MODEL_COLUMN_UNIQUE_ID,
   THUNAR_UCA_MODEL_COLUMN_COMMAND,
   THUNAR_UCA_MODEL_COLUMN_STARTUP_NOTIFY,
+  THUNAR_UCA_MODEL_COLUMN_UPPER,
+  THUNAR_UCA_MODEL_COLUMN_LOWER,
   THUNAR_UCA_MODEL_COLUMN_PATTERNS,
   THUNAR_UCA_MODEL_COLUMN_TYPES,
   THUNAR_UCA_MODEL_COLUMN_STOCK_LABEL,
@@ -96,6 +98,8 @@
                                                  const gchar            *command,
                                                  gboolean                startup_notify,
                                                  const gchar            *patterns,
+						 const gchar		*upper,
+						 const gchar		*lower,
                                                  ThunarUcaTypes          types);
 
 gboolean        thunar_uca_model_save           (ThunarUcaModel         *uca_model,
diff -ru Thunar-1.6.15.orig/plugins/thunar-uca/uca.xml.in Thunar-1.6.15/plugins/thunar-uca/uca.xml.in
--- Thunar-1.6.15.orig/plugins/thunar-uca/uca.xml.in	2018-04-27 18:34:10.000000000 -0400
+++ Thunar-1.6.15/plugins/thunar-uca/uca.xml.in	2018-04-27 18:34:19.000000000 -0400
@@ -38,6 +38,8 @@
   <action>
     <icon>utilities-terminal</icon>
     <patterns>*</patterns>
+    <lower>-1</lower>
+    <upper>-1</upper>
     <_name>Open Terminal Here</_name>
     <command>exo-open --working-directory %f --launch TerminalEmulator</command>
     <_description>Example for a custom action</_description>
@@ -45,4 +47,15 @@
     <directories/>
   </action>
 
+  <action>
+    <icon>preferences-desktop-wallpaper</icon>
+    <patterns>*</patterns>
+    <lower>0</lower>
+    <upper>1</upper>
+    <_name>Set as wallpaper</_name>
+    <command>xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path --create -t string -s \"%f\"</command>
+    <_description>Implementing the entire wallpaper plugin with just a bit of XML</_description>    
+    <image-files/>
+  </action>
+
 </actions>