aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-search.c
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-05-11 12:27:35 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-05-11 12:27:35 +0800
commit59c9d146b95fdf399b64971d6b86d9e8a5474157 (patch)
treeb53a6c5bcea1ca1c1c749018fdcd2fcad0207852 /mail/mail-search.c
parentfce621fd558b52b3bdcca568af4c2676ba2e461c (diff)
downloadgsoc2013-evolution-59c9d146b95fdf399b64971d6b86d9e8a5474157.tar
gsoc2013-evolution-59c9d146b95fdf399b64971d6b86d9e8a5474157.tar.gz
gsoc2013-evolution-59c9d146b95fdf399b64971d6b86d9e8a5474157.tar.bz2
gsoc2013-evolution-59c9d146b95fdf399b64971d6b86d9e8a5474157.tar.lz
gsoc2013-evolution-59c9d146b95fdf399b64971d6b86d9e8a5474157.tar.xz
gsoc2013-evolution-59c9d146b95fdf399b64971d6b86d9e8a5474157.tar.zst
gsoc2013-evolution-59c9d146b95fdf399b64971d6b86d9e8a5474157.zip
Use the ESearchingTokenizer to highlight search matches for folder-level
2001-05-10 Jon Trowbridge <trow@ximian.com> * folder-browser.c (folder_browser_config_search): Use the ESearchingTokenizer to highlight search matches for folder-level searches. Still mildly broken, but it works for the simple cases. * mail-display.c (mail_display_new): Use our ESearchingTokenizer for the mail display GtkHTML widget. * mail-search.c (dialog_clicked_cb): Use the ESearchingTokenizer to highlight search matches. (mail_search_construct): Add a match count to the search dialog. * e-searching-tokenizer.c (e_searching_tokenizer_set_search_string): Added. A custom HTML tokenizer that does highlighting of search strings. svn path=/trunk/; revision=9754
Diffstat (limited to 'mail/mail-search.c')
-rw-r--r--mail/mail-search.c83
1 files changed, 76 insertions, 7 deletions
diff --git a/mail/mail-search.c b/mail/mail-search.c
index 9611c34887..7f7dc579d1 100644
--- a/mail/mail-search.c
+++ b/mail/mail-search.c
@@ -30,9 +30,11 @@
#endif
#include "mail-search.h"
+#include "e-searching-tokenizer.h"
#include <gal/widgets/e-unicode.h>
#include <gtkhtml/gtkhtml-search.h>
+#include <gtkhtml/htmlengine.h>
static GtkObjectClass *parent_class;
@@ -41,6 +43,11 @@ mail_search_destroy (GtkObject *obj)
{
MailSearch *ms = MAIL_SEARCH (obj);
+ gtk_signal_disconnect (GTK_OBJECT (ms->mail->html->engine->ht),
+ ms->match_handler);
+ gtk_signal_disconnect (GTK_OBJECT (ms->mail->html->engine->ht),
+ ms->begin_handler);
+
g_free (ms->last_search);
gtk_object_unref (GTK_OBJECT (ms->mail));
}
@@ -83,6 +90,22 @@ mail_search_get_type (void)
}
/*
+ * Convenience
+ */
+
+static ESearchingTokenizer *
+mail_search_tokenizer (MailSearch *ms)
+{
+ return E_SEARCHING_TOKENIZER (ms->mail->html->engine->ht);
+}
+
+static void
+mail_search_redisplay_message (MailSearch *ms)
+{
+ mail_display_redisplay (ms->mail, FALSE);
+}
+
+/*
* Construct Objects
*/
@@ -90,6 +113,11 @@ static void
toggled_case_cb (GtkToggleButton *b, MailSearch *ms)
{
ms->case_sensitive = gtk_toggle_button_get_active (b);
+
+ e_searching_tokenizer_set_case_sensitivity (mail_search_tokenizer (ms),
+ ms->case_sensitive);
+ mail_search_redisplay_message (ms);
+
}
static void
@@ -101,11 +129,14 @@ toggled_fwd_cb (GtkToggleButton *b, MailSearch *ms)
static void
dialog_clicked_cb (GtkWidget *w, gint button_number, MailSearch *ms)
{
+ ESearchingTokenizer *st = mail_search_tokenizer (ms);
+
if (button_number == 0) { /* "Search" */
char *search_text, *tmp;
-
+
tmp = gtk_editable_get_chars (GTK_EDITABLE (ms->entry), 0, -1);
+
g_strstrip (tmp);
search_text = e_utf8_from_gtk_string ((GtkWidget *) ms->entry, tmp);
g_free (tmp);
@@ -120,10 +151,13 @@ dialog_clicked_cb (GtkWidget *w, gint button_number, MailSearch *ms)
}
} else {
-
+
g_free (ms->last_search);
ms->last_search = NULL;
-
+
+ e_searching_tokenizer_set_search_string (st, search_text);
+ mail_search_redisplay_message (ms);
+
if (gtk_html_engine_search (ms->mail->html, search_text,
ms->case_sensitive, ms->search_forward,
FALSE)) {
@@ -132,15 +166,32 @@ dialog_clicked_cb (GtkWidget *w, gint button_number, MailSearch *ms)
}
}
+
g_free (search_text);
} else if (button_number == 1) { /* "Close" */
+ e_searching_tokenizer_set_search_string (st, NULL);
+ mail_search_redisplay_message (ms);
+
gtk_widget_destroy (w);
}
}
+static void
+begin_cb (ESearchingTokenizer *st, gchar *foo, MailSearch *ms)
+{
+ gtk_label_set_text (GTK_LABEL (ms->count_label), "0");
+}
+
+static void
+match_cb (ESearchingTokenizer *st, MailSearch *ms)
+{
+ gchar buf[16];
+ g_snprintf (buf, 16, "%d", e_searching_tokenizer_match_count (st));
+ gtk_label_set_text (GTK_LABEL (ms->count_label), buf);
+}
void
mail_search_construct (MailSearch *ms, MailDisplay *mail)
@@ -150,8 +201,10 @@ mail_search_construct (MailSearch *ms, MailDisplay *mail)
NULL };
gchar *title = NULL;
GtkWidget *top_hbox;
+ GtkWidget *mid_hbox;
GtkWidget *bot_hbox;
GtkWidget *entry;
+ GtkWidget *count_label;
GtkWidget *case_check;
GtkWidget *fwd_check;
@@ -174,17 +227,28 @@ mail_search_construct (MailSearch *ms, MailDisplay *mail)
ms->search_forward = TRUE;
ms->case_sensitive = FALSE;
+ ms->begin_handler = gtk_signal_connect (GTK_OBJECT (ms->mail->html->engine->ht),
+ "begin",
+ GTK_SIGNAL_FUNC (begin_cb),
+ ms);
+ ms->match_handler = gtk_signal_connect (GTK_OBJECT (ms->mail->html->engine->ht),
+ "match",
+ GTK_SIGNAL_FUNC (match_cb),
+ ms);
/* Construct the dialog contents. */
top_hbox = gtk_hbox_new (FALSE, 0);
+ mid_hbox = gtk_hbox_new (FALSE, 0);
bot_hbox = gtk_hbox_new (FALSE, 0);
- entry = gtk_entry_new ();
- case_check = gtk_check_button_new_with_label (_("Case Sensitive"));
- fwd_check = gtk_check_button_new_with_label (_("Search Forward"));
+ entry = gtk_entry_new ();
+ count_label = gtk_label_new ("0");
+ case_check = gtk_check_button_new_with_label (_("Case Sensitive"));
+ fwd_check = gtk_check_button_new_with_label (_("Search Forward"));
- ms->entry = entry;
+ ms->entry = entry;
+ ms->count_label = count_label;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fwd_check), ms->search_forward);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (case_check), ms->case_sensitive);
@@ -192,13 +256,18 @@ mail_search_construct (MailSearch *ms, MailDisplay *mail)
gtk_box_pack_start (GTK_BOX (top_hbox), gtk_label_new (_("Find:")), FALSE, FALSE, 3);
gtk_box_pack_start (GTK_BOX (top_hbox), entry, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (mid_hbox), gtk_label_new (_("Matches:")), FALSE, FALSE, 3);
+ gtk_box_pack_start (GTK_BOX (mid_hbox), count_label, FALSE, FALSE, 0);
+
gtk_box_pack_start (GTK_BOX (bot_hbox), case_check, FALSE, FALSE, 4);
gtk_box_pack_start (GTK_BOX (bot_hbox), fwd_check, FALSE, FALSE, 4);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (ms)->vbox), top_hbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (ms)->vbox), mid_hbox, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (ms)->vbox), bot_hbox, TRUE, TRUE, 0);
gtk_widget_show_all (top_hbox);
+ gtk_widget_show_all (mid_hbox);
gtk_widget_show_all (bot_hbox);