aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Zucci <zucchi@src.gnome.org>2000-05-02 09:59:58 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-05-02 09:59:58 +0800
commitc65aa11c9bea4c474eef6129d82495de4784cbc5 (patch)
tree1e2a5f51ebd4702a1a5c79a2c7ef1b4f3f3a1350
parentdf0650ac1e84245d0812332f81a101d70d7e19ed (diff)
downloadgsoc2013-evolution-c65aa11c9bea4c474eef6129d82495de4784cbc5.tar.gz
gsoc2013-evolution-c65aa11c9bea4c474eef6129d82495de4784cbc5.tar.zst
gsoc2013-evolution-c65aa11c9bea4c474eef6129d82495de4784cbc5.zip
> (folder_browser_gui_init): Add an option meny to the search line.
> (create_option_menu): Build the option menu from a table. > (search_set): Build a search from another string whent he option > menu or text item is changed. 5 search options are defined so > far. svn path=/trunk/; revision=2742
-rw-r--r--mail/ChangeLog5
-rw-r--r--mail/folder-browser.c108
-rw-r--r--mail/folder-browser.h3
-rw-r--r--mail/message-list.c6
4 files changed, 108 insertions, 14 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index ebf858866a..2760e4f3de 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -4,6 +4,11 @@
quick-search entry.
(search_activate): Perform a quick-search on the folder subject
only.
+ (folder_browser_gui_init): Add an option meny to the search line.
+ (create_option_menu): Build the option menu from a table.
+ (search_set): Build a search from another string whent he option
+ menu or text item is changed. 5 search options are defined so
+ far.
* message-list.c (get_message_info): If there is an active search,
then get the data from that ... use this instead of
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index cdb4296205..455a1af44e 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -192,25 +192,107 @@ folder_browser_properties_init (FolderBrowser *fb)
BONOBO_ARG_BOOLEAN, NULL, _("Whether a message preview should be shown"), 0);
}
+static char * search_options[] = {
+ "Body or subject contains",
+ "Body contains",
+ "Subject contains",
+ "Body does not contain",
+ "Subject does not contain",
+ NULL
+};
+
+/* %s is replaced by the whole search string in quotes ...
+ possibly could split the search string into words as well ? */
+static char * search_string[] = {
+ "(or (body-contains %s) (match-all (header-contains \"Subject\" %s)))",
+ "(body-contains %s)",
+ "(match-all (header-contains \"Subject\" %s)",
+ "(match-all (not (body-contains %s)))",
+ "(match-all (not (header-contains \"Subject\" %s)))"
+};
+
static void
-search_activate(GtkEntry *entry, FolderBrowser *fb)
+search_set(FolderBrowser *fb)
{
+ GtkWidget *widget;
+ GString *out;
+ char *str;
+ int index;
char *text;
- text = gtk_entry_get_text(entry);
+ text = gtk_entry_get_text((GtkEntry *)fb->search_entry);
+
if (text == NULL || text[0] == 0) {
message_list_set_search (fb->message_list, NULL);
- } else {
- char *search = g_strdup_printf("(match-all (header-contains \"Subject\" \"%s\"))", text);
- message_list_set_search (fb->message_list, search);
- g_free(search);
+ return;
+ }
+
+ widget = gtk_menu_get_active (GTK_MENU(GTK_OPTION_MENU(fb->search_menu)->menu));
+ index = (int)gtk_object_get_data((GtkObject *)widget, "search_option");
+ if (index > sizeof(search_string)/sizeof(search_string[0]))
+ index = 0;
+ str = search_string[index];
+
+ out = g_string_new("");
+ while (*str) {
+ if (str[0] == '%' && str[1]=='s') {
+ str+=2;
+ g_string_sprintfa(out, "\"%s\"", text);
+ } else {
+ g_string_append_c(out, *str);
+ str++;
+ }
}
+ message_list_set_search (fb->message_list, out->str);
+ g_string_free(out, TRUE);
+}
+
+static void
+search_menu_deactivate(GtkWidget *menu, FolderBrowser *fb)
+{
+ search_set(fb);
+}
+
+static GtkWidget *
+create_option_menu (char **menu_list, int item, void *data)
+{
+ GtkWidget *omenu;
+ GtkWidget *menu;
+ int i = 0;
+
+ omenu = gtk_option_menu_new ();
+ menu = gtk_menu_new ();
+ while (*menu_list){
+ GtkWidget *entry;
+
+ entry = gtk_menu_item_new_with_label (*menu_list);
+ gtk_widget_show (entry);
+ gtk_object_set_data((GtkObject *)entry, "search_option", (void *)i);
+ gtk_menu_append (GTK_MENU (menu), entry);
+ menu_list++;
+ i++;
+ }
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
+ gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), item);
+ gtk_widget_show (omenu);
+
+ gtk_signal_connect (GTK_OBJECT (menu),
+ "deactivate",
+ GTK_SIGNAL_FUNC (search_menu_deactivate), data);
+
+ return omenu;
+}
+
+static void
+search_activate(GtkEntry *entry, FolderBrowser *fb)
+{
+ search_set(fb);
}
static void
folder_browser_gui_init (FolderBrowser *fb)
{
- GtkWidget *entry, *hbox, *label;
+ GtkWidget *hbox, *label;
/*
* The panned container
@@ -228,12 +310,14 @@ folder_browser_gui_init (FolderBrowser *fb)
/* quick-search entry */
hbox = gtk_hbox_new(FALSE, 3);
gtk_widget_show(hbox);
- entry = gtk_entry_new();
- gtk_widget_show(entry);
- gtk_signal_connect(entry, "activate", search_activate, fb);
- label = gtk_label_new("Search (subject contains)");
+ fb->search_entry = gtk_entry_new();
+ gtk_widget_show(fb->search_entry);
+ gtk_signal_connect(fb->search_entry, "activate", search_activate, fb);
+ label = gtk_label_new("Search");
gtk_widget_show(label);
- gtk_box_pack_end((GtkBox *)hbox, entry, FALSE, FALSE, 3);
+ fb->search_menu = create_option_menu(search_options, 0, fb);
+ gtk_box_pack_end((GtkBox *)hbox, fb->search_entry, FALSE, FALSE, 3);
+ gtk_box_pack_end((GtkBox *)hbox, fb->search_menu, FALSE, FALSE, 3);
gtk_box_pack_end((GtkBox *)hbox, label, FALSE, FALSE, 3);
gtk_table_attach (
GTK_TABLE (fb), hbox,
diff --git a/mail/folder-browser.h b/mail/folder-browser.h
index 04c3dbcb4a..6e9c66a0cd 100644
--- a/mail/folder-browser.h
+++ b/mail/folder-browser.h
@@ -37,6 +37,9 @@ struct _FolderBrowser {
GtkWidget *message_list_w;
MailDisplay *mail_display;
GtkWidget *vpaned;
+ GtkWidget *search_menu;
+ GtkWidget *search_entry;
+
gboolean preview_shown;
};
diff --git a/mail/message-list.c b/mail/message-list.c
index 7536946f44..d1a87201f8 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -63,8 +63,11 @@ CamelMessageInfo *get_message_info(MessageList *message_list, gint row)
char *uid;
uid = g_list_nth_data(message_list->matches, row);
- if (uid)
+ if (uid) {
info = camel_folder_summary_get_by_uid(message_list->folder, uid);
+ } else {
+ g_warning("trying to get data for nonexistant row %d", row);
+ }
} else {
GPtrArray *msg_info_array;
msg_info_array = camel_folder_summary_get_message_info
@@ -677,7 +680,6 @@ message_list_set_search (MessageList *message_list, const char *search)
if (search) {
CamelException ex;
- printf("Searching for: %s\n", search);
camel_exception_init (&ex);
message_list->matches = camel_folder_search_by_expression(message_list->folder, search, &ex);
}