sync with 0.8.11cvs31
authorPaul Mangan <paul@claws-mail.org>
Tue, 22 Apr 2003 13:53:19 +0000 (13:53 +0000)
committerPaul Mangan <paul@claws-mail.org>
Tue, 22 Apr 2003 13:53:19 +0000 (13:53 +0000)
18 files changed:
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.ac
src/action.c
src/action.h
src/codeconv.c
src/common/utils.c
src/common/utils.h
src/html.c
src/inputdialog.c
src/messageview.c
src/messageview.h
src/mimeview.c
src/mimeview.h
src/procheader.h
src/summaryview.c
src/summaryview.h

index 50ed573..17d82ee 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2003-04-22
+
+       * src/action.[ch]: refactored. Also fixed a bug on MIME mode, and
+         some memory leaks on error.
+         action_update_msgview_menu(): new.
+       * src/messageview.[ch]: added "Tools/Actions" menu. Keep window list.
+         messageview_get_selected_mime_part(): returns MimeInfo of selected
+         part when MessageView is in MIME mode.
+       * src/mimeview.[ch]: mimeview_get_selected_part(): returns MimeInfo
+         of selected part.
+       * src/summaryview.[ch]: summary_get_selected_msg_list(): returns
+         MsgInfo list of selected messages.
+
+2003-04-21
+
+       * src/prefs_filter.[ch]: include original message's headers as
+         the preset keywords. Modified the sizes of the widgets.
+       * src/utils.[ch]: added str_case_equal() and str_case_hash() for
+         case-insensitive hash.
+
 2003-04-18
 
        * src/procmsg.c: procmsg_get_filter_keyword(): added X-Sequence to
index 9a06443..08aec4a 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-22 [paul]      0.8.11claws106
+
+       * sync with 0.8.11cvs31
+               see ChangeLog 2003-04-21 and 2003-04-22
+
 2003-04-21 [alfons]    0.8.11claws105
 
        * src/main.c
index def4fdc..1f55bfa 100644 (file)
@@ -1,3 +1,24 @@
+2003-04-22
+
+       * src/action.[ch]: ¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¡£ ¤Þ¤¿ MIME ¥â¡¼¥É¤Ë¤ª¤±¤ë¥Ð¥°
+         ¤È¡¢¥¨¥é¡¼»þ¤Î¥á¥â¥ê¥ê¡¼¥¯¤ò½¤Àµ¡£
+         action_update_msgview_menu(): ¿·µ¬¡£
+       * src/messageview.[ch]: "Tools/Actions" ¥á¥Ë¥å¡¼¤òÄɲᣥ¦¥£¥ó¥É¥¦
+         ¥ê¥¹¥È¤òÊÝ»ý¡£
+         messageview_get_selected_mime_part(): MessageView ¤¬ MIME ¥â¡¼¥É
+         ¤Î¤È¤­¡¢ÁªÂò¤µ¤ì¤¿¥Ñ¡¼¥È¤Î MimeInfo ¤òÊÖ¤¹¡£
+       * src/mimeview.[ch]: mimeview_get_selected_part(): ÁªÂò¤µ¤ì¤¿¥Ñ¡¼¥È
+         ¤Î MimeInfo ¤òÊÖ¤¹¡£
+       * src/summaryview.[ch]: summary_get_selected_msg_list(): ÁªÂò¤µ¤ì¤¿
+         ¥á¥Ã¥»¡¼¥¸¤Î MsgInfo ¥ê¥¹¥È¤òÊÖ¤¹¡£
+
+2003-04-21
+
+       * src/prefs_filter.[ch]: ¸µ¤Î¥á¥Ã¥»¡¼¥¸¤Î¥Ø¥Ã¥À¤ò¥»¥Ã¥ÈºÑ¥­¡¼¥ï¡¼¥É
+         ¤È¤·¤Æ´Þ¤à¤è¤¦¤Ë¤·¤¿¡£¥¦¥£¥¸¥§¥Ã¥È¤Î¥µ¥¤¥º¤ò½¤Àµ¡£
+       * src/utils.[ch]: Â羮ʸ»ú¤ò¶èÊ̤·¤Ê¤¤¥Ï¥Ã¥·¥åÍѤˠstr_case_equal()
+         ¤È str_case_hash() ¤òÄɲá£
+
 2003-04-18
 
        * src/procmsg.c: procmsg_get_filter_keyword(): ¼«Æ°¸¡½Ð¤µ¤ì¤ë¥Ø¥Ã¥À
index 113144d..e8cc47c 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=11
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws105
+EXTRA_VERSION=claws106
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index a123b91..1335bae 100644 (file)
@@ -48,7 +48,6 @@
 #include "compose.h"
 #include "procmsg.h"
 #include "gtkstext.h"
-#include "mimeview.h"
 #include "textview.h"
 
 typedef struct _Children               Children;
@@ -70,6 +69,9 @@ struct _Children
        gint             nb;
        gint             open_in;
        gboolean         output;
+
+       GtkWidget       *msg_text;
+       GdkFont         *msgfont;
 };
 
 struct _ChildInfo
@@ -87,9 +89,8 @@ struct _ChildInfo
        gint             tag_err;
        gint             tag_status;
        gint             new_out;
+
        GString         *output;
-       GtkWidget       *text;
-       GdkFont         *msgfont;
 };
 
 static void action_update_menu         (GtkItemFactory *ifactory,
@@ -107,19 +108,19 @@ static void msgview_actions_execute_cb    (MessageView    *msgview,
                                         GtkWidget      *widget);
 static void message_actions_execute    (MessageView    *msgview,
                                         guint           action_nb,
-                                        GtkCTree       *ctree);
+                                        GSList         *msg_list);
 
 static gboolean execute_actions                (gchar          *action, 
-                                        GtkCTree       *ctree
+                                        GSList         *msg_list
                                         GtkWidget      *text,
                                         GdkFont        *msgfont,
                                         gint            body_pos,
-                                        MimeView       *mimeview);
+                                        MimeInfo       *partinfo);
 
 static gchar *parse_action_cmd         (gchar          *action,
                                         MsgInfo        *msginfo,
-                                        GtkCTree       *ctree,
-                                        MimeView       *mimeview,
+                                        GSList         *msg_list,
+                                        MimeInfo       *partinfo,
                                         const gchar    *user_str,
                                         const gchar    *user_hidden_str,
                                         const gchar    *sel_str);
@@ -128,13 +129,11 @@ static gboolean parse_append_filename     (GString        *cmd,
 
 static gboolean parse_append_msgpart   (GString        *cmd,
                                         MsgInfo        *msginfo,
-                                        MimeView       *mimeview);
+                                        MimeInfo       *partinfo);
 
 static ChildInfo *fork_child           (gchar          *cmd,
                                         gint            action_type,
-                                        GtkWidget      *text,
-                                        GdkFont        *msgfont,
-                                        gint            body_pos,
+                                        const gchar    *msg_str,
                                         Children       *children);
 
 static gint wait_for_children          (Children       *children);
@@ -232,15 +231,14 @@ ActionType action_get_type(const gchar *action_str)
 }
 
 static gchar *parse_action_cmd(gchar *action, MsgInfo *msginfo,
-                              GtkCTree *ctree, MimeView *mimeview,
+                              GSList *msg_list, MimeInfo *partinfo,
                               const gchar *user_str,
                               const gchar *user_hidden_str,
                               const gchar *sel_str)
 {
        GString *cmd;
        gchar *p;
-       GList *cur;
-       MsgInfo *msg;
+       GSList *cur;
        
        p = action;
        
@@ -261,10 +259,10 @@ static gchar *parse_action_cmd(gchar *action, MsgInfo *msginfo,
                                p++;
                                break;
                        case 'F':
-                               for (cur = GTK_CLIST(ctree)->selection;
-                                    cur != NULL; cur = cur->next) {
-                                       msg = gtk_ctree_node_get_row_data(ctree,
-                                             GTK_CTREE_NODE(cur->data));
+                               for (cur = msg_list; cur != NULL;
+                                    cur = cur->next) {
+                                       MsgInfo *msg = (MsgInfo *)cur->data;
+
                                        if (!parse_append_filename(cmd, msg)) {
                                                g_string_free(cmd, TRUE);
                                                return NULL;
@@ -276,7 +274,7 @@ static gchar *parse_action_cmd(gchar *action, MsgInfo *msginfo,
                                break;
                        case 'p':
                                if (!parse_append_msgpart(cmd, msginfo,
-                                                         mimeview)) {
+                                                         partinfo)) {
                                        g_string_free(cmd, TRUE);
                                        return NULL;
                                }
@@ -338,15 +336,15 @@ static gboolean parse_append_filename(GString *cmd, MsgInfo *msginfo)
 }
 
 static gboolean parse_append_msgpart(GString *cmd, MsgInfo *msginfo,
-                                    MimeView *mimeview)
+                                    MimeInfo *partinfo)
 {
-       gchar    *filename;
-       gchar    *partname;
-       MimeInfo *partinfo;
-       gint      ret;
-       FILE     *fp;
+       gboolean single_part = FALSE;
+       gchar *filename;
+       gchar *part_filename;
+       gint ret;
 
-       if (!mimeview) {
+       if (!partinfo) {
+               FILE *fp;
 #if USE_GPGME
                if ((fp = procmsg_open_message_decrypted(msginfo, &partinfo))
                    == NULL) {
@@ -366,40 +364,28 @@ static gboolean parse_append_msgpart(GString *cmd, MsgInfo *msginfo,
                        alertpanel_error(_("Could not get message part."));
                        return FALSE;
                }
-               filename = procmsg_get_message_file(msginfo);
-       } else {
-               if (!mimeview->opened) {
-                       alertpanel_error(_("No message part selected."));
-                       return FALSE;
-               }
-               if (!mimeview->file) {
-                       alertpanel_error(_("No message file selected."));
-                       return FALSE;
-               }
-               partinfo = gtk_ctree_node_get_row_data
-                               (GTK_CTREE(mimeview->ctree),
-                                mimeview->opened);
-               g_return_val_if_fail(partinfo != NULL, FALSE);
-               filename = mimeview->file;
+
+               single_part = TRUE;
        }
-       partname = procmime_get_tmp_file_name(partinfo);
 
-       ret = procmime_get_part(partname, filename, partinfo); 
+       filename = procmsg_get_message_file_path(msginfo);
+       part_filename = procmime_get_tmp_file_name(partinfo);
+
+       ret = procmime_get_part(part_filename, filename, partinfo); 
 
-       if (!mimeview) {
+       if (single_part)
                procmime_mimeinfo_free_all(partinfo);
-               g_free(filename);
-       }
+       g_free(filename);
 
        if (ret < 0) {
                alertpanel_error(_("Can't get part of multipart message"));
-               g_free(partname);
+               g_free(part_filename);
                return FALSE;
        }
 
-       g_string_append(cmd, partname);
+       g_string_append(cmd, part_filename);
 
-       g_free(partname);
+       g_free(part_filename);
 
        return TRUE;
 }
@@ -423,6 +409,12 @@ void action_update_mainwin_menu(GtkItemFactory *ifactory, MainWindow *mainwin)
                           mainwin_actions_execute_cb, mainwin);
 }
 
+void action_update_msgview_menu(GtkItemFactory *ifactory, MessageView *msgview)
+{
+       action_update_menu(ifactory, "/Tools/Actions",
+                          msgview_actions_execute_cb, msgview);
+}
+
 void action_update_compose_menu(GtkItemFactory *ifactory, Compose *compose)
 {
        action_update_menu(ifactory, "/Tools/Actions",
@@ -503,21 +495,29 @@ static void compose_actions_execute_cb(Compose *compose, guint action_nb,
 static void mainwin_actions_execute_cb(MainWindow *mainwin, guint action_nb,
                                       GtkWidget *widget)
 {
-       message_actions_execute(mainwin->messageview, action_nb,
-                               GTK_CTREE(mainwin->summaryview->ctree));
+       GSList *msg_list;
+
+       msg_list = summary_get_selected_msg_list(mainwin->summaryview);
+       message_actions_execute(mainwin->messageview, action_nb, msg_list);
+       g_slist_free(msg_list);
 }
 
 static void msgview_actions_execute_cb(MessageView *msgview, guint action_nb,
                                       GtkWidget *widget)
 {
-       message_actions_execute(msgview, action_nb, NULL);
+       GSList *msg_list = NULL;
+
+       if (msgview->msginfo)
+               msg_list = g_slist_append(msg_list, msgview->msginfo);
+       message_actions_execute(msgview, action_nb, msg_list);
+       g_slist_free(msg_list);
 }
 
 static void message_actions_execute(MessageView *msgview, guint action_nb,
-                                   GtkCTree *ctree)
+                                   GSList *msg_list)
 {
-       TextView *textview = NULL;
-       MimeView *mimeview = NULL;
+       TextView *textview;
+       MimeInfo *partinfo;
        gchar *buf;
        gchar *action;
        GtkWidget *text = NULL;
@@ -534,45 +534,32 @@ static void message_actions_execute(MessageView *msgview, guint action_nb,
        /* Point to the beginning of the command-line */
        action += 2;
 
-       switch (msgview->type) {
-       case MVIEW_TEXT:
-               if (msgview->textview && msgview->textview->text)
-                       textview = msgview->textview;
-               break;
-       case MVIEW_MIME:
-               if (msgview->mimeview) {
-                       mimeview = msgview->mimeview;
-                       if (msgview->mimeview->type == MIMEVIEW_TEXT &&
-                           msgview->mimeview->textview &&
-                           msgview->mimeview->textview->text)
-                               textview = msgview->mimeview->textview;
-               }
-               break;
-       }
-
+       textview = messageview_get_current_textview(msgview);
        if (textview) {
                text     = textview->text;
                msgfont  = textview->msgfont;
                body_pos = textview->body_pos;
        }
+       partinfo = messageview_get_selected_mime_part(msgview);
 
-       execute_actions(action, ctree, text, msgfont, body_pos, mimeview);
+       execute_actions(action, msg_list, text, msgfont, body_pos, partinfo);
 }
 
-static gboolean execute_actions(gchar *action, GtkCTree *ctree,
+static gboolean execute_actions(gchar *action, GSList *msg_list,
                                GtkWidget *text, GdkFont *msgfont,
-                               gint body_pos, MimeView *mimeview)
+                               gint body_pos, MimeInfo *partinfo)
 {
-       GList *cur, *selection = NULL;
        GSList *children_list = NULL;
        gint is_ok  = TRUE;
-       gint selection_len = 0;
+       gint msg_list_len;
        Children *children;
        ChildInfo *child_info;
        gint action_type;
        MsgInfo *msginfo;
        gchar *cmd;
+       guint start = 0, end = 0;
        gchar *sel_str = NULL;
+       gchar *msg_str = NULL;
        gchar *user_str = NULL;
        gchar *user_hidden_str = NULL;
 
@@ -583,17 +570,13 @@ static gboolean execute_actions(gchar *action, GtkCTree *ctree,
        if (action_type == ACTION_ERROR)
                return FALSE;         /* ERR: syntax error */
 
-       if (action_type & (ACTION_SINGLE | ACTION_MULTIPLE) && 
-           !(ctree && GTK_CLIST(ctree)->selection))
+       if (action_type & (ACTION_SINGLE | ACTION_MULTIPLE) && !msg_list)
                return FALSE;         /* ERR: file command without selection */
 
-       if (ctree) {
-               selection = GTK_CLIST(ctree)->selection;
-               selection_len = g_list_length(selection);
-       }
+       msg_list_len = g_slist_length(msg_list);
 
        if (action_type & (ACTION_PIPE_OUT | ACTION_PIPE_IN | ACTION_INSERT)) {
-               if (ctree && selection_len > 1)
+               if (msg_list_len > 1)
                        return FALSE; /* ERR: pipe + multiple selection */
                if (!text)
                        return FALSE; /* ERR: pipe and no displayed text */
@@ -602,80 +585,109 @@ static gboolean execute_actions(gchar *action, GtkCTree *ctree,
        if (action_type & ACTION_SELECTION_STR) {
                if (!text)
                        return FALSE; /* ERR: selection string but no text */
-               else {
-                       guint start = 0, end = 0;
-                       if (GTK_EDITABLE(text)->has_selection) {
-                               start = GTK_EDITABLE(text)->selection_start_pos;
-                               end   = GTK_EDITABLE(text)->selection_end_pos;
-                               if (start > end) {
-                                       guint tmp;
-                                       tmp = start;
-                                       start = end;
-                                       end = tmp;
-                               }
-                       }
+       }
+
+       if (GTK_EDITABLE(text)->has_selection) {
+               start = GTK_EDITABLE(text)->selection_start_pos;
+               end   = GTK_EDITABLE(text)->selection_end_pos;
+               if (start > end) {
+                       guint tmp;
+                       tmp = start;
+                       start = end;
+                       end = tmp;
+               }
+
+               if (start == end) {
+                       start = body_pos;
+                       end = gtk_stext_get_length(GTK_STEXT(text));
+                       msg_str = gtk_editable_get_chars(GTK_EDITABLE(text),
+                                                        start, end);
+               } else {
                        sel_str = gtk_editable_get_chars(GTK_EDITABLE(text),
                                                         start, end);
+                       msg_str = g_strdup(sel_str);
                }
+       } else {
+               start = body_pos;
+               end = gtk_stext_get_length(GTK_STEXT(text));
+               msg_str = gtk_editable_get_chars(GTK_EDITABLE(text),
+                                                start, end);
        }
 
-       if (action_type & (ACTION_USER_STR))
-               if (!(user_str = get_user_string(action, ACTION_USER_STR)))
+       if (action_type & ACTION_USER_STR) {
+               if (!(user_str = get_user_string(action, ACTION_USER_STR))) {
+                       g_free(msg_str);
+                       g_free(sel_str);
                        return FALSE;
+               }
+       }
 
-       if (action_type & (ACTION_USER_HIDDEN_STR))
+       if (action_type & ACTION_USER_HIDDEN_STR) {
                if (!(user_hidden_str =
-                       get_user_string(action, ACTION_USER_HIDDEN_STR)))
+                       get_user_string(action, ACTION_USER_HIDDEN_STR))) {
+                       g_free(msg_str);
+                       g_free(sel_str);
+                       g_free(user_str);
                        return FALSE;
+               }
+       }
+
+       if (action_type & ACTION_PIPE_OUT) {
+               gtk_stext_freeze(GTK_STEXT(text));
+               gtk_stext_set_point(GTK_STEXT(text), start);
+               gtk_stext_forward_delete(GTK_STEXT(text), end - start);
+               gtk_stext_thaw(GTK_STEXT(text));
+       }
 
        children = g_new0(Children, 1);
 
+       children->msg_text = text;
+       children->msgfont = msgfont;
+
+       if ((action_type & (ACTION_USER_IN | ACTION_USER_HIDDEN_IN)) &&
+           ((action_type & ACTION_SINGLE) == 0 || msg_list_len == 1))
+               children->open_in = 1;
+
        if (action_type & ACTION_SINGLE) {
-               for (cur = selection; cur && is_ok == TRUE; cur = cur->next) {
-                       msginfo = gtk_ctree_node_get_row_data(ctree,
-                                       GTK_CTREE_NODE(cur->data));
+               GSList *cur;
+
+               for (cur = msg_list; cur && is_ok == TRUE; cur = cur->next) {
+                       msginfo = (MsgInfo *)cur->data;
                        if (!msginfo) {
                                is_ok  = FALSE; /* ERR: msginfo missing */
                                break;
                        }
-                       cmd = parse_action_cmd(action, msginfo, ctree,
-                                              mimeview, user_str,
+                       cmd = parse_action_cmd(action, msginfo, msg_list,
+                                              partinfo, user_str,
                                               user_hidden_str, sel_str);
                        if (!cmd) {
                                debug_print("Action command error\n");
                                is_ok  = FALSE; /* ERR: incorrect command */
                                break;
                        }
-                       if ((child_info = fork_child(cmd, action_type, text,
-                                                    msgfont, body_pos,
+                       if ((child_info = fork_child(cmd, action_type, msg_str,
                                                     children))) {
                                children_list = g_slist_append(children_list,
                                                               child_info);
-                               children->open_in = (selection_len == 1) ?
-                                                   (action_type &
-                                                    (ACTION_USER_IN |
-                                                     ACTION_USER_HIDDEN_IN)) : 0;
                        }
                        g_free(cmd);
                }
        } else {
-               cmd = parse_action_cmd(action, NULL, ctree, mimeview, user_str,
-                                      user_hidden_str, sel_str);
+               cmd = parse_action_cmd(action, NULL, msg_list, partinfo,
+                                      user_str, user_hidden_str, sel_str);
                if (cmd) {
-                       if ((child_info = fork_child(cmd, action_type, text,
-                                                    msgfont, body_pos,
+                       if ((child_info = fork_child(cmd, action_type, msg_str,
                                                     children))) {
                                children_list = g_slist_append(children_list,
                                                               child_info);
-                               children->open_in = action_type &
-                                                   (ACTION_USER_IN |
-                                                    ACTION_USER_HIDDEN_IN);
                        }
                        g_free(cmd);
                } else
                        is_ok  = FALSE;         /* ERR: incorrect command */
        }
 
+       g_free(msg_str);
+       g_free(sel_str);
        g_free(user_str);
        g_free(user_hidden_str);
 
@@ -704,15 +716,11 @@ static gboolean execute_actions(gchar *action, GtkCTree *ctree,
        return is_ok;
 }
 
-static ChildInfo *fork_child(gchar *cmd, gint action_type, GtkWidget *text,
-                            GdkFont *msgfont, gint body_pos,
-                            Children *children)
+static ChildInfo *fork_child(gchar *cmd, gint action_type,
+                            const gchar *msg_str, Children *children)
 {
        gint chld_in[2], chld_out[2], chld_err[2], chld_status[2];
        gchar *cmdline[4];
-       guint start, end;
-       gint is_selection;
-       gchar *selection;
        pid_t pid, gch_pid;
        ChildInfo *child_info;
        gint sync;
@@ -755,6 +763,7 @@ static ChildInfo *fork_child(gchar *cmd, gint action_type, GtkWidget *text,
                if (gch_pid == 0) {
                        if (setpgid(0, getppid()))
                                perror("setpgid");
+
                        if (sync) {
                                if (action_type &
                                    (ACTION_PIPE_IN |
@@ -799,8 +808,7 @@ static ChildInfo *fork_child(gchar *cmd, gint action_type, GtkWidget *text,
                                close(chld_err[0]);
                                close(chld_err[1]);
                                close(chld_status[0]);
-                       }
-                       if (sync) {
+
                                debug_print("Child: Waiting for grandchild\n");
                                waitpid(gch_pid, NULL, 0);
                                debug_print("Child: grandchild ended\n");
@@ -824,7 +832,8 @@ static ChildInfo *fork_child(gchar *cmd, gint action_type, GtkWidget *text,
        }
 
        close(chld_in[0]);
-       if (!(action_type & (ACTION_PIPE_IN | ACTION_USER_IN | ACTION_USER_HIDDEN_IN)))
+       if (!(action_type &
+             (ACTION_PIPE_IN | ACTION_USER_IN | ACTION_USER_HIDDEN_IN)))
                close(chld_in[1]);
        close(chld_out[1]);
        close(chld_err[1]);
@@ -855,46 +864,12 @@ static ChildInfo *fork_child(gchar *cmd, gint action_type, GtkWidget *text,
        if (!(action_type & (ACTION_PIPE_IN | ACTION_PIPE_OUT | ACTION_INSERT)))
                return child_info;
 
-       child_info->text        = text;
-       child_info->msgfont     = msgfont;
-
-       start = body_pos;
-       end   = gtk_stext_get_length(GTK_STEXT(text));
-
-       if (GTK_EDITABLE(text)->has_selection) {
-               start = GTK_EDITABLE(text)->selection_start_pos;
-               end   = GTK_EDITABLE(text)->selection_end_pos;
-               if (start > end) {
-                       guint tmp;
-                       tmp = start;
-                       start = end;
-                       end = tmp;
-               }
-               is_selection = TRUE;
-               if (start == end) {
-                       start = 0;
-                       end = gtk_stext_get_length(GTK_STEXT(text));
-                       is_selection = FALSE;
-               }
-       }
-
-       selection = gtk_editable_get_chars(GTK_EDITABLE(text), start, end);
-
-       if (action_type & ACTION_PIPE_IN) {
-               write(chld_in[1], selection, strlen(selection));
+       if ((action_type & ACTION_PIPE_IN) && msg_str) {
+               write(chld_in[1], msg_str, strlen(msg_str));
                if (!(action_type & (ACTION_USER_IN | ACTION_USER_HIDDEN_IN)))
                        close(chld_in[1]);
                child_info->chld_in = -1; /* No more input */
        }
-       g_free(selection);
-
-       gtk_stext_freeze(GTK_STEXT(text));
-       if (action_type & ACTION_PIPE_OUT) {
-               gtk_stext_set_point(GTK_STEXT(text), start);
-               gtk_stext_forward_delete(GTK_STEXT(text), end - start);
-       }
-
-       gtk_stext_thaw(GTK_STEXT(text));
 
        return child_info;
 }
@@ -1236,7 +1211,8 @@ static void catch_output(gpointer data, gint source, GdkInputCondition cond)
        if (child_info->type & (ACTION_PIPE_OUT | ACTION_INSERT)
            && source == child_info->chld_out) {
                gboolean is_selection = FALSE;
-               GtkWidget *text = child_info->text;
+               GtkWidget *text = child_info->children->msg_text;
+
                if (GTK_EDITABLE(text)->has_selection)
                        is_selection = TRUE;
                gtk_stext_freeze(GTK_STEXT(text));
@@ -1244,7 +1220,8 @@ static void catch_output(gpointer data, gint source, GdkInputCondition cond)
                        c = read(source, buf, sizeof(buf) - 1);
                        if (c == 0)
                                break;
-                       gtk_stext_insert(GTK_STEXT(text), child_info->msgfont,
+                       gtk_stext_insert(GTK_STEXT(text),
+                                        child_info->children->msgfont,
                                         NULL, NULL, buf, c);
                }
                if (is_selection) {
@@ -1255,7 +1232,7 @@ static void catch_output(gpointer data, gint source, GdkInputCondition cond)
                        GTK_EDITABLE(text)->selection_end_pos =
                                        gtk_stext_get_point(GTK_STEXT(text));
                }
-               gtk_stext_thaw(GTK_STEXT(child_info->text));
+               gtk_stext_thaw(GTK_STEXT(text));
        } else {
                c = read(source, buf, sizeof(buf) - 1);
                for (i = 0; i < c; i++)
@@ -1266,17 +1243,6 @@ static void catch_output(gpointer data, gint source, GdkInputCondition cond)
        wait_for_children(child_info->children);
 }
 
-static gboolean user_string_dialog_delete_cb(GtkWidget *widget,
-                                            GdkEvent *event, gpointer data)
-{
-       return FALSE;
-}
-
-static void user_string_dialog_destroy_cb(GtkWidget *widget, gpointer data)
-{
-       gtk_main_quit();
-}
-
 static gchar *get_user_string(const gchar *action, ActionType type)
 {
        gchar *message;
index 28d3fe2..a7abadb 100644 (file)
@@ -24,6 +24,7 @@
 #include <gtk/gtkitemfactory.h>
 
 #include "mainwindow.h"
+#include "messageview.h"
 #include "compose.h"
 
 typedef enum
@@ -52,6 +53,8 @@ void actions_execute                    (gpointer       data,
 
 void action_update_mainwin_menu        (GtkItemFactory *ifactory, 
                                 MainWindow     *mainwin);
+void action_update_msgview_menu        (GtkItemFactory *ifactory,
+                                MessageView    *msgview);
 void action_update_compose_menu        (GtkItemFactory *ifactory, 
                                 Compose        *compose);
 
index 52db04e..50990d8 100644 (file)
@@ -1148,25 +1148,6 @@ static GHashTable *conv_get_charset_to_str_table(void)
        return table;
 }
 
-static gint str_case_equal(gconstpointer v, gconstpointer v2)
-{
-       return strcasecmp((const gchar *)v, (const gchar *)v2) == 0;
-}
-
-static guint str_case_hash(gconstpointer key)
-{
-       const gchar *p = key;
-       guint h = *p;
-
-       if (h) {
-               h = tolower(h);
-               for (p += 1; *p != '\0'; p++)
-                       h = (h << 5) - h + tolower(*p);
-       }
-
-       return h;
-}
-
 static GHashTable *conv_get_charset_from_str_table(void)
 {
        static GHashTable *table;
index 462e857..8c851ba 100644 (file)
@@ -109,6 +109,25 @@ void hash_free_value_mem(GHashTable *table)
        g_hash_table_foreach(table, hash_free_value_mem_func, NULL);
 }
 
+gint str_case_equal(gconstpointer v, gconstpointer v2)
+{
+       return strcasecmp((const gchar *)v, (const gchar *)v2) == 0;
+}
+
+guint str_case_hash(gconstpointer key)
+{
+       const gchar *p = key;
+       guint h = *p;
+
+       if (h) {
+               h = tolower(h);
+               for (p += 1; *p != '\0'; p++)
+                       h = (h << 5) - h + tolower(*p);
+       }
+
+       return h;
+}
+
 void ptr_array_free_strings(GPtrArray *array)
 {
        gint i;
index 95c6c71..76e5ef1 100644 (file)
@@ -152,6 +152,10 @@ void slist_free_strings            (GSList         *list);
 void hash_free_strings         (GHashTable     *table);
 void hash_free_value_mem       (GHashTable     *table);
 
+gint str_case_equal            (gconstpointer   v,
+                                gconstpointer   v2);
+guint str_case_hash            (gconstpointer   key);
+
 void ptr_array_free_strings    (GPtrArray      *array);
 
 /* number-string conversion */
index da489b9..3f708a3 100644 (file)
@@ -319,11 +319,6 @@ static void html_get_parenthesis   (HTMLParser     *parser,
                                         gchar          *buf,
                                         gint            len);
 
-#if 0
-static gint g_str_case_equal           (gconstpointer   v,
-                                        gconstpointer   v2);
-static guint g_str_case_hash           (gconstpointer   key);
-#endif
 
 HTMLParser *html_parser_new(FILE *fp, CodeConverter *conv)
 {
@@ -778,25 +773,3 @@ static void html_get_parenthesis(HTMLParser *parser, gchar *buf, gint len)
        g_strstrip(buf);
        parser->bufp = p + 1;
 }
-
-/* these hash functions were taken from gstring.c in glib */
-#if 0
-static gint g_str_case_equal(gconstpointer v, gconstpointer v2)
-{
-       return strcasecmp((const gchar *)v, (const gchar *)v2) == 0;
-}
-
-static guint g_str_case_hash(gconstpointer key)
-{
-       const gchar *p = key;
-       guint h = *p;
-
-       if (h) {
-               h = tolower(h);
-               for (p += 1; *p != '\0'; p++)
-                       h = (h << 5) - h + tolower(*p);
-       }
-
-       return h;
-}
-#endif
index ff2cd8d..2966a43 100644 (file)
@@ -269,12 +269,12 @@ static void input_dialog_set(const gchar *title, const gchar *message,
 
        gtk_window_set_title(GTK_WINDOW(dialog), title);
        gtk_label_set_text(GTK_LABEL(msg_label), message);
-       if (default_string && *default_string)
+       if (default_string && *default_string) {
                gtk_entry_set_text(GTK_ENTRY(entry_), default_string);
-       else
+               gtk_entry_set_position(GTK_ENTRY(entry_), 0);
+               gtk_entry_select_region(GTK_ENTRY(entry_), 0, -1);
+       } else
                gtk_entry_set_text(GTK_ENTRY(entry_), "");
-       gtk_entry_set_position(GTK_ENTRY(entry_), 0);
-       gtk_entry_select_region(GTK_ENTRY(entry_), 0, -1);
 
        gtk_widget_grab_focus(ok_button);
        gtk_widget_grab_focus(entry_);
index 710b8e1..5542230 100644 (file)
@@ -52,6 +52,7 @@
 #include "procheader.h"
 #include "procmime.h"
 #include "account.h"
+#include "action.h"
 #include "prefs_common.h"
 #include "prefs_account.h"
 #include "gtkutils.h"
@@ -61,6 +62,7 @@
 #include "pgptext.h"
 #include "stock_pixmap.h"
 
+static GList *messageview_list = NULL;
 
 static void messageview_change_view_type(MessageView   *messageview,
                                         MessageType     type);
@@ -272,6 +274,8 @@ static GtkItemFactoryEntry msgview_entries[] =
                                        NULL, create_filter_cb, FILTER_BY_TO, NULL},
        {N_("/_Tools/_Create filter rule/by _Subject"),
                                        NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
+       {N_("/_Tools/---"),             NULL, NULL, 0, "<Separator>"},
+       {N_("/_Tools/Actio_ns"),        NULL, NULL, 0, "<Branch>"},
 
        {N_("/_Help"),                  NULL, NULL, 0, "<Branch>"},
        {N_("/_Help/_About"),           NULL, about_cb, 0, NULL}
@@ -339,6 +343,7 @@ void messageview_add_toolbar(MessageView *msgview, GtkWidget *window)
        GtkWidget *handlebox;
        GtkWidget *vbox;
        GtkWidget *menubar;
+       GtkItemFactory *ifactory;
        guint n_menu_entries;
 
        vbox = gtk_vbox_new(FALSE, 0);
@@ -360,6 +365,9 @@ void messageview_add_toolbar(MessageView *msgview, GtkWidget *window)
        gtk_container_add(GTK_CONTAINER(vbox),
                          GTK_WIDGET_PTR(msgview));
 
+       ifactory = gtk_item_factory_from_widget(menubar);
+       action_update_msgview_menu(ifactory, msgview);
+
        msgview_list = g_list_append(msgview_list, msgview);
 }
 
@@ -661,6 +669,11 @@ static gint disposition_notification_send(MsgInfo *msginfo)
        return ok;
 }
 
+GList *messageview_get_window_list(void)
+{
+       return messageview_list;
+}
+
 void messageview_show(MessageView *messageview, MsgInfo *msginfo,
                      gboolean all_headers)
 {
@@ -775,6 +788,8 @@ void messageview_destroy(MessageView *messageview)
        GtkWidget *mimeview  = GTK_WIDGET_PTR(messageview->mimeview);
 
        debug_print("destroy messageview\n");
+       messageview_list = g_list_remove(messageview_list, messageview);
+
        headerview_destroy(messageview->headerview);
        textview_destroy(messageview->textview);
        mimeview_destroy(messageview->mimeview);
@@ -902,6 +917,14 @@ TextView *messageview_get_current_textview(MessageView *messageview)
        return text;
 }
 
+MimeInfo *messageview_get_selected_mime_part(MessageView *messageview)
+{
+       if (messageview->type == MVIEW_MIME)
+               return mimeview_get_selected_part(messageview->mimeview);
+
+       return NULL;
+}
+
 void messageview_copy_clipboard(MessageView *messageview)
 {
        TextView *text;
index 28d802c..f640ccc 100644 (file)
@@ -31,6 +31,7 @@ typedef struct _MessageView           MessageView;
 #include "mimeview.h"
 #include "noticeview.h"
 #include "procmsg.h"
+#include "procmime.h"
 #include "toolbar.h"
 
 typedef enum
@@ -78,10 +79,12 @@ void messageview_show                               (MessageView    *messageview,
                                                 gboolean        all_headers);
 void messageview_clear                         (MessageView    *messageview);
 void messageview_destroy                       (MessageView    *messageview);
+
 void messageview_quote_color_set               (void);
 void messageview_set_font                      (MessageView    *messageview);
 
 TextView *messageview_get_current_textview     (MessageView    *messageview);
+MimeInfo *messageview_get_selected_mime_part   (MessageView    *messageview);
 
 void messageview_copy_clipboard                        (MessageView    *messageview);
 void messageview_select_all                    (MessageView    *messageview);
index 01d5b47..f48fa58 100644 (file)
@@ -244,8 +244,7 @@ static gboolean mimeview_is_signed(MimeView *mimeview)
 
         debug_print("mimeview_is_signed: file\n" );
 
-       partinfo = gtk_ctree_node_get_row_data
-               (GTK_CTREE(mimeview->ctree), mimeview->opened);
+       partinfo = mimeview_get_selected_part(mimeview);
        g_return_val_if_fail(partinfo != NULL, FALSE);
 
        /* walk the tree and see whether there is a signature somewhere */
@@ -363,6 +362,16 @@ void mimeview_destroy(MimeView *mimeview)
        mimeviews = g_slist_remove(mimeviews, mimeview);
 }
 
+MimeInfo *mimeview_get_selected_part(MimeView *mimeview)
+{
+       if (gtk_notebook_get_current_page
+               (GTK_NOTEBOOK(mimeview->notebook)) == 0)
+               return NULL;
+
+       return gtk_ctree_node_get_row_data
+               (GTK_CTREE(mimeview->ctree), mimeview->opened);
+}
+
 static void mimeview_set_multipart_tree(MimeView *mimeview,
                                        MimeInfo *mimeinfo,
                                        GtkCTreeNode *parent)
@@ -655,11 +664,10 @@ static void mimeview_start_drag(GtkWidget *widget, gint button,
        GtkTargetList *list;
        GdkDragContext *context;
        MimeInfo *partinfo;
-       GtkCTree *ctree;
 
        g_return_if_fail(mimeview != NULL);
-       ctree = GTK_CTREE(mimeview->ctree);
-       partinfo = gtk_ctree_node_get_row_data(ctree, mimeview->opened);
+
+       partinfo = mimeview_get_selected_part(mimeview);
        if (partinfo->filename == NULL && partinfo->name == NULL) return;
 
        list = gtk_target_list_new(mimeview_mime_types, 1);
@@ -691,8 +699,7 @@ static gint mimeview_button_pressed(GtkWidget *widget, GdkEventButton *event,
                /* call external program for image, audio or html */
                mimeview_launch(mimeview);
        } else if (event->button == 3) {
-               partinfo = gtk_ctree_node_get_row_data
-                       (GTK_CTREE(mimeview->ctree), mimeview->opened);
+               partinfo = mimeview_get_selected_part(mimeview);
                if (partinfo && (partinfo->mime_type == MIME_TEXT ||
                                 partinfo->mime_type == MIME_TEXT_HTML ||
                                 partinfo->mime_type == MIME_TEXT_ENRICHED ||
@@ -826,8 +833,7 @@ static void mimeview_drag_data_get(GtkWidget            *widget,
        if (!mimeview->opened) return;
        if (!mimeview->file) return;
 
-       partinfo = gtk_ctree_node_get_row_data
-               (GTK_CTREE(mimeview->ctree), mimeview->opened);
+       partinfo = mimeview_get_selected_part(mimeview);
        if (!partinfo) return;
        if (!partinfo->filename && !partinfo->name) return;
 
@@ -861,8 +867,7 @@ static void mimeview_save_all(MimeView *mimeview)
        if (!mimeview->opened) return;
        if (!mimeview->file) return;
 
-       partinfo = gtk_ctree_node_get_row_data
-               (GTK_CTREE(mimeview->ctree), mimeview->opened);
+       partinfo = mimeview_get_selected_part(mimeview);
        g_return_if_fail(partinfo != NULL);
 
        dirname = filesel_select_file(_("Save as"), defname);
@@ -913,8 +918,8 @@ static void mimeview_display_as_text(MimeView *mimeview)
 
        if (!mimeview->opened) return;
 
-       partinfo = gtk_ctree_node_get_row_data
-               (GTK_CTREE(mimeview->ctree), mimeview->opened);
+       partinfo = mimeview_get_selected_part(mimeview);
+       g_return_if_fail(partinfo != NULL);
        mimeview_show_message_part(mimeview, partinfo);
 }
 
@@ -928,8 +933,7 @@ static void mimeview_save_as(MimeView *mimeview)
        if (!mimeview->opened) return;
        if (!mimeview->file) return;
 
-       partinfo = gtk_ctree_node_get_row_data
-               (GTK_CTREE(mimeview->ctree), mimeview->opened);
+       partinfo = mimeview_get_selected_part(mimeview);
        g_return_if_fail(partinfo != NULL);
 
        if (partinfo->filename)
@@ -964,8 +968,7 @@ static void mimeview_launch(MimeView *mimeview)
        if (!mimeview->opened) return;
        if (!mimeview->file) return;
 
-       partinfo = gtk_ctree_node_get_row_data
-               (GTK_CTREE(mimeview->ctree), mimeview->opened);
+       partinfo = mimeview_get_selected_part(mimeview);
        g_return_if_fail(partinfo != NULL);
 
        filename = procmime_get_tmp_file_name(partinfo);
@@ -988,8 +991,7 @@ static void mimeview_open_with(MimeView *mimeview)
        if (!mimeview->opened) return;
        if (!mimeview->file) return;
 
-       partinfo = gtk_ctree_node_get_row_data
-               (GTK_CTREE(mimeview->ctree), mimeview->opened);
+       partinfo = mimeview_get_selected_part(mimeview);
        g_return_if_fail(partinfo != NULL);
 
        filename = procmime_get_tmp_file_name(partinfo);
@@ -1100,8 +1102,7 @@ static void mimeview_update_signature_info(MimeView *mimeview)
        if (!mimeview) return;
        if (!mimeview->opened) return;
 
-       partinfo = gtk_ctree_node_get_row_data
-               (GTK_CTREE(mimeview->ctree), mimeview->opened);
+       partinfo = mimeview_get_selected_part(mimeview);
        if (!partinfo) return;
 
        if (g_strcasecmp(partinfo->content_type,
@@ -1119,8 +1120,7 @@ void mimeview_check_signature(MimeView *mimeview)
        g_return_if_fail (mimeview_is_signed(mimeview));
        g_return_if_fail (gpg_started);
 
-       mimeinfo = gtk_ctree_node_get_row_data
-               (GTK_CTREE(mimeview->ctree), mimeview->opened);
+       mimeinfo = mimeview_get_selected_part(mimeview);
        g_return_if_fail(mimeinfo != NULL);
        g_return_if_fail(mimeview->file != NULL);
 
index f96c614..3d030c6 100644 (file)
@@ -97,6 +97,8 @@ void mimeview_show_message    (MimeView       *mimeview,
                                 const gchar    *file);
 void mimeview_destroy          (MimeView       *mimeview);
 
+MimeInfo *mimeview_get_selected_part   (MimeView       *mimeview);
+
 #if USE_GPGME
 void mimeview_check_signature  (MimeView       *mimeview);
 #endif
index 112af72..7dd68c9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -52,9 +52,10 @@ gchar *procheader_get_unfolded_line  (gchar          *buf,
 
 GSList *procheader_get_header_list_from_file   (const gchar    *file);
 GSList *procheader_get_header_list             (FILE           *fp);
+void procheader_header_list_destroy            (GSList         *hlist);
+
 GPtrArray *procheader_get_header_array         (FILE           *fp);
 GPtrArray *procheader_get_header_array_asis    (FILE           *fp);
-void procheader_header_list_destroy            (GSList         *hlist);
 void procheader_header_array_destroy           (GPtrArray      *harray);
 void procheader_header_free                    (Header         *header);
 
index 2fe1052..e31fb23 100644 (file)
@@ -1249,6 +1249,26 @@ SummarySelection summary_get_selection_type(SummaryView *summaryview)
        return selection;
 }
 
+GSList *summary_get_selected_msg_list(SummaryView *summaryview)
+{
+       GSList *mlist = NULL;
+       GList *row_list;
+       GList *cur;
+       MsgInfo *msginfo;
+
+       row_list = GTK_CLIST(summaryview->ctree)->selection;
+       for (cur = row_list; cur != NULL; cur = cur->next) {
+               msginfo = gtk_ctree_node_get_row_data
+                       (GTK_CTREE(summaryview->ctree),
+                        GTK_CTREE_NODE(cur->data));
+               mlist = g_slist_prepend(mlist, msginfo);
+       }
+
+       mlist = g_slist_reverse(mlist);
+
+       return mlist;
+}
+
 static void summary_set_menu_sensitive(SummaryView *summaryview)
 {
        GtkItemFactory *ifactory = summaryview->popupfactory;
index 0ed2b8a..2d162ab 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -180,6 +180,7 @@ void summary_unlock           (SummaryView          *summaryview);
 gboolean summary_is_locked       (SummaryView          *summaryview);
 
 SummarySelection summary_get_selection_type    (SummaryView    *summaryview);
+GSList *summary_get_selected_msg_list          (SummaryView    *summaryview);
 
 void summary_select_prev_unread          (SummaryView          *summaryview);
 void summary_select_next_unread          (SummaryView          *summaryview);