add reference to Sylpheed-Claws team
[claws.git] / src / prefs_actions.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2003 Hiroyuki Yamamoto & The Sylpheed Claws Team
4  *
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 2 of the License, or
8  * (at your option) any later version.
9  *
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.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #include "defs.h"
25
26 #include <glib.h>
27 #include <gtk/gtk.h>
28 #include <gdk/gdkkeysyms.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <errno.h>
33
34 #include "intl.h"
35 #include "prefs_gtk.h"
36 #include "inc.h"
37 #include "utils.h"
38 #include "gtkutils.h"
39 #include "manage_window.h"
40 #include "mainwindow.h"
41 #include "prefs_common.h"
42 #include "alertpanel.h"
43 #include "prefs_actions.h"
44 #include "action.h"
45 #include "description_window.h"
46
47 static struct Actions
48 {
49         GtkWidget *window;
50
51         GtkWidget *ok_btn;
52
53         GtkWidget *name_entry;
54         GtkWidget *cmd_entry;
55
56         GtkWidget *actions_clist;
57 } actions;
58
59 /* widget creating functions */
60 static void prefs_actions_create        (MainWindow *mainwin);
61 static void prefs_actions_set_dialog    (void);
62 static gint prefs_actions_clist_set_row (gint row);
63
64 /* callback functions */
65 static void prefs_actions_help_cb       (GtkWidget      *w,
66                                          gpointer        data);
67 static void prefs_actions_register_cb   (GtkWidget      *w,
68                                          gpointer        data);
69 static void prefs_actions_substitute_cb (GtkWidget      *w,
70                                          gpointer        data);
71 static void prefs_actions_delete_cb     (GtkWidget      *w,
72                                          gpointer        data);
73 static void prefs_actions_up            (GtkWidget      *w,
74                                          gpointer        data);
75 static void prefs_actions_down          (GtkWidget      *w,
76                                          gpointer        data);
77 static void prefs_actions_select        (GtkCList       *clist,
78                                          gint            row,
79                                          gint            column,
80                                          GdkEvent       *event);
81 static void prefs_actions_row_move      (GtkCList       *clist,
82                                          gint            source_row,
83                                          gint            dest_row);
84 static gint prefs_actions_deleted       (GtkWidget      *widget,
85                                          GdkEventAny    *event,
86                                          gpointer       *data);
87 static void prefs_actions_key_pressed   (GtkWidget      *widget,
88                                          GdkEventKey    *event,
89                                          gpointer        data);
90 static void prefs_actions_cancel        (GtkWidget      *w,
91                                          gpointer        data);
92 static void prefs_actions_ok            (GtkWidget      *w,
93                                          gpointer        data);
94
95
96 void prefs_actions_open(MainWindow *mainwin)
97 {
98         inc_lock();
99
100         if (!actions.window)
101                 prefs_actions_create(mainwin);
102
103         manage_window_set_transient(GTK_WINDOW(actions.window));
104         gtk_widget_grab_focus(actions.ok_btn);
105
106         prefs_actions_set_dialog();
107
108         gtk_widget_show(actions.window);
109 }
110
111 static void prefs_actions_create(MainWindow *mainwin)
112 {
113         GtkWidget *window;
114         GtkWidget *vbox;
115         GtkWidget *ok_btn;
116         GtkWidget *cancel_btn;
117         GtkWidget *confirm_area;
118
119         GtkWidget *vbox1;
120
121         GtkWidget *entry_vbox;
122         GtkWidget *hbox;
123         GtkWidget *name_label;
124         GtkWidget *name_entry;
125         GtkWidget *cmd_label;
126         GtkWidget *cmd_entry;
127
128         GtkWidget *reg_hbox;
129         GtkWidget *btn_hbox;
130         GtkWidget *arrow;
131         GtkWidget *reg_btn;
132         GtkWidget *subst_btn;
133         GtkWidget *del_btn;
134
135         GtkWidget *cond_hbox;
136         GtkWidget *cond_scrolledwin;
137         GtkWidget *cond_clist;
138
139         GtkWidget *help_button;
140
141         GtkWidget *btn_vbox;
142         GtkWidget *up_btn;
143         GtkWidget *down_btn;
144
145         gchar *title[1];
146
147         debug_print("Creating actions configuration window...\n");
148
149         window = gtk_window_new (GTK_WINDOW_DIALOG);
150
151         gtk_container_set_border_width(GTK_CONTAINER (window), 8);
152         gtk_window_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
153         gtk_window_set_modal(GTK_WINDOW(window), TRUE);
154         gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, TRUE);
155         gtk_window_set_default_size(GTK_WINDOW(window), 400, -1);
156
157         vbox = gtk_vbox_new(FALSE, 6);
158         gtk_widget_show(vbox);
159         gtk_container_add(GTK_CONTAINER(window), vbox);
160
161         gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
162                                 &cancel_btn, _("Cancel"), NULL, NULL);
163         gtk_widget_show(confirm_area);
164         gtk_box_pack_end(GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
165         gtk_widget_grab_default(ok_btn);
166
167         gtk_window_set_title(GTK_WINDOW(window), _("Actions configuration"));
168         gtk_signal_connect(GTK_OBJECT(window), "delete_event",
169                            GTK_SIGNAL_FUNC(prefs_actions_deleted), NULL);
170         gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
171                            GTK_SIGNAL_FUNC(prefs_actions_key_pressed), NULL);
172         MANAGE_WINDOW_SIGNALS_CONNECT(window);
173         gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked",
174                            GTK_SIGNAL_FUNC(prefs_actions_ok), mainwin);
175         gtk_signal_connect(GTK_OBJECT(cancel_btn), "clicked",
176                            GTK_SIGNAL_FUNC(prefs_actions_cancel), NULL);
177
178         vbox1 = gtk_vbox_new(FALSE, 8);
179         gtk_widget_show(vbox1);
180         gtk_box_pack_start(GTK_BOX(vbox), vbox1, TRUE, TRUE, 0);
181         gtk_container_set_border_width(GTK_CONTAINER(vbox1), 2);
182
183         entry_vbox = gtk_vbox_new(FALSE, 4);
184         gtk_box_pack_start(GTK_BOX(vbox1), entry_vbox, FALSE, FALSE, 0);
185
186         hbox = gtk_hbox_new(FALSE, 8);
187         gtk_box_pack_start(GTK_BOX(entry_vbox), hbox, FALSE, FALSE, 0);
188
189         name_label = gtk_label_new(_("Menu name:"));
190         gtk_box_pack_start(GTK_BOX(hbox), name_label, FALSE, FALSE, 0);
191
192         name_entry = gtk_entry_new();
193         gtk_box_pack_start(GTK_BOX(hbox), name_entry, TRUE, TRUE, 0);
194
195         hbox = gtk_hbox_new(FALSE, 8);
196         gtk_box_pack_start(GTK_BOX(entry_vbox), hbox, TRUE, TRUE, 0);
197
198         cmd_label = gtk_label_new(_("Command line:"));
199         gtk_box_pack_start(GTK_BOX(hbox), cmd_label, FALSE, FALSE, 0);
200
201         cmd_entry = gtk_entry_new();
202         gtk_box_pack_start(GTK_BOX(hbox), cmd_entry, TRUE, TRUE, 0);
203
204         gtk_widget_show_all(entry_vbox);
205
206         /* register / substitute / delete */
207
208         reg_hbox = gtk_hbox_new(FALSE, 4);
209         gtk_widget_show(reg_hbox);
210         gtk_box_pack_start(GTK_BOX(vbox1), reg_hbox, FALSE, FALSE, 0);
211
212         arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
213         gtk_widget_show(arrow);
214         gtk_box_pack_start(GTK_BOX(reg_hbox), arrow, FALSE, FALSE, 0);
215         gtk_widget_set_usize(arrow, -1, 16);
216
217         btn_hbox = gtk_hbox_new(TRUE, 4);
218         gtk_widget_show(btn_hbox);
219         gtk_box_pack_start(GTK_BOX(reg_hbox), btn_hbox, FALSE, FALSE, 0);
220
221         reg_btn = gtk_button_new_with_label(_("Add"));
222         gtk_widget_show(reg_btn);
223         gtk_box_pack_start(GTK_BOX(btn_hbox), reg_btn, FALSE, TRUE, 0);
224         gtk_signal_connect(GTK_OBJECT(reg_btn), "clicked",
225                            GTK_SIGNAL_FUNC(prefs_actions_register_cb), NULL);
226
227         subst_btn = gtk_button_new_with_label(_(" Replace "));
228         gtk_widget_show(subst_btn);
229         gtk_box_pack_start(GTK_BOX(btn_hbox), subst_btn, FALSE, TRUE, 0);
230         gtk_signal_connect(GTK_OBJECT(subst_btn), "clicked",
231                            GTK_SIGNAL_FUNC(prefs_actions_substitute_cb),
232                            NULL);
233
234         del_btn = gtk_button_new_with_label(_("Delete"));
235         gtk_widget_show(del_btn);
236         gtk_box_pack_start(GTK_BOX(btn_hbox), del_btn, FALSE, TRUE, 0);
237         gtk_signal_connect(GTK_OBJECT(del_btn), "clicked",
238                            GTK_SIGNAL_FUNC(prefs_actions_delete_cb), NULL);
239
240         help_button = gtk_button_new_with_label(_(" Syntax help "));
241         gtk_widget_show(help_button);
242         gtk_box_pack_end(GTK_BOX(reg_hbox), help_button, FALSE, FALSE, 0);
243         gtk_signal_connect(GTK_OBJECT(help_button), "clicked",
244                            GTK_SIGNAL_FUNC(prefs_actions_help_cb), NULL);
245
246         cond_hbox = gtk_hbox_new(FALSE, 8);
247         gtk_widget_show(cond_hbox);
248         gtk_box_pack_start(GTK_BOX(vbox1), cond_hbox, TRUE, TRUE, 0);
249
250         cond_scrolledwin = gtk_scrolled_window_new(NULL, NULL);
251         gtk_widget_show(cond_scrolledwin);
252         gtk_widget_set_usize(cond_scrolledwin, -1, 150);
253         gtk_box_pack_start(GTK_BOX(cond_hbox), cond_scrolledwin,
254                            TRUE, TRUE, 0);
255         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (cond_scrolledwin),
256                                        GTK_POLICY_AUTOMATIC,
257                                        GTK_POLICY_AUTOMATIC);
258
259         title[0] = _("Current actions");
260         cond_clist = gtk_clist_new_with_titles(1, title);
261         gtk_widget_show(cond_clist);
262         gtk_container_add(GTK_CONTAINER (cond_scrolledwin), cond_clist);
263         gtk_clist_set_column_width(GTK_CLIST (cond_clist), 0, 80);
264         gtk_clist_set_selection_mode(GTK_CLIST (cond_clist),
265                                      GTK_SELECTION_BROWSE);
266         GTK_WIDGET_UNSET_FLAGS(GTK_CLIST(cond_clist)->column[0].button,
267                                GTK_CAN_FOCUS);
268         gtk_signal_connect(GTK_OBJECT(cond_clist), "select_row",
269                            GTK_SIGNAL_FUNC(prefs_actions_select), NULL);
270         gtk_signal_connect_after(GTK_OBJECT(cond_clist), "row_move",
271                                  GTK_SIGNAL_FUNC(prefs_actions_row_move),
272                                  NULL);
273
274         btn_vbox = gtk_vbox_new(FALSE, 8);
275         gtk_widget_show(btn_vbox);
276         gtk_box_pack_start(GTK_BOX(cond_hbox), btn_vbox, FALSE, FALSE, 0);
277
278         up_btn = gtk_button_new_with_label(_("Up"));
279         gtk_widget_show(up_btn);
280         gtk_box_pack_start(GTK_BOX(btn_vbox), up_btn, FALSE, FALSE, 0);
281         gtk_signal_connect(GTK_OBJECT(up_btn), "clicked",
282                            GTK_SIGNAL_FUNC(prefs_actions_up), NULL);
283
284         down_btn = gtk_button_new_with_label(_("Down"));
285         gtk_widget_show(down_btn);
286         gtk_box_pack_start(GTK_BOX(btn_vbox), down_btn, FALSE, FALSE, 0);
287         gtk_signal_connect(GTK_OBJECT(down_btn), "clicked",
288                            GTK_SIGNAL_FUNC(prefs_actions_down), NULL);
289
290         gtk_widget_show(window);
291
292         actions.window = window;
293         actions.ok_btn = ok_btn;
294
295         actions.name_entry = name_entry;
296         actions.cmd_entry  = cmd_entry;
297
298         actions.actions_clist = cond_clist;
299 }
300
301
302 void prefs_actions_read_config(void)
303 {
304         gchar *rcpath;
305         FILE *fp;
306         gchar buf[PREFSBUFSIZE];
307         gchar *act;
308
309         debug_print("Reading actions configurations...\n");
310
311         rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACTIONS_RC, NULL);
312         if ((fp = fopen(rcpath, "rb")) == NULL) {
313                 if (ENOENT != errno) FILE_OP_ERROR(rcpath, "fopen");
314                 g_free(rcpath);
315                 return;
316         }
317         g_free(rcpath);
318
319         while (prefs_common.actions_list != NULL) {
320                 act = (gchar *)prefs_common.actions_list->data;
321                 prefs_common.actions_list =
322                         g_slist_remove(prefs_common.actions_list, act);
323                 g_free(act);
324         }
325
326         while (fgets(buf, sizeof(buf), fp) != NULL) {
327                 g_strchomp(buf);
328                 act = strstr(buf, ": ");
329                 if (act && act[2] && 
330                     action_get_type(&act[2]) != ACTION_ERROR)
331                         prefs_common.actions_list =
332                                 g_slist_append(prefs_common.actions_list,
333                                                g_strdup(buf));
334         }
335         fclose(fp);
336 }
337
338 void prefs_actions_write_config(void)
339 {
340         gchar *rcpath;
341         PrefFile *pfile;
342         GSList *cur;
343
344         debug_print("Writing actions configuration...\n");
345
346         rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACTIONS_RC, NULL);
347         if ((pfile= prefs_write_open(rcpath)) == NULL) {
348                 g_warning("failed to write configuration to file\n");
349                 g_free(rcpath);
350                 return;
351         }
352
353         for (cur = prefs_common.actions_list; cur != NULL; cur = cur->next) {
354                 gchar *act = (gchar *)cur->data;
355                 if (fputs(act, pfile->fp) == EOF ||
356                     fputc('\n', pfile->fp) == EOF) {
357                         FILE_OP_ERROR(rcpath, "fputs || fputc");
358                         prefs_file_close_revert(pfile);
359                         g_free(rcpath);
360                         return;
361                 }
362         }
363         
364         g_free(rcpath);
365
366         if (prefs_file_close(pfile) < 0) {
367                 g_warning("failed to write configuration to file\n");
368                 return;
369         }
370 }
371
372 static void prefs_actions_set_dialog(void)
373 {
374         GtkCList *clist = GTK_CLIST(actions.actions_clist);
375         GSList *cur;
376         gchar *action_str[1];
377         gint row;
378
379         gtk_clist_freeze(clist);
380         gtk_clist_clear(clist);
381
382         action_str[0] = _("(New)");
383         row = gtk_clist_append(clist, action_str);
384         gtk_clist_set_row_data(clist, row, NULL);
385
386         for (cur = prefs_common.actions_list; cur != NULL; cur = cur->next) {
387                 gchar *action[1];
388
389                 action[0] = (gchar *)cur->data;
390                 row = gtk_clist_append(clist, action);
391                 gtk_clist_set_row_data(clist, row, action[0]);
392         }
393
394         gtk_clist_thaw(clist);
395 }
396
397 static void prefs_actions_set_list(void)
398 {
399         gint row = 1;
400         gchar *action;
401
402         g_slist_free(prefs_common.actions_list);
403         prefs_common.actions_list = NULL;
404
405         while ((action = (gchar *)gtk_clist_get_row_data
406                 (GTK_CLIST(actions.actions_clist), row)) != NULL) {
407                 prefs_common.actions_list =
408                         g_slist_append(prefs_common.actions_list, action);
409                 row++;
410         }
411 }
412
413 #define GET_ENTRY(entry) \
414         entry_text = gtk_entry_get_text(GTK_ENTRY(entry))
415
416 static gint prefs_actions_clist_set_row(gint row)
417 {
418         GtkCList *clist = GTK_CLIST(actions.actions_clist);
419         gchar *entry_text;
420         gint len;
421         gchar action[PREFSBUFSIZE];
422         gchar *buf[1];
423
424         g_return_val_if_fail(row != 0, -1);
425
426         GET_ENTRY(actions.name_entry);
427         if (entry_text[0] == '\0') {
428                 alertpanel_error(_("Menu name is not set."));
429                 return -1;
430         }
431
432         if (strchr(entry_text, ':')) {
433                 alertpanel_error(_("Colon ':' is not allowed in the menu name."));
434                 return -1;
435         }
436
437         strncpy(action, entry_text, PREFSBUFSIZE - 1);
438         g_strstrip(action);
439
440         /* Keep space for the ': ' delimiter */
441         len = strlen(action) + 2;
442         if (len >= PREFSBUFSIZE - 1) {
443                 alertpanel_error(_("Menu name is too long."));
444                 return -1;
445         }
446
447         strcat(action, ": ");
448
449         GET_ENTRY(actions.cmd_entry);
450
451         if (entry_text[0] == '\0') {
452                 alertpanel_error(_("Command line not set."));
453                 return -1;
454         }
455
456         if (len + strlen(entry_text) >= PREFSBUFSIZE - 1) {
457                 alertpanel_error(_("Menu name and command are too long."));
458                 return -1;
459         }
460
461         if (action_get_type(entry_text) == ACTION_ERROR) {
462                 alertpanel_error(_("The command\n%s\nhas a syntax error."), 
463                                  entry_text);
464                 return -1;
465         }
466
467         strcat(action, entry_text);
468
469         buf[0] = action;
470         if (row < 0)
471                 row = gtk_clist_append(clist, buf);
472         else {
473                 gchar *old_action;
474                 gtk_clist_set_text(clist, row, 0, action);
475                 old_action = (gchar *) gtk_clist_get_row_data(clist, row);
476                 if (old_action)
477                         g_free(old_action);
478         }
479
480         buf[0] = g_strdup(action);
481
482         gtk_clist_set_row_data(clist, row, buf[0]);
483
484         prefs_actions_set_list();
485
486         return 0;
487 }
488
489 /* callback functions */
490
491 static void prefs_actions_register_cb(GtkWidget *w, gpointer data)
492 {
493         prefs_actions_clist_set_row(-1);
494 }
495
496 static void prefs_actions_substitute_cb(GtkWidget *w, gpointer data)
497 {
498         GtkCList *clist = GTK_CLIST(actions.actions_clist);
499         gchar *action;
500         gint row;
501
502         if (!clist->selection) return;
503
504         row = GPOINTER_TO_INT(clist->selection->data);
505         if (row == 0) return;
506
507         action = gtk_clist_get_row_data(clist, row);
508         if (!action) return;
509
510         prefs_actions_clist_set_row(row);
511 }
512
513 static void prefs_actions_delete_cb(GtkWidget *w, gpointer data)
514 {
515         GtkCList *clist = GTK_CLIST(actions.actions_clist);
516         gchar *action;
517         gint row;
518
519         if (!clist->selection) return;
520         row = GPOINTER_TO_INT(clist->selection->data);
521         if (row == 0) return;
522
523         if (alertpanel(_("Delete action"),
524                        _("Do you really want to delete this action?"),
525                        _("Yes"), _("No"), NULL) == G_ALERTALTERNATE)
526                 return;
527
528         action = gtk_clist_get_row_data(clist, row);
529         g_free(action);
530         gtk_clist_remove(clist, row);
531         prefs_common.actions_list = g_slist_remove(prefs_common.actions_list,
532                                                    action);
533 }
534
535 static void prefs_actions_up(GtkWidget *w, gpointer data)
536 {
537         GtkCList *clist = GTK_CLIST(actions.actions_clist);
538         gint row;
539
540         if (!clist->selection) return;
541
542         row = GPOINTER_TO_INT(clist->selection->data);
543         if (row > 1)
544                 gtk_clist_row_move(clist, row, row - 1);
545 }
546
547 static void prefs_actions_down(GtkWidget *w, gpointer data)
548 {
549         GtkCList *clist = GTK_CLIST(actions.actions_clist);
550         gint row;
551
552         if (!clist->selection) return;
553
554         row = GPOINTER_TO_INT(clist->selection->data);
555         if (row > 0 && row < clist->rows - 1)
556                 gtk_clist_row_move(clist, row, row + 1);
557 }
558
559 #define ENTRY_SET_TEXT(entry, str) \
560         gtk_entry_set_text(GTK_ENTRY(entry), str ? str : "")
561
562 static void prefs_actions_select(GtkCList *clist, gint row, gint column,
563                                  GdkEvent *event)
564 {
565         gchar *action;
566         gchar *cmd;
567         gchar buf[PREFSBUFSIZE];
568         action = gtk_clist_get_row_data(clist, row);
569
570         if (!action) {
571                 ENTRY_SET_TEXT(actions.name_entry, "");
572                 ENTRY_SET_TEXT(actions.cmd_entry, "");
573                 return;
574         }
575
576         strncpy(buf, action, PREFSBUFSIZE - 1);
577         buf[PREFSBUFSIZE - 1] = 0x00;
578         cmd = strstr(buf, ": ");
579
580         if (cmd && cmd[2])
581                 ENTRY_SET_TEXT(actions.cmd_entry, &cmd[2]);
582         else
583                 return;
584
585         *cmd = 0x00;
586         ENTRY_SET_TEXT(actions.name_entry, buf);
587 }
588
589 static void prefs_actions_row_move(GtkCList *clist,
590                                    gint source_row, gint dest_row)
591 {
592         prefs_actions_set_list();
593         if (gtk_clist_row_is_visible(clist, dest_row) != GTK_VISIBILITY_FULL) {
594                 gtk_clist_moveto(clist, dest_row, -1,
595                                  source_row < dest_row ? 1.0 : 0.0, 0.0);
596         }
597 }
598
599 static gint prefs_actions_deleted(GtkWidget *widget, GdkEventAny *event,
600                                   gpointer *data)
601 {
602         prefs_actions_cancel(widget, data);
603         return TRUE;
604 }
605
606 static void prefs_actions_key_pressed(GtkWidget *widget, GdkEventKey *event,
607                                       gpointer data)
608 {
609         if (event && event->keyval == GDK_Escape)
610                 prefs_actions_cancel(widget, data);
611 }
612
613 static void prefs_actions_cancel(GtkWidget *w, gpointer data)
614 {
615         prefs_actions_read_config();
616         gtk_widget_hide(actions.window);
617         inc_unlock();
618 }
619
620 static void prefs_actions_ok(GtkWidget *widget, gpointer data)
621 {
622         GtkItemFactory *ifactory;
623         MainWindow *mainwin = (MainWindow *)data;
624
625         prefs_actions_write_config();
626         ifactory = gtk_item_factory_from_widget(mainwin->menubar);
627         action_update_mainwin_menu(ifactory, mainwin);
628         gtk_widget_hide(actions.window);
629         inc_unlock();
630 }
631
632 /*
633  * Strings describing action format strings
634  * 
635  * When adding new lines, remember to put one string for each line
636  */
637 static gchar *actions_desc_strings[] = {
638         N_("MENU NAME:"), NULL,
639         "      ",   N_("Use / in menu name to make submenus."),
640         "", NULL,
641         N_("COMMAND LINE:"), NULL,
642         N_("Begin with:"), NULL,
643         "     |",   N_("to send message body or selection to command"),
644         "     >",   N_("to send user provided text to command"),
645         "     *",   N_("to send user provided hidden text to command"),
646         N_("End with:"), NULL, 
647         "     |",   N_("to replace message body or selection with command output"),
648         "     >",   N_("to insert command's output without replacing old text"),
649         "     &",   N_("to run command asynchronously"),
650         N_("Use:"), NULL, 
651         "     %f",  N_("for message file name"),
652         "     %F",  N_("for the list of the file names of selected messages"),
653         "     %p",  N_("for the selected message MIME part"),
654         "     %u",  N_("for a user provided argument"),
655         "     %h",  N_("for a user provided hidden argument"),
656         "     %s",  N_("for the text selection"),
657         NULL
658 };
659
660
661 static DescriptionWindow actions_desc_win = { 
662         NULL, 
663         2,
664         N_("Description of symbols"),
665         actions_desc_strings
666 };
667
668
669 static void prefs_actions_help_cb(GtkWidget *w, gpointer data)
670 {
671         description_window_create(&actions_desc_win);
672 }