+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
+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.
+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 ¥×¥í¥»¥¹¤Î¥Ï¥ó¥°¤Þ¤¿¤Ï¥¯¥é¥Ã¥·¥å
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
src/mbox.c
src/mbox_folder.c
src/menu.c
+src/message_search.c
src/messageview.c
src/mgutils.c
src/mh.c
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 \
#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"
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;
/*
* 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() \
{ \
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);
#include "summaryview.h"
#include "summary_search.h"
#include "messageview.h"
+#include "message_search.h"
#include "headerview.h"
#include "menu.h"
#include "folder.h"
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);
{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>"},
{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>"},
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)
{
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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__ */
(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;
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__ */
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);
}
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;
}
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;
#include "main.h"
#include "summary_search.h"
#include "summaryview.h"
+#include "mainwindow.h"
#include "utils.h"
#include "gtkutils.h"
#include "manage_window.h"
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;
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);
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);
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)
node = GTK_CTREE_NODE_NEXT(summaryview->selected);
}
+ if (*body_str)
+ main_window_cursor_wait(summaryview->mainwin);
+
for (;;) {
if (!node) {
gchar *str;
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);
}
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;
}
}
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)
/*
* 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__ */
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);
* 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);
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);
textview->text_mb = text_mb;
textview->text_is_mb = FALSE;
textview->uri_list = NULL;
+ textview->body_pos = 0;
return textview;
}
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);
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);
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)
#ifndef __TEXTVIEW_H__
#define __TEXTVIEW_H__
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <glib.h>
#include <gtk/gtkwidget.h>
gboolean text_is_mb;
GSList *uri_list;
+ gint body_pos;
GdkFont *msgfont;
GdkFont *boldfont;
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__ */