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
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;
20 /* configure the dialog properties */
21 gtk_dialog_add_button (GTK_DIALOG (uca_editor), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
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));
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);
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);
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,
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);
108 g_free (description);
114 @@ -825,10 +856,16 @@
115 ThunarUcaModel *uca_model,
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)),
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)),
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
145 PARSER_STARTUP_NOTIFY,
154 guint startup_notify : 1;
158 ThunarUcaTypes types;
160 /* derived attributes */
164 GString *description;
167 gboolean startup_notify;
168 gboolean description_use;
169 guint description_match;
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:
186 str = g_strjoinv (";", item->patterns);
187 g_value_take_string (value, str);
191 + case THUNAR_UCA_MODEL_COLUMN_UPPER:
192 + g_value_set_static_string (value, item->upper);
195 + case THUNAR_UCA_MODEL_COLUMN_LOWER:
196 + g_value_set_static_string (value, item->lower);
199 case THUNAR_UCA_MODEL_COLUMN_TYPES:
200 g_value_set_uint (value, item->types);
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);
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);
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);
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);
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)
256 parser->command->str,
257 parser->startup_notify,
258 parser->patterns->str,
259 + parser->upper->str,
260 + parser->lower->str,
265 if (strcmp (element_name, "patterns") != 0)
266 goto unknown_element;
271 + if (strcmp (element_name, "upper") != 0)
272 + goto unknown_element;
276 + if (strcmp (element_name, "lower") != 0)
277 + goto unknown_element;
280 case PARSER_DESCRIPTION:
281 if (strcmp (element_name, "description") != 0)
282 goto unknown_element;
284 case PARSER_PATTERNS:
285 g_string_append_len (parser->patterns, text, text_len);
290 + g_string_append_len (parser->upper, text, text_len);
294 + g_string_append_len (parser->lower, text, text_len);
297 case PARSER_DESCRIPTION:
298 if (parser->description_use)
299 g_string_append_len (parser->description, text, text_len);
300 @@ -1026,6 +1084,7 @@
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);
322 + if (((!item->multiple_selection) && (n_files > 1)) || (n_files > upper) || (n_files < lower))
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);
346 @@ -1350,11 +1424,15 @@
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 : "",
360 fprintf (fp, "%s", escaped);
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
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,
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
388 <icon>Terminal</icon>
389 <patterns>*</patterns>
392 <_name>Open Terminal Here</_name>
393 <command>exo-open --working-directory %f --launch TerminalEmulator</command>
394 <_description>Example for a custom action</_description>
401 + <icon>preferences-desktop-wallpaper</icon>
402 + <patterns>*</patterns>
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>