aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2008-09-07 12:02:27 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-09-07 12:02:27 +0800
commit52d683e48cf1103a9806da95c72abce2db3ae1f4 (patch)
treeb6cee16af70a03666a2d7add2e5bff5c6ed8035c
parenteca687589d106ff87cd4fca7bf581cb0532caf96 (diff)
downloadgsoc2013-evolution-52d683e48cf1103a9806da95c72abce2db3ae1f4.tar
gsoc2013-evolution-52d683e48cf1103a9806da95c72abce2db3ae1f4.tar.gz
gsoc2013-evolution-52d683e48cf1103a9806da95c72abce2db3ae1f4.tar.bz2
gsoc2013-evolution-52d683e48cf1103a9806da95c72abce2db3ae1f4.tar.lz
gsoc2013-evolution-52d683e48cf1103a9806da95c72abce2db3ae1f4.tar.xz
gsoc2013-evolution-52d683e48cf1103a9806da95c72abce2db3ae1f4.tar.zst
gsoc2013-evolution-52d683e48cf1103a9806da95c72abce2db3ae1f4.zip
Progress update:
- Contacts module mostly working now. - View and search UI not yet working. - Still refining shell design. svn path=/branches/kill-bonobo/; revision=36268
-rw-r--r--Makefile.am2
-rw-r--r--a11y/Makefile.am3
-rw-r--r--addressbook/gui/component/Makefile.am1
-rw-r--r--addressbook/gui/component/addressbook-view.c14
-rw-r--r--addressbook/gui/component/e-book-shell-module.c2
-rw-r--r--addressbook/gui/component/e-book-shell-view-actions.c121
-rw-r--r--addressbook/gui/component/e-book-shell-view-actions.h10
-rw-r--r--addressbook/gui/component/e-book-shell-view-private.c61
-rw-r--r--addressbook/gui/component/e-book-shell-view-private.h14
-rw-r--r--addressbook/gui/widgets/Makefile.am5
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c399
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.h15
-rw-r--r--filter/Makefile.am1
-rw-r--r--shell/Makefile.am2
-rw-r--r--shell/e-shell-content.c3
-rw-r--r--shell/e-shell-module.c9
-rw-r--r--shell/e-shell-module.h2
-rw-r--r--shell/e-shell-sidebar.c46
-rw-r--r--shell/e-shell-sidebar.h1
-rw-r--r--shell/e-shell-switcher.c215
-rw-r--r--shell/e-shell-switcher.h3
-rw-r--r--shell/e-shell-view.c78
-rw-r--r--shell/e-shell-view.h4
-rw-r--r--shell/e-shell-window-actions.c132
-rw-r--r--shell/e-shell-window-actions.h10
-rw-r--r--shell/e-shell-window-private.c14
-rw-r--r--shell/e-shell-window-private.h9
-rw-r--r--shell/e-shell-window.c26
-rw-r--r--shell/test/e-test-shell-module.c2
-rw-r--r--ui/evolution-shell.ui9
-rw-r--r--widgets/misc/Makefile.am6
-rw-r--r--widgets/misc/e-filter-bar.c652
-rw-r--r--widgets/misc/e-filter-bar.h69
-rw-r--r--widgets/misc/e-icon-entry.c1
-rw-r--r--widgets/misc/e-search-bar.c142
-rw-r--r--widgets/misc/e-search-bar.h6
36 files changed, 1092 insertions, 997 deletions
diff --git a/Makefile.am b/Makefile.am
index 01907d1c03..785e39bf96 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -59,9 +59,9 @@ SUBDIRS = \
data \
e-util \
a11y \
+ filter \
widgets \
shell \
- filter \
$(SMIME_DIR) \
addressbook \
art \
diff --git a/a11y/Makefile.am b/a11y/Makefile.am
index 073b51fe0f..a1b0f8c68b 100644
--- a/a11y/Makefile.am
+++ b/a11y/Makefile.am
@@ -1,6 +1,5 @@
# Somewhat odd looking to have "." in SUBDIRS, but apparently it works?
-#SUBDIRS = e-text e-table . calendar widgets addressbook
-SUBDIRS = e-text e-table . calendar widgets
+SUBDIRS = e-text e-table . calendar widgets addressbook
if OS_WIN32
WIN32_BOOTSTRAP_LIBS = \
diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am
index b78e2ba0e1..adf68f4e15 100644
--- a/addressbook/gui/component/Makefile.am
+++ b/addressbook/gui/component/Makefile.am
@@ -60,7 +60,6 @@ libevolution_addressbook_la_LIBADD = \
$(top_builddir)/widgets/table/libetable.la \
$(top_builddir)/widgets/text/libetext.la \
$(top_builddir)/widgets/misc/libemiscwidgets.la \
- $(top_builddir)/widgets/misc/libefilterbar.la \
$(top_builddir)/widgets/menus/libmenus.la \
$(top_builddir)/a11y/addressbook/libevolution-addressbook-a11y.la \
$(top_builddir)/addressbook/importers/libevolution-addressbook-importers.la \
diff --git a/addressbook/gui/component/addressbook-view.c b/addressbook/gui/component/addressbook-view.c
index 992dd602f4..c3bb7c43d7 100644
--- a/addressbook/gui/component/addressbook-view.c
+++ b/addressbook/gui/component/addressbook-view.c
@@ -109,20 +109,6 @@ control_activate (BonoboControl *control,
EABView *v = get_current_view (view);
char *xmlfile;
- remote_ui_container = bonobo_control_get_remote_ui_container (control, NULL);
- bonobo_ui_component_set_container (uic, remote_ui_container, NULL);
- bonobo_object_release_unref (remote_ui_container, NULL);
-
- bonobo_ui_component_freeze (uic, NULL);
-
- xmlfile = g_build_filename (EVOLUTION_UIDIR,
- "evolution-addressbook.xml",
- NULL);
- bonobo_ui_util_set_ui (uic, PREFIX,
- xmlfile,
- "evolution-addressbook", NULL);
- g_free (xmlfile);
-
if (v)
eab_view_setup_menus (v, uic);
diff --git a/addressbook/gui/component/e-book-shell-module.c b/addressbook/gui/component/e-book-shell-module.c
index 1be7a6782d..08c372f220 100644
--- a/addressbook/gui/component/e-book-shell-module.c
+++ b/addressbook/gui/component/e-book-shell-module.c
@@ -42,6 +42,7 @@
#define MODULE_NAME "addressbook"
#define MODULE_ALIASES ""
#define MODULE_SCHEMES ""
+#define MODULE_SEARCHES "addresstypes.xml"
#define MODULE_SORT_ORDER 300
#define LDAP_BASE_URI "ldap://"
@@ -417,6 +418,7 @@ static EShellModuleInfo module_info = {
MODULE_NAME,
MODULE_ALIASES,
MODULE_SCHEMES,
+ MODULE_SEARCHES,
MODULE_SORT_ORDER,
/* Methods */
diff --git a/addressbook/gui/component/e-book-shell-view-actions.c b/addressbook/gui/component/e-book-shell-view-actions.c
index 5b07b84557..e5e08e34a2 100644
--- a/addressbook/gui/component/e-book-shell-view-actions.c
+++ b/addressbook/gui/component/e-book-shell-view-actions.c
@@ -364,6 +364,93 @@ action_contact_send_message_cb (GtkAction *action,
eab_view_send_to (view);
}
+static void
+action_search_execute_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ GtkWidget *widget;
+ GString *string;
+ EABView *view;
+ const gchar *search_format;
+ const gchar *search_text;
+ gchar *search_query;
+ gint value;
+
+ shell_view = E_SHELL_VIEW (book_shell_view);
+ if (!e_shell_view_is_selected (shell_view))
+ return;
+
+ /* Dig up the search text. */
+ widget = e_shell_view_get_content_widget (shell_view);
+ widget = e_shell_content_get_search_bar (E_SHELL_CONTENT (widget));
+ search_text = e_search_bar_get_search_text (E_SEARCH_BAR (widget));
+
+ shell_window = e_shell_view_get_window (shell_view);
+ action = ACTION (CONTACT_SEARCH_ANY_FIELD_CONTAINS);
+ value = gtk_radio_action_get_current_value (
+ GTK_RADIO_ACTION (action));
+
+ if (search_text == NULL || *search_text == '\0') {
+ search_text = "\"\"";
+ value = CONTACT_SEARCH_ANY_FIELD_CONTAINS;
+ }
+
+ switch (value) {
+ case CONTACT_SEARCH_NAME_CONTAINS:
+ search_format = "(contains \"full_name\" %s)";
+ break;
+
+ case CONTACT_SEARCH_EMAIL_BEGINS_WITH:
+ search_format = "(beginswith \"email\" %s)";
+ break;
+
+ default:
+ search_text = "\"\"";
+ /* fall through */
+
+ case CONTACT_SEARCH_ANY_FIELD_CONTAINS:
+ search_format =
+ "(contains \"x-evolution-any-field\" %s)";
+ break;
+ }
+
+ /* Build the query. */
+ string = g_string_new ("");
+ e_sexp_encode_string (string, search_text);
+ search_query = g_strdup_printf (search_format, string->str);
+ g_string_free (string, TRUE);
+
+ /* Filter by category. */
+ value = e_search_bar_get_filter_value (E_SEARCH_BAR (widget));
+ if (value >= 0) {
+ GList *categories;
+ const gchar *category_name;
+ gchar *temp;
+
+ categories = e_categories_get_list ();
+ category_name = g_list_nth_data (categories, value);
+ g_list_free (categories);
+
+ temp = g_strdup_printf (
+ "(and (is \"category_list\" \"%s\") %s)",
+ category_name, search_query);
+ g_free (search_query);
+ search_query = temp;
+ }
+
+ /* Submit the query. */
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_object_set (view, "query", search_query, NULL);
+ g_free (search_query);
+
+ view->displayed_contact = -1;
+ eab_contact_display_render (
+ EAB_CONTACT_DISPLAY (view->contact_display),
+ NULL, EAB_CONTACT_DISPLAY_RENDER_NORMAL);
+}
+
static GtkActionEntry contact_entries[] = {
{ "address-book-copy",
@@ -564,6 +651,30 @@ static GtkToggleActionEntry contact_toggle_entries[] = {
TRUE }
};
+static GtkRadioActionEntry contact_search_entries[] = {
+
+ { "contact-search-any-field-contains",
+ NULL,
+ N_("Any field contains"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ CONTACT_SEARCH_ANY_FIELD_CONTAINS },
+
+ { "contact-search-email-begins-with",
+ NULL,
+ N_("Email begins with"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ CONTACT_SEARCH_EMAIL_BEGINS_WITH },
+
+ { "contact-search-name-contains",
+ NULL,
+ N_("Name contains"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ CONTACT_SEARCH_NAME_CONTAINS }
+};
+
void
e_book_shell_view_actions_init (EBookShellView *book_shell_view)
{
@@ -592,6 +703,11 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view)
gtk_action_group_add_toggle_actions (
action_group, contact_toggle_entries,
G_N_ELEMENTS (contact_toggle_entries), book_shell_view);
+ gtk_action_group_add_radio_actions (
+ action_group, contact_search_entries,
+ G_N_ELEMENTS (contact_search_entries),
+ CONTACT_SEARCH_NAME_CONTAINS,
+ NULL, NULL);
gtk_ui_manager_insert_action_group (manager, action_group, 0);
/* Bind GObject properties to GConf keys. */
@@ -606,6 +722,10 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view)
action = ACTION (CONTACT_DELETE);
g_object_set (action, "short-label", _("Delete"), NULL);
+
+ g_signal_connect (
+ ACTION (SEARCH_EXECUTE), "activate",
+ G_CALLBACK (action_search_execute_cb), book_shell_view);
}
void
@@ -694,4 +814,3 @@ e_book_shell_view_update_actions (EBookShellView *book_shell_view,
sensitive = FALSE;
gtk_action_set_sensitive (action, sensitive);
}
-
diff --git a/addressbook/gui/component/e-book-shell-view-actions.h b/addressbook/gui/component/e-book-shell-view-actions.h
index bce21fe634..a809eeacf9 100644
--- a/addressbook/gui/component/e-book-shell-view-actions.h
+++ b/addressbook/gui/component/e-book-shell-view-actions.h
@@ -43,7 +43,7 @@
#define E_SHELL_WINDOW_ACTION_CONTACT_CLIPBOARD_COPY(window) \
E_SHELL_WINDOW_ACTION ((window), "contact-clipboard-copy")
#define E_SHELL_WINDOW_ACTION_CONTACT_CLIPBOARD_CUT(window) \
- E_SHELL_WINDOW_ACTION ((window), "contact-clipbard-cut")
+ E_SHELL_WINDOW_ACTION ((window), "contact-clipboard-cut")
#define E_SHELL_WINDOW_ACTION_CONTACT_CLIPBOARD_PASTE(window) \
E_SHELL_WINDOW_ACTION ((window), "contact-clipboard-paste")
#define E_SHELL_WINDOW_ACTION_CONTACT_COPY(window) \
@@ -73,6 +73,14 @@
#define E_SHELL_WINDOW_ACTION_CONTACT_SEND_MESSAGE(window) \
E_SHELL_WINDOW_ACTION ((window), "contact-send-message")
+/* Search Actions */
+#define E_SHELL_WINDOW_ACTION_CONTACT_SEARCH_ANY_FIELD_CONTAINS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-search-any-field-contains")
+#define E_SHELL_WINDOW_ACTION_CONTACT_SEARCH_EMAIL_BEGINS_WITH(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-search-email-begins-with")
+#define E_SHELL_WINDOW_ACTION_CONTACT_SEARCH_NAME_CONTAINS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-search-name-contains")
+
/* Action Groups */
#define E_SHELL_WINDOW_ACTION_GROUP_CONTACTS(window) \
E_SHELL_WINDOW_ACTION_GROUP ((window), "contacts")
diff --git a/addressbook/gui/component/e-book-shell-view-private.c b/addressbook/gui/component/e-book-shell-view-private.c
index b75a8c6f60..71be4b5254 100644
--- a/addressbook/gui/component/e-book-shell-view-private.c
+++ b/addressbook/gui/component/e-book-shell-view-private.c
@@ -75,17 +75,20 @@ set_folder_bar_message (EABView *view,
EShellView *shell_view;
EABView *current_view;
+ GtkWidget *widget;
const gchar *name;
shell_view = E_SHELL_VIEW (book_shell_view);
+
current_view = e_book_shell_view_get_current_view (book_shell_view);
if (view != current_view || view->source == NULL)
return;
name = e_source_peek_name (view->source);
+ widget = e_shell_view_get_sidebar_widget (shell_view);
- e_shell_view_set_primary_text (shell_view, name);
- e_shell_view_set_secondary_text (shell_view, message);
+ e_shell_sidebar_set_primary_text (E_SHELL_SIDEBAR (widget), name);
+ e_shell_sidebar_set_secondary_text (E_SHELL_SIDEBAR (widget), message);
}
static void
@@ -229,6 +232,12 @@ book_shell_view_show_popup_menu (GdkEventButton *event,
return TRUE;
}
+static void
+book_shell_view_categories_changed_cb (EBookShellView *book_shell_view)
+{
+ e_book_shell_view_update_search_filter (book_shell_view);
+}
+
static gboolean
book_shell_view_selector_button_press_event_cb (EShellView *shell_view,
GdkEventButton *event)
@@ -309,6 +318,7 @@ e_book_shell_view_private_init (EBookShellView *book_shell_view)
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
gtk_container_add (GTK_CONTAINER (container), widget);
+ priv->notebook = g_object_ref (widget);
gtk_widget_show (widget);
widget = e_shell_view_get_taskbar_widget (shell_view);
@@ -354,6 +364,11 @@ e_book_shell_view_private_init (EBookShellView *book_shell_view)
book_shell_view);
book_shell_view_activate_selected_source (book_shell_view);
+
+ e_categories_register_change_listener (
+ G_CALLBACK (book_shell_view_categories_changed_cb),
+ book_shell_view);
+ e_book_shell_view_update_search_filter (book_shell_view);
}
void
@@ -364,9 +379,7 @@ e_book_shell_view_private_dispose (EBookShellView *book_shell_view)
DISPOSE (priv->contact_actions);
DISPOSE (priv->notebook);
- DISPOSE (priv->scrolled_window);
DISPOSE (priv->selector);
- DISPOSE (priv->task_bar);
DISPOSE (priv->activity_handler);
@@ -413,3 +426,43 @@ e_book_shell_view_editor_weak_notify (EditorUidClosure *closure,
hash_table = closure->view->priv->uid_to_editor;
g_hash_table_remove (hash_table, closure->uid);
}
+
+void
+e_book_shell_view_update_search_filter (EBookShellView *book_shell_view)
+{
+ EShellView *shell_view;
+ GtkRadioAction *action;
+ GtkWidget *widget;
+ GList *list, *iter;
+ GSList *group = NULL;
+ gint ii;
+
+ /* Dig up the search bar. */
+ shell_view = E_SHELL_VIEW (book_shell_view);
+ widget = e_shell_view_get_content_widget (shell_view);
+ widget = e_shell_content_get_search_bar (E_SHELL_CONTENT (widget));
+
+ action = gtk_radio_action_new (
+ "category-any", _("Any Category"), NULL, NULL, -1);
+
+ gtk_radio_action_set_group (action, group);
+ group = gtk_radio_action_get_group (action);
+
+ list = e_categories_get_list ();
+ for (iter = list, ii = 0; iter != NULL; iter = iter->next, ii++) {
+ const gchar *category_name = iter->data;
+ gchar *action_name;
+
+ action_name = g_strdup_printf ("category-%d", ii);
+ action = gtk_radio_action_new (
+ action_name, category_name, NULL, NULL, ii);
+ g_free (action_name);
+
+ gtk_radio_action_set_group (action, group);
+ group = gtk_radio_action_get_group (action);
+ }
+ g_list_free (list);
+
+ /* Use any action in the group; doesn't matter which. */
+ e_search_bar_set_filter_action (E_SEARCH_BAR (widget), action);
+}
diff --git a/addressbook/gui/component/e-book-shell-view-private.h b/addressbook/gui/component/e-book-shell-view-private.h
index 130e061dcd..80fb21dbde 100644
--- a/addressbook/gui/component/e-book-shell-view-private.h
+++ b/addressbook/gui/component/e-book-shell-view-private.h
@@ -27,8 +27,13 @@
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
#include <libebook/e-book.h>
+#include <libedataserver/e-categories.h>
+#include <libedataserver/e-sexp.h>
#include <libedataserverui/e-source-selector.h>
+#include <shell/e-shell-content.h>
+#include <shell/e-shell-sidebar.h>
+
#include <eab-menu.h>
#include <eab-gui-util.h>
#include <e-activity-handler.h>
@@ -67,6 +72,13 @@ struct _EditorUidClosure {
EBookShellView *view;
};
+/* List these in the order to be displayed. */
+enum {
+ CONTACT_SEARCH_NAME_CONTAINS,
+ CONTACT_SEARCH_EMAIL_BEGINS_WITH,
+ CONTACT_SEARCH_ANY_FIELD_CONTAINS
+};
+
struct _EBookShellViewPrivate {
/*** UI Management ***/
@@ -110,6 +122,8 @@ EABView * e_book_shell_view_get_current_view
void e_book_shell_view_editor_weak_notify
(EditorUidClosure *closure,
GObject *where_the_object_was);
+void e_book_shell_view_update_search_filter
+ (EBookShellView *book_shell_view);
G_END_DECLS
diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am
index c39598f516..af8a069800 100644
--- a/addressbook/gui/widgets/Makefile.am
+++ b/addressbook/gui/widgets/Makefile.am
@@ -7,6 +7,7 @@ INCLUDES = \
-DEVOLUTION_GALVIEWSDIR=\""$(viewsdir)"\" \
-DSEARCH_RULE_DIR=\"$(ruledir)\" \
-I$(top_srcdir) \
+ -I$(top_srcdir)/filter \
-I$(top_srcdir)/widgets \
-I$(top_srcdir)/addressbook \
-I$(top_srcdir)/addressbook/gui/contact-editor \
@@ -80,5 +81,5 @@ etspec_DATA= e-addressbook-view.etspec
EXTRA_DIST = \
$(etspec_DATA) \
- eab-marshal.list \
- addresstypes.xml
+ $(rule_DATA) \
+ eab-marshal.list
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index d44898ba1a..3a221342d8 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -98,13 +98,6 @@ static void selection_get (GtkWidget *invisible, GtkSelectionData *selection_dat
guint info, guint time_stamp, EABView *view);
static void invisible_destroyed (gpointer data, GObject *where_object_was);
-static void categories_changed_cb (gpointer object, gpointer user_data);
-static void make_suboptions (EABView *view);
-static void query_changed (ESearchBar *esb, EABView *view);
-static void search_activated (ESearchBar *esb, EABView *view);
-static void search_menu_activated (ESearchBar *esb, int id, EABView *view);
-static GList *get_master_list (gboolean force_rebuild);
-
static gpointer parent_class;
/* The arguments we take */
@@ -131,11 +124,6 @@ enum DndTargetType {
#define VCARD_TYPE "text/x-vcard"
#define SOURCE_VCARD_TYPE "text/x-source-vcard"
-typedef struct EABSearchBarItem {
- ESearchBarItem search;
- char *image;
-}EABSearchBarItem;
-
static GtkTargetEntry drag_types[] = {
{ SOURCE_VCARD_TYPE, 0, DND_TARGET_TYPE_SOURCE_VCARD },
{ VCARD_TYPE, 0, DND_TARGET_TYPE_VCARD }
@@ -148,29 +136,6 @@ static GdkAtom clipboard_atom = GDK_NONE;
static GalViewCollection *collection = NULL;
-enum {
- ESB_FULL_NAME,
- ESB_EMAIL,
- ESB_ANY,
-};
-
-#if 0
-static ESearchBarItem addressbook_search_option_items[] = {
- { N_("Name begins with"), ESB_FULL_NAME },
- { N_("Email begins with"), ESB_EMAIL },
- { N_("Any field contains"), ESB_ANY },
- { NULL, -1 }
-};
-#endif
-
-static ESearchBarItem addressbook_search_items[] = {
- E_FILTERBAR_ADVANCED,
- {NULL, 0, 0},
- E_FILTERBAR_SAVE,
- E_FILTERBAR_EDIT,
- {NULL, -1, 0}
-};
-
GType
eab_view_get_type (void)
{
@@ -295,7 +260,6 @@ eab_view_init (EABView *eav)
eav->view_instance = NULL;
/*eav->view_menus = NULL;*/
eav->current_view = NULL;
- eav->uic = NULL;
eav->book = NULL;
eav->source = NULL;
@@ -310,8 +274,6 @@ eab_view_dispose (GObject *object)
{
EABView *eav = EAB_VIEW(object);
- e_categories_unregister_change_listener (G_CALLBACK (categories_changed_cb), eav);
-
if (eav->model) {
g_signal_handlers_disconnect_matched (eav->model,
G_SIGNAL_MATCH_DATA,
@@ -336,8 +298,6 @@ eab_view_dispose (GObject *object)
eav->query = NULL;
}
- eav->uic = NULL;
-
if (eav->view_instance) {
g_object_unref (eav->view_instance);
eav->view_instance = NULL;
@@ -359,18 +319,6 @@ eab_view_dispose (GObject *object)
eav->invisible = NULL;
}
- /*
- if (eav->search_context) {
- g_object_unref (eav->search_context);
- eav->search_context = NULL;
- }
- */
-
- if (eav->search_rule) {
- g_object_unref (eav->search_rule);
- eav->search_rule = NULL;
- }
-
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -413,9 +361,6 @@ eab_view_new (void)
{
GtkWidget *widget = GTK_WIDGET (g_object_new (E_TYPE_AB_VIEW, NULL));
EABView *eav = EAB_VIEW (widget);
- FilterPart *part;
- char *xmlfile;
- char *userfile;
/* create our model */
eav->model = eab_model_new ();
@@ -440,49 +385,6 @@ eab_view_new (void)
eav->editable = FALSE;
eav->query = g_strdup (SHOW_ALL_SEARCH);
- /* create the search context */
- eav->search_context = rule_context_new ();
- rule_context_add_part_set (eav->search_context, "partset", filter_part_get_type (),
- rule_context_add_part, rule_context_next_part);
- rule_context_add_rule_set (eav->search_context, "ruleset", filter_rule_get_type (),
- rule_context_add_rule, rule_context_next_rule);
-
- userfile = g_build_filename ( g_get_home_dir (), ".evolution/addressbook/searches.xml", NULL);
- xmlfile = g_build_filename (SEARCH_RULE_DIR, "addresstypes.xml", NULL);
-
- g_object_set_data_full (G_OBJECT (eav->search_context), "user", userfile, g_free);
- g_object_set_data_full (G_OBJECT (eav->search_context), "system", xmlfile, g_free);
-
- rule_context_load (eav->search_context, xmlfile, userfile);
-
- eav->search_rule = filter_rule_new ();
- part = rule_context_next_part (eav->search_context, NULL);
-
- if (part == NULL)
- g_warning ("Could not load addressbook search; no parts.");
- else
- filter_rule_add_part (eav->search_rule, filter_part_clone (part));
-
- eav->search = e_filter_bar_new (eav->search_context, xmlfile, userfile, NULL, eav);
-
- g_free (xmlfile);
- g_free (userfile);
-
- e_search_bar_set_menu ( (ESearchBar *) eav->search, addressbook_search_items);
- gtk_widget_show (GTK_WIDGET (eav->search));
- make_suboptions (eav);
-
- e_categories_register_change_listener (G_CALLBACK (categories_changed_cb), eav);
-
- g_signal_connect (eav->search, "query_changed",
- G_CALLBACK (query_changed), eav);
- g_signal_connect (eav->search, "search_activated",
- G_CALLBACK (search_activated), eav);
- g_signal_connect (eav->search, "menu_activated",
- G_CALLBACK (search_menu_activated), eav);
-
- gtk_box_pack_start (GTK_BOX (eav), GTK_WIDGET (eav->search), FALSE, FALSE, 0);
-
/* create the paned window and contact display */
eav->paned = gtk_vpaned_new ();
gtk_box_pack_start (GTK_BOX (eav), eav->paned, TRUE, TRUE, 0);
@@ -521,18 +423,6 @@ eab_view_new (void)
return widget;
}
-RuleContext *
-eab_view_peek_search_context (EABView *view)
-{
- return view->search_context;
-}
-
-FilterRule *
-eab_view_peek_search_rule (EABView *view)
-{
- return view->search_rule;
-}
-
static void
writable_status (GtkObject *object, gboolean writable, EABView *eav)
{
@@ -560,24 +450,6 @@ display_view(GalViewInstance *instance,
}
static void
-setup_menus (EABView *view)
-{
- if (view->book && view->view_instance == NULL) {
- view->view_instance = gal_view_instance_new (collection, e_book_get_uri (view->book));
- }
-
- if (view->view_instance && view->uic) {
- /*view->view_menus = gal_view_menus_new(view->view_instance);
- gal_view_menus_apply(view->view_menus, view->uic, NULL);*/
-
- display_view (view->view_instance, gal_view_instance_get_current_view (view->view_instance), view);
-
- g_signal_connect(view->view_instance, "display_view",
- G_CALLBACK (display_view), view);
- }
-}
-
-static void
eab_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
EABView *eav = EAB_VIEW(object);
@@ -590,11 +462,9 @@ eab_view_set_property (GObject *object, guint prop_id, const GValue *value, GPar
if (g_value_get_object (value)) {
eav->book = E_BOOK(g_value_get_object (value));
g_object_ref (eav->book);
- gtk_widget_set_sensitive (GTK_WIDGET (eav->search), TRUE);
}
else {
eav->book = NULL;
- gtk_widget_set_sensitive (GTK_WIDGET (eav->search), FALSE);
}
if (eav->view_instance) {
@@ -606,8 +476,6 @@ eab_view_set_property (GObject *object, guint prop_id, const GValue *value, GPar
"book", eav->book,
NULL);
- setup_menus (eav);
-
break;
case PROP_SOURCE:
if (eav->source) {
@@ -1263,225 +1131,6 @@ change_view_type (EABView *view, EABViewType view_type)
command_state_change (view);
}
-
-
-static void
-search_activated (ESearchBar *esb, EABView *v)
-{
- GList *master_list;
- char *search_word, *search_query, *view_sexp;
- const char *category_name;
- int search_type, subid;
-
- 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));
- }
- else {
- if ((search_word && strlen (search_word))) {
- GString *s = g_string_new ("");
- e_sexp_encode_string (s, search_word);
- switch (search_type) {
- case ESB_ANY:
- search_query = g_strdup_printf ("(contains \"x-evolution-any-field\" %s)",
- s->str);
- break;
- case ESB_FULL_NAME:
- search_query = g_strdup_printf ("(contains \"full_name\" %s)",
- s->str);
- break;
- case ESB_EMAIL:
- search_query = g_strdup_printf ("(beginswith \"email\" %s)",
- s->str);
- break;
- default:
- search_query = g_strdup ("(contains \"x-evolution-any-field\" \"\")");
- break;
- }
- g_string_free (s, TRUE);
-
- } else
- search_query = g_strdup ("(contains \"x-evolution-any-field\" \"\")");
-
- /* Merge view and sexp */
- subid = e_search_bar_get_viewitem_id (esb);
-
- if (subid) {
- master_list = get_master_list (FALSE);
- category_name = g_list_nth_data (master_list, subid-1);
- 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,
- NULL);
-
- g_free (search_query);
- }
-
- g_free (search_word);
- v->displayed_contact = -1;
- eab_contact_display_render (EAB_CONTACT_DISPLAY (v->contact_display), NULL,
- EAB_CONTACT_DISPLAY_RENDER_NORMAL);
-}
-
-static void
-search_menu_activated (ESearchBar *esb, int id, EABView *view)
-{
- if (id == E_FILTERBAR_ADVANCED_ID)
- e_search_bar_set_item_id (esb, id);
-}
-
-static void
-query_changed (ESearchBar *esb, EABView *view)
-{
- int search_type;
- char *query;
-
- search_type = e_search_bar_get_item_id(esb);
- if (search_type == E_FILTERBAR_ADVANCED_ID) {
- g_object_get (esb, "query", &query, NULL);
- g_object_set (view, "query", query, NULL);
- g_free (query);
- }
-}
-
-static int
-compare_subitems (const void *a, const void *b)
-{
- const ESearchBarItem *subitem_a = a;
- const ESearchBarItem *subitem_b = b;
- char *collate_a, *collate_b;
- int ret;
-
- collate_a = g_utf8_collate_key (subitem_a->text, -1);
- collate_b = g_utf8_collate_key (subitem_b->text, -1);
-
- ret = strcmp (collate_a, collate_b);
-
- g_free (collate_a);
- g_free (collate_b);
-
- return ret;
-}
-
-static GtkWidget *
-generate_viewoption_menu (EABSearchBarItem *subitems)
-{
- GtkWidget *menu, *menu_item;
- gint i = 0;
-
- menu = gtk_menu_new ();
-
- for (i = 0; subitems[i].search.id != -1; ++i) {
- if (subitems[i].search.text) {
- char *str = NULL;
- str = e_str_without_underscores (subitems[i].search.text);
- menu_item = gtk_image_menu_item_new_with_label (str);
- if (subitems[i].image) {
- GtkWidget *image;
-
- image = gtk_image_new_from_icon_name (
- subitems[i].image,
- GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (
- GTK_IMAGE_MENU_ITEM (menu_item),
- image);
- }
- 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].search.id));
-
- gtk_widget_show (menu_item);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
- }
-
- return menu;
-}
-
-static void
-categories_changed_cb (gpointer object, gpointer user_data)
-{
- get_master_list (TRUE);
- make_suboptions (user_data);
-}
-
-static void
-make_suboptions (EABView *view)
-{
- EABSearchBarItem *subitems, *s;
- GList *master_list;
- gint i, N;
- GtkWidget *menu;
-
- master_list = get_master_list (FALSE);
- N = g_list_length (master_list);
- subitems = g_new (EABSearchBarItem, N+2);
-
- subitems[0].search.id = 0;
- subitems[0].search.text = g_strdup (_("Any Category"));
- subitems[0].image = NULL;
-
- for (i=0; i<N; ++i) {
- const char *category = g_list_nth_data (master_list, i);
- subitems[i+1].search.id = i+1;
- subitems[i+1].search.text = g_strdup (category);
- subitems[i+1].image = (char *)e_categories_get_icon_file_for (category);
- }
-
- subitems[N+1].search.id = -1;
- subitems[N+1].search.text = NULL;
- subitems[N+1].image = NULL;
-
- qsort (subitems + 1, N, sizeof (subitems[0]), compare_subitems);
- menu = generate_viewoption_menu (subitems);
- e_search_bar_set_viewoption_menu ((ESearchBar *)view->search, menu);
-
- for (s = subitems; ((ESearchBarItem *)s)->id != -1; s++) {
- if (((ESearchBarItem *)s)->text)
- g_free (((ESearchBarItem *)s)->text);
- }
- g_free (subitems);
-}
-
-static GList *
-get_master_list (gboolean force_rebuild)
-{
- static GList *category_list = NULL;
-
- if (force_rebuild) {
- g_list_free (category_list);
- category_list = NULL;
- }
-
- if (category_list == NULL) {
- GList *l, *p = e_categories_get_list ();
-
- for (l = p; l; l = l->next) {
- if (e_categories_is_searchable ((const char *) l->data))
- category_list = g_list_prepend (category_list, l->data);
- }
-
- category_list = g_list_reverse (category_list);
-
- g_list_free (p);
- }
-
- return category_list;
-}
-
static void
contact_print_button_draw_page (GtkPrintOperation *operation,
GtkPrintContext *context,
@@ -1536,54 +1185,6 @@ eab_view_show_contact_preview (EABView *view, gboolean show)
}
void
-eab_view_setup_menus (EABView *view,
- BonoboUIComponent *uic)
-{
-
- g_return_if_fail (view != NULL);
- g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view));
- g_return_if_fail (uic != NULL);
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (uic));
-
- view->uic = uic;
-
- setup_menus (view);
-
- /* XXX toshok - yeah this really doesn't belong here, but it
- needs to happen at the same time and takes the uic */
- e_search_bar_set_ui_component ( (ESearchBar *)view->search, uic);
-}
-
-/**
- * eab_view_discard_menus:
- * @view: An addressbook view.
- *
- * Makes an addressbook view discard its GAL view menus and its views instance
- * objects. This should be called when the corresponding Bonobo component is
- * deactivated.
- **/
-void
-eab_view_discard_menus (EABView *view)
-{
- g_return_if_fail (view != NULL);
- g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view));
-
- /*if (view->view_menus) {
- gal_view_menus_unmerge (view->view_menus, NULL);
-
- g_object_unref (view->view_menus);
- view->view_menus = NULL;
- }*/
-
- if (view->view_instance) {
- g_object_unref (view->view_instance);
- view->view_instance = NULL;
- }
-
- view->uic = NULL;
-}
-
-void
eab_view_print (EABView *view, GtkPrintOperationAction action)
{
if (view->view_type == EAB_VIEW_MINICARD) {
diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h
index af5d50a78f..eae3b54861 100644
--- a/addressbook/gui/widgets/e-addressbook-view.h
+++ b/addressbook/gui/widgets/e-addressbook-view.h
@@ -27,7 +27,6 @@
#include "e-addressbook-model.h"
#include "eab-contact-display.h"
#include "misc/e-search-bar.h"
-#include "misc/e-filter-bar.h"
/* Standard GObject macros */
#define E_TYPE_AB_VIEW \
@@ -92,13 +91,6 @@ struct _EABView {
GalViewInstance *view_instance;
/*GalViewMenus *view_menus;*/
GalView *current_view;
- BonoboUIComponent *uic;
-
- /* the search bar and related machinery */
- EFilterBar *search;
- gint ecml_changed_id;
- RuleContext *search_context;
- FilterRule *search_rule;
};
struct _EABViewClass {
@@ -115,13 +107,6 @@ GType eab_view_get_type (void);
GtkWidget * eab_view_new (void);
void eab_view_show_contact_preview (EABView *view,
gboolean show);
-void eab_view_setup_menus (EABView *view,
- BonoboUIComponent *uic);
-void eab_view_discard_menus (EABView *view);
-
-RuleContext * eab_view_peek_search_context (EABView *view);
-FilterRule * eab_view_peek_search_rule (EABView *view);
-
void eab_view_save_as (EABView *view,
gboolean all);
void eab_view_view (EABView *view);
diff --git a/filter/Makefile.am b/filter/Makefile.am
index 72cebb002a..e15deb1a3c 100644
--- a/filter/Makefile.am
+++ b/filter/Makefile.am
@@ -4,7 +4,6 @@ glade_DATA = filter.glade
INCLUDES = \
-I $(top_srcdir) \
-I $(top_srcdir)/e-util \
- -I $(top_srcdir)/widgets/misc \
-DEVOLUTION_GLADEDIR=\"$(gladedir)\" \
-DG_LOG_DOMAIN=\"filter\" \
$(LIBFILTER_CFLAGS)
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 7bedc4e46d..c593548b6d 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -3,6 +3,7 @@ SUBDIRS = . test
endif
INCLUDES = \
+ -I$(top_srcdir)/e-util \
-I$(top_srcdir)/widgets \
-I$(top_srcdir)/widgets/menus \
-I$(top_srcdir)/widgets/misc \
@@ -15,6 +16,7 @@ INCLUDES = \
-DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \
-DEVOLUTION_HELPDIR=\""$(evolutionhelpdir)"\" \
-DEVOLUTION_MODULEDIR=\""$(moduledir)"\" \
+ -DEVOLUTION_RULEDIR=\""$(ruledir)"\" \
-DEVOLUTION_UIDIR=\""$(evolutionuidir)"\" \
-DEVOLUTION_TOOLSDIR=\""$(privlibexecdir)"\" \
-DPREFIX=\""$(prefix)"\" \
diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c
index 22b2bc8af8..6671e5505e 100644
--- a/shell/e-shell-content.c
+++ b/shell/e-shell-content.c
@@ -94,7 +94,8 @@ shell_content_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (child, &child_allocation);
child_allocation.y += child_requisition.height;
- child_allocation.height = allocation->height - child_allocation.y;
+ child_allocation.height =
+ allocation->height - child_requisition.height;
child = gtk_bin_get_child (GTK_BIN (widget));
if (child != NULL)
diff --git a/shell/e-shell-module.c b/shell/e-shell-module.c
index ed8d2411f1..75dbc3756f 100644
--- a/shell/e-shell-module.c
+++ b/shell/e-shell-module.c
@@ -303,6 +303,14 @@ e_shell_module_get_filename (EShellModule *shell_module)
return shell_module->priv->filename;
}
+const gchar *
+e_shell_module_get_searches (EShellModule *shell_module)
+{
+ g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), NULL);
+
+ return shell_module->priv->info.searches;
+}
+
EShell *
e_shell_module_get_shell (EShellModule *shell_module)
{
@@ -361,6 +369,7 @@ e_shell_module_set_info (EShellModule *shell_module,
module_info->aliases = g_intern_string (info->aliases);
module_info->schemes = g_intern_string (info->schemes);
+ module_info->searches = g_intern_string (info->searches);
module_info->sort_order = info->sort_order;
module_info->is_busy = info->is_busy;
diff --git a/shell/e-shell-module.h b/shell/e-shell-module.h
index d643d94527..7e2722f210 100644
--- a/shell/e-shell-module.h
+++ b/shell/e-shell-module.h
@@ -53,6 +53,7 @@ struct _EShellModuleInfo {
const gchar *name;
const gchar *aliases; /* colon-separated list */
const gchar *schemes; /* colon-separated list */
+ const gchar *searches; /* built-in search rules */
gint sort_order;
gboolean (*is_busy) (EShellModule *shell_module);
@@ -75,6 +76,7 @@ gint e_shell_module_compare (EShellModule *shell_module_a,
EShellModule *shell_module_b);
const gchar * e_shell_module_get_data_dir (EShellModule *shell_module);
const gchar * e_shell_module_get_filename (EShellModule *shell_module);
+const gchar * e_shell_module_get_searches (EShellModule *shell_module);
EShell * e_shell_module_get_shell (EShellModule *shell_module);
gboolean e_shell_module_is_busy (EShellModule *shell_module);
gboolean e_shell_module_shutdown (EShellModule *shell_module);
diff --git a/shell/e-shell-sidebar.c b/shell/e-shell-sidebar.c
index 30917fd25c..32b31a83c9 100644
--- a/shell/e-shell-sidebar.c
+++ b/shell/e-shell-sidebar.c
@@ -29,7 +29,6 @@ struct _EShellSidebarPrivate {
GtkWidget *image;
GtkWidget *primary_label;
GtkWidget *secondary_label;
- GtkSizeGroup *size_group;
gchar *primary_text;
gchar *secondary_text;
};
@@ -45,9 +44,9 @@ static gpointer parent_class;
static void
shell_sidebar_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
case PROP_ICON_NAME:
@@ -74,9 +73,9 @@ shell_sidebar_set_property (GObject *object,
static void
shell_sidebar_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
case PROP_ICON_NAME:
@@ -108,11 +107,6 @@ shell_sidebar_dispose (GObject *object)
priv = E_SHELL_SIDEBAR_GET_PRIVATE (object);
- if (priv->size_group != NULL) {
- g_object_unref (priv->size_group);
- priv->size_group = NULL;
- }
-
if (priv->event_box != NULL) {
g_object_unref (priv->event_box);
priv->event_box = NULL;
@@ -175,7 +169,7 @@ shell_sidebar_size_request (GtkWidget *widget,
static void
shell_sidebar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
+ GtkAllocation *allocation)
{
EShellSidebarPrivate *priv;
GtkAllocation child_allocation;
@@ -197,7 +191,8 @@ shell_sidebar_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (child, &child_allocation);
child_allocation.y += child_requisition.height;
- child_allocation.height = allocation->height - child_allocation.y;
+ child_allocation.height =
+ allocation->height - child_requisition.height;
child = gtk_bin_get_child (GTK_BIN (widget));
if (child != NULL)
@@ -206,7 +201,7 @@ shell_sidebar_size_allocate (GtkWidget *widget,
static void
shell_sidebar_remove (GtkContainer *container,
- GtkWidget *widget)
+ GtkWidget *widget)
{
EShellSidebarPrivate *priv;
@@ -226,9 +221,9 @@ shell_sidebar_remove (GtkContainer *container,
static void
shell_sidebar_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data)
{
EShellSidebarPrivate *priv;
@@ -306,7 +301,6 @@ shell_sidebar_init (EShellSidebar *shell_sidebar)
GtkStyle *style;
GtkWidget *container;
GtkWidget *widget;
- GtkSizeGroup *size_group;
const GdkColor *color;
shell_sidebar->priv = E_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar);
@@ -349,10 +343,6 @@ shell_sidebar_init (EShellSidebar *shell_sidebar)
gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
shell_sidebar->priv->secondary_label = g_object_ref (widget);
gtk_widget_show (widget);
-
- size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
- gtk_size_group_add_widget (size_group, shell_sidebar->priv->event_box);
- shell_sidebar->priv->size_group = size_group;
}
GType
@@ -461,7 +451,7 @@ e_shell_sidebar_get_secondary_text (EShellSidebar *shell_sidebar)
void
e_shell_sidebar_set_secondary_text (EShellSidebar *shell_sidebar,
- const gchar *secondary_text)
+ const gchar *secondary_text)
{
GtkLabel *label;
gchar *markup;
@@ -482,11 +472,3 @@ e_shell_sidebar_set_secondary_text (EShellSidebar *shell_sidebar,
gtk_widget_queue_resize (GTK_WIDGET (shell_sidebar));
g_object_notify (G_OBJECT (shell_sidebar), "secondary-text");
}
-
-GtkSizeGroup *
-e_shell_sidebar_get_size_group (EShellSidebar *shell_sidebar)
-{
- g_return_val_if_fail (E_IS_SHELL_SIDEBAR (shell_sidebar), NULL);
-
- return shell_sidebar->priv->size_group;
-}
diff --git a/shell/e-shell-sidebar.h b/shell/e-shell-sidebar.h
index d674339ef7..70777b80fd 100644
--- a/shell/e-shell-sidebar.h
+++ b/shell/e-shell-sidebar.h
@@ -72,7 +72,6 @@ const gchar * e_shell_sidebar_get_secondary_text
void e_shell_sidebar_set_secondary_text
(EShellSidebar *shell_sidebar,
const gchar *secondary_text);
-GtkSizeGroup * e_shell_sidebar_get_size_group (EShellSidebar *shell_sidebar);
G_END_DECLS
diff --git a/shell/e-shell-switcher.c b/shell/e-shell-switcher.c
index bfcae011bc..f9cf1810b7 100644
--- a/shell/e-shell-switcher.c
+++ b/shell/e-shell-switcher.c
@@ -33,11 +33,13 @@ struct _EShellSwitcherPrivate {
GtkToolbarStyle style;
GtkSettings *settings;
gulong settings_handler_id;
+ gboolean toolbar_visible;
};
enum {
PROP_0,
- PROP_TOOLBAR_STYLE
+ PROP_TOOLBAR_STYLE,
+ PROP_TOOLBAR_VISIBLE
};
enum {
@@ -48,21 +50,25 @@ enum {
static gpointer parent_class;
static guint signals[LAST_SIGNAL];
-static void
-switcher_layout_actions (EShellSwitcher *switcher)
+static gint
+shell_switcher_layout_actions (EShellSwitcher *switcher)
{
- GtkAllocation *allocation = & GTK_WIDGET (switcher)->allocation;
- gboolean icons_only;
+ GtkAllocation *allocation;
int num_btns = g_list_length (switcher->priv->proxies), btns_per_row;
GList **rows, *p;
- int row_number;
- int max_width = 0, max_height = 0;
- int row_last;
- int x, y;
- int i;
+ gboolean icons_only;
+ gint row_number;
+ gint max_width = 0;
+ gint max_height = 0;
+ gint row_last;
+ gint x, y;
+ gint i;
+
+ allocation = &GTK_WIDGET (switcher)->allocation;
+ y = allocation->y + allocation->height;
if (num_btns == 0)
- return;
+ return allocation->height;
icons_only = (switcher->priv->style == GTK_TOOLBAR_ICONS);
@@ -111,11 +117,11 @@ switcher_layout_actions (EShellSwitcher *switcher)
row_last = row_number;
/* Layout the buttons. */
- y = allocation->y;
for (i = 0; i < row_last + 1; i++) {
int len, extra_width;
x = H_PADDING + allocation->x;
+ y -= max_height;
len = g_list_length (rows[i]);
if (!icons_only)
extra_width = (allocation->width - (len * max_width ) - (len * H_PADDING)) / len;
@@ -134,16 +140,18 @@ switcher_layout_actions (EShellSwitcher *switcher)
x += child_allocation.width + H_PADDING;
}
- y += max_height + V_PADDING;
+ y -= V_PADDING;
}
for (i = 0; i <= row_last; i ++)
g_list_free (rows [i]);
g_free (rows);
+
+ return y - allocation->y;
}
static void
-switcher_toolbar_style_changed_cb (EShellSwitcher *switcher)
+shell_switcher_toolbar_style_changed_cb (EShellSwitcher *switcher)
{
if (!switcher->priv->style_set) {
switcher->priv->style_set = TRUE;
@@ -152,10 +160,10 @@ switcher_toolbar_style_changed_cb (EShellSwitcher *switcher)
}
static void
-switcher_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+shell_switcher_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
case PROP_TOOLBAR_STYLE:
@@ -163,16 +171,22 @@ switcher_set_property (GObject *object,
E_SHELL_SWITCHER (object),
g_value_get_enum (value));
return;
+
+ case PROP_TOOLBAR_VISIBLE:
+ e_shell_switcher_set_visible (
+ E_SHELL_SWITCHER (object),
+ g_value_get_boolean (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
-switcher_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+shell_switcher_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
case PROP_TOOLBAR_STYLE:
@@ -180,13 +194,19 @@ switcher_get_property (GObject *object,
value, e_shell_switcher_get_style (
E_SHELL_SWITCHER (object)));
return;
+
+ case PROP_TOOLBAR_VISIBLE:
+ g_value_set_boolean (
+ value, e_shell_switcher_get_visible (
+ E_SHELL_SWITCHER (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
-switcher_dispose (GObject *object)
+shell_switcher_dispose (GObject *object)
{
EShellSwitcherPrivate *priv;
@@ -202,10 +222,11 @@ switcher_dispose (GObject *object)
}
static void
-switcher_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+shell_switcher_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
{
EShellSwitcherPrivate *priv;
+ GtkWidget *child;
GList *iter;
priv = E_SHELL_SWITCHER_GET_PRIVATE (widget);
@@ -213,6 +234,13 @@ switcher_size_request (GtkWidget *widget,
requisition->width = 0;
requisition->height = 0;
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ if (child != NULL)
+ gtk_widget_size_request (child, requisition);
+
+ if (!priv->toolbar_visible)
+ return;
+
for (iter = priv->proxies; iter != NULL; iter = iter->next) {
GtkWidget *widget = iter->data;
GtkRequisition child_requisition;
@@ -229,21 +257,36 @@ switcher_size_request (GtkWidget *widget,
}
static void
-switcher_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
+shell_switcher_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
{
- EShellSwitcherPrivate *priv;
+ EShellSwitcher *switcher;
+ GtkAllocation child_allocation;
+ GtkWidget *child;
+ gint height;
- priv = E_SHELL_SWITCHER_GET_PRIVATE (widget);
+ switcher = E_SHELL_SWITCHER (widget);
widget->allocation = *allocation;
- switcher_layout_actions (E_SHELL_SWITCHER (widget));
+ if (switcher->priv->toolbar_visible)
+ height = shell_switcher_layout_actions (switcher);
+ else
+ height = allocation->height;
+
+ child_allocation.x = allocation->x;
+ child_allocation.y = allocation->y;
+ child_allocation.width = allocation->width;
+ child_allocation.height = height;
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ if (child != NULL)
+ gtk_widget_size_allocate (child, &child_allocation);
}
static void
-switcher_screen_changed (GtkWidget *widget,
- GdkScreen *previous_screen)
+shell_switcher_screen_changed (GtkWidget *widget,
+ GdkScreen *previous_screen)
{
EShellSwitcherPrivate *priv;
GtkSettings *settings;
@@ -268,16 +311,17 @@ switcher_screen_changed (GtkWidget *widget,
priv->settings = g_object_ref (settings);
priv->settings_handler_id = g_signal_connect_swapped (
settings, "notify::gtk-toolbar-style",
- G_CALLBACK (switcher_toolbar_style_changed_cb), widget);
+ G_CALLBACK (shell_switcher_toolbar_style_changed_cb),
+ widget);
} else
priv->settings = NULL;
- switcher_toolbar_style_changed_cb (E_SHELL_SWITCHER (widget));
+ shell_switcher_toolbar_style_changed_cb (E_SHELL_SWITCHER (widget));
}
static void
-switcher_remove (GtkContainer *container,
- GtkWidget *widget)
+shell_switcher_remove (GtkContainer *container,
+ GtkWidget *widget)
{
EShellSwitcherPrivate *priv;
GList *link;
@@ -301,10 +345,10 @@ switcher_remove (GtkContainer *container,
}
static void
-switcher_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
+shell_switcher_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data)
{
EShellSwitcherPrivate *priv;
@@ -320,8 +364,8 @@ switcher_forall (GtkContainer *container,
}
static void
-switcher_style_changed (EShellSwitcher *switcher,
- GtkToolbarStyle style)
+shell_switcher_style_changed (EShellSwitcher *switcher,
+ GtkToolbarStyle style)
{
if (switcher->priv->style == style)
return;
@@ -337,33 +381,31 @@ switcher_style_changed (EShellSwitcher *switcher,
}
static GtkIconSize
-switcher_get_icon_size (GtkToolShell *shell)
+shell_switcher_get_icon_size (GtkToolShell *shell)
{
return GTK_ICON_SIZE_LARGE_TOOLBAR;
}
static GtkOrientation
-switcher_get_orientation (GtkToolShell *shell)
+shell_switcher_get_orientation (GtkToolShell *shell)
{
return GTK_ORIENTATION_HORIZONTAL;
}
static GtkToolbarStyle
-switcher_get_style (GtkToolShell *shell)
+shell_switcher_get_style (GtkToolShell *shell)
{
return e_shell_switcher_get_style (E_SHELL_SWITCHER (shell));
}
static GtkReliefStyle
-switcher_get_relief_style (GtkToolShell *shell)
+shell_switcher_get_relief_style (GtkToolShell *shell)
{
- /* XXX GTK+ 2.13.6 discards this value.
- * http://bugzilla.gnome.org/show_bug.cgi?id=549943 */
return GTK_RELIEF_NORMAL;
}
static void
-switcher_class_init (EShellSwitcherClass *class)
+shell_switcher_class_init (EShellSwitcherClass *class)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
@@ -373,20 +415,20 @@ switcher_class_init (EShellSwitcherClass *class)
g_type_class_add_private (class, sizeof (EShellSwitcherPrivate));
object_class = G_OBJECT_CLASS (class);
- object_class->set_property = switcher_set_property;
- object_class->get_property = switcher_get_property;
- object_class->dispose = switcher_dispose;
+ object_class->set_property = shell_switcher_set_property;
+ object_class->get_property = shell_switcher_get_property;
+ object_class->dispose = shell_switcher_dispose;
widget_class = GTK_WIDGET_CLASS (class);
- widget_class->size_request = switcher_size_request;
- widget_class->size_allocate = switcher_size_allocate;
- widget_class->screen_changed = switcher_screen_changed;
+ widget_class->size_request = shell_switcher_size_request;
+ widget_class->size_allocate = shell_switcher_size_allocate;
+ widget_class->screen_changed = shell_switcher_screen_changed;
container_class = GTK_CONTAINER_CLASS (class);
- container_class->remove = switcher_remove;
- container_class->forall = switcher_forall;
+ container_class->remove = shell_switcher_remove;
+ container_class->forall = shell_switcher_forall;
- class->style_changed = switcher_style_changed;
+ class->style_changed = shell_switcher_style_changed;
g_object_class_install_property (
object_class,
@@ -400,6 +442,17 @@ switcher_class_init (EShellSwitcherClass *class)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
+ g_object_class_install_property (
+ object_class,
+ PROP_TOOLBAR_VISIBLE,
+ g_param_spec_boolean (
+ "toolbar-visible",
+ NULL,
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
signals[STYLE_CHANGED] = g_signal_new (
"style-changed",
G_OBJECT_CLASS_TYPE (class),
@@ -412,7 +465,7 @@ switcher_class_init (EShellSwitcherClass *class)
}
static void
-switcher_init (EShellSwitcher *switcher)
+shell_switcher_init (EShellSwitcher *switcher)
{
switcher->priv = E_SHELL_SWITCHER_GET_PRIVATE (switcher);
@@ -420,12 +473,12 @@ switcher_init (EShellSwitcher *switcher)
}
static void
-switcher_tool_shell_iface_init (GtkToolShellIface *iface)
+shell_switcher_tool_shell_iface_init (GtkToolShellIface *iface)
{
- iface->get_icon_size = switcher_get_icon_size;
- iface->get_orientation = switcher_get_orientation;
- iface->get_style = switcher_get_style;
- iface->get_relief_style = switcher_get_relief_style;
+ iface->get_icon_size = shell_switcher_get_icon_size;
+ iface->get_orientation = shell_switcher_get_orientation;
+ iface->get_style = shell_switcher_get_style;
+ iface->get_relief_style = shell_switcher_get_relief_style;
}
GType
@@ -438,17 +491,17 @@ e_shell_switcher_get_type (void)
sizeof (EShellSwitcherClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
- (GClassInitFunc) switcher_class_init,
+ (GClassInitFunc) shell_switcher_class_init,
(GClassFinalizeFunc) NULL,
NULL, /* class_data */
sizeof (EShellSwitcher),
0, /* n_preallocs */
- (GInstanceInitFunc) switcher_init,
+ (GInstanceInitFunc) shell_switcher_init,
NULL /* value_table */
};
static const GInterfaceInfo tool_shell_info = {
- (GInterfaceInitFunc) switcher_tool_shell_iface_init,
+ (GInterfaceInitFunc) shell_switcher_tool_shell_iface_init,
(GInterfaceFinalizeFunc) NULL,
NULL /* interface_data */
};
@@ -502,7 +555,7 @@ e_shell_switcher_get_style (EShellSwitcher *switcher)
void
e_shell_switcher_set_style (EShellSwitcher *switcher,
- GtkToolbarStyle style)
+ GtkToolbarStyle style)
{
g_return_if_fail (E_IS_SHELL_SWITCHER (switcher));
@@ -535,3 +588,29 @@ e_shell_switcher_unset_style (EShellSwitcher *switcher)
switcher->priv->style_set = FALSE;
}
+
+gboolean
+e_shell_switcher_get_visible (EShellSwitcher *switcher)
+{
+ g_return_val_if_fail (E_IS_SHELL_SWITCHER (switcher), FALSE);
+
+ return switcher->priv->toolbar_visible;
+}
+
+void
+e_shell_switcher_set_visible (EShellSwitcher *switcher,
+ gboolean visible)
+{
+ GList *iter;
+
+ g_return_if_fail (E_IS_SHELL_SWITCHER (switcher));
+
+ switcher->priv->toolbar_visible = visible;
+
+ for (iter = switcher->priv->proxies; iter != NULL; iter = iter->next)
+ g_object_set (iter->data, "visible", visible, NULL);
+
+ gtk_widget_queue_resize (GTK_WIDGET (switcher));
+
+ g_object_notify (G_OBJECT (switcher), "toolbar-visible");
+}
diff --git a/shell/e-shell-switcher.h b/shell/e-shell-switcher.h
index 6d2995f99a..67201279d2 100644
--- a/shell/e-shell-switcher.h
+++ b/shell/e-shell-switcher.h
@@ -70,6 +70,9 @@ GtkToolbarStyle e_shell_switcher_get_style (EShellSwitcher *switcher);
void e_shell_switcher_set_style (EShellSwitcher *switcher,
GtkToolbarStyle style);
void e_shell_switcher_unset_style (EShellSwitcher *switcher);
+gboolean e_shell_switcher_get_visible (EShellSwitcher *switcher);
+void e_shell_switcher_set_visible (EShellSwitcher *switcher,
+ gboolean visible);
G_END_DECLS
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index 2cb2ec9f3c..7620cb92a7 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -23,9 +23,12 @@
#include <string.h>
#include <glib/gi18n.h>
-#include <e-task-bar.h>
+#include <filter/rule-context.h>
+#include <widgets/misc/e-search-bar.h>
+#include <widgets/misc/e-task-bar.h>
#include <e-shell-content.h>
+#include <e-shell-module.h>
#include <e-shell-sidebar.h>
#include <e-shell-window.h>
#include <e-shell-window-actions.h>
@@ -63,6 +66,70 @@ static gpointer parent_class;
static gulong signals[LAST_SIGNAL];
static void
+shell_view_setup_search_context (EShellView *shell_view)
+{
+ RuleContext *context;
+ EShellViewClass *class;
+ EShellModule *shell_module;
+ FilterRule *rule;
+ FilterPart *part;
+ GtkWidget *widget;
+ gchar *system_filename;
+ gchar *user_filename;
+
+ class = E_SHELL_VIEW_GET_CLASS (shell_view);
+ shell_module = E_SHELL_MODULE (class->type_module);
+
+ /* The filename for built-in searches is specified in a
+ * module's EShellModuleInfo. All built-in search rules
+ * live in the same directory. */
+ system_filename = g_build_filename (
+ EVOLUTION_RULEDIR,
+ e_shell_module_get_searches (shell_module), NULL);
+
+ /* The filename for custom saved searches is always of
+ * the form "$(shell_module_data_dir)/searches.xml". */
+ user_filename = g_build_filename (
+ e_shell_module_get_data_dir (shell_module),
+ "searches.xml", NULL);
+
+ context = rule_context_new ();
+ rule_context_add_part_set (
+ context, "partset", FILTER_TYPE_PART,
+ rule_context_add_part, rule_context_next_part);
+ rule_context_add_rule_set (
+ context, "ruleset", FILTER_TYPE_RULE,
+ rule_context_add_rule, rule_context_next_rule);
+ rule_context_load (context, system_filename, user_filename);
+
+ /* XXX Not sure why this is necessary. */
+ g_object_set_data_full (
+ G_OBJECT (context), "system", system_filename, g_free);
+ g_object_set_data_full (
+ G_OBJECT (context), "user", user_filename, g_free);
+
+ /* XXX I don't really understand what this does. */
+ rule = filter_rule_new ();
+ part = rule_context_next_part (context, NULL);
+ if (part == NULL)
+ g_warning (
+ "Could not load %s search; no parts.",
+ class->type_module->name);
+ else
+ filter_rule_add_part (rule, filter_part_clone (part));
+
+ g_free (system_filename);
+ g_free (user_filename);
+
+ /* Hand the context off to the search bar. */
+ widget = e_shell_view_get_content_widget (shell_view);
+ widget = e_shell_content_get_search_bar (E_SHELL_CONTENT (widget));
+ e_search_bar_set_context (E_SEARCH_BAR (widget), context);
+
+ g_object_unref (context);
+}
+
+static void
shell_view_set_page_num (EShellView *shell_view,
gint page_num)
{
@@ -205,15 +272,19 @@ static void
shell_view_constructed (GObject *object)
{
EShellViewClass *class;
+ EShellView *shell_view;
GtkWidget *sidebar;
+ shell_view = E_SHELL_VIEW (object);
class = E_SHELL_VIEW_GET_CLASS (object);
- sidebar = e_shell_view_get_sidebar_widget (E_SHELL_VIEW (object));
+ sidebar = e_shell_view_get_sidebar_widget (shell_view);
e_shell_sidebar_set_icon_name (
E_SHELL_SIDEBAR (sidebar), class->icon_name);
e_shell_sidebar_set_primary_text (
E_SHELL_SIDEBAR (sidebar), class->label);
+ shell_view_setup_search_context (shell_view);
+
/* XXX GObjectClass doesn't implement constructed(), so we will.
* Then subclasses won't have to check the function pointer
* before chaining up.
@@ -369,6 +440,9 @@ e_shell_view_set_title (EShellView *shell_view,
{
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+ if (title == NULL)
+ title = E_SHELL_VIEW_GET_CLASS (shell_view)->label;
+
g_free (shell_view->priv->title);
shell_view->priv->title = g_strdup (title);
diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h
index a13efcf4b4..5deeac0f31 100644
--- a/shell/e-shell-view.h
+++ b/shell/e-shell-view.h
@@ -92,8 +92,8 @@ void e_shell_view_set_view_instance (EShellView *shell_view,
EShellWindow * e_shell_view_get_window (EShellView *shell_view);
gboolean e_shell_view_is_selected (EShellView *shell_view);
gint e_shell_view_get_page_num (EShellView *shell_view);
-GtkWidget * e_shell_view_get_content_widget (EShellView *shell_view);
-GtkWidget * e_shell_view_get_sidebar_widget (EShellView *shell_view);
+GtkWidget * e_shell_view_get_content_widget (EShellView *shell_view);
+GtkWidget * e_shell_view_get_sidebar_widget (EShellView *shell_view);
GtkWidget * e_shell_view_get_taskbar_widget (EShellView *shell_view);
void e_shell_view_changed (EShellView *shell_view);
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
index 44d82e8bbe..9983d77f36 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -22,10 +22,10 @@
#include <string.h>
-#include <e-util/e-dialog-utils.h>
-#include <e-util/e-error.h>
-#include <e-util/e-print.h>
-#include <e-util/e-util.h>
+#include <e-dialog-utils.h>
+#include <e-error.h>
+#include <e-print.h>
+#include <e-util.h>
#include <gal-define-views-dialog.h>
#include <libedataserverui/e-passwords.h>
@@ -859,6 +859,77 @@ action_quit_cb (GtkAction *action,
}
static void
+action_search_advanced_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+}
+
+static void
+action_search_clear_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ GtkWidget *widget;
+ const gchar *view_name;
+
+ /* Dig up the search bar. */
+ view_name = e_shell_window_get_current_view (shell_window);
+ shell_view = e_shell_window_get_view (shell_window, view_name);
+ widget = e_shell_view_get_content_widget (shell_view);
+ widget = e_shell_content_get_search_bar (E_SHELL_CONTENT (widget));
+
+ e_search_bar_set_search_text (E_SEARCH_BAR (widget), NULL);
+}
+
+static void
+action_search_edit_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ RuleContext *context;
+ RuleEditor *editor;
+ GtkWidget *widget;
+ const gchar *filename;
+ const gchar *view_name;
+
+ /* Dig up the search bar. */
+ view_name = e_shell_window_get_current_view (shell_window);
+ shell_view = e_shell_window_get_view (shell_window, view_name);
+ widget = e_shell_view_get_content_widget (shell_view);
+ widget = e_shell_content_get_search_bar (E_SHELL_CONTENT (widget));
+
+ context = e_search_bar_get_context (E_SEARCH_BAR (widget));
+ g_return_if_fail (context != NULL);
+
+ /* XXX I don't know why the RuleContext can't just store
+ * system and user file names properly. Fix this? */
+ filename = g_object_get_data (G_OBJECT (context), "user");
+ g_return_if_fail (filename != NULL);
+
+ editor = rule_editor_new (
+ context, FILTER_SOURCE_INCOMING, _("Searches"));
+ gtk_window_set_title (GTK_WINDOW (editor), _("Searches"));
+
+ if (gtk_dialog_run (GTK_DIALOG (editor)) == GTK_RESPONSE_OK)
+ rule_context_save (context, filename);
+
+ gtk_widget_destroy (GTK_WIDGET (editor));
+}
+
+static void
+action_search_execute_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ gtk_action_set_sensitive (action, FALSE);
+}
+
+static void
+action_search_save_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+}
+
+static void
action_send_receive_cb (GtkAction *action,
EShellWindow *shell_window)
{
@@ -910,12 +981,12 @@ static void
action_show_switcher_cb (GtkToggleAction *action,
EShellWindow *shell_window)
{
- GtkWidget *widget;
+ EShellSwitcher *switcher;
gboolean active;
- widget = shell_window->priv->switcher;
+ switcher = E_SHELL_SWITCHER (shell_window->priv->switcher);
active = gtk_toggle_action_get_active (action);
- g_object_set (widget, "visible", active, NULL);
+ e_shell_switcher_set_visible (switcher, active);
}
static void
@@ -1102,6 +1173,41 @@ static GtkActionEntry shell_entries[] = {
N_("Exit the program"),
G_CALLBACK (action_quit_cb) },
+ { "search-advanced",
+ NULL,
+ N_("_Advanced Search..."),
+ NULL,
+ N_("Construct a more advanced search"),
+ G_CALLBACK (action_search_advanced_cb) },
+
+ { "search-clear",
+ GTK_STOCK_CLEAR,
+ NULL,
+ "<Control><Shift>q",
+ N_("Clear the current search parameters"),
+ G_CALLBACK (action_search_clear_cb) },
+
+ { "search-edit",
+ NULL,
+ N_("_Edit Saved Searches..."),
+ NULL,
+ N_("Manage your saved searches"),
+ G_CALLBACK (action_search_edit_cb) },
+
+ { "search-execute",
+ GTK_STOCK_FIND,
+ N_("_Find Now"),
+ NULL,
+ N_("Execute the current search parameters"),
+ G_CALLBACK (action_search_execute_cb) },
+
+ { "search-save",
+ NULL,
+ N_("_Save Search..."),
+ NULL,
+ N_("Save the current search parameters"),
+ G_CALLBACK (action_search_save_cb) },
+
{ "send-receive",
"mail-send-receive",
N_("Send / _Receive"),
@@ -1534,6 +1640,7 @@ e_shell_window_create_shell_view_actions (EShellWindow *shell_window)
EShellViewClass *class;
GtkRadioAction *action;
const gchar *view_name;
+ gchar *accelerator;
gchar *action_name;
gchar *tooltip;
@@ -1588,8 +1695,14 @@ e_shell_window_create_shell_view_actions (EShellWindow *shell_window)
gtk_radio_action_set_group (action, group);
group = gtk_radio_action_get_group (action);
- gtk_action_group_add_action (
- action_group, GTK_ACTION (action));
+ /* The first nine views have accelerators Ctrl+(1-9). */
+ if (ii < 9)
+ accelerator = g_strdup_printf ("<Control>%d", ii + 1);
+ else
+ accelerator = g_strdup ("");
+
+ gtk_action_group_add_action_with_accel (
+ action_group, GTK_ACTION (action), accelerator);
e_shell_switcher_add_action (switcher, GTK_ACTION (action));
@@ -1599,6 +1712,7 @@ e_shell_window_create_shell_view_actions (EShellWindow *shell_window)
action_name, action_name,
GTK_UI_MANAGER_AUTO, FALSE);
+ g_free (accelerator);
g_free (action_name);
g_free (tooltip);
diff --git a/shell/e-shell-window-actions.h b/shell/e-shell-window-actions.h
index f1f9b8a554..2e3595f0f7 100644
--- a/shell/e-shell-window-actions.h
+++ b/shell/e-shell-window-actions.h
@@ -56,6 +56,16 @@
E_SHELL_WINDOW_ACTION ((window), "quick-reference")
#define E_SHELL_WINDOW_ACTION_QUIT(window) \
E_SHELL_WINDOW_ACTION ((window), "quit")
+#define E_SHELL_WINDOW_ACTION_SEARCH_ADVANCED(window) \
+ E_SHELL_WINDOW_ACTION ((window), "search-advanced")
+#define E_SHELL_WINDOW_ACTION_SEARCH_CLEAR(window) \
+ E_SHELL_WINDOW_ACTION ((window), "search-clear")
+#define E_SHELL_WINDOW_ACTION_SEARCH_EDIT(window) \
+ E_SHELL_WINDOW_ACTION ((window), "search-edit")
+#define E_SHELL_WINDOW_ACTION_SEARCH_EXECUTE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "search-execute")
+#define E_SHELL_WINDOW_ACTION_SEARCH_SAVE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "search-save")
#define E_SHELL_WINDOW_ACTION_SEND_RECEIVE(window) \
E_SHELL_WINDOW_ACTION ((window), "send-receive")
#define E_SHELL_WINDOW_ACTION_SHOW_SIDEBAR(window) \
diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c
index 5d0a8d3bee..8224ee901a 100644
--- a/shell/e-shell-window-private.c
+++ b/shell/e-shell-window-private.c
@@ -287,31 +287,27 @@ e_shell_window_private_init (EShellWindow *shell_window)
container = priv->content_pane;
- widget = gtk_vbox_new (FALSE, 6);
+ widget = e_shell_switcher_new ();
gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, FALSE);
+ priv->switcher = g_object_ref (widget);
gtk_widget_show (widget);
widget = gtk_notebook_new ();
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
- gtk_paned_pack2 (GTK_PANED (container), widget, TRUE, FALSE);
+ gtk_paned_pack2 (GTK_PANED (container), widget, TRUE, TRUE);
priv->content_notebook = g_object_ref (widget);
gtk_widget_show (widget);
- container = gtk_paned_get_child1 (GTK_PANED (priv->content_pane));
+ container = priv->switcher;
widget = gtk_notebook_new ();
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (container), widget);
priv->sidebar_notebook = g_object_ref (widget);
gtk_widget_show (widget);
- widget = e_shell_switcher_new ();
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- priv->switcher = g_object_ref (widget);
- gtk_widget_show (widget);
-
container = priv->status_area;
widget = e_online_button_new ();
diff --git a/shell/e-shell-window-private.h b/shell/e-shell-window-private.h
index 81bf254c61..161bb17e0b 100644
--- a/shell/e-shell-window-private.h
+++ b/shell/e-shell-window-private.h
@@ -25,15 +25,18 @@
#include <glib/gi18n.h>
+#include <filter/rule-editor.h>
+#include <widgets/misc/e-menu-tool-button.h>
+#include <widgets/misc/e-online-button.h>
+#include <widgets/misc/e-search-bar.h>
+
#include <e-shell.h>
+#include <e-shell-content.h>
#include <e-shell-view.h>
#include <e-shell-registry.h>
#include <e-shell-switcher.h>
#include <e-shell-window-actions.h>
-#include <e-menu-tool-button.h>
-#include <e-online-button.h>
-
#define E_SHELL_WINDOW_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_SHELL_WINDOW, EShellWindowPrivate))
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index c53867b527..8d2e3c1180 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -40,6 +40,27 @@ enum {
static gpointer parent_class;
+static void
+shell_window_update_title (EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ const gchar *view_title;
+ const gchar *view_name;
+ gchar *window_title;
+
+ view_name = e_shell_window_get_current_view (shell_window);
+ shell_view = e_shell_window_get_view (shell_window, view_name);
+ view_title = e_shell_view_get_title (shell_view);
+
+ if (!e_shell_view_is_selected (shell_view))
+ return;
+
+ /* Translators: This is used for the main window title. */
+ window_title = g_strdup_printf (_("%s - Evolution"), view_title);
+ gtk_window_set_title (GTK_WINDOW (shell_window), window_title);
+ g_free (window_title);
+}
+
static EShellView *
shell_window_new_view (EShellWindow *shell_window,
GType shell_view_type,
@@ -78,6 +99,10 @@ shell_window_new_view (EShellWindow *shell_window,
widget = e_shell_view_get_taskbar_widget (shell_view);
gtk_notebook_append_page (notebook, widget, NULL);
+ g_signal_connect_swapped (
+ shell_view, "notify::title",
+ G_CALLBACK (shell_window_update_title), shell_window);
+
return shell_view;
}
@@ -473,6 +498,7 @@ e_shell_window_set_current_view (EShellWindow *shell_window,
shell_window->priv->current_view = view_name;
g_object_notify (G_OBJECT (shell_window), "current-view");
+ shell_window_update_title (shell_window);
e_shell_window_update_gal_view_menu (shell_window);
/* Notify all loaded views. */
diff --git a/shell/test/e-test-shell-module.c b/shell/test/e-test-shell-module.c
index 2aec01a444..b09e589d74 100644
--- a/shell/test/e-test-shell-module.c
+++ b/shell/test/e-test-shell-module.c
@@ -29,6 +29,7 @@
#define MODULE_NAME "test"
#define MODULE_ALIASES "monkey"
#define MODULE_SCHEMES ""
+#define MODULE_SEARCHES NULL
#define MODULE_SORT_ORDER 100
/* Module Entry Point */
@@ -131,6 +132,7 @@ static EShellModuleInfo module_info = {
MODULE_NAME,
MODULE_ALIASES,
MODULE_SCHEMES,
+ MODULE_SEARCHES,
MODULE_SORT_ORDER,
/* Methods */
diff --git a/ui/evolution-shell.ui b/ui/evolution-shell.ui
index b0b9b353cd..633703f24a 100644
--- a/ui/evolution-shell.ui
+++ b/ui/evolution-shell.ui
@@ -49,7 +49,14 @@
</menu>
</menu>
<placeholder name='custom-menus'/>
- <menu action='search-menu'/>
+ <menu action='search-menu'>
+ <menuitem action='search-execute'/>
+ <menuitem action='search-clear'/>
+ <menuitem action='search-advanced'/>
+ <separator/>
+ <menuitem action='search-save'/>
+ <menuitem action='search-edit'/>
+ </menu>
<menu action='help-menu'>
<menuitem action='contents'/>
<menuitem action='quick-reference'/>
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index ee91224f5e..138d102295 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -5,6 +5,7 @@ endif
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/a11y/widgets \
+ -I$(top_srcdir)/filter \
-I$(top_srcdir)/widgets \
-DEVOLUTION_IMAGES=\""$(imagesdir)"\" \
-DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \
@@ -132,6 +133,7 @@ libemiscwidgets_la_LDFLAGS = $(NO_UNDEFINED)
libemiscwidgets_la_LIBADD = $(top_builddir)/e-util/libeutil.la \
$(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/filter/libfilter.la \
$(top_builddir)/widgets/table/libetable.la \
$(top_builddir)/widgets/text/libetext.la \
$(top_builddir)/a11y/widgets/libevolution-widgets-a11y.la \
@@ -166,6 +168,7 @@ test_calendar_SOURCES = \
test_calendar_LDADD = \
libemiscwidgets.la \
$(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/filter/libfilter.la \
$(E_WIDGETS_LIBS)
# test-dateedit
@@ -176,6 +179,7 @@ test_dateedit_SOURCES = \
test_dateedit_LDADD = \
libemiscwidgets.la \
$(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/filter/libfilter.la \
$(E_WIDGETS_LIBS)
# test-dropdown-button
@@ -186,6 +190,7 @@ test_dropdown_button_SOURCES = \
test_dropdown_button_LDADD = \
libemiscwidgets.la \
$(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/filter/libfilter.la \
$(E_WIDGETS_LIBS)
# test-preferences-window
@@ -196,6 +201,7 @@ test_preferences_window_SOURCES = \
test_preferences_window_LDADD = \
libemiscwidgets.la \
$(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/filter/libfilter.la \
$(E_WIDGETS_LIBS)
diff --git a/widgets/misc/e-filter-bar.c b/widgets/misc/e-filter-bar.c
index 37f508c9f6..dc9863a8f5 100644
--- a/widgets/misc/e-filter-bar.c
+++ b/widgets/misc/e-filter-bar.c
@@ -29,26 +29,15 @@
#endif
#include <string.h>
+#include <glib/gi18n.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
-#include <glib/gi18n.h>
-
#include "e-dropdown-button.h"
#include "e-filter-bar.h"
#include "filter/rule-editor.h"
-#define d(x)
-
-enum {
- LAST_SIGNAL
-};
-
-/*static gint esb_signals [LAST_SIGNAL] = { 0, };*/
-
-static ESearchBarClass *parent_class = NULL;
-
/* The arguments we take */
enum {
PROP_0,
@@ -56,59 +45,26 @@ enum {
PROP_STATE,
};
+static gpointer parent_class;
/* Callbacks. */
static void rule_changed (FilterRule *rule, gpointer user_data);
-
/* rule editor thingy */
static void
-rule_editor_destroyed (EFilterBar *efb, GObject *deadbeef)
-{
- efb->save_dialog = NULL;
- e_search_bar_set_menu_sensitive (E_SEARCH_BAR (efb), E_FILTERBAR_SAVE_ID, TRUE);
-}
-
-/* FIXME: need to update the popup menu to match any edited rules, sigh */
-static void
-full_rule_editor_response (GtkWidget *dialog, int response, void *data)
-{
- EFilterBar *efb = data;
-
- if (response == GTK_RESPONSE_OK)
- rule_context_save (efb->context, efb->userrules);
-
- gtk_widget_destroy (dialog);
-}
-
-static void
-rule_editor_response (GtkWidget *dialog, int response, void *data)
+rule_editor_destroyed (EFilterBar *filter_bar, GObject *deadbeef)
{
- EFilterBar *efb = data;
- FilterRule *rule;
-
- if (response == GTK_RESPONSE_OK) {
- rule = g_object_get_data (G_OBJECT (dialog), "rule");
- if (rule) {
- if (!filter_rule_validate (rule))
- return;
-
- rule_context_add_rule (efb->context, rule);
- /* FIXME: check return */
- rule_context_save (efb->context, efb->userrules);
- }
- }
-
- gtk_widget_destroy (dialog);
+ filter_bar->save_dialog = NULL;
+ e_search_bar_set_menu_sensitive (E_SEARCH_BAR (filter_bar), E_FILTERBAR_SAVE_ID, TRUE);
}
static void
rule_advanced_response (GtkWidget *dialog, int response, void *data)
{
- EFilterBar *efb = data;
+ EFilterBar *filter_bar = data;
/* the below generates a compiler warning about incompatible pointer types */
- ESearchBar *esb = (ESearchBar *)efb;
+ ESearchBar *search_bar = (ESearchBar *)filter_bar;
FilterRule *rule;
if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) {
@@ -119,26 +75,26 @@ rule_advanced_response (GtkWidget *dialog, int response, void *data)
if (!filter_rule_validate (rule))
return;
- efb->current_query = rule;
+ filter_bar->current_query = rule;
g_object_ref (rule);
- g_signal_emit_by_name (efb, "search_activated");
+ g_signal_emit_by_name (filter_bar, "search_activated");
- 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]));
- e_search_bar_set_text (esb,_("Advanced Search"));
- gtk_widget_set_sensitive (esb->clear_button, TRUE);
+ gtk_widget_modify_base (search_bar->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
+ gtk_widget_modify_text (search_bar->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED]));
+ gtk_widget_modify_base (search_bar->icon_entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
+ gtk_widget_modify_base (search_bar->viewoption, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
+ e_search_bar_set_text (search_bar,_("Advanced Search"));
+ gtk_widget_set_sensitive (search_bar->clear_button, TRUE);
if (response == GTK_RESPONSE_APPLY) {
- if (!rule_context_find_rule (efb->context, rule->name, rule->source))
- rule_context_add_rule (efb->context, rule);
+ if (!rule_context_find_rule (filter_bar->context, rule->name, rule->source))
+ rule_context_add_rule (filter_bar->context, rule);
/* FIXME: check return */
- rule_context_save (efb->context, efb->userrules);
+ rule_context_save (filter_bar->context, filter_bar->userrules);
}
}
} else {
- e_search_bar_set_item_id (esb, esb->last_search_option);
+ e_search_bar_set_item_id (search_bar, search_bar->last_search_option);
}
if (response != GTK_RESPONSE_APPLY)
@@ -148,34 +104,26 @@ rule_advanced_response (GtkWidget *dialog, int response, void *data)
static void
dialog_rule_changed (FilterRule *fr, GtkWidget *dialog)
{
- gboolean sensitive;
-
- g_return_if_fail (dialog != NULL);
-
- sensitive = fr && fr->parts;
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, sensitive);
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_APPLY, sensitive);
+ /* mbarnes: converted */
}
static void
-do_advanced (ESearchBar *esb)
+do_advanced (ESearchBar *search_bar)
{
- EFilterBar *efb = (EFilterBar *)esb;
-
- d(printf("Advanced search!\n"));
+ EFilterBar *filter_bar = (EFilterBar *)search_bar;
- if (!efb->save_dialog && !efb->setquery) {
+ if (!filter_bar->save_dialog && !filter_bar->setquery) {
GtkWidget *dialog, *w;
FilterRule *rule;
- if (efb->current_query)
- rule = filter_rule_clone (efb->current_query);
+ if (filter_bar->current_query)
+ rule = filter_rule_clone (filter_bar->current_query);
else {
rule = filter_rule_new ();
- efb->current_query = rule;
+ filter_bar->current_query = rule;
}
- w = filter_rule_get_widget (rule, efb->context);
+ w = filter_rule_get_widget (rule, filter_bar->context);
filter_rule_set_source (rule, FILTER_SOURCE_INCOMING);
gtk_container_set_border_width (GTK_CONTAINER (w), 12);
@@ -185,7 +133,7 @@ do_advanced (ESearchBar *esb)
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
- efb->save_dialog = dialog;
+ filter_bar->save_dialog = dialog;
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
@@ -201,166 +149,105 @@ do_advanced (ESearchBar *esb)
g_signal_connect (rule, "changed", G_CALLBACK (dialog_rule_changed), dialog);
dialog_rule_changed (rule, dialog);
- g_signal_connect (dialog, "response", G_CALLBACK (rule_advanced_response), efb);
- g_object_weak_ref ((GObject *) dialog, (GWeakNotify) rule_editor_destroyed, efb);
+ g_signal_connect (dialog, "response", G_CALLBACK (rule_advanced_response), filter_bar);
+ g_object_weak_ref ((GObject *) dialog, (GWeakNotify) rule_editor_destroyed, filter_bar);
- e_search_bar_set_menu_sensitive (esb, E_FILTERBAR_SAVE_ID, FALSE);
+ e_search_bar_set_menu_sensitive (search_bar, E_FILTERBAR_SAVE_ID, FALSE);
gtk_widget_show (dialog);
}
}
static void
-save_search_dialog (ESearchBar *esb)
+save_search_dialog (ESearchBar *search_bar)
{
- 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);
-
- g_signal_connect (rule, "changed", G_CALLBACK (dialog_rule_changed), dialog);
- dialog_rule_changed (rule, dialog);
-
- e_search_bar_set_menu_sensitive (esb, E_FILTERBAR_SAVE_ID, FALSE);
-
- gtk_widget_show (dialog);
+ /* mbarnes: converted */
}
static void
-menubar_activated (ESearchBar *esb, int id, void *data)
+menubar_activated (ESearchBar *search_bar, int id, void *data)
{
- EFilterBar *efb = (EFilterBar *)esb;
+ EFilterBar *filter_bar = (EFilterBar *)search_bar;
GtkWidget *dialog;
GtkStyle *style;
- d(printf ("menubar activated!\n"));
-
switch (id) {
case E_FILTERBAR_EDIT_ID:
- if (!efb->save_dialog) {
- efb->save_dialog = dialog = (GtkWidget *) rule_editor_new (efb->context, FILTER_SOURCE_INCOMING, _("_Searches"));
-
- gtk_window_set_title (GTK_WINDOW (dialog), _("Searches"));
- g_signal_connect (dialog, "response", G_CALLBACK (full_rule_editor_response), efb);
- g_object_weak_ref ((GObject *) dialog, (GWeakNotify) rule_editor_destroyed, efb);
- gtk_widget_show (dialog);
- }
+ /* mbarnes: converted */
break;
case E_FILTERBAR_SAVE_ID:
- if (efb->current_query && !efb->save_dialog)
- save_search_dialog (esb);
+ if (filter_bar->current_query && !filter_bar->save_dialog)
+ save_search_dialog (search_bar);
- d(printf("Save menu\n"));
break;
case E_FILTERBAR_ADVANCED_ID:
- e_search_bar_set_item_id (esb, E_FILTERBAR_ADVANCED_ID);
+ e_search_bar_set_item_id (search_bar, E_FILTERBAR_ADVANCED_ID);
break;
default:
- if (id >= efb->menu_base && id < efb->menu_base + efb->menu_rules->len) {
-#if d(!)0
- GString *out = g_string_new ("");
-
- printf("Selected rule: %s\n", ((FilterRule *)efb->menu_rules->pdata[id - efb->menu_base])->name);
- filter_rule_build_code (efb->menu_rules->pdata[id - efb->menu_base], out);
- printf("query: '%s'\n", out->str);
- g_string_free (out, TRUE);
-#endif
- efb->current_query = (FilterRule *)efb->menu_rules->pdata[id - efb->menu_base];
+ if (id >= filter_bar->menu_base && id < filter_bar->menu_base + filter_bar->menu_rules->len) {
+ filter_bar->current_query = (FilterRule *)filter_bar->menu_rules->pdata[id - filter_bar->menu_base];
- efb->setquery = TRUE;
- e_search_bar_set_item_id (esb, E_FILTERBAR_ADVANCED_ID);
- efb->setquery = FALSE;
+ filter_bar->setquery = TRUE;
+ e_search_bar_set_item_id (search_bar, E_FILTERBAR_ADVANCED_ID);
+ filter_bar->setquery = FALSE;
/* saved searches activated */
style = gtk_widget_get_default_style ();
- efb->setquery = TRUE;
- 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] ));
- e_search_bar_set_text (esb,_("Advanced Search"));
- g_signal_emit_by_name (efb, "search_activated", NULL);
- efb->setquery = FALSE;
+ filter_bar->setquery = TRUE;
+ gtk_widget_modify_base (search_bar->entry , GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED] ));
+ gtk_widget_modify_text (search_bar->entry, GTK_STATE_NORMAL, &(style->text [GTK_STATE_SELECTED] ));
+ gtk_widget_modify_base (search_bar->icon_entry, GTK_STATE_NORMAL, &(style->base [GTK_STATE_SELECTED] ));
+ gtk_widget_modify_base (search_bar->viewoption, GTK_STATE_NORMAL, &(style->base [GTK_STATE_SELECTED] ));
+ e_search_bar_set_text (search_bar,_("Advanced Search"));
+ g_signal_emit_by_name (filter_bar, "search_activated", NULL);
+ filter_bar->setquery = FALSE;
} else {
return;
}
}
- g_signal_stop_emission_by_name (esb, "menu_activated");
+ g_signal_stop_emission_by_name (search_bar, "menu_activated");
}
static void
-option_changed (ESearchBar *esb, void *data)
+option_changed (ESearchBar *search_bar, void *data)
{
- EFilterBar *efb = (EFilterBar *)esb;
- int id = e_search_bar_get_item_id (esb);
+ EFilterBar *filter_bar = (EFilterBar *)search_bar;
+ int id = e_search_bar_get_item_id (search_bar);
char *query;
- d(printf("option changed, id = %d, setquery = %s %d\n", id, efb->setquery ? "true" : "false", esb->block_search));
-
- if (esb->scopeitem_id == E_FILTERBAR_CURRENT_MESSAGE_ID) {
- gtk_widget_set_sensitive (esb->option_button, FALSE);
+ if (search_bar->scopeitem_id == E_FILTERBAR_CURRENT_MESSAGE_ID) {
+ gtk_widget_set_sensitive (search_bar->option_button, FALSE);
} else {
- gtk_widget_set_sensitive (esb->option_button, TRUE);
+ gtk_widget_set_sensitive (search_bar->option_button, TRUE);
}
- if (efb->setquery)
+ if (filter_bar->setquery)
return;
switch (id) {
case E_FILTERBAR_SAVE_ID:
/* Fixme */
- /* save_search_dialog (esb); */
+ /* save_search_dialog (search_bar); */
break;
case E_FILTERBAR_ADVANCED_ID:
- d(printf ("do_advanced\n"));
- if (!esb->block_search)
- do_advanced (esb);
+ if (!search_bar->block_search)
+ do_advanced (search_bar);
break;
default:
- 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) {
- query = e_search_bar_get_text (esb);
- efb->config (efb, efb->current_query, id, query, efb->config_data);
+ if (id >= filter_bar->option_base && id < filter_bar->option_base + filter_bar->option_rules->len) {
+ filter_bar->current_query = (FilterRule *)filter_bar->option_rules->pdata[id - filter_bar->option_base];
+ if (filter_bar->config && filter_bar->current_query) {
+ query = e_search_bar_get_text (search_bar);
+ filter_bar->config (filter_bar, filter_bar->current_query, id, query, filter_bar->config_data);
g_free (query);
}
} 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);
- efb->current_query = NULL;
- gtk_entry_set_text ((GtkEntry *)esb->entry, "");
+ gtk_widget_modify_base (search_bar->entry, GTK_STATE_NORMAL, NULL);
+ gtk_widget_modify_text (search_bar->entry, GTK_STATE_NORMAL, NULL);
+ gtk_widget_modify_base (search_bar->icon_entry, GTK_STATE_NORMAL, NULL);
+ filter_bar->current_query = NULL;
+ gtk_entry_set_text ((GtkEntry *)search_bar->entry, "");
}
}
}
@@ -375,10 +262,10 @@ dup_item_no_subitems (ESearchBarItem *dest,
}
static GArray *
-build_items (ESearchBar *esb, ESearchBarItem *items, int type, int *start, GPtrArray *rules)
+build_items (ESearchBar *search_bar, ESearchBarItem *items, int type, int *start, GPtrArray *rules)
{
FilterRule *rule = NULL;
- EFilterBar *efb = (EFilterBar *)esb;
+ EFilterBar *filter_bar = (EFilterBar *)search_bar;
int id = 0, i;
GArray *menu = g_array_new (FALSE, FALSE, sizeof (ESearchBarItem));
ESearchBarItem item = { NULL, -1, 2 };
@@ -410,7 +297,7 @@ build_items (ESearchBar *esb, ESearchBarItem *items, int type, int *start, GPtrA
source = FILTER_SOURCE_INCOMING;
/* Add a separator if there is at least one custom rule. */
- if (rule_context_next_rule (efb->context, rule, source) != NULL) {
+ if (rule_context_next_rule (filter_bar->context, rule, source) != NULL) {
item.id = 0;
item.text = NULL;
item.type = 0;
@@ -421,7 +308,7 @@ build_items (ESearchBar *esb, ESearchBarItem *items, int type, int *start, GPtrA
}
num = 1;
- while ((rule = rule_context_next_rule (efb->context, rule, source))) {
+ while ((rule = rule_context_next_rule (filter_bar->context, rule, source))) {
item.id = id++;
if (type == 0 && num <= 10) {
@@ -434,7 +321,7 @@ build_items (ESearchBar *esb, ESearchBarItem *items, int type, int *start, GPtrA
if (g_slist_find(gtksux, rule) == NULL) {
g_object_ref (rule);
- g_signal_connect (rule, "changed", G_CALLBACK (rule_changed), efb);
+ g_signal_connect (rule, "changed", G_CALLBACK (rule_changed), filter_bar);
} else {
gtksux = g_slist_remove(gtksux, rule);
}
@@ -448,7 +335,7 @@ build_items (ESearchBar *esb, ESearchBarItem *items, int type, int *start, GPtrA
next = gtksux->next;
rule = gtksux->data;
- g_signal_handlers_disconnect_by_func (rule, G_CALLBACK (rule_changed), efb);
+ g_signal_handlers_disconnect_by_func (rule, G_CALLBACK (rule_changed), filter_bar);
g_object_unref (rule);
g_slist_free_1(gtksux);
@@ -491,13 +378,13 @@ free_built_items (GArray *menu)
}
static void
-generate_menu (ESearchBar *esb, ESearchBarItem *items)
+generate_menu (ESearchBar *search_bar, ESearchBarItem *items)
{
- EFilterBar *efb = (EFilterBar *)esb;
+ EFilterBar *filter_bar = (EFilterBar *)search_bar;
GArray *menu;
- menu = build_items (esb, items, 0, &efb->menu_base, efb->menu_rules);
- ((ESearchBarClass *)parent_class)->set_menu (esb, (ESearchBarItem *)menu->data);
+ menu = build_items (search_bar, items, 0, &filter_bar->menu_base, filter_bar->menu_rules);
+ ((ESearchBarClass *)parent_class)->set_menu (search_bar, (ESearchBarItem *)menu->data);
free_built_items (menu);
}
@@ -515,14 +402,14 @@ free_items (ESearchBarItem *items)
/* Virtual methods */
static void
-set_menu (ESearchBar *esb, ESearchBarItem *items)
+set_menu (ESearchBar *search_bar, ESearchBarItem *items)
{
- EFilterBar *efb = E_FILTER_BAR (esb);
+ EFilterBar *filter_bar = E_FILTER_BAR (search_bar);
ESearchBarItem *default_items;
int i, num;
- if (efb->default_items)
- free_items (efb->default_items);
+ if (filter_bar->default_items)
+ free_items (filter_bar->default_items);
for (num = 0; items[num].id != -1; num++)
;
@@ -534,72 +421,72 @@ set_menu (ESearchBar *esb, ESearchBarItem *items)
default_items[i].type = items[i].type;
}
- efb->default_items = default_items;
+ filter_bar->default_items = default_items;
- generate_menu (esb, default_items);
+ generate_menu (search_bar, default_items);
}
static void
-set_option (ESearchBar *esb, ESearchBarItem *items)
+set_option (ESearchBar *search_bar, ESearchBarItem *items)
{
GArray *menu;
- EFilterBar *efb = (EFilterBar *)esb;
+ EFilterBar *filter_bar = (EFilterBar *)search_bar;
- menu = build_items (esb, items, 1, &efb->option_base, efb->option_rules);
- ((ESearchBarClass *)parent_class)->set_option (esb, (ESearchBarItem *)menu->data);
+ menu = build_items (search_bar, items, 1, &filter_bar->option_base, filter_bar->option_rules);
+ ((ESearchBarClass *)parent_class)->set_option (search_bar, (ESearchBarItem *)menu->data);
free_built_items (menu);
- e_search_bar_set_item_id (esb, efb->option_base);
+ e_search_bar_set_item_id (search_bar, filter_bar->option_base);
}
static void
context_changed (RuleContext *context, gpointer user_data)
{
- EFilterBar *efb = E_FILTER_BAR (user_data);
- ESearchBar *esb = E_SEARCH_BAR (user_data);
+ EFilterBar *filter_bar = E_FILTER_BAR (user_data);
+ ESearchBar *search_bar = E_SEARCH_BAR (user_data);
/* just generate whole menu again */
- generate_menu (esb, efb->default_items);
+ generate_menu (search_bar, filter_bar->default_items);
}
static void
context_rule_removed (RuleContext *context, FilterRule *rule, gpointer user_data)
{
- EFilterBar *efb = E_FILTER_BAR (user_data);
- ESearchBar *esb = E_SEARCH_BAR (user_data);
+ EFilterBar *filter_bar = E_FILTER_BAR (user_data);
+ ESearchBar *search_bar = E_SEARCH_BAR (user_data);
/* just generate whole menu again */
- generate_menu (esb, efb->default_items);
+ generate_menu (search_bar, filter_bar->default_items);
}
static void
rule_changed (FilterRule *rule, gpointer user_data)
{
- EFilterBar *efb = E_FILTER_BAR (user_data);
- ESearchBar *esb = E_SEARCH_BAR (user_data);
+ EFilterBar *filter_bar = E_FILTER_BAR (user_data);
+ ESearchBar *search_bar = E_SEARCH_BAR (user_data);
/* just generate whole menu again */
- generate_menu (esb, efb->default_items);
+ generate_menu (search_bar, filter_bar->default_items);
}
-
-/* GtkObject methods. */
-
static void
-get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+filter_bar_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- EFilterBar *efb = (EFilterBar *) object;
- ESearchBar *esb = E_SEARCH_BAR (object);
+ EFilterBar *filter_bar = (EFilterBar *) object;
+ ESearchBar *search_bar = E_SEARCH_BAR (object);
switch (property_id) {
case PROP_QUERY: {
- char *text = e_search_bar_get_text (E_SEARCH_BAR (efb));
+ char *text = e_search_bar_get_text (E_SEARCH_BAR (filter_bar));
/* empty search text means searching turned off */
- if (efb->current_query && text && *text) {
+ if (filter_bar->current_query && text && *text) {
GString *out = g_string_new ("");
- filter_rule_build_code (efb->current_query, out);
+ filter_rule_build_code (filter_bar->current_query, out);
g_value_take_string (value, out->str);
g_string_free (out, FALSE);
} else {
@@ -616,32 +503,32 @@ get_property (GObject *object, guint property_id, GValue *value, GParamSpec *psp
xmlNodePtr root, node;
xmlDocPtr doc;
- item_id = e_search_bar_get_item_id ((ESearchBar *) efb);
+ item_id = e_search_bar_get_item_id ((ESearchBar *) filter_bar);
doc = xmlNewDoc ((const unsigned char *)"1.0");
root = xmlNewDocNode (doc, NULL, (const unsigned char *)"state", NULL);
xmlDocSetRootElement (doc, root);
- searchscope = e_search_bar_get_search_scope ((ESearchBar *) efb);
- view_id = e_search_bar_get_viewitem_id ((ESearchBar *) efb);
+ searchscope = e_search_bar_get_search_scope ((ESearchBar *) filter_bar);
+ view_id = e_search_bar_get_viewitem_id ((ESearchBar *) filter_bar);
if (searchscope < E_FILTERBAR_CURRENT_FOLDER_ID)
- item_id = esb->last_search_option;
+ item_id = search_bar->last_search_option;
if (item_id == E_FILTERBAR_ADVANCED_ID) {
/* advanced query, save the filterbar state */
node = xmlNewChild (root, NULL, (const unsigned char *)"filter-bar", NULL);
- sprintf (buf, "%d", esb->last_search_option);
+ sprintf (buf, "%d", search_bar->last_search_option);
xmlSetProp (node, (const unsigned char *)"item_id", (unsigned char *)buf);
sprintf (buf, "%d", searchscope);
xmlSetProp (node, (const unsigned char *)"searchscope", (unsigned char *)buf);
sprintf (buf, "%d", view_id);
xmlSetProp (node, (const unsigned char *)"view_id", (unsigned char *)buf);
- xmlAddChild (node, filter_rule_xml_encode (efb->current_query));
+ xmlAddChild (node, filter_rule_xml_encode (filter_bar->current_query));
} else {
/* simple query, save the searchbar state */
- text = e_search_bar_get_text ((ESearchBar *) efb);
+ text = e_search_bar_get_text ((ESearchBar *) filter_bar);
node = xmlNewChild (root, NULL, (const unsigned char *)"search-bar", NULL);
xmlSetProp (node, (const unsigned char *)"text", (unsigned char *)(text ? text : ""));
@@ -689,10 +576,13 @@ xml_get_prop_int (xmlNodePtr node, const char *prop)
}
static void
-set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+filter_bar_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EFilterBar *efb = (EFilterBar *) object;
- ESearchBar *esb = E_SEARCH_BAR (object);
+ EFilterBar *filter_bar = (EFilterBar *) object;
+ ESearchBar *search_bar = E_SEARCH_BAR (object);
xmlNodePtr root, node;
const char *state;
xmlDocPtr doc;
@@ -730,43 +620,43 @@ set_property (GObject *object, guint property_id, const GValue *value, GParamSpe
GtkStyle *style = gtk_widget_get_default_style ();
rule = filter_rule_new ();
- if (filter_rule_xml_decode (rule, node, efb->context) != 0) {
- gtk_widget_modify_base (E_SEARCH_BAR (efb)->entry, GTK_STATE_NORMAL, NULL);
- gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL);
- gtk_widget_modify_base (((ESearchBar *)efb)->icon_entry, GTK_STATE_NORMAL, NULL);
+ if (filter_rule_xml_decode (rule, node, filter_bar->context) != 0) {
+ gtk_widget_modify_base (E_SEARCH_BAR (filter_bar)->entry, GTK_STATE_NORMAL, NULL);
+ gtk_widget_modify_text (((ESearchBar *)filter_bar)->entry, GTK_STATE_NORMAL, NULL);
+ gtk_widget_modify_base (((ESearchBar *)filter_bar)->icon_entry, GTK_STATE_NORMAL, NULL);
g_object_unref (rule);
rule = NULL;
} else {
rule_set = TRUE;
- gtk_widget_set_sensitive (esb->clear_button, TRUE);
- gtk_widget_modify_base (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
- gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED]));
- gtk_widget_modify_base (((ESearchBar *)efb)->icon_entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
- gtk_widget_modify_base (((ESearchBar *)efb)->viewoption, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
+ gtk_widget_set_sensitive (search_bar->clear_button, TRUE);
+ gtk_widget_modify_base (((ESearchBar *)filter_bar)->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
+ gtk_widget_modify_text (((ESearchBar *)filter_bar)->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED]));
+ gtk_widget_modify_base (((ESearchBar *)filter_bar)->icon_entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
+ gtk_widget_modify_base (((ESearchBar *)filter_bar)->viewoption, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
g_object_set_data_full (object, "rule", rule, (GDestroyNotify) g_object_unref);
}
}
if (rule_set) {
- esb->block_search = TRUE;
- e_search_bar_set_text (esb, _("Advanced Search"));
- e_search_bar_set_item_menu ((ESearchBar *) efb, item_id);
- e_search_bar_set_search_scope ((ESearchBar *) efb, scope);
- esb->block_search = FALSE;
- efb->current_query = (FilterRule *)efb->option_rules->pdata[item_id - efb->option_base];
- if (efb->config && efb->current_query) {
- char *query = e_search_bar_get_text (esb);
- efb->config (efb, efb->current_query, item_id, query, efb->config_data);
+ search_bar->block_search = TRUE;
+ e_search_bar_set_text (search_bar, _("Advanced Search"));
+ e_search_bar_set_item_menu ((ESearchBar *) filter_bar, item_id);
+ e_search_bar_set_search_scope ((ESearchBar *) filter_bar, scope);
+ search_bar->block_search = FALSE;
+ filter_bar->current_query = (FilterRule *)filter_bar->option_rules->pdata[item_id - filter_bar->option_base];
+ if (filter_bar->config && filter_bar->current_query) {
+ char *query = e_search_bar_get_text (search_bar);
+ filter_bar->config (filter_bar, filter_bar->current_query, item_id, query, filter_bar->config_data);
g_free (query);
}
}
- e_search_bar_set_viewitem_id ((ESearchBar *) efb, view_id);
- efb->current_query = rule;
- efb->setquery = TRUE;
- e_search_bar_set_item_id ((ESearchBar *) efb, E_FILTERBAR_ADVANCED_ID);
- efb->setquery = FALSE;
+ e_search_bar_set_viewitem_id ((ESearchBar *) filter_bar, view_id);
+ filter_bar->current_query = rule;
+ filter_bar->setquery = TRUE;
+ e_search_bar_set_item_id ((ESearchBar *) filter_bar, E_FILTERBAR_ADVANCED_ID);
+ filter_bar->setquery = FALSE;
break;
} else if (!strcmp ((char *)node->name, "search-bar")) {
@@ -781,36 +671,36 @@ set_property (GObject *object, guint property_id, const GValue *value, GParamSpe
item_id = xml_get_prop_int (node, "item_id");
subitem_id = xml_get_prop_int (node, "subitem_id");
- esb->block_search = TRUE;
+ search_bar->block_search = TRUE;
if (subitem_id >= 0)
- e_search_bar_set_ids (E_SEARCH_BAR (efb), item_id, subitem_id);
+ e_search_bar_set_ids (E_SEARCH_BAR (filter_bar), item_id, subitem_id);
else
- e_search_bar_set_item_menu (E_SEARCH_BAR (efb), item_id);
- esb->block_search = FALSE;
+ e_search_bar_set_item_menu (E_SEARCH_BAR (filter_bar), item_id);
+ search_bar->block_search = FALSE;
view_id = xml_get_prop_int (node, "view_id");
- e_search_bar_set_viewitem_id (E_SEARCH_BAR (efb), view_id);
+ e_search_bar_set_viewitem_id (E_SEARCH_BAR (filter_bar), view_id);
scope = xml_get_prop_int (node, "searchscope");
- e_search_bar_set_search_scope (E_SEARCH_BAR (efb), scope);
+ e_search_bar_set_search_scope (E_SEARCH_BAR (filter_bar), scope);
text = (char *)xmlGetProp (node, (const unsigned char *)"text");
- e_search_bar_set_text (E_SEARCH_BAR (efb), text);
+ e_search_bar_set_text (E_SEARCH_BAR (filter_bar), text);
if (text && *text) {
- efb->current_query = (FilterRule *)efb->option_rules->pdata[item_id - efb->option_base];
- if (efb->config && efb->current_query)
- efb->config (efb, efb->current_query, item_id, text, efb->config_data);
- gtk_widget_set_sensitive (esb->clear_button, TRUE);
- gtk_widget_modify_base (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
- gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED]));
- gtk_widget_modify_base (((ESearchBar *)efb)->icon_entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
- gtk_widget_modify_base (((ESearchBar *)efb)->viewoption, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
+ filter_bar->current_query = (FilterRule *)filter_bar->option_rules->pdata[item_id - filter_bar->option_base];
+ if (filter_bar->config && filter_bar->current_query)
+ filter_bar->config (filter_bar, filter_bar->current_query, item_id, text, filter_bar->config_data);
+ gtk_widget_set_sensitive (search_bar->clear_button, TRUE);
+ gtk_widget_modify_base (((ESearchBar *)filter_bar)->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
+ gtk_widget_modify_text (((ESearchBar *)filter_bar)->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED]));
+ gtk_widget_modify_base (((ESearchBar *)filter_bar)->icon_entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
+ gtk_widget_modify_base (((ESearchBar *)filter_bar)->viewoption, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
} else {
- gtk_widget_modify_base (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL);
- gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL);
- gtk_widget_modify_base (((ESearchBar *)efb)->icon_entry, GTK_STATE_NORMAL, NULL);
- e_search_bar_paint (esb);
- efb->current_query = (FilterRule *)efb->option_rules->pdata[item_id - efb->option_base];
- if (efb->config && efb->current_query)
- efb->config (efb, efb->current_query, item_id, "", efb->config_data);
+ gtk_widget_modify_base (((ESearchBar *)filter_bar)->entry, GTK_STATE_NORMAL, NULL);
+ gtk_widget_modify_text (((ESearchBar *)filter_bar)->entry, GTK_STATE_NORMAL, NULL);
+ gtk_widget_modify_base (((ESearchBar *)filter_bar)->icon_entry, GTK_STATE_NORMAL, NULL);
+ e_search_bar_paint (search_bar);
+ filter_bar->current_query = (FilterRule *)filter_bar->option_rules->pdata[item_id - filter_bar->option_base];
+ if (filter_bar->config && filter_bar->current_query)
+ filter_bar->config (filter_bar, filter_bar->current_query, item_id, "", filter_bar->config_data);
}
xmlFree (text);
@@ -825,15 +715,15 @@ set_property (GObject *object, guint property_id, const GValue *value, GParamSpe
xmlFreeDoc (doc);
} else {
/* set default state */
- e_search_bar_set_item_id ((ESearchBar *) efb, 0);
- e_search_bar_set_viewitem_id ((ESearchBar *) efb, 0);
- e_search_bar_set_search_scope ((ESearchBar *) efb, E_FILTERBAR_CURRENT_FOLDER_ID);
+ e_search_bar_set_item_id ((ESearchBar *) filter_bar, 0);
+ e_search_bar_set_viewitem_id ((ESearchBar *) filter_bar, 0);
+ e_search_bar_set_search_scope ((ESearchBar *) filter_bar, E_FILTERBAR_CURRENT_FOLDER_ID);
}
/* we don't want to run option_changed */
- efb->setquery = TRUE;
- g_signal_emit_by_name (efb, "search_activated", NULL);
- efb->setquery = FALSE;
+ filter_bar->setquery = TRUE;
+ g_signal_emit_by_name (filter_bar, "search_activated", NULL);
+ filter_bar->setquery = FALSE;
break;
default:
@@ -842,22 +732,27 @@ set_property (GObject *object, guint property_id, const GValue *value, GParamSpe
}
}
-static void clear_rules(EFilterBar *efb, GPtrArray *rules)
+static void
+filter_bar_clear_rules (EFilterBar *filter_bar,
+ GPtrArray *rules)
{
- int i;
FilterRule *rule;
+ gint ii;
+
+ /* Clear out any data on old rules. */
+ for (ii = 0; ii < rules->len; ii++) {
+ FilterRule *rule = rules->pdata[ii];
- /* clear out any data on old rules */
- for (i=0;i<rules->len;i++) {
- rule = rules->pdata[i];
- g_signal_handlers_disconnect_by_func (rule, G_CALLBACK (rule_changed), efb);
+ g_signal_handlers_disconnect_by_func (
+ rule, G_CALLBACK (rule_changed), filter_bar);
g_object_unref(rule);
}
+
g_ptr_array_set_size (rules, 0);
}
static void
-dispose (GObject *object)
+filter_bar_dispose (GObject *object)
{
EFilterBar *bar;
@@ -870,8 +765,8 @@ dispose (GObject *object)
rule_context_save (bar->context, bar->userrules);
if (bar->menu_rules != NULL) {
- clear_rules(bar, bar->menu_rules);
- clear_rules(bar, bar->option_rules);
+ filter_bar_clear_rules (bar, bar->menu_rules);
+ filter_bar_clear_rules (bar, bar->option_rules);
g_ptr_array_free (bar->menu_rules, TRUE);
g_ptr_array_free (bar->option_rules, TRUE);
@@ -898,97 +793,97 @@ dispose (GObject *object)
bar->default_items = NULL;
}
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
-
static void
-class_init (EFilterBarClass *klass)
+class_init (EFilterBarClass *class)
{
- GObjectClass *object_class = (GObjectClass *) klass;
- ESearchBarClass *esb_class = (ESearchBarClass *) klass;
+ GObjectClass *object_class;
+ ESearchBarClass *search_bar_class;
GParamSpec *pspec;
- parent_class = g_type_class_ref (e_search_bar_get_type ());
-
- object_class->dispose = dispose;
- object_class->get_property = get_property;
- object_class->set_property = set_property;
-
- esb_class->set_menu = set_menu;
- esb_class->set_option = set_option;
-
- pspec = g_param_spec_string ("query", NULL, NULL, NULL, G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_QUERY, pspec);
-
- pspec = g_param_spec_string ("state", NULL, NULL, NULL, G_PARAM_READWRITE);
- g_object_class_install_property (object_class, PROP_STATE, pspec);
-
- /*gtk_object_add_arg_type ("EFilterBar::query", G_TYPE_STRING, GTK_ARG_READABLE, ARG_QUERY);*/
-
-#if 0
- esb_signals [QUERY_CHANGED] =
- g_signal_new ("query_changed",
- G_SIGNAL_RUN_LAST,
- object_class->type,
- G_STRUCT_OFFSET (EFilterBarClass, query_changed),
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- esb_signals [MENU_ACTIVATED] =
- g_signal_new ("menu_activated",
- G_SIGNAL_RUN_LAST,
- object_class->type,
- G_STRUCT_OFFSET (EFilterBarClass, menu_activated),
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
-
- gtk_object_class_add_signals (object_class, esb_signals, LAST_SIGNAL);
-#endif
+ parent_class = g_type_class_peek_parent (class);
+
+ object_class = G_OBJECT_CLASS (object_class);
+ object_class->set_property = filter_bar_set_property;
+ object_class->get_property = filter_bar_get_property;
+ object_class->dispose = filter_bar_dispose;
+
+ search_bar_class = E_SEARCH_BAR_CLASS (class);
+ search_bar_class->set_menu = set_menu;
+ search_bar_class->set_option = set_option;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_QUERY,
+ g_param_spec_string (
+ "query",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_STATE,
+ g_param_spec_string (
+ "state",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
}
static void
-init (EFilterBar *efb)
+filter_bar_init (EFilterBar *filter_bar)
{
- g_signal_connect (efb, "menu_activated", G_CALLBACK (menubar_activated), NULL);
- g_signal_connect (efb, "query_changed", G_CALLBACK (option_changed), NULL);
- g_signal_connect (efb, "search_activated", G_CALLBACK (option_changed), NULL);
+ g_signal_connect (filter_bar, "menu_activated", G_CALLBACK (menubar_activated), NULL);
+ g_signal_connect (filter_bar, "query_changed", G_CALLBACK (option_changed), NULL);
+ g_signal_connect (filter_bar, "search_activated", G_CALLBACK (option_changed), NULL);
- efb->menu_rules = g_ptr_array_new ();
- efb->option_rules = g_ptr_array_new ();
+ filter_bar->menu_rules = g_ptr_array_new ();
+ filter_bar->option_rules = g_ptr_array_new ();
}
-
-/* Object construction. */
-
-EFilterBar *
-e_filter_bar_new (RuleContext *context,
- const char *systemrules,
- const char *userrules,
- EFilterBarConfigRule config,
- void *data)
+GType
+e_filter_bar_get_type (void)
{
- EFilterBar *bar;
+ static GType type = 0;
- bar = g_object_new (e_filter_bar_get_type (), NULL);
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (EFilterBarClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) filter_bar_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EFilterBar),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) filter_bar_init,
+ NULL /* value_table */
+ };
- e_filter_bar_new_construct (context, systemrules, userrules, config, data, bar);
+ type = g_type_register_static (
+ E_TYPE_SEARCH_BAR, "EFilterBar", &type_info, 0);
+ }
- return bar;
+ return type;
}
-
-void
-e_filter_bar_new_construct (RuleContext *context,
- const char *systemrules,
- const char *userrules,
+EFilterBar *
+e_filter_bar_new (RuleContext *context,
+ const gchar *systemrules,
+ const gchar *userrules,
EFilterBarConfigRule config,
- void *data ,EFilterBar *bar )
+ gpointer data)
{
- ESearchBarItem item = { NULL, -1, 0 };
+ EFilterBar *bar;
+
+ bar = g_object_new (E_TYPE_FILTER_BAR, NULL);
- bar->context = context;
- g_object_ref (context);
+ bar->context = g_object_ref (context);
bar->config = config;
bar->config_data = data;
@@ -1000,35 +895,8 @@ e_filter_bar_new_construct (RuleContext *context,
bar->account_search_vf = NULL;
bar->account_search_cancel = NULL;
- e_search_bar_construct ((ESearchBar *)bar, &item, &item);
-
g_signal_connect (context, "changed", G_CALLBACK (context_changed), bar);
g_signal_connect (context, "rule_removed", G_CALLBACK (context_rule_removed), bar);
-}
-
-GType
-e_filter_bar_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static const GTypeInfo type_info = {
- sizeof (EFilterBarClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (EFilterBar),
- 0, /* n_preallocs */
- (GInstanceInitFunc) init,
- NULL /* value_table */
- };
-
- type = g_type_register_static (
- e_search_bar_get_type (), "EFilterBar", &type_info, 0);
- }
-
- return type;
+ return bar;
}
diff --git a/widgets/misc/e-filter-bar.h b/widgets/misc/e-filter-bar.h
index 5caf803485..ca53f3aeb0 100644
--- a/widgets/misc/e-filter-bar.h
+++ b/widgets/misc/e-filter-bar.h
@@ -17,8 +17,8 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-#ifndef __E_FILTER_BAR_H__
-#define __E_FILTER_BAR_H__
+#ifndef E_FILTER_BAR_H
+#define E_FILTER_BAR_H
#include <gtk/gtk.h>
#include <camel/camel-vee-folder.h>
@@ -29,11 +29,6 @@
#include "filter/rule-context.h"
#include "filter/filter-rule.h"
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
/* EFilterBar - A filter rule driven search bar.
*
* The following arguments are available:
@@ -44,14 +39,29 @@ extern "C" {
* state string RW XML string representing the state.
*/
-#define E_FILTER_BAR_TYPE (e_filter_bar_get_type ())
-#define E_FILTER_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_FILTER_BAR_TYPE, EFilterBar))
-#define E_FILTER_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_FILTER_BAR_TYPE, EFilterBarClass))
-#define E_IS_FILTER_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_FILTER_BAR_TYPE))
-#define E_IS_FILTER_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_FILTER_BAR_TYPE))
-
-typedef struct _EFilterBar EFilterBar;
-typedef struct _EFilterBarClass EFilterBarClass;
+/* Standard GObject macros */
+#define E_TYPE_FILTER_BAR \
+ (e_filter_bar_get_type ())
+#define E_FILTER_BAR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_FILTER_BAR, EFilterBar))
+#define E_FILTER_BAR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_FILTER_BAR, EFilterBarClass))
+#define E_IS_FILTER_BAR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_FILTER_BAR))
+#define E_IS_FILTER_BAR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((obj), E_TYPE_FILTER_BAR))
+#define E_FILTER_BAR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_FILTER_BAR, EFilterBarClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EFilterBar EFilterBar;
+typedef struct _EFilterBarClass EFilterBarClass;
typedef void (*EFilterBarConfigRule)(EFilterBar *, FilterRule *rule, int id, const char *query, void *data);
@@ -79,8 +89,7 @@ struct _EFilterBar {
CamelOperation *account_search_cancel;
};
-struct _EFilterBarClass
-{
+struct _EFilterBarClass {
ESearchBarClass parent_class;
};
@@ -116,23 +125,13 @@ const char * strings[] = {
#endif
-GType e_filter_bar_get_type (void);
-
-EFilterBar *e_filter_bar_new (RuleContext *context,
- const char *systemrules,
- const char *userrules,
- EFilterBarConfigRule config,
- void *data);
-void
-e_filter_bar_new_construct (RuleContext *context,
- const char *systemrules,
- const char *userrules,
- EFilterBarConfigRule config,
- void *data ,EFilterBar *bar );
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+GType e_filter_bar_get_type (void);
+EFilterBar * e_filter_bar_new (RuleContext *context,
+ const gchar *systemrules,
+ const gchar *userrules,
+ EFilterBarConfigRule config,
+ gpointer data);
+G_END_DECLS
-#endif /* __E_FILTER_BAR_H__ */
+#endif /* E_FILTER_BAR_H */
diff --git a/widgets/misc/e-icon-entry.c b/widgets/misc/e-icon-entry.c
index 500b27e6db..1c9ed12d96 100644
--- a/widgets/misc/e-icon-entry.c
+++ b/widgets/misc/e-icon-entry.c
@@ -69,7 +69,6 @@ icon_entry_create_proxy (GtkAction *action)
gtk_event_box_set_visible_window (GTK_EVENT_BOX (proxy), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (proxy), 2);
gtk_action_connect_proxy (action, proxy);
- gtk_widget_show (widget);
widget = gtk_action_create_icon (action, GTK_ICON_SIZE_MENU);
gtk_container_add (GTK_CONTAINER (proxy), widget);
diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c
index fcfe002843..fa8b099569 100644
--- a/widgets/misc/e-search-bar.c
+++ b/widgets/misc/e-search-bar.c
@@ -45,6 +45,9 @@
((obj), E_TYPE_SEARCH_BAR, ESearchBarPrivate))
struct _ESearchBarPrivate {
+ RuleContext *context;
+ FilterRule *current_query;
+
GtkWidget *filter_label;
GtkWidget *filter_combo_box;
GtkWidget *search_label;
@@ -60,6 +63,7 @@ struct _ESearchBarPrivate {
enum {
PROP_0,
+ PROP_CONTEXT,
PROP_FILTER_ACTION,
PROP_FILTER_VALUE,
PROP_FILTER_VISIBLE,
@@ -123,6 +127,20 @@ static GtkActionEntry search_entries[] = {
};
static void
+search_bar_rule_changed (FilterRule *rule,
+ GtkDialog *dialog)
+{
+ gboolean sensitive;
+
+ sensitive = (rule != NULL && rule->parts != NULL);
+
+ gtk_dialog_set_response_sensitive (
+ dialog, GTK_RESPONSE_OK, sensitive);
+ gtk_dialog_set_response_sensitive (
+ dialog, GTK_RESPONSE_APPLY, sensitive);
+}
+
+static void
search_bar_update_search_popup (ESearchBar *search_bar)
{
GtkAction *action;
@@ -355,6 +373,12 @@ search_bar_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_CONTEXT:
+ e_search_bar_set_context (
+ E_SEARCH_BAR (object),
+ g_value_get_object (value));
+ return;
+
case PROP_FILTER_ACTION:
e_search_bar_set_filter_action (
E_SEARCH_BAR (object),
@@ -426,6 +450,12 @@ search_bar_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_CONTEXT:
+ g_value_set_object (
+ value, e_search_bar_get_context (
+ E_SEARCH_BAR (object)));
+ return;
+
case PROP_FILTER_ACTION:
g_value_set_object (
value, e_search_bar_get_filter_action (
@@ -497,6 +527,11 @@ search_bar_dispose (GObject *object)
priv = E_SEARCH_BAR_GET_PRIVATE (object);
+ if (priv->context != NULL) {
+ g_object_unref (priv->context);
+ priv->context = NULL;
+ }
+
if (priv->filter_label != NULL) {
g_object_unref (priv->filter_label);
priv->filter_label = NULL;
@@ -556,6 +591,16 @@ search_bar_class_init (ESearchBarClass *class)
g_object_class_install_property (
object_class,
+ PROP_CONTEXT,
+ g_param_spec_object (
+ "context",
+ NULL,
+ NULL,
+ RULE_TYPE_CONTEXT,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
PROP_FILTER_ACTION,
g_param_spec_object (
"filter-action",
@@ -809,6 +854,28 @@ e_search_bar_get_action_group (ESearchBar *search_bar)
return search_bar->priv->action_group;
}
+RuleContext *
+e_search_bar_get_context (ESearchBar *search_bar)
+{
+ g_return_val_if_fail (E_IS_SEARCH_BAR (search_bar), NULL);
+
+ return search_bar->priv->context;
+}
+
+void
+e_search_bar_set_context (ESearchBar *search_bar,
+ RuleContext *context)
+{
+ g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
+ g_return_if_fail (IS_RULE_CONTEXT (context));
+
+ if (search_bar->priv->context != NULL)
+ g_object_unref (search_bar->priv->context);
+
+ search_bar->priv->context = g_object_ref (context);
+ g_object_notify (G_OBJECT (search_bar), "context");
+}
+
GtkRadioAction *
e_search_bar_get_filter_action (ESearchBar *search_bar)
{
@@ -950,6 +1017,7 @@ e_search_bar_set_search_text (ESearchBar *search_bar,
icon_entry = E_ICON_ENTRY (search_bar->priv->search_entry);
entry = e_icon_entry_get_entry (icon_entry);
+ text = (text != NULL) ? text : "";
gtk_entry_set_text (GTK_ENTRY (entry), text);
g_object_notify (G_OBJECT (search_bar), "search-text");
}
@@ -1076,3 +1144,77 @@ e_search_bar_set_scope_visible (ESearchBar *search_bar,
g_object_notify (G_OBJECT (search_bar), "scope-visible");
}
+
+static void
+search_bar_rule_changed_cb (FilterRule *rule,
+ GtkDialog *dialog)
+{
+ /* FIXME Think this does something with sensitivity. */
+}
+
+void
+e_search_bar_save_search_dialog (ESearchBar *search_bar,
+ const gchar *filename)
+{
+ RuleContext *context;
+ FilterRule *rule;
+ GtkWidget *dialog;
+ GtkWidget *parent;
+ GtkWidget *widget;
+ const gchar *search_text;
+ gchar *rule_name;
+
+ g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
+ g_return_if_fail (filename != NULL);
+
+ g_return_if_fail (search_bar->priv->current_query != NULL);
+
+ rule = filter_rule_clone (search_bar->priv->current_query);
+ search_text = e_search_bar_get_search_text (search_bar);
+ if (search_text == NULL || *search_text == '\0')
+ search_text = "''";
+
+ rule_name = g_strdup_printf ("%s %s", rule->name, search_text);
+ filter_rule_set_name (rule, rule_name);
+ g_free (rule_name);
+
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (search_bar));
+
+ dialog = gtk_dialog_new_with_buttons (
+ _("Save Search"), GTK_WINDOW (parent),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
+ NULL);
+
+ gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 300);
+ 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);
+
+ context = search_bar->priv->context;
+ widget = filter_rule_get_widget (rule, context);
+ filter_rule_set_source (rule, FILTER_SOURCE_INCOMING);
+ gtk_container_set_border_width (GTK_CONTAINER (widget), 12);
+ gtk_box_pack_start (
+ GTK_BOX (GTK_DIALOG (dialog)->vbox),
+ widget, TRUE, TRUE, 0);
+
+ g_signal_connect (
+ rule, "changed",
+ G_CALLBACK (search_bar_rule_changed_cb),
+ dialog);
+
+ search_bar_rule_changed_cb (rule, GTK_DIALOG (dialog));
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
+ if (filter_rule_validate (rule)) {
+ rule_context_add_rule (context, rule);
+ rule_context_save (context, filename);
+ }
+ }
+
+ gtk_widget_destroy (dialog);
+}
diff --git a/widgets/misc/e-search-bar.h b/widgets/misc/e-search-bar.h
index 56883e27bc..dd51edd698 100644
--- a/widgets/misc/e-search-bar.h
+++ b/widgets/misc/e-search-bar.h
@@ -22,6 +22,7 @@
#define E_SEARCH_BAR_H
#include <gtk/gtk.h>
+#include <filter/rule-context.h>
/* Standard GObject macros */
#define E_TYPE_SEARCH_BAR \
@@ -67,6 +68,9 @@ struct _ESearchBarClass
GType e_search_bar_get_type (void);
GtkWidget * e_search_bar_new (void);
GtkActionGroup *e_search_bar_get_action_group (ESearchBar *search_bar);
+RuleContext * e_search_bar_get_context (ESearchBar *search_bar);
+void e_search_bar_set_context (ESearchBar *search_bar,
+ RuleContext *context);
GtkRadioAction *e_search_bar_get_filter_action (ESearchBar *search_bar);
void e_search_bar_set_filter_action (ESearchBar *search_bar,
GtkRadioAction *action);
@@ -97,6 +101,8 @@ void e_search_bar_set_scope_value (ESearchBar *search_bar,
gboolean e_search_bar_get_scope_visible (ESearchBar *search_bar);
void e_search_bar_set_scope_visible (ESearchBar *search_bar,
gboolean visible);
+void e_search_bar_save_search_dialog (ESearchBar *search_bar,
+ const gchar *filename);
G_END_DECLS