sync with sylpheed 0.6.2cvs5
authorPaul Mangan <paul@claws-mail.org>
Mon, 24 Sep 2001 08:15:52 +0000 (08:15 +0000)
committerPaul Mangan <paul@claws-mail.org>
Mon, 24 Sep 2001 08:15:52 +0000 (08:15 +0000)
20 files changed:
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.in
po/POTFILES.in
src/Makefile.am
src/gtkutils.c
src/gtkutils.h
src/mainwindow.c
src/message_search.c [new file with mode: 0644]
src/message_search.h [new file with mode: 0644]
src/messageview.c
src/messageview.h
src/procmime.c
src/summary_search.c
src/summary_search.h
src/summaryview.c
src/summaryview.h
src/textview.c
src/textview.h

index d47b157..92c7135 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2001-09-23
+
+       * src/message_search.[ch]: new. A Dialog for searching in current
+         message.
+       * src/gtkutils.[ch]: gtkut_text_match_string(): new. Compare the
+         text in current position of GtkText and given wide-character
+         string.
+       * src/messageview.[ch]: messageview_search_string()
+         src/textview.[ch]: textview_search_string(): return TRUE if
+         found.
+       * src/textview.[ch]: remember the beginning of body.
+
+2001-09-21
+
+       * src/procmime.c: procmime_get_first_text_content(): modified so
+         that it search entire MIME structure.
+       * src/summary_search.c: summary_search_execute(): use
+         strdup_mbstowcs() instead of macro. Display matched message.
+
 2001-09-20
 
        * src/inc.c: fix for background POP3 hangs and crashes (thanks to
index 4f1b5c8..34f273e 100644 (file)
@@ -1,3 +1,10 @@
+2001-09-24 [paul]
+
+       * configure.in
+               change to version 0.6.2claws3
+
+       * sync with sylpheed 0.6.2cvs5 
+
 2001-09-24 [match]
        * src/ldif.[ch], src/importldif.[ch], addressbook.c
                import LDIF files.
index f293bf5..dd8d1ef 100644 (file)
@@ -1,3 +1,20 @@
+2001-09-23
+
+       * src/message_search.[ch]: ¿·µ¬¡£¸½ºß¤Î¥á¥Ã¥»¡¼¥¸¤Î¸¡º÷¥À¥¤¥¢¥í¥°¡£
+       * src/gtkutils.[ch]: gtkut_text_match_string(): ¿·µ¬¡£ GtkText ¤Î
+         ¸½ºß°ÌÃ֤Υƥ­¥¹¥È¤ÈÍ¿¤¨¤é¤ì¤¿¥ï¥¤¥É¥­¥ã¥é¥¯¥¿Ê¸»úÎó¤òÈæ³Ó¡£
+       * src/messageview.[ch]: messageview_search_string()
+         src/textview.[ch]: textview_search_string(): ¸«¤Ä¤«¤Ã¤¿¤é TRUE
+         ¤òÊÖ¤¹¤è¤¦¤Ë¤·¤¿¡£
+       * src/textview.[ch]: ËÜʸ¤Î³«»Ï°ÌÃÖ¤òµ­²±¡£
+
+2001-09-21
+
+       * src/procmime.c: procmime_get_first_text_content(): MIME ¹½Â¤Á´ÂÎ
+         ¤òõº÷¤¹¤ë¤è¤¦¤Ë½¤Àµ¡£
+       * src/summary_search.c: summary_search_execute(): ¥Þ¥¯¥í¤ÎÂå¤ï¤ê¤Ë
+         strdup_mbstowcs() ¤ò»ÈÍÑ¡£¥Þ¥Ã¥Á¤·¤¿¥á¥Ã¥»¡¼¥¸¤òɽ¼¨¤¹¤ë¤è¤¦¤Ë¤·¤¿¡£
+
 2001-09-20
 
        * src/inc.c: ¥Ð¥Ã¥¯¥°¥é¥¦¥ó¥É¤Î POP3 ¥×¥í¥»¥¹¤Î¥Ï¥ó¥°¤Þ¤¿¤Ï¥¯¥é¥Ã¥·¥å
index c146532..b3e62b9 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=6
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws2
+EXTRA_VERSION=claws3
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
index 2a5368f..61fa19f 100644 (file)
@@ -44,6 +44,7 @@ src/matcher.c
 src/mbox.c
 src/mbox_folder.c
 src/menu.c
+src/message_search.c
 src/messageview.c
 src/mgutils.c
 src/mh.c
index db6d134..0e1e0f4 100644 (file)
@@ -14,6 +14,7 @@ sylpheed_SOURCES = \
        imageview.c imageview.h \
        mimeview.c mimeview.h \
        summary_search.c summary_search.h \
+       message_search.c message_search.h \
        colorlabel.c colorlabel.h \
        folder.c folder.h \
        procmsg.c procmsg.h \
index bf5df7a..581c98d 100644 (file)
 #include <gtk/gtkbindings.h>
 #include <stdarg.h>
 
+#if (HAVE_WCTYPE_H && HAVE_WCHAR_H)
+#  include <wchar.h>
+#  include <wctype.h>
+#endif
+
 #include "intl.h"
 #include "gtkutils.h"
 #include "utils.h"
@@ -243,6 +248,28 @@ void gtkut_combo_set_items(GtkCombo *combo, const gchar *str1, ...)
        g_list_free(combo_items);
 }
 
+gboolean gtkut_text_match_string(GtkText *text, gint pos, wchar_t *wcs,
+                                gint len, gboolean case_sens)
+{
+       gint match_count = 0;
+
+       for (; match_count < len; pos++, match_count++) {
+               if (case_sens) {
+                       if (GTK_TEXT_INDEX(text, pos) != wcs[match_count])
+                               break;
+               } else {
+                       if (towlower(GTK_TEXT_INDEX(text, pos)) !=
+                           towlower(wcs[match_count]))
+                               break;
+               }
+       }
+
+       if (match_count == len)
+               return TRUE;
+       else
+               return FALSE;
+}
+
 void gtkut_widget_disable_theme_engine(GtkWidget *widget)
 {
        GtkStyle *style, *new_style;
index 492f6f2..33e94e4 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999,2000 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2001 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
 #ifndef __GTKUTILS_H__
 #define __GTKUTILS_H__
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
 #include <glib.h>
 #include <gdk/gdk.h>
 #include <gtk/gtkmain.h>
 #include <gtk/gtkwidget.h>
 #include <gtk/gtkctree.h>
 #include <gtk/gtkcombo.h>
+#include <gtk/gtktext.h>
+#include <stdlib.h>
+#if HAVE_WCHAR_H
+#  include <wchar.h>
+#endif
 
 #define GTK_EVENTS_FLUSH() \
 { \
@@ -84,18 +93,24 @@ void gtkut_ctree_expand_parent_all  (GtkCTree       *ctree,
                                         GtkCTreeNode   *node);
 void gtkut_ctree_set_focus_row         (GtkCTree       *ctree,
                                         GtkCTreeNode   *node);
+
 void gtkut_clist_set_focus_row         (GtkCList       *clist,
                                         gint            row);
+
 void gtkut_combo_set_items             (GtkCombo       *combo,
                                         const gchar    *str1, ...);
-void gtkut_widget_disable_theme_engine (GtkWidget      *widget);
 
-void gtkut_widget_wait_for_draw                (GtkWidget      *widget);
+gboolean gtkut_text_match_string       (GtkText        *text,
+                                        gint            pos,
+                                        wchar_t        *wcs,
+                                        gint            len,
+                                        gboolean        case_sens);
 
+void gtkut_widget_disable_theme_engine (GtkWidget      *widget);
+void gtkut_widget_wait_for_draw                (GtkWidget      *widget);
 void gtkut_widget_get_uposition                (GtkWidget      *widget,
                                         gint           *px,
                                         gint           *py);
-
 void gtkut_widget_init                 (void);
 
 void gtk_widget_set_app_icon           (GtkWidget      *widget);
index 826ade8..5398272 100644 (file)
@@ -48,6 +48,7 @@
 #include "summaryview.h"
 #include "summary_search.h"
 #include "messageview.h"
+#include "message_search.h"
 #include "headerview.h"
 #include "menu.h"
 #include "folder.h"
@@ -196,6 +197,10 @@ static void app_exit_cb             (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
 
+static void search_cb           (MainWindow    *mainwin,
+                                 guint          action,
+                                 GtkWidget     *widget);
+
 static void toggle_folder_cb    (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
@@ -415,7 +420,8 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_Edit/_Copy"),                    "<control>C", copy_cb, 0, NULL},
        {N_("/_Edit/Select _all"),              "<control>A", allsel_cb, 0, NULL},
        {N_("/_Edit/---"),                      NULL, NULL, 0, "<Separator>"},
-       {N_("/_Edit/_Search"),                  "<control>S", summary_search_cb, 0, NULL},
+       {N_("/_Edit/_Find in current message"), "<control>F", search_cb, 0, NULL},
+       {N_("/_Edit/_Search folder"),           "<control>S", search_cb, 1, NULL},
 
        {N_("/_View"),                          NULL, NULL, 0, "<Branch>"},
        {N_("/_View/_Folder tree"),             NULL, toggle_folder_cb, 0, "<ToggleItem>"},
@@ -521,7 +527,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_Message/Repl_y to sender"),      "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
        {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
        {N_("/_Message/Reply to a_ll"),         "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
-       {N_("/_Message/_Forward"),              "<control>F", reply_cb, COMPOSE_FORWARD, NULL},
+       {N_("/_Message/_Forward"),              "<shift><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
        {N_("/_Message/Forward as a_ttachment"),
                                                "<shift><control>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
        {N_("/_Message/---"),                   NULL, NULL, 0, "<Separator>"},
@@ -2178,6 +2184,14 @@ static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
        app_will_exit(widget, mainwin);
 }
 
+static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
+{
+       if (action == 1)
+               summary_search(mainwin->summaryview);
+       else
+               message_search(mainwin->messageview);
+}
+
 static void toggle_folder_cb(MainWindow *mainwin, guint action,
                             GtkWidget *widget)
 {
diff --git a/src/message_search.c b/src/message_search.c
new file mode 100644 (file)
index 0000000..7d48750
--- /dev/null
@@ -0,0 +1,219 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2001 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "defs.h"
+
+#include <glib.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtkwidget.h>
+#include <gtk/gtkwindow.h>
+#include <gtk/gtkvbox.h>
+#include <gtk/gtktable.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkentry.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtkcheckbutton.h>
+#include <gtk/gtkhbbox.h>
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkctree.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "intl.h"
+#include "main.h"
+#include "message_search.h"
+#include "messageview.h"
+#include "utils.h"
+#include "gtkutils.h"
+#include "manage_window.h"
+#include "alertpanel.h"
+
+static GtkWidget *window;
+static GtkWidget *body_entry;
+static GtkWidget *case_checkbtn;
+static GtkWidget *backward_checkbtn;
+static GtkWidget *search_btn;
+static GtkWidget *clear_btn;
+static GtkWidget *close_btn;
+
+static void message_search_create(MessageView *summaryview);
+static void message_search_execute(GtkButton *button, gpointer data);
+static void message_search_clear(GtkButton *button, gpointer data);
+static void body_activated(void);
+static void key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data);
+
+void message_search(MessageView *messageview)
+{
+       if (!window)
+               message_search_create(messageview);
+       else
+               gtk_widget_hide(window);
+
+       gtk_widget_grab_focus(search_btn);
+       gtk_widget_grab_focus(body_entry);
+       gtk_widget_show(window);
+}
+
+static void message_search_create(MessageView *messageview)
+{
+       GtkWidget *vbox1;
+       GtkWidget *hbox1;
+       GtkWidget *body_label;
+       GtkWidget *checkbtn_hbox;
+       GtkWidget *confirm_area;
+
+       window = gtk_window_new (GTK_WINDOW_DIALOG);
+       gtk_window_set_title (GTK_WINDOW (window),
+                             _("Find in current message"));
+       gtk_widget_set_usize (window, 450, -1);
+       gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, TRUE);
+       gtk_container_set_border_width (GTK_CONTAINER (window), 8);
+       gtk_signal_connect(GTK_OBJECT(window), "delete_event",
+                          GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete), NULL);
+       gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
+                          GTK_SIGNAL_FUNC(key_pressed), NULL);
+       gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
+                          GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
+       gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
+                          GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
+
+       vbox1 = gtk_vbox_new (FALSE, 0);
+       gtk_widget_show (vbox1);
+       gtk_container_add (GTK_CONTAINER (window), vbox1);
+
+       hbox1 = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (hbox1);
+       gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 0);
+
+       body_label = gtk_label_new (_("Find text:"));
+       gtk_widget_show (body_label);
+       gtk_box_pack_start (GTK_BOX (hbox1), body_label, FALSE, FALSE, 0);
+       //gtk_label_set_justify (GTK_LABEL (body_label), GTK_JUSTIFY_RIGHT);
+       //gtk_misc_set_alignment (GTK_MISC (body_label), 1, 0.5);
+
+       body_entry = gtk_entry_new ();
+       gtk_widget_show (body_entry);
+       gtk_box_pack_start (GTK_BOX (hbox1), body_entry, TRUE, TRUE, 0);
+       gtk_signal_connect(GTK_OBJECT(body_entry), "activate",
+                          GTK_SIGNAL_FUNC(body_activated), messageview);
+
+       checkbtn_hbox = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (checkbtn_hbox);
+       gtk_box_pack_start (GTK_BOX (vbox1), checkbtn_hbox, TRUE, TRUE, 0);
+       gtk_container_set_border_width (GTK_CONTAINER (checkbtn_hbox), 8);
+
+       case_checkbtn = gtk_check_button_new_with_label (_("Case sensitive"));
+       gtk_widget_show (case_checkbtn);
+       gtk_box_pack_start (GTK_BOX (checkbtn_hbox), case_checkbtn,
+                           FALSE, FALSE, 0);
+
+       backward_checkbtn =
+               gtk_check_button_new_with_label (_("Backward search"));
+       gtk_widget_show (backward_checkbtn);
+       gtk_box_pack_start (GTK_BOX (checkbtn_hbox), backward_checkbtn,
+                           FALSE, FALSE, 0);
+
+       gtkut_button_set_create(&confirm_area,
+                               &search_btn, _("Search"),
+                               &clear_btn,  _("Clear"),
+                               &close_btn,  _("Close"));
+       gtk_widget_show (confirm_area);
+       gtk_box_pack_start (GTK_BOX (vbox1), confirm_area, FALSE, FALSE, 0);
+       gtk_widget_grab_default(search_btn);
+
+       gtk_signal_connect(GTK_OBJECT(search_btn), "clicked",
+                          GTK_SIGNAL_FUNC(message_search_execute),
+                          messageview);
+       gtk_signal_connect(GTK_OBJECT(clear_btn), "clicked",
+                          GTK_SIGNAL_FUNC(message_search_clear),
+                          messageview);
+       gtk_signal_connect_object(GTK_OBJECT(close_btn), "clicked",
+                                 GTK_SIGNAL_FUNC(gtk_widget_hide),
+                                 GTK_OBJECT(window));
+}
+
+static void message_search_execute(GtkButton *button, gpointer data)
+{
+       MessageView *messageview = data;
+       gboolean case_sens;
+       gboolean backward;
+       gboolean all_searched = FALSE;
+       gchar *body_str;
+
+       body_str = gtk_entry_get_text(GTK_ENTRY(body_entry));
+       if (*body_str == '\0') return;
+
+       case_sens = gtk_toggle_button_get_active
+               (GTK_TOGGLE_BUTTON(case_checkbtn));
+       backward = gtk_toggle_button_get_active
+               (GTK_TOGGLE_BUTTON(backward_checkbtn));
+
+       for (;;) {
+               gchar *str;
+               AlertValue val;
+
+               if (messageview_search_string(messageview, body_str, case_sens)
+                   == TRUE)
+                       break;
+
+               if (all_searched) {
+                       alertpanel_message
+                               (_("Search failed"),
+                                _("Search string not found."));
+                       break;
+               }
+
+               all_searched = TRUE;
+
+               if (backward)
+                       str = _("Beginning of message reached; "
+                               "continue from end?");
+               else
+                       str = _("End of message reached; "
+                               "continue from beginning?");
+
+               val = alertpanel(_("Search finished"), str,
+                                _("Yes"), _("No"), NULL);
+               if (G_ALERTDEFAULT == val)
+                       manage_window_focus_in(window, NULL, NULL);
+               else
+                       break;
+       }
+}
+
+static void message_search_clear(GtkButton *button, gpointer data)
+{
+       gtk_editable_delete_text(GTK_EDITABLE(body_entry),    0, -1);
+}
+
+static void body_activated(void)
+{
+       gtk_button_clicked(GTK_BUTTON(search_btn));
+}
+
+static void key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data)
+{
+       if (event && event->keyval == GDK_Escape)
+               gtk_widget_hide(window);
+}
diff --git a/src/message_search.h b/src/message_search.h
new file mode 100644 (file)
index 0000000..1ec45ed
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2001 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __MESSAGE_SEARCH_H__
+#define __MESSAGE_SEARCH_H__
+
+#include <glib.h>
+
+#include "messageview.h"
+
+void message_search    (MessageView    *messageview);
+
+#endif /* __MESSAGE_SEARCH_H__ */
index eee4f99..7334062 100644 (file)
@@ -523,6 +523,15 @@ void messageview_select_all(MessageView *messageview)
                        (GTK_EDITABLE(messageview->textview->text), 0, -1);
 }
 
+gboolean messageview_search_string(MessageView *messageview, const gchar *str,
+                                  gboolean case_sens)
+{
+       if (messageview->type == MVIEW_TEXT)
+               return textview_search_string(messageview->textview,
+                                             str, case_sens);
+       return FALSE;
+}
+
 GtkWidget *messageview_get_text_widget(MessageView *messageview)
 {
        return messageview->textview->text;
index f17f418..b29057f 100644 (file)
@@ -65,6 +65,11 @@ void messageview_quote_color_set             (void);
 void messageview_set_font                      (MessageView    *messageview);
 void messageview_copy_clipboard                        (MessageView    *messageview);
 void messageview_select_all                    (MessageView    *messageview);
+
+gboolean messageview_search_string             (MessageView    *messageview,
+                                                const gchar    *str,
+                                                gboolean        case_sens);
+
 GtkWidget *messageview_get_text_widget         (MessageView    *messageview);
 
 #endif /* __MESSAGEVIEW_H__ */
index a57a13c..90c4b41 100644 (file)
@@ -693,11 +693,8 @@ FILE *procmime_get_text_content(MimeInfo *mimeinfo, FILE *infp)
    decode, convert it and output to outfp. */
 FILE *procmime_get_first_text_content(MsgInfo *msginfo)
 {
-       FILE *infp, *tmpfp, *outfp;
-       MimeInfo *mimeinfo, *partinfo = NULL;
-       gchar *src_codeset;
-       gboolean conv_fail = FALSE;
-       gchar buf[BUFFSIZE];
+       FILE *infp, *outfp = NULL;
+       MimeInfo *mimeinfo, *partinfo;
 
        g_return_val_if_fail(msginfo != NULL, NULL);
 
@@ -710,57 +707,14 @@ FILE *procmime_get_first_text_content(MsgInfo *msginfo)
        }
 
        partinfo = mimeinfo;
-       while (partinfo && partinfo->mime_type == MIME_MULTIPART)
-               partinfo = partinfo->children;
-
-       if (partinfo && partinfo->mime_type == MIME_TEXT) {
-               if (fseek(infp, partinfo->fpos, SEEK_SET) < 0) {
-                       perror("fseek");
-                       partinfo = NULL;
-               }
-       }
-
-       if (!partinfo) {
-               procmime_mimeinfo_free_all(mimeinfo);
-               return NULL;
-       }
-
-       while (fgets(buf, sizeof(buf), infp) != NULL)
-               if (buf[0] == '\r' || buf[0] == '\n') break;
-
-       tmpfp = procmime_decode_content(NULL, infp, partinfo);
-       if (!tmpfp) {
-               procmime_mimeinfo_free_all(mimeinfo);
-               return NULL;
-       }
-
-       if ((outfp = my_tmpfile()) == NULL) {
-               perror("tmpfile");
-               fclose(tmpfp);
-               procmime_mimeinfo_free_all(mimeinfo);
-               return NULL;
-       }
-
-       src_codeset = prefs_common.force_charset
-               ? prefs_common.force_charset : partinfo->charset;
+       while (partinfo && partinfo->mime_type != MIME_TEXT)
+               partinfo = procmime_mimeinfo_next(partinfo);
 
-       while (fgets(buf, sizeof(buf), tmpfp) != NULL) {
-               gchar *str;
-
-               str = conv_codeset_strdup(buf, src_codeset, NULL);
-               if (str) {
-                       fputs(str, outfp);
-                       g_free(str);
-               } else {
-                       conv_fail = TRUE;
-                       fputs(buf, outfp);
-               }
-       }
-       if (conv_fail) g_warning(_("Code conversion failed.\n"));
+       if (partinfo)
+               outfp = procmime_get_text_content(partinfo, infp);
 
-       fclose(tmpfp);
+       fclose(infp);
        procmime_mimeinfo_free_all(mimeinfo);
-       rewind(outfp);
 
        return outfp;
 }
@@ -814,8 +768,8 @@ gboolean procmime_find_string(MsgInfo *msginfo, const gchar *str,
        gchar *filename;
        gboolean found = FALSE;
 
-       g_return_val_if_fail(msginfo != NULL, NULL);
-       g_return_val_if_fail(str != NULL, NULL);
+       g_return_val_if_fail(msginfo != NULL, FALSE);
+       g_return_val_if_fail(str != NULL, FALSE);
 
        filename = procmsg_get_message_file(msginfo);
        if (!filename) return FALSE;
index 5b79761..a962e29 100644 (file)
@@ -44,6 +44,7 @@
 #include "main.h"
 #include "summary_search.h"
 #include "summaryview.h"
+#include "mainwindow.h"
 #include "utils.h"
 #include "gtkutils.h"
 #include "manage_window.h"
@@ -80,13 +81,6 @@ void summary_search(SummaryView *summaryview)
        gtk_widget_show(window);
 }
 
-void summary_search_cb(gpointer data, guint action, GtkWidget *widget)
-{
-       MainWindow *mainwin = data;
-
-       summary_search(mainwin->summaryview);
-}
-
 static void summary_search_create(SummaryView *summaryview)
 {
        GtkWidget *vbox1;
@@ -99,7 +93,7 @@ static void summary_search_create(SummaryView *summaryview)
        GtkWidget *confirm_area;
 
        window = gtk_window_new (GTK_WINDOW_DIALOG);
-       gtk_window_set_title (GTK_WINDOW (window), _("Search"));
+       gtk_window_set_title (GTK_WINDOW (window), _("Search folder"));
        gtk_widget_set_usize (window, 450, -1);
        /*gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);*/
        gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, TRUE);
@@ -173,7 +167,7 @@ static void summary_search_create(SummaryView *summaryview)
        gtk_label_set_justify (GTK_LABEL (subject_label), GTK_JUSTIFY_RIGHT);
        gtk_misc_set_alignment (GTK_MISC (subject_label), 1, 0.5);
 
-       body_label = gtk_label_new (_("Body"));
+       body_label = gtk_label_new (_("Body:"));
        gtk_widget_show (body_label);
        gtk_table_attach (GTK_TABLE (table1), body_label, 0, 1, 3, 4,
                          GTK_FILL, 0, 0, 0);
@@ -219,13 +213,6 @@ static void summary_search_create(SummaryView *summaryview)
        gtk_signal_connect_object(GTK_OBJECT(close_btn), "clicked",
                                  GTK_SIGNAL_FUNC(gtk_widget_hide),
                                  GTK_OBJECT(window));
-
-}
-
-#define STRDUP_MBSTOWCS(wcs, s) \
-{ \
-       wcs = g_malloc((strlen(s) + 1) * sizeof(wchar_t)); \
-       mbstowcs(wcs, s, strlen(s) + 1); \
 }
 
 static void summary_search_execute(GtkButton *button, gpointer data)
@@ -290,6 +277,9 @@ static void summary_search_execute(GtkButton *button, gpointer data)
                        node = GTK_CTREE_NODE_NEXT(summaryview->selected);
        }
 
+       if (*body_str)
+               main_window_cursor_wait(summaryview->mainwin);
+
        for (;;) {
                if (!node) {
                        gchar *str;
@@ -334,20 +324,20 @@ static void summary_search_execute(GtkButton *button, gpointer data)
                msginfo = gtk_ctree_node_get_row_data(ctree, node);
 
                if (*fromwcs && msginfo->from) {
-                       STRDUP_MBSTOWCS(wcs_hs, msginfo->from);
-                       if (WCSFindFunc(wcs_hs, fromwcs) != NULL)
+                       wcs_hs = strdup_mbstowcs(msginfo->from);
+                       if (wcs_hs && WCSFindFunc(wcs_hs, fromwcs) != NULL)
                                from_matched = TRUE;
                        g_free(wcs_hs);
                }
                if (*towcs && msginfo->to) {
-                       STRDUP_MBSTOWCS(wcs_hs, msginfo->to);
-                       if (WCSFindFunc(wcs_hs, towcs) != NULL)
+                       wcs_hs = strdup_mbstowcs(msginfo->to);
+                       if (wcs_hs && WCSFindFunc(wcs_hs, towcs) != NULL)
                                to_matched = TRUE;
                        g_free(wcs_hs);
                }
                if (*subjwcs && msginfo->subject) {
-                       STRDUP_MBSTOWCS(wcs_hs, msginfo->subject);
-                       if (WCSFindFunc(wcs_hs, subjwcs) != NULL)
+                       wcs_hs = strdup_mbstowcs(msginfo->subject);
+                       if (wcs_hs && WCSFindFunc(wcs_hs, subjwcs) != NULL)
                                subj_matched = TRUE;
                        g_free(wcs_hs);
                }
@@ -360,12 +350,12 @@ static void summary_search_execute(GtkButton *button, gpointer data)
                        if (search_all)
                                gtk_ctree_select(ctree, node);
                        else {
-                               gtk_clist_freeze(GTK_CLIST(ctree));
-                               gtk_clist_unselect_all(GTK_CLIST(ctree));
-                               gtk_ctree_select(ctree, node);
-                               gtk_ctree_node_moveto(ctree, node, 0, 0.5, 0);
-                               gtkut_ctree_set_focus_row(ctree, node);
-                               gtk_clist_thaw(GTK_CLIST(ctree));
+                               summary_select_node(summaryview, node, TRUE);
+                               if (body_matched) {
+                                       messageview_search_string
+                                               (summaryview->messageview,
+                                                body_str, case_sens);
+                               }
                                break;
                        }
                }
@@ -373,6 +363,9 @@ static void summary_search_execute(GtkButton *button, gpointer data)
                node = backward ? GTK_CTREE_NODE_PREV(node)
                                : GTK_CTREE_NODE_NEXT(node);
        }
+
+       if (*body_str)
+               main_window_cursor_normal(summaryview->mainwin);
 }
 
 static void summary_search_clear(GtkButton *button, gpointer data)
index 4c8d1d3..8e3fcc0 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999,2000 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2001 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
 #define __SUMMARY_SEARCH_H__
 
 #include <glib.h>
-#include <gtk/gtkwidget.h>
 
 #include "summaryview.h"
 
-void summary_search(SummaryView *summaryview);
-void summary_search_cb(gpointer data, guint action, GtkWidget *widget);
+void summary_search    (SummaryView    *summaryview);
 
 #endif /* __SUMMARY_SEARCH_H__ */
index 9263320..58eeaa1 100644 (file)
@@ -150,10 +150,6 @@ static void summary_write_cache_func       (GtkCTree               *ctree,
 
 static void summary_set_menu_sensitive (SummaryView            *summaryview);
 
-static void summary_select_node                (SummaryView            *summaryview,
-                                        GtkCTreeNode           *node,
-                                        gboolean                display_msg);
-
 static guint summary_get_msgnum                (SummaryView            *summaryview,
                                         GtkCTreeNode           *node);
 
@@ -1292,8 +1288,8 @@ void summary_select_by_msgnum(SummaryView *summaryview, guint msgnum)
  * thread, if necessary) and unselect all others.  If @display_msg is
  * TRUE, display the corresponding message in the message view.
  **/
-static void summary_select_node(SummaryView *summaryview, GtkCTreeNode *node,
-                               gboolean display_msg)
+void summary_select_node(SummaryView *summaryview, GtkCTreeNode *node,
+                        gboolean display_msg)
 {
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
 
index f76ed6b..b55ac20 100644 (file)
@@ -172,6 +172,9 @@ void summary_select_next_labeled  (SummaryView              *summaryview);
 void summary_select_by_msgnum    (SummaryView          *summaryview,
                                   guint                 msgnum);
 guint summary_get_current_msgnum  (SummaryView         *summaryview);
+void summary_select_node         (SummaryView          *summaryview,
+                                  GtkCTreeNode         *node,
+                                  gboolean              display_msg);
 void summary_thread_build        (SummaryView          *summaryview,
                                   gboolean              init);
 void summary_unthread            (SummaryView          *summaryview);
index 1ab3223..7a52d56 100644 (file)
@@ -208,6 +208,7 @@ TextView *textview_create(void)
        textview->text_mb        = text_mb;
        textview->text_is_mb     = FALSE;
        textview->uri_list       = NULL;
+       textview->body_pos       = 0;
 
        return textview;
 }
@@ -333,6 +334,8 @@ void textview_show_part(TextView *textview, MimeInfo *mimeinfo, FILE *fp)
        text = GTK_TEXT(textview->text);
        gtk_text_freeze(text);
 
+       textview->body_pos = 0;
+
        if (headers) {
                textview_show_header(textview, headers);
                procheader_header_array_destroy(headers);
@@ -800,7 +803,8 @@ void textview_clear(TextView *textview)
        GtkText *text = GTK_TEXT(textview->text);
 
        gtk_text_freeze(text);
-       gtk_text_backward_delete(text, gtk_text_get_length(text));
+       gtk_text_set_point(text, 0);
+       gtk_text_forward_delete(text, gtk_text_get_length(text));
        gtk_text_thaw(text);
 
        textview_uri_list_remove_all(textview->uri_list);
@@ -1028,6 +1032,46 @@ static void textview_show_header(TextView *textview, GPtrArray *headers)
 
        gtk_text_insert(text, textview->msgfont, NULL, NULL, "\n", 1);
        gtk_text_thaw(text);
+       textview->body_pos = gtk_text_get_length(text);
+}
+
+gboolean textview_search_string(TextView *textview, const gchar *str,
+                               gboolean case_sens)
+{
+       GtkText *text = GTK_TEXT(textview->text);
+       gint pos;
+       wchar_t *wcs;
+       gint len;
+       gint text_len;
+       gboolean found = FALSE;
+
+       g_return_val_if_fail(str != NULL, FALSE);
+
+       wcs = strdup_mbstowcs(str);
+       g_return_val_if_fail(wcs != NULL, FALSE);
+       len = wcslen(wcs);
+       pos = gtk_editable_get_position(GTK_EDITABLE(text));
+       if (pos < textview->body_pos)
+               pos = textview->body_pos;
+       text_len = gtk_text_get_length(text);
+
+       for (; pos < text_len; pos++) {
+               if (text_len - pos < len) break;
+               if (gtkut_text_match_string(text, pos, wcs, len, case_sens)
+                   == TRUE) {
+                       gtk_text_freeze(text);
+                       gtk_text_set_point(text, pos + len);
+                       gtk_editable_set_position(GTK_EDITABLE(text), pos + len);
+                       gtk_editable_select_region(GTK_EDITABLE(text),
+                                                  pos, pos + len);
+                       gtk_text_thaw(text);
+                       found = TRUE;
+                       break;
+               }
+       }
+
+       g_free(wcs);
+       return found;
 }
 
 void textview_scroll_one_line(TextView *textview, gboolean up)
index 71334a2..bcf4f2c 100644 (file)
 #ifndef __TEXTVIEW_H__
 #define __TEXTVIEW_H__
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
 #include <glib.h>
 #include <gtk/gtkwidget.h>
 
@@ -41,6 +45,7 @@ struct _TextView
        gboolean text_is_mb;
 
        GSList *uri_list;
+       gint body_pos;
 
        GdkFont *msgfont;
        GdkFont *boldfont;
@@ -72,6 +77,11 @@ void textview_scroll_one_line        (TextView       *textview,
                                 gboolean        up);
 gboolean textview_scroll_page  (TextView       *textview,
                                 gboolean        up);
-void textview_update_message_colors(void);
+
+void textview_update_message_colors    (void);
+
+gboolean textview_search_string        (TextView       *textview,
+                                const gchar    *str,
+                                gboolean        case_sens);
 
 #endif /* __TEXTVIEW_H__ */