Made the actions help text for %p more clear
[claws.git] / src / prefs_actions.c
index 0c30d98dd85c669532318e4902f55340aa576dbb..a2cf0cb95e60fb107a771b02ae3a9766cec6f871 100644 (file)
 #include "gtkstext.h"
 #include "mimeview.h"
 
-#define WAIT_LAP 10000
-                                               
 typedef enum
 {
        ACTION_NONE     = 1 << 0,
-       ACTION_PIPE_IN  = 1 << 1,
-       ACTION_PIPE_OUT = 1 << 2,
+       ACTION_PIPE_IN  = 1 << 1,
+       ACTION_PIPE_OUT = 1 << 2,
        ACTION_SINGLE   = 1 << 3,
-       ACTION_MULTIPLE = 1 << 4,
+       ACTION_MULTIPLE = 1 << 4,
        ACTION_ASYNC    = 1 << 5,
-       ACTION_OPEN_IN  = 1 << 6,
-       ACTION_HIDE_IN  = 1 << 7,
+       ACTION_OPEN_IN  = 1 << 6,
+       ACTION_HIDE_IN  = 1 << 7,
        ACTION_ERROR    = 1 << 8,
 } ActionType;
 
@@ -83,18 +81,17 @@ typedef struct _ChildInfo ChildInfo;
 
 struct _Children
 {
-       GtkWidget       *window;
-       GtkWidget       *dialog;
-       GtkWidget       *text;
-       GtkWidget       *input_entry;
-       GtkWidget       *input_hbox;
-       GtkWidget       *abort_btn;
-       GtkWidget       *hide_btn;
-       GtkWidget       *scrolledwin;
-
-       gchar           *action;
-       guint            timer;
-       GSList          *list;
+       GtkWidget       *window;
+       GtkWidget       *dialog;
+       GtkWidget       *text;
+       GtkWidget       *input_entry;
+       GtkWidget       *input_hbox;
+       GtkWidget       *abort_btn;
+       GtkWidget       *close_btn;
+       GtkWidget       *scrolledwin;
+
+       gchar           *action;
+       GSList          *list;
        gint             nb;
        gint             open_in;
        gboolean         output;
@@ -103,10 +100,10 @@ struct _Children
 struct _ChildInfo
 {
        Children        *children;
-       gchar           *cmd;
-       guint            type;
-       pid_t            pid;
-       gint             chld_in;
+       gchar           *cmd;
+       guint            type;
+       pid_t            pid;
+       gint             chld_in;
        gint             chld_out;
        gint             chld_err;
        gint             chld_status;
@@ -159,8 +156,8 @@ static void update_actions_menu             (GtkItemFactory *ifactory,
                                         gpointer        callback,
                                         gpointer        data);
 static void mainwin_actions_execute_cb         (MainWindow     *mainwin,
-                                        guint           action_nb,
-                                        GtkWidget      *widget);
+                                        guint           action_nb,
+                                        GtkWidget      *widget);
 static void compose_actions_execute_cb (Compose        *compose,
                                         guint           action_nb,
                                         GtkWidget      *widget);
@@ -184,8 +181,8 @@ static GString *parse_append_msgpart        (GString        *cmd,
                                         MimeView       *mimeview);
 
 ChildInfo *fork_child                  (gchar          *cmd,
-                                        gint            action_type,
-                                        GtkWidget      *text,
+                                        gint            action_type,
+                                        GtkWidget      *text,
                                         Children       *children);
 
 static gint wait_for_children          (gpointer        data);
@@ -195,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,
@@ -221,7 +217,7 @@ void prefs_actions_open(MainWindow *mainwin)
 
        if (!actions.window)
                prefs_actions_create(mainwin);
-       
+
        manage_window_set_transient(GTK_WINDOW(actions.window));
        gtk_widget_grab_focus(actions.ok_btn);
 
@@ -265,10 +261,10 @@ static void prefs_actions_create(MainWindow *mainwin)
        GtkWidget *btn_vbox;
        GtkWidget *up_btn;
        GtkWidget *down_btn;
-       
+
        gchar *title[1];
 
-       debug_print(_("Creating actions setting window...\n"));
+       debug_print("Creating actions setting window...\n");
 
        window = gtk_window_new (GTK_WINDOW_DIALOG);
 
@@ -343,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);
@@ -441,7 +437,7 @@ static void prefs_actions_create(MainWindow *mainwin)
 
        actions.name_entry = name_entry;
        actions.cmd_entry  = cmd_entry;
-       
+
        actions.actions_clist = cond_clist;
 }
 
@@ -453,14 +449,14 @@ static void prefs_actions_help_cb(GtkWidget *w, gpointer data)
                gtk_widget_hide(GTK_WIDGET(data));
 }
 
-void prefs_actions_read_config()
+void prefs_actions_read_config(void)
 {
        gchar *rcpath;
        FILE *fp;
        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) {
@@ -476,7 +472,7 @@ void prefs_actions_read_config()
                        g_slist_remove(prefs_common.actions_list, act);
                g_free(act);
        }
-       
+
        while (fgets(buf, sizeof(buf), fp) != NULL) {
                g_strchomp(buf);
                act = strstr(buf, ": ");
@@ -489,13 +485,13 @@ void prefs_actions_read_config()
        fclose(fp);
 }
 
-void prefs_actions_write_config()
+void prefs_actions_write_config(void)
 {
        gchar *rcpath;
        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) {
@@ -527,7 +523,7 @@ static guint get_action_type(gchar *action)
 {
        gchar *p;
        guint action_type = ACTION_NONE;
-       
+
        g_return_val_if_fail(action,  ACTION_ERROR);
        g_return_val_if_fail(*action, ACTION_ERROR);
 
@@ -598,7 +594,7 @@ static gchar *parse_action_cmd(gchar *action, MsgInfo *msginfo,
                        switch (p[1]) {
                        case 'f':
                                cmd = parse_append_filename(cmd, msginfo);
-                               p++;    
+                               p++;
                                break;
                        case 'F':
                                for (cur = GTK_CLIST(ctree)->selection;
@@ -666,7 +662,7 @@ static GString *parse_append_msgpart(GString *cmd, MsgInfo *msginfo,
        MimeInfo *partinfo;
        gint      ret;
        FILE     *fp;
-       
+
        if (!mimeview) {
 #if USE_GPGME
                if ((fp = procmsg_open_message_decrypted(msginfo, &partinfo))
@@ -675,8 +671,7 @@ static GString *parse_append_msgpart(GString *cmd, MsgInfo *msginfo,
                        return NULL;
                }
 #else
-               if ((fp = procmsg_open_message(msginfo)) == NULL)
-               {
+               if ((fp = procmsg_open_message(msginfo)) == NULL) {
                        alertpanel_error(_("Could not get message file."));
                        return NULL;
                }
@@ -747,14 +742,15 @@ static void prefs_actions_set_dialog(void)
                row = gtk_clist_append(clist, action);
                gtk_clist_set_row_data(clist, row, action[0]);
        }
-       
+
        gtk_clist_thaw(clist);
 }
+
 static void prefs_actions_set_list(void)
 {
        gint row = 1;
        gchar *action;
-       
+
        g_slist_free(prefs_common.actions_list);
        prefs_common.actions_list = NULL;
 
@@ -765,7 +761,6 @@ static void prefs_actions_set_list(void)
                row++;
        }
 }
-               
 
 #define GET_ENTRY(entry) \
        entry_text = gtk_entry_get_text(GTK_ENTRY(entry))
@@ -777,11 +772,8 @@ static gint prefs_actions_clist_set_row(gint row)
        gint len;
        gchar action[PREFSBUFSIZE];
        gchar *buf[1];
-       
-       
-       g_return_val_if_fail(row != 0, -1);
 
-       
+       g_return_val_if_fail(row != 0, -1);
 
        GET_ENTRY(actions.name_entry);
        if (entry_text[0] == '\0') {
@@ -793,7 +785,7 @@ static gint prefs_actions_clist_set_row(gint row)
                alertpanel_error(_("Colon ':' is not allowed in the menu name."));
                return -1;
        }
-       
+
        strncpy(action, entry_text, PREFSBUFSIZE - 1);
        g_strstrip(action);
 
@@ -823,7 +815,7 @@ static gint prefs_actions_clist_set_row(gint row)
                                 entry_text);
                return -1;
        }
-       
+
        strcat(action, entry_text);
 
        buf[0] = action;
@@ -838,14 +830,14 @@ static gint prefs_actions_clist_set_row(gint row)
        }
 
        buf[0] = g_strdup(action);
-       
+
        gtk_clist_set_row_data(clist, row, buf[0]);
 
        prefs_actions_set_list();
 
        return 0;
 }
-       
+
 /* callback functions */
 
 static void prefs_actions_register_cb(GtkWidget *w, gpointer data)
@@ -866,7 +858,7 @@ static void prefs_actions_substitute_cb(GtkWidget *w, gpointer data)
 
        action = gtk_clist_get_row_data(clist, row);
        if (!action) return;
-       
+
        prefs_actions_clist_set_row(row);
 }
 
@@ -918,6 +910,7 @@ static void prefs_actions_down(GtkWidget *w, gpointer data)
 
 #define ENTRY_SET_TEXT(entry, str) \
        gtk_entry_set_text(GTK_ENTRY(entry), str ? str : "")
+
 static void prefs_actions_select(GtkCList *clist, gint row, gint column,
                                 GdkEvent *event)
 {
@@ -931,7 +924,7 @@ static void prefs_actions_select(GtkCList *clist, gint row, gint column,
                ENTRY_SET_TEXT(actions.cmd_entry, "");
                return;
        }
-       
+
        strncpy(buf, action, PREFSBUFSIZE - 1);
        buf[PREFSBUFSIZE - 1] = 0x00;
        cmd = strstr(buf, ": ");
@@ -944,7 +937,7 @@ static void prefs_actions_select(GtkCList *clist, gint row, gint column,
        *cmd = 0x00;
        ENTRY_SET_TEXT(actions.name_entry, buf);
 }
-       
+
 static void prefs_actions_row_move(GtkCList *clist,
                                   gint source_row, gint dest_row)
 {
@@ -988,23 +981,36 @@ static void prefs_actions_ok(GtkWidget *widget, gpointer data)
        inc_unlock();
 }
 
-void update_mainwin_actions_menu(GtkItemFactory *ifactory, 
+void update_mainwin_actions_menu(GtkItemFactory *ifactory,
                                 MainWindow *mainwin)
 {
-       update_actions_menu(ifactory, "/Tools/Actions", 
-                           mainwin_actions_execute_cb, 
+       update_actions_menu(ifactory, "/Tools/Actions",
+                           mainwin_actions_execute_cb,
                            mainwin);
 }
 
-void update_compose_actions_menu(GtkItemFactory *ifactory, 
+void update_compose_actions_menu(GtkItemFactory *ifactory,
                                 gchar *branch_path,
                                 Compose *compose)
 {
-       update_actions_menu(ifactory, branch_path, 
-                           compose_actions_execute_cb, 
+       update_actions_menu(ifactory, branch_path,
+                           compose_actions_execute_cb,
                            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,
@@ -1018,7 +1024,7 @@ static void update_actions_menu(GtkItemFactory *ifactory,
        GtkItemFactoryEntry ifentry = {NULL, NULL, NULL, 0, "<Branch>"};
 
        ifentry.path = branch_path;
-       menuitem = gtk_item_factory_get_widget(ifactory, branch_path);  
+       menuitem = gtk_item_factory_get_widget(ifactory, branch_path);
        g_return_if_fail(menuitem != NULL);
 
        amenu = GTK_MENU_SHELL(menuitem)->children;
@@ -1039,7 +1045,7 @@ static void update_actions_menu(GtkItemFactory *ifactory,
                if (action_p && action_p[2] &&
                    get_action_type(&action_p[2]) != ACTION_ERROR) {
                        action_p[0] = 0x00;
-                       menu_path = g_strdup_printf("%s/%s", branch_path, 
+                       menu_path = g_strdup_printf("%s/%s", branch_path,
                                                    action);
                        ifentry.path = menu_path;
                        gtk_item_factory_create_item(ifactory, &ifentry, data,
@@ -1047,16 +1053,15 @@ static void update_actions_menu(GtkItemFactory *ifactory,
                        g_free(menu_path);
                }
                g_free(action);
-               ifentry.callback_action++;      
+               ifentry.callback_action++;
        }
 }
 
-static void compose_actions_execute_cb (Compose        *compose,
-                                        guint           action_nb,
-                                        GtkWidget      *widget)
+static void compose_actions_execute_cb(Compose *compose, guint action_nb,
+                                      GtkWidget *widget)
 {
        gchar *buf, *action;
-       guint action_type;      
+       guint action_type;
 
        g_return_if_fail(action_nb < g_slist_length(prefs_common.actions_list));
 
@@ -1079,9 +1084,8 @@ static void compose_actions_execute_cb    (Compose        *compose,
        execute_actions(action, compose->window, NULL, compose->text, NULL);
 }
 
-static void mainwin_actions_execute_cb         (MainWindow     *mainwin,
-                                        guint           action_nb,
-                                        GtkWidget      *widget)
+static void mainwin_actions_execute_cb(MainWindow *mainwin, guint action_nb,
+                                      GtkWidget *widget)
 {
        MessageView *messageview = mainwin->messageview;
        GtkWidget   *text = NULL;
@@ -1092,7 +1096,7 @@ static void mainwin_actions_execute_cb    (MainWindow     *mainwin,
        g_return_if_fail(action_nb < g_slist_length(prefs_common.actions_list));
 
        buf = (gchar *)g_slist_nth_data(prefs_common.actions_list, action_nb);
-       
+
        g_return_if_fail(buf);
        g_return_if_fail(action = strstr(buf, ": "));
 
@@ -1119,11 +1123,9 @@ static void mainwin_actions_execute_cb   (MainWindow     *mainwin,
                        GTK_CTREE(mainwin->summaryview->ctree), text, mimeview);
 }
 
-static gboolean execute_actions(gchar     *action, 
-                               GtkWidget *window,
-                               GtkCTree  *ctree, 
-                               GtkWidget *text,
-                               MimeView  *mimeview)
+static gboolean execute_actions(gchar *action, GtkWidget *window,
+                               GtkCTree *ctree, GtkWidget *text,
+                               MimeView *mimeview)
 {
        GList *cur, *selection = NULL;
        GSList *children_list = NULL;
@@ -1150,7 +1152,7 @@ static gboolean execute_actions(gchar     *action,
                selection = GTK_CLIST(ctree)->selection;
                selection_len = g_list_length(selection);
        }
-       
+
        if (action_type & (ACTION_PIPE_OUT | ACTION_PIPE_IN)) {
                if (ctree && selection_len > 1)
                        return FALSE; /* ERR: pipe + multiple selection */
@@ -1158,10 +1160,6 @@ static gboolean execute_actions(gchar     *action,
                        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) {
@@ -1175,7 +1173,7 @@ static gboolean execute_actions(gchar     *action,
                        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;
                        }
@@ -1183,8 +1181,8 @@ static gboolean execute_actions(gchar     *action,
                                                     children))) {
                                children_list = g_slist_append(children_list,
                                                               child_info);
-                               children->open_in = (selection_len == 1) ? 
-                                                   (action_type & 
+                               children->open_in = (selection_len == 1) ?
+                                                   (action_type &
                                                     (ACTION_OPEN_IN |
                                                      ACTION_HIDE_IN)) : 0;
                        }
@@ -1209,12 +1207,9 @@ static gboolean execute_actions(gchar     *action,
        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;
-               
+
                children->action  = g_strdup(action);
                children->window  = window;
                children->dialog  = NULL;
@@ -1228,19 +1223,14 @@ static gboolean execute_actions(gchar     *action,
                                              GDK_INPUT_READ,
                                              catch_status, child_info);
                }
-               children->timer = children->open_in ? 0 :
-                                 gtk_timeout_add(WAIT_LAP, wait_for_children,
-                                                 children);
-       }
-       if (children->open_in)
+
                create_io_dialog(children);
+       }
 
        return is_ok;
 }
 
-ChildInfo *fork_child(gchar *cmd,
-                     gint action_type,
-                     GtkWidget *text,
+ChildInfo *fork_child(gchar *cmd, gint action_type, GtkWidget *text,
                      Children *children)
 {
        gint chld_in[2], chld_out[2], chld_err[2], chld_status[2];
@@ -1275,7 +1265,7 @@ ChildInfo *fork_child(gchar *cmd,
                }
        }
 
-       debug_print(_("Forking child and grandchild.\n"));
+       debug_print("Forking child and grandchild.\n");
 
        pid = fork();
        if (pid == 0) { /* Child */
@@ -1290,9 +1280,9 @@ ChildInfo *fork_child(gchar *cmd,
                        if (setpgid(0, getppid()))
                                perror("setpgid");
                        if (sync) {
-                               if (action_type & 
-                                   (ACTION_PIPE_IN | 
-                                    ACTION_OPEN_IN | 
+                               if (action_type &
+                                   (ACTION_PIPE_IN |
+                                    ACTION_OPEN_IN |
                                     ACTION_HIDE_IN)) {
                                        close(fileno(stdin));
                                        dup  (chld_in[0]);
@@ -1316,7 +1306,7 @@ ChildInfo *fork_child(gchar *cmd,
                        cmdline[2] = cmd;
                        cmdline[3] = 0;
                        execvp("/bin/sh", cmdline);
-                       
+
                        perror("execvp");
                        _exit(1);
                } else if (gch_pid < (pid_t) 0) { /* Fork error */
@@ -1335,9 +1325,9 @@ ChildInfo *fork_child(gchar *cmd,
                                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]);
@@ -1346,14 +1336,14 @@ ChildInfo *fork_child(gchar *cmd,
                }
        } else if (pid < 0) { /* Fork error */
                alertpanel_error(_("Could not fork to execute the following "
-                                  "command:\n%s\n%s"), 
+                                  "command:\n%s\n%s"),
                                 cmd, g_strerror(errno));
                return NULL; 
        }
 
        /* Parent */
 
-       if (!sync) 
+       if (!sync)
                return NULL;
 
        close(chld_in[0]);
@@ -1366,7 +1356,7 @@ ChildInfo *fork_child(gchar *cmd,
        child_info = g_new0(ChildInfo, 1);
 
        child_info->children    = children;
-       
+
        child_info->pid         = pid;
        child_info->cmd         = g_strdup(cmd);
        child_info->type        = action_type;
@@ -1405,7 +1395,7 @@ ChildInfo *fork_child(gchar *cmd,
                is_selection = TRUE;
                if (start == end) {
                        start = 0;
-                       end   = gtk_stext_get_length(GTK_STEXT(text));
+                       end = gtk_stext_get_length(GTK_STEXT(text));
                        is_selection = FALSE;
                }
        }
@@ -1427,10 +1417,10 @@ ChildInfo *fork_child(gchar *cmd,
        }
 
        gtk_stext_thaw(GTK_STEXT(text));
-       
+
        return child_info;
 }
-       
+
 static void kill_children_cb(GtkWidget *widget, gpointer data)
 {
        GSList *cur;
@@ -1439,40 +1429,32 @@ 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);
-               if (child_info->pid && (kill(-child_info->pid, SIGTERM) < 0))
-                               perror("kill");
+               debug_print("Killing child group id %d\n", child_info->pid);
+               if (child_info->pid && kill(-child_info->pid, SIGTERM) < 0)
+                       perror("kill");
        }
 }
 
 static gint wait_for_children(gpointer data)
 {
        gboolean new_output;
-       Children *children = (Children *) data;
+       Children *children = (Children *)data;
        ChildInfo *child_info;
        GSList *cur;
        gint nb = children->nb;
 
        children->nb = 0;
-               
+
        cur = children->list;
        new_output = FALSE;
        while (cur) {
-               child_info = (ChildInfo *) cur->data;
+               child_info = (ChildInfo *)cur->data;
                if (child_info->pid)
                        children->nb++;
                new_output |= child_info->new_out;
                cur = cur->next;
        }
 
-       if (!children->dialog && 
-           (new_output || children->timer))
-               create_io_dialog(children);
-       
-       if (children->timer) {
-               gtk_timeout_remove(children->timer);
-               children->timer = 0;
-       }
        children->output |= new_output;
 
        if (new_output || (children->dialog && (nb != children->nb)))
@@ -1482,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;
 }
 
@@ -1494,7 +1476,7 @@ static void send_input(GtkWidget *w, gpointer data)
 {
        Children *children = (Children *) data;
        ChildInfo *child_info = (ChildInfo *) children->list->data;
-       
+
        child_info->tag_in = gdk_input_add(child_info->chld_in,
                                           GDK_INPUT_WRITE,
                                           catch_input, children);
@@ -1510,10 +1492,9 @@ static gint delete_io_dialog_cb(GtkWidget *w, GdkEvent *e, gpointer data)
 static void hide_io_dialog_cb(GtkWidget *w, gpointer data)
 {
 
-       Children *children = (Children *) 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);
@@ -1540,11 +1521,11 @@ static void free_children(Children *children)
        GSList *cur;
        ChildInfo *child_info;
 
-       debug_print(_("Freeing children data %x\n"), (guint) children);
-                               
+       debug_print("Freeing children data %p\n", children);
+
        g_free(children->action);
        for (cur = children->list; cur;) {
-               child_info = (ChildInfo *) cur->data;
+               child_info = (ChildInfo *)cur->data;
                g_free(child_info->cmd);
                g_string_free(child_info->output, TRUE);
                children->list = g_slist_remove(children->list, child_info);
@@ -1552,18 +1533,17 @@ static void free_children(Children *children)
                cur = children->list;
        }
        g_free(children);
-}      
+}
 
 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,7 +1559,7 @@ static void update_io_dialog(Children *children)
                gtk_text_forward_delete(GTK_TEXT(text), 
                                        gtk_text_get_length(GTK_TEXT(text)));
                for (cur = children->list; cur; cur = cur->next) {
-                       child_info = (ChildInfo *) cur->data;
+                       child_info = (ChildInfo *)cur->data;
                        if (child_info->pid)
                                caption = g_strdup_printf
                                        (_("--- Running: %s\n"),
@@ -1588,7 +1568,7 @@ static void update_io_dialog(Children *children)
                                caption = g_strdup_printf
                                        (_("--- Ended: %s\n"),
                                         child_info->cmd);
-                       
+
                        gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL,
                                        caption, -1);
                        gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL,
@@ -1599,11 +1579,11 @@ static void update_io_dialog(Children *children)
                gtk_text_thaw(GTK_TEXT(text));
        }
 }
-       
-       
+
 static void create_io_dialog(Children *children)
 {
        GtkWidget *dialog;
+       GtkWidget *vbox;
        GtkWidget *entry = NULL;
        GtkWidget *input_hbox = NULL;
        GtkWidget *send_button;
@@ -1612,29 +1592,37 @@ static void create_io_dialog(Children *children)
        GtkWidget *scrolledwin;
        GtkWidget *hbox;
        GtkWidget *abort_button;
-       GtkWidget *hide_button;
-       
-       debug_print(_("Creating actions dialog\n"));
+       GtkWidget *close_button;
 
-       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);
+       debug_print("Creating action IO dialog\n");
 
-       gtk_window_set_title(GTK_WINDOW(dialog), _("Actions' input/output"));
+       dialog = gtk_dialog_new();
+       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
@@ -1650,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);
+               gtk_box_pack_start(GTK_BOX(input_hbox), send_button, FALSE,
+                                  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);
 
@@ -1695,40 +1676,40 @@ 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);
 }
 
 static void catch_status(gpointer data, gint source, GdkInputCondition cond)
 {
-       ChildInfo *child_info = (ChildInfo *) data;
+       ChildInfo *child_info = (ChildInfo *)data;
        gchar buf;
        gint c;
 
        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);
        child_info->pid = 0;
-       
+
        wait_for_children(child_info->children);
 }
        
 static void catch_input(gpointer data, gint source, GdkInputCondition cond)
 {
-       Children *children = (Children *) data;
-       ChildInfo *child_info = (ChildInfo *) children->list->data;
+       Children *children = (Children *)data;
+       ChildInfo *child_info = (ChildInfo *)children->list->data;
        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;
-       
+
        gdk_input_remove(child_info->tag_in);
        child_info->tag_in = -1;
 
@@ -1742,16 +1723,16 @@ 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)
 {
-       ChildInfo *child_info = (ChildInfo *) data;
+       ChildInfo *child_info = (ChildInfo *)data;
        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;
@@ -1771,7 +1752,7 @@ static void catch_output(gpointer data, gint source, GdkInputCondition cond)
                         * so we just change selection position and 
                         * defere drawing when thawing. Hack?
                         */
-                       GTK_EDITABLE(text)->selection_end_pos = 
+                       GTK_EDITABLE(text)->selection_end_pos =
                                        gtk_stext_get_point(GTK_STEXT(text));
                }
                gtk_stext_thaw(GTK_STEXT(child_info->text));