2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2013 Hiroyuki Yamamoto & The Claws Mail Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "claws-features.h"
28 #include <glib/gi18n.h>
30 #include <gdk/gdkkeysyms.h>
36 #include "prefs_gtk.h"
40 #include "manage_window.h"
41 #include "mainwindow.h"
42 #include "prefs_common.h"
43 #include "alertpanel.h"
44 #include "prefs_actions.h"
46 #include "description_window.h"
50 #include "filtering.h"
51 #include "prefs_filtering_action.h"
52 #include "matcher_parser.h"
53 #include "prefs_toolbar.h"
56 PREFS_ACTIONS_STRING
, /*!< string pointer managed by list store,
57 * and never touched or retrieved by
59 PREFS_ACTIONS_DATA
, /*!< pointer to string that is not managed by
60 * the list store, and which is retrieved
61 * and touched by us */
62 PREFS_ACTIONS_VALID
, /*!< contains a valid action, otherwise "(New)" */
63 N_PREFS_ACTIONS_COLUMNS
71 GtkWidget
*filter_btn
;
72 GtkWidget
*name_entry
;
75 GtkWidget
*shell_radiobtn
;
76 GtkWidget
*filter_radiobtn
;
78 GtkWidget
*actions_list_view
;
81 static int modified
= FALSE
;
82 static int modified_list
= FALSE
;
84 /* widget creating functions */
85 static void prefs_actions_create (MainWindow
*mainwin
);
86 static void prefs_actions_set_dialog (void);
87 static gint
prefs_actions_clist_set_row (gint row
);
89 /* callback functions */
90 static void prefs_actions_info_cb (GtkWidget
*w
,
92 static void prefs_actions_register_cb (GtkWidget
*w
,
94 static void prefs_actions_substitute_cb (GtkWidget
*w
,
96 static void prefs_actions_delete_cb (gpointer gtk_action
, gpointer data
);
97 static void prefs_actions_delete_all_cb (gpointer gtk_action
, gpointer data
);
98 static void prefs_actions_clear_cb (gpointer gtk_action
, gpointer data
);
99 static void prefs_actions_duplicate_cb (gpointer gtk_action
, gpointer data
);
100 static void prefs_actions_up (GtkWidget
*w
,
102 static void prefs_actions_down (GtkWidget
*w
,
104 static gint
prefs_actions_deleted (GtkWidget
*widget
,
107 static gboolean
prefs_actions_key_pressed(GtkWidget
*widget
,
110 static gboolean
prefs_actions_search_func_cb (GtkTreeModel
*model
, gint column
,
111 const gchar
*key
, GtkTreeIter
*iter
,
112 gpointer search_data
);
113 static void prefs_actions_cancel (GtkWidget
*w
,
115 static void prefs_actions_ok (GtkWidget
*w
,
118 static GtkListStore
* prefs_actions_create_data_store (void);
120 static void prefs_actions_list_view_insert_action (GtkWidget
*list_view
,
124 static GtkWidget
*prefs_actions_list_view_create (void);
125 static void prefs_actions_create_list_view_columns (GtkWidget
*list_view
);
126 static void prefs_actions_select_row(GtkTreeView
*list_view
, GtkTreePath
*path
);
128 static void prefs_action_filter_radiobtn_cb(GtkWidget
*widget
, gpointer data
);
129 static void prefs_action_shell_radiobtn_cb(GtkWidget
*widget
, gpointer data
);
130 static void prefs_action_filterbtn_cb(GtkWidget
*widget
, gpointer data
);
131 static void prefs_action_define_filter_done(GSList
* action_list
);
134 void prefs_actions_open(MainWindow
*mainwin
)
139 prefs_actions_create(mainwin
);
141 manage_window_set_transient(GTK_WINDOW(actions
.window
));
142 gtk_widget_grab_focus(actions
.ok_btn
);
144 prefs_actions_set_dialog();
146 gtk_widget_show(actions
.window
);
147 gtk_window_set_modal(GTK_WINDOW(actions
.window
), TRUE
);
151 *\brief Save Gtk object size to prefs dataset
153 static void prefs_actions_size_allocate_cb(GtkWidget
*widget
,
154 GtkAllocation
*allocation
)
156 cm_return_if_fail(allocation
!= NULL
);
158 prefs_common
.actionswin_width
= allocation
->width
;
159 prefs_common
.actionswin_height
= allocation
->height
;
162 static void prefs_actions_create(MainWindow
*mainwin
)
166 GtkWidget
*filter_hbox
;
169 GtkWidget
*cancel_btn
;
170 GtkWidget
*confirm_area
;
175 GtkWidget
*shell_radiobtn
;
176 GtkWidget
*filter_radiobtn
;
178 GtkWidget
*name_label
;
179 GtkWidget
*name_entry
;
180 GtkWidget
*cmd_label
;
181 GtkWidget
*cmd_entry
;
182 GtkWidget
*filter_btn
;
188 GtkWidget
*subst_btn
;
190 GtkWidget
*clear_btn
;
192 GtkWidget
*cond_hbox
;
193 GtkWidget
*cond_scrolledwin
;
194 GtkWidget
*cond_list_view
;
201 static GdkGeometry geometry
;
203 debug_print("Creating actions configuration window...\n");
205 window
= gtkut_window_new(GTK_WINDOW_TOPLEVEL
, "prefs_actions");
207 gtk_container_set_border_width(GTK_CONTAINER (window
), 8);
208 gtk_window_set_position(GTK_WINDOW(window
), GTK_WIN_POS_CENTER
);
209 gtk_window_set_resizable(GTK_WINDOW(window
), TRUE
);
211 vbox
= gtk_vbox_new(FALSE
, 6);
212 gtk_widget_show(vbox
);
213 gtk_container_add(GTK_CONTAINER(window
), vbox
);
215 gtkut_stock_button_set_create_with_help(&confirm_area
, &help_btn
,
216 &cancel_btn
, GTK_STOCK_CANCEL
,
217 &ok_btn
, GTK_STOCK_OK
,
219 gtk_widget_show(confirm_area
);
220 gtk_box_pack_end(GTK_BOX(vbox
), confirm_area
, FALSE
, FALSE
, 0);
221 gtk_widget_grab_default(ok_btn
);
223 gtk_window_set_title(GTK_WINDOW(window
), _("Actions configuration"));
224 g_signal_connect(G_OBJECT(window
), "delete_event",
225 G_CALLBACK(prefs_actions_deleted
), NULL
);
226 g_signal_connect(G_OBJECT(window
), "size_allocate",
227 G_CALLBACK(prefs_actions_size_allocate_cb
), NULL
);
228 g_signal_connect(G_OBJECT(window
), "key_press_event",
229 G_CALLBACK(prefs_actions_key_pressed
), NULL
);
230 MANAGE_WINDOW_SIGNALS_CONNECT(window
);
231 g_signal_connect(G_OBJECT(ok_btn
), "clicked",
232 G_CALLBACK(prefs_actions_ok
), mainwin
);
233 g_signal_connect(G_OBJECT(cancel_btn
), "clicked",
234 G_CALLBACK(prefs_actions_cancel
), NULL
);
235 g_signal_connect(G_OBJECT(help_btn
), "clicked",
236 G_CALLBACK(manual_open_with_anchor_cb
),
237 MANUAL_ANCHOR_ACTIONS
);
239 vbox1
= gtk_vbox_new(FALSE
, VSPACING
);
240 gtk_widget_show(vbox1
);
241 gtk_box_pack_start(GTK_BOX(vbox
), vbox1
, TRUE
, TRUE
, 0);
242 gtk_container_set_border_width(GTK_CONTAINER(vbox1
), 2);
244 table
= gtk_table_new(3, 2, FALSE
);
245 gtk_table_set_row_spacings (GTK_TABLE (table
), VSPACING_NARROW_2
);
246 gtk_table_set_col_spacings (GTK_TABLE (table
), 4);
247 gtk_widget_show(table
);
248 gtk_box_pack_start (GTK_BOX (vbox1
), table
, FALSE
, FALSE
, 0);
250 name_label
= gtk_label_new (_("Menu name"));
251 gtk_widget_show (name_label
);
252 gtk_misc_set_alignment (GTK_MISC (name_label
), 1, 0.5);
253 gtk_table_attach (GTK_TABLE (table
), name_label
, 0, 1, 0, 1,
254 (GtkAttachOptions
) (GTK_FILL
),
255 (GtkAttachOptions
) (0), 0, 0);
257 name_entry
= gtk_entry_new ();
258 gtk_widget_show (name_entry
);
259 gtk_table_attach (GTK_TABLE (table
), name_entry
, 1, 2, 0, 1,
260 (GtkAttachOptions
) (GTK_FILL
|GTK_EXPAND
),
261 (GtkAttachOptions
) (0), 0, 0);
263 cmd_label
= gtk_label_new (_("Command"));
264 gtk_widget_show (cmd_label
);
265 gtk_misc_set_alignment (GTK_MISC (cmd_label
), 1, 0.5);
266 gtk_table_attach (GTK_TABLE (table
), cmd_label
, 0, 1, 2, 3,
267 (GtkAttachOptions
) (GTK_FILL
),
268 (GtkAttachOptions
) (0), 0, 0);
270 cmd_entry
= gtk_entry_new ();
271 gtk_widget_show (cmd_entry
);
272 gtk_table_attach (GTK_TABLE (table
), cmd_entry
, 1, 2, 2, 3,
273 (GtkAttachOptions
) (GTK_FILL
|GTK_EXPAND
),
274 (GtkAttachOptions
) (0), 0, 0);
276 /* radio buttons for filter actions or shell */
277 filter_hbox
= gtk_hbox_new(FALSE
,4);
278 gtk_table_attach(GTK_TABLE(table
), filter_hbox
, 1, 2, 3, 4,
279 (GtkAttachOptions
) (GTK_FILL
|GTK_EXPAND
),
280 (GtkAttachOptions
) (0), 0, 0);
281 gtk_widget_show(filter_hbox
);
283 shell_radiobtn
= gtk_radio_button_new_with_label(NULL
, _("Shell command"));
284 gtk_box_pack_start(GTK_BOX(filter_hbox
), shell_radiobtn
, FALSE
, FALSE
, 0);
285 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(shell_radiobtn
), TRUE
);
286 gtk_widget_show(shell_radiobtn
);
288 g_signal_connect(G_OBJECT(shell_radiobtn
), "clicked",
289 G_CALLBACK(prefs_action_shell_radiobtn_cb
), NULL
);
292 gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(shell_radiobtn
),
294 gtk_box_pack_start(GTK_BOX(filter_hbox
), filter_radiobtn
, FALSE
, FALSE
, 0);
295 gtk_widget_show(filter_radiobtn
);
296 g_signal_connect(G_OBJECT(filter_radiobtn
), "clicked",
297 G_CALLBACK(prefs_action_filter_radiobtn_cb
), NULL
);
299 filter_btn
= gtk_button_new_with_label(_("Edit filter action"));
300 gtk_box_pack_start(GTK_BOX(filter_hbox
), filter_btn
, FALSE
, FALSE
, 0);
301 gtk_widget_set_sensitive(filter_btn
, FALSE
);
302 g_signal_connect(G_OBJECT(filter_btn
), "clicked",
303 G_CALLBACK(prefs_action_filterbtn_cb
), NULL
);
304 gtk_widget_show(filter_btn
);
306 /* register / substitute / delete */
308 reg_hbox
= gtk_hbox_new(FALSE
, 4);
309 gtk_widget_show(reg_hbox
);
310 gtk_box_pack_start(GTK_BOX(vbox1
), reg_hbox
, FALSE
, FALSE
, 0);
312 arrow
= gtk_arrow_new(GTK_ARROW_DOWN
, GTK_SHADOW_OUT
);
313 gtk_widget_show(arrow
);
314 gtk_box_pack_start(GTK_BOX(reg_hbox
), arrow
, FALSE
, FALSE
, 0);
315 gtk_widget_set_size_request(arrow
, -1, 16);
317 btn_hbox
= gtk_hbox_new(TRUE
, 4);
318 gtk_widget_show(btn_hbox
);
319 gtk_box_pack_start(GTK_BOX(reg_hbox
), btn_hbox
, FALSE
, FALSE
, 0);
321 reg_btn
= gtk_button_new_from_stock(GTK_STOCK_ADD
);
322 gtk_widget_show(reg_btn
);
323 gtk_box_pack_start(GTK_BOX(btn_hbox
), reg_btn
, FALSE
, TRUE
, 0);
324 g_signal_connect(G_OBJECT(reg_btn
), "clicked",
325 G_CALLBACK(prefs_actions_register_cb
), NULL
);
326 CLAWS_SET_TIP(reg_btn
,
327 _("Append the new action above to the list"));
329 subst_btn
= gtkut_get_replace_btn(_("_Replace"));
330 gtk_widget_show(subst_btn
);
331 gtk_box_pack_start(GTK_BOX(btn_hbox
), subst_btn
, FALSE
, TRUE
, 0);
332 g_signal_connect(G_OBJECT(subst_btn
), "clicked",
333 G_CALLBACK(prefs_actions_substitute_cb
), NULL
);
334 CLAWS_SET_TIP(subst_btn
,
335 _("Replace the selected action in list with the action above"));
337 del_btn
= gtk_button_new_with_mnemonic (_("D_elete"));
338 gtk_button_set_image(GTK_BUTTON(del_btn
),
339 gtk_image_new_from_stock(GTK_STOCK_REMOVE
,GTK_ICON_SIZE_BUTTON
));
340 gtk_widget_show(del_btn
);
341 gtk_box_pack_start(GTK_BOX(btn_hbox
), del_btn
, FALSE
, TRUE
, 0);
342 g_signal_connect(G_OBJECT(del_btn
), "clicked",
343 G_CALLBACK(prefs_actions_delete_cb
), NULL
);
344 CLAWS_SET_TIP(del_btn
,
345 _("Delete the selected action from the list"));
347 clear_btn
= gtk_button_new_with_mnemonic (_("C_lear"));
348 gtk_button_set_image(GTK_BUTTON(clear_btn
),
349 gtk_image_new_from_stock(GTK_STOCK_CLEAR
,GTK_ICON_SIZE_BUTTON
));
350 gtk_widget_show (clear_btn
);
351 gtk_box_pack_start (GTK_BOX (btn_hbox
), clear_btn
, FALSE
, TRUE
, 0);
352 g_signal_connect(G_OBJECT (clear_btn
), "clicked",
353 G_CALLBACK(prefs_actions_clear_cb
), NULL
);
354 CLAWS_SET_TIP(clear_btn
,
355 _("Clear all the input fields in the dialog"));
357 info_btn
= gtk_button_new_from_stock(GTK_STOCK_INFO
);
358 gtk_widget_show(info_btn
);
359 gtk_box_pack_end(GTK_BOX(reg_hbox
), info_btn
, FALSE
, FALSE
, 0);
360 g_signal_connect(G_OBJECT(info_btn
), "clicked",
361 G_CALLBACK(prefs_actions_info_cb
), GTK_WINDOW(window
));
362 CLAWS_SET_TIP(info_btn
,
363 _("Show information on configuring actions"));
365 cond_hbox
= gtk_hbox_new(FALSE
, 8);
366 gtk_widget_show(cond_hbox
);
367 gtk_box_pack_start(GTK_BOX(vbox1
), cond_hbox
, TRUE
, TRUE
, 0);
369 cond_scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
370 gtk_widget_show(cond_scrolledwin
);
371 gtk_widget_set_size_request(cond_scrolledwin
, -1, 150);
372 gtk_box_pack_start(GTK_BOX(cond_hbox
), cond_scrolledwin
,
374 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (cond_scrolledwin
),
375 GTK_POLICY_AUTOMATIC
,
376 GTK_POLICY_AUTOMATIC
);
377 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(cond_scrolledwin
),
378 GTK_SHADOW_ETCHED_IN
);
380 cond_list_view
= prefs_actions_list_view_create();
381 gtk_widget_show(cond_list_view
);
382 gtk_container_add(GTK_CONTAINER (cond_scrolledwin
), cond_list_view
);
384 btn_vbox
= gtk_vbox_new(FALSE
, 8);
385 gtk_widget_show(btn_vbox
);
386 gtk_box_pack_start(GTK_BOX(cond_hbox
), btn_vbox
, FALSE
, FALSE
, 0);
388 up_btn
= gtk_button_new_from_stock(GTK_STOCK_GO_UP
);
389 gtk_widget_show(up_btn
);
390 gtk_box_pack_start(GTK_BOX(btn_vbox
), up_btn
, FALSE
, FALSE
, 0);
391 g_signal_connect(G_OBJECT(up_btn
), "clicked",
392 G_CALLBACK(prefs_actions_up
), NULL
);
393 CLAWS_SET_TIP(up_btn
,
394 _("Move the selected action up"));
396 down_btn
= gtk_button_new_from_stock(GTK_STOCK_GO_DOWN
);
397 gtk_widget_show(down_btn
);
398 gtk_box_pack_start(GTK_BOX(btn_vbox
), down_btn
, FALSE
, FALSE
, 0);
399 g_signal_connect(G_OBJECT(down_btn
), "clicked",
400 G_CALLBACK(prefs_actions_down
), NULL
);
401 CLAWS_SET_TIP(down_btn
,
402 _("Move selected action down"));
404 if (!geometry
.min_height
) {
405 geometry
.min_width
= 486;
406 geometry
.min_height
= 322;
409 gtk_window_set_geometry_hints(GTK_WINDOW(window
), NULL
, &geometry
,
411 gtk_widget_set_size_request(window
, prefs_common
.actionswin_width
,
412 prefs_common
.actionswin_height
);
414 gtk_widget_show(window
);
416 actions
.window
= window
;
417 actions
.ok_btn
= ok_btn
;
418 actions
.info_btn
= info_btn
;
420 actions
.name_entry
= name_entry
;
421 actions
.cmd_entry
= cmd_entry
;
422 actions
.filter_btn
= filter_btn
;
423 actions
.shell_radiobtn
= shell_radiobtn
;
424 actions
.filter_radiobtn
= filter_radiobtn
;
426 actions
.actions_list_view
= cond_list_view
;
429 static void prefs_actions_reset_dialog(void)
431 gtk_entry_set_text(GTK_ENTRY(actions
.name_entry
), "");
432 gtk_entry_set_text(GTK_ENTRY(actions
.cmd_entry
), "");
433 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(actions
.shell_radiobtn
), TRUE
);
436 void prefs_actions_read_config(void)
440 gchar buf
[PREFSBUFSIZE
];
443 debug_print("Reading actions configurations...\n");
445 rcpath
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
, ACTIONS_RC
, NULL
);
446 if ((fp
= g_fopen(rcpath
, "rb")) == NULL
) {
447 if (ENOENT
!= errno
) FILE_OP_ERROR(rcpath
, "fopen");
453 while (prefs_common
.actions_list
!= NULL
) {
454 act
= (gchar
*)prefs_common
.actions_list
->data
;
455 prefs_common
.actions_list
=
456 g_slist_remove(prefs_common
.actions_list
, act
);
460 while (fgets(buf
, sizeof(buf
), fp
) != NULL
) {
461 const gchar
*src_codeset
= conv_get_locale_charset_str();
462 const gchar
*dest_codeset
= CS_UTF_8
;
465 tmp
= conv_codeset_strdup(buf
, src_codeset
, dest_codeset
);
467 g_warning("Failed to convert character set of action configuration");
472 act
= strstr(tmp
, ": ");
474 action_get_type(&act
[2]) != ACTION_ERROR
)
475 prefs_common
.actions_list
=
476 g_slist_append(prefs_common
.actions_list
,
484 void prefs_actions_write_config(void)
490 debug_print("Writing actions configuration...\n");
492 rcpath
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
, ACTIONS_RC
, NULL
);
493 if ((pfile
= prefs_write_open(rcpath
)) == NULL
) {
494 g_warning("failed to write configuration to file");
499 for (cur
= prefs_common
.actions_list
; cur
!= NULL
; cur
= cur
->next
) {
500 gchar
*tmp
= (gchar
*)cur
->data
;
501 const gchar
*src_codeset
= CS_UTF_8
;
502 const gchar
*dest_codeset
= conv_get_locale_charset_str();
505 act
= conv_codeset_strdup(tmp
, src_codeset
, dest_codeset
);
507 g_warning("Failed to convert character set of action configuration");
511 if (fputs(act
, pfile
->fp
) == EOF
||
512 fputc('\n', pfile
->fp
) == EOF
) {
513 FILE_OP_ERROR(rcpath
, "fputs || fputc");
514 prefs_file_close_revert(pfile
);
524 if (prefs_file_close(pfile
) < 0) {
525 g_warning("failed to write configuration to file");
530 static void prefs_actions_clear_list(GtkListStore
*list_store
)
532 gtk_list_store_clear(list_store
);
534 prefs_actions_list_view_insert_action(actions
.actions_list_view
,
535 -1, _("(New)"), FALSE
);
538 static void prefs_actions_set_dialog(void)
543 store
= GTK_LIST_STORE(gtk_tree_view_get_model
544 (GTK_TREE_VIEW(actions
.actions_list_view
)));
546 prefs_actions_clear_list(store
);
547 prefs_actions_reset_dialog();
549 for (cur
= prefs_common
.actions_list
; cur
!= NULL
; cur
= cur
->next
) {
550 gchar
*action
= (gchar
*) cur
->data
;
552 prefs_actions_list_view_insert_action(actions
.actions_list_view
,
557 static void prefs_actions_set_list(void)
562 g_slist_free(prefs_common
.actions_list
);
563 prefs_common
.actions_list
= NULL
;
565 store
= GTK_LIST_STORE(gtk_tree_view_get_model
566 (GTK_TREE_VIEW(actions
.actions_list_view
)));
568 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store
), &iter
)) {
573 gtk_tree_model_get(GTK_TREE_MODEL(store
), &iter
,
574 PREFS_ACTIONS_DATA
, &action
,
575 PREFS_ACTIONS_VALID
, &is_valid
,
579 prefs_common
.actions_list
=
580 g_slist_append(prefs_common
.actions_list
,
583 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(store
),
588 #define GET_ENTRY(entry) \
589 entry_text = gtk_entry_get_text(GTK_ENTRY(entry))
591 static gint
prefs_actions_clist_set_row(gint row
)
593 const gchar
*entry_text
;
595 gchar action
[PREFSBUFSIZE
];
598 GET_ENTRY(actions
.name_entry
);
599 if (entry_text
[0] == '\0') {
600 alertpanel_error(_("Menu name is not set."));
604 if (entry_text
[0] == '/') {
605 alertpanel_error(_("A leading '/' is not allowed in the menu name."));
609 if (strchr(entry_text
, ':')) {
610 alertpanel_error(_("Colon ':' is not allowed in the menu name."));
614 action_nb
= prefs_actions_find_by_name(entry_text
);
615 if ((action_nb
!= -1) && ((row
== -1) || (row
!= action_nb
+ 1))) {
616 alertpanel_error(_("There is an action with this name already."));
620 strncpy(action
, entry_text
, PREFSBUFSIZE
- 1);
622 while (strstr(action
, "//")) {
623 char *to_move
= strstr(action
, "//")+1;
624 char *where
= strstr(action
, "//");
625 int old_len
= strlen(action
);
626 memmove(where
, to_move
, strlen(to_move
));
627 action
[old_len
-1] = '\0';
632 /* Keep space for the ': ' delimiter */
633 len
= strlen(action
) + 2;
634 if (len
>= PREFSBUFSIZE
- 1) {
635 alertpanel_error(_("Menu name is too long."));
639 strcat(action
, ": ");
641 GET_ENTRY(actions
.cmd_entry
);
643 if (entry_text
[0] == '\0') {
644 alertpanel_error(_("Command-line not set."));
648 if (len
+ strlen(entry_text
) >= PREFSBUFSIZE
- 1) {
649 alertpanel_error(_("Menu name and command are too long."));
653 if (action_get_type(entry_text
) == ACTION_ERROR
) {
655 message
= g_markup_printf_escaped(_("The command\n%s\nhas a syntax error."),
657 alertpanel_error("%s", message
);
662 strcat(action
, entry_text
);
664 new_action
= g_strdup(action
);
665 prefs_actions_list_view_insert_action(actions
.actions_list_view
,
666 row
, new_action
, TRUE
);
668 prefs_actions_set_list();
673 /* callback functions */
675 static void prefs_actions_register_cb(GtkWidget
*w
, gpointer data
)
677 prefs_actions_clist_set_row(-1);
680 modified_list
= TRUE
;
683 static void prefs_actions_substitute_cb(GtkWidget
*w
, gpointer data
)
687 row
= gtkut_list_view_get_selected_row(actions
.actions_list_view
);
691 prefs_actions_clist_set_row(row
);
694 modified_list
= TRUE
;
697 static void prefs_actions_delete_cb(gpointer gtk_action
, gpointer data
)
704 row
= gtkut_list_view_get_selected_row(actions
.actions_list_view
);
708 if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection
709 (GTK_TREE_VIEW(actions
.actions_list_view
)),
713 if (alertpanel(_("Delete action"),
714 _("Do you really want to delete this action?"),
715 GTK_STOCK_CANCEL
, GTK_STOCK_DELETE
, NULL
) != G_ALERTALTERNATE
)
718 /* XXX: Here's the reason why we need to store the original
719 * pointer: we search the slist for it. */
720 gtk_tree_model_get(model
, &sel
,
721 PREFS_ACTIONS_DATA
, &action
,
723 gtk_list_store_remove(GTK_LIST_STORE(model
), &sel
);
725 prefs_common
.actions_list
= g_slist_remove(prefs_common
.actions_list
,
727 modified_list
= TRUE
;
730 static void prefs_actions_delete_all_cb(gpointer gtk_action
, gpointer data
)
732 GtkListStore
*list_store
;
734 if (alertpanel(_("Delete all actions"),
735 _("Do you really want to delete all the actions?"),
736 GTK_STOCK_CANCEL
, GTK_STOCK_DELETE
, NULL
) != G_ALERTDEFAULT
)
739 list_store
= GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(actions
.actions_list_view
)));
740 prefs_actions_clear_list(list_store
);
743 prefs_actions_reset_dialog();
744 modified_list
= TRUE
;
747 static void prefs_actions_clear_cb(gpointer gtk_action
, gpointer data
)
751 prefs_actions_reset_dialog();
752 row
= gtkut_list_view_get_selected_row(actions
.actions_list_view
);
759 static void prefs_actions_duplicate_cb(gpointer gtk_action
, gpointer data
)
763 row
= gtkut_list_view_get_selected_row(actions
.actions_list_view
);
767 modified_list
= !prefs_actions_clist_set_row(-row
-2);
770 static void prefs_actions_up(GtkWidget
*w
, gpointer data
)
772 GtkTreePath
*prev
, *sel
, *try;
774 GtkListStore
*store
= NULL
;
775 GtkTreeModel
*model
= NULL
;
778 if (!gtk_tree_selection_get_selected
779 (gtk_tree_view_get_selection
780 (GTK_TREE_VIEW(actions
.actions_list_view
)),
784 store
= (GtkListStore
*)model
;
785 sel
= gtk_tree_model_get_path(GTK_TREE_MODEL(store
), &isel
);
789 /* no move if we're at row 0 or 1, looks phony, but other
790 * solutions are more convoluted... */
791 try = gtk_tree_path_copy(sel
);
792 if (!gtk_tree_path_prev(try) || !gtk_tree_path_prev(try)) {
793 gtk_tree_path_free(try);
794 gtk_tree_path_free(sel
);
797 gtk_tree_path_free(try);
799 prev
= gtk_tree_path_copy(sel
);
800 if (!gtk_tree_path_prev(prev
)) {
801 gtk_tree_path_free(prev
);
802 gtk_tree_path_free(sel
);
806 gtk_tree_model_get_iter(GTK_TREE_MODEL(store
),
808 gtk_tree_path_free(sel
);
809 gtk_tree_path_free(prev
);
811 gtk_list_store_swap(store
, &iprev
, &isel
);
812 prefs_actions_set_list();
813 modified_list
= TRUE
;
816 static void prefs_actions_down(GtkWidget
*w
, gpointer data
)
818 GtkListStore
*store
= NULL
;
819 GtkTreeModel
*model
= NULL
;
820 GtkTreeIter next
, sel
;
823 if (!gtk_tree_selection_get_selected
824 (gtk_tree_view_get_selection
825 (GTK_TREE_VIEW(actions
.actions_list_view
)),
829 store
= (GtkListStore
*)model
;
830 try = gtk_tree_model_get_path(GTK_TREE_MODEL(store
), &sel
);
834 /* no move when we're at row 0 */
835 if (!gtk_tree_path_prev(try)) {
836 gtk_tree_path_free(try);
839 gtk_tree_path_free(try);
842 if (!gtk_tree_model_iter_next(GTK_TREE_MODEL(store
), &next
))
845 gtk_list_store_swap(store
, &next
, &sel
);
846 prefs_actions_set_list();
847 modified_list
= TRUE
;
850 static gint
prefs_actions_deleted(GtkWidget
*widget
, GdkEventAny
*event
,
853 prefs_actions_cancel(widget
, data
);
857 static gboolean
prefs_actions_key_pressed(GtkWidget
*widget
, GdkEventKey
*event
,
860 if (event
&& event
->keyval
== GDK_KEY_Escape
)
861 prefs_actions_cancel(widget
, data
);
863 GtkWidget
*focused
= gtkut_get_focused_child(
864 GTK_CONTAINER(widget
));
865 if (focused
&& GTK_IS_EDITABLE(focused
))
871 static gboolean
prefs_actions_search_func_cb (GtkTreeModel
*model
, gint column
, const gchar
*key
,
872 GtkTreeIter
*iter
, gpointer search_data
)
878 gtk_tree_model_get (model
, iter
, column
, &store_string
, -1);
880 if (!store_string
|| !key
)
884 retval
= (strncmp (key
, store_string
, strlen(key
)) != 0);
886 g_free(store_string
);
887 debug_print("selecting row\n");
888 path
= gtk_tree_model_get_path(model
, iter
);
889 prefs_actions_select_row(GTK_TREE_VIEW(actions
.actions_list_view
), path
);
890 gtk_tree_path_free(path
);
894 static void prefs_actions_cancel(GtkWidget
*w
, gpointer data
)
898 if (modified
&& alertpanel(_("Entry not saved"),
899 _("The entry was not saved. Close anyway?"),
900 GTK_STOCK_CLOSE
, g_strconcat("+", _("_Continue editing"), NULL
),
901 NULL
) != G_ALERTDEFAULT
) {
903 } else if (modified_list
&& alertpanel(_("Actions list not saved"),
904 _("The actions list has been modified. Close anyway?"),
905 GTK_STOCK_CLOSE
, g_strconcat("+", _("_Continue editing"), NULL
),
906 NULL
) != G_ALERTDEFAULT
) {
910 modified_list
= FALSE
;
911 store
= GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW
912 (actions
.actions_list_view
)));
913 gtk_list_store_clear(store
);
914 prefs_actions_read_config();
915 gtk_widget_hide(actions
.window
);
916 gtk_window_set_modal(GTK_WINDOW(actions
.window
), FALSE
);
920 static void prefs_actions_ok(GtkWidget
*widget
, gpointer data
)
922 MainWindow
*mainwin
= (MainWindow
*) data
;
925 MessageView
*msgview
;
929 if (modified
&& alertpanel(_("Entry not saved"),
930 _("The entry was not saved. Close anyway?"),
931 GTK_STOCK_CLOSE
, g_strconcat("+", _("_Continue editing"), NULL
),
932 NULL
) != G_ALERTDEFAULT
) {
936 modified_list
= FALSE
;
937 prefs_actions_set_list();
938 store
= GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW
939 (actions
.actions_list_view
)));
940 gtk_list_store_clear(store
);
941 prefs_actions_write_config();
943 /* Update mainwindow actions menu */
944 main_window_update_actions_menu(mainwin
);
946 /* Update separated message view actions menu */
947 list
= messageview_get_msgview_list();
948 for (iter
= list
; iter
; iter
= iter
->next
) {
949 msgview
= (MessageView
*) iter
->data
;
950 messageview_update_actions_menu(msgview
);
953 /* Update compose windows actions menu */
954 list
= compose_get_compose_list();
955 for (iter
= list
; iter
; iter
= iter
->next
) {
956 compose
= (Compose
*) iter
->data
;
957 compose_update_actions_menu(compose
);
960 /* Update toolbars */
961 prefs_toolbar_update_action_btns();
963 gtk_widget_hide(actions
.window
);
964 gtk_window_set_modal(GTK_WINDOW(actions
.window
), FALSE
);
969 * Strings describing action format strings
971 * When adding new lines, remember to put one string for each line
973 static gchar
*actions_desc_strings
[] = {
974 N_("<span weight=\"bold\" underline=\"single\">Menu name:</span>"), NULL
,
975 N_("Use / in menu name to make submenus."), NULL
,
977 N_("<span weight=\"bold\" underline=\"single\">Command-line:</span>"), NULL
,
978 N_("<span weight=\"bold\">Begin with:</span>"), NULL
,
979 " |", N_("to send message body or selection to command's standard input"),
980 " >", N_("to send user provided text to command's standard input"),
981 " *", N_("to send user provided hidden text to command's standard input"),
982 N_("<span weight=\"bold\">End with:</span>"), NULL
,
983 " |", N_("to replace message body or selection with command's standard output"),
984 " >", N_("to insert command's standard output without replacing old text"),
985 " &", N_("to run command asynchronously"),
986 N_("<span weight=\"bold\">Use:</span>"), NULL
,
987 " %f", N_("for the file of the selected message in RFC822/2822 format "),
988 " %F", N_("for the list of the files of the selected messages in RFC822/2822 format"),
989 " %p", N_("for the file of the selected decoded message MIME part"),
990 " %u", N_("for a user provided argument"),
991 " %h", N_("for a user provided hidden argument (e.g. password)"),
992 " %s", N_("for the text selection"),
993 " %as{}", N_("apply filtering actions between {} to selected messages"),
994 " %%", N_("for a literal %"),
999 static DescriptionWindow actions_desc_win
= {
1005 N_("The Actions feature is a way for the user to launch "
1006 "external commands to process a complete message file or just "
1007 "one of its parts."),
1008 actions_desc_strings
1012 static void prefs_actions_info_cb(GtkWidget
*w
, GtkWidget
*window
)
1014 actions_desc_win
.parent
= window
;
1015 description_window_create(&actions_desc_win
);
1018 static GtkListStore
* prefs_actions_create_data_store(void)
1020 return gtk_list_store_new(N_PREFS_ACTIONS_COLUMNS
,
1027 static void prefs_actions_list_view_insert_action(GtkWidget
*list_view
,
1033 GtkTreeIter sibling
;
1034 GtkListStore
*list_store
= GTK_LIST_STORE(gtk_tree_view_get_model
1035 (GTK_TREE_VIEW(list_view
)));
1037 /* row -1 to add a new rule to store,
1038 row >=0 to change an existing row
1039 row <-1 insert a new row after (-row-2)
1042 /* modify the existing */
1043 if (!gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(list_store
),
1046 } else if (row
< -1 ) {
1047 if (!gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(list_store
),
1048 &sibling
, NULL
, -row
-2))
1054 gtk_list_store_append(list_store
, &iter
);
1055 gtk_list_store_set(list_store
, &iter
,
1056 PREFS_ACTIONS_STRING
, action
,
1057 PREFS_ACTIONS_DATA
, action
,
1058 PREFS_ACTIONS_VALID
, is_valid
,
1060 } else if (row
< -1) {
1062 gtk_list_store_insert_after(list_store
, &iter
, &sibling
);
1063 gtk_list_store_set(list_store
, &iter
,
1064 PREFS_ACTIONS_STRING
, action
,
1065 PREFS_ACTIONS_DATA
, action
,
1066 PREFS_ACTIONS_VALID
, is_valid
,
1069 /* change existing */
1072 gtk_tree_model_get(GTK_TREE_MODEL(list_store
), &iter
,
1073 PREFS_ACTIONS_DATA
, &old_action
,
1077 gtk_list_store_set(list_store
, &iter
,
1078 PREFS_ACTIONS_STRING
, action
,
1079 PREFS_ACTIONS_DATA
, action
,
1084 static GtkActionGroup
*prefs_actions_popup_action
= NULL
;
1085 static GtkWidget
*prefs_actions_popup_menu
= NULL
;
1087 static GtkActionEntry prefs_actions_popup_entries
[] =
1089 {"PrefsActionsPopup", NULL
, "PrefsActionsPopup" },
1090 {"PrefsActionsPopup/Delete", NULL
, N_("_Delete"), NULL
, NULL
, G_CALLBACK(prefs_actions_delete_cb
) },
1091 {"PrefsActionsPopup/DeleteAll", NULL
, N_("Delete _all"), NULL
, NULL
, G_CALLBACK(prefs_actions_delete_all_cb
) },
1092 {"PrefsActionsPopup/Duplicate", NULL
, N_("D_uplicate"), NULL
, NULL
, G_CALLBACK(prefs_actions_duplicate_cb
) },
1095 static void prefs_actions_row_selected(GtkTreeSelection
*selection
, GtkTreeView
*list_view
)
1099 GtkTreeModel
*model
;
1101 if (!gtk_tree_selection_get_selected(selection
, &model
, &iter
))
1104 path
= gtk_tree_model_get_path(model
, &iter
);
1105 prefs_actions_select_row(list_view
, path
);
1106 gtk_tree_path_free(path
);
1109 static gint
prefs_actions_list_btn_pressed(GtkWidget
*widget
, GdkEventButton
*event
,
1110 GtkTreeView
*list_view
)
1113 /* left- or right-button click */
1114 if (event
->button
== 1 || event
->button
== 3) {
1115 GtkTreePath
*path
= NULL
;
1116 if (gtk_tree_view_get_path_at_pos( list_view
, event
->x
, event
->y
,
1117 &path
, NULL
, NULL
, NULL
)) {
1118 prefs_actions_select_row(list_view
, path
);
1121 gtk_tree_path_free(path
);
1124 /* right-button click */
1125 if (event
->button
== 3) {
1126 GtkTreeModel
*model
= gtk_tree_view_get_model(list_view
);
1131 if (!prefs_actions_popup_menu
) {
1132 prefs_actions_popup_action
= cm_menu_create_action_group("PrefsActionsPopup",
1133 prefs_actions_popup_entries
, G_N_ELEMENTS(prefs_actions_popup_entries
),
1134 (gpointer
)list_view
);
1135 MENUITEM_ADDUI("/Menus", "PrefsActionsPopup", "PrefsActionsPopup", GTK_UI_MANAGER_MENU
)
1136 MENUITEM_ADDUI("/Menus/PrefsActionsPopup", "Delete", "PrefsActionsPopup/Delete", GTK_UI_MANAGER_MENUITEM
)
1137 MENUITEM_ADDUI("/Menus/PrefsActionsPopup", "DeleteAll", "PrefsActionsPopup/DeleteAll", GTK_UI_MANAGER_MENUITEM
)
1138 MENUITEM_ADDUI("/Menus/PrefsActionsPopup", "Duplicate", "PrefsActionsPopup/Duplicate", GTK_UI_MANAGER_MENUITEM
)
1139 prefs_actions_popup_menu
= gtk_menu_item_get_submenu(GTK_MENU_ITEM(
1140 gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/PrefsActionsPopup")) );
1143 /* grey out some popup menu items if there is no selected row */
1144 row
= gtkut_list_view_get_selected_row(GTK_WIDGET(list_view
));
1145 cm_menu_set_sensitive("PrefsActionsPopup/Delete", (row
> 0));
1146 cm_menu_set_sensitive("PrefsActionsPopup/Duplicate", (row
> 0));
1148 /* grey out seom popup menu items if there is no row
1149 (not counting the (New) one at row 0) */
1150 non_empty
= gtk_tree_model_get_iter_first(model
, &iter
);
1152 non_empty
= gtk_tree_model_iter_next(model
, &iter
);
1153 cm_menu_set_sensitive("PrefsActionsPopup/DeleteAll", non_empty
);
1155 gtk_menu_popup(GTK_MENU(prefs_actions_popup_menu
),
1156 NULL
, NULL
, NULL
, NULL
,
1157 event
->button
, event
->time
);
1163 static gboolean
prefs_actions_list_popup_menu(GtkWidget
*widget
, gpointer data
)
1165 GtkTreeView
*list_view
= (GtkTreeView
*)data
;
1166 GdkEventButton event
;
1169 event
.time
= gtk_get_current_event_time();
1171 prefs_actions_list_btn_pressed(NULL
, &event
, list_view
);
1176 static GtkWidget
*prefs_actions_list_view_create(void)
1178 GtkTreeView
*list_view
;
1179 GtkTreeSelection
*selector
;
1180 GtkTreeModel
*model
;
1182 model
= GTK_TREE_MODEL(prefs_actions_create_data_store());
1183 list_view
= GTK_TREE_VIEW(gtk_tree_view_new_with_model(model
));
1184 g_object_unref(model
);
1186 g_signal_connect(G_OBJECT(list_view
), "popup-menu",
1187 G_CALLBACK(prefs_actions_list_popup_menu
), list_view
);
1188 g_signal_connect(G_OBJECT(list_view
), "button-press-event",
1189 G_CALLBACK(prefs_actions_list_btn_pressed
), list_view
);
1191 gtk_tree_view_set_rules_hint(list_view
, prefs_common
.use_stripes_everywhere
);
1192 gtk_tree_view_set_reorderable(list_view
, TRUE
);
1194 selector
= gtk_tree_view_get_selection(list_view
);
1195 gtk_tree_selection_set_mode(selector
, GTK_SELECTION_BROWSE
);
1196 g_signal_connect(G_OBJECT(selector
), "changed",
1197 G_CALLBACK(prefs_actions_row_selected
), list_view
);
1199 /* create the columns */
1200 prefs_actions_create_list_view_columns(GTK_WIDGET(list_view
));
1202 return GTK_WIDGET(list_view
);
1205 static void prefs_actions_create_list_view_columns(GtkWidget
*list_view
)
1207 GtkTreeViewColumn
*column
;
1208 GtkCellRenderer
*renderer
;
1210 renderer
= gtk_cell_renderer_text_new();
1211 column
= gtk_tree_view_column_new_with_attributes
1212 (_("Current actions"),
1214 "text", PREFS_ACTIONS_STRING
,
1216 gtk_tree_view_append_column(GTK_TREE_VIEW(list_view
), column
);
1217 gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(list_view
), prefs_actions_search_func_cb
, NULL
, NULL
);
1220 #define ENTRY_SET_TEXT(entry, str) \
1221 gtk_entry_set_text(GTK_ENTRY(entry), str ? str : "")
1223 static void prefs_actions_select_row(GtkTreeView
*list_view
, GtkTreePath
*path
)
1225 GtkTreeModel
*model
= gtk_tree_view_get_model(list_view
);
1226 GtkTreeSelection
*selection
;
1229 gchar buf
[PREFSBUFSIZE
];
1233 if (!model
|| !path
|| !gtk_tree_model_get_iter(model
, &iter
, path
))
1237 selection
= gtk_tree_view_get_selection(list_view
);
1238 gtk_tree_selection_select_path(selection
, path
);
1240 gtk_tree_model_get(model
, &iter
,
1241 PREFS_ACTIONS_VALID
, &is_valid
,
1242 PREFS_ACTIONS_DATA
, &action
,
1245 prefs_actions_reset_dialog();
1249 strncpy(buf
, action
, PREFSBUFSIZE
- 1);
1250 buf
[PREFSBUFSIZE
- 1] = '\0';
1251 cmd
= strstr(buf
, ": ");
1254 ENTRY_SET_TEXT(actions
.cmd_entry
, &cmd
[2]);
1259 gtk_entry_set_text(GTK_ENTRY(actions
.name_entry
), buf
);
1261 if (g_str_has_prefix(&cmd
[2], "%as{") == TRUE
)
1262 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
1263 actions
.filter_radiobtn
), TRUE
);
1265 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
1266 actions
.shell_radiobtn
), TRUE
);
1271 static void prefs_action_filter_radiobtn_cb(GtkWidget
*widget
, gpointer data
)
1273 if (actions
.filter_btn
)
1274 gtk_widget_set_sensitive(actions
.filter_btn
, TRUE
);
1275 if (actions
.cmd_entry
)
1276 gtk_widget_set_sensitive(actions
.cmd_entry
, FALSE
);
1277 if (actions
.info_btn
)
1278 gtk_widget_set_sensitive(actions
.info_btn
, FALSE
);
1281 static void prefs_action_shell_radiobtn_cb(GtkWidget
*widget
, gpointer data
)
1283 if (actions
.filter_btn
)
1284 gtk_widget_set_sensitive(actions
.filter_btn
, FALSE
);
1285 if (actions
.cmd_entry
)
1286 gtk_widget_set_sensitive(actions
.cmd_entry
, TRUE
);
1287 if (actions
.info_btn
)
1288 gtk_widget_set_sensitive(actions
.info_btn
, TRUE
);
1291 static void prefs_action_filterbtn_cb(GtkWidget
*widget
, gpointer data
)
1293 gchar
*action_str
, **tokens
;
1294 GSList
*action_list
= NULL
, *cur
;
1296 /* I think this warning is useless - it's logical to clear the field when
1299 if(modified && alertpanel(_("Entry was modified"),
1300 _("Opening the filter action dialog will clear current modifications "
1301 "of the command line."),
1302 GTK_STOCK_CANCEL, _("+_Continue editing"), NULL) != G_ALERTDEFAULT)
1305 action_str
= gtk_editable_get_chars(GTK_EDITABLE(actions
.cmd_entry
), 0, -1);
1306 tokens
= g_strsplit_set(action_str
, "{}", 5);
1308 if (tokens
[0] && tokens
[1] && *tokens
[1] != '\0') {
1309 action_list
= matcher_parser_get_action_list(tokens
[1]);
1310 if (action_list
== NULL
)
1311 alertpanel_error(_("Action string is not valid."));
1314 prefs_filtering_action_open(action_list
, prefs_action_define_filter_done
);
1316 if (action_list
!= NULL
) {
1317 for(cur
= action_list
; cur
!= NULL
; cur
= cur
->next
)
1318 filteringaction_free(cur
->data
);
1325 static void prefs_action_define_filter_done(GSList
* action_list
)
1329 if (action_list
== NULL
)
1332 action_list
= filtering_action_list_sort(action_list
);
1333 str
= filteringaction_list_to_string(action_list
);
1337 cmd
= g_strdup_printf("%%as{%s}",str
);
1339 gtk_entry_set_text(GTK_ENTRY(actions
.cmd_entry
), cmd
);
1345 void prefs_actions_rename_path(const gchar
*old_path
, const gchar
*new_path
)
1347 gchar
**tokens
, *action_str
;
1348 GSList
*action
, *action_list
;
1350 for (action
= prefs_common
.actions_list
; action
!= NULL
;
1351 action
= action
->next
) {
1352 action_str
= (gchar
*)action
->data
;
1353 tokens
= g_strsplit_set(action_str
, "{}", 5);
1355 if (tokens
[0] && tokens
[1] && *tokens
[1] != '\0')
1356 action_list
= matcher_parser_get_action_list(tokens
[1]);
1361 filtering_action_list_rename_path(action_list
,
1362 old_path
, new_path
)) {
1363 g_free(action
->data
);
1364 action
->data
= g_strconcat(tokens
[0], "{",
1365 filteringaction_list_to_string(action_list
),
1373 gint
prefs_actions_find_by_name(const gchar
*name
)
1375 GSList
*act
= prefs_common
.actions_list
;
1376 gchar
*action_name
, *action_p
;
1379 for (; act
!= NULL
; act
= act
->next
) {
1380 action_name
= g_strdup((gchar
*)act
->data
);
1381 action_p
= strstr(action_name
, ": ");
1384 if (g_utf8_collate(name
, action_name
) == 0) {
1385 g_free(action_name
);
1389 g_free(action_name
);