updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / thunar-extended / uca_num_files.patch
blobb16e3bfd2a778f05d17a349461ff1974dd744cc9
1 diff -ru Thunar-1.3.0.orig/plugins/thunar-uca/thunar-uca-editor.c Thunar-1.3.0/plugins/thunar-uca/thunar-uca-editor.c
2 --- Thunar-1.3.0.orig/plugins/thunar-uca/thunar-uca-editor.c 2011-02-25 22:39:26.000000000 -0500
3 +++ Thunar-1.3.0/plugins/thunar-uca/thunar-uca-editor.c 2011-02-25 23:53:34.000000000 -0500
4 @@ -62,6 +62,8 @@
5 GtkWidget *sn_button;
6 GtkWidget *parameter_entry;
7 GtkWidget *patterns_entry;
8 + GtkWidget *upper_button;
9 + GtkWidget *lower_button;
10 GtkWidget *directories_button;
11 GtkWidget *audio_files_button;
12 GtkWidget *image_files_button;
13 @@ -101,6 +103,8 @@
14 GtkWidget *table;
15 GtkWidget *hbox;
16 GtkWidget *vbox;
17 + GtkWidget *spin;
18 + GtkAdjustment *adj;
20 /* configure the dialog properties */
21 gtk_dialog_add_button (GTK_DIALOG (uca_editor), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
22 @@ -380,6 +384,25 @@
23 gtk_label_set_mnemonic_widget (GTK_LABEL (label), uca_editor->patterns_entry);
24 gtk_widget_show (uca_editor->patterns_entry);
26 + /* widgets for setting the upper and lower bounds */
27 + label = gtk_label_new ("Minimum number of files:");
28 + gtk_widget_show (label);
29 + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
30 + adj = (GtkAdjustment *) gtk_adjustment_new (-1.0, -1.0, 9999.0, 1.0, 1.0, 0.0);
31 + spin = gtk_spin_button_new (adj, 1.0, 0);
32 + gtk_widget_show (spin);
33 + gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
34 + uca_editor->lower_button = spin;
36 + label = gtk_label_new ("Maximum number of files:");
37 + gtk_widget_show (label);
38 + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
39 + adj = (GtkAdjustment *) gtk_adjustment_new (-1.0, -1.0, 9999.0, 1.0, 1.0, 0.0);
40 + spin = gtk_spin_button_new (adj, 1.0, 0);
41 + gtk_widget_show (spin);
42 + gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
43 + uca_editor->upper_button = spin;
45 /* set Atk label relation for the entry */
46 object = gtk_widget_get_accessible (uca_editor->patterns_entry);
47 relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label));
48 @@ -388,15 +411,15 @@
49 g_object_unref (G_OBJECT (relation));
51 align = g_object_new (GTK_TYPE_ALIGNMENT, "height-request", 0, NULL);
52 - gtk_table_attach (GTK_TABLE (table), align, 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
53 + gtk_table_attach (GTK_TABLE (table), align, 0, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
54 gtk_widget_show (align);
56 label = g_object_new (GTK_TYPE_LABEL, "label", _("Appears if selection contains:"), "xalign", 0.0f, NULL);
57 - gtk_table_attach (GTK_TABLE (table), label, 0, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
58 + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
59 gtk_widget_show (label);
61 align = g_object_new (GTK_TYPE_ALIGNMENT, "left-padding", 18, NULL);
62 - gtk_table_attach (GTK_TABLE (table), align, 0, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
63 + gtk_table_attach (GTK_TABLE (table), align, 0, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
64 gtk_widget_show (align);
66 itable = gtk_table_new (3, 2, TRUE);
67 @@ -430,11 +453,11 @@
68 gtk_widget_show (uca_editor->other_files_button);
70 align = g_object_new (GTK_TYPE_ALIGNMENT, "height-request", 12, NULL);
71 - gtk_table_attach (GTK_TABLE (table), align, 0, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
72 + gtk_table_attach (GTK_TABLE (table), align, 0, 2, 6, 7, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
73 gtk_widget_show (align);
75 hbox = gtk_hbox_new (FALSE, 6);
76 - gtk_table_attach (GTK_TABLE (table), hbox, 0, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
77 + gtk_table_attach (GTK_TABLE (table), hbox, 0, 2, 7, 8, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
78 gtk_widget_show (hbox);
80 image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DND);
81 @@ -767,6 +790,8 @@
83 ThunarUcaTypes types;
84 gchar *description;
85 + gchar *upper;
86 + gchar *lower;
87 gchar *patterns;
88 gchar *command;
89 gchar *icon;
90 @@ -780,6 +805,8 @@
91 /* determine the current values from the model */
92 gtk_tree_model_get (GTK_TREE_MODEL (uca_model), iter,
93 THUNAR_UCA_MODEL_COLUMN_DESCRIPTION, &description,
94 + THUNAR_UCA_MODEL_COLUMN_UPPER, &upper,
95 + THUNAR_UCA_MODEL_COLUMN_LOWER, &lower,
96 THUNAR_UCA_MODEL_COLUMN_PATTERNS, &patterns,
97 THUNAR_UCA_MODEL_COLUMN_COMMAND, &command,
98 THUNAR_UCA_MODEL_COLUMN_TYPES, &types,
99 @@ -799,10 +826,14 @@
100 gtk_entry_set_text (GTK_ENTRY (uca_editor->patterns_entry), (patterns != NULL) ? patterns : "");
101 gtk_entry_set_text (GTK_ENTRY (uca_editor->command_entry), (command != NULL) ? command : "");
102 gtk_entry_set_text (GTK_ENTRY (uca_editor->name_entry), (name != NULL) ? name : "");
103 + gtk_spin_button_set_value (GTK_SPIN_BUTTON (uca_editor->upper_button), (upper != NULL) ? g_strtod (upper, NULL) : -1.0);
104 + gtk_spin_button_set_value (GTK_SPIN_BUTTON (uca_editor->lower_button), (lower != NULL) ? g_strtod (lower, NULL) : -1.0);
105 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (uca_editor->sn_button), startup_notify);
107 /* cleanup */
108 g_free (description);
109 + g_free (upper);
110 + g_free (lower);
111 g_free (patterns);
112 g_free (command);
113 g_free (icon);
114 @@ -825,10 +856,16 @@
115 ThunarUcaModel *uca_model,
116 GtkTreeIter *iter)
118 + gchar *upper_string;
119 + gchar *lower_string;
121 g_return_if_fail (THUNAR_UCA_IS_EDITOR (uca_editor));
122 g_return_if_fail (THUNAR_UCA_IS_MODEL (uca_model));
123 g_return_if_fail (iter != NULL);
125 + upper_string = g_strdup_printf ("%d", gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (uca_editor->upper_button)));
126 + lower_string = g_strdup_printf ("%d", gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (uca_editor->lower_button)));
128 thunar_uca_model_update (uca_model, iter,
129 gtk_entry_get_text (GTK_ENTRY (uca_editor->name_entry)),
130 gtk_entry_get_text (GTK_ENTRY (uca_editor->description_entry)),
131 @@ -836,6 +873,8 @@
132 gtk_entry_get_text (GTK_ENTRY (uca_editor->command_entry)),
133 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (uca_editor->sn_button)),
134 gtk_entry_get_text (GTK_ENTRY (uca_editor->patterns_entry)),
135 + upper_string,
136 + lower_string,
137 thunar_uca_editor_get_types (uca_editor));
140 diff -ru Thunar-1.3.0.orig/plugins/thunar-uca/thunar-uca-model.c Thunar-1.3.0/plugins/thunar-uca/thunar-uca-model.c
141 --- Thunar-1.3.0.orig/plugins/thunar-uca/thunar-uca-model.c 2011-02-25 22:39:26.000000000 -0500
142 +++ Thunar-1.3.0/plugins/thunar-uca/thunar-uca-model.c 2011-02-26 00:01:26.000000000 -0500
143 @@ -76,6 +76,8 @@
144 PARSER_COMMAND,
145 PARSER_STARTUP_NOTIFY,
146 PARSER_PATTERNS,
147 + PARSER_UPPER,
148 + PARSER_LOWER,
149 PARSER_DESCRIPTION,
150 PARSER_DIRECTORIES,
151 PARSER_AUDIO_FILES,
152 @@ -164,6 +166,8 @@
153 gchar *command;
154 guint startup_notify : 1;
155 gchar **patterns;
156 + gchar *upper;
157 + gchar *lower;
158 ThunarUcaTypes types;
160 /* derived attributes */
161 @@ -184,6 +188,8 @@
162 GString *command;
163 GString *patterns;
164 GString *description;
165 + GString *upper;
166 + GString *lower;
167 gboolean startup_notify;
168 gboolean description_use;
169 guint description_match;
170 @@ -331,7 +337,13 @@
172 case THUNAR_UCA_MODEL_COLUMN_PATTERNS:
173 return G_TYPE_STRING;
176 + case THUNAR_UCA_MODEL_COLUMN_UPPER:
177 + return G_TYPE_STRING;
179 + case THUNAR_UCA_MODEL_COLUMN_LOWER:
180 + return G_TYPE_STRING;
182 case THUNAR_UCA_MODEL_COLUMN_TYPES:
183 return G_TYPE_UINT;
185 @@ -426,7 +438,15 @@
186 str = g_strjoinv (";", item->patterns);
187 g_value_take_string (value, str);
188 break;
191 + case THUNAR_UCA_MODEL_COLUMN_UPPER:
192 + g_value_set_static_string (value, item->upper);
193 + break;
195 + case THUNAR_UCA_MODEL_COLUMN_LOWER:
196 + g_value_set_static_string (value, item->lower);
197 + break;
199 case THUNAR_UCA_MODEL_COLUMN_TYPES:
200 g_value_set_uint (value, item->types);
201 break;
202 @@ -558,6 +578,8 @@
203 parser.icon = g_string_new (NULL);
204 parser.command = g_string_new (NULL);
205 parser.patterns = g_string_new (NULL);
206 + parser.upper = g_string_new (NULL);
207 + parser.lower = g_string_new (NULL);
208 parser.description = g_string_new (NULL);
209 parser.startup_notify = FALSE;
210 xfce_stack_push (parser.stack, PARSER_START);
211 @@ -570,6 +592,8 @@
212 /* cleanup */
213 g_markup_parse_context_free (context);
214 g_string_free (parser.description, TRUE);
215 + g_string_free (parser.upper, TRUE);
216 + g_string_free (parser.lower, TRUE);
217 g_string_free (parser.patterns, TRUE);
218 g_string_free (parser.command, TRUE);
219 g_string_free (parser.icon, TRUE);
220 @@ -587,6 +611,8 @@
222 /* release the previous values... */
223 g_strfreev (item->patterns);
224 + g_free (item->upper);
225 + g_free (item->lower);
226 g_free (item->description);
227 g_free (item->command);
228 g_free (item->name);
229 @@ -638,6 +664,8 @@
230 g_string_truncate (parser->name, 0);
231 g_string_truncate (parser->command, 0);
232 g_string_truncate (parser->patterns, 0);
233 + g_string_truncate (parser->upper, 0);
234 + g_string_truncate (parser->lower, 0);
235 g_string_truncate (parser->description, 0);
236 xfce_stack_push (parser->stack, PARSER_ACTION);
238 @@ -690,6 +718,16 @@
239 g_string_truncate (parser->patterns, 0);
240 xfce_stack_push (parser->stack, PARSER_PATTERNS);
242 + else if (strcmp (element_name, "upper") == 0)
244 + g_string_truncate (parser->upper, 0);
245 + xfce_stack_push (parser->stack, PARSER_UPPER);
247 + else if (strcmp (element_name, "lower") == 0)
249 + g_string_truncate (parser->lower, 0);
250 + xfce_stack_push (parser->stack, PARSER_LOWER);
252 else if (strcmp (element_name, "description") == 0)
254 for (n = 0; attribute_names[n] != NULL; ++n)
255 @@ -803,6 +841,8 @@
256 parser->command->str,
257 parser->startup_notify,
258 parser->patterns->str,
259 + parser->upper->str,
260 + parser->lower->str,
261 parser->types);
263 else
264 @@ -828,7 +868,17 @@
265 if (strcmp (element_name, "patterns") != 0)
266 goto unknown_element;
267 break;
270 + case PARSER_UPPER:
271 + if (strcmp (element_name, "upper") != 0)
272 + goto unknown_element;
273 + break;
275 + case PARSER_LOWER:
276 + if (strcmp (element_name, "lower") != 0)
277 + goto unknown_element;
278 + break;
280 case PARSER_DESCRIPTION:
281 if (strcmp (element_name, "description") != 0)
282 goto unknown_element;
283 @@ -910,7 +960,15 @@
284 case PARSER_PATTERNS:
285 g_string_append_len (parser->patterns, text, text_len);
286 break;
289 + case PARSER_UPPER:
290 + g_string_append_len (parser->upper, text, text_len);
291 + break;
293 + case PARSER_LOWER:
294 + g_string_append_len (parser->lower, text, text_len);
295 + break;
297 case PARSER_DESCRIPTION:
298 if (parser->description_use)
299 g_string_append_len (parser->description, text, text_len);
300 @@ -1026,6 +1084,7 @@
301 GList *lp;
302 gint n_files;
303 gint i, m, n;
304 + gint upper, lower;
306 g_return_val_if_fail (THUNAR_UCA_IS_MODEL (uca_model), NULL);
308 @@ -1068,7 +1127,16 @@
310 /* check if we can just ignore this item */
311 item = (ThunarUcaModelItem *) lp->data;
312 - if (!item->multiple_selection && n_files > 1)
313 + upper = g_strtod(item->upper, NULL);
314 + lower = g_strtod(item->lower, NULL);
316 + if (upper == -1)
317 + upper = n_files;
319 + if (lower == -1)
320 + lower = n_files;
322 + if (((!item->multiple_selection) && (n_files > 1)) || (n_files > upper) || (n_files < lower))
323 continue;
325 /* match the specified files */
326 @@ -1240,6 +1308,8 @@
327 const gchar *command,
328 gboolean startup_notify,
329 const gchar *patterns,
330 + const gchar *upper,
331 + const gchar *lower,
332 ThunarUcaTypes types)
334 ThunarUcaModelItem *item;
335 @@ -1260,6 +1330,10 @@
336 item->icon = g_strdup (icon);
337 if (G_LIKELY (command != NULL && *command != '\0'))
338 item->command = g_strdup (command);
339 + if (G_LIKELY (upper != NULL && *upper != '\0'))
340 + item->upper = g_strdup (upper);
341 + if (G_LIKELY (lower != NULL && *lower != '\0'))
342 + item->lower = g_strdup (lower);
343 if (G_LIKELY (description != NULL && *description != '\0'))
344 item->description = g_strdup (description);
345 item->types = types;
346 @@ -1350,11 +1424,15 @@
347 "<name>%s</name>"
348 "<command>%s</command>"
349 "<description>%s</description>"
350 + "<upper>%s</upper>"
351 + "<lower>%s</lower>"
352 "<patterns>%s</patterns>",
353 (item->icon != NULL) ? item->icon : "",
354 (item->name != NULL) ? item->name : "",
355 (item->command != NULL) ? item->command : "",
356 (item->description != NULL) ? item->description : "",
357 + (item->upper != NULL) ? item->upper : "",
358 + (item->lower != NULL) ? item->lower : "",
359 patterns);
360 fprintf (fp, "%s", escaped);
361 g_free (patterns);
362 diff -ru Thunar-1.3.0.orig/plugins/thunar-uca/thunar-uca-model.h Thunar-1.3.0/plugins/thunar-uca/thunar-uca-model.h
363 --- Thunar-1.3.0.orig/plugins/thunar-uca/thunar-uca-model.h 2011-02-25 22:39:26.000000000 -0500
364 +++ Thunar-1.3.0/plugins/thunar-uca/thunar-uca-model.h 2011-02-26 00:02:26.000000000 -0500
365 @@ -42,6 +42,8 @@
366 THUNAR_UCA_MODEL_COLUMN_ICON,
367 THUNAR_UCA_MODEL_COLUMN_COMMAND,
368 THUNAR_UCA_MODEL_COLUMN_STARTUP_NOTIFY,
369 + THUNAR_UCA_MODEL_COLUMN_UPPER,
370 + THUNAR_UCA_MODEL_COLUMN_LOWER,
371 THUNAR_UCA_MODEL_COLUMN_PATTERNS,
372 THUNAR_UCA_MODEL_COLUMN_TYPES,
373 THUNAR_UCA_MODEL_COLUMN_STOCK_LABEL,
374 @@ -93,6 +95,8 @@
375 const gchar *command,
376 gboolean startup_notify,
377 const gchar *patterns,
378 + const gchar *upper,
379 + const gchar *lower,
380 ThunarUcaTypes types);
382 gboolean thunar_uca_model_save (ThunarUcaModel *uca_model,
383 diff -ru Thunar-1.3.0.orig/plugins/thunar-uca/uca.xml.in Thunar-1.3.0/plugins/thunar-uca/uca.xml.in
384 --- Thunar-1.3.0.orig/plugins/thunar-uca/uca.xml.in 2011-02-25 22:39:26.000000000 -0500
385 +++ Thunar-1.3.0/plugins/thunar-uca/uca.xml.in 2011-02-26 00:03:25.000000000 -0500
386 @@ -36,11 +36,25 @@
387 <action>
388 <icon>Terminal</icon>
389 <patterns>*</patterns>
390 + <lower>-1</lower>
391 + <upper>-1</upper>
392 <_name>Open Terminal Here</_name>
393 <command>exo-open --working-directory %f --launch TerminalEmulator</command>
394 <_description>Example for a custom action</_description>
396 <directories/>
397 </action>
400 + <action>
401 + <icon>preferences-desktop-wallpaper</icon>
402 + <patterns>*</patterns>
403 + <lower>0</lower>
404 + <upper>1</upper>
405 + <_name>Set as wallpaper</_name>
406 + <command>xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path --create -t string -s \"%f\"</command>
407 + <_description>Implementing the entire wallpaper plugin with just a bit of XML</_description>
409 + <image-files/>
410 + </action>
412 </actions>