Made the actions help text for %p more clear
[claws.git] / src / prefs_actions.c
index e097335c89a12d7537a2d25cd17e3af1e1dcad93..a2cf0cb95e60fb107a771b02ae3a9766cec6f871 100644 (file)
@@ -87,7 +87,7 @@ struct _Children
        GtkWidget       *input_entry;
        GtkWidget       *input_hbox;
        GtkWidget       *abort_btn;
-       GtkWidget       *hide_btn;
+       GtkWidget       *close_btn;
        GtkWidget       *scrolledwin;
 
        gchar           *action;
@@ -192,7 +192,6 @@ static void free_children           (Children       *children);
 static void childinfo_close_pipes      (ChildInfo      *child_info);
 
 static void create_io_dialog           (Children       *children);
-
 static void update_io_dialog           (Children       *children);
 
 static void hide_io_dialog_cb          (GtkWidget      *widget,
@@ -265,7 +264,7 @@ static void prefs_actions_create(MainWindow *mainwin)
 
        gchar *title[1];
 
-       debug_print(_("Creating actions setting window...\n"));
+       debug_print("Creating actions setting window...\n");
 
        window = gtk_window_new (GTK_WINDOW_DIALOG);
 
@@ -340,7 +339,7 @@ static void prefs_actions_create(MainWindow *mainwin)
                   "   & to run command asynchronously\n"
                   " Use %f for message file name\n"
                   "   %F for the list of the file names of selected messages\n"
-                  "   %p for the selected message part."));
+                  "   %p for the selected message MIME part."));
        gtk_misc_set_alignment(GTK_MISC(help_label), 0, 0.5);
        gtk_label_set_justify(GTK_LABEL(help_label), GTK_JUSTIFY_LEFT);
        gtk_widget_show(help_label);
@@ -457,7 +456,7 @@ void prefs_actions_read_config(void)
        gchar buf[PREFSBUFSIZE];
        gchar *act;
 
-       debug_print(_("Reading actions configurations...\n"));
+       debug_print("Reading actions configurations...\n");
 
        rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACTIONS_RC, NULL);
        if ((fp = fopen(rcpath, "rb")) == NULL) {
@@ -492,7 +491,7 @@ void prefs_actions_write_config(void)
        PrefFile *pfile;
        GSList *cur;
 
-       debug_print(_("Writing actions configuration...\n"));
+       debug_print("Writing actions configuration...\n");
 
        rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACTIONS_RC, NULL);
        if ((pfile= prefs_write_open(rcpath)) == NULL) {
@@ -999,6 +998,19 @@ void update_compose_actions_menu(GtkItemFactory *ifactory,
                            compose);
 }
 
+void actions_execute(gpointer data, 
+                    guint action_nb,
+                    GtkWidget *widget,
+                    gint source)
+{
+       if (source == TOOLBAR_MAIN) 
+               mainwin_actions_execute_cb((MainWindow*)data, action_nb, widget);
+
+       else if (source == TOOLBAR_COMPOSE)
+               compose_actions_execute_cb((Compose*)data, action_nb, widget);
+}
+
+
 static void update_actions_menu(GtkItemFactory *ifactory,
                                gchar *branch_path,
                                gpointer callback,
@@ -1148,10 +1160,6 @@ static gboolean execute_actions(gchar *action, GtkWidget *window,
                        return FALSE; /* ERR: pipe and no displayed text */
        }
 
-       if (!(action_type & ACTION_ASYNC) && window) {
-               gtk_widget_set_sensitive(window, FALSE);
-       }
-
        children = g_new0(Children, 1);
 
        if (action_type & ACTION_SINGLE) {
@@ -1165,7 +1173,7 @@ static gboolean execute_actions(gchar *action, GtkWidget *window,
                        cmd = parse_action_cmd(action, msginfo, ctree,
                                               mimeview);
                        if (!cmd) {
-                               debug_print(_("Action command error\n"));
+                               debug_print("Action command error\n");
                                is_ok  = FALSE; /* ERR: incorrect command */
                                break;
                        }
@@ -1199,9 +1207,6 @@ static gboolean execute_actions(gchar *action, GtkWidget *window,
        if (!children_list) {
                 /* If not waiting for children, return */
                g_free(children);
-               if (!(action_type & ACTION_ASYNC) && window) {
-                       gtk_widget_set_sensitive(window, TRUE);
-               }
        } else {
                GSList *cur;
 
@@ -1218,8 +1223,9 @@ static gboolean execute_actions(gchar *action, GtkWidget *window,
                                              GDK_INPUT_READ,
                                              catch_status, child_info);
                }
+
+               create_io_dialog(children);
        }
-       create_io_dialog(children);
 
        return is_ok;
 }
@@ -1259,7 +1265,7 @@ ChildInfo *fork_child(gchar *cmd, gint action_type, GtkWidget *text,
                }
        }
 
-       debug_print(_("Forking child and grandchild.\n"));
+       debug_print("Forking child and grandchild.\n");
 
        pid = fork();
        if (pid == 0) { /* Child */
@@ -1319,9 +1325,9 @@ ChildInfo *fork_child(gchar *cmd, gint action_type, GtkWidget *text,
                                close(chld_status[0]);
                        }
 
-                       debug_print(_("Child: Waiting for grandchild\n"));
+                       debug_print("Child: Waiting for grandchild\n");
                        waitpid(gch_pid, NULL, 0);
-                       debug_print(_("Child: grandchild ended\n"));
+                       debug_print("Child: grandchild ended\n");
                        if (sync) {
                                write(chld_status[1], "0\n", 2);
                                close(chld_status[1]);
@@ -1423,7 +1429,7 @@ static void kill_children_cb(GtkWidget *widget, gpointer data)
 
        for (cur = children->list; cur; cur = cur->next) {
                child_info = (ChildInfo *)(cur->data);
-               debug_print(_("Killing child group id %d\n"), child_info->pid);
+               debug_print("Killing child group id %d\n", child_info->pid);
                if (child_info->pid && kill(-child_info->pid, SIGTERM) < 0)
                        perror("kill");
        }
@@ -1458,11 +1464,11 @@ static gint wait_for_children(gpointer data)
                return FALSE;
 
        if (!children->dialog) {
-               gtk_widget_set_sensitive(children->window, TRUE);
                free_children(children);
        } else if (!children->output) {
                gtk_widget_destroy(children->dialog);
        }
+
        return FALSE;
 }
 
@@ -1489,7 +1495,6 @@ static void hide_io_dialog_cb(GtkWidget *w, gpointer data)
        Children *children = (Children *)data;
 
        if (!children->nb) {
-               gtk_widget_set_sensitive(children->window, TRUE);
                gtk_signal_disconnect_by_data(GTK_OBJECT(children->dialog),
                                              children);
                gtk_widget_destroy(children->dialog);
@@ -1516,7 +1521,7 @@ static void free_children(Children *children)
        GSList *cur;
        ChildInfo *child_info;
 
-       debug_print(_("Freeing children data %p\n"), children);
+       debug_print("Freeing children data %p\n", children);
 
        g_free(children->action);
        for (cur = children->list; cur;) {
@@ -1534,12 +1539,11 @@ static void update_io_dialog(Children *children)
 {
        GSList *cur;
 
-       debug_print(_("Updating actions input/output dialog.\n"));
+       debug_print("Updating actions input/output dialog.\n");
 
        if (!children->nb) {
                gtk_widget_set_sensitive(children->abort_btn, FALSE);
-               gtk_widget_set_sensitive(children->hide_btn, TRUE);
-               gtk_widget_set_sensitive(children->window, TRUE);
+               gtk_widget_set_sensitive(children->close_btn, TRUE);
                if (children->input_hbox)
                        gtk_widget_set_sensitive(children->input_hbox, FALSE);
        }
@@ -1579,6 +1583,7 @@ static void update_io_dialog(Children *children)
 static void create_io_dialog(Children *children)
 {
        GtkWidget *dialog;
+       GtkWidget *vbox;
        GtkWidget *entry = NULL;
        GtkWidget *input_hbox = NULL;
        GtkWidget *send_button;
@@ -1587,29 +1592,37 @@ static void create_io_dialog(Children *children)
        GtkWidget *scrolledwin;
        GtkWidget *hbox;
        GtkWidget *abort_button;
-       GtkWidget *hide_button;
+       GtkWidget *close_button;
 
-       debug_print(_("Creating actions dialog\n"));
+       debug_print("Creating action IO dialog\n");
 
        dialog = gtk_dialog_new();
-       label = gtk_label_new(children->action);
-       gtk_misc_set_padding(GTK_MISC(label), 8, 8);
-       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, FALSE,
-                          FALSE, 0);
-
-       gtk_window_set_title(GTK_WINDOW(dialog), _("Actions' input/output"));
+       gtk_container_set_border_width
+               (GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), 5);
+       gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+       gtk_window_set_title(GTK_WINDOW(dialog), _("Action's input/output"));
+       gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+       manage_window_set_transient(GTK_WINDOW(dialog));
        gtk_signal_connect(GTK_OBJECT(dialog), "delete_event",
                        GTK_SIGNAL_FUNC(delete_io_dialog_cb), children);
        gtk_signal_connect(GTK_OBJECT(dialog), "destroy",
                        GTK_SIGNAL_FUNC(hide_io_dialog_cb),
                        children);
 
+       vbox = gtk_vbox_new(FALSE, 8);
+       gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), vbox);
+       gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
+       gtk_widget_show(vbox);
+
+       label = gtk_label_new(children->action);
+       gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
+       gtk_widget_show(label);
+
        scrolledwin = gtk_scrolled_window_new(NULL, NULL);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
                                       GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
-       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), scrolledwin, TRUE,
-                          TRUE, 0);
-       gtk_widget_set_usize(scrolledwin, 600, 200);
+       gtk_box_pack_start(GTK_BOX(vbox), scrolledwin, TRUE, TRUE, 0);
+       gtk_widget_set_usize(scrolledwin, 480, 200);
        gtk_widget_hide(scrolledwin);
 
        text = gtk_text_new(gtk_scrolled_window_get_hadjustment
@@ -1625,42 +1638,35 @@ static void create_io_dialog(Children *children)
                gtk_widget_show(input_hbox);
 
                entry = gtk_entry_new();
+               gtk_widget_set_usize(entry, 320, -1);
                gtk_signal_connect(GTK_OBJECT(entry), "activate",
                                   GTK_SIGNAL_FUNC(send_input), children);
-               gtk_box_pack_start(GTK_BOX(input_hbox), entry, TRUE, TRUE, 8);
+               gtk_box_pack_start(GTK_BOX(input_hbox), entry, TRUE, TRUE, 0);
                if (children->open_in & ACTION_HIDE_IN)
                        gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
                gtk_widget_show(entry);
 
-               send_button = gtk_button_new_with_label(_("Send"));
+               send_button = gtk_button_new_with_label(_(" Send "));
                gtk_signal_connect(GTK_OBJECT(send_button), "clicked",
                                   GTK_SIGNAL_FUNC(send_input), children);
                gtk_box_pack_start(GTK_BOX(input_hbox), send_button, FALSE,
-                                  FALSE, 8);
+                                  FALSE, 0);
                gtk_widget_show(send_button);
 
-               gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
-                               input_hbox, FALSE, FALSE, 8);
+               gtk_box_pack_start(GTK_BOX(vbox), input_hbox, FALSE, FALSE, 0);
                gtk_widget_grab_focus(entry);
        }
 
-       hbox = gtk_hbox_new(TRUE, 0);
-       gtk_widget_show(hbox);
-
-       abort_button = gtk_button_new_with_label(_("Abort actions"));
+       gtkut_button_set_create(&hbox, &abort_button, _("Abort"),
+                               &close_button, _("Close"), NULL, NULL);
        gtk_signal_connect(GTK_OBJECT(abort_button), "clicked",
                        GTK_SIGNAL_FUNC(kill_children_cb), children);
-       gtk_box_pack_start(GTK_BOX(hbox), abort_button, TRUE, TRUE, 8);
-       gtk_widget_show(abort_button);
-
-       hide_button = gtk_button_new_with_label(_("Close window"));
-       gtk_signal_connect(GTK_OBJECT(hide_button), "clicked",
+       gtk_signal_connect(GTK_OBJECT(close_button), "clicked",
                        GTK_SIGNAL_FUNC(hide_io_dialog_cb), children);
-       gtk_box_pack_start(GTK_BOX(hbox), hide_button, TRUE, TRUE, 8);
-       gtk_widget_show(hide_button);
+       gtk_widget_show(hbox);
 
        if (children->nb)
-               gtk_widget_set_sensitive(hide_button, FALSE);
+               gtk_widget_set_sensitive(close_button, FALSE);
 
        gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), hbox);
 
@@ -1670,7 +1676,7 @@ static void create_io_dialog(Children *children)
        children->input_hbox  = children->open_in ? input_hbox : NULL;
        children->input_entry = children->open_in ? entry : NULL;
        children->abort_btn   = abort_button;
-       children->hide_btn    = hide_button;
+       children->close_btn   = close_button;
 
        gtk_widget_show(dialog);
 }
@@ -1684,7 +1690,7 @@ static void catch_status(gpointer data, gint source, GdkInputCondition cond)
        gdk_input_remove(child_info->tag_status);
 
        c = read(source, &buf, 1);
-       debug_print(_("Child returned %c\n"), buf);
+       debug_print("Child returned %c\n", buf);
 
        waitpid(-child_info->pid, NULL, 0);
        childinfo_close_pipes(child_info);
@@ -1700,7 +1706,7 @@ static void catch_input(gpointer data, gint source, GdkInputCondition cond)
        gchar *input;
        gint c;
 
-       debug_print(_("Sending input to grand child.\n"));
+       debug_print("Sending input to grand child.\n");
        if (!(cond && GDK_INPUT_WRITE))
                return;
 
@@ -1717,7 +1723,7 @@ static void catch_input(gpointer data, gint source, GdkInputCondition cond)
 
        gtk_entry_set_text(GTK_ENTRY(children->input_entry), "");
        gtk_widget_set_sensitive(children->input_hbox, TRUE);
-       debug_print(_("Input to grand child sent.\n"));
+       debug_print("Input to grand child sent.\n");
 }
 
 static void catch_output(gpointer data, gint source, GdkInputCondition cond)
@@ -1726,7 +1732,7 @@ static void catch_output(gpointer data, gint source, GdkInputCondition cond)
        gint c, i;
        gchar buf[PREFSBUFSIZE];
 
-       debug_print(_("Catching grand child's output.\n"));
+       debug_print("Catching grand child's output.\n");
        if (child_info->type & ACTION_PIPE_OUT
            && source == child_info->chld_out) {
                gboolean is_selection = FALSE;