aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-04-26 14:04:06 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-04-26 14:04:06 +0800
commite2284d39ddc5a7199d7186dec3fb7877e1b20ac5 (patch)
tree4521e5e8ea9de757c3a0369413f1e3e1b4774353
parentcd0ca6cdb7a4c30a32e87b1ea4b0af9b50b2d5e9 (diff)
downloadgsoc2013-evolution-e2284d39ddc5a7199d7186dec3fb7877e1b20ac5.tar.gz
gsoc2013-evolution-e2284d39ddc5a7199d7186dec3fb7877e1b20ac5.tar.zst
gsoc2013-evolution-e2284d39ddc5a7199d7186dec3fb7877e1b20ac5.zip
Added "MessageSearch" verb.
2001-04-26 Jon Trowbridge <trow@ximian.com> * folder-browser-factory.c: Added "MessageSearch" verb. * mail-callbacks.c (search_msg): Added search callback. (are_you_sure): Added some casts to fix compiler warnings. * mail-search.c: Added. A simple search-in-message widget, that uses GtkHTML's searching capabilities. 2001-04-26 Jon Trowbridge <trow@ximian.com> * evolution-mail.xml: Added "Search Message" to "View" menu. svn path=/trunk/; revision=9575
-rw-r--r--mail/ChangeLog10
-rw-r--r--mail/Makefile.am2
-rw-r--r--mail/folder-browser-factory.c2
-rw-r--r--mail/mail-callbacks.c20
-rw-r--r--mail/mail-callbacks.h1
-rw-r--r--mail/mail-search.c230
-rw-r--r--mail/mail-search.h76
-rw-r--r--ui/ChangeLog4
-rw-r--r--ui/evolution-mail.xml5
9 files changed, 348 insertions, 2 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 6900721612..9e9b277754 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,13 @@
+2001-04-26 Jon Trowbridge <trow@ximian.com>
+
+ * folder-browser-factory.c: Added "MessageSearch" verb.
+
+ * mail-callbacks.c (search_msg): Added search callback.
+ (are_you_sure): Added some casts to fix compiler warnings.
+
+ * mail-search.c: Added. A simple search-in-message widget,
+ that uses GtkHTML's searching capabilities.
+
2001-04-25 Dan Winship <danw@ximian.com>
* mail-callbacks.c (are_you_sure): New foot-shooting-prevention
diff --git a/mail/Makefile.am b/mail/Makefile.am
index ed3cdf3b2b..0fd1abb708 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -81,6 +81,8 @@ evolution_mail_SOURCES = \
mail-mt.h \
mail-ops.c \
mail-ops.h \
+ mail-search.c \
+ mail-search.h \
mail-search-dialogue.c \
mail-search-dialogue.h \
mail-send-recv.c \
diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c
index 9f6abf43bb..e26e3595ea 100644
--- a/mail/folder-browser-factory.c
+++ b/mail/folder-browser-factory.c
@@ -111,6 +111,8 @@ BonoboUIVerb verbs [] = {
BONOBO_UI_UNSAFE_VERB ("MailStop", stop_threads),
BONOBO_UI_UNSAFE_VERB ("MailPrevious", previous_msg),
BONOBO_UI_UNSAFE_VERB ("MailNext", next_msg),
+
+ BONOBO_UI_UNSAFE_VERB ("MessageSearch", search_msg),
BONOBO_UI_VERB_END
};
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index 6919ac32e9..18407ee6a4 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -51,6 +51,7 @@
#include "mail-tools.h"
#include "mail-ops.h"
#include "mail-local.h"
+#include "mail-search.h"
#include "mail-send-recv.h"
#include "mail-vfolder.h"
#include "folder-browser.h"
@@ -1124,14 +1125,14 @@ is_drafts_folder (CamelFolder *folder)
static gboolean
are_you_sure (const char *msg, GPtrArray *uids, FolderBrowser *fb)
{
- GtkWidget *window = gtk_widget_get_ancestor (fb, GTK_TYPE_WINDOW);
+ GtkWidget *window = gtk_widget_get_ancestor (GTK_WIDGET (fb), GTK_TYPE_WINDOW);
GtkWidget *dialog;
char *buf;
int button, i;
buf = g_strdup_printf (msg, uids->len);
dialog = gnome_ok_cancel_dialog_parented (buf, NULL, NULL, (GtkWindow *)window);
- button = gnome_dialog_run_and_close (dialog);
+ button = gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
if (button != 0) {
for (i = 0; i < uids->len; i++)
g_free (uids->pdata[i]);
@@ -1213,6 +1214,21 @@ resend_msg (GtkWidget *widget, gpointer user_data)
mail_get_messages (fb->folder, uids, do_resend_messages, fb);
}
+void
+search_msg (GtkWidget *widget, gpointer user_data)
+{
+ FolderBrowser *fb = FOLDER_BROWSER (user_data);
+ GtkWidget *w;
+
+ if (fb->mail_display->current_message == NULL) {
+ gtk_widget_show_all (gnome_warning_dialog (_("No Message Selected")));
+ return;
+ }
+
+ w = mail_search_new (fb->mail_display);
+ gtk_widget_show_all (w);
+}
+
static void
save_msg_ok (GtkWidget *widget, gpointer user_data)
{
diff --git a/mail/mail-callbacks.h b/mail/mail-callbacks.h
index c856c201c1..2e9e9b855a 100644
--- a/mail/mail-callbacks.h
+++ b/mail/mail-callbacks.h
@@ -70,6 +70,7 @@ void view_source (GtkWidget *widget, gpointer user_data);
void next_msg (GtkWidget *widget, gpointer user_data);
void previous_msg (GtkWidget *widget, gpointer user_data);
void resend_msg (GtkWidget *widget, gpointer user_data);
+void search_msg (GtkWidget *widget, gpointer user_data);
void select_all (BonoboUIComponent *uih, void *user_data, const char *path);
void invert_selection (BonoboUIComponent *uih, void *user_data, const char *path);
diff --git a/mail/mail-search.c b/mail/mail-search.c
new file mode 100644
index 0000000000..4de003afe0
--- /dev/null
+++ b/mail/mail-search.c
@@ -0,0 +1,230 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * mail-search.c
+ *
+ * Copyright (C) 2001 Ximian, Inc.
+ *
+ * Developed by Jon Trowbridge <trow@ximian.com>
+ */
+
+/*
+ * 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 <gtkhtml/gtkhtml-search.h>
+#include "mail-search.h"
+
+static GtkObjectClass *parent_class;
+
+static void
+mail_search_destroy (GtkObject *obj)
+{
+ MailSearch *ms = MAIL_SEARCH (obj);
+
+ g_free (ms->last_search);
+ gtk_object_unref (ms->mail);
+}
+
+static void
+mail_search_class_init (MailSearchClass *klass)
+{
+ GtkObjectClass *object_class = (GtkObjectClass *) klass;
+ parent_class = GTK_OBJECT_CLASS (gtk_type_class (gnome_dialog_get_type ()));
+
+ object_class->destroy = mail_search_destroy;
+}
+
+static void
+mail_search_init (MailSearch *ms)
+{
+
+}
+
+GtkType
+mail_search_get_type (void)
+{
+ static GtkType mail_search_type = 0;
+
+ if (! mail_search_type) {
+ GtkTypeInfo mail_search_info = {
+ "MailSearch",
+ sizeof (MailSearch),
+ sizeof (MailSearchClass),
+ (GtkClassInitFunc) mail_search_class_init,
+ (GtkObjectInitFunc) mail_search_init,
+ NULL, NULL, /* mysteriously reserved */
+ (GtkClassInitFunc) NULL
+ };
+
+ mail_search_type = gtk_type_unique (gnome_dialog_get_type (), &mail_search_info);
+ }
+
+ return mail_search_type;
+}
+
+/*
+ * Construct Objects
+ */
+
+static void
+toggled_case_cb (GtkToggleButton *b, MailSearch *ms)
+{
+ ms->case_sensitive = gtk_toggle_button_get_active (b);
+}
+
+static void
+toggled_fwd_cb (GtkToggleButton *b, MailSearch *ms)
+{
+ ms->search_forward = gtk_toggle_button_get_active (b);
+}
+
+static void
+dialog_clicked_cb (GtkWidget *w, gint button_number, MailSearch *ms)
+{
+ if (button_number == 0) { /* "Search" */
+
+ gchar *search_text = gtk_editable_get_chars (GTK_EDITABLE (ms->entry), 0, -1);
+ g_strstrip (search_text);
+
+ if (search_text && *search_text) {
+
+ if (ms->last_search && !strcmp (ms->last_search, search_text)) {
+
+ if (! gtk_html_engine_search_next (ms->mail->html)) {
+ g_free (ms->last_search);
+ ms->last_search = NULL;
+ }
+
+ } else {
+
+ g_free (ms->last_search);
+ ms->last_search = NULL;
+
+ if (gtk_html_engine_search (ms->mail->html, search_text,
+ ms->case_sensitive, ms->search_forward,
+ FALSE)) {
+ ms->last_search = g_strdup (search_text);
+ }
+ }
+ }
+
+ g_free (search_text);
+
+ } else if (button_number == 1) { /* "Close" */
+
+ gtk_widget_destroy (w);
+
+ }
+}
+
+
+void
+mail_search_construct (MailSearch *ms, MailDisplay *mail)
+{
+ const gchar *buttons[] = { N_("Search"),
+ GNOME_STOCK_BUTTON_CLOSE,
+ NULL };
+ gchar *title = NULL;
+ GtkWidget *top_hbox;
+ GtkWidget *bot_hbox;
+ GtkWidget *entry;
+ GtkWidget *case_check;
+ GtkWidget *fwd_check;
+
+ g_return_if_fail (ms != NULL && IS_MAIL_SEARCH (ms));
+ g_return_if_fail (mail != NULL && IS_MAIL_DISPLAY (mail));
+
+ /* Basic set-up */
+
+ ms->mail = mail;
+ gtk_object_ref (GTK_OBJECT (mail));
+
+ if (mail->current_message->subject && *mail->current_message->subject)
+ title = g_strdup_printf (_("Search \"%s\""), mail->current_message->subject);
+ else
+ title = g_strdup (_("Search Untitled Message"));
+
+ gnome_dialog_constructv (GNOME_DIALOG (ms), title, buttons);
+ g_free (title);
+
+ ms->search_forward = TRUE;
+ ms->case_sensitive = FALSE;
+
+
+ /* Construct the dialog contents. */
+
+ top_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"));
+
+ ms->entry = entry;
+
+ 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);
+
+ 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 (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), bot_hbox, TRUE, TRUE, 0);
+
+ gtk_widget_show_all (top_hbox);
+ gtk_widget_show_all (bot_hbox);
+
+
+ /* Hook up signals */
+
+ gtk_signal_connect (GTK_OBJECT (case_check),
+ "toggled",
+ GTK_SIGNAL_FUNC (toggled_case_cb),
+ ms);
+ gtk_signal_connect (GTK_OBJECT (fwd_check),
+ "toggled",
+ GTK_SIGNAL_FUNC (toggled_fwd_cb),
+ ms);
+
+ gtk_signal_connect (GTK_OBJECT (ms),
+ "clicked",
+ GTK_SIGNAL_FUNC (dialog_clicked_cb),
+ ms);
+
+
+}
+
+GtkWidget *
+mail_search_new (MailDisplay *mail)
+{
+ gpointer ptr;
+
+ g_return_val_if_fail (mail && IS_MAIL_DISPLAY (mail), NULL);
+
+ ptr = gtk_type_new (mail_search_get_type ());
+ mail_search_construct (MAIL_SEARCH (ptr), mail);
+
+ return GTK_WIDGET (ptr);
+}
+
diff --git a/mail/mail-search.h b/mail/mail-search.h
new file mode 100644
index 0000000000..f02bbb5fb4
--- /dev/null
+++ b/mail/mail-search.h
@@ -0,0 +1,76 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * mail-search.h
+ *
+ * Copyright (C) 2001 Ximian, Inc.
+ *
+ * Developed by Jon Trowbridge <trow@ximian.com>
+ */
+
+/*
+ * 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 _MAIL_SEARCH_H_
+#define _MAIL_SEARCH_H_
+
+#ifdef _cplusplus
+extern "C" {
+#pragma }
+#endif /* _cplusplus */
+
+#include <gnome.h>
+#include "mail-display.h"
+
+#define MAIL_SEARCH_TYPE (mail_search_get_type ())
+#define MAIL_SEARCH(o) (GTK_CHECK_CAST ((o), MAIL_SEARCH_TYPE, MailSearch))
+#define MAIL_SEARCH_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), MAIL_SEARCH_TYPE, MailSearch))
+#define IS_MAIL_SEARCH(o) (GTK_CHECK_TYPE ((o), MAIL_SEARCH_TYPE))
+#define IS_MAIL_SEARCH_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), MAIL_SEARCH_TYPE))
+
+typedef struct _MailSearch MailSearch;
+typedef struct _MailSearchClass MailSearchClass;
+
+struct _MailSearch {
+ GnomeDialog parent;
+
+ MailDisplay *mail;
+
+ GtkWidget *entry;
+
+ gboolean search_forward, case_sensitive;
+
+ gchar *last_search;
+};
+
+struct _MailSearchClass {
+ GnomeDialogClass parent_class;
+
+};
+
+GtkType mail_search_get_type (void);
+
+void mail_search_construct (MailSearch *, MailDisplay *);
+GtkWidget *mail_search_new (MailDisplay *);
+
+
+#ifdef _cplusplus
+}
+#endif /* _cplusplus */
+
+#endif /* _MAIL_SEARCH_H_ */
+
diff --git a/ui/ChangeLog b/ui/ChangeLog
index 4dc8d0070a..a26a4f34c8 100644
--- a/ui/ChangeLog
+++ b/ui/ChangeLog
@@ -1,3 +1,7 @@
+2001-04-26 Jon Trowbridge <trow@ximian.com>
+
+ * evolution-mail.xml: Added "Search Message" to "View" menu.
+
2001-04-16 Ettore Perazzoli <ettore@ximian.com>
* evolution.xml: Rename "New View" to "New Window" as suggested in
diff --git a/ui/evolution-mail.xml b/ui/evolution-mail.xml
index ef84a62ecf..de7feacba8 100644
--- a/ui/evolution-mail.xml
+++ b/ui/evolution-mail.xml
@@ -187,6 +187,11 @@
<submenu name="View">
<separator/>
+
+ <menuitem name="MessageSearch" verb=""
+ _label="S_earch Message" accel="*Control*e"/>
+
+ <separator/>
<menuitem name="Threaded" verb="ViewThreaded" accel="*Control*t"/>