aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/ChangeLog9
-rw-r--r--addressbook/gui/widgets/addresstypes.xml5
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c55
-rw-r--r--calendar/ChangeLog9
-rw-r--r--calendar/gui/cal-search-bar.c121
-rw-r--r--calendar/gui/e-tasks.c2
-rw-r--r--mail/ChangeLog22
-rw-r--r--mail/em-folder-browser.c617
-rw-r--r--mail/em-folder-browser.h4
-rw-r--r--mail/em-folder-view.c5
-rw-r--r--mail/em-format-html-display.c256
-rw-r--r--mail/em-format-html-display.h4
-rw-r--r--mail/mail-component.c40
-rw-r--r--mail/mail-vfolder.c101
-rw-r--r--mail/message-list.c36
-rw-r--r--mail/message-list.etspec2
-rw-r--r--widgets/ChangeLog34
-rw-r--r--widgets/misc/Makefile.am2
-rw-r--r--widgets/misc/e-filter-bar.c158
-rw-r--r--widgets/misc/e-filter-bar.h24
-rw-r--r--widgets/misc/e-search-bar.c898
-rw-r--r--widgets/misc/e-search-bar.h60
-rw-r--r--widgets/table/e-tree-table-adapter.c2
23 files changed, 1727 insertions, 739 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index b878b58aa4..3fa22350ef 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,12 @@
+2006-06-30 Johnny Jacob <jjohnny@novell.com>
+ * gui/cal-search-bar.c: (get_current_category),
+ (get_category_sexp), (notify_e_cal_view_contains),
+ (notify_category_is), (regen_query), (regen_view_query),
+ (make_suboptions), (cal_search_bar_construct): Added/Removed code
+ for new search ui.
+ * gui/e-tasks.c: (search_bar_sexp_changed_cb):
+ Added/Removed code for search ui.
+
2006-06-29 simon.zheng <simon.zheng@sun.com>
* gui/widgets/eab-gui-util.c: (file_exists): Convert filename
diff --git a/addressbook/gui/widgets/addresstypes.xml b/addressbook/gui/widgets/addresstypes.xml
index f320a9b03f..b8274a983f 100644
--- a/addressbook/gui/widgets/addresstypes.xml
+++ b/addressbook/gui/widgets/addresstypes.xml
@@ -161,11 +161,6 @@
</rule>
<rule grouping="any" source="demand">
- <_title>Category is</_title>
- <sources/>
- </rule>
-
- <rule grouping="any" source="demand">
<_title>Any field contains</_title>
<sources/>
</rule>
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index bf541bb05c..6cfc0913d6 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -166,10 +166,9 @@ enum {
};
static ESearchBarItem addressbook_search_option_items[] = {
- { N_("Name begins with"), ESB_FULL_NAME, NULL },
- { N_("Email begins with"), ESB_EMAIL, NULL },
- { N_("Category is"), ESB_CATEGORY, NULL }, /* We attach subitems below */
- { N_("Any field contains"), ESB_ANY, NULL },
+ { N_("Name begins with"), ESB_FULL_NAME, ESB_ITEMTYPE_RADIO },
+ { N_("Email begins with"), ESB_EMAIL, ESB_ITEMTYPE_RADIO },
+ { N_("Any field contains"), ESB_ANY, ESB_ITEMTYPE_RADIO },
{ NULL, -1, NULL }
};
@@ -1483,19 +1482,17 @@ static void
search_activated (ESearchBar *esb, EABView *v)
{
GList *master_list;
- char *search_word, *search_query;
+ char *search_word, *search_query, *view_sexp;
const char *category_name;
int search_type, subid;
- g_message ("in search_activated");
-
g_object_get(esb,
"text", &search_word,
"item_id", &search_type,
NULL);
if (search_type == E_FILTERBAR_ADVANCED_ID) {
- //gtk_widget_show(eab_search_dialog_new(v));
+ gtk_widget_show(eab_search_dialog_new(v));
}
else {
if ((search_word && strlen (search_word)) || search_type == ESB_CATEGORY) {
@@ -1514,26 +1511,26 @@ search_activated (ESearchBar *esb, EABView *v)
search_query = g_strdup_printf ("(beginswith \"email\" %s)",
s->str);
break;
- case ESB_CATEGORY:
- subid = e_search_bar_get_subitem_id (esb);
-
- if (subid < 0 || subid == G_MAXINT) {
- /* match everything */
- search_query = g_strdup ("(contains \"x-evolution-any-field\" \"\")");
- } else {
- master_list = get_master_list ();
- category_name = g_list_nth_data (master_list, subid);
- search_query = g_strdup_printf ("(is \"category_list\" \"%s\")", category_name);
- }
- break;
default:
search_query = g_strdup ("(contains \"x-evolution-any-field\" \"\")");
break;
}
g_string_free (s, TRUE);
- } else
+
+ } else
search_query = g_strdup ("(contains \"x-evolution-any-field\" \"\")");
+ /* Merge view and sexp */
+ subid = e_search_bar_get_viewitem_id (esb);
+
+ if (subid != G_MAXINT) {
+ master_list = get_master_list ();
+ category_name = g_list_nth_data (master_list, subid);
+ view_sexp = g_strdup_printf ("(is \"category_list\" \"%s\")", category_name);
+ search_query = g_strconcat ("(and ", view_sexp, search_query, ")", NULL);
+ g_free (view_sexp);
+ }
+
if (search_query)
g_object_set (v,
"query", search_query,
@@ -1564,6 +1561,7 @@ query_changed (ESearchBar *esb, EABView *view)
search_type = e_search_bar_get_item_id(esb);
if (search_type == E_FILTERBAR_ADVANCED_ID) {
g_object_get (esb, "query", &query, NULL);
+ printf ("e-addresbook-view.c : query_changed : query = %s\n",query);
g_object_set (view, "query", query, NULL);
g_free (query);
}
@@ -1572,8 +1570,8 @@ query_changed (ESearchBar *esb, EABView *view)
static int
compare_subitems (const void *a, const void *b)
{
- const ESearchBarSubitem *subitem_a = a;
- const ESearchBarSubitem *subitem_b = b;
+ const ESearchBarItem *subitem_a = a;
+ const ESearchBarItem *subitem_b = b;
char *collate_a, *collate_b;
int ret;
@@ -1589,33 +1587,32 @@ compare_subitems (const void *a, const void *b)
}
static void
+
make_suboptions (EABView *view)
{
- ESearchBarSubitem *subitems, *s;
+ ESearchBarItem *subitems, *s;
GList *master_list;
gint i, N;
master_list = get_master_list ();
N = g_list_length (master_list);
- subitems = g_new (ESearchBarSubitem, N+2);
+ subitems = g_new (ESearchBarItem, N+2);
subitems[0].id = G_MAXINT;
subitems[0].text = g_strdup (_("Any Category"));
- subitems[0].translate = FALSE;
for (i=0; i<N; ++i) {
const char *category = g_list_nth_data (master_list, i);
-
subitems[i+1].id = i;
subitems[i+1].text = g_strdup (category);
- subitems[i+1].translate = FALSE;
}
+
subitems[N+1].id = -1;
subitems[N+1].text = NULL;
qsort (subitems + 1, N, sizeof (subitems[0]), compare_subitems);
- e_search_bar_set_suboption ( (ESearchBar *) view->search, ESB_CATEGORY, subitems);
+ e_search_bar_set_viewoption ( (ESearchBar *) view->search, ESB_CATEGORY, subitems);
for (s = subitems; s->id != -1; s++) {
if (s->text)
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 6246ef2a56..4de3de06bc 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,12 @@
+2006-06-30 Johnny Jacob <jjohnny@novell.com>
+ * gui/cal-search-bar.c: (get_current_category),
+ (get_category_sexp), (notify_e_cal_view_contains),
+ (notify_category_is), (regen_query), (regen_view_query),
+ (make_suboptions), (cal_search_bar_construct): Added/Removed code
+ for new search ui.
+ * gui/e-tasks.c: (search_bar_sexp_changed_cb):
+ Added/Removed code for search ui.
+
2006-06-28 Andre Klapper <a9016009@gmx.de>
* gui/e-itip-control.glade: Adding translator comments to the
diff --git a/calendar/gui/cal-search-bar.c b/calendar/gui/cal-search-bar.c
index ba199049da..12c6f1018e 100644
--- a/calendar/gui/cal-search-bar.c
+++ b/calendar/gui/cal-search-bar.c
@@ -45,12 +45,11 @@ enum {
/* Comments are disabled because they are kind of useless right now, see bug 33247 */
static ESearchBarItem search_option_items[] = {
- { N_("Summary contains"), SEARCH_SUMMARY_CONTAINS, NULL },
- { N_("Description contains"), SEARCH_DESCRIPTION_CONTAINS, NULL },
- { N_("Category is"), SEARCH_CATEGORY_IS, NULL },
- { N_("Comment contains"), SEARCH_COMMENT_CONTAINS, NULL },
- { N_("Location contains"), SEARCH_LOCATION_CONTAINS, NULL },
- { N_("Any field contains"), SEARCH_ANY_FIELD_CONTAINS, NULL },
+ { N_("Summary contains"), SEARCH_SUMMARY_CONTAINS, ESB_ITEMTYPE_RADIO },
+ { N_("Description contains"), SEARCH_DESCRIPTION_CONTAINS, ESB_ITEMTYPE_RADIO },
+ { N_("Comment contains"), SEARCH_COMMENT_CONTAINS, ESB_ITEMTYPE_RADIO },
+ { N_("Location contains"), SEARCH_LOCATION_CONTAINS, ESB_ITEMTYPE_RADIO },
+ { N_("Any field contains"), SEARCH_ANY_FIELD_CONTAINS, ESB_ITEMTYPE_RADIO },
};
/* IDs for the categories suboptions */
@@ -186,48 +185,28 @@ static const char *
get_current_category (CalSearchBar *cal_search)
{
CalSearchBarPrivate *priv;
- int id, subid;
+ gint viewid;
priv = cal_search->priv;
g_assert (priv->categories != NULL);
- id = e_search_bar_get_item_id (E_SEARCH_BAR (cal_search));
- if (id != SEARCH_CATEGORY_IS)
- return NULL;
+ viewid = e_search_bar_get_viewitem_id (E_SEARCH_BAR (cal_search));
- subid = e_search_bar_get_subitem_id (E_SEARCH_BAR (cal_search));
- if (subid == CATEGORIES_ALL)
+ if (viewid == CATEGORIES_ALL)
return (const char *) 1;
- else if (subid == CATEGORIES_UNMATCHED)
+ else if (viewid == CATEGORIES_UNMATCHED)
return NULL;
else {
int i;
- i = subid - CATEGORIES_OFFSET;
+ i = viewid - CATEGORIES_OFFSET;
g_assert (i >= 0 && i < priv->categories->len);
return priv->categories->pdata[i];
}
}
-/* Sets the query string to be (contains? "field" "text") */
-static void
-notify_e_cal_view_contains (CalSearchBar *cal_search, const char *field)
-{
- char *text;
- char *sexp;
-
- text = e_search_bar_get_text (E_SEARCH_BAR (cal_search));
- if (!text)
- return; /* This is an error in the UTF8 conversion, not an empty string! */
-
- sexp = g_strdup_printf ("(contains? \"%s\" \"%s\")", field, text);
- g_free (text);
-
- notify_sexp_changed (cal_search, sexp);
- g_free (sexp);
-}
/* Returns a sexp for the selected category in the drop-down menu. The "All"
* option is returned as (const char *) 1, and the "Unfiled" option is returned
@@ -242,12 +221,42 @@ get_category_sexp (CalSearchBar *cal_search)
if (category == NULL)
return g_strdup ("(has-categories? #f)"); /* Unfiled items */
- else if (category == (const char *) 1)
+ else if (category == (const char *) 1) {
return NULL; /* All items */
+ }
else
return g_strdup_printf ("(has-categories? \"%s\")", category); /* Specific category */
}
+
+/* Sets the query string to be (contains? "field" "text") */
+static void
+notify_e_cal_view_contains (CalSearchBar *cal_search, const char *field, const char *view)
+{
+ char *text = NULL;
+ char *sexp = " ";
+
+ text = e_search_bar_get_text (E_SEARCH_BAR (cal_search));
+
+ if (!text)
+ return; /* This is an error in the UTF8 conversion, not an empty string! */
+
+ if (text && *text) {
+ sexp = g_strdup_printf ("(contains? \"%s\" \"%s\")", field, text);
+ g_free (text);
+ } else
+ sexp = g_strdup_printf ("(contains? \"summary\" \"\")", field, text); /* Show all */
+
+
+ /* Apply the selected view on search */
+ view = get_category_sexp (cal_search);
+ if (view && *view)
+ sexp = g_strconcat ("(and ",sexp, view, ")", NULL);
+
+ notify_sexp_changed (cal_search, sexp);
+ g_free (sexp);
+}
+
/* Sets the query string to the appropriate match for categories */
static void
notify_category_is (CalSearchBar *cal_search)
@@ -255,6 +264,7 @@ notify_category_is (CalSearchBar *cal_search)
char *sexp;
sexp = get_category_sexp (cal_search);
+
if (!sexp)
notify_sexp_changed (cal_search, "#t"); /* Match all */
else
@@ -269,41 +279,34 @@ static void
regen_query (CalSearchBar *cal_search)
{
int id;
- const char *category;
+ const char *category_sexp, *category;
/* Fetch the data from the ESearchBar's entry widgets */
-
id = e_search_bar_get_item_id (E_SEARCH_BAR (cal_search));
- /* Generate the different types of queries */
+ /* Get the selected view */
+ category_sexp = get_category_sexp (cal_search);
+ /* Generate the different types of queries */
switch (id) {
case SEARCH_ANY_FIELD_CONTAINS:
- notify_e_cal_view_contains (cal_search, "any");
+ notify_e_cal_view_contains (cal_search, "any", category_sexp);
break;
case SEARCH_SUMMARY_CONTAINS:
- notify_e_cal_view_contains (cal_search, "summary");
+ notify_e_cal_view_contains (cal_search, "summary", category_sexp);
break;
case SEARCH_DESCRIPTION_CONTAINS:
- notify_e_cal_view_contains (cal_search, "description");
+ notify_e_cal_view_contains (cal_search, "description", category_sexp);
break;
case SEARCH_COMMENT_CONTAINS:
- notify_e_cal_view_contains (cal_search, "comment");
+ notify_e_cal_view_contains (cal_search, "comment", category_sexp);
break;
case SEARCH_LOCATION_CONTAINS:
- notify_e_cal_view_contains (cal_search, "location");
- break;
-
- case SEARCH_CATEGORY_IS:
- notify_category_is (cal_search);
-
- category = cal_search_bar_get_category (cal_search);
- gtk_signal_emit (GTK_OBJECT (cal_search), cal_search_bar_signals[CATEGORY_CHANGED],
- category);
+ notify_e_cal_view_contains (cal_search, "location", category_sexp);
break;
default:
@@ -311,6 +314,16 @@ regen_query (CalSearchBar *cal_search)
}
}
+static void
+regen_view_query (CalSearchBar *cal_search)
+{
+ const char *category;
+ notify_category_is (cal_search);
+
+ category = cal_search_bar_get_category (cal_search);
+ gtk_signal_emit (GTK_OBJECT (cal_search), cal_search_bar_signals[CATEGORY_CHANGED],
+ category);
+}
/* search_activated handler for the calendar search bar */
static void
cal_search_bar_search_activated (ESearchBar *search)
@@ -328,7 +341,7 @@ static void
make_suboptions (CalSearchBar *cal_search)
{
CalSearchBarPrivate *priv;
- ESearchBarSubitem *subitems;
+ ESearchBarItem *subitems;
int i;
priv = cal_search->priv;
@@ -336,17 +349,15 @@ make_suboptions (CalSearchBar *cal_search)
g_assert (priv->categories != NULL);
/* Categories plus "all", "unmatched", separator, terminator */
- subitems = g_new (ESearchBarSubitem, priv->categories->len + 3 + 1);
+ subitems = g_new (ESearchBarItem, priv->categories->len + 3 + 1);
/* All, unmatched, separator */
subitems[0].text = _("Any Category");
subitems[0].id = CATEGORIES_ALL;
- subitems[0].translate = FALSE;
subitems[1].text = _("Unmatched");
subitems[1].id = CATEGORIES_UNMATCHED;
- subitems[1].translate = FALSE;
/* All the other items */
@@ -363,14 +374,13 @@ make_suboptions (CalSearchBar *cal_search)
subitems[i + CATEGORIES_OFFSET].text = str;
subitems[i + CATEGORIES_OFFSET].id = i + CATEGORIES_OFFSET;
- subitems[i + CATEGORIES_OFFSET].translate = FALSE;
}
subitems[i + CATEGORIES_OFFSET].id = -1; /* terminator */
} else
subitems[2].id = -1; /* terminator */
- e_search_bar_set_suboption (E_SEARCH_BAR (cal_search), SEARCH_CATEGORY_IS, subitems);
+ e_search_bar_set_viewoption (E_SEARCH_BAR (cal_search), SEARCH_CATEGORY_IS, subitems);
/* Free the strings */
for (i = 0; i < priv->categories->len; i++)
@@ -402,14 +412,13 @@ cal_search_bar_construct (CalSearchBar *cal_search, guint32 flags)
if ((flags & bit) != 0) {
items[j].text = search_option_items[i].text;
items[j].id = search_option_items[i].id;
- items[j].subitems = search_option_items[i].subitems;
+ items[j].type = search_option_items[i].type;
j++;
}
}
items[j].text = NULL;
items[j].id = -1;
- items[j].subitems = NULL;
e_search_bar_construct (E_SEARCH_BAR (cal_search), NULL, items);
make_suboptions (cal_search);
diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c
index 5d9a7d6bf6..adfef2b564 100644
--- a/calendar/gui/e-tasks.c
+++ b/calendar/gui/e-tasks.c
@@ -220,7 +220,7 @@ search_bar_sexp_changed_cb (CalSearchBar *cal_search, const char *sexp, gpointer
g_free (priv->sexp);
priv->sexp = g_strdup (sexp);
-
+
update_view (tasks);
}
diff --git a/mail/ChangeLog b/mail/ChangeLog
index ebf18e842e..4f74e3823a 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,25 @@
+2006-06-30 Johnny Jacob <jjohnny@novell.com>
+ * mail/em-folder-browser.h: Added search_activated signal
+ * mail/em-folder-view.c: (emfv_init):
+ * mail/em-format-html-display.c: (efhd_search_response),
+ (efhd_search_response_back), (efhd_search_destroy),
+ (efhd_search_case_toggled), (efhd_key_pressed),
+ (clear_button_clicked_cb), (icon_entry_changed_cb),
+ (em_format_html_get_search_dialog), (set_focus_cb),
+ (em_format_html_display_search),
+ (em_format_html_display_search_with),
+ (em_format_html_display_search_close):
+ * mail/em-format-html-display.h:
+ * mail/mail-component.c: (disable_folder_tree),
+ (enable_folder_tree), (impl_createView):
+ * mail/mail-vfolder.c: (mail_vfolder_add_uri),
+ (mail_vfolder_get_sources_local),
+ (mail_vfolder_get_sources_remote), (store_folder_renamed):
+ * mail/message-list.c: (ml_tree_value_at),
+ (message_list_setup_etree):
+ * mail/message-list.etspec:
+ Added code for search ui.
+
2006-06-27 Matthew Barnes <mbarnes@redhat.com>
* evolution-mail.schemas.in.in:
diff --git a/mail/em-folder-browser.c b/mail/em-folder-browser.c
index 0493035075..f15df9984c 100644
--- a/mail/em-folder-browser.c
+++ b/mail/em-folder-browser.c
@@ -60,6 +60,8 @@
#include <camel/camel-stream.h>
#include <camel/camel-url.h>
+#include <camel/camel-vee-folder.h>
+#include <camel/camel-vee-store.h>
#include <bonobo/bonobo-main.h>
#include <bonobo/bonobo-object.h>
@@ -74,6 +76,7 @@
#include "em-vfolder-rule.h"
#include <misc/e-filter-bar.h>
#include <camel/camel-search-private.h>
+#include <camel/camel-store.h>
#include "e-util/e-dialog-utils.h"
#include "e-util/e-error.h"
@@ -94,6 +97,9 @@
#include "evolution-shell-component-utils.h" /* Pixmap stuff, sigh */
+extern CamelSession *session;
+CamelStore *vfolder_store; /* the 1 static vfolder store */
+
#define d(x)
struct _EMFolderBrowserPrivate {
@@ -122,6 +128,7 @@ struct _EMFolderBrowserPrivate {
static void emfb_activate(EMFolderView *emfv, BonoboUIComponent *uic, int state);
static void emfb_set_folder(EMFolderView *emfv, CamelFolder *folder, const char *uri);
+static void emfb_set_search_folder(EMFolderView *emfv, CamelFolder *folder, const char *uri);
/* FilterBar stuff ... */
static void emfb_search_config_search(EFilterBar *efb, FilterRule *rule, int id, const char *query, void *data);
@@ -135,17 +142,70 @@ static void emfb_list_message_selected (MessageList *ml, const char *uid, EMFold
static const EMFolderViewEnable emfb_enable_map[];
enum {
+ ACCOUNT_SEARCH_ACTIVATED,
+ ACCOUNT_SEARCH_CLEARED,
+ LAST_SIGNAL
+};
+
+static guint folder_browser_signals [LAST_SIGNAL] = {0, };
+
+enum {
ESB_SAVE,
};
static ESearchBarItem emfb_search_items[] = {
E_FILTERBAR_ADVANCED,
- { NULL, 0, NULL },
+ { NULL, 0, 0 },
E_FILTERBAR_SAVE,
E_FILTERBAR_EDIT,
- { NULL, 0, NULL },
- { N_("C_reate Search Folder From Search..."), ESB_SAVE, NULL },
- { NULL, -1, NULL }
+ { NULL, 0, 0 },
+ { N_("C_reate Search Folder From Search..."), ESB_SAVE, 0},
+ { NULL, -1, 0 }
+};
+
+/* IDs and option items for the ESearchBar */
+enum {
+ VIEW_ALL_MESSAGES,
+ VIEW_UNREAD_MESSAGES,
+ VIEW_READ_MESSAGES,
+ VIEW_RECENT_MESSAGES,
+ VIEW_LAST_FIVE_DAYS,
+ VIEW_WITH_ATTACHMENTS,
+ VIEW_NOT_JUNK,
+ VIEW_NO_LABEL,
+ VIEW_LABEL,
+ VIEW_ANY_FIELD_CONTAINS,
+ VIEW_CUSTOMIZE
+};
+
+/* Options for View */
+static ESearchBarItem emfb_view_items[] = {
+ { N_("All Messages"), VIEW_ALL_MESSAGES, 0 },
+ { N_("Unread Messages"), VIEW_UNREAD_MESSAGES, 0 },
+ { NULL, 0, 0 },
+ { N_("No Label"),VIEW_NO_LABEL, 0 },
+ { NULL, -1, 0 }
+};
+
+/* TODO: Following options should be customizable */
+static ESearchBarItem temp_view_items[] = {
+ { NULL, 0, 0 },
+ { N_("Read Messages"), VIEW_READ_MESSAGES, 0 },
+ { N_("Recent Messages"), VIEW_RECENT_MESSAGES, 0 },
+ { N_("Last 5 Days Messages"), VIEW_LAST_FIVE_DAYS, 0 },
+ { N_("Messages with Attachments"), VIEW_WITH_ATTACHMENTS, 0 },
+ { N_("Messages Not Junk"), VIEW_NOT_JUNK, 0 },
+/* { NULL, 0, NULL }, */
+/* { N_("Customize"), NOT_IMPLEMENTED, NULL }, */
+ { NULL, -1, 0 }
+};
+
+static ESearchBarItem emfb_search_scope_items[] = {
+ E_FILTERBAR_ALL_ACCOUNTS,
+ E_FILTERBAR_CURRENT_ACCOUNT,
+ E_FILTERBAR_CURRENT_FOLDER,
+ E_FILTERBAR_CURRENT_MESSAGE,
+ { NULL, -1, 0 }
};
static EMFolderViewClass *emfb_parent;
@@ -189,12 +249,136 @@ free_one_ui_file (gpointer data,
g_free (data);
}
+static char *
+string_without_underscores (const char *s)
+{
+ char *new_string;
+ const char *sp;
+ char *dp;
+
+ new_string = g_malloc (strlen (s) + 1);
+
+ dp = new_string;
+ for (sp = s; *sp != '\0'; sp ++) {
+ if (*sp != '_') {
+ *dp = *sp;
+ dp ++;
+ } else if (sp[1] == '_') {
+ /* Translate "__" in "_". */
+ *dp = '_';
+ dp ++;
+ sp ++;
+ }
+ }
+ *dp = 0;
+
+ return new_string;
+}
+
+static GtkWidget *
+generate_viewoption_menu ()
+{
+ GtkWidget *menu, *menu_item;
+ gint i = 0;
+ GSList *l;
+
+ menu = gtk_menu_new ();
+
+ for (i = 0; emfb_view_items[i].id != -1; ++i) {
+ if (emfb_view_items[i].text) {
+ char *str;
+ str = string_without_underscores (emfb_view_items[i].text);
+ menu_item = gtk_menu_item_new_with_label (str);
+ g_free (str);
+ } else {
+ menu_item = gtk_menu_item_new ();
+ gtk_widget_set_sensitive (menu_item, FALSE);
+ }
+
+ g_object_set_data (G_OBJECT (menu_item), "EsbItemId",
+ GINT_TO_POINTER (emfb_view_items[i].id));
+
+ gtk_widget_show (menu_item);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
+ }
+
+ /* Add the labels */
+ for (l = mail_config_get_labels(); l; l = l->next) {
+ MailConfigLabel *label = l->data;
+ if (label->name && *(label->name)) {
+ char *str;
+ str = string_without_underscores (label->name);
+ menu_item = gtk_menu_item_new_with_label (str);
+ g_free (str);
+
+ g_object_set_data (G_OBJECT (menu_item), "EsbItemId",
+ GINT_TO_POINTER (VIEW_LABEL));
+
+ g_object_set_data (G_OBJECT (menu_item), "LabelTag",
+ g_strdup(label->tag));
+ }
+
+ gtk_widget_show (menu_item);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
+ }
+
+ for (i = 0; temp_view_items[i].id != -1; ++i) {
+ if (temp_view_items[i].text) {
+ char *str;
+ str = string_without_underscores (temp_view_items[i].text);
+ menu_item = gtk_menu_item_new_with_label (str);
+ g_free (str);
+ } else {
+ menu_item = gtk_menu_item_new ();
+ gtk_widget_set_sensitive (menu_item, FALSE);
+ }
+
+ g_object_set_data (G_OBJECT (menu_item), "EsbItemId",
+ GINT_TO_POINTER (temp_view_items[i].id));
+
+ gtk_widget_show (menu_item);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
+ }
+
+ return menu;
+}
+
+
+static GArray *
+viewoption_menu_generator ()
+{
+ GArray *menu = g_array_new (FALSE, FALSE, sizeof (ESearchBarItem));
+ gint i = 0;
+ ESearchBarItem dup_item;
+ GSList *l;
+
+ for (i = 0; emfb_view_items[i].id != -1; i++)
+ g_array_append_vals (menu, &emfb_view_items[i], 1);
+
+ for (l = mail_config_get_labels(); l; l = l->next) {
+ ESearchBarItem item;
+ MailConfigLabel *label = l->data;
+
+ item.text = label->name;
+ item.id = VIEW_LABEL;
+
+ g_array_append_vals (menu, &item, 1);
+ }
+
+ dup_item.id = -1;
+ dup_item.text = NULL;
+ g_array_append_vals (menu, &dup_item, 1);
+
+ return menu;
+}
+
static void
emfb_init(GObject *o)
{
EMFolderBrowser *emfb = (EMFolderBrowser *)o;
RuleContext *search_context = mail_component_peek_search_context (mail_component_peek ());
struct _EMFolderBrowserPrivate *p;
+ GtkWidget *menu;
p = emfb->priv = g_malloc0(sizeof(struct _EMFolderBrowserPrivate));
@@ -222,9 +406,13 @@ emfb_init(GObject *o)
if (search_context) {
const char *systemrules = g_object_get_data (G_OBJECT (search_context), "system");
const char *userrules = g_object_get_data (G_OBJECT (search_context), "user");
-
+
emfb->search = e_filter_bar_new(search_context, systemrules, userrules, emfb_search_config_search, emfb);
e_search_bar_set_menu ((ESearchBar *)emfb->search, emfb_search_items);
+ e_search_bar_set_scopeoption ((ESearchBar *)emfb->search, emfb_search_scope_items);
+
+ menu = generate_viewoption_menu();
+ e_search_bar_set_viewoption_menu ((ESearchBar *)emfb->search, menu);
gtk_widget_show((GtkWidget *)emfb->search);
p->search_menu_activated_id = g_signal_connect(emfb->search, "menu_activated", G_CALLBACK(emfb_search_menu_activated), emfb);
@@ -261,6 +449,7 @@ emfb_init(GObject *o)
g_signal_connect (((EMFolderView *) emfb)->list->tree, "key_press", G_CALLBACK(emfb_list_key_press), emfb);
g_signal_connect (((EMFolderView *) emfb)->list, "message_selected", G_CALLBACK (emfb_list_message_selected), emfb);
+
}
static void
@@ -305,6 +494,27 @@ emfb_class_init(GObjectClass *klass)
{
klass->finalize = emfb_finalise;
+ folder_browser_signals[ACCOUNT_SEARCH_ACTIVATED] =
+ g_signal_new ("account_search_activated",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EMFolderBrowserClass, account_search_activated),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+
+ folder_browser_signals[ACCOUNT_SEARCH_CLEARED] =
+ g_signal_new ("account_search_cleared",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EMFolderBrowserClass, account_search_cleared),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+
+
((GtkObjectClass *)klass)->destroy = emfb_destroy;
((EMFolderViewClass *)klass)->set_folder = emfb_set_folder;
((EMFolderViewClass *)klass)->activate = emfb_activate;
@@ -465,7 +675,7 @@ emfb_search_config_search(EFilterBar *efb, FilterRule *rule, int id, const char
struct _camel_search_words *words;
int i;
GSList *strings = NULL;
-
+
/* we scan the parts of a rule, and set all the types we know about to the query string */
partl = rule->parts;
while (partl) {
@@ -502,40 +712,360 @@ emfb_search_config_search(EFilterBar *efb, FilterRule *rule, int id, const char
strings);
while (strings) {
GSList *n = strings->next;
-
g_free(strings->data);
g_slist_free_1(strings);
strings = n;
}
}
+static char *
+get_view_query (ESearchBar *esb)
+{
+ char *view_sexp = NULL;
+ gint id;
+ GtkWidget *menu_item;
+ char *tag;
+
+ /* Get the current selected view */
+ id = e_search_bar_get_viewitem_id (esb);
+ menu_item = e_search_bar_get_selected_viewitem (esb);
+
+ switch (id) {
+ case VIEW_ALL_MESSAGES:
+ view_sexp = " ";
+ break;
+
+ case VIEW_UNREAD_MESSAGES:
+ view_sexp = "(match-all (not (system-flag \"Seen\")))";
+ break;
+ case VIEW_READ_MESSAGES:
+ view_sexp = "(match-all (system-flag \"Seen\"))";
+ break;
+ case VIEW_RECENT_MESSAGES:
+ view_sexp = "(match-all (> (get-received-date) (- (get-current-date) 86400)))";
+ break;
+ case VIEW_LAST_FIVE_DAYS:
+ view_sexp = " (match-all (> (get-received-date) (- (get-current-date) 432000)))";
+ break;
+ case VIEW_WITH_ATTACHMENTS:
+ view_sexp = "(match-all (system-flag \"Attachments\"))";
+ break;
+ case VIEW_NOT_JUNK:
+ view_sexp = "(match-all (not (system-flag \"junk\")))";
+ break;
+ case VIEW_NO_LABEL:
+ /* FIXME : cannot hard code this query */
+ view_sexp = "(and (match-all (not (= (user-tag \"label\") \"important\")))"
+ "(match-all (not (= (user-tag \"label\") \"work\"))) (match-all (not (= (user-tag \"label\") \"personal\")))"
+ "(match-all (not (= (user-tag \"label\") \"todo\"))) (match-all (not (= (user-tag \"label\") \"later\"))) ))";
+ break;
+ case VIEW_LABEL:
+ tag = (char *)g_object_get_data (G_OBJECT (menu_item), "LabelTag");
+ view_sexp = g_strdup_printf ("(match-all (= (user-tag \"label\") \"%s\"))",tag);
+ break;
+ case VIEW_ANY_FIELD_CONTAINS:
+ break;
+
+ case VIEW_CUSTOMIZE:
+ view_sexp = " ";
+ break;
+ }
+ return view_sexp;
+}
+
+
+struct _setup_msg {
+ struct _mail_msg msg;
+
+ CamelFolder *folder;
+ char *query;
+ GList *sources_uri;
+ GList *sources_folder;
+};
+
+static char *
+vfolder_setup_desc(struct _mail_msg *mm, int done)
+{
+ struct _setup_msg *m = (struct _setup_msg *)mm;
+
+ return g_strdup(_("Searching"));
+}
+
+static void
+vfolder_setup_do(struct _mail_msg *mm)
+{
+ struct _setup_msg *m = (struct _setup_msg *)mm;
+ GList *l, *list = NULL;
+ CamelFolder *folder;
+
+ d(printf("Setting up Search Folder: %s\n", m->folder->full_name));
+
+ camel_vee_folder_set_expression((CamelVeeFolder *)m->folder, m->query);
+
+ l = m->sources_uri;
+ while (l) {
+ d(printf(" Adding uri: %s\n", (char *)l->data));
+ folder = mail_tool_uri_to_folder (l->data, 0, &mm->ex);
+ if (folder) {
+ list = g_list_append(list, folder);
+ } else {
+ g_warning("Could not open vfolder source: %s", (char *)l->data);
+ camel_exception_clear(&mm->ex);
+ }
+ l = l->next;
+ }
+
+ l = m->sources_folder;
+ while (l) {
+ d(printf(" Adding folder: %s\n", ((CamelFolder *)l->data)->full_name));
+ camel_object_ref(l->data);
+ list = g_list_append(list, l->data);
+ l = l->next;
+ }
+
+ camel_vee_folder_set_folders((CamelVeeFolder *)m->folder, list);
+
+ l = list;
+ while (l) {
+ camel_object_unref(l->data);
+ l = l->next;
+ }
+ g_list_free(list);
+}
+
+static void
+vfolder_setup_done(struct _mail_msg *mm)
+{
+ struct _setup_msg *m = (struct _setup_msg *)mm;
+
+ m = m;
+}
+
+static void
+vfolder_setup_free (struct _mail_msg *mm)
+{
+ struct _setup_msg *m = (struct _setup_msg *)mm;
+ GList *l;
+
+ camel_object_unref(m->folder);
+ g_free(m->query);
+
+ l = m->sources_uri;
+ while (l) {
+ g_free(l->data);
+ l = l->next;
+ }
+ g_list_free(m->sources_uri);
+
+ l = m->sources_folder;
+ while (l) {
+ camel_object_unref(l->data);
+ l = l->next;
+ }
+ g_list_free(m->sources_folder);
+}
+
+static struct _mail_msg_op vfolder_setup_op = {
+ vfolder_setup_desc,
+ vfolder_setup_do,
+ vfolder_setup_done,
+ vfolder_setup_free,
+};
+
+/* sources_uri should be camel uri's */
+static int
+vfolder_setup(CamelFolder *folder, const char *query, GList *sources_uri, GList *sources_folder)
+{
+ struct _setup_msg *m;
+ int id;
+
+ m = mail_msg_new(&vfolder_setup_op, NULL, sizeof (*m));
+ m->folder = folder;
+ camel_object_ref(folder);
+ m->query = g_strdup(query);
+ m->sources_uri = sources_uri;
+ m->sources_folder = sources_folder;
+
+ id = m->msg.seq;
+ e_thread_put(mail_thread_queued_slow, (EMsg *)m);
+
+ return id;
+}
+
static void
emfb_search_search_activated(ESearchBar *esb, EMFolderBrowser *emfb)
{
EMFolderView *emfv = (EMFolderView *) emfb;
- char *search_word, *search_state;
-
+ EFilterBar *efb = (EFilterBar *)esb;
+ char *search_state, *view_sexp, *folder_uri;
+ char *word = NULL, *storeuri = NULL, *search_word = NULL;;
+ gint id, i;
+ CamelFolder *folder;
+ CamelStore *store;
+ GPtrArray *folders;
+ GList *folder_list_account = NULL ;
+ GList *l, *folder_list = NULL ;
+ CamelException *ex;
+
+ ex = camel_exception_new ();
+
if (emfv->list == NULL || emfv->folder == NULL)
return;
+ id = e_search_bar_get_search_scope (esb);
+
+ switch (id) {
+ case E_FILTERBAR_CURRENT_MESSAGE_ID:
+ word = e_search_bar_get_text (esb);
+ if ( word && *word ) {
+ gtk_widget_set_sensitive (esb->option_button, FALSE);
+ em_format_html_display_search_with (emfb->view.preview, word);
+ } else {
+ em_format_html_display_search_close (emfb->view.preview);
+ }
+ return;
+ break;
+
+ case E_FILTERBAR_CURRENT_FOLDER_ID:
+ g_object_get (esb, "query", &search_word, NULL);
+ break;
+
+ case E_FILTERBAR_CURRENT_ACCOUNT_ID:
+ word = e_search_bar_get_text (esb);
+ if (!(word && *word)) {
+ g_signal_emit (emfb, folder_browser_signals [ACCOUNT_SEARCH_CLEARED], 0);
+ gtk_widget_set_sensitive (esb->scopeoption, TRUE);
+ break;
+ }
+
+ gtk_widget_set_sensitive (esb->scopeoption, FALSE);
+
+ /* Disable the folder tree */
+ g_signal_emit (emfb, folder_browser_signals [ACCOUNT_SEARCH_ACTIVATED], 0);
+
+ store = emfv->folder->parent_store;
+ if (store->folders) {
+ folders = camel_object_bag_list(store->folders);
+ for (i=0;i<folders->len;i++) {
+ folder = folders->pdata[i];
+ folder_list_account = g_list_append(folder_list_account, folder);
+ }
+ }
+
+ /* Create a camel vee folder */
+ storeuri = g_strdup_printf("vfolder:%s/mail/vfolder", mail_component_peek_base_directory (mail_component_peek ()));
+ vfolder_store = camel_session_get_store (session, storeuri, NULL);
+ efb->account_search_vf = camel_vee_folder_new (vfolder_store,"Account Search",CAMEL_STORE_VEE_FOLDER_AUTO);
+
+ /* Set the search expression */
+ g_object_get (esb, "query", &search_word, NULL);
+
+ vfolder_setup (efb->account_search_vf, search_word, NULL, folder_list_account);
+
+ folder_uri = mail_tools_folder_to_url ((CamelFolder *)efb->account_search_vf);
+ emfb_set_search_folder (emfv, (CamelFolder *)efb->account_search_vf, folder_uri);
+
+/* g_list_free (folder_list_account); */
+/* g_free (folder_uri); */
+/* g_free (storeuri); */
+ break;
+
+ case E_FILTERBAR_ALL_ACCOUNTS_ID:
+ word = e_search_bar_get_text (esb);
+ if (!(word && *word)) {
+ g_signal_emit (emfb, folder_browser_signals [ACCOUNT_SEARCH_CLEARED], 0);
+ gtk_widget_set_sensitive (esb->scopeoption, TRUE);
+ break;
+ }
+
+ gtk_widget_set_sensitive (esb->scopeoption, FALSE);
+ g_signal_emit (emfb, folder_browser_signals [ACCOUNT_SEARCH_ACTIVATED], 0);
+
+ /* Create a camel vee folder */
+ storeuri = g_strdup_printf("vfolder:%s/mail/vfolder", mail_component_peek_base_directory (mail_component_peek ()));
+ vfolder_store = camel_session_get_store (session, storeuri, NULL);
+ efb->all_account_search_vf = camel_vee_folder_new (vfolder_store,"All Account Search",CAMEL_STORE_VEE_FOLDER_AUTO);
+
+ /* Set sexp */
+ g_object_get (esb, "query", &search_word, NULL);
+
+ /* FIXME: there got to be a better way :) */
+
+ /* Add the local folders */
+ l = mail_vfolder_get_sources_local ();
+ while (l) {
+ folder = mail_tool_uri_to_folder ((const char *)l->data, 0,ex);
+ if (folder)
+ folder_list = g_list_append(folder_list, folder);
+ else {
+ g_warning("Could not open vfolder source: %s", (char *)l->data);
+ camel_exception_clear(ex);
+ }
+ l = l->next;
+ }
+
+ /* Add the remote source folder */
+ l = mail_vfolder_get_sources_remote ();
+ while (l) {
+ folder = mail_tool_uri_to_folder ((const char *)l->data, 0,ex);
+ if (folder)
+ folder_list = g_list_append(folder_list, folder);
+ else {
+ g_warning("Could not open vfolder source: %s", (char *)l->data);
+ camel_exception_clear(ex);
+ }
+ l = l->next;
+ }
+
+ vfolder_setup (efb->all_account_search_vf, search_word, NULL, folder_list);
+
+ folder_uri = mail_tools_folder_to_url ((CamelFolder *)efb->all_account_search_vf);
+ emfb_set_search_folder (emfv, (CamelFolder *)efb->all_account_search_vf, folder_uri);
+
+ g_list_free (l);
+ break;
+ }
+
+ /* Merge the view and search expresion*/
+ view_sexp = get_view_query (esb);
g_object_get (esb, "query", &search_word, NULL);
+
+ if (search_word && *search_word)
+ search_word = g_strconcat ("(and ", view_sexp, search_word, " )", NULL);
+ else
+ search_word = g_strdup (view_sexp);
+
message_list_set_search(emfb->view.list, search_word);
- g_free (search_word);
-
+
+ /* Fixme */
g_object_get (esb, "state", &search_state, NULL);
camel_object_meta_set (emfv->folder, "evolution:search_state", search_state);
camel_object_state_write (emfv->folder);
- g_free (search_state);
+
+ camel_exception_free (ex);
}
static void
emfb_search_query_changed(ESearchBar *esb, EMFolderBrowser *emfb)
{
- int id;
+ int search_scope;
+ int item_id;
+
+ search_scope = e_search_bar_get_search_scope (esb);
+ item_id = e_search_bar_get_item_id (esb);
+
+ /* Close the current message search bar */
+ if ( search_scope != E_FILTERBAR_CURRENT_MESSAGE_ID ) {
+ em_format_html_display_search_close (emfb->view.preview);
+ gtk_widget_set_sensitive (esb->option_button, TRUE);
+ } else
+ gtk_widget_set_sensitive (esb->option_button, FALSE);
- id = e_search_bar_get_item_id(esb);
- if (id == E_FILTERBAR_ADVANCED_ID)
- emfb_search_search_activated(esb, emfb);
+ switch (item_id) {
+ case E_FILTERBAR_ADVANCED_ID:
+ emfb_search_search_activated(esb, emfb);
+ break;
+ }
}
/* ********************************************************************** */
@@ -581,12 +1111,12 @@ emfb_edit_cut(BonoboUIComponent *uid, void *data, const char *path)
/* TODO: pity we can't sucblass this method, ugh, virtualise it? */
- if (GTK_WIDGET_HAS_FOCUS(((ESearchBar *)emfb->search)->entry))
- gtk_editable_cut_clipboard((GtkEditable *)((ESearchBar *)emfb->search)->entry);
- else if (GTK_WIDGET_HAS_FOCUS(emfb->view.preview->formathtml.html))
- em_format_html_display_cut(emfb->view.preview);
- else
- message_list_copy(emfb->view.list, TRUE);
+/* if (GTK_HAS_FOCUS(((ESearchBar *)emfb->search)->entry)) */
+/* gtk_editable_cut_clipboard((GtkEditable *)((ESearchBar *)emfb->search)->entry); */
+/* else if (GTK_WIDGET_HAS_FOCUS(emfb->view.preview->formathtml.html)) */
+/* em_format_html_display_cut(emfb->view.preview); */
+/* else */
+/* message_list_copy(emfb->view.list, TRUE); */
}
static void
@@ -1143,6 +1673,42 @@ emfb_list_built (MessageList *ml, EMFolderBrowser *emfb)
}
static void
+emfb_set_search_folder(EMFolderView *emfv, CamelFolder *folder, const char *uri)
+{
+ EMFolderBrowser *emfb = (EMFolderBrowser *) emfv;
+
+ message_list_freeze(emfv->list);
+
+ if (emfb->priv->list_scrolled_id) {
+ g_signal_handler_disconnect (emfv->list, emfb->priv->list_scrolled_id);
+ emfb->priv->list_scrolled_id = 0;
+ }
+
+ if (emfb->priv->idle_scroll_id) {
+ g_source_remove (emfb->priv->idle_scroll_id);
+ emfb->priv->idle_scroll_id = 0;
+ }
+
+ if (emfb->view.folder) {
+ camel_object_remove_event(emfb->view.folder, emfb->priv->folder_changed_id);
+ emfb->priv->folder_changed_id = 0;
+ }
+
+ emfb_parent->set_folder(emfv, folder, uri);
+
+ /* etspec for search results */
+ char *state = "<ETableState>"
+ "<column source=\"0\"/> <column source=\"3\"/> <column source=\"1\"/>"
+ "<column source=\"14\"/> <column source=\"5\"/>"
+ "<column source=\"7\"/> <column source=\"13\"/> "
+ "<grouping> </grouping> </ETableState>";
+ e_tree_set_state (((MessageList *)emfv->list)->tree, state);
+
+ message_list_thaw(emfv->list);
+}
+
+
+static void
emfb_set_folder(EMFolderView *emfv, CamelFolder *folder, const char *uri)
{
EMFolderBrowser *emfb = (EMFolderBrowser *) emfv;
@@ -1207,9 +1773,10 @@ emfb_set_folder(EMFolderView *emfv, CamelFolder *folder, const char *uri)
bonobo_ui_component_set_prop(emfv->uic, "/commands/HideDeleted", "sensitive", state?"1":"0", NULL);
}
- sstate = camel_object_meta_get(folder, "evolution:search_state");
- g_object_set(emfb->search, "state", sstate, NULL);
- g_free(sstate);
+ /* Fixme */
+/* sstate = camel_object_meta_get(folder, "evolution:search_state"); */
+/* g_object_set(emfb->search, "state", sstate, NULL); */
+/* g_free(sstate); */
/* set the query manually, so we dont pop up advanced or saved search stuff */
g_object_get(emfb->search, "query", &sstate, NULL);
diff --git a/mail/em-folder-browser.h b/mail/em-folder-browser.h
index f31f78fd93..d09bf91cd3 100644
--- a/mail/em-folder-browser.h
+++ b/mail/em-folder-browser.h
@@ -44,6 +44,10 @@ struct _EMFolderBrowser {
struct _EMFolderBrowserClass {
EMFolderViewClass parent_class;
+
+ /* Signals*/
+ void (*account_search_activated) (EMFolderBrowser *emfb);
+ void (*account_search_cleared) (EMFolderBrowser *emfb);
};
GType em_folder_browser_get_type(void);
diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c
index 4c0c225393..c4479a1054 100644
--- a/mail/em-folder-view.c
+++ b/mail/em-folder-view.c
@@ -91,6 +91,7 @@
#include "em-folder-view.h"
#include "em-folder-browser.h"
#include "em-mailer-prefs.h"
+#include "em-folder-browser.h"
#include "em-message-browser.h"
#include "message-list.h"
#include "em-utils.h"
@@ -185,6 +186,7 @@ emfv_init(GObject *o)
EMFolderView *emfv = (EMFolderView *)o;
struct _EMFolderViewPrivate *p;
extern CamelSession *session;
+ GtkWidget *search_bar;
gtk_box_set_homogeneous (GTK_BOX (emfv), FALSE);
@@ -227,6 +229,9 @@ emfv_init(GObject *o)
gtk_selection_add_target(p->invisible, GDK_SELECTION_PRIMARY, GDK_SELECTION_TYPE_STRING, 0);
gtk_selection_add_target(p->invisible, GDK_SELECTION_CLIPBOARD, GDK_SELECTION_TYPE_STRING, 1);
+ search_bar = em_format_html_get_search_dialog (emfv->preview);
+ gtk_box_pack_end(GTK_WIDGET (emfv), search_bar, FALSE, FALSE, 5);
+
emfv->async = mail_async_event_new();
emfv_setting_setup(emfv);
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 5f9160787a..0708439ee8 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -105,6 +105,7 @@
#include "em-popup.h"
#include "e-attachment.h"
#include "e-attachment-bar.h"
+#include "e-icon-entry.h"
#ifdef G_OS_WIN32
/* Undefine the similar macro from <pthread.h>,it doesn't check if
@@ -123,8 +124,9 @@
struct _EMFormatHTMLDisplayPrivate {
/* For the interactive search dialogue */
/* TODO: Should this be more subtle, like the mozilla one? */
- GtkDialog *search_dialog;
+ GtkHBox *search_dialog;
GtkWidget *search_entry;
+ GtkWidget *search_entry_box;
GtkWidget *search_matches_label;
GtkWidget *search_case_check;
char *search_text;
@@ -527,37 +529,67 @@ efhd_update_search(EMFormatHTMLDisplay *efhd)
}
static void
-efhd_search_response(GtkWidget *w, int button, EMFormatHTMLDisplay *efhd)
+efhd_search_response(GtkWidget *w, EMFormatHTMLDisplay *efhd)
{
struct _EMFormatHTMLDisplayPrivate *p = efhd->priv;
- if (button == GTK_RESPONSE_ACCEPT) {
- char *txt = g_strdup(gtk_entry_get_text((GtkEntry *)p->search_entry));
+ char *txt = g_strdup(gtk_entry_get_text((GtkEntry *)p->search_entry));
- g_strstrip(txt);
- if (p->search_text && strcmp(p->search_text, txt) == 0 && !p->search_wrap) {
- if (!gtk_html_engine_search_next(((EMFormatHTML *)efhd)->html))
- p->search_wrap = TRUE;
- g_free(txt);
- } else {
- g_free(p->search_text);
- p->search_text = txt;
- if (!p->search_wrap)
- efhd_update_search(efhd);
- p->search_wrap = FALSE;
- gtk_html_engine_search(((EMFormatHTML *)efhd)->html, txt,
- gtk_toggle_button_get_active((GtkToggleButton *)p->search_case_check),
- TRUE, FALSE);
- }
+ g_strstrip(txt);
+ if (p->search_text && strcmp(p->search_text, txt) == 0 && !p->search_wrap) {
+ gtk_html_engine_search_set_forward (((EMFormatHTML *)efhd)->html, TRUE);
+ if (!gtk_html_engine_search_next(((EMFormatHTML *)efhd)->html))
+ p->search_wrap = TRUE;
+ g_free(txt);
+ } else {
+ g_free(p->search_text);
+ p->search_text = txt;
+ if (!p->search_wrap)
+ efhd_update_search(efhd);
+ p->search_wrap = FALSE;
+ gtk_html_engine_search(((EMFormatHTML *)efhd)->html, txt,
+ gtk_toggle_button_get_active((GtkToggleButton *)p->search_case_check),
+ TRUE, FALSE);
+ }
+}
+
+
+static void
+efhd_search_response_back (GtkWidget *w, EMFormatHTMLDisplay *efhd)
+{
+ struct _EMFormatHTMLDisplayPrivate *p = efhd->priv;
+
+ char *txt = g_strdup(gtk_entry_get_text((GtkEntry *)p->search_entry));
+
+ g_strstrip(txt);
+ if (p->search_text && strcmp(p->search_text, txt) == 0 && !p->search_wrap) {
+ gtk_html_engine_search_set_forward (((EMFormatHTML *)efhd)->html, FALSE);
+ if (!gtk_html_engine_search_next(((EMFormatHTML *)efhd)->html))
+ p->search_wrap = TRUE;
+ g_free(txt);
} else {
g_free(p->search_text);
- p->search_text = NULL;
- gtk_widget_destroy((GtkWidget *)p->search_dialog);
- p->search_dialog = NULL;
- em_format_html_display_set_search(efhd, EM_FORMAT_HTML_DISPLAY_SEARCH_PRIMARY, NULL);
+ p->search_text = txt;
+ if (!p->search_wrap)
+ efhd_update_search(efhd);
+ p->search_wrap = FALSE;
+ gtk_html_engine_search(((EMFormatHTML *)efhd)->html, txt,
+ gtk_toggle_button_get_active((GtkToggleButton *)p->search_case_check),
+ FALSE, FALSE);
}
}
+
+static void
+efhd_search_destroy(GtkWidget *w, EMFormatHTMLDisplay *efhd)
+{
+ struct _EMFormatHTMLDisplayPrivate *p = efhd->priv;
+ g_free(p->search_text);
+ p->search_text = NULL;
+ gtk_widget_hide((GtkWidget *)p->search_dialog);
+ em_format_html_display_set_search(efhd, EM_FORMAT_HTML_DISPLAY_SEARCH_PRIMARY, NULL);
+}
+
static void
efhd_search_case_toggled(GtkWidget *w, EMFormatHTMLDisplay *efhd)
{
@@ -565,13 +597,116 @@ efhd_search_case_toggled(GtkWidget *w, EMFormatHTMLDisplay *efhd)
g_free(p->search_text);
p->search_text = NULL;
- efhd_search_response(w, GTK_RESPONSE_ACCEPT, efhd);
+ efhd_search_response(w, efhd);
}
+static gboolean
+efhd_key_pressed (GtkWidget *w, GdkEventKey *event, EMFormatHTMLDisplay *efhd)
+{
+ if (event->keyval == GDK_Escape){
+ efhd_search_destroy (w, efhd);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static void
+clear_button_clicked_cb (GtkWidget *widget, gpointer dummy, EMFormatHTMLDisplay *efhd)
+{
+ struct _EMFormatHTMLDisplayPrivate *p = efhd->priv;
+
+ gtk_entry_set_text (p->search_entry, "");
+
+ gtk_signal_emit_by_name (p->search_entry, "activate", efhd);
+}
+
+/* Controlls the visibility of icon_entry's visibility */
static void
-efhd_search_entry_activate(GtkWidget *w, EMFormatHTMLDisplay *efhd)
+icon_entry_changed_cb (GtkWidget *widget, GtkWidget *clear_button)
{
- efhd_search_response(w, GTK_RESPONSE_ACCEPT, efhd);
+ const char *text = gtk_entry_get_text (widget);
+
+ if (text && *text)
+ gtk_widget_show (clear_button);
+ else
+ gtk_widget_hide (clear_button);
+}
+
+GtkWidget *
+em_format_html_get_search_dialog (EMFormatHTMLDisplay *efhd)
+{
+ struct _EMFormatHTMLDisplayPrivate *p = efhd->priv;
+ GtkWidget *hbox3, *hbox2, *button3, *button2, *button1, *label1, *alignment, *image1, *label2;
+ GtkWidget *icon_entry, *clear_button;
+
+ p->search_entry_box = gtk_hbox_new (FALSE, 0);
+
+ label1 = gtk_label_new (_("Find:"));
+ gtk_widget_show (label1);
+ gtk_box_pack_start ((GtkBox *)(p->search_entry_box), label1, FALSE, FALSE, 5);
+
+ /* Icon entry */
+ icon_entry = e_icon_entry_new ();
+ p->search_entry = e_icon_entry_get_entry (E_ICON_ENTRY (icon_entry));
+ gtk_widget_show (p->search_entry);
+ clear_button = e_icon_entry_create_button ("gtk-clear");
+ e_icon_entry_pack_widget (E_ICON_ENTRY (icon_entry), clear_button, FALSE);
+ gtk_widget_show_all (icon_entry);
+ gtk_widget_hide (clear_button);
+
+ g_signal_connect (G_OBJECT (clear_button), "button-press-event", clear_button_clicked_cb, efhd);
+ g_signal_connect (G_OBJECT (p->search_entry), "changed", icon_entry_changed_cb, clear_button);
+
+ gtk_box_pack_start ((GtkBox *)(p->search_entry_box), icon_entry, FALSE, FALSE, 0);
+// gtk_box_pack_start ((GtkBox *)(p->search_entry_box), icon_entry, TRUE, TRUE, 0);
+
+ hbox2 = gtk_hbox_new (FALSE, 0);
+ gtk_box_pack_start ((GtkBox *)(hbox2), p->search_entry_box, FALSE, FALSE, 5);
+// gtk_box_pack_start ((GtkBox *)(hbox2), p->search_entry_box, TRUE, TRUE, 5);
+
+ button3 = gtk_button_new_from_stock ("gtk-go-back");
+ gtk_widget_show (button3);
+ gtk_box_pack_start ((GtkBox *)(hbox2), button3, FALSE, FALSE, 5);
+
+ button2 = gtk_button_new_from_stock ("gtk-go-forward");
+ gtk_widget_show (button2);
+ gtk_box_pack_start ((GtkBox *)(hbox2), button2, FALSE, FALSE, 5);
+
+ p->search_case_check = gtk_check_button_new_with_mnemonic (_("Match case"));
+ gtk_widget_show (p->search_case_check);
+ gtk_box_pack_start ((GtkBox *)(hbox2), p->search_case_check, FALSE, FALSE, 0);
+
+ p->search_matches_label = gtk_label_new (_(""));
+ gtk_widget_show (p->search_matches_label);
+ gtk_box_pack_start ((GtkBox *)(hbox2), p->search_matches_label, TRUE, TRUE, 0);
+ p->search_dialog = (GtkWidget *)hbox2;
+
+ p->search_wrap = FALSE;
+
+ g_signal_connect (p->search_entry, "activate", G_CALLBACK(efhd_search_response), efhd);
+ g_signal_connect (p->search_entry, "key-press-event", G_CALLBACK(efhd_key_pressed), efhd);
+ g_signal_connect (p->search_case_check, "toggled", G_CALLBACK(efhd_search_case_toggled), efhd);
+ g_signal_connect (button2, "clicked", G_CALLBACK(efhd_search_response), efhd);
+ g_signal_connect (button3, "clicked", G_CALLBACK(efhd_search_response_back), efhd);
+
+ efhd_update_matches(efhd);
+
+ return (GtkWidget *)p->search_dialog;
+
+}
+
+static void
+set_focus_cb (GtkWidget *window, GtkWidget *widget, EMFormatHTMLDisplay *efhd)
+{
+ struct _EMFormatHTMLDisplayPrivate *p = efhd->priv;
+ GtkWidget *sbar = p->search_dialog;
+
+ while (widget != NULL && widget != sbar) {
+ widget = widget->parent;
+ }
+
+ if (widget != sbar)
+ efhd_search_destroy(widget, efhd);
}
/**
@@ -584,45 +719,52 @@ void
em_format_html_display_search(EMFormatHTMLDisplay *efhd)
{
struct _EMFormatHTMLDisplayPrivate *p = efhd->priv;
- GladeXML *xml;
- char *gladefile;
- if (p->search_dialog) {
- gdk_window_raise(((GtkWidget *)p->search_dialog)->window);
- return;
- }
+ if (p->search_dialog){
+ GtkWidget *toplevel;
+ gtk_widget_show ( (GtkWidget *)(p->search_dialog));
+ gtk_widget_grab_focus ( (GtkWidget *)(p->search_entry));
+ gtk_widget_show ( (GtkWidget *) p->search_entry_box);
- gladefile = g_build_filename (EVOLUTION_GLADEDIR,
- "mail-dialogs.glade",
- NULL);
- xml = glade_xml_new (gladefile, "search_message_dialog", NULL);
- g_free (gladefile);
+ toplevel = gtk_widget_get_toplevel ((GtkWidget *)(p->search_dialog));
- if (xml == NULL) {
- g_warning("Cannot open search dialog glade file");
- /* ?? */
- return;
+ g_signal_connect (toplevel, "set-focus",
+ G_CALLBACK (set_focus_cb), efhd);
}
- /* TODO: The original put the subject in the frame, but it had some
- ugly arbitrary string-cutting code to make sure it fit. */
+}
+/**
+ * em_format_html_display_search_with:
+ * @efhd:
+ *
+ * Run an interactive search dialogue.
+ **/
+void
+em_format_html_display_search_with (EMFormatHTMLDisplay *efhd, char *word)
+{
+ struct _EMFormatHTMLDisplayPrivate *p = efhd->priv;
+ char *str;
- p->search_dialog = (GtkDialog *)glade_xml_get_widget(xml, "search_message_dialog");
- p->search_entry = glade_xml_get_widget(xml, "search_entry");
- p->search_matches_label = glade_xml_get_widget(xml, "search_matches_label");
- p->search_case_check = glade_xml_get_widget(xml, "search_case_check");
- p->search_wrap = FALSE;
+ if (p->search_dialog){
+ GtkWidget *toplevel;
+ gtk_widget_show ( (GtkWidget *)(p->search_dialog));
+
+ /* Set the query */
+ gtk_entry_set_text ( (GtkWidget *) p->search_entry, word);
+ gtk_widget_hide ( (GtkWidget *) p->search_entry_box);
- gtk_dialog_set_default_response((GtkDialog *)p->search_dialog, GTK_RESPONSE_ACCEPT);
- e_dialog_set_transient_for ((GtkWindow *) p->search_dialog, (GtkWidget *) ((EMFormatHTML *) efhd)->html);
- gtk_window_set_destroy_with_parent ((GtkWindow *) p->search_dialog, TRUE);
- efhd_update_matches(efhd);
+ /* Trigger the search */
+ gtk_signal_emit_by_name (p->search_entry, "activate", efhd);
+ }
+}
+
+void
+em_format_html_display_search_close (EMFormatHTMLDisplay *efhd)
+{
+ struct _EMFormatHTMLDisplayPrivate *p = efhd->priv;
- g_signal_connect(p->search_entry, "activate", G_CALLBACK(efhd_search_entry_activate), efhd);
- g_signal_connect(p->search_case_check, "toggled", G_CALLBACK(efhd_search_case_toggled), efhd);
- g_signal_connect(p->search_dialog, "response", G_CALLBACK(efhd_search_response), efhd);
- gtk_widget_show((GtkWidget *)p->search_dialog);
- gtk_widget_hide((GtkWidget *)p->search_matches_label);
+ if (p->search_dialog)
+ efhd_search_destroy(p->search_dialog, efhd);
}
void
diff --git a/mail/em-format-html-display.h b/mail/em-format-html-display.h
index c1aa050c70..be84decc11 100644
--- a/mail/em-format-html-display.h
+++ b/mail/em-format-html-display.h
@@ -51,6 +51,10 @@ void em_format_html_display_set_caret_mode(EMFormatHTMLDisplay *efhd, gboolean s
void em_format_html_display_set_search(EMFormatHTMLDisplay *efhd, int type, GSList *strings);
void em_format_html_display_search(EMFormatHTMLDisplay *efhd);
+void em_format_html_display_search_with (EMFormatHTMLDisplay *efhd, char *word);
+void em_format_html_display_search_close (EMFormatHTMLDisplay *efhd);
+
+GtkWidget *em_format_html_get_search_dialog (EMFormatHTMLDisplay *efhd);
void em_format_html_display_cut (EMFormatHTMLDisplay *efhd);
void em_format_html_display_copy (EMFormatHTMLDisplay *efhd);
diff --git a/mail/mail-component.c b/mail/mail-component.c
index 43e469b78b..1318db581f 100644
--- a/mail/mail-component.c
+++ b/mail/mail-component.c
@@ -618,6 +618,43 @@ view_changed_cb(EMFolderView *emfv, EComponentView *component_view)
g_object_set_data((GObject *)emfv, "view-changed-timeout", GINT_TO_POINTER(g_timeout_add(250, view_changed_timeout, component_view)));
}
+static void
+disable_folder_tree (gpointer *emfb, gpointer dummy, GtkWidget *widget)
+{
+ gtk_widget_set_sensitive (widget, FALSE);
+}
+
+static void
+enable_folder_tree (GtkWidget *emfb, gpointer dum, GtkWidget *emft)
+{
+ char *uri;
+ CamelURL *selected_curl, *current_curl;
+ CamelFolder *folder;
+ CamelException ex;
+ EMFolderView *emfv = (EMFolderView *)emfb;
+
+ /* Currently displayed folder */
+ MessageList *ml = emfv->list;
+ folder = ml->folder;
+ uri = mail_tools_folder_to_url (folder);
+ current_curl = camel_url_new (uri, NULL);
+
+ /* Selected folder in emft*/
+ uri = em_folder_tree_get_selected_uri ((EMFolderTree *) emft);
+ folder = mail_tool_uri_to_folder (uri, 0, &ex);
+ selected_curl = camel_url_new (uri, NULL);
+
+ if (!camel_url_equal (selected_curl, current_curl))
+ g_signal_emit_by_name (emft, "folder-selected", emft, uri, folder->full_name, uri, folder->folder_flags);
+
+ gtk_widget_set_sensitive (emft, TRUE);
+
+ camel_url_free (current_curl);
+ camel_url_free (selected_curl);
+ g_free (uri);
+
+}
+
/* Evolution::Component CORBA methods. */
static GNOME_Evolution_ComponentView
@@ -676,9 +713,12 @@ impl_createView (PortableServer_Servant servant,
e_user_creatable_items_handler_new("mail", create_local_item_cb, tree_widget),
(GDestroyNotify)g_object_unref);
+
g_signal_connect (component_view->view_control, "activate", G_CALLBACK (view_control_activate_cb), view_widget);
g_signal_connect (tree_widget, "folder-selected", G_CALLBACK (folder_selected_cb), view_widget);
+ g_signal_connect((EMFolderBrowser *)view_widget, "account_search_cleared", G_CALLBACK (enable_folder_tree), tree_widget);
+ g_signal_connect(((EMFolderBrowser *)view_widget), "account_search_activated", G_CALLBACK (disable_folder_tree), tree_widget);
g_signal_connect(view_widget, "changed", G_CALLBACK(view_changed_cb), component_view);
g_signal_connect(view_widget, "loaded", G_CALLBACK(view_changed_cb), component_view);
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 66b29de918..727ed89866 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -49,7 +49,7 @@
#include "mail-tools.h"
#include "mail-vfolder.h"
-#define d(x) /*(printf("%s(%d):%s: ", __FILE__, __LINE__, __PRETTY_FUNCTION__), (x))*/
+#define d(x) /* (printf("%s(%d):%s: ", __FILE__, __LINE__, __PRETTY_FUNCTION__), (x))*/
static EMVFolderContext *context; /* context remains open all time */
CamelStore *vfolder_store; /* the 1 static vfolder store */
@@ -453,8 +453,8 @@ mail_vfolder_add_uri(CamelStore *store, const char *curi, int remove)
LOCK();
- d(printf("%s uri to check: %s\n", remove?"Removing":"Adding", uri));
-
+/* d(printf("%s uri to check: %s\n", remove?"Removing":"Adding", uri)); */
+
/* maintain the source folders lists for changed rules later on */
if (CAMEL_IS_VEE_STORE(store)) {
is_ignore = TRUE;
@@ -489,7 +489,6 @@ mail_vfolder_add_uri(CamelStore *store, const char *curi, int remove)
d(printf("invalid rule (%p): rule->name is set to NULL\n", rule));
continue;
}
-
/* dont auto-add any sent/drafts folders etc, they must be explictly listed as a source */
if (rule->source
&& !is_ignore
@@ -501,7 +500,6 @@ mail_vfolder_add_uri(CamelStore *store, const char *curi, int remove)
source = NULL;
while (!found && (source = em_vfolder_rule_next_source((EMVFolderRule *)rule, source))) {
char *csource;
-
csource = em_uri_to_camel(source);
found = camel_store_folder_uri_equal(store, curi, csource);
d(printf(found?" '%s' == '%s'?\n":" '%s' != '%s'\n", curi, csource));
@@ -664,6 +662,18 @@ mail_vfolder_rename_uri(CamelStore *store, const char *cfrom, const char *cto)
g_free(to);
}
+GList *
+mail_vfolder_get_sources_local ()
+{
+ return source_folders_local;
+}
+
+GList *
+mail_vfolder_get_sources_remote ()
+{
+ return source_folders_remote;
+}
+
/* ********************************************************************** */
static void context_rule_added(RuleContext *ctx, FilterRule *rule);
@@ -834,80 +844,43 @@ store_folder_deleted(CamelObject *o, void *event_data, void *data)
UNLOCK();
}
-static int
-store_folder_renamed_rec(char *prefix, int ignore, CamelFolderInfo *new)
-{
- int changed = 0;
- FilterRule *rule;
- char *key;
- GString *old = g_string_new(prefix);
- CamelFolder *folder;
-
- while (new) {
- if (new->child)
- changed |= store_folder_renamed_rec(prefix, ignore, new->child);
-
- g_string_truncate(old, strlen(prefix));
- g_string_append(old, new->full_name+ignore);
-
- d(printf("Changing folder name in hash table to '%s'\n", new->full_name));
- if (g_hash_table_lookup_extended(vfolder_hash, old->str, (void **)&key, (void **)&folder)) {
- g_hash_table_remove(vfolder_hash, key);
- g_hash_table_insert(vfolder_hash, g_strdup(new->full_name), folder);
-
- rule = rule_context_find_rule((RuleContext *)context, key, NULL);
- g_free(key);
- g_assert(rule);
- g_signal_handlers_disconnect_matched(rule, G_SIGNAL_MATCH_FUNC|G_SIGNAL_MATCH_DATA, 0,
- 0, NULL, rule_changed, folder);
- filter_rule_set_name(rule, new->full_name);
- g_signal_connect(rule, "changed", G_CALLBACK(rule_changed), folder);
- changed = 1;
- } else {
- g_warning("couldn't find a vfolder rule in our table? %s", new->full_name);
- }
- new = new->next;
- }
-
- g_string_free(old, TRUE);
- return changed;
-}
-
static void
store_folder_renamed(CamelObject *o, void *event_data, void *data)
{
CamelRenameInfo *info = event_data;
- char *end, *prefix;
- int ignore;
-
+ FilterRule *rule;
+ char *user;
+ char *key;
+ CamelFolder *folder;
+
/* This should be more-or-less thread-safe */
d(printf("Folder renamed to '%s' from '%s'\n", info->new->full_name, info->old_base));
/* Folder is already renamed? */
LOCK();
- end = strrchr(info->new->full_name, '/');
- if (end == NULL) {
- ignore = 0;
- end = strrchr(info->old_base, '/');
- if (end) {
- prefix = g_alloca(end-info->old_base+2);
- memcpy(prefix, info->old_base, end-info->old_base+1);
- prefix[end-info->old_base+1] = 0;
- } else
- prefix = "";
- } else {
- ignore = end-info->new->full_name+1;
- prefix = "";
- }
- if (store_folder_renamed_rec(prefix, ignore, info->new)) {
- char *user;
+ d(printf("Changing folder name in hash table to '%s'\n", info->new->full_name));
+ if (g_hash_table_lookup_extended(vfolder_hash, info->old_base, (void **)&key, (void **)&folder)) {
+ g_hash_table_remove(vfolder_hash, key);
+ g_free(key);
+ g_hash_table_insert(vfolder_hash, g_strdup(info->new->full_name), folder);
+
+ rule = rule_context_find_rule((RuleContext *)context, info->old_base, NULL);
+ g_assert(rule);
+ g_signal_handlers_disconnect_matched(rule, G_SIGNAL_MATCH_FUNC|G_SIGNAL_MATCH_DATA, 0,
+ 0, NULL, rule_changed, folder);
+ filter_rule_set_name(rule, info->new->full_name);
+ g_signal_connect(rule, "changed", G_CALLBACK(rule_changed), folder);
user = g_strdup_printf("%s/mail/vfolders.xml", mail_component_peek_base_directory (mail_component_peek ()));
rule_context_save((RuleContext *)context, user);
g_free(user);
+
+ UNLOCK();
+ } else {
+ UNLOCK();
+ g_warning("couldn't find a vfolder rule in our table? %s", info->new->full_name);
}
- UNLOCK();
}
void
diff --git a/mail/message-list.c b/mail/message-list.c
index cea727d562..865610abfd 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -93,7 +93,7 @@
#define localtime_r(tp,tmp) (localtime(tp)?(*(tmp)=*localtime(tp),(tmp)):0)
#endif
-#define d(x)
+#define d(x)
#define t(x)
struct _MLSelection {
@@ -1209,9 +1209,13 @@ ml_tree_value_at (ETreeModel *etm, ETreePath path, int col, void *model_data)
{
MessageList *message_list = model_data;
CamelMessageInfo *msg_info;
+ CamelException ex;
+
const char *str;
guint32 flags;
+ camel_exception_init (&ex);
+
if (e_tree_model_node_is_root (etm, path))
return NULL;
@@ -1342,8 +1346,11 @@ ml_tree_value_at (ETreeModel *etm, ETreePath path, int col, void *model_data)
return (void *) colour;
}
case COL_LOCATION: {
+ /* Fixme : freeing memory stuff (mem leaks) */
CamelFolder *folder;
- char *name;
+ CamelURL *curl;
+ EAccount *account;
+ char *location, *euri, *url;
if (CAMEL_IS_VEE_FOLDER(message_list->folder)) {
folder = camel_vee_folder_get_location((CamelVeeFolder *)message_list->folder, (CamelVeeMessageInfo *)msg_info, NULL);
@@ -1351,8 +1358,27 @@ ml_tree_value_at (ETreeModel *etm, ETreePath path, int col, void *model_data)
folder = message_list->folder;
}
- camel_object_get(folder, NULL, CAMEL_OBJECT_DESCRIPTION, &name, 0);
- return name;
+ url = mail_tools_folder_to_url (folder);
+ euri = em_uri_from_camel(url);
+
+ account = mail_config_get_account_by_source_url (url);
+
+ if (account) {
+ curl = camel_url_new (url, &ex);
+ location = g_strconcat (account->name, ":", curl->path, NULL);
+ } else {
+ /* Local account */
+ euri = em_uri_from_camel(url);
+ curl = camel_url_new (euri, &ex);
+ if (curl->host && !strcmp(curl->host, "local") && curl->user && !strcmp(curl->user, "local"))
+ location = g_strconcat ("On This Computer", ":",curl->path, NULL);
+ }
+
+ camel_exception_clear (&ex);
+ g_free (url);
+ g_free (euri);
+
+ return location;
}
case COL_MIXED_RECIPIENTS:
case COL_RECIPIENTS:{
@@ -1673,7 +1699,7 @@ message_list_setup_etree (MessageList *message_list, gboolean outgoing)
path = mail_config_folder_to_cachename (message_list->folder, "et-expanded-");
g_object_set_data (((GnomeCanvasItem *) item)->canvas, "freeze-cursor", 1);
-
+
if (path && g_stat (path, &st) == 0 && st.st_size > 0 && S_ISREG (st.st_mode)) {
/* build based on saved file */
e_tree_load_expanded_state (message_list->tree, path);
diff --git a/mail/message-list.etspec b/mail/message-list.etspec
index 9911ad4fba..3887e2723a 100644
--- a/mail/message-list.etspec
+++ b/mail/message-list.etspec
@@ -25,7 +25,7 @@
<ETableColumn model_col="12" _title="Due By" expansion="0.2" minimum_width="32" resizable="true" cell="render_date" compare="integer"/>
- <ETableColumn model_col="13" _title="Original Location" expansion="0.2" minimum_width="32" resizable="true" cell="render_text" compare="string"/>
+ <ETableColumn model_col="13" _title="Location" expansion="0.2" minimum_width="32" resizable="true" cell="render_text" compare="string"/>
<ETableColumn model_col="14" _title="Sender" expansion="1.0" minimum_width="32" resizable="true" cell="render_text" compare="address_compare" search="string" priority="10"/>
<ETableColumn model_col="15" _title="Recipients" expansion="1.0" minimum_width="32" resizable="true" cell="render_text" compare="address_compare" search="string" priority="10"/>
diff --git a/widgets/ChangeLog b/widgets/ChangeLog
index 952c71177d..3cb3ceb474 100644
--- a/widgets/ChangeLog
+++ b/widgets/ChangeLog
@@ -1,3 +1,37 @@
+2006-06-30 Johnny Jacob <jjohnny@novell.com>
+ * misc/Makefile.am: Added e-icon-entry.c, e-icon-entry.h
+ * misc/e-filter-bar.c: (rule_advanced_response),
+ (save_search_dialog), (menubar_activated), (option_changed),
+ (dup_item_no_subitems), (build_items), (free_built_items),
+ (free_items), (set_menu), (get_property), (e_filter_bar_new):
+ * misc/e-filter-bar.h:
+ * misc/e-search-bar.c: (set_find_now_sensitive),
+ (clear_search), (emit_search_activated), (search_now_verb_cb),
+ (clear_verb_cb), (setup_standard_verbs), (search_verb_cb),
+ (get_selected_item_label), (entry_focus_in_cb),
+ (entry_focus_out_cb), (entry_activated_cb), (entry_changed_cb),
+ (viewitem_activated_cb), (scopeitem_activated_cb),
+ (option_activated_cb), (option_button_clicked_cb),
+ (clear_button_clicked_cb), (scopeoption_changed_cb), (set_menu),
+ (set_option), (impl_get_property), (impl_set_property),
+ (impl_dispose), (class_init), (init), (e_search_bar_construct),
+ (e_search_bar_set_viewoption_menufunc),
+ (e_search_bar_set_viewoption_menu),
+ (e_search_bar_get_selected_viewitem),
+ (e_search_bar_set_viewoption), (e_search_bar_set_scopeoption),
+ (e_search_bar_set_scopeoption_menu),
+ (e_search_bar_set_viewitem_id), (e_search_bar_set_item_id),
+ (e_search_bar_set_search_scope), (e_search_bar_get_item_id),
+ (e_search_bar_get_search_scope), (e_search_bar_get_viewitem_id),
+ (e_search_bar_set_ids), (e_search_bar_set_text),
+ (e_search_bar_get_text):
+ * misc/e-search-bar.h:
+ * table/e-tree-table-adapter.c:
+ (e_tree_table_adapter_save_expanded_state): Added code for search
+ ui.
+ * misc/e-icon-entry.c : Added.
+ * misc/e-icon-entry.h : Added.
+
2006-06-20 Harish Krishnaswamy <kharish@novell.com>
* e-timezone-dialog/e-timezone-dialog.c
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index 3cc799964f..559f426a28 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -50,6 +50,7 @@ widgetsinclude_HEADERS = \
e-dateedit.h \
e-dropdown-button.h \
e-expander.h \
+ e-icon-entry.h \
e-image-chooser.h \
e-info-label.h \
e-map.h \
@@ -97,6 +98,7 @@ libemiscwidgets_la_SOURCES = \
e-dateedit.c \
e-dropdown-button.c \
e-expander.c \
+ e-icon-entry.c \
e-image-chooser.c \
e-info-label.c \
e-map.c \
diff --git a/widgets/misc/e-filter-bar.c b/widgets/misc/e-filter-bar.c
index 75d1b0d9e3..a67554b29a 100644
--- a/widgets/misc/e-filter-bar.c
+++ b/widgets/misc/e-filter-bar.c
@@ -125,6 +125,7 @@ rule_advanced_response (GtkWidget *dialog, int response, void *data)
gtk_widget_modify_base (esb->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED]));
+ gtk_widget_show (esb->clear_button);
if (response == GTK_RESPONSE_APPLY) {
if (!rule_context_find_rule (efb->context, rule->name, rule->source))
@@ -189,13 +190,57 @@ do_advanced (ESearchBar *esb)
}
static void
+save_search_dialog (ESearchBar *esb)
+{
+ FilterRule *rule;
+ char *name, *text;
+ GtkWidget *dialog, *w;
+
+ EFilterBar *efb = (EFilterBar *)esb;
+
+ rule = filter_rule_clone (efb->current_query);
+ text = e_search_bar_get_text (esb);
+ name = g_strdup_printf ("%s %s", rule->name, text && text[0] ? text : "''");
+ filter_rule_set_name (rule, name);
+ g_free (text);
+ g_free (name);
+
+ w = filter_rule_get_widget (rule, efb->context);
+ filter_rule_set_source (rule, FILTER_SOURCE_INCOMING);
+ gtk_container_set_border_width (GTK_CONTAINER (w), 12);
+
+ /* FIXME: get the toplevel window... */
+ dialog = gtk_dialog_new_with_buttons (_("Save Search"), NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+ efb->save_dialog = dialog;
+ gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 0);
+ gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 12);
+
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 300);
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), w, TRUE, TRUE, 0);
+
+ g_object_ref (rule);
+ g_object_set_data_full ((GObject *) dialog, "rule", rule, (GDestroyNotify) g_object_unref);
+ g_signal_connect (dialog, "response", G_CALLBACK (rule_editor_response), efb);
+ g_object_weak_ref ((GObject *) dialog, (GWeakNotify) rule_editor_destroyed, efb);
+
+ e_search_bar_set_menu_sensitive (esb, E_FILTERBAR_SAVE_ID, FALSE);
+ gtk_widget_set_sensitive (esb->entry, FALSE);
+
+ gtk_widget_show (dialog);
+}
+
+static void
menubar_activated (ESearchBar *esb, int id, void *data)
{
EFilterBar *efb = (EFilterBar *)esb;
GtkWidget *dialog, *w;
d(printf ("menubar activated!\n"));
-
+
switch (id) {
case E_FILTERBAR_EDIT_ID:
if (!efb->save_dialog) {
@@ -208,44 +253,8 @@ menubar_activated (ESearchBar *esb, int id, void *data)
}
break;
case E_FILTERBAR_SAVE_ID:
- if (efb->current_query && !efb->save_dialog) {
- FilterRule *rule;
- char *name, *text;
-
- rule = filter_rule_clone (efb->current_query);
- text = e_search_bar_get_text (esb);
- name = g_strdup_printf ("%s %s", rule->name, text && text[0] ? text : "''");
- filter_rule_set_name (rule, name);
- g_free (text);
- g_free (name);
-
- w = filter_rule_get_widget (rule, efb->context);
- filter_rule_set_source (rule, FILTER_SOURCE_INCOMING);
- gtk_container_set_border_width (GTK_CONTAINER (w), 12);
-
- /* FIXME: get the toplevel window... */
- dialog = gtk_dialog_new_with_buttons (_("Save Search"), NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
- efb->save_dialog = dialog;
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 0);
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 12);
-
- gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 300);
-
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), w, TRUE, TRUE, 0);
-
- g_object_ref (rule);
- g_object_set_data_full ((GObject *) dialog, "rule", rule, (GDestroyNotify) g_object_unref);
- g_signal_connect (dialog, "response", G_CALLBACK (rule_editor_response), efb);
- g_object_weak_ref ((GObject *) dialog, (GWeakNotify) rule_editor_destroyed, efb);
-
- e_search_bar_set_menu_sensitive (esb, E_FILTERBAR_SAVE_ID, FALSE);
- gtk_widget_set_sensitive (esb->entry, FALSE);
-
- gtk_widget_show (dialog);
- }
+ if (efb->current_query && !efb->save_dialog)
+ save_search_dialog (esb);
d(printf("Save menu\n"));
break;
@@ -289,8 +298,12 @@ option_changed (ESearchBar *esb, void *data)
if (efb->setquery)
return;
-
+
switch (id) {
+ case E_FILTERBAR_SAVE_ID:
+ /* Fixme */
+ /* save_search_dialog (esb); */
+ break;
case E_FILTERBAR_ADVANCED_ID:
d(printf ("do_advanced\n"));
do_advanced (esb);
@@ -299,7 +312,7 @@ option_changed (ESearchBar *esb, void *data)
if (id >= efb->option_base && id < efb->option_base + efb->option_rules->len) {
efb->current_query = (FilterRule *)efb->option_rules->pdata[id - efb->option_base];
if (efb->config && efb->current_query) {
- g_object_get (G_OBJECT (esb), "text", &query, NULL);
+ query = e_search_bar_get_text (esb);
efb->config (efb, efb->current_query, id, query, efb->config_data);
g_free (query);
}
@@ -318,11 +331,9 @@ static void
dup_item_no_subitems (ESearchBarItem *dest,
const ESearchBarItem *src)
{
- g_assert (src->subitems == NULL);
-
dest->id = src->id;
dest->text = g_strdup (src->text);
- dest->subitems = NULL;
+ dest->type = src->type;
}
static GArray *
@@ -356,7 +367,7 @@ build_items (ESearchBar *esb, ESearchBarItem *items, int type, int *start, GPtrA
}
*start = id;
-
+
if (type == 0) {
source = FILTER_SOURCE_INCOMING;
@@ -364,7 +375,7 @@ build_items (ESearchBar *esb, ESearchBarItem *items, int type, int *start, GPtrA
if (rule_context_next_rule (efb->context, rule, source) != NULL) {
item.id = 0;
item.text = NULL;
- item.subitems = NULL;
+ item.type = 0;
g_array_append_vals (menu, &item, 1);
}
} else {
@@ -381,8 +392,6 @@ build_items (ESearchBar *esb, ESearchBarItem *items, int type, int *start, GPtrA
} else {
item.text = g_strdup (rule->name);
}
-
- item.subitems = NULL;
g_array_append_vals (menu, &item, 1);
if (g_slist_find(gtksux, rule) == NULL) {
@@ -410,17 +419,19 @@ build_items (ESearchBar *esb, ESearchBarItem *items, int type, int *start, GPtrA
/* always add on the advanced menu */
if (type == 1) {
- ESearchBarItem sb_items[2] = { E_FILTERBAR_SEPARATOR, E_FILTERBAR_ADVANCED };
+ ESearchBarItem sb_items[2] = { E_FILTERBAR_SEPARATOR, E_FILTERBAR_ADVANCED,
+ /* E_FILTERBAR_SEPARATOR, E_FILTERBAR_SAVE */ };
ESearchBarItem dup_items[2];
dup_item_no_subitems (&dup_items[0], &sb_items[0]);
dup_item_no_subitems (&dup_items[1], &sb_items[1]);
+ /* dup_item_no_subitems (&dup_items[2], &sb_items[2]); */
+ /* dup_item_no_subitems (&dup_items[3], &sb_items[3]); */
g_array_append_vals (menu, &dup_items, 2);
}
item.id = -1;
item.text = NULL;
- item.subitems = NULL;
g_array_append_vals (menu, &item, 1);
return menu;
@@ -436,8 +447,6 @@ free_built_items (GArray *menu)
item = & g_array_index (menu, ESearchBarItem, i);
g_free (item->text);
-
- g_assert (item->subitems == NULL);
}
g_array_free (menu, TRUE);
@@ -454,39 +463,14 @@ generate_menu (ESearchBar *esb, ESearchBarItem *items)
free_built_items (menu);
}
-static ESearchBarSubitem *
-copy_subitems (ESearchBarSubitem *subitems)
-{
- ESearchBarSubitem *items;
- int i, num;
-
- for (num = 0; subitems[num].id != -1; num++)
- ;
-
- items = g_new (ESearchBarSubitem, num + 1);
- for (i = 0; i < num + 1; i++) {
- items[i].text = g_strdup (subitems[i].text);
- items[i].id = subitems[i].id;
- items[i].translate = subitems[i].translate;
- }
-
- return items;
-}
-
static void
free_items (ESearchBarItem *items)
{
int i, j;
- for (i = 0; items[i].id != -1; i++) {
+ for (i = 0; items[i].id != -1; i++)
g_free (items[i].text);
- if (items[i].subitems) {
- for (j = 0; items[i].subitems[j].id != -1; j++)
- g_free (items[i].subitems[j].text);
-
- g_free (items[i].subitems);
- }
- }
+
g_free (items);
}
@@ -509,10 +493,7 @@ set_menu (ESearchBar *esb, ESearchBarItem *items)
for (i = 0; i < num + 1; i++) {
default_items[i].text = g_strdup (items[i].text);
default_items[i].id = items[i].id;
- if (items[i].subitems)
- default_items[i].subitems = copy_subitems (items[i].subitems);
- else
- default_items[i].subitems = NULL;
+ default_items[i].type = items[i].type;
}
efb->default_items = default_items;
@@ -586,7 +567,7 @@ get_property (GObject *object, guint property_id, GValue *value, GParamSpec *psp
case PROP_STATE: {
/* FIXME: we should have ESearchBar save its own state to the xmlDocPtr */
char *xmlbuf, *text, buf[12];
- int subitem_id, item_id, n;
+ int searchscope, item_id, n;
xmlNodePtr root, node;
xmlDocPtr doc;
@@ -603,14 +584,14 @@ get_property (GObject *object, guint property_id, GValue *value, GParamSpec *psp
} else {
/* simple query, save the searchbar state */
text = e_search_bar_get_text ((ESearchBar *) efb);
- subitem_id = e_search_bar_get_subitem_id ((ESearchBar *) efb);
+ searchscope = e_search_bar_get_search_scope ((ESearchBar *) efb);
node = xmlNewChild (root, NULL, "search-bar", NULL);
xmlSetProp (node, "text", text ? text : "");
sprintf (buf, "%d", item_id);
xmlSetProp (node, "item_id", buf);
- sprintf (buf, "%d", subitem_id);
- xmlSetProp (node, "subitem_id", buf);
+ sprintf (buf, "%d", searchscope);
+ xmlSetProp (node, "searchscope", buf);
g_free (text);
}
@@ -889,6 +870,9 @@ e_filter_bar_new (RuleContext *context,
bar->systemrules = g_strdup (systemrules);
bar->userrules = g_strdup (userrules);
+ bar->all_account_search_vf = NULL;
+ bar->account_search_vf = NULL;
+
e_search_bar_construct ((ESearchBar *)bar, &item, &item);
g_signal_connect (context, "changed", G_CALLBACK (context_changed), bar);
diff --git a/widgets/misc/e-filter-bar.h b/widgets/misc/e-filter-bar.h
index 4b85a36d79..2b1ff53416 100644
--- a/widgets/misc/e-filter-bar.h
+++ b/widgets/misc/e-filter-bar.h
@@ -21,6 +21,7 @@
#define __E_FILTER_BAR_H__
#include <gtk/gtk.h>
+#include <camel/camel-vee-folder.h>
#include "e-search-bar.h"
@@ -55,14 +56,13 @@ typedef void (*EFilterBarConfigRule)(EFilterBar *, FilterRule *rule, int id, con
struct _EFilterBar {
ESearchBar parent;
-
int menu_base, option_base;
GPtrArray *menu_rules, *option_rules;
ESearchBarItem *default_items;
GtkWidget *save_dialog; /* current save dialogue (so we dont pop up multiple ones) */
-
+
FilterRule *current_query; /* as it says */
int setquery; /* true when we're setting a query directly to advanced, so dont popup the dialog */
@@ -72,6 +72,10 @@ struct _EFilterBar {
EFilterBarConfigRule config;
void *config_data;
+
+ CamelVeeFolder *all_account_search_vf;
+ CamelVeeFolder *account_search_vf;
+
};
struct _EFilterBarClass
@@ -87,12 +91,20 @@ enum {
/* preset option options */
E_FILTERBAR_ADVANCED_ID = -5,
+ E_FILTERBAR_CURRENT_MESSAGE_ID = -6,
+ E_FILTERBAR_CURRENT_FOLDER_ID = -7,
+ E_FILTERBAR_CURRENT_ACCOUNT_ID = -8,
+ E_FILTERBAR_ALL_ACCOUNTS_ID = -9,
};
-#define E_FILTERBAR_SAVE { N_("_Save Search..."), E_FILTERBAR_SAVE_ID, NULL }
-#define E_FILTERBAR_EDIT { N_("_Edit Saved Searches..."), E_FILTERBAR_EDIT_ID, NULL }
-#define E_FILTERBAR_ADVANCED { N_("_Advanced Search..."), E_FILTERBAR_ADVANCED_ID, NULL }
-#define E_FILTERBAR_SEPARATOR { NULL, 0, NULL }
+#define E_FILTERBAR_SAVE { N_("_Save Search..."), E_FILTERBAR_SAVE_ID, 0 }
+#define E_FILTERBAR_EDIT { N_("_Edit Saved Searches..."), E_FILTERBAR_EDIT_ID, 0 }
+#define E_FILTERBAR_ADVANCED { N_("_Advanced Search..."), E_FILTERBAR_ADVANCED_ID, 0 }
+#define E_FILTERBAR_ALL_ACCOUNTS { N_("All Accounts"), E_FILTERBAR_ALL_ACCOUNTS_ID, ESB_ITEMTYPE_RADIO }
+#define E_FILTERBAR_CURRENT_ACCOUNT { N_("Current Account"), E_FILTERBAR_CURRENT_ACCOUNT_ID, ESB_ITEMTYPE_RADIO }
+#define E_FILTERBAR_CURRENT_FOLDER { N_("Current Folder"), E_FILTERBAR_CURRENT_FOLDER_ID, ESB_ITEMTYPE_RADIO }
+#define E_FILTERBAR_CURRENT_MESSAGE { N_("Current Message"), E_FILTERBAR_CURRENT_MESSAGE_ID, ESB_ITEMTYPE_RADIO }
+#define E_FILTERBAR_SEPARATOR { NULL, 0, NULL, 0 }
#ifdef JUST_FOR_TRANSLATORS
const char * strings[] = {
diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c
index f0895dbdbb..f0b77efd5c 100644
--- a/widgets/misc/e-search-bar.c
+++ b/widgets/misc/e-search-bar.c
@@ -8,7 +8,6 @@
* Chris Lahey <clahey@ximian.com>
* Ettore Perazzoli <ettore@ximian.com>
* Jon Trowbridge <trow@ximian.com>
-
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
@@ -34,6 +33,8 @@
#include <gtk/gtkeventbox.h>
#include <gtk/gtkmenuitem.h>
#include <gtk/gtkoptionmenu.h>
+#include <gtk/gtkradiomenuitem.h>
+#include <gtk/gtkstock.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkversion.h>
@@ -47,6 +48,7 @@
#include <stdlib.h>
#include <string.h>
+#include "e-icon-entry.h"
#include "e-search-bar.h"
#include "e-util/e-util-marshal.h"
#include "e-util/e-icon-factory.h"
@@ -55,7 +57,7 @@ enum {
QUERY_CHANGED,
MENU_ACTIVATED,
SEARCH_ACTIVATED,
-
+ SEARCH_CLEARED,
LAST_SIGNAL
};
@@ -75,7 +77,6 @@ enum {
/* Forward decls. */
static int find_id (GtkWidget *menu, int idin, const char *type, GtkWidget **widget);
-static void activate_by_subitems (ESearchBar *esb, gint item_id, ESearchBarSubitem *subitems);
static void emit_search_activated (ESearchBar *esb);
static void emit_query_changed (ESearchBar *esb);
@@ -91,8 +92,6 @@ set_find_now_sensitive (ESearchBar *search_bar,
bonobo_ui_component_set_prop (search_bar->ui_component,
"/commands/ESearchBar:FindNow",
"sensitive", sensitive ? "1" : "0", NULL);
-
- gtk_widget_set_sensitive (search_bar->activate_button, sensitive);
}
static char *
@@ -107,36 +106,13 @@ verb_name_from_id (int id)
static void
clear_search (ESearchBar *esb)
{
- GtkWidget *widget;
- ESearchBarSubitem *subitems;
-
e_search_bar_set_text (esb, "");
e_search_bar_set_item_id (esb, 0);
-
- find_id (esb->option_menu, 0, "EsbChoiceId", &widget);
-
- subitems = g_object_get_data (G_OBJECT (widget), "EsbChoiceSubitems");
- activate_by_subitems (esb, 0, subitems);
+ e_search_bar_set_viewitem_id (esb, 0);
emit_search_activated (esb);
}
-/* Frees an array of subitem information */
-static void
-free_subitems (ESearchBarSubitem *subitems)
-{
- ESearchBarSubitem *s;
-
- g_assert (subitems != NULL);
-
- for (s = subitems; s->id != -1; s++) {
- if (s->text)
- g_free (s->text);
- }
-
- g_free (subitems);
-}
-
static void
free_menu_items (ESearchBar *esb)
{
@@ -171,7 +147,7 @@ emit_query_changed (ESearchBar *esb)
}
static void
-emit_search_activated (ESearchBar *esb)
+emit_search_activated(ESearchBar *esb)
{
if (esb->pending_activate) {
g_source_remove (esb->pending_activate);
@@ -204,14 +180,18 @@ search_now_verb_cb (BonoboUIComponent *ui_component,
const char *text;
esb = E_SEARCH_BAR (data);
- text = gtk_entry_get_text (GTK_ENTRY (esb->entry));
+ text = e_search_bar_get_text (esb);
if (text && *text) {
gtk_widget_modify_base (esb->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED]));
+ gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
+ gtk_widget_modify_base (esb->viewoption, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
+
} else {
gtk_widget_modify_base (esb->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
+ gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, NULL);
}
emit_search_activated (esb);
@@ -227,7 +207,8 @@ clear_verb_cb (BonoboUIComponent *ui_component,
gtk_widget_modify_base (esb->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
-
+ gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, NULL);
+
clear_search (esb);
}
@@ -246,7 +227,7 @@ setup_standard_verbs (ESearchBar *search_bar)
"</commands>"),
NULL);
- /* Make sure the entries are created with the correct sensitivity. */
+ /* Make sure the entries are created with the correct sensitivity. */
set_find_now_sensitive (search_bar, FALSE);
}
@@ -267,9 +248,68 @@ search_verb_cb (BonoboUIComponent *ui_component,
g_assert (p != NULL);
id = atoi (p + 1);
+
emit_menu_activated (esb, id);
}
+/* Get the selected menu item's label */
+static const gchar *
+get_selected_item_label (GtkWidget *menu)
+{
+ GtkWidget *label, *item;
+ const gchar *text = NULL;
+
+ item = gtk_menu_get_active ((GtkMenu *)menu);
+ label = gtk_bin_get_child ((GtkBin *)item);
+
+ if (GTK_IS_LABEL (label))
+ text = gtk_label_get_text ((GtkLabel *)label);
+
+ return text;
+}
+
+static gboolean
+entry_focus_in_cb (GtkWidget *widget,
+ GdkEventFocus *event,
+ ESearchBar *esb)
+{
+ GtkStyle *entry_style, *default_style;
+
+ entry_style = gtk_widget_get_style (esb->entry);
+ default_style = gtk_widget_get_default_style ();
+
+ if (gdk_color_equal (&(entry_style->text[GTK_STATE_NORMAL]), &(default_style->text[GTK_STATE_INSENSITIVE]))) {
+ gtk_entry_set_text (GTK_ENTRY (esb->entry), "");
+ gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
+ }
+
+ return FALSE;
+}
+
+static gboolean
+entry_focus_out_cb (GtkWidget *widget,
+ GdkEventFocus *event,
+ ESearchBar *esb)
+{
+ GtkStyle *style = gtk_widget_get_default_style ();
+ const gchar *text = NULL;
+
+ if (!GTK_IS_RADIO_MENU_ITEM (gtk_menu_get_active ( GTK_MENU (esb->option_menu))))
+ return FALSE;
+
+ text = gtk_entry_get_text (GTK_ENTRY (widget));
+ if (!(text && *text)) {
+ /* no query in search entry .. so set the current option */
+ text = get_selected_item_label (esb->option_menu);
+ if (text && *text) {
+ gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_INSENSITIVE]));
+ gtk_entry_set_text (GTK_ENTRY (esb->entry), text);
+ gtk_widget_hide (esb->clear_button);
+ }
+ }
+ return FALSE;
+}
+
static void
entry_activated_cb (GtkWidget *widget,
ESearchBar *esb)
@@ -278,11 +318,14 @@ entry_activated_cb (GtkWidget *widget,
GtkStyle *style = gtk_widget_get_default_style ();
if (text && *text) {
- gtk_widget_modify_base (esb->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
+ gtk_widget_modify_base (esb->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED]));
+ gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
+ gtk_widget_modify_base (esb->viewoption, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
} else {
gtk_widget_modify_base (esb->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
+ gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, NULL);
}
emit_search_activated (esb);
@@ -292,24 +335,65 @@ static void
entry_changed_cb (GtkWidget *widget,
ESearchBar *esb)
{
- set_find_now_sensitive (esb, TRUE);
+ const char *text = gtk_entry_get_text (GTK_ENTRY (esb->entry));
+ GtkStyle *entry_style, *default_style;
+
+ entry_style = gtk_widget_get_style (esb->entry);
+ default_style = gtk_widget_get_default_style ();
+
+ if (text && *text)
+ if (gdk_color_equal (&(entry_style->text[GTK_STATE_NORMAL]), &(default_style->text[GTK_STATE_INSENSITIVE])))
+ gtk_widget_hide (esb->clear_button);
+ else
+ gtk_widget_show (esb->clear_button);
+ else
+ gtk_widget_hide (esb->clear_button);
}
static void
-subitem_activated_cb (GtkWidget *widget, ESearchBar *esb)
+viewitem_activated_cb(GtkWidget *widget, ESearchBar *esb)
{
- gint id, subid;
+ gint viewid;
+ GtkStyle *entry_style, *default_style;
+
+ widget = gtk_menu_get_active (GTK_MENU (esb->viewoption_menu));
+
+ viewid = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "EsbItemId"));
+ esb->viewitem_id = viewid;
- id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "EsbItemId"));
- subid = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "EsbSubitemId"));
+ entry_style = gtk_widget_get_style (esb->entry);
+ default_style = gtk_widget_get_default_style ();
+
+ /* If the text is grayed, Its not the query string */
+ if (gdk_color_equal (&(entry_style->text[GTK_STATE_NORMAL]), &(default_style->text[GTK_STATE_INSENSITIVE]))) {
+ gtk_entry_set_text (GTK_ENTRY (esb->entry), "");
+ gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
+ }
- esb->item_id = id;
- esb->subitem_id = subid;
emit_search_activated (esb);
+}
- set_find_now_sensitive (esb, FALSE);
-
- gtk_widget_grab_focus (esb->entry);
+static void
+scopeitem_activated_cb(GtkWidget *widget, ESearchBar *esb)
+{
+ gint scopeid;
+ GtkStyle *entry_style, *default_style;
+
+ widget = gtk_menu_get_active (GTK_MENU (esb->scopeoption_menu));
+
+ scopeid = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "EsbItemId"));
+ esb->scopeitem_id = scopeid;
+
+ entry_style = gtk_widget_get_style (esb->entry);
+ default_style = gtk_widget_get_default_style ();
+
+ /* If the text is grayed, Its not the query string */
+ if (gdk_color_equal (&(entry_style->text[GTK_STATE_NORMAL]), &(default_style->text[GTK_STATE_INSENSITIVE]))) {
+ gtk_entry_set_text (GTK_ENTRY (esb->entry), "");
+ gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
+ }
+
+ emit_search_activated (esb);
}
static char *
@@ -339,170 +423,45 @@ string_without_underscores (const char *s)
}
static void
-activate_by_subitems (ESearchBar *esb, gint item_id, ESearchBarSubitem *subitems)
-{
- if (subitems == NULL) {
- /* This item uses the entry. */
-
- /* Remove the menu */
- if (esb->suboption && esb->subitem_id != -1) {
- g_assert (esb->suboption->parent == esb->entry_box);
- g_assert (!esb->entry || esb->entry->parent == NULL);
- gtk_container_remove (GTK_CONTAINER (esb->entry_box), esb->suboption);
- }
-
- /* Create and add the entry */
-
- if (esb->entry == NULL) {
- AtkObject *a11y;
-
- esb->entry = gtk_entry_new();
- gtk_widget_set_size_request (esb->entry, 4, -1);
- g_object_ref (esb->entry);
- g_signal_connect (esb->entry, "changed",
- G_CALLBACK (entry_changed_cb), esb);
- g_signal_connect (esb->entry, "activate",
- G_CALLBACK (entry_activated_cb), esb);
- gtk_container_add (GTK_CONTAINER (esb->entry_box), esb->entry);
- gtk_widget_show(esb->entry);
-
- a11y = gtk_widget_get_accessible (esb->entry);
- /* To translators: This is the accessibility name of
- the search bar's text entry widget */
- atk_object_set_name (a11y, _("Search"));
-
- esb->subitem_id = -1;
- }
-
- if (esb->subitem_id == -1) {
- g_assert (esb->entry->parent == esb->entry_box);
- g_assert (!esb->suboption || esb->suboption->parent == NULL);
- } else {
- gtk_container_add (GTK_CONTAINER (esb->entry_box), esb->entry);
- gtk_widget_grab_focus (esb->entry);
-
- esb->subitem_id = -1;
-
- }
- } else {
- /* This item uses a submenu */
- GtkWidget *menu;
- GtkWidget *menu_item;
- gint i;
-
- /* Remove the entry */
- if (esb->entry && esb->subitem_id == -1) {
- g_assert (esb->entry->parent == esb->entry_box);
- g_assert (!esb->suboption || esb->suboption->parent == NULL);
- gtk_container_remove (GTK_CONTAINER (esb->entry_box), esb->entry);
- }
-
- /* Create and add the menu */
-
- if (esb->suboption == NULL) {
- esb->suboption = gtk_option_menu_new ();
- g_object_ref (esb->suboption);
- gtk_container_add (GTK_CONTAINER (esb->entry_box), esb->suboption);
- gtk_widget_show (esb->suboption);
-
- esb->subitem_id = subitems[0].id;
- }
-
- if (esb->subitem_id != -1) {
- g_assert (esb->suboption->parent == esb->entry_box);
- g_assert (!esb->entry || esb->entry->parent == NULL);
- } else {
- gtk_container_add (GTK_CONTAINER (esb->entry_box), esb->suboption);
- esb->subitem_id = subitems[0].id;
- }
-
- /* Create the items */
-
- esb->suboption_menu = menu = gtk_menu_new ();
- for (i = 0; subitems[i].id != -1; ++i) {
- if (subitems[i].text) {
- char *str;
-
- if (subitems[i].translate)
- str = string_without_underscores (_(subitems[i].text));
- else
- str = string_without_underscores (subitems[i].text);
-
- menu_item = gtk_menu_item_new_with_label (str);
-
- g_free (str);
- } else {
- menu_item = gtk_menu_item_new ();
- gtk_widget_set_sensitive (menu_item, FALSE);
- }
-
- g_object_set_data (G_OBJECT (menu_item), "EsbItemId",
- GINT_TO_POINTER (item_id));
- g_object_set_data (G_OBJECT (menu_item), "EsbSubitemId",
- GINT_TO_POINTER (subitems[i].id));
-
- g_signal_connect (menu_item,
- "activate",
- G_CALLBACK (subitem_activated_cb),
- esb);
-
- gtk_widget_show (menu_item);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
- }
-
- gtk_option_menu_remove_menu (GTK_OPTION_MENU (esb->suboption));
- gtk_option_menu_set_menu (GTK_OPTION_MENU (esb->suboption), menu);
- }
-
- if (esb->activate_button)
- gtk_widget_set_sensitive (esb->activate_button, subitems == NULL);
-}
-
-static void
option_activated_cb (GtkWidget *widget,
ESearchBar *esb)
{
- int id;
-
- id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "EsbChoiceId"));
+/* int id; */
+
+/* id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "EsbItemId")); */
- activate_by_subitems (esb, id, g_object_get_data (G_OBJECT (widget), "EsbChoiceSubitems"));
-
- esb->item_id = id;
+/* esb->item_id = id; */
emit_query_changed (esb);
+ emit_search_activated (esb);
}
static void
-activate_button_clicked_cb (GtkWidget *widget,
- ESearchBar *esb)
+option_button_clicked_cb (GtkWidget *widget, GdkEventButton *event,
+ ESearchBar *esb)
{
- const char *text = gtk_entry_get_text (GTK_ENTRY (esb->entry));
- GtkStyle *style = gtk_widget_get_default_style ();
-
- if (text && *text) {
- gtk_widget_modify_base (esb->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
- gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED]));
- } else {
- gtk_widget_modify_base (esb->entry, GTK_STATE_NORMAL, NULL);
- gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
- }
- emit_search_activated (esb);
+ gtk_menu_popup (GTK_MENU (esb->option_menu), NULL, NULL, NULL, NULL,1,gtk_get_current_event_time());
gtk_widget_grab_focus (esb->entry);
}
static void
-clear_button_clicked_cb (GtkWidget *widget,
+clear_button_clicked_cb (GtkWidget *widget, GdkEventButton *event,
ESearchBar *esb)
{
gtk_widget_modify_base (esb->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
-
+ gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, NULL);
+
clear_search (esb);
gtk_widget_grab_focus (esb->entry);
}
+static void
+scopeoption_changed_cb (GtkWidget *option_menu, ESearchBar *search_bar)
+{
+ emit_query_changed (search_bar);
+}
/* Widgetry creation. */
@@ -523,30 +482,6 @@ put_in_spacer_widget (GtkWidget *widget)
return holder;
}
-static ESearchBarSubitem *
-copy_subitems (ESearchBarSubitem *subitems)
-{
- gint i, N;
- ESearchBarSubitem *copy;
-
- if (subitems == NULL)
- return NULL;
-
- for (N=0; subitems[N].id != -1; ++N);
- copy = g_new (ESearchBarSubitem, N+1);
-
- for (i=0; i<N; ++i) {
- copy[i].text = g_strdup (subitems[i].text);
- copy[i].id = subitems[i].id;
- copy[i].translate = subitems[i].translate;
- }
-
- copy[N].text = NULL;
- copy[N].id = -1;
-
- return copy;
-}
-
static void
append_xml_menu_item (GString *xml,
const char *name,
@@ -643,12 +578,10 @@ set_menu (ESearchBar *esb,
for (i = 0; items[i].id != -1; i++) {
ESearchBarItem *new_item;
- g_assert (items[i].subitems == NULL);
-
new_item = g_new (ESearchBarItem, 1);
new_item->text = items[i].text ? g_strdup (_(items[i].text)) : NULL;
new_item->id = items[i].id;
- new_item->subitems = NULL;
+ new_item->type = items[i].type;
esb->menu_items = g_slist_append (esb->menu_items, new_item);
}
@@ -657,50 +590,59 @@ set_menu (ESearchBar *esb,
update_bonobo_menus (esb);
}
-/* Callback used when an option item is destroyed. We have to destroy its
- * suboption items.
- */
-static void
-option_item_destroy_cb (GtkObject *object, gpointer data)
-{
- ESearchBarSubitem *subitems;
+/* /\* Callback used when an option item is destroyed. We have to destroy its */
+/* * suboption items. */
+/* *\/ */
+/* static void */
+/* option_item_destroy_cb (GtkObject *object, gpointer data) */
+/* { */
+/* /\* ESearchBarSubitem *subitems; *\/ */
- subitems = data;
+/* /\* subitems = data; *\/ */
- g_assert (subitems != NULL);
- free_subitems (subitems);
- g_object_set_data (G_OBJECT (object), "EsbChoiceSubitems", NULL);
-}
+/* /\* g_assert (subitems != NULL); *\/ */
+/* /\* free_subitems (subitems); *\/ */
+/* /\* g_object_set_data (G_OBJECT (object), "EsbChoiceSubitems", NULL); *\/ */
+/* } */
static void
set_option (ESearchBar *esb, ESearchBarItem *items)
{
GtkWidget *menu;
+ GSList *group = NULL;
int i;
- if (esb->option) {
+ if (esb->option)
gtk_widget_destroy (esb->option_menu);
- } else {
- AtkObject *a11y;
-
- esb->option = gtk_option_menu_new ();
- gtk_widget_show (esb->option);
- gtk_box_pack_start (GTK_BOX (esb), esb->option, FALSE, FALSE, 0);
- a11y = gtk_widget_get_accessible (esb->option);
- atk_object_set_name (a11y, _("Search Type"));
-
- }
esb->option_menu = menu = gtk_menu_new ();
for (i = 0; items[i].id != -1; i++) {
GtkWidget *item;
- ESearchBarSubitem *subitems = NULL;
+
+ /* Create a new group */
+ if (items[i].id == 0)
+ group = 0;
if (items[i].text) {
char *str;
-
str = string_without_underscores (_(items[i].text));
- item = gtk_menu_item_new_with_label (str);
+ switch (items[i].type) {
+ case ESB_ITEMTYPE_NORMAL:
+ item = gtk_menu_item_new_with_label (str);
+ break;
+ case ESB_ITEMTYPE_CHECK:
+ item = gtk_check_menu_item_new_with_label (str);
+ break;
+ case ESB_ITEMTYPE_RADIO:
+ item = gtk_radio_menu_item_new_with_label (group, str);
+ group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM (item));
+ break;
+ default:
+ /* Fixme : this should be a normal item */
+ item = gtk_radio_menu_item_new_with_label (group, str);
+ group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM (item));
+ break;
+ }
g_free (str);
} else {
item = gtk_menu_item_new ();
@@ -709,17 +651,7 @@ set_option (ESearchBar *esb, ESearchBarItem *items)
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
- g_object_set_data (G_OBJECT (item), "EsbChoiceId", GINT_TO_POINTER(items[i].id));
-
- if (items[i].subitems != NULL) {
- subitems = copy_subitems (items[i].subitems);
- g_object_set_data (G_OBJECT (item), "EsbChoiceSubitems", subitems);
- g_signal_connect (item, "destroy",
- G_CALLBACK (option_item_destroy_cb), subitems);
- }
-
- if (i == 0)
- activate_by_subitems (esb, items[i].id, subitems);
+ g_object_set_data (G_OBJECT (item), "EsbItemId", GINT_TO_POINTER(items[i].id));
g_signal_connect (item, "activate",
G_CALLBACK (option_activated_cb),
@@ -728,55 +660,9 @@ set_option (ESearchBar *esb, ESearchBarItem *items)
gtk_widget_show_all (menu);
- gtk_option_menu_set_menu (GTK_OPTION_MENU (esb->option), menu);
gtk_option_menu_set_history (GTK_OPTION_MENU (esb->option), 0);
- gtk_widget_set_sensitive (esb->option, TRUE);
-}
-
-static GtkWidget *
-add_button (ESearchBar *esb,
- const char *text,
- const char *stock,
- GCallback callback)
-{
- GtkWidget *holder;
- GtkWidget *button;
- GtkWidget *image;
-
-#if !GTK_CHECK_VERSION (2,6,0)
- GtkWidget *hbox = gtk_hbox_new (FALSE, 2);
- GtkWidget *label = gtk_label_new_with_mnemonic (text);
-
- gtk_misc_set_padding (GTK_MISC (label), 2, 0);
-#endif
-
- /* See the comment in `put_in_spacer_widget()' to understand
- why we have to do this. */
-
- image = gtk_image_new_from_stock (stock, GTK_ICON_SIZE_BUTTON);
- button = gtk_button_new_with_mnemonic (text);
-#if GTK_CHECK_VERSION (2,6,0)
- gtk_button_set_image (GTK_BUTTON (button), image);
-#else
- gtk_widget_show (image);
- gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
- gtk_widget_show (hbox);
-
- button = gtk_button_new ();
- gtk_container_add (GTK_CONTAINER (button), hbox);
-#endif
- gtk_widget_show (button);
-
- holder = put_in_spacer_widget (button);
- gtk_widget_show (holder);
-
- g_signal_connect (G_OBJECT (button), "clicked", callback, esb);
-
- gtk_box_pack_end (GTK_BOX (esb), holder, FALSE, FALSE, 1);
-
- return button;
+ entry_focus_out_cb (esb->entry, NULL, esb);
}
static int
@@ -814,10 +700,6 @@ impl_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *ps
g_value_set_int (value, e_search_bar_get_item_id (esb));
break;
- case PROP_SUBITEM_ID:
- g_value_set_int (value, e_search_bar_get_subitem_id (esb));
- break;
-
case PROP_TEXT:
g_value_set_string_take_ownership (value, e_search_bar_get_text (esb));
break;
@@ -838,10 +720,6 @@ impl_set_property (GObject *object, guint prop_id, const GValue *value, GParamSp
e_search_bar_set_item_id (esb, g_value_get_int (value));
break;
- case PROP_SUBITEM_ID:
- e_search_bar_set_subitem_id (esb, g_value_get_int (value));
- break;
-
case PROP_TEXT:
e_search_bar_set_text (esb, g_value_get_string (value));
break;
@@ -867,10 +745,10 @@ impl_dispose (GObject *object)
bonobo_object_unref (BONOBO_OBJECT (esb->ui_component));
esb->ui_component = NULL;
}
- if (esb->entry) {
- g_object_unref (esb->entry);
- esb->entry = NULL;
- }
+/* if (esb->entry) { */
+/* g_object_unref (esb->entry); */
+/* esb->entry = NULL; */
+/* } */
if (esb->suboption) {
g_object_unref (esb->suboption);
esb->suboption = NULL;
@@ -911,13 +789,6 @@ class_init (ESearchBarClass *klass)
0, 0, 0,
G_PARAM_READWRITE | G_PARAM_LAX_VALIDATION));
- g_object_class_install_property (object_class, PROP_SUBITEM_ID,
- g_param_spec_int ("subitem_id",
- _("Subitem ID"),
- /*_( */"XXX blurb" /*)*/,
- 0, 0, 0,
- G_PARAM_READWRITE | G_PARAM_LAX_VALIDATION));
-
g_object_class_install_property (object_class, PROP_TEXT,
g_param_spec_string ("text",
_("Text"),
@@ -951,6 +822,7 @@ class_init (ESearchBarClass *klass)
NULL, NULL,
e_util_marshal_NONE__NONE,
G_TYPE_NONE, 0);
+
}
static void
@@ -965,14 +837,18 @@ init (ESearchBar *esb)
esb->option_menu = NULL;
esb->suboption_menu = NULL;
- esb->activate_button = NULL;
+ esb->option_button = NULL;
esb->clear_button = NULL;
esb->entry_box = NULL;
+ esb->scopeoption_menu = NULL;
+ esb->scopeoption = NULL;
+ esb->scopeoption_box = NULL;
+
esb->pending_activate = 0;
esb->item_id = 0;
- esb->subitem_id = 0;
+ esb->scopeitem_id = 0;
}
@@ -992,26 +868,88 @@ e_search_bar_construct (ESearchBar *search_bar,
ESearchBarItem *menu_items,
ESearchBarItem *option_items)
{
- GtkWidget *image;
+ GtkWidget *label, *hbox, *bighbox;
+
g_return_if_fail (search_bar != NULL);
g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
g_return_if_fail (option_items != NULL);
- gtk_box_set_spacing (GTK_BOX (search_bar), 1);
-
- search_bar->clear_button = add_button (search_bar, _("_Clear"), "gtk-clear",
- G_CALLBACK (clear_button_clicked_cb));
- search_bar->activate_button = add_button (search_bar, _("Find No_w"), "gtk-find",
- G_CALLBACK (activate_button_clicked_cb));
+ gtk_box_set_spacing (GTK_BOX (search_bar), 3);
- e_search_bar_set_menu (search_bar, menu_items);
+ gtk_box_set_homogeneous (GTK_BOX (search_bar), FALSE);
+ bighbox = gtk_hbox_new (FALSE, 0);
search_bar->entry_box = gtk_hbox_new (0, FALSE);
+ search_bar->icon_entry = e_icon_entry_new ();
+ search_bar->entry = e_icon_entry_get_entry (E_ICON_ENTRY (search_bar->icon_entry));
+
+ g_signal_connect (search_bar->entry, "changed",
+ G_CALLBACK (entry_changed_cb), search_bar);
+ g_signal_connect (search_bar->entry, "activate",
+ G_CALLBACK (entry_activated_cb), search_bar);
+ g_signal_connect (search_bar->entry, "focus-in-event",
+ G_CALLBACK (entry_focus_in_cb), search_bar);
+ g_signal_connect (search_bar->entry, "focus-out-event",
+ G_CALLBACK (entry_focus_out_cb), search_bar);
+
+ search_bar->clear_button = e_icon_entry_create_button ("gtk-clear");
+ g_signal_connect (G_OBJECT (search_bar->clear_button), "button-press-event", clear_button_clicked_cb, search_bar);
+ e_icon_entry_pack_widget (E_ICON_ENTRY (search_bar->icon_entry), search_bar->clear_button, FALSE);
+
+ search_bar->option_button = e_icon_entry_create_button ("gtk-find");
+ g_signal_connect (G_OBJECT (search_bar->option_button), "button-press-event", option_button_clicked_cb, search_bar);
+ e_icon_entry_pack_widget (E_ICON_ENTRY (search_bar->icon_entry), search_bar->option_button, TRUE);
+
+ gtk_box_pack_start (GTK_BOX(search_bar->entry_box), search_bar->icon_entry, FALSE, FALSE, 0);
+
+ gtk_widget_show_all (search_bar->entry_box);
+ gtk_widget_hide (search_bar->clear_button);
+
+ /* Current View filter */
+ search_bar->viewoption_box = gtk_hbox_new (0, FALSE);
+
+ label = gtk_label_new_with_mnemonic (_("Show : "));
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX(search_bar->viewoption_box), label, FALSE, FALSE, 0);
+
+ search_bar->viewoption = gtk_option_menu_new ();
+ gtk_box_pack_start (GTK_BOX(search_bar->viewoption_box), search_bar->viewoption, FALSE, TRUE, 0);
+ gtk_widget_show_all (search_bar->viewoption_box);
+ gtk_box_pack_start (GTK_BOX(search_bar), search_bar->viewoption_box, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(search_bar), hbox, FALSE, FALSE, 0);
+
+ /* Search entry */
+ hbox = gtk_hbox_new (FALSE, 0);
+ label = gtk_label_new_with_mnemonic (_("S_earch : "));
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(hbox), search_bar->entry_box, FALSE, FALSE, 0);
+ gtk_widget_show (search_bar->entry_box);
- e_search_bar_set_option (search_bar, option_items);
+ /* Search Scope Widgets */
+ search_bar->scopeoption_box = gtk_hbox_new (0, FALSE);
+ gtk_box_set_spacing (GTK_BOX (search_bar->scopeoption_box), 3);
+ label = gtk_label_new_with_mnemonic (_(" in "));
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX(search_bar->scopeoption_box), label, FALSE, FALSE, 0);
+
+ search_bar->scopeoption = gtk_option_menu_new ();
+ g_signal_connect (GTK_OPTION_MENU (search_bar->scopeoption), "changed", scopeoption_changed_cb, search_bar);
+ gtk_box_pack_start (GTK_BOX(search_bar->scopeoption_box), search_bar->scopeoption, FALSE, FALSE, 0);
+ gtk_widget_show_all (search_bar->scopeoption_box);
+ gtk_widget_hide (hbox);
+
+ gtk_box_pack_end (GTK_BOX(hbox), search_bar->scopeoption_box, FALSE, FALSE, 0);
+ gtk_widget_hide (search_bar->scopeoption_box);
+
+ gtk_box_pack_end (GTK_BOX(search_bar), hbox, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
- gtk_widget_show (search_bar->entry_box);
- gtk_box_pack_start (GTK_BOX(search_bar), search_bar->entry_box, TRUE, TRUE, 0);
+ /* Set the menu */
+ e_search_bar_set_menu (search_bar, menu_items);
+ e_search_bar_set_option (search_bar, option_items);
/*
* If the default choice for the option menu has subitems, then we need to
@@ -1020,11 +958,8 @@ e_search_bar_construct (ESearchBar *search_bar,
* so we can't emit here. Thus we launch a one-shot idle function that will
* emit the changed signal, so that the proper callback will get invoked.
*/
- if (search_bar->subitem_id >= 0) {
- gtk_widget_set_sensitive (search_bar->activate_button, FALSE);
- search_bar->pending_activate = g_idle_add (idle_activate_hack, search_bar);
- }
+ search_bar->pending_activate = g_idle_add (idle_activate_hack, search_bar);
}
void
@@ -1055,8 +990,14 @@ e_search_bar_set_option (ESearchBar *search_bar, ESearchBarItem *option_items)
((ESearchBarClass *) GTK_OBJECT_GET_CLASS (search_bar))->set_option (search_bar, option_items);
}
+void
+e_search_bar_set_viewoption_menufunc (ESearchBar *search_bar, ESearchBarMenuFunc *menu_gen_func, void *data)
+{
+ g_signal_connect (search_bar->viewoption, "button_press_event", G_CALLBACK (menu_gen_func), data);
+}
+
/**
- * e_search_bar_set_suboption:
+ * e_search_bar_set_viewoption_menu:
* @search_bar: A search bar.
* @option_id: Identifier of the main option menu item under which the subitems
* are to be set.
@@ -1064,41 +1005,155 @@ e_search_bar_set_option (ESearchBar *search_bar, ESearchBarItem *option_items)
*
* Sets the items for the secondary option menu of a search bar.
**/
-void
-e_search_bar_set_suboption (ESearchBar *search_bar, int option_id, ESearchBarSubitem *subitems)
+void
+e_search_bar_set_viewoption_menu (ESearchBar *search_bar, GtkWidget *menu)
{
- int row;
- GtkWidget *item;
- ESearchBarSubitem *old_subitems;
- ESearchBarSubitem *new_subitems;
+
+ if (search_bar->viewoption_menu != NULL)
+ gtk_option_menu_remove_menu (GTK_OPTION_MENU (search_bar->viewoption));
- g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
+ search_bar->viewoption_menu = menu;
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (search_bar->viewoption), search_bar->viewoption_menu);
+
+ g_signal_connect (search_bar->viewoption_menu,
+ "selection-done",
+ G_CALLBACK (viewitem_activated_cb),
+ search_bar);
+}
+
+GtkWidget *
+e_search_bar_get_selected_viewitem (ESearchBar *search_bar)
+{
+ GtkWidget *widget = NULL;
+
+ widget = gtk_menu_get_active (GTK_MENU (search_bar->viewoption_menu));
+
+ return widget;
+}
+
+/**
+ * e_search_bar_set_viewoption:
+ * @search_bar: A search bar.
+ * @option_id: Identifier of the main option menu item under which the subitems
+ * are to be set.
+ * @subitems: Array of subitem information.
+ *
+ * Sets the items for the secondary option menu of a search bar.
+ **/
+void
+e_search_bar_set_viewoption (ESearchBar *search_bar, int option_id, ESearchBarItem *subitems)
+{
+ GtkWidget *menu;
+ GtkWidget *menu_item;
+ gint i;
+
+ /* Create the menu if it is not there. right scenario ????*/
+
+ if (search_bar->viewoption_menu == NULL) {
+ search_bar->viewoption_menu = menu = gtk_menu_new ();
+ } else {
+ gtk_option_menu_remove_menu (GTK_OPTION_MENU (search_bar->viewoption));
+ search_bar->viewoption_menu = menu = gtk_menu_new ();
+ }
+
+ /* Create the items */
+
+ for (i = 0; subitems[i].id != -1; ++i) {
+ if (subitems[i].text) {
+ char *str = NULL;
+ str = string_without_underscores (subitems[i].text);
+ menu_item = gtk_menu_item_new_with_label (str);
+ g_free (str);
+ } else {
+ menu_item = gtk_menu_item_new ();
+ gtk_widget_set_sensitive (menu_item, FALSE);
+ }
+
+ g_object_set_data (G_OBJECT (menu_item), "EsbItemId",
+ GINT_TO_POINTER (subitems[i].id));
+
+ g_signal_connect (menu_item,
+ "activate",
+ G_CALLBACK (viewitem_activated_cb),
+ search_bar);
+
+ gtk_widget_show (menu_item);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
+ }
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (search_bar->viewoption), menu);
+
+}
+
+/**
+ * e_search_bar_set_scopeoption:
+ * @search_bar: A search bar.
+ * are to be set.
+ * @scopeitems: Array of scope information.
+ *
+ * Sets the items for the search scope option menu of a search bar.
+ **/
+void
+e_search_bar_set_scopeoption (ESearchBar *search_bar, ESearchBarItem *scopeitems)
+{
+ GtkWidget *menu;
+ GtkWidget *menu_item;
+ gint i;
- row = find_id (search_bar->option_menu, option_id, "EsbChoiceId", &item);
- g_return_if_fail (row != -1);
- g_assert (item != NULL);
-
- old_subitems = g_object_get_data (G_OBJECT (item), "EsbChoiceSubitems");
- if (old_subitems) {
- /* This was connected in set_option() */
- g_signal_handlers_disconnect_matched (item,
- G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL,
- old_subitems);
- free_subitems (old_subitems);
- g_object_set_data (G_OBJECT (item), "EsbChoiceSubitems", NULL);
+ gtk_widget_show (search_bar->scopeoption_box);
+ if (search_bar->scopeoption_menu != NULL) {
+ gtk_option_menu_remove_menu (GTK_OPTION_MENU (search_bar->scopeoption));
+ }
+
+ search_bar->scopeoption_menu = menu = gtk_menu_new ();
+
+ /* Generate items */
+ for (i = 0; scopeitems[i].id != -1; ++i) {
+ if (scopeitems[i].text) {
+ char *str;
+ str = string_without_underscores (scopeitems[i].text);
+ menu_item = gtk_menu_item_new_with_label (str);
+ g_free (str);
+ } else {
+ menu_item = gtk_menu_item_new ();
+ gtk_widget_set_sensitive (menu_item, FALSE);
+ }
+
+ g_object_set_data (G_OBJECT (menu_item), "EsbItemId",
+ GINT_TO_POINTER (scopeitems[i].id));
+
+ g_signal_connect (menu_item,
+ "activate",
+ G_CALLBACK (scopeitem_activated_cb),
+ search_bar);
+
+ gtk_widget_show (menu_item);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
}
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (search_bar->scopeoption), menu);
+}
+
+
+/**
+ * e_search_bar_set_scopeoption_menu:
+ * @search_bar: A search bar.
+ * @menu: the scope option menu
+ *
+ * Sets the items for the secondary option menu of a search bar.
+ **/
+void
+e_search_bar_set_scopeoption_menu (ESearchBar *search_bar, GtkMenu *menu)
+{
- if (subitems) {
- new_subitems = copy_subitems (subitems);
- g_object_set_data (G_OBJECT (item), "EsbChoiceSubitems", new_subitems);
- g_signal_connect (item, "destroy",
- G_CALLBACK (option_item_destroy_cb), new_subitems);
- } else
- new_subitems = NULL;
+ if (search_bar->scopeoption_menu != NULL)
+ gtk_option_menu_remove_menu (GTK_OPTION_MENU (search_bar->scopeoption));
+
+ search_bar->scopeoption_menu = GTK_WIDGET (menu);
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (search_bar->scopeoption), search_bar->scopeoption_menu);
- if (search_bar->item_id == option_id)
- activate_by_subitems (search_bar, option_id, new_subitems);
+ g_signal_connect (search_bar->scopeoption_menu,
+ "selection-done",
+ G_CALLBACK (scopeitem_activated_cb),
+ search_bar);
}
GtkWidget *
@@ -1176,6 +1231,22 @@ e_search_bar_get_type (void)
return type;
}
+void
+e_search_bar_set_viewitem_id (ESearchBar *search_bar, int id)
+{
+ int row;
+
+ g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
+
+ row = find_id (search_bar->viewoption_menu, id, "EsbItemId", NULL);
+ g_return_if_fail (row != -1);
+
+ search_bar->viewitem_id = id;
+ gtk_option_menu_set_history (GTK_OPTION_MENU (search_bar->viewoption), row);
+
+ emit_query_changed (search_bar);
+}
+
/**
* e_search_bar_set_item_id:
* @search_bar: A search bar.
@@ -1190,14 +1261,39 @@ e_search_bar_set_item_id (ESearchBar *search_bar, int id)
g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
- row = find_id (search_bar->option_menu, id, "EsbChoiceId", NULL);
+ row = find_id (search_bar->option_menu, id, "EsbItemId", NULL);
+ g_return_if_fail (row != -1);
+
+ search_bar->item_id = id;
+ gtk_menu_set_active (search_bar->option_menu, row);
+
+ emit_query_changed (search_bar);
+}
+
+/**
+ * e_search_bar_set_search_scope:
+ * @search_bar: A search bar.
+ * @id: Identifier of the item to set.
+ *
+ * Sets the active item in the options menu of a search bar.
+ **/
+void
+e_search_bar_set_search_scope (ESearchBar *search_bar, int id)
+{
+ int row;
+
+ g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
+
+ row = find_id (search_bar->option_menu, id, "EsbItemId", NULL);
g_return_if_fail (row != -1);
search_bar->item_id = id;
gtk_option_menu_set_history (GTK_OPTION_MENU (search_bar->option), row);
+
emit_query_changed (search_bar);
}
+
/**
* e_search_bar_get_item_id:
* @search_bar: A search bar.
@@ -1209,44 +1305,69 @@ e_search_bar_set_item_id (ESearchBar *search_bar, int id)
int
e_search_bar_get_item_id (ESearchBar *search_bar)
{
+ GtkWidget *menu_item;
+ gint item_id;
+
g_return_val_if_fail (search_bar != NULL, -1);
g_return_val_if_fail (E_IS_SEARCH_BAR (search_bar), -1);
+ menu_item = gtk_menu_get_active (GTK_MENU (search_bar->option_menu));
+ item_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "EsbItemId"));
+ search_bar->item_id = item_id;
+
return search_bar->item_id;
}
-void
-e_search_bar_set_subitem_id (ESearchBar *search_bar, int id)
+/**
+ * e_search_bar_get_search_scope:
+ * @search_bar: A search bar.
+ *
+ * Queries the currently selected search type in the options menu of a search bar.
+ *
+ * Return value: Identifier of the selected item in the options menu.
+ **/
+int
+e_search_bar_get_search_scope (ESearchBar *search_bar)
{
- int row;
+ GtkWidget *menu_item;
+ gint scopeitem_id;
- g_return_if_fail (search_bar != NULL);
- g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
+ g_return_val_if_fail (search_bar != NULL, -1);
+ g_return_val_if_fail (E_IS_SEARCH_BAR (search_bar), -1);
- row = find_id (search_bar->suboption_menu, id, "EsbSubitemId", NULL);
- g_return_if_fail (row != -1);
+ menu_item = gtk_menu_get_active (GTK_MENU (search_bar->scopeoption_menu));
+ scopeitem_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "EsbItemId"));
- search_bar->subitem_id = id;
- gtk_option_menu_set_history (GTK_OPTION_MENU (search_bar->suboption), row);
+ search_bar->scopeitem_id = scopeitem_id;
+
+ return search_bar->scopeitem_id;
}
/**
- * e_search_bar_get_subitem_id:
+ * e_search_bar_get_viewitem_id:
* @search_bar: A search bar.
*
- * Queries the currently selected item in the suboptions menu of a search bar.
+ * Queries the currently selected item in the viewoptions menu of a search bar.
*
- * Return value: Identifier of the selected item in the suboptions menu.
- * If the search bar currently contains an entry rather than a a suboption menu,
+ * Return value: Identifier of the selected item in the viewoptions menu.
+ * If the search bar currently contains an entry rather than a a viewoption menu,
* a value less than zero is returned.
**/
int
-e_search_bar_get_subitem_id (ESearchBar *search_bar)
+e_search_bar_get_viewitem_id (ESearchBar *search_bar)
{
+ GtkWidget *menu_item;
+ gint viewitem_id;
+
g_return_val_if_fail (search_bar != NULL, -1);
g_return_val_if_fail (E_IS_SEARCH_BAR (search_bar), -1);
- return search_bar->subitem_id;
+ menu_item = gtk_menu_get_active (GTK_MENU (search_bar->viewoption_menu));
+ viewitem_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "EsbItemId"));
+
+ search_bar->viewitem_id = viewitem_id;
+
+ return search_bar->viewitem_id;
}
/**
@@ -1263,7 +1384,6 @@ e_search_bar_set_ids (ESearchBar *search_bar, int item_id, int subitem_id)
{
int item_row;
GtkWidget *item_widget;
- ESearchBarSubitem *subitems;
g_return_if_fail (search_bar != NULL);
g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
@@ -1272,14 +1392,9 @@ e_search_bar_set_ids (ESearchBar *search_bar, int item_id, int subitem_id)
g_return_if_fail (item_row != -1);
g_assert (item_widget != NULL);
- subitems = g_object_get_data (G_OBJECT (item_widget), "EsbChoiceSubitems");
- g_return_if_fail (subitems != NULL);
-
search_bar->item_id = item_id;
gtk_option_menu_set_history (GTK_OPTION_MENU (search_bar->option), item_row);
- activate_by_subitems (search_bar, item_id, subitems);
- e_search_bar_set_subitem_id (search_bar, subitem_id);
}
/**
@@ -1293,7 +1408,6 @@ void
e_search_bar_set_text (ESearchBar *search_bar, const char *text)
{
g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
-
gtk_entry_set_text (GTK_ENTRY (search_bar->entry), text);
}
@@ -1310,8 +1424,18 @@ e_search_bar_set_text (ESearchBar *search_bar, const char *text)
char *
e_search_bar_get_text (ESearchBar *search_bar)
{
+ GtkStyle *entry_style, *default_style;
+
g_return_val_if_fail (search_bar != NULL, NULL);
g_return_val_if_fail (E_IS_SEARCH_BAR (search_bar), NULL);
-
- return search_bar->subitem_id < 0 ? g_strdup (gtk_entry_get_text (GTK_ENTRY (search_bar->entry))) : NULL;
+
+ entry_style = gtk_widget_get_style (search_bar->entry);
+ default_style = gtk_widget_get_default_style ();
+
+ if (gdk_color_equal (&(entry_style->text[GTK_STATE_NORMAL]), &(default_style->text[GTK_STATE_INSENSITIVE]))) {
+ gtk_entry_set_text (GTK_ENTRY (search_bar->entry), "");
+ gtk_widget_modify_text (search_bar->entry, GTK_STATE_NORMAL, NULL);
+ }
+
+ return g_strdup (gtk_entry_get_text (GTK_ENTRY (search_bar->entry)));
}
diff --git a/widgets/misc/e-search-bar.h b/widgets/misc/e-search-bar.h
index b0333ad58b..7f6c9237a4 100644
--- a/widgets/misc/e-search-bar.h
+++ b/widgets/misc/e-search-bar.h
@@ -43,21 +43,24 @@ G_BEGIN_DECLS
#define E_IS_SEARCH_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_SEARCH_BAR_TYPE))
#define E_IS_SEARCH_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_SEARCH_BAR_TYPE))
+enum _ESearchBarItemType {
+ ESB_ITEMTYPE_NORMAL,
+ ESB_ITEMTYPE_CHECK,
+ ESB_ITEMTYPE_RADIO,
+};
+typedef enum _ESearchBarItemType ESearchBarItemType;
+
typedef struct {
char *text;
int id;
- gboolean translate; /* whether to translate the text */
-} ESearchBarSubitem;
-
-typedef struct {
- char *text;
- int id;
- ESearchBarSubitem *subitems;
+ int type;
} ESearchBarItem;
typedef struct _ESearchBar ESearchBar;
typedef struct _ESearchBarClass ESearchBarClass;
+typedef void (*ESearchBarMenuFunc)(ESearchBar *esb, ESearchBarItem *menu_items );
+
struct _ESearchBar
{
GtkHBox parent;
@@ -75,14 +78,27 @@ struct _ESearchBar
GtkWidget *dropdown_holder; /* holds the dropdown */
GtkWidget *option_menu;
GtkWidget *suboption_menu;
- GtkWidget *activate_button;
+ GtkWidget *option_button;
GtkWidget *clear_button;
GtkWidget *entry_box;
+ GtkWidget *icon_entry;
+
+ /* show option widgets */
+ GtkWidget *viewoption_box;
+ GtkWidget *viewoption; /* an option menu for the choices associated with some search options */
+ GtkWidget *viewoption_menu;
+
+ /* search scope widgets */
+ GtkWidget *scopeoption_box;
+ GtkWidget *scopeoption; /* an option menu for the choices associated with scope search */
+ GtkWidget *scopeoption_menu;
+
guint pending_activate;
/* The currently-selected item & subitem */
int item_id;
- int subitem_id; /* < 0 if the entry widget is active */
+ int viewitem_id; /* Current View Id */
+ int scopeitem_id; /* Scope of search */
};
struct _ESearchBarClass
@@ -94,6 +110,7 @@ struct _ESearchBarClass
/* signals */
void (*search_activated) (ESearchBar *search);
+ void (*search_cleared) (ESearchBar *search);
void (*query_changed) (ESearchBar *search);
void (*menu_activated) (ESearchBar *search, int item);
};
@@ -121,9 +138,10 @@ void e_search_bar_add_menu (ESearchBar *search_bar,
void e_search_bar_set_option (ESearchBar *search_bar,
ESearchBarItem *option_items);
-void e_search_bar_set_suboption (ESearchBar *search_bar,
- int option_id,
- ESearchBarSubitem *subitems);
+
+void e_search_bar_set_viewoption (ESearchBar *search_bar,
+ int option_id,
+ ESearchBarItem *subitems);
void e_search_bar_set_menu_sensitive (ESearchBar *search_bar,
int id,
@@ -133,14 +151,26 @@ void e_search_bar_set_item_id (ESearchBar *search_bar,
int id);
int e_search_bar_get_item_id (ESearchBar *search_bar);
-void e_search_bar_set_subitem_id (ESearchBar *search_bar,
- int id);
-int e_search_bar_get_subitem_id (ESearchBar *search_bar);
+int e_search_bar_get_viewitem_id (ESearchBar *search_bar);
void e_search_bar_set_ids (ESearchBar *search_bar,
int item_id,
int subitem_id);
+void e_search_bar_set_scopeoption (ESearchBar *search_bar, ESearchBarItem *scopeitems);
+
+void e_search_bar_set_scopeoption_menu (ESearchBar *search_bar, GtkMenu *menu);
+
+void e_search_bar_set_search_scope (ESearchBar *search_bar, int id);
+
+void e_search_bar_set_viewoption_menu (ESearchBar *search_bar, GtkWidget *menu);
+
+void e_search_bar_set_viewoption_menufunc (ESearchBar *search_bar, ESearchBarMenuFunc *menu_gen_func, void *data);
+
+GtkWidget *e_search_bar_get_selected_viewitem (ESearchBar *search_bar);
+
+int e_search_bar_get_search_scope (ESearchBar *search_bar);
+
void e_search_bar_set_text (ESearchBar *search_bar,
const char *text);
char *e_search_bar_get_text (ESearchBar *search_bar);
diff --git a/widgets/table/e-tree-table-adapter.c b/widgets/table/e-tree-table-adapter.c
index 4514a7b15e..c4585f240a 100644
--- a/widgets/table/e-tree-table-adapter.c
+++ b/widgets/table/e-tree-table-adapter.c
@@ -913,7 +913,7 @@ e_tree_table_adapter_save_expanded_state (ETreeTableAdapter *etta, const char *f
e_xml_set_bool_prop_by_name (root, "default", tar.expanded_default);
g_hash_table_foreach (etta->priv->nodes, save_expanded_state_func, &tar);
-
+
e_xml_save_file (filename, doc);
xmlFreeDoc (doc);
}