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"
54 #include "file-utils.h"
57 PREFS_ACTIONS_STRING
, /*!< string pointer managed by list store,
58 * and never touched or retrieved by
60 PREFS_ACTIONS_DATA
, /*!< pointer to string that is not managed by
61 * the list store, and which is retrieved
62 * and touched by us */
63 PREFS_ACTIONS_VALID
, /*!< contains a valid action, otherwise "(New)" */
64 N_PREFS_ACTIONS_COLUMNS
72 GtkWidget
*filter_btn
;
73 GtkWidget
*name_entry
;
76 GtkWidget
*shell_radiobtn
;
77 GtkWidget
*filter_radiobtn
;
79 GtkWidget
*actions_list_view
;
82 static int modified
= FALSE
;
83 static int modified_list
= FALSE
;
85 /* widget creating functions */
86 static void prefs_actions_create (MainWindow
*mainwin
);
87 static void prefs_actions_set_dialog (void);
88 static gint
prefs_actions_clist_set_row (gint row
);
90 /* callback functions */
91 static void prefs_actions_info_cb (GtkWidget
*w
,
93 static void prefs_actions_register_cb (GtkWidget
*w
,
95 static void prefs_actions_substitute_cb (GtkWidget
*w
,
97 static void prefs_actions_delete_cb (gpointer gtk_action
, gpointer data
);
98 static void prefs_actions_delete_all_cb (gpointer gtk_action
, gpointer data
);
99 static void prefs_actions_clear_cb (gpointer gtk_action
, gpointer data
);
100 static void prefs_actions_duplicate_cb (gpointer gtk_action
, gpointer data
);
101 static void prefs_actions_up (GtkWidget
*w
,
103 static void prefs_actions_down (GtkWidget
*w
,
105 static gint
prefs_actions_deleted (GtkWidget
*widget
,
108 static gboolean
prefs_actions_key_pressed(GtkWidget
*widget
,
111 static gboolean
prefs_actions_search_func_cb (GtkTreeModel
*model
, gint column
,
112 const gchar
*key
, GtkTreeIter
*iter
,
113 gpointer search_data
);
114 static void prefs_actions_cancel (GtkWidget
*w
,
116 static void prefs_actions_ok (GtkWidget
*w
,
119 static GtkListStore
* prefs_actions_create_data_store (void);
121 static void prefs_actions_list_view_insert_action (GtkWidget
*list_view
,
125 static GtkWidget
*prefs_actions_list_view_create (void);
126 static void prefs_actions_create_list_view_columns (GtkWidget
*list_view
);
127 static void prefs_actions_select_row(GtkTreeView
*list_view
, GtkTreePath
*path
);
129 static void prefs_action_filter_radiobtn_cb(GtkWidget
*widget
, gpointer data
);
130 static void prefs_action_shell_radiobtn_cb(GtkWidget
*widget
, gpointer data
);
131 static void prefs_action_filterbtn_cb(GtkWidget
*widget
, gpointer data
);
132 static void prefs_action_define_filter_done(GSList
* action_list
);
135 void prefs_actions_open(MainWindow
*mainwin
)
140 prefs_actions_create(mainwin
);
142 manage_window_set_transient(GTK_WINDOW(actions
.window
));
143 gtk_widget_grab_focus(actions
.ok_btn
);
145 prefs_actions_set_dialog();
147 gtk_widget_show(actions
.window
);
148 gtk_window_set_modal(GTK_WINDOW(actions
.window
), TRUE
);
152 *\brief Save Gtk object size to prefs dataset
154 static void prefs_actions_size_allocate_cb(GtkWidget
*widget
,
155 GtkAllocation
*allocation
)
157 cm_return_if_fail(allocation
!= NULL
);
159 prefs_common
.actionswin_width
= allocation
->width
;
160 prefs_common
.actionswin_height
= allocation
->height
;
163 static void prefs_actions_create(MainWindow
*mainwin
)
167 GtkWidget
*filter_hbox
;
170 GtkWidget
*cancel_btn
;
171 GtkWidget
*confirm_area
;
176 GtkWidget
*shell_radiobtn
;
177 GtkWidget
*filter_radiobtn
;
179 GtkWidget
*name_label
;
180 GtkWidget
*name_entry
;
181 GtkWidget
*cmd_label
;
182 GtkWidget
*cmd_entry
;
183 GtkWidget
*filter_btn
;
189 GtkWidget
*subst_btn
;
191 GtkWidget
*clear_btn
;
193 GtkWidget
*cond_hbox
;
194 GtkWidget
*cond_scrolledwin
;
195 GtkWidget
*cond_list_view
;
202 static GdkGeometry geometry
;
204 debug_print("Creating actions configuration window...\n");
206 window
= gtkut_window_new(GTK_WINDOW_TOPLEVEL
, "prefs_actions");
208 gtk_container_set_border_width(GTK_CONTAINER (window
), 8);
209 gtk_window_set_position(GTK_WINDOW(window
), GTK_WIN_POS_CENTER
);
210 gtk_window_set_resizable(GTK_WINDOW(window
), TRUE
);
212 vbox
= gtk_vbox_new(FALSE
, 6);
213 gtk_widget_show(vbox
);
214 gtk_container_add(GTK_CONTAINER(window
), vbox
);
216 gtkut_stock_button_set_create_with_help(&confirm_area
, &help_btn
,
217 &cancel_btn
, GTK_STOCK_CANCEL
,
218 &ok_btn
, GTK_STOCK_OK
,
220 gtk_widget_show(confirm_area
);
221 gtk_box_pack_end(GTK_BOX(vbox
), confirm_area
, FALSE
, FALSE
, 0);
222 gtk_widget_grab_default(ok_btn
);
224 gtk_window_set_title(GTK_WINDOW(window
), _("Actions configuration"));
225 g_signal_connect(G_OBJECT(window
), "delete_event",
226 G_CALLBACK(prefs_actions_deleted
), NULL
);
227 g_signal_connect(G_OBJECT(window
), "size_allocate",
228 G_CALLBACK(prefs_actions_size_allocate_cb
), NULL
);
229 g_signal_connect(G_OBJECT(window
), "key_press_event",
230 G_CALLBACK(prefs_actions_key_pressed
), NULL
);
231 MANAGE_WINDOW_SIGNALS_CONNECT(window
);
232 g_signal_connect(G_OBJECT(ok_btn
), "clicked",
233 G_CALLBACK(prefs_actions_ok
), mainwin
);
234 g_signal_connect(G_OBJECT(cancel_btn
), "clicked",
235 G_CALLBACK(prefs_actions_cancel
), NULL
);
236 g_signal_connect(G_OBJECT(help_btn
), "clicked",
237 G_CALLBACK(manual_open_with_anchor_cb
),
238 MANUAL_ANCHOR_ACTIONS
);
240 vbox1
= gtk_vbox_new(FALSE
, VSPACING
);
241 gtk_widget_show(vbox1
);
242 gtk_box_pack_start(GTK_BOX(vbox
), vbox1
, TRUE
, TRUE
, 0);
243 gtk_container_set_border_width(GTK_CONTAINER(vbox1
), 2);
245 table
= gtk_table_new(3, 2, FALSE
);
246 gtk_table_set_row_spacings (GTK_TABLE (table
), VSPACING_NARROW_2
);
247 gtk_table_set_col_spacings (GTK_TABLE (table
), 4);
248 gtk_widget_show(table
);
249 gtk_box_pack_start (GTK_BOX (vbox1
), table
, FALSE
, FALSE
, 0);
251 name_label
= gtk_label_new (_("Menu name"));
252 gtk_widget_show (name_label
);
253 gtk_misc_set_alignment (GTK_MISC (name_label
), 1, 0.5);
254 gtk_table_attach (GTK_TABLE (table
), name_label
, 0, 1, 0, 1,
255 (GtkAttachOptions
) (GTK_FILL
),
256 (GtkAttachOptions
) (0), 0, 0);
258 name_entry
= gtk_entry_new ();
259 gtk_widget_show (name_entry
);
260 gtk_table_attach (GTK_TABLE (table
), name_entry
, 1, 2, 0, 1,
261 (GtkAttachOptions
) (GTK_FILL
|GTK_EXPAND
),
262 (GtkAttachOptions
) (0), 0, 0);
264 cmd_label
= gtk_label_new (_("Command"));
265 gtk_widget_show (cmd_label
);
266 gtk_misc_set_alignment (GTK_MISC (cmd_label
), 1, 0.5);
267 gtk_table_attach (GTK_TABLE (table
), cmd_label
, 0, 1, 2, 3,
268 (GtkAttachOptions
) (GTK_FILL
),
269 (GtkAttachOptions
) (0), 0, 0);
271 cmd_entry
= gtk_entry_new ();
272 gtk_widget_show (cmd_entry
);
273 gtk_table_attach (GTK_TABLE (table
), cmd_entry
, 1, 2, 2, 3,
274 (GtkAttachOptions
) (GTK_FILL
|GTK_EXPAND
),
275 (GtkAttachOptions
) (0), 0, 0);
277 /* radio buttons for filter actions or shell */
278 filter_hbox
= gtk_hbox_new(FALSE
,4);
279 gtk_table_attach(GTK_TABLE(table
), filter_hbox
, 1, 2, 3, 4,
280 (GtkAttachOptions
) (GTK_FILL
|GTK_EXPAND
),
281 (GtkAttachOptions
) (0), 0, 0);
282 gtk_widget_show(filter_hbox
);
284 shell_radiobtn
= gtk_radio_button_new_with_label(NULL
, _("Shell command"));
285 gtk_box_pack_start(GTK_BOX(filter_hbox
), shell_radiobtn
, FALSE
, FALSE
, 0);
286 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(shell_radiobtn
), TRUE
);
287 gtk_widget_show(shell_radiobtn
);
289 g_signal_connect(G_OBJECT(shell_radiobtn
), "clicked",
290 G_CALLBACK(prefs_action_shell_radiobtn_cb
), NULL
);
293 gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(shell_radiobtn
),
295 gtk_box_pack_start(GTK_BOX(filter_hbox
), filter_radiobtn
, FALSE
, FALSE
, 0);
296 gtk_widget_show(filter_radiobtn
);
297 g_signal_connect(G_OBJECT(filter_radiobtn
), "clicked",
298 G_CALLBACK(prefs_action_filter_radiobtn_cb
), NULL
);
300 filter_btn
= gtk_button_new_with_label(_("Edit filter action"));
301 gtk_box_pack_start(GTK_BOX(filter_hbox
), filter_btn
, FALSE
, FALSE
, 0);
302 gtk_widget_set_sensitive(filter_btn
, FALSE
);
303 g_signal_connect(G_OBJECT(filter_btn
), "clicked",
304 G_CALLBACK(prefs_action_filterbtn_cb
), NULL
);
305 gtk_widget_show(filter_btn
);
307 /* register / substitute / delete */
309 reg_hbox
= gtk_hbox_new(FALSE
, 4);
310 gtk_widget_show(reg_hbox
);
311 gtk_box_pack_start(GTK_BOX(vbox1
), reg_hbox
, FALSE
, FALSE
, 0);
313 arrow
= gtk_arrow_new(GTK_ARROW_DOWN
, GTK_SHADOW_OUT
);
314 gtk_widget_show(arrow
);
315 gtk_box_pack_start(GTK_BOX(reg_hbox
), arrow
, FALSE
, FALSE
, 0);
316 gtk_widget_set_size_request(arrow
, -1, 16);
318 btn_hbox
= gtk_hbox_new(TRUE
, 4);
319 gtk_widget_show(btn_hbox
);
320 gtk_box_pack_start(GTK_BOX(reg_hbox
), btn_hbox
, FALSE
, FALSE
, 0);
322 reg_btn
= gtk_button_new_from_stock(GTK_STOCK_ADD
);
323 gtk_widget_show(reg_btn
);
324 gtk_box_pack_start(GTK_BOX(btn_hbox
), reg_btn
, FALSE
, TRUE
, 0);
325 g_signal_connect(G_OBJECT(reg_btn
), "clicked",
326 G_CALLBACK(prefs_actions_register_cb
), NULL
);
327 CLAWS_SET_TIP(reg_btn
,
328 _("Append the new action above to the list"));
330 subst_btn
= gtkut_get_replace_btn(_("_Replace"));
331 gtk_widget_show(subst_btn
);
332 gtk_box_pack_start(GTK_BOX(btn_hbox
), subst_btn
, FALSE
, TRUE
, 0);
333 g_signal_connect(G_OBJECT(subst_btn
), "clicked",
334 G_CALLBACK(prefs_actions_substitute_cb
), NULL
);
335 CLAWS_SET_TIP(subst_btn
,
336 _("Replace the selected action in list with the action above"));
338 del_btn
= gtk_button_new_with_mnemonic (_("D_elete"));
339 gtk_button_set_image(GTK_BUTTON(del_btn
),
340 gtk_image_new_from_stock(GTK_STOCK_REMOVE
,GTK_ICON_SIZE_BUTTON
));
341 gtk_widget_show(del_btn
);
342 gtk_box_pack_start(GTK_BOX(btn_hbox
), del_btn
, FALSE
, TRUE
, 0);
343 g_signal_connect(G_OBJECT(del_btn
), "clicked",
344 G_CALLBACK(prefs_actions_delete_cb
), NULL
);
345 CLAWS_SET_TIP(del_btn
,
346 _("Delete the selected action from the list"));
348 clear_btn
= gtk_button_new_with_mnemonic (_("C_lear"));
349 gtk_button_set_image(GTK_BUTTON(clear_btn
),
350 gtk_image_new_from_stock(GTK_STOCK_CLEAR
,GTK_ICON_SIZE_BUTTON
));
351 gtk_widget_show (clear_btn
);
352 gtk_box_pack_start (GTK_BOX (btn_hbox
), clear_btn
, FALSE
, TRUE
, 0);
353 g_signal_connect(G_OBJECT (clear_btn
), "clicked",
354 G_CALLBACK(prefs_actions_clear_cb
), NULL
);
355 CLAWS_SET_TIP(clear_btn
,
356 _("Clear all the input fields in the dialog"));
358 info_btn
= gtk_button_new_from_stock(GTK_STOCK_INFO
);
359 gtk_widget_show(info_btn
);
360 gtk_box_pack_end(GTK_BOX(reg_hbox
), info_btn
, FALSE
, FALSE
, 0);
361 g_signal_connect(G_OBJECT(info_btn
), "clicked",
362 G_CALLBACK(prefs_actions_info_cb
), GTK_WINDOW(window
));
363 CLAWS_SET_TIP(info_btn
,
364 _("Show information on configuring actions"));
366 cond_hbox
= gtk_hbox_new(FALSE
, 8);
367 gtk_widget_show(cond_hbox
);
368 gtk_box_pack_start(GTK_BOX(vbox1
), cond_hbox
, TRUE
, TRUE
, 0);
370 cond_scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
371 gtk_widget_show(cond_scrolledwin
);
372 gtk_widget_set_size_request(cond_scrolledwin
, -1, 150);
373 gtk_box_pack_start(GTK_BOX(cond_hbox
), cond_scrolledwin
,
375 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (cond_scrolledwin
),
376 GTK_POLICY_AUTOMATIC
,
377 GTK_POLICY_AUTOMATIC
);
378 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(cond_scrolledwin
),
379 GTK_SHADOW_ETCHED_IN
);
381 cond_list_view
= prefs_actions_list_view_create();
382 gtk_widget_show(cond_list_view
);
383 gtk_container_add(GTK_CONTAINER (cond_scrolledwin
), cond_list_view
);
385 btn_vbox
= gtk_vbox_new(FALSE
, 8);
386 gtk_widget_show(btn_vbox
);
387 gtk_box_pack_start(GTK_BOX(cond_hbox
), btn_vbox
, FALSE
, FALSE
, 0);
389 up_btn
= gtk_button_new_from_stock(GTK_STOCK_GO_UP
);
390 gtk_widget_show(up_btn
);
391 gtk_box_pack_start(GTK_BOX(btn_vbox
), up_btn
, FALSE
, FALSE
, 0);
392 g_signal_connect(G_OBJECT(up_btn
), "clicked",
393 G_CALLBACK(prefs_actions_up
), NULL
);
394 CLAWS_SET_TIP(up_btn
,
395 _("Move the selected action up"));
397 down_btn
= gtk_button_new_from_stock(GTK_STOCK_GO_DOWN
);
398 gtk_widget_show(down_btn
);
399 gtk_box_pack_start(GTK_BOX(btn_vbox
), down_btn
, FALSE
, FALSE
, 0);
400 g_signal_connect(G_OBJECT(down_btn
), "clicked",
401 G_CALLBACK(prefs_actions_down
), NULL
);
402 CLAWS_SET_TIP(down_btn
,
403 _("Move selected action down"));
405 if (!geometry
.min_height
) {
406 geometry
.min_width
= 486;
407 geometry
.min_height
= 322;
410 gtk_window_set_geometry_hints(GTK_WINDOW(window
), NULL
, &geometry
,
412 gtk_widget_set_size_request(window
, prefs_common
.actionswin_width
,
413 prefs_common
.actionswin_height
);
415 gtk_widget_show(window
);
417 actions
.window
= window
;
418 actions
.ok_btn
= ok_btn
;
419 actions
.info_btn
= info_btn
;
421 actions
.name_entry
= name_entry
;
422 actions
.cmd_entry
= cmd_entry
;
423 actions
.filter_btn
= filter_btn
;
424 actions
.shell_radiobtn
= shell_radiobtn
;
425 actions
.filter_radiobtn
= filter_radiobtn
;
427 actions
.actions_list_view
= cond_list_view
;
430 static void prefs_actions_reset_dialog(void)
432 gtk_entry_set_text(GTK_ENTRY(actions
.name_entry
), "");
433 gtk_entry_set_text(GTK_ENTRY(actions
.cmd_entry
), "");
434 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(actions
.shell_radiobtn
), TRUE
);
437 void prefs_actions_read_config(void)
441 gchar buf
[PREFSBUFSIZE
];
444 debug_print("Reading actions configurations...\n");
446 rcpath
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
, ACTIONS_RC
, NULL
);
447 if ((fp
= claws_fopen(rcpath
, "rb")) == NULL
) {
448 if (ENOENT
!= errno
) FILE_OP_ERROR(rcpath
, "claws_fopen");
454 while (prefs_common
.actions_list
!= NULL
) {
455 act
= (gchar
*)prefs_common
.actions_list
->data
;
456 prefs_common
.actions_list
=
457 g_slist_remove(prefs_common
.actions_list
, act
);
461 while (claws_fgets(buf
, sizeof(buf
), fp
) != NULL
) {
462 const gchar
*src_codeset
= conv_get_locale_charset_str();
463 const gchar
*dest_codeset
= CS_UTF_8
;
466 tmp
= conv_codeset_strdup(buf
, src_codeset
, dest_codeset
);
468 g_warning("Failed to convert character set of action configuration");
473 act
= strstr(tmp
, ": ");
475 action_get_type(&act
[2]) != ACTION_ERROR
)
476 prefs_common
.actions_list
=
477 g_slist_append(prefs_common
.actions_list
,
485 void prefs_actions_write_config(void)
491 debug_print("Writing actions configuration...\n");
493 rcpath
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
, ACTIONS_RC
, NULL
);
494 if ((pfile
= prefs_write_open(rcpath
)) == NULL
) {
495 g_warning("failed to write configuration to file");
500 for (cur
= prefs_common
.actions_list
; cur
!= NULL
; cur
= cur
->next
) {
501 gchar
*tmp
= (gchar
*)cur
->data
;
502 const gchar
*src_codeset
= CS_UTF_8
;
503 const gchar
*dest_codeset
= conv_get_locale_charset_str();
506 act
= conv_codeset_strdup(tmp
, src_codeset
, dest_codeset
);
508 g_warning("Failed to convert character set of action configuration");
512 if (claws_fputs(act
, pfile
->fp
) == EOF
||
513 claws_fputc('\n', pfile
->fp
) == EOF
) {
514 FILE_OP_ERROR(rcpath
, "claws_fputs || claws_fputc");
515 prefs_file_close_revert(pfile
);
525 if (prefs_file_close(pfile
) < 0) {
526 g_warning("failed to write configuration to file");
531 static void prefs_actions_clear_list(GtkListStore
*list_store
)
533 gtk_list_store_clear(list_store
);
535 prefs_actions_list_view_insert_action(actions
.actions_list_view
,
536 -1, _("(New)"), FALSE
);
539 static void prefs_actions_set_dialog(void)
544 store
= GTK_LIST_STORE(gtk_tree_view_get_model
545 (GTK_TREE_VIEW(actions
.actions_list_view
)));
547 prefs_actions_clear_list(store
);
548 prefs_actions_reset_dialog();
550 for (cur
= prefs_common
.actions_list
; cur
!= NULL
; cur
= cur
->next
) {
551 gchar
*action
= (gchar
*) cur
->data
;
553 prefs_actions_list_view_insert_action(actions
.actions_list_view
,
558 static void prefs_actions_set_list(void)
563 g_slist_free(prefs_common
.actions_list
);
564 prefs_common
.actions_list
= NULL
;
566 store
= GTK_LIST_STORE(gtk_tree_view_get_model
567 (GTK_TREE_VIEW(actions
.actions_list_view
)));
569 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store
), &iter
)) {
574 gtk_tree_model_get(GTK_TREE_MODEL(store
), &iter
,
575 PREFS_ACTIONS_DATA
, &action
,
576 PREFS_ACTIONS_VALID
, &is_valid
,
580 prefs_common
.actions_list
=
581 g_slist_append(prefs_common
.actions_list
,
584 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(store
),
589 #define GET_ENTRY(entry) \
590 entry_text = gtk_entry_get_text(GTK_ENTRY(entry))
592 static gint
prefs_actions_clist_set_row(gint row
)
594 const gchar
*entry_text
;
596 gchar action
[PREFSBUFSIZE
];
599 GET_ENTRY(actions
.name_entry
);
600 if (entry_text
[0] == '\0') {
601 alertpanel_error(_("Menu name is not set."));
605 if (entry_text
[0] == '/') {
606 alertpanel_error(_("A leading '/' is not allowed in the menu name."));
610 if (strchr(entry_text
, ':')) {
611 alertpanel_error(_("Colon ':' is not allowed in the menu name."));
615 strncpy(action
, entry_text
, PREFSBUFSIZE
- 1);
617 while (strstr(action
, "//")) {
618 char *to_move
= strstr(action
, "//")+1;
619 char *where
= strstr(action
, "//");
620 int old_len
= strlen(action
);
621 memmove(where
, to_move
, strlen(to_move
));
622 action
[old_len
-1] = '\0';
627 /* Keep space for the ': ' delimiter */
628 len
= strlen(action
) + 2;
629 if (len
>= PREFSBUFSIZE
- 1) {
630 alertpanel_error(_("Menu name is too long."));
634 strcat(action
, ": ");
636 GET_ENTRY(actions
.cmd_entry
);
638 if (entry_text
[0] == '\0') {
639 alertpanel_error(_("Command-line not set."));
643 if (len
+ strlen(entry_text
) >= PREFSBUFSIZE
- 1) {
644 alertpanel_error(_("Menu name and command are too long."));
648 if (action_get_type(entry_text
) == ACTION_ERROR
) {
650 message
= g_markup_printf_escaped(_("The command\n%s\nhas a syntax error."),
652 alertpanel_error("%s", message
);
657 strcat(action
, entry_text
);
659 new_action
= g_strdup(action
);
660 prefs_actions_list_view_insert_action(actions
.actions_list_view
,
661 row
, new_action
, TRUE
);
663 prefs_actions_set_list();
668 /* callback functions */
670 static void prefs_actions_register_cb(GtkWidget
*w
, gpointer data
)
672 prefs_actions_clist_set_row(-1);
675 modified_list
= TRUE
;
678 static void prefs_actions_substitute_cb(GtkWidget
*w
, gpointer data
)
682 row
= gtkut_list_view_get_selected_row(actions
.actions_list_view
);
686 prefs_actions_clist_set_row(row
);
689 modified_list
= TRUE
;
692 static void prefs_actions_delete_cb(gpointer gtk_action
, gpointer data
)
699 row
= gtkut_list_view_get_selected_row(actions
.actions_list_view
);
703 if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection
704 (GTK_TREE_VIEW(actions
.actions_list_view
)),
708 if (alertpanel(_("Delete action"),
709 _("Do you really want to delete this action?"),
710 GTK_STOCK_CANCEL
, GTK_STOCK_DELETE
, NULL
, ALERTFOCUS_FIRST
) != G_ALERTALTERNATE
)
713 /* XXX: Here's the reason why we need to store the original
714 * pointer: we search the slist for it. */
715 gtk_tree_model_get(model
, &sel
,
716 PREFS_ACTIONS_DATA
, &action
,
718 gtk_list_store_remove(GTK_LIST_STORE(model
), &sel
);
720 prefs_common
.actions_list
= g_slist_remove(prefs_common
.actions_list
,
722 modified_list
= TRUE
;
725 static void prefs_actions_delete_all_cb(gpointer gtk_action
, gpointer data
)
727 GtkListStore
*list_store
;
729 if (alertpanel(_("Delete all actions"),
730 _("Do you really want to delete all the actions?"),
731 GTK_STOCK_CANCEL
, GTK_STOCK_DELETE
, NULL
, ALERTFOCUS_FIRST
) != G_ALERTDEFAULT
)
734 list_store
= GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(actions
.actions_list_view
)));
735 prefs_actions_clear_list(list_store
);
738 prefs_actions_reset_dialog();
739 modified_list
= TRUE
;
742 static void prefs_actions_clear_cb(gpointer gtk_action
, gpointer data
)
746 prefs_actions_reset_dialog();
747 row
= gtkut_list_view_get_selected_row(actions
.actions_list_view
);
754 static void prefs_actions_duplicate_cb(gpointer gtk_action
, gpointer data
)
758 row
= gtkut_list_view_get_selected_row(actions
.actions_list_view
);
762 modified_list
= !prefs_actions_clist_set_row(-row
-2);
765 static void prefs_actions_up(GtkWidget
*w
, gpointer data
)
767 GtkTreePath
*prev
, *sel
, *try;
769 GtkListStore
*store
= NULL
;
770 GtkTreeModel
*model
= NULL
;
773 if (!gtk_tree_selection_get_selected
774 (gtk_tree_view_get_selection
775 (GTK_TREE_VIEW(actions
.actions_list_view
)),
779 store
= (GtkListStore
*)model
;
780 sel
= gtk_tree_model_get_path(GTK_TREE_MODEL(store
), &isel
);
784 /* no move if we're at row 0 or 1, looks phony, but other
785 * solutions are more convoluted... */
786 try = gtk_tree_path_copy(sel
);
787 if (!gtk_tree_path_prev(try) || !gtk_tree_path_prev(try)) {
788 gtk_tree_path_free(try);
789 gtk_tree_path_free(sel
);
792 gtk_tree_path_free(try);
794 prev
= gtk_tree_path_copy(sel
);
795 if (!gtk_tree_path_prev(prev
)) {
796 gtk_tree_path_free(prev
);
797 gtk_tree_path_free(sel
);
801 gtk_tree_model_get_iter(GTK_TREE_MODEL(store
),
803 gtk_tree_path_free(sel
);
804 gtk_tree_path_free(prev
);
806 gtk_list_store_swap(store
, &iprev
, &isel
);
807 prefs_actions_set_list();
808 modified_list
= TRUE
;
811 static void prefs_actions_down(GtkWidget
*w
, gpointer data
)
813 GtkListStore
*store
= NULL
;
814 GtkTreeModel
*model
= NULL
;
815 GtkTreeIter next
, sel
;
818 if (!gtk_tree_selection_get_selected
819 (gtk_tree_view_get_selection
820 (GTK_TREE_VIEW(actions
.actions_list_view
)),
824 store
= (GtkListStore
*)model
;
825 try = gtk_tree_model_get_path(GTK_TREE_MODEL(store
), &sel
);
829 /* no move when we're at row 0 */
830 if (!gtk_tree_path_prev(try)) {
831 gtk_tree_path_free(try);
834 gtk_tree_path_free(try);
837 if (!gtk_tree_model_iter_next(GTK_TREE_MODEL(store
), &next
))
840 gtk_list_store_swap(store
, &next
, &sel
);
841 prefs_actions_set_list();
842 modified_list
= TRUE
;
845 static gint
prefs_actions_deleted(GtkWidget
*widget
, GdkEventAny
*event
,
848 prefs_actions_cancel(widget
, data
);
852 static gboolean
prefs_actions_key_pressed(GtkWidget
*widget
, GdkEventKey
*event
,
855 if (event
&& event
->keyval
== GDK_KEY_Escape
)
856 prefs_actions_cancel(widget
, data
);
858 GtkWidget
*focused
= gtkut_get_focused_child(
859 GTK_CONTAINER(widget
));
860 if (focused
&& GTK_IS_EDITABLE(focused
))
866 static gboolean
prefs_actions_search_func_cb (GtkTreeModel
*model
, gint column
, const gchar
*key
,
867 GtkTreeIter
*iter
, gpointer search_data
)
873 gtk_tree_model_get (model
, iter
, column
, &store_string
, -1);
875 if (!store_string
|| !key
)
879 retval
= (strncmp (key
, store_string
, strlen(key
)) != 0);
881 g_free(store_string
);
882 debug_print("selecting row\n");
883 path
= gtk_tree_model_get_path(model
, iter
);
884 prefs_actions_select_row(GTK_TREE_VIEW(actions
.actions_list_view
), path
);
885 gtk_tree_path_free(path
);
889 static void prefs_actions_cancel(GtkWidget
*w
, gpointer data
)
893 if (modified
&& alertpanel(_("Entry not saved"),
894 _("The entry was not saved. Close anyway?"),
895 GTK_STOCK_CLOSE
, _("_Continue editing"), NULL
,
896 ALERTFOCUS_SECOND
) != G_ALERTDEFAULT
) {
898 } else if (modified_list
&& alertpanel(_("Actions list not saved"),
899 _("The actions list has been modified. Close anyway?"),
900 GTK_STOCK_CLOSE
, _("_Continue editing"), NULL
,
901 ALERTFOCUS_SECOND
) != G_ALERTDEFAULT
) {
905 modified_list
= FALSE
;
906 store
= GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW
907 (actions
.actions_list_view
)));
908 gtk_list_store_clear(store
);
909 prefs_actions_read_config();
910 gtk_widget_hide(actions
.window
);
911 gtk_window_set_modal(GTK_WINDOW(actions
.window
), FALSE
);
915 static void prefs_actions_ok(GtkWidget
*widget
, gpointer data
)
917 MainWindow
*mainwin
= (MainWindow
*) data
;
920 MessageView
*msgview
;
924 if (modified
&& alertpanel(_("Entry not saved"),
925 _("The entry was not saved. Close anyway?"),
926 GTK_STOCK_CLOSE
, _("_Continue editing"),
927 NULL
, ALERTFOCUS_SECOND
) != G_ALERTDEFAULT
) {
931 modified_list
= FALSE
;
932 prefs_actions_set_list();
933 store
= GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW
934 (actions
.actions_list_view
)));
935 gtk_list_store_clear(store
);
936 prefs_actions_write_config();
938 /* Update mainwindow actions menu */
939 main_window_update_actions_menu(mainwin
);
941 /* Update separated message view actions menu */
942 list
= messageview_get_msgview_list();
943 for (iter
= list
; iter
; iter
= iter
->next
) {
944 msgview
= (MessageView
*) iter
->data
;
945 messageview_update_actions_menu(msgview
);
948 /* Update compose windows actions menu */
949 list
= compose_get_compose_list();
950 for (iter
= list
; iter
; iter
= iter
->next
) {
951 compose
= (Compose
*) iter
->data
;
952 compose_update_actions_menu(compose
);
955 /* Update toolbars */
956 prefs_toolbar_update_action_btns();
958 gtk_widget_hide(actions
.window
);
959 gtk_window_set_modal(GTK_WINDOW(actions
.window
), FALSE
);
964 * Strings describing action format strings
966 * When adding new lines, remember to put one string for each line
968 static gchar
*actions_desc_strings
[] = {
969 N_("<span weight=\"bold\" underline=\"single\">Menu name:</span>"), NULL
,
970 N_("Use / in menu name to make submenus."), NULL
,
972 N_("<span weight=\"bold\" underline=\"single\">Command-line:</span>"), NULL
,
973 N_("<span weight=\"bold\">Begin with:</span>"), NULL
,
974 " |", N_("to send message body or selection to command's standard input"),
975 " >", N_("to send user provided text to command's standard input"),
976 " *", N_("to send user provided hidden text to command's standard input"),
977 N_("<span weight=\"bold\">End with:</span>"), NULL
,
978 " |", N_("to replace message body or selection with command's standard output"),
979 " >", N_("to insert command's standard output without replacing old text"),
980 " &", N_("to run command asynchronously"),
981 N_("<span weight=\"bold\">Use:</span>"), NULL
,
982 " %f", N_("for the file of the selected message in RFC822/2822 format "),
983 " %F", N_("for the list of the files of the selected messages in RFC822/2822 format"),
984 " %p", N_("for the file of the selected decoded message MIME part"),
985 " %u", N_("for a user provided argument"),
986 " %h", N_("for a user provided hidden argument (e.g. password)"),
987 " %s", N_("for the text selection"),
988 " %as{}", N_("apply filtering actions between {} to selected messages"),
989 " %%", N_("for a literal %"),
994 static DescriptionWindow actions_desc_win
= {
1000 N_("The Actions feature is a way for the user to launch "
1001 "external commands to process a complete message file or just "
1002 "one of its parts."),
1003 actions_desc_strings
1007 static void prefs_actions_info_cb(GtkWidget
*w
, GtkWidget
*window
)
1009 actions_desc_win
.parent
= window
;
1010 description_window_create(&actions_desc_win
);
1013 static GtkListStore
* prefs_actions_create_data_store(void)
1015 return gtk_list_store_new(N_PREFS_ACTIONS_COLUMNS
,
1022 static void prefs_actions_list_view_insert_action(GtkWidget
*list_view
,
1028 GtkTreeIter sibling
;
1029 GtkListStore
*list_store
= GTK_LIST_STORE(gtk_tree_view_get_model
1030 (GTK_TREE_VIEW(list_view
)));
1032 /* row -1 to add a new rule to store,
1033 row >=0 to change an existing row
1034 row <-1 insert a new row after (-row-2)
1037 /* modify the existing */
1038 if (!gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(list_store
),
1041 } else if (row
< -1 ) {
1042 if (!gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(list_store
),
1043 &sibling
, NULL
, -row
-2))
1049 gtk_list_store_append(list_store
, &iter
);
1050 gtk_list_store_set(list_store
, &iter
,
1051 PREFS_ACTIONS_STRING
, action
,
1052 PREFS_ACTIONS_DATA
, action
,
1053 PREFS_ACTIONS_VALID
, is_valid
,
1055 } else if (row
< -1) {
1057 gtk_list_store_insert_after(list_store
, &iter
, &sibling
);
1058 gtk_list_store_set(list_store
, &iter
,
1059 PREFS_ACTIONS_STRING
, action
,
1060 PREFS_ACTIONS_DATA
, action
,
1061 PREFS_ACTIONS_VALID
, is_valid
,
1064 /* change existing */
1067 gtk_tree_model_get(GTK_TREE_MODEL(list_store
), &iter
,
1068 PREFS_ACTIONS_DATA
, &old_action
,
1072 gtk_list_store_set(list_store
, &iter
,
1073 PREFS_ACTIONS_STRING
, action
,
1074 PREFS_ACTIONS_DATA
, action
,
1079 static GtkActionGroup
*prefs_actions_popup_action
= NULL
;
1080 static GtkWidget
*prefs_actions_popup_menu
= NULL
;
1082 static GtkActionEntry prefs_actions_popup_entries
[] =
1084 {"PrefsActionsPopup", NULL
, "PrefsActionsPopup", NULL
, NULL
, NULL
},
1085 {"PrefsActionsPopup/Delete", NULL
, N_("_Delete"), NULL
, NULL
, G_CALLBACK(prefs_actions_delete_cb
) },
1086 {"PrefsActionsPopup/DeleteAll", NULL
, N_("Delete _all"), NULL
, NULL
, G_CALLBACK(prefs_actions_delete_all_cb
) },
1087 {"PrefsActionsPopup/Duplicate", NULL
, N_("D_uplicate"), NULL
, NULL
, G_CALLBACK(prefs_actions_duplicate_cb
) },
1090 static void prefs_actions_row_selected(GtkTreeSelection
*selection
, GtkTreeView
*list_view
)
1094 GtkTreeModel
*model
;
1096 if (!gtk_tree_selection_get_selected(selection
, &model
, &iter
))
1099 path
= gtk_tree_model_get_path(model
, &iter
);
1100 prefs_actions_select_row(list_view
, path
);
1101 gtk_tree_path_free(path
);
1104 static gint
prefs_actions_list_btn_pressed(GtkWidget
*widget
, GdkEventButton
*event
,
1105 GtkTreeView
*list_view
)
1108 /* left- or right-button click */
1109 if (event
->button
== 1 || event
->button
== 3) {
1110 GtkTreePath
*path
= NULL
;
1111 if (gtk_tree_view_get_path_at_pos( list_view
, event
->x
, event
->y
,
1112 &path
, NULL
, NULL
, NULL
)) {
1113 prefs_actions_select_row(list_view
, path
);
1116 gtk_tree_path_free(path
);
1119 /* right-button click */
1120 if (event
->button
== 3) {
1121 GtkTreeModel
*model
= gtk_tree_view_get_model(list_view
);
1126 if (!prefs_actions_popup_menu
) {
1127 prefs_actions_popup_action
= cm_menu_create_action_group("PrefsActionsPopup",
1128 prefs_actions_popup_entries
, G_N_ELEMENTS(prefs_actions_popup_entries
),
1129 (gpointer
)list_view
);
1130 MENUITEM_ADDUI("/Menus", "PrefsActionsPopup", "PrefsActionsPopup", GTK_UI_MANAGER_MENU
)
1131 MENUITEM_ADDUI("/Menus/PrefsActionsPopup", "Delete", "PrefsActionsPopup/Delete", GTK_UI_MANAGER_MENUITEM
)
1132 MENUITEM_ADDUI("/Menus/PrefsActionsPopup", "DeleteAll", "PrefsActionsPopup/DeleteAll", GTK_UI_MANAGER_MENUITEM
)
1133 MENUITEM_ADDUI("/Menus/PrefsActionsPopup", "Duplicate", "PrefsActionsPopup/Duplicate", GTK_UI_MANAGER_MENUITEM
)
1134 prefs_actions_popup_menu
= gtk_menu_item_get_submenu(GTK_MENU_ITEM(
1135 gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/PrefsActionsPopup")) );
1138 /* grey out some popup menu items if there is no selected row */
1139 row
= gtkut_list_view_get_selected_row(GTK_WIDGET(list_view
));
1140 cm_menu_set_sensitive("PrefsActionsPopup/Delete", (row
> 0));
1141 cm_menu_set_sensitive("PrefsActionsPopup/Duplicate", (row
> 0));
1143 /* grey out seom popup menu items if there is no row
1144 (not counting the (New) one at row 0) */
1145 non_empty
= gtk_tree_model_get_iter_first(model
, &iter
);
1147 non_empty
= gtk_tree_model_iter_next(model
, &iter
);
1148 cm_menu_set_sensitive("PrefsActionsPopup/DeleteAll", non_empty
);
1150 gtk_menu_popup(GTK_MENU(prefs_actions_popup_menu
),
1151 NULL
, NULL
, NULL
, NULL
,
1152 event
->button
, event
->time
);
1158 static gboolean
prefs_actions_list_popup_menu(GtkWidget
*widget
, gpointer data
)
1160 GtkTreeView
*list_view
= (GtkTreeView
*)data
;
1161 GdkEventButton event
;
1164 event
.time
= gtk_get_current_event_time();
1166 prefs_actions_list_btn_pressed(NULL
, &event
, list_view
);
1171 static GtkWidget
*prefs_actions_list_view_create(void)
1173 GtkTreeView
*list_view
;
1174 GtkTreeSelection
*selector
;
1175 GtkTreeModel
*model
;
1177 model
= GTK_TREE_MODEL(prefs_actions_create_data_store());
1178 list_view
= GTK_TREE_VIEW(gtk_tree_view_new_with_model(model
));
1179 g_object_unref(model
);
1181 g_signal_connect(G_OBJECT(list_view
), "popup-menu",
1182 G_CALLBACK(prefs_actions_list_popup_menu
), list_view
);
1183 g_signal_connect(G_OBJECT(list_view
), "button-press-event",
1184 G_CALLBACK(prefs_actions_list_btn_pressed
), list_view
);
1186 gtk_tree_view_set_rules_hint(list_view
, prefs_common
.use_stripes_everywhere
);
1187 gtk_tree_view_set_reorderable(list_view
, TRUE
);
1189 selector
= gtk_tree_view_get_selection(list_view
);
1190 gtk_tree_selection_set_mode(selector
, GTK_SELECTION_BROWSE
);
1191 g_signal_connect(G_OBJECT(selector
), "changed",
1192 G_CALLBACK(prefs_actions_row_selected
), list_view
);
1194 /* create the columns */
1195 prefs_actions_create_list_view_columns(GTK_WIDGET(list_view
));
1197 return GTK_WIDGET(list_view
);
1200 static void prefs_actions_create_list_view_columns(GtkWidget
*list_view
)
1202 GtkTreeViewColumn
*column
;
1203 GtkCellRenderer
*renderer
;
1205 renderer
= gtk_cell_renderer_text_new();
1206 column
= gtk_tree_view_column_new_with_attributes
1207 (_("Current actions"),
1209 "text", PREFS_ACTIONS_STRING
,
1211 gtk_tree_view_append_column(GTK_TREE_VIEW(list_view
), column
);
1212 gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(list_view
), prefs_actions_search_func_cb
, NULL
, NULL
);
1215 #define ENTRY_SET_TEXT(entry, str) \
1216 gtk_entry_set_text(GTK_ENTRY(entry), str ? str : "")
1218 static void prefs_actions_select_row(GtkTreeView
*list_view
, GtkTreePath
*path
)
1220 GtkTreeModel
*model
= gtk_tree_view_get_model(list_view
);
1221 GtkTreeSelection
*selection
;
1224 gchar buf
[PREFSBUFSIZE
];
1228 if (!model
|| !path
|| !gtk_tree_model_get_iter(model
, &iter
, path
))
1232 selection
= gtk_tree_view_get_selection(list_view
);
1233 gtk_tree_selection_select_path(selection
, path
);
1235 gtk_tree_model_get(model
, &iter
,
1236 PREFS_ACTIONS_VALID
, &is_valid
,
1237 PREFS_ACTIONS_DATA
, &action
,
1240 prefs_actions_reset_dialog();
1244 strncpy(buf
, action
, PREFSBUFSIZE
- 1);
1245 buf
[PREFSBUFSIZE
- 1] = '\0';
1246 cmd
= strstr(buf
, ": ");
1249 ENTRY_SET_TEXT(actions
.cmd_entry
, &cmd
[2]);
1254 gtk_entry_set_text(GTK_ENTRY(actions
.name_entry
), buf
);
1256 if (g_str_has_prefix(&cmd
[2], "%as{") == TRUE
)
1257 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
1258 actions
.filter_radiobtn
), TRUE
);
1260 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
1261 actions
.shell_radiobtn
), TRUE
);
1266 static void prefs_action_filter_radiobtn_cb(GtkWidget
*widget
, gpointer data
)
1268 if (actions
.filter_btn
)
1269 gtk_widget_set_sensitive(actions
.filter_btn
, TRUE
);
1270 if (actions
.cmd_entry
)
1271 gtk_widget_set_sensitive(actions
.cmd_entry
, FALSE
);
1272 if (actions
.info_btn
)
1273 gtk_widget_set_sensitive(actions
.info_btn
, FALSE
);
1276 static void prefs_action_shell_radiobtn_cb(GtkWidget
*widget
, gpointer data
)
1278 if (actions
.filter_btn
)
1279 gtk_widget_set_sensitive(actions
.filter_btn
, FALSE
);
1280 if (actions
.cmd_entry
)
1281 gtk_widget_set_sensitive(actions
.cmd_entry
, TRUE
);
1282 if (actions
.info_btn
)
1283 gtk_widget_set_sensitive(actions
.info_btn
, TRUE
);
1286 static void prefs_action_filterbtn_cb(GtkWidget
*widget
, gpointer data
)
1288 gchar
*action_str
, **tokens
;
1289 GSList
*action_list
= NULL
, *cur
;
1291 /* I think this warning is useless - it's logical to clear the field when
1294 if(modified && alertpanel(_("Entry was modified"),
1295 _("Opening the filter action dialog will clear current modifications "
1296 "of the command line."),
1297 GTK_STOCK_CANCEL, _("_Continue editing"), NULL, ALERTFOCUS_SECOND) != G_ALERTDEFAULT)
1300 action_str
= gtk_editable_get_chars(GTK_EDITABLE(actions
.cmd_entry
), 0, -1);
1301 tokens
= g_strsplit_set(action_str
, "{}", 5);
1303 if (tokens
[0] && tokens
[1] && *tokens
[1] != '\0') {
1304 action_list
= matcher_parser_get_action_list(tokens
[1]);
1305 if (action_list
== NULL
)
1306 alertpanel_error(_("Action string is not valid."));
1309 prefs_filtering_action_open(action_list
, prefs_action_define_filter_done
);
1311 if (action_list
!= NULL
) {
1312 for(cur
= action_list
; cur
!= NULL
; cur
= cur
->next
)
1313 filteringaction_free(cur
->data
);
1320 static void prefs_action_define_filter_done(GSList
* action_list
)
1324 if (action_list
== NULL
)
1327 action_list
= filtering_action_list_sort(action_list
);
1328 str
= filteringaction_list_to_string(action_list
);
1332 cmd
= g_strdup_printf("%%as{%s}",str
);
1334 gtk_entry_set_text(GTK_ENTRY(actions
.cmd_entry
), cmd
);
1340 void prefs_actions_rename_path(const gchar
*old_path
, const gchar
*new_path
)
1342 gchar
**tokens
, *action_str
;
1343 GSList
*action
, *action_list
;
1345 for (action
= prefs_common
.actions_list
; action
!= NULL
;
1346 action
= action
->next
) {
1347 action_str
= (gchar
*)action
->data
;
1348 tokens
= g_strsplit_set(action_str
, "{}", 5);
1350 if (tokens
[0] && tokens
[1] && *tokens
[1] != '\0')
1351 action_list
= matcher_parser_get_action_list(tokens
[1]);
1356 filtering_action_list_rename_path(action_list
,
1357 old_path
, new_path
)) {
1358 g_free(action
->data
);
1359 action
->data
= g_strconcat(tokens
[0], "{",
1360 filteringaction_list_to_string(action_list
),
1366 prefs_actions_write_config();
1369 gint
prefs_actions_find_by_name(const gchar
*name
)
1371 GSList
*act
= prefs_common
.actions_list
;
1372 gchar
*action_name
, *action_p
;
1375 for (; act
!= NULL
; act
= act
->next
) {
1376 action_name
= g_strdup((gchar
*)act
->data
);
1377 action_p
= strstr(action_name
, ": ");
1380 if (g_utf8_collate(name
, action_name
) == 0) {
1381 g_free(action_name
);
1385 g_free(action_name
);