aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-12-19 07:23:48 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-12-19 11:38:00 +0800
commit4cbbdedf522a6ac10df93a128bbf25f67173d66e (patch)
treefab7bf95e0927e4fa98c58a659e310afff7153ee
parenta1efb837566cdac798cd8777dd34e06e9782cf61 (diff)
downloadgsoc2013-evolution-4cbbdedf522a6ac10df93a128bbf25f67173d66e.tar.gz
gsoc2013-evolution-4cbbdedf522a6ac10df93a128bbf25f67173d66e.tar.zst
gsoc2013-evolution-4cbbdedf522a6ac10df93a128bbf25f67173d66e.zip
Refactor the EShell search API.
Move the search interface to a new widget: EShellSearchbar The current search rule is now stored in EShellView, and the search context in EShellViewClass similar to GalViewCollection (since it's class-specific, not instance-specific). Also add a couple new signals to EShellView: "clear-search" and "custom-search" ("custom" refers to an advanced search or a saved search -- something more complex than a quick search). Still working out a few kinks. The search entry is clearly trying to be too many things. We need a different way of indicating that you're looking at search results. Perhaps a search results banner similar to Nautilus.
-rw-r--r--doc/reference/shell/eshell-docs.sgml1
-rw-r--r--doc/reference/shell/eshell-sections.txt71
-rw-r--r--doc/reference/shell/eshell.types1
-rw-r--r--doc/reference/shell/tmpl/e-shell-content.sgml272
-rw-r--r--doc/reference/shell/tmpl/e-shell-searchbar.sgml223
-rw-r--r--doc/reference/shell/tmpl/e-shell-view.sgml84
-rw-r--r--doc/reference/shell/tmpl/eshell-unused.sgml264
-rw-r--r--modules/addressbook/e-book-shell-content.c55
-rw-r--r--modules/addressbook/e-book-shell-content.h8
-rw-r--r--modules/addressbook/e-book-shell-view-actions.c32
-rw-r--r--modules/addressbook/e-book-shell-view-private.h1
-rw-r--r--modules/addressbook/e-book-shell-view.c23
-rw-r--r--modules/calendar/e-cal-shell-content.c15
-rw-r--r--modules/calendar/e-cal-shell-content.h4
-rw-r--r--modules/calendar/e-cal-shell-view-actions.c37
-rw-r--r--modules/calendar/e-cal-shell-view.c16
-rw-r--r--modules/calendar/e-memo-shell-content.c15
-rw-r--r--modules/calendar/e-memo-shell-content.h4
-rw-r--r--modules/calendar/e-memo-shell-view-actions.c34
-rw-r--r--modules/calendar/e-memo-shell-view.c14
-rw-r--r--modules/calendar/e-task-shell-content.c15
-rw-r--r--modules/calendar/e-task-shell-content.h4
-rw-r--r--modules/calendar/e-task-shell-view-actions.c36
-rw-r--r--modules/calendar/e-task-shell-view.c15
-rw-r--r--modules/mail/e-mail-shell-content.c17
-rw-r--r--modules/mail/e-mail-shell-content.h4
-rw-r--r--modules/mail/e-mail-shell-view-actions.c68
-rw-r--r--modules/mail/e-mail-shell-view-private.c14
-rw-r--r--modules/mail/e-mail-shell-view-private.h1
-rw-r--r--modules/mail/e-mail-shell-view.c21
-rw-r--r--shell/Makefile.am2
-rw-r--r--shell/e-shell-content.c1334
-rw-r--r--shell/e-shell-content.h67
-rw-r--r--shell/e-shell-searchbar.c1053
-rw-r--r--shell/e-shell-searchbar.h119
-rw-r--r--shell/e-shell-view.c292
-rw-r--r--shell/e-shell-view.h33
-rw-r--r--shell/e-shell-window-actions.c36
38 files changed, 2563 insertions, 1742 deletions
diff --git a/doc/reference/shell/eshell-docs.sgml b/doc/reference/shell/eshell-docs.sgml
index 9c4e875992..b744d9c78a 100644
--- a/doc/reference/shell/eshell-docs.sgml
+++ b/doc/reference/shell/eshell-docs.sgml
@@ -20,6 +20,7 @@ url="http://mbarnes.fedorapeople.org/docs/eshell/">http://mbarnes.fedorapeople.o
<xi:include href="xml/e-shell-content.xml"/>
<xi:include href="xml/e-shell-sidebar.xml"/>
<xi:include href="xml/e-shell-taskbar.xml"/>
+ <xi:include href="xml/e-shell-searchbar.xml"/>
<xi:include href="xml/e-shell-settings.xml"/>
<xi:include href="xml/e-shell-switcher.xml"/>
<xi:include href="xml/e-shell-utils.xml"/>
diff --git a/doc/reference/shell/eshell-sections.txt b/doc/reference/shell/eshell-sections.txt
index 0b67e41ef7..7dc8df9e72 100644
--- a/doc/reference/shell/eshell-sections.txt
+++ b/doc/reference/shell/eshell-sections.txt
@@ -69,37 +69,15 @@ EShellBackendPrivate
<TITLE>EShellContent</TITLE>
EShellContent
e_shell_content_new
+e_shell_content_get_searchbar
e_shell_content_check_state
e_shell_content_get_shell_view
-e_shell_content_get_filter_action
-e_shell_content_set_filter_action
-e_shell_content_get_filter_value
-e_shell_content_set_filter_value
-e_shell_content_get_filter_visible
-e_shell_content_set_filter_visible
-e_shell_content_add_filter_separator_before
-e_shell_content_add_filter_separator_after
-e_shell_content_get_search_context
-e_shell_content_get_search_hint
-e_shell_content_set_search_hint
-e_shell_content_get_search_rule
-e_shell_content_set_search_rule
-e_shell_content_get_search_text
-e_shell_content_set_search_text
-e_shell_content_get_search_visible
-e_shell_content_set_search_visible
-e_shell_content_get_scope_action
-e_shell_content_set_scope_action
-e_shell_content_get_scope_value
-e_shell_content_set_scope_value
-e_shell_content_get_scope_visible
-e_shell_content_set_scope_visible
e_shell_content_get_view_id
e_shell_content_set_view_id
+e_shell_content_get_search_name
e_shell_content_run_advanced_search_dialog
e_shell_content_run_edit_searches_dialog
e_shell_content_run_save_search_dialog
-e_shell_content_restore_state
<SUBSECTION Standard>
E_SHELL_CONTENT
E_IS_SHELL_CONTENT
@@ -114,6 +92,40 @@ EShellContentPrivate
</SECTION>
<SECTION>
+<FILE>e-shell-searchbar</FILE>
+<TITLE>EShellSearchbar</TITLE>
+EShellSearchbar
+e_shell_searchbar_new
+e_shell_searchbar_get_shell_view
+e_shell_searchbar_get_filter_combo_box
+e_shell_searchbar_get_filter_visible
+e_shell_searchbar_set_filter_visible
+e_shell_searchbar_get_search_hint
+e_shell_searchbar_set_search_hint
+e_shell_searchbar_get_search_option
+e_shell_searchbar_set_search_option
+e_shell_searchbar_get_search_text
+e_shell_searchbar_set_search_text
+e_shell_searchbar_get_search_visible
+e_shell_searchbar_set_search_visible
+e_shell_searchbar_get_scope_combo_box
+e_shell_searchbar_get_scope_visible
+e_shell_searchbar_set_scope_visible
+e_shell_searchbar_restore_state
+<SUBSECTION Standard>
+E_SHELL_SEARCHBAR
+E_IS_SHELL_SEARCHBAR
+E_TYPE_SHELL_SEARCHBAR
+E_SHELL_SEARCHBAR_CLASS
+E_IS_SHELL_SEARCHBAR_CLASS
+E_SHELL_SEARCHBAR_GET_CLASS
+EShellSearchbarClass
+e_shell_searchbar_get_type
+<SUBSECTION Private>
+EShellSearchbarPrivate
+</SECTION>
+
+<SECTION>
<FILE>e-shell-settings</FILE>
<TITLE>EShellSettings</TITLE>
EShellSettings
@@ -240,6 +252,9 @@ e_shell_view_set_view_id
e_shell_view_is_active
e_shell_view_get_page_num
e_shell_view_set_page_num
+e_shell_view_get_search_rule
+e_shell_view_set_search_rule
+e_shell_view_get_search_query
e_shell_view_get_size_group
e_shell_view_get_shell_backend
e_shell_view_get_shell_content
@@ -248,7 +263,11 @@ e_shell_view_get_shell_taskbar
e_shell_view_get_shell_window
e_shell_view_get_state_key_file
e_shell_view_set_state_dirty
+e_shell_view_clear_search
+e_shell_view_custom_search
e_shell_view_execute_search
+e_shell_view_block_execute_search
+e_shell_view_unblock_execute_search
e_shell_view_update_actions
e_shell_view_show_popup_menu
e_shell_view_new_view_instance
@@ -330,10 +349,6 @@ E_ALERT_NO_SAVE_FILE
E_ALERT_NO_LOAD_FILE
EAlert
e_alert_new
-e_alert_newv
-e_alert_free
-e_alert_new_dialog
-e_alert_new_dialog_for_args
e_alert_run_dialog
e_alert_run_dialog_for_args
e_alert_dialog_count_buttons
diff --git a/doc/reference/shell/eshell.types b/doc/reference/shell/eshell.types
index e03302f8d5..ae84ef0905 100644
--- a/doc/reference/shell/eshell.types
+++ b/doc/reference/shell/eshell.types
@@ -6,6 +6,7 @@ e_signature_list_get_type
e_shell_get_type
e_shell_backend_get_type
e_shell_content_get_type
+e_shell_searchbar_get_type
e_shell_sidebar_get_type
e_shell_switcher_get_type
e_shell_taskbar_get_type
diff --git a/doc/reference/shell/tmpl/e-shell-content.sgml b/doc/reference/shell/tmpl/e-shell-content.sgml
index fb17dd86bf..b4803b93b0 100644
--- a/doc/reference/shell/tmpl/e-shell-content.sgml
+++ b/doc/reference/shell/tmpl/e-shell-content.sgml
@@ -23,66 +23,6 @@ EShellContent
</para>
-<!-- ##### ARG EShellContent:filter-action ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG EShellContent:filter-value ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG EShellContent:filter-visible ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG EShellContent:scope-action ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG EShellContent:scope-value ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG EShellContent:scope-visible ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG EShellContent:search-context ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG EShellContent:search-hint ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG EShellContent:search-radio-action ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG EShellContent:search-rule ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG EShellContent:search-text ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG EShellContent:search-visible ##### -->
-<para>
-
-</para>
-
<!-- ##### ARG EShellContent:shell-view ##### -->
<para>
@@ -97,7 +37,7 @@ EShellContent
@Returns:
-<!-- ##### FUNCTION e_shell_content_check_state ##### -->
+<!-- ##### FUNCTION e_shell_content_get_searchbar ##### -->
<para>
</para>
@@ -106,169 +46,7 @@ EShellContent
@Returns:
-<!-- ##### FUNCTION e_shell_content_get_shell_view ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@Returns:
-
-
-<!-- ##### FUNCTION e_shell_content_get_filter_action ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@Returns:
-
-
-<!-- ##### FUNCTION e_shell_content_set_filter_action ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@filter_action:
-
-
-<!-- ##### FUNCTION e_shell_content_get_filter_value ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@Returns:
-
-
-<!-- ##### FUNCTION e_shell_content_set_filter_value ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@filter_value:
-
-
-<!-- ##### FUNCTION e_shell_content_get_filter_visible ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@Returns:
-
-
-<!-- ##### FUNCTION e_shell_content_set_filter_visible ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@filter_visible:
-
-
-<!-- ##### FUNCTION e_shell_content_add_filter_separator_before ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@action_value:
-
-
-<!-- ##### FUNCTION e_shell_content_add_filter_separator_after ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@action_value:
-
-
-<!-- ##### FUNCTION e_shell_content_get_search_context ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@Returns:
-
-
-<!-- ##### FUNCTION e_shell_content_get_search_hint ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@Returns:
-
-
-<!-- ##### FUNCTION e_shell_content_set_search_hint ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@search_hint:
-
-
-<!-- ##### FUNCTION e_shell_content_get_search_rule ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@Returns:
-
-
-<!-- ##### FUNCTION e_shell_content_set_search_rule ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@search_rule:
-
-
-<!-- ##### FUNCTION e_shell_content_get_search_text ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@Returns:
-
-
-<!-- ##### FUNCTION e_shell_content_set_search_text ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@search_text:
-
-
-<!-- ##### FUNCTION e_shell_content_get_search_visible ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@Returns:
-
-
-<!-- ##### FUNCTION e_shell_content_set_search_visible ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@search_visible:
-
-
-<!-- ##### FUNCTION e_shell_content_get_scope_action ##### -->
+<!-- ##### FUNCTION e_shell_content_check_state ##### -->
<para>
</para>
@@ -277,16 +55,7 @@ EShellContent
@Returns:
-<!-- ##### FUNCTION e_shell_content_set_scope_action ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@scope_action:
-
-
-<!-- ##### FUNCTION e_shell_content_get_scope_value ##### -->
+<!-- ##### FUNCTION e_shell_content_get_shell_view ##### -->
<para>
</para>
@@ -295,16 +64,7 @@ EShellContent
@Returns:
-<!-- ##### FUNCTION e_shell_content_set_scope_value ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@scope_value:
-
-
-<!-- ##### FUNCTION e_shell_content_get_scope_visible ##### -->
+<!-- ##### FUNCTION e_shell_content_get_view_id ##### -->
<para>
</para>
@@ -313,16 +73,16 @@ EShellContent
@Returns:
-<!-- ##### FUNCTION e_shell_content_set_scope_visible ##### -->
+<!-- ##### FUNCTION e_shell_content_set_view_id ##### -->
<para>
</para>
@shell_content:
-@scope_visible:
+@view_id:
-<!-- ##### FUNCTION e_shell_content_get_view_id ##### -->
+<!-- ##### FUNCTION e_shell_content_get_search_name ##### -->
<para>
</para>
@@ -331,15 +91,6 @@ EShellContent
@Returns:
-<!-- ##### FUNCTION e_shell_content_set_view_id ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@view_id:
-
-
<!-- ##### FUNCTION e_shell_content_run_advanced_search_dialog ##### -->
<para>
@@ -364,12 +115,3 @@ EShellContent
@shell_content:
-<!-- ##### FUNCTION e_shell_content_restore_state ##### -->
-<para>
-
-</para>
-
-@shell_content:
-@group_name:
-
-
diff --git a/doc/reference/shell/tmpl/e-shell-searchbar.sgml b/doc/reference/shell/tmpl/e-shell-searchbar.sgml
new file mode 100644
index 0000000000..a491daf40a
--- /dev/null
+++ b/doc/reference/shell/tmpl/e-shell-searchbar.sgml
@@ -0,0 +1,223 @@
+<!-- ##### SECTION Title ##### -->
+EShellSearchbar
+
+<!-- ##### SECTION Short_Description ##### -->
+
+
+<!-- ##### SECTION Long_Description ##### -->
+<para>
+
+</para>
+
+<!-- ##### SECTION See_Also ##### -->
+<para>
+
+</para>
+
+<!-- ##### SECTION Stability_Level ##### -->
+
+
+<!-- ##### STRUCT EShellSearchbar ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG EShellSearchbar:filter-combo-box ##### -->
+<para>
+
+</para>
+
+<!-- ##### ARG EShellSearchbar:filter-visible ##### -->
+<para>
+
+</para>
+
+<!-- ##### ARG EShellSearchbar:scope-combo-box ##### -->
+<para>
+
+</para>
+
+<!-- ##### ARG EShellSearchbar:scope-visible ##### -->
+<para>
+
+</para>
+
+<!-- ##### ARG EShellSearchbar:search-hint ##### -->
+<para>
+
+</para>
+
+<!-- ##### ARG EShellSearchbar:search-option ##### -->
+<para>
+
+</para>
+
+<!-- ##### ARG EShellSearchbar:search-text ##### -->
+<para>
+
+</para>
+
+<!-- ##### ARG EShellSearchbar:search-visible ##### -->
+<para>
+
+</para>
+
+<!-- ##### ARG EShellSearchbar:shell-view ##### -->
+<para>
+
+</para>
+
+<!-- ##### FUNCTION e_shell_searchbar_new ##### -->
+<para>
+
+</para>
+
+@shell_view:
+@Returns:
+
+
+<!-- ##### FUNCTION e_shell_searchbar_get_shell_view ##### -->
+<para>
+
+</para>
+
+@searchbar:
+@Returns:
+
+
+<!-- ##### FUNCTION e_shell_searchbar_get_filter_combo_box ##### -->
+<para>
+
+</para>
+
+@searchbar:
+@Returns:
+
+
+<!-- ##### FUNCTION e_shell_searchbar_get_filter_visible ##### -->
+<para>
+
+</para>
+
+@searchbar:
+@Returns:
+
+
+<!-- ##### FUNCTION e_shell_searchbar_set_filter_visible ##### -->
+<para>
+
+</para>
+
+@searchbar:
+@filter_visible:
+
+
+<!-- ##### FUNCTION e_shell_searchbar_get_search_hint ##### -->
+<para>
+
+</para>
+
+@searchbar:
+@Returns:
+
+
+<!-- ##### FUNCTION e_shell_searchbar_set_search_hint ##### -->
+<para>
+
+</para>
+
+@searchbar:
+@search_hint:
+
+
+<!-- ##### FUNCTION e_shell_searchbar_get_search_option ##### -->
+<para>
+
+</para>
+
+@searchbar:
+@Returns:
+
+
+<!-- ##### FUNCTION e_shell_searchbar_set_search_option ##### -->
+<para>
+
+</para>
+
+@searchbar:
+@search_option:
+
+
+<!-- ##### FUNCTION e_shell_searchbar_get_search_text ##### -->
+<para>
+
+</para>
+
+@searchbar:
+@Returns:
+
+
+<!-- ##### FUNCTION e_shell_searchbar_set_search_text ##### -->
+<para>
+
+</para>
+
+@searchbar:
+@search_text:
+
+
+<!-- ##### FUNCTION e_shell_searchbar_get_search_visible ##### -->
+<para>
+
+</para>
+
+@searchbar:
+@Returns:
+
+
+<!-- ##### FUNCTION e_shell_searchbar_set_search_visible ##### -->
+<para>
+
+</para>
+
+@searchbar:
+@search_visible:
+
+
+<!-- ##### FUNCTION e_shell_searchbar_get_scope_combo_box ##### -->
+<para>
+
+</para>
+
+@searchbar:
+@Returns:
+
+
+<!-- ##### FUNCTION e_shell_searchbar_get_scope_visible ##### -->
+<para>
+
+</para>
+
+@searchbar:
+@Returns:
+
+
+<!-- ##### FUNCTION e_shell_searchbar_set_scope_visible ##### -->
+<para>
+
+</para>
+
+@searchbar:
+@scope_visible:
+
+
+<!-- ##### FUNCTION e_shell_searchbar_restore_state ##### -->
+<para>
+
+</para>
+
+@searchbar:
+@group_name:
+
+
diff --git a/doc/reference/shell/tmpl/e-shell-view.sgml b/doc/reference/shell/tmpl/e-shell-view.sgml
index 0508608faf..03d8830fdb 100644
--- a/doc/reference/shell/tmpl/e-shell-view.sgml
+++ b/doc/reference/shell/tmpl/e-shell-view.sgml
@@ -23,6 +23,21 @@ EShellView
</para>
+<!-- ##### SIGNAL EShellView::clear-search ##### -->
+<para>
+
+</para>
+
+@eshellview: the object which received the signal.
+
+<!-- ##### SIGNAL EShellView::custom-search ##### -->
+<para>
+
+</para>
+
+@eshellview: the object which received the signal.
+@arg1:
+
<!-- ##### SIGNAL EShellView::execute-search ##### -->
<para>
@@ -54,6 +69,11 @@ EShellView
</para>
+<!-- ##### ARG EShellView:search-rule ##### -->
+<para>
+
+</para>
+
<!-- ##### ARG EShellView:shell-backend ##### -->
<para>
@@ -104,6 +124,8 @@ EShellView
@icon_name:
@ui_definition:
@ui_manager_id:
+@search_context_type:
+@search_context:
@search_options:
@search_rules:
@view_collection:
@@ -112,6 +134,8 @@ EShellView
@new_shell_sidebar:
@new_shell_taskbar:
@toggled:
+@clear_search:
+@custom_search:
@execute_search:
@update_actions:
@@ -196,6 +220,33 @@ EShellView
@page_num:
+<!-- ##### FUNCTION e_shell_view_get_search_rule ##### -->
+<para>
+
+</para>
+
+@shell_view:
+@Returns:
+
+
+<!-- ##### FUNCTION e_shell_view_set_search_rule ##### -->
+<para>
+
+</para>
+
+@shell_view:
+@search_rule:
+
+
+<!-- ##### FUNCTION e_shell_view_get_search_query ##### -->
+<para>
+
+</para>
+
+@shell_view:
+@Returns:
+
+
<!-- ##### FUNCTION e_shell_view_get_size_group ##### -->
<para>
@@ -267,6 +318,23 @@ EShellView
@shell_view:
+<!-- ##### FUNCTION e_shell_view_clear_search ##### -->
+<para>
+
+</para>
+
+@shell_view:
+
+
+<!-- ##### FUNCTION e_shell_view_custom_search ##### -->
+<para>
+
+</para>
+
+@shell_view:
+@custom_rule:
+
+
<!-- ##### FUNCTION e_shell_view_execute_search ##### -->
<para>
@@ -275,6 +343,22 @@ EShellView
@shell_view:
+<!-- ##### FUNCTION e_shell_view_block_execute_search ##### -->
+<para>
+
+</para>
+
+@shell_view:
+
+
+<!-- ##### FUNCTION e_shell_view_unblock_execute_search ##### -->
+<para>
+
+</para>
+
+@shell_view:
+
+
<!-- ##### FUNCTION e_shell_view_update_actions ##### -->
<para>
diff --git a/doc/reference/shell/tmpl/eshell-unused.sgml b/doc/reference/shell/tmpl/eshell-unused.sgml
index 359f603599..f0e339d5ab 100644
--- a/doc/reference/shell/tmpl/eshell-unused.sgml
+++ b/doc/reference/shell/tmpl/eshell-unused.sgml
@@ -509,12 +509,84 @@ intelligent
</para>
+<!-- ##### ARG EShellContent:filter-action ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG EShellContent:filter-value ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG EShellContent:filter-visible ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG EShellContent:scope-action ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG EShellContent:scope-value ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG EShellContent:scope-visible ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG EShellContent:search-context ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG EShellContent:search-hint ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG EShellContent:search-radio-action ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG EShellContent:search-rule ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG EShellContent:search-text ##### -->
+<para>
+
+</para>
+
+
<!-- ##### ARG EShellContent:search-value ##### -->
<para>
</para>
+<!-- ##### ARG EShellContent:search-visible ##### -->
+<para>
+
+</para>
+
+
<!-- ##### ENUM EShellLineStatus ##### -->
<para>
@@ -2068,6 +2140,22 @@ intelligent
@shell_backend:
@Returns:
+<!-- ##### FUNCTION e_shell_content_add_filter_separator_after ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@action_value:
+
+<!-- ##### FUNCTION e_shell_content_add_filter_separator_before ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@action_value:
+
<!-- ##### FUNCTION e_shell_content_get_context ##### -->
<para>
@@ -2076,6 +2164,86 @@ intelligent
@shell_content:
@Returns:
+<!-- ##### FUNCTION e_shell_content_get_filter_action ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@Returns:
+
+<!-- ##### FUNCTION e_shell_content_get_filter_value ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@Returns:
+
+<!-- ##### FUNCTION e_shell_content_get_filter_visible ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@Returns:
+
+<!-- ##### FUNCTION e_shell_content_get_scope_action ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@Returns:
+
+<!-- ##### FUNCTION e_shell_content_get_scope_value ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@Returns:
+
+<!-- ##### FUNCTION e_shell_content_get_scope_visible ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@Returns:
+
+<!-- ##### FUNCTION e_shell_content_get_search_context ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@Returns:
+
+<!-- ##### FUNCTION e_shell_content_get_search_hint ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@Returns:
+
+<!-- ##### FUNCTION e_shell_content_get_search_rule ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@Returns:
+
+<!-- ##### FUNCTION e_shell_content_get_search_text ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@Returns:
+
<!-- ##### FUNCTION e_shell_content_get_search_value ##### -->
<para>
@@ -2084,6 +2252,22 @@ intelligent
@shell_content:
@Returns:
+<!-- ##### FUNCTION e_shell_content_get_search_visible ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@Returns:
+
+<!-- ##### FUNCTION e_shell_content_restore_state ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@group_name:
+
<!-- ##### FUNCTION e_shell_content_set_context ##### -->
<para>
@@ -2092,6 +2276,78 @@ intelligent
@shell_content:
@context:
+<!-- ##### FUNCTION e_shell_content_set_filter_action ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@filter_action:
+
+<!-- ##### FUNCTION e_shell_content_set_filter_value ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@filter_value:
+
+<!-- ##### FUNCTION e_shell_content_set_filter_visible ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@filter_visible:
+
+<!-- ##### FUNCTION e_shell_content_set_scope_action ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@scope_action:
+
+<!-- ##### FUNCTION e_shell_content_set_scope_value ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@scope_value:
+
+<!-- ##### FUNCTION e_shell_content_set_scope_visible ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@scope_visible:
+
+<!-- ##### FUNCTION e_shell_content_set_search_hint ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@search_hint:
+
+<!-- ##### FUNCTION e_shell_content_set_search_rule ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@search_rule:
+
+<!-- ##### FUNCTION e_shell_content_set_search_text ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@search_text:
+
<!-- ##### FUNCTION e_shell_content_set_search_value ##### -->
<para>
@@ -2100,6 +2356,14 @@ intelligent
@shell_content:
@search_value:
+<!-- ##### FUNCTION e_shell_content_set_search_visible ##### -->
+<para>
+
+</para>
+
+@shell_content:
+@search_visible:
+
<!-- ##### FUNCTION e_shell_create_window ##### -->
<para>
diff --git a/modules/addressbook/e-book-shell-content.c b/modules/addressbook/e-book-shell-content.c
index 46d9824f2e..5eb4459b7b 100644
--- a/modules/addressbook/e-book-shell-content.c
+++ b/modules/addressbook/e-book-shell-content.c
@@ -520,6 +520,9 @@ void
e_book_shell_content_set_current_view (EBookShellContent *book_shell_content,
EAddressbookView *addressbook_view)
{
+ EShellView *shell_view;
+ EShellContent *shell_content;
+ EShellSearchbar *searchbar;
EBookShellView *book_shell_view;
GtkNotebook *notebook;
GtkWidget *child;
@@ -528,6 +531,12 @@ e_book_shell_content_set_current_view (EBookShellContent *book_shell_content,
g_return_if_fail (E_IS_BOOK_SHELL_CONTENT (book_shell_content));
g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (addressbook_view));
+ shell_content = E_SHELL_CONTENT (book_shell_content);
+ shell_view = e_shell_content_get_shell_view (shell_content);
+
+ book_shell_view = E_BOOK_SHELL_VIEW (shell_view);
+ searchbar = e_book_shell_content_get_searchbar (book_shell_content);
+
notebook = GTK_NOTEBOOK (book_shell_content->priv->notebook);
child = GTK_WIDGET (addressbook_view);
page_num = gtk_notebook_page_num (notebook, child);
@@ -537,26 +546,33 @@ e_book_shell_content_set_current_view (EBookShellContent *book_shell_content,
gtk_notebook_set_current_page (notebook, page_num);
if (old_page_num != page_num) {
- EShellContent *shell_content;
+ EActionComboBox *combo_box;
+ GtkRadioAction *action;
gint filter_id = 0, search_id = 0;
gchar *search_text = NULL;
EFilterRule *advanced_search = NULL;
- GtkRadioAction *radio_action;
-
- shell_content = E_SHELL_CONTENT (book_shell_content);
- book_shell_view = E_BOOK_SHELL_VIEW (e_shell_content_get_shell_view (shell_content));
e_book_shell_view_disable_searching (book_shell_view);
- e_addressbook_view_get_search (addressbook_view, &filter_id, &search_id, &search_text, &advanced_search);
- if (e_shell_content_get_filter_action (shell_content))
- e_shell_content_set_filter_value (shell_content, filter_id);
- radio_action = e_shell_content_get_search_radio_action (shell_content);
- gtk_radio_action_set_current_value (radio_action, search_id);
- e_shell_content_set_search_text (shell_content, search_text ? search_text : "");
- e_shell_content_set_search_rule (shell_content, advanced_search);
+
+ e_addressbook_view_get_search (
+ addressbook_view, &filter_id, &search_id,
+ &search_text, &advanced_search);
+
+ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
+ e_action_combo_box_set_current_value (combo_box, filter_id);
+
+ action = e_shell_searchbar_get_search_option (searchbar);
+ gtk_radio_action_set_current_value (action, search_id);
+
+ e_shell_searchbar_set_search_text (searchbar, search_text);
+
+ e_shell_view_set_search_rule (shell_view, advanced_search);
+
g_free (search_text);
+
if (advanced_search)
g_object_unref (advanced_search);
+
e_book_shell_view_enable_searching (book_shell_view);
}
@@ -619,6 +635,21 @@ e_book_shell_content_set_preview_visible (EBookShellContent *book_shell_content,
g_object_notify (G_OBJECT (book_shell_content), "preview-visible");
}
+EShellSearchbar *
+e_book_shell_content_get_searchbar (EBookShellContent *book_shell_content)
+{
+ EShellContent *shell_content;
+ GtkWidget *widget;
+
+ g_return_val_if_fail (
+ E_IS_BOOK_SHELL_CONTENT (book_shell_content), NULL);
+
+ shell_content = E_SHELL_CONTENT (book_shell_content);
+ widget = e_shell_content_get_searchbar (shell_content);
+
+ return E_SHELL_SEARCHBAR (widget);
+}
+
void
e_book_shell_content_clipboard_copy (EBookShellContent *book_shell_content)
{
diff --git a/modules/addressbook/e-book-shell-content.h b/modules/addressbook/e-book-shell-content.h
index 5acfae46c8..62cc7bf80f 100644
--- a/modules/addressbook/e-book-shell-content.h
+++ b/modules/addressbook/e-book-shell-content.h
@@ -24,8 +24,9 @@
#include <libebook/e-contact.h>
-#include "shell/e-shell-content.h"
-#include "shell/e-shell-view.h"
+#include <shell/e-shell-content.h>
+#include <shell/e-shell-searchbar.h>
+#include <shell/e-shell-view.h>
#include "addressbook/gui/widgets/e-addressbook-view.h"
#include "eab-composer-util.h"
@@ -104,6 +105,9 @@ gboolean e_book_shell_content_get_preview_visible
void e_book_shell_content_set_preview_visible
(EBookShellContent *book_shell_content,
gboolean preview_visible);
+EShellSearchbar *
+ e_book_shell_content_get_searchbar
+ (EBookShellContent *book_shell_content);
void e_book_shell_content_clipboard_copy
(EBookShellContent *book_shell_content);
diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c
index 5214f611d3..904b777c8b 100644
--- a/modules/addressbook/e-book-shell-view-actions.c
+++ b/modules/addressbook/e-book-shell-view-actions.c
@@ -973,7 +973,7 @@ static GtkRadioActionEntry contact_search_entries[] = {
{ "contact-search-advanced-hidden",
NULL,
- N_("Advanced search"),
+ N_("Advanced Search"),
NULL,
NULL,
CONTACT_SEARCH_ADVANCED },
@@ -1051,14 +1051,14 @@ static EPopupActionEntry lockdown_save_to_disk_popup_entries[] = {
void
e_book_shell_view_actions_init (EBookShellView *book_shell_view)
{
+ EBookShellContent *book_shell_content;
EShellView *shell_view;
EShellWindow *shell_window;
- EBookShellContent *book_shell_content;
+ EShellSearchbar *searchbar;
EABContactDisplay *contact_preview;
GtkActionGroup *action_group;
GConfBridge *bridge;
GtkAction *action;
- GtkRadioAction *radio_action;
GObject *object;
const gchar *key;
@@ -1066,6 +1066,7 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view)
shell_window = e_shell_view_get_shell_window (shell_view);
book_shell_content = book_shell_view->priv->book_shell_content;
+ searchbar = e_book_shell_content_get_searchbar (book_shell_content);
contact_preview = e_book_shell_content_get_preview (book_shell_content);
/* Contact Actions */
@@ -1088,11 +1089,14 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view)
G_N_ELEMENTS (contact_search_entries),
-1, NULL, NULL);
- /* Advanced Search action */
- radio_action = GTK_RADIO_ACTION (ACTION (CONTACT_SEARCH_ADVANCED_HIDDEN));
- e_shell_content_set_search_radio_action (e_shell_view_get_shell_content (shell_view), radio_action);
- gtk_action_set_visible (GTK_ACTION (radio_action), FALSE);
- gtk_radio_action_set_current_value (radio_action, CONTACT_SEARCH_NAME_CONTAINS);
+ /* Advanced Search Action */
+ action = ACTION (CONTACT_SEARCH_ADVANCED_HIDDEN);
+ gtk_action_set_visible (action, FALSE);
+ e_shell_searchbar_set_search_option (
+ searchbar, GTK_RADIO_ACTION (action));
+ gtk_radio_action_set_current_value (
+ GTK_RADIO_ACTION (action),
+ CONTACT_SEARCH_NAME_CONTAINS);
/* Lockdown Printing Actions */
action_group = ACTION_GROUP (LOCKDOWN_PRINTING);
@@ -1156,9 +1160,11 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view)
void
e_book_shell_view_update_search_filter (EBookShellView *book_shell_view)
{
+ EBookShellContent *book_shell_content;
EShellView *shell_view;
- EShellContent *shell_content;
EShellWindow *shell_window;
+ EShellSearchbar *searchbar;
+ EActionComboBox *combo_box;
GtkActionGroup *action_group;
GtkRadioAction *radio_action;
GList *list, *iter;
@@ -1166,7 +1172,6 @@ e_book_shell_view_update_search_filter (EBookShellView *book_shell_view)
gint ii;
shell_view = E_SHELL_VIEW (book_shell_view);
- shell_content = e_shell_view_get_shell_content (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
action_group = ACTION_GROUP (CONTACTS_FILTER);
@@ -1230,8 +1235,11 @@ e_book_shell_view_update_search_filter (EBookShellView *book_shell_view)
g_list_free (list);
/* Use any action in the group; doesn't matter which. */
- e_shell_content_set_filter_action (shell_content, radio_action);
+ book_shell_content = book_shell_view->priv->book_shell_content;
+ searchbar = e_book_shell_content_get_searchbar (book_shell_content);
+ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
+ e_action_combo_box_set_action (combo_box, radio_action);
ii = CONTACT_FILTER_UNMATCHED;
- e_shell_content_add_filter_separator_after (shell_content, ii);
+ e_action_combo_box_add_separator_after (combo_box, ii);
}
diff --git a/modules/addressbook/e-book-shell-view-private.h b/modules/addressbook/e-book-shell-view-private.h
index f1b23c2cfb..c0fb2f09df 100644
--- a/modules/addressbook/e-book-shell-view-private.h
+++ b/modules/addressbook/e-book-shell-view-private.h
@@ -37,6 +37,7 @@
#include "e-util/e-file-utils.h"
#include "e-util/gconf-bridge.h"
#include "shell/e-shell-content.h"
+#include "shell/e-shell-searchbar.h"
#include "shell/e-shell-sidebar.h"
#include "shell/e-shell-utils.h"
#include "misc/e-popup-action.h"
diff --git a/modules/addressbook/e-book-shell-view.c b/modules/addressbook/e-book-shell-view.c
index ebbf3e79d0..fa5e5bbe29 100644
--- a/modules/addressbook/e-book-shell-view.c
+++ b/modules/addressbook/e-book-shell-view.c
@@ -127,6 +127,8 @@ book_shell_view_execute_search (EShellView *shell_view)
EBookShellContent *book_shell_content;
EShellWindow *shell_window;
EShellContent *shell_content;
+ EShellSearchbar *searchbar;
+ EActionComboBox *combo_box;
GtkRadioAction *action;
EAddressbookView *view;
EAddressbookModel *model;
@@ -141,25 +143,29 @@ book_shell_view_execute_search (EShellView *shell_view)
if (priv->search_locked)
return;
- shell_content = e_shell_view_get_shell_content (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+
+ book_shell_content = E_BOOK_SHELL_CONTENT (shell_content);
+ searchbar = e_book_shell_content_get_searchbar (book_shell_content);
+
action = GTK_RADIO_ACTION (ACTION (CONTACT_SEARCH_ANY_FIELD_CONTAINS));
search_id = gtk_radio_action_get_current_value (action);
if (search_id == CONTACT_SEARCH_ADVANCED) {
- query = e_shell_content_get_search_rule_as_string (shell_content);
+ query = e_shell_view_get_search_query (shell_view);
- if (!query)
+ if (query == NULL)
query = g_strdup ("");
/* internal pointer, no need to free it */
- advanced_search = e_shell_content_get_search_rule (shell_content);
+ advanced_search = e_shell_view_get_search_rule (shell_view);
} else {
const gchar *text;
const gchar *format;
GString *string;
- text = e_shell_content_get_search_text (shell_content);
+ text = e_shell_searchbar_get_search_text (searchbar);
if (text == NULL || *text == '\0') {
text = "";
@@ -194,7 +200,8 @@ book_shell_view_execute_search (EShellView *shell_view)
}
/* Apply selected filter. */
- filter_id = e_shell_content_get_filter_value (shell_content);
+ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
+ filter_id = e_action_combo_box_get_current_value (combo_box);
switch (filter_id) {
case CONTACT_FILTER_ANY_CATEGORY:
break;
@@ -226,11 +233,11 @@ book_shell_view_execute_search (EShellView *shell_view)
}
/* Submit the query. */
- book_shell_content = E_BOOK_SHELL_CONTENT (shell_content);
view = e_book_shell_content_get_current_view (book_shell_content);
model = e_addressbook_view_get_model (view);
e_addressbook_model_set_query (model, query);
- e_addressbook_view_set_search (view, filter_id, search_id, search_text, advanced_search);
+ e_addressbook_view_set_search (
+ view, filter_id, search_id, search_text, advanced_search);
g_free (query);
g_free (search_text);
diff --git a/modules/calendar/e-cal-shell-content.c b/modules/calendar/e-cal-shell-content.c
index 0627f74dd6..fcebf59ca5 100644
--- a/modules/calendar/e-cal-shell-content.c
+++ b/modules/calendar/e-cal-shell-content.c
@@ -679,6 +679,21 @@ e_cal_shell_content_get_task_table (ECalShellContent *cal_shell_content)
return E_CALENDAR_TABLE (cal_shell_content->priv->task_table);
}
+EShellSearchbar *
+e_cal_shell_content_get_searchbar (ECalShellContent *cal_shell_content)
+{
+ EShellContent *shell_content;
+ GtkWidget *widget;
+
+ g_return_val_if_fail (
+ E_IS_CAL_SHELL_CONTENT (cal_shell_content), NULL);
+
+ shell_content = E_SHELL_CONTENT (cal_shell_content);
+ widget = e_shell_content_get_searchbar (shell_content);
+
+ return E_SHELL_SEARCHBAR (widget);
+}
+
GalViewInstance *
e_cal_shell_content_get_view_instance (ECalShellContent *cal_shell_content)
{
diff --git a/modules/calendar/e-cal-shell-content.h b/modules/calendar/e-cal-shell-content.h
index 3db7d33260..eae8bf3301 100644
--- a/modules/calendar/e-cal-shell-content.h
+++ b/modules/calendar/e-cal-shell-content.h
@@ -23,6 +23,7 @@
#define E_CAL_SHELL_CONTENT_H
#include <shell/e-shell-content.h>
+#include <shell/e-shell-searchbar.h>
#include <shell/e-shell-view.h>
#include <calendar/gui/e-memo-table.h>
@@ -89,6 +90,9 @@ EMemoTable * e_cal_shell_content_get_memo_table
(ECalShellContent *cal_shell_content);
ECalendarTable *e_cal_shell_content_get_task_table
(ECalShellContent *cal_shell_content);
+EShellSearchbar *
+ e_cal_shell_content_get_searchbar
+ (ECalShellContent *cal_shell_content);
GalViewInstance *
e_cal_shell_content_get_view_instance
(ECalShellContent *cal_shell_content);
diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c
index b0408b6b5a..148cc4a426 100644
--- a/modules/calendar/e-cal-shell-view-actions.c
+++ b/modules/calendar/e-cal-shell-view-actions.c
@@ -1654,7 +1654,7 @@ static GtkRadioActionEntry calendar_search_entries[] = {
{ "calendar-search-advanced-hidden",
NULL,
- N_("Advanced search"),
+ N_("Advanced Search"),
NULL,
NULL,
CALENDAR_SEARCH_ADVANCED },
@@ -1715,15 +1715,19 @@ static EPopupActionEntry lockdown_printing_popup_entries[] = {
void
e_cal_shell_view_actions_init (ECalShellView *cal_shell_view)
{
+ ECalShellContent *cal_shell_content;
EShellView *shell_view;
EShellWindow *shell_window;
+ EShellSearchbar *searchbar;
GtkActionGroup *action_group;
GtkAction *action;
- GtkRadioAction *radio_action;
shell_view = E_SHELL_VIEW (cal_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
+ cal_shell_content = cal_shell_view->priv->cal_shell_content;
+ searchbar = e_cal_shell_content_get_searchbar (cal_shell_content);
+
/* Calendar Actions */
action_group = ACTION_GROUP (CALENDAR);
gtk_action_group_add_actions (
@@ -1741,11 +1745,14 @@ e_cal_shell_view_actions_init (ECalShellView *cal_shell_view)
G_N_ELEMENTS (calendar_search_entries),
-1, NULL, NULL);
- /* Advanced Search action */
- radio_action = GTK_RADIO_ACTION (ACTION (CALENDAR_SEARCH_ADVANCED_HIDDEN));
- e_shell_content_set_search_radio_action (e_shell_view_get_shell_content (shell_view), radio_action);
- gtk_action_set_visible (GTK_ACTION (radio_action), FALSE);
- gtk_radio_action_set_current_value (radio_action, CALENDAR_SEARCH_SUMMARY_CONTAINS);
+ /* Advanced Search Action */
+ action = ACTION (CALENDAR_SEARCH_ADVANCED_HIDDEN);
+ gtk_action_set_visible (action, FALSE);
+ e_shell_searchbar_set_search_option (
+ searchbar, GTK_RADIO_ACTION (action));
+ gtk_radio_action_set_current_value (
+ GTK_RADIO_ACTION (action),
+ CALENDAR_SEARCH_SUMMARY_CONTAINS);
/* Lockdown Printing Actions */
action_group = ACTION_GROUP (LOCKDOWN_PRINTING);
@@ -1794,9 +1801,11 @@ e_cal_shell_view_actions_init (ECalShellView *cal_shell_view)
void
e_cal_shell_view_update_search_filter (ECalShellView *cal_shell_view)
{
- EShellContent *shell_content;
- EShellWindow *shell_window;
+ ECalShellContent *cal_shell_content;
EShellView *shell_view;
+ EShellWindow *shell_window;
+ EShellSearchbar *searchbar;
+ EActionComboBox *combo_box;
GtkActionGroup *action_group;
GtkRadioAction *radio_action;
GList *list, *iter;
@@ -1804,7 +1813,6 @@ e_cal_shell_view_update_search_filter (ECalShellView *cal_shell_view)
gint ii;
shell_view = E_SHELL_VIEW (cal_shell_view);
- shell_content = e_shell_view_get_shell_content (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
action_group = ACTION_GROUP (CALENDAR_FILTER);
@@ -1868,11 +1876,14 @@ e_cal_shell_view_update_search_filter (ECalShellView *cal_shell_view)
g_list_free (list);
/* Use any action in the group; doesn't matter which. */
- e_shell_content_set_filter_action (shell_content, radio_action);
+ cal_shell_content = cal_shell_view->priv->cal_shell_content;
+ searchbar = e_cal_shell_content_get_searchbar (cal_shell_content);
+ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
+ e_action_combo_box_set_action (combo_box, radio_action);
ii = CALENDAR_FILTER_UNMATCHED;
- e_shell_content_add_filter_separator_after (shell_content, ii);
+ e_action_combo_box_add_separator_after (combo_box, ii);
ii = CALENDAR_FILTER_NEXT_7_DAYS_APPOINTMENTS;
- e_shell_content_add_filter_separator_after (shell_content, ii);
+ e_action_combo_box_add_separator_after (combo_box, ii);
}
diff --git a/modules/calendar/e-cal-shell-view.c b/modules/calendar/e-cal-shell-view.c
index 47d734921c..262cd39246 100644
--- a/modules/calendar/e-cal-shell-view.c
+++ b/modules/calendar/e-cal-shell-view.c
@@ -59,6 +59,8 @@ cal_shell_view_execute_search (EShellView *shell_view)
EShellWindow *shell_window;
EShellContent *shell_content;
EShellSidebar *shell_sidebar;
+ EShellSearchbar *searchbar;
+ EActionComboBox *combo_box;
GnomeCalendar *calendar;
ECalendar *date_navigator;
GtkRadioAction *action;
@@ -74,11 +76,16 @@ cal_shell_view_execute_search (EShellView *shell_view)
shell_content = e_shell_view_get_shell_content (shell_view);
shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
+ cal_shell_content = E_CAL_SHELL_CONTENT (shell_content);
+ cal_shell_sidebar = E_CAL_SHELL_SIDEBAR (shell_sidebar);
+
+ searchbar = e_cal_shell_content_get_searchbar (cal_shell_content);
+
action = GTK_RADIO_ACTION (ACTION (CALENDAR_SEARCH_ANY_FIELD_CONTAINS));
value = gtk_radio_action_get_current_value (action);
if (value == CALENDAR_SEARCH_ADVANCED) {
- query = e_shell_content_get_search_rule_as_string (shell_content);
+ query = e_shell_view_get_search_query (shell_view);
if (!query)
query = g_strdup ("");
@@ -87,7 +94,7 @@ cal_shell_view_execute_search (EShellView *shell_view)
const gchar *text;
GString *string;
- text = e_shell_content_get_search_text (shell_content);
+ text = e_shell_searchbar_get_search_text (searchbar);
if (text == NULL || *text == '\0') {
text = "";
@@ -123,7 +130,8 @@ cal_shell_view_execute_search (EShellView *shell_view)
start_range = end_range = 0;
/* Apply selected filter. */
- value = e_shell_content_get_filter_value (shell_content);
+ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
+ value = e_action_combo_box_get_current_value (combo_box);
switch (value) {
case CALENDAR_FILTER_ANY_CATEGORY:
break;
@@ -186,7 +194,6 @@ cal_shell_view_execute_search (EShellView *shell_view)
}
}
- cal_shell_sidebar = E_CAL_SHELL_SIDEBAR (shell_sidebar);
date_navigator = e_cal_shell_sidebar_get_date_navigator (cal_shell_sidebar);
if (range_search) {
@@ -200,7 +207,6 @@ cal_shell_view_execute_search (EShellView *shell_view)
}
/* Submit the query. */
- cal_shell_content = E_CAL_SHELL_CONTENT (shell_content);
calendar = e_cal_shell_content_get_calendar (cal_shell_content);
gnome_calendar_set_search_query (
calendar, query, range_search, start_range, end_range);
diff --git a/modules/calendar/e-memo-shell-content.c b/modules/calendar/e-memo-shell-content.c
index d3fe10f20b..4de685cd4b 100644
--- a/modules/calendar/e-memo-shell-content.c
+++ b/modules/calendar/e-memo-shell-content.c
@@ -727,6 +727,21 @@ e_memo_shell_content_set_preview_visible (EMemoShellContent *memo_shell_content,
g_object_notify (G_OBJECT (memo_shell_content), "preview-visible");
}
+EShellSearchbar *
+e_memo_shell_content_get_searchbar (EMemoShellContent *memo_shell_content)
+{
+ EShellContent *shell_content;
+ GtkWidget *widget;
+
+ g_return_val_if_fail (
+ E_IS_MEMO_SHELL_CONTENT (memo_shell_content), NULL);
+
+ shell_content = E_SHELL_CONTENT (memo_shell_content);
+ widget = e_shell_content_get_searchbar (shell_content);
+
+ return E_SHELL_SEARCHBAR (widget);
+}
+
GalViewInstance *
e_memo_shell_content_get_view_instance (EMemoShellContent *memo_shell_content)
{
diff --git a/modules/calendar/e-memo-shell-content.h b/modules/calendar/e-memo-shell-content.h
index 20c7db4df1..a923b27f0b 100644
--- a/modules/calendar/e-memo-shell-content.h
+++ b/modules/calendar/e-memo-shell-content.h
@@ -23,6 +23,7 @@
#define E_MEMO_SHELL_CONTENT_H
#include <shell/e-shell-content.h>
+#include <shell/e-shell-searchbar.h>
#include <shell/e-shell-view.h>
#include <calendar/gui/e-memo-table.h>
@@ -88,6 +89,9 @@ gboolean e_memo_shell_content_get_preview_visible
void e_memo_shell_content_set_preview_visible
(EMemoShellContent *memo_shell_content,
gboolean preview_visible);
+EShellSearchbar *
+ e_memo_shell_content_get_searchbar
+ (EMemoShellContent *memo_shell_content);
GalViewInstance *
e_memo_shell_content_get_view_instance
(EMemoShellContent *memo_shell_content);
diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c
index 394d6091a4..baf90f5a73 100644
--- a/modules/calendar/e-memo-shell-view-actions.c
+++ b/modules/calendar/e-memo-shell-view-actions.c
@@ -819,7 +819,7 @@ static GtkRadioActionEntry memo_search_entries[] = {
{ "memo-search-advanced-hidden",
NULL,
- N_("Advanced search"),
+ N_("Advanced Search"),
NULL,
NULL,
MEMO_SEARCH_ADVANCED },
@@ -897,14 +897,14 @@ static EPopupActionEntry lockdown_save_to_disk_popup_entries[] = {
void
e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view)
{
+ EMemoShellContent *memo_shell_content;
EShellView *shell_view;
EShellWindow *shell_window;
- EMemoShellContent *memo_shell_content;
+ EShellSearchbar *searchbar;
ECalComponentPreview *memo_preview;
GtkActionGroup *action_group;
GConfBridge *bridge;
GtkAction *action;
- GtkRadioAction *radio_action;
GObject *object;
const gchar *key;
@@ -912,6 +912,7 @@ e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view)
shell_window = e_shell_view_get_shell_window (shell_view);
memo_shell_content = memo_shell_view->priv->memo_shell_content;
+ searchbar = e_memo_shell_content_get_searchbar (memo_shell_content);
memo_preview = e_memo_shell_content_get_memo_preview (memo_shell_content);
/* Memo Actions */
@@ -934,11 +935,14 @@ e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view)
G_N_ELEMENTS (memo_search_entries),
-1, NULL, NULL);
- /* Advanced Search action */
- radio_action = GTK_RADIO_ACTION (ACTION (MEMO_SEARCH_ADVANCED_HIDDEN));
- e_shell_content_set_search_radio_action (e_shell_view_get_shell_content (shell_view), radio_action);
- gtk_action_set_visible (GTK_ACTION (radio_action), FALSE);
- gtk_radio_action_set_current_value (radio_action, MEMO_SEARCH_SUMMARY_CONTAINS);
+ /* Advanced Search Action */
+ action = ACTION (MEMO_SEARCH_ADVANCED_HIDDEN);
+ gtk_action_set_visible (action, FALSE);
+ e_shell_searchbar_set_search_option (
+ searchbar, GTK_RADIO_ACTION (action));
+ gtk_radio_action_set_current_value (
+ GTK_RADIO_ACTION (action),
+ MEMO_SEARCH_SUMMARY_CONTAINS);
/* Lockdown Printing Actions */
action_group = ACTION_GROUP (LOCKDOWN_PRINTING);
@@ -1002,9 +1006,11 @@ e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view)
void
e_memo_shell_view_update_search_filter (EMemoShellView *memo_shell_view)
{
- EShellContent *shell_content;
- EShellWindow *shell_window;
+ EMemoShellContent *memo_shell_content;
EShellView *shell_view;
+ EShellWindow *shell_window;
+ EShellSearchbar *searchbar;
+ EActionComboBox *combo_box;
GtkActionGroup *action_group;
GtkRadioAction *radio_action;
GList *list, *iter;
@@ -1012,7 +1018,6 @@ e_memo_shell_view_update_search_filter (EMemoShellView *memo_shell_view)
gint ii;
shell_view = E_SHELL_VIEW (memo_shell_view);
- shell_content = e_shell_view_get_shell_content (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
action_group = ACTION_GROUP (MEMOS_FILTER);
@@ -1076,8 +1081,11 @@ e_memo_shell_view_update_search_filter (EMemoShellView *memo_shell_view)
g_list_free (list);
/* Use any action in the group; doesn't matter which. */
- e_shell_content_set_filter_action (shell_content, radio_action);
+ memo_shell_content = memo_shell_view->priv->memo_shell_content;
+ searchbar = e_memo_shell_content_get_searchbar (memo_shell_content);
+ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
+ e_action_combo_box_set_action (combo_box, radio_action);
ii = MEMO_FILTER_UNMATCHED;
- e_shell_content_add_filter_separator_after (shell_content, ii);
+ e_action_combo_box_add_separator_after (combo_box, ii);
}
diff --git a/modules/calendar/e-memo-shell-view.c b/modules/calendar/e-memo-shell-view.c
index 206e50c961..29a82524c4 100644
--- a/modules/calendar/e-memo-shell-view.c
+++ b/modules/calendar/e-memo-shell-view.c
@@ -57,6 +57,8 @@ memo_shell_view_execute_search (EShellView *shell_view)
EMemoShellContent *memo_shell_content;
EShellWindow *shell_window;
EShellContent *shell_content;
+ EShellSearchbar *searchbar;
+ EActionComboBox *combo_box;
GtkRadioAction *action;
ECalComponentPreview *memo_preview;
EMemoTable *memo_table;
@@ -67,11 +69,15 @@ memo_shell_view_execute_search (EShellView *shell_view)
shell_content = e_shell_view_get_shell_content (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
+
+ memo_shell_content = E_MEMO_SHELL_CONTENT (shell_content);
+ searchbar = e_memo_shell_content_get_searchbar (memo_shell_content);
+
action = GTK_RADIO_ACTION (ACTION (MEMO_SEARCH_ANY_FIELD_CONTAINS));
value = gtk_radio_action_get_current_value (action);
if (value == MEMO_SEARCH_ADVANCED) {
- query = e_shell_content_get_search_rule_as_string (shell_content);
+ query = e_shell_view_get_search_query (shell_view);
if (!query)
query = g_strdup ("");
@@ -80,7 +86,7 @@ memo_shell_view_execute_search (EShellView *shell_view)
const gchar *text;
GString *string;
- text = e_shell_content_get_search_text (shell_content);
+ text = e_shell_searchbar_get_search_text (searchbar);
if (text == NULL || *text == '\0') {
text = "";
@@ -113,7 +119,8 @@ memo_shell_view_execute_search (EShellView *shell_view)
}
/* Apply selected filter. */
- value = e_shell_content_get_filter_value (shell_content);
+ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
+ value = e_action_combo_box_get_current_value (combo_box);
switch (value) {
case MEMO_FILTER_ANY_CATEGORY:
break;
@@ -143,7 +150,6 @@ memo_shell_view_execute_search (EShellView *shell_view)
}
/* Submit the query. */
- memo_shell_content = E_MEMO_SHELL_CONTENT (shell_content);
memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
model = e_memo_table_get_model (memo_table);
e_cal_model_set_search_query (model, query);
diff --git a/modules/calendar/e-task-shell-content.c b/modules/calendar/e-task-shell-content.c
index c033d6e489..4692e7bf7e 100644
--- a/modules/calendar/e-task-shell-content.c
+++ b/modules/calendar/e-task-shell-content.c
@@ -750,6 +750,21 @@ e_task_shell_content_set_preview_visible (ETaskShellContent *task_shell_content,
g_object_notify (G_OBJECT (task_shell_content), "preview-visible");
}
+EShellSearchbar *
+e_task_shell_content_get_searchbar (ETaskShellContent *task_shell_content)
+{
+ EShellContent *shell_content;
+ GtkWidget *widget;
+
+ g_return_val_if_fail (
+ E_IS_TASK_SHELL_CONTENT (task_shell_content), NULL);
+
+ shell_content = E_SHELL_CONTENT (task_shell_content);
+ widget = e_shell_content_get_searchbar (shell_content);
+
+ return E_SHELL_SEARCHBAR (widget);
+}
+
GalViewInstance *
e_task_shell_content_get_view_instance (ETaskShellContent *task_shell_content)
{
diff --git a/modules/calendar/e-task-shell-content.h b/modules/calendar/e-task-shell-content.h
index e5bdecd8c0..971d46ad95 100644
--- a/modules/calendar/e-task-shell-content.h
+++ b/modules/calendar/e-task-shell-content.h
@@ -23,6 +23,7 @@
#define E_TASK_SHELL_CONTENT_H
#include <shell/e-shell-content.h>
+#include <shell/e-shell-searchbar.h>
#include <shell/e-shell-view.h>
#include <calendar/gui/e-cal-model.h>
@@ -92,6 +93,9 @@ gboolean e_task_shell_content_get_preview_visible
void e_task_shell_content_set_preview_visible
(ETaskShellContent *task_shell_content,
gboolean preview_visible);
+EShellSearchbar *
+ e_task_shell_content_get_searchbar
+ (ETaskShellContent *task_shell_content);
GalViewInstance *
e_task_shell_content_get_view_instance
(ETaskShellContent *task_shell_content);
diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c
index 6e79c23395..8e28b55863 100644
--- a/modules/calendar/e-task-shell-view-actions.c
+++ b/modules/calendar/e-task-shell-view-actions.c
@@ -1018,7 +1018,7 @@ static GtkRadioActionEntry task_search_entries[] = {
{ "task-search-advanced-hidden",
NULL,
- N_("Advanced search"),
+ N_("Advanced Search"),
NULL,
NULL,
TASK_SEARCH_ADVANCED },
@@ -1096,14 +1096,14 @@ static EPopupActionEntry lockdown_save_to_disk_popup_entries[] = {
void
e_task_shell_view_actions_init (ETaskShellView *task_shell_view)
{
+ ETaskShellContent *task_shell_content;
EShellView *shell_view;
EShellWindow *shell_window;
- ETaskShellContent *task_shell_content;
+ EShellSearchbar *searchbar;
ECalComponentPreview *task_preview;
GtkActionGroup *action_group;
GConfBridge *bridge;
GtkAction *action;
- GtkRadioAction *radio_action;
GObject *object;
const gchar *key;
@@ -1111,6 +1111,7 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view)
shell_window = e_shell_view_get_shell_window (shell_view);
task_shell_content = task_shell_view->priv->task_shell_content;
+ searchbar = e_task_shell_content_get_searchbar (task_shell_content);
task_preview = e_task_shell_content_get_task_preview (task_shell_content);
/* Task Actions */
@@ -1133,11 +1134,14 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view)
G_N_ELEMENTS (task_search_entries),
-1, NULL, NULL);
- /* Advanced Search action */
- radio_action = GTK_RADIO_ACTION (ACTION (TASK_SEARCH_ADVANCED_HIDDEN));
- e_shell_content_set_search_radio_action (e_shell_view_get_shell_content (shell_view), radio_action);
- gtk_action_set_visible (GTK_ACTION (radio_action), FALSE);
- gtk_radio_action_set_current_value (radio_action, TASK_SEARCH_SUMMARY_CONTAINS);
+ /* Advanced Search Action */
+ action = ACTION (TASK_SEARCH_ADVANCED_HIDDEN);
+ gtk_action_set_visible (action, FALSE);
+ e_shell_searchbar_set_search_option (
+ searchbar, GTK_RADIO_ACTION (action));
+ gtk_radio_action_set_current_value (
+ GTK_RADIO_ACTION (action),
+ TASK_SEARCH_SUMMARY_CONTAINS);
/* Lockdown Printing Actions */
action_group = ACTION_GROUP (LOCKDOWN_PRINTING);
@@ -1201,9 +1205,11 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view)
void
e_task_shell_view_update_search_filter (ETaskShellView *task_shell_view)
{
- EShellContent *shell_content;
- EShellWindow *shell_window;
+ ETaskShellContent *task_shell_content;
EShellView *shell_view;
+ EShellWindow *shell_window;
+ EShellSearchbar *searchbar;
+ EActionComboBox *combo_box;
GtkActionGroup *action_group;
GtkRadioAction *radio_action;
GList *list, *iter;
@@ -1211,7 +1217,6 @@ e_task_shell_view_update_search_filter (ETaskShellView *task_shell_view)
gint ii;
shell_view = E_SHELL_VIEW (task_shell_view);
- shell_content = e_shell_view_get_shell_content (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
action_group = ACTION_GROUP (TASKS_FILTER);
@@ -1275,11 +1280,14 @@ e_task_shell_view_update_search_filter (ETaskShellView *task_shell_view)
g_list_free (list);
/* Use any action in the group; doesn't matter which. */
- e_shell_content_set_filter_action (shell_content, radio_action);
+ task_shell_content = task_shell_view->priv->task_shell_content;
+ searchbar = e_task_shell_content_get_searchbar (task_shell_content);
+ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
+ e_action_combo_box_set_action (combo_box, radio_action);
ii = TASK_FILTER_UNMATCHED;
- e_shell_content_add_filter_separator_after (shell_content, ii);
+ e_action_combo_box_add_separator_after (combo_box, ii);
ii = TASK_FILTER_TASKS_WITH_ATTACHMENTS;
- e_shell_content_add_filter_separator_after (shell_content, ii);
+ e_action_combo_box_add_separator_after (combo_box, ii);
}
diff --git a/modules/calendar/e-task-shell-view.c b/modules/calendar/e-task-shell-view.c
index 9558eb77c0..a481356690 100644
--- a/modules/calendar/e-task-shell-view.c
+++ b/modules/calendar/e-task-shell-view.c
@@ -96,6 +96,8 @@ task_shell_view_execute_search (EShellView *shell_view)
ETaskShellContent *task_shell_content;
EShellWindow *shell_window;
EShellContent *shell_content;
+ EShellSearchbar *searchbar;
+ EActionComboBox *combo_box;
GtkRadioAction *action;
ECalComponentPreview *task_preview;
ECalendarTable *task_table;
@@ -107,13 +109,17 @@ task_shell_view_execute_search (EShellView *shell_view)
gchar *temp;
gint value;
- shell_content = e_shell_view_get_shell_content (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+
+ task_shell_content = E_TASK_SHELL_CONTENT (shell_content);
+ searchbar = e_task_shell_content_get_searchbar (task_shell_content);
+
action = GTK_RADIO_ACTION (ACTION (TASK_SEARCH_ANY_FIELD_CONTAINS));
value = gtk_radio_action_get_current_value (action);
if (value == TASK_SEARCH_ADVANCED) {
- query = e_shell_content_get_search_rule_as_string (shell_content);
+ query = e_shell_view_get_search_query (shell_view);
if (!query)
query = g_strdup ("");
@@ -122,7 +128,7 @@ task_shell_view_execute_search (EShellView *shell_view)
const gchar *text;
GString *string;
- text = e_shell_content_get_search_text (shell_content);
+ text = e_shell_searchbar_get_search_text (searchbar);
if (text == NULL || *text == '\0') {
text = "";
@@ -155,7 +161,8 @@ task_shell_view_execute_search (EShellView *shell_view)
}
/* Apply selected filter. */
- value = e_shell_content_get_filter_value (shell_content);
+ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
+ value = e_action_combo_box_get_current_value (combo_box);
switch (value) {
case TASK_FILTER_ANY_CATEGORY:
break;
diff --git a/modules/mail/e-mail-shell-content.c b/modules/mail/e-mail-shell-content.c
index f9b0b7da80..a1d8a40d82 100644
--- a/modules/mail/e-mail-shell-content.c
+++ b/modules/mail/e-mail-shell-content.c
@@ -31,7 +31,6 @@
#include "widgets/menus/gal-view-instance.h"
#include "widgets/misc/e-paned.h"
-#include "em-search-context.h"
#include "em-utils.h"
#include "mail-config.h"
#include "mail-ops.h"
@@ -610,7 +609,6 @@ mail_shell_content_class_init (EMailShellContentClass *class)
object_class->constructed = mail_shell_content_constructed;
shell_content_class = E_SHELL_CONTENT_CLASS (class);
- shell_content_class->new_search_context = em_search_context_new;
shell_content_class->check_state = mail_shell_content_check_state;
g_object_class_install_property (
@@ -758,6 +756,21 @@ e_mail_shell_content_set_preview_visible (EMailShellContent *mail_shell_content,
g_object_notify (G_OBJECT (mail_shell_content), "preview-visible");
}
+EShellSearchbar *
+e_mail_shell_content_get_searchbar (EMailShellContent *mail_shell_content)
+{
+ EShellContent *shell_content;
+ GtkWidget *widget;
+
+ g_return_val_if_fail (
+ E_IS_MAIL_SHELL_CONTENT (mail_shell_content), NULL);
+
+ shell_content = E_SHELL_CONTENT (mail_shell_content);
+ widget = e_shell_content_get_searchbar (shell_content);
+
+ return E_SHELL_SEARCHBAR (widget);
+}
+
gboolean
e_mail_shell_content_get_show_deleted (EMailShellContent *mail_shell_content)
{
diff --git a/modules/mail/e-mail-shell-content.h b/modules/mail/e-mail-shell-content.h
index c11323b5f1..69a1fdc397 100644
--- a/modules/mail/e-mail-shell-content.h
+++ b/modules/mail/e-mail-shell-content.h
@@ -23,6 +23,7 @@
#define E_MAIL_SHELL_CONTENT_H
#include <shell/e-shell-content.h>
+#include <shell/e-shell-searchbar.h>
#include <shell/e-shell-view.h>
#include <mail/em-format-html-display.h>
@@ -73,6 +74,9 @@ gboolean e_mail_shell_content_get_preview_visible
void e_mail_shell_content_set_preview_visible
(EMailShellContent *mail_shell_content,
gboolean preview_visible);
+EShellSearchbar *
+ e_mail_shell_content_get_searchbar
+ (EMailShellContent *mail_shell_content);
gboolean e_mail_shell_content_get_show_deleted
(EMailShellContent *mail_shell_content);
void e_mail_shell_content_set_show_deleted
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index f300ec0c92..103463b586 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -80,9 +80,10 @@ static void
action_mail_create_search_folder_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
+ EMailShellContent *mail_shell_content;
EMailReader *reader;
EShellView *shell_view;
- EShellContent *shell_content;
+ EShellSearchbar *searchbar;
EFilterRule *search_rule;
EMVFolderRule *vfolder_rule;
const gchar *folder_uri;
@@ -92,16 +93,17 @@ action_mail_create_search_folder_cb (GtkAction *action,
vfolder_load_storage ();
shell_view = E_SHELL_VIEW (mail_shell_view);
- shell_content = e_shell_view_get_shell_content (shell_view);
- search_rule = e_shell_content_get_search_rule (shell_content);
- search_text = e_shell_content_get_search_text (shell_content);
-
+ search_rule = e_shell_view_get_search_rule (shell_view);
g_return_if_fail (search_rule != NULL);
+ mail_shell_content = mail_shell_view->priv->mail_shell_content;
+ searchbar = e_mail_shell_content_get_searchbar (mail_shell_content);
+ search_text = e_shell_searchbar_get_search_text (searchbar);
+
if (search_text == NULL || *search_text == '\0')
search_text = "''";
- reader = E_MAIL_READER (shell_content);
+ reader = E_MAIL_READER (mail_shell_content);
folder_uri = e_mail_reader_get_folder_uri (reader);
search_rule = vfolder_clone_rule (search_rule);
@@ -1427,7 +1429,7 @@ static GtkRadioActionEntry mail_search_entries[] = {
{ "mail-search-advanced-hidden",
NULL,
- N_("Advanced search"),
+ N_("Advanced Search"),
NULL,
NULL,
MAIL_SEARCH_ADVANCED },
@@ -1502,11 +1504,13 @@ static GtkRadioActionEntry mail_scope_entries[] = {
void
e_mail_shell_view_actions_init (EMailShellView *mail_shell_view)
{
+ EMailShellContent *mail_shell_content;
EShellView *shell_view;
EShellWindow *shell_window;
- EShellContent *shell_content;
+ EShellSearchbar *searchbar;
+ EActionComboBox *combo_box;
GtkActionGroup *action_group;
- GtkRadioAction *radio_action;
+ GtkAction *action;
GConfBridge *bridge;
GObject *object;
const gchar *key;
@@ -1515,7 +1519,9 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view)
shell_view = E_SHELL_VIEW (mail_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
- shell_content = e_shell_view_get_shell_content (shell_view);
+
+ mail_shell_content = mail_shell_view->priv->mail_shell_content;
+ searchbar = e_mail_shell_content_get_searchbar (mail_shell_content);
/* Mail Actions */
action_group = ACTION_GROUP (MAIL);
@@ -1542,15 +1548,19 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view)
MAIL_SCOPE_CURRENT_FOLDER,
G_CALLBACK (action_search_scope_cb), mail_shell_view);
- radio_action = GTK_RADIO_ACTION (ACTION (MAIL_SCOPE_ALL_ACCOUNTS));
- e_shell_content_set_scope_action (shell_content, radio_action);
- e_shell_content_set_scope_visible (shell_content, TRUE);
+ action = ACTION (MAIL_SCOPE_ALL_ACCOUNTS);
+ combo_box = e_shell_searchbar_get_scope_combo_box (searchbar);
+ e_action_combo_box_set_action (combo_box, GTK_RADIO_ACTION (action));
+ e_shell_searchbar_set_scope_visible (searchbar, TRUE);
- /* Advanced Search action */
- radio_action = GTK_RADIO_ACTION (ACTION (MAIL_SEARCH_ADVANCED_HIDDEN));
- e_shell_content_set_search_radio_action (shell_content, radio_action);
- gtk_action_set_visible (GTK_ACTION (radio_action), FALSE);
- gtk_radio_action_set_current_value (radio_action, MAIL_SEARCH_SUBJECT_OR_ADDRESSES_CONTAIN);
+ /* Advanced Search Action */
+ action = ACTION (MAIL_SEARCH_ADVANCED_HIDDEN);
+ gtk_action_set_visible (action, FALSE);
+ e_shell_searchbar_set_search_option (
+ searchbar, GTK_RADIO_ACTION (action));
+ gtk_radio_action_set_current_value (
+ GTK_RADIO_ACTION (action),
+ MAIL_SEARCH_SUBJECT_OR_ADDRESSES_CONTAIN);
/* Bind GObject properties for GConf keys. */
@@ -1588,7 +1598,7 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view)
e_mutual_binding_new (
ACTION (MAIL_PREVIEW), "active",
- shell_content, "preview-visible");
+ mail_shell_content, "preview-visible");
e_binding_new (
ACTION (MAIL_PREVIEW), "active",
@@ -1601,7 +1611,7 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view)
/* XXX The boolean sense of the GConf key is the inverse of
* the menu item, so we have to maintain two properties. */
e_mutual_binding_new_with_negation (
- shell_content, "show-deleted",
+ mail_shell_content, "show-deleted",
ACTION (MAIL_HIDE_DELETED), "active");
/* Keep the sensitivity of "Create Search Folder from Search"
@@ -1772,11 +1782,13 @@ e_mail_shell_view_update_popup_labels (EMailShellView *mail_shell_view)
void
e_mail_shell_view_update_search_filter (EMailShellView *mail_shell_view)
{
+ EMailShellContent *mail_shell_content;
EShell *shell;
- EShellContent *shell_content;
- EShellSettings *shell_settings;
- EShellWindow *shell_window;
EShellView *shell_view;
+ EShellWindow *shell_window;
+ EShellSettings *shell_settings;
+ EShellSearchbar *searchbar;
+ EActionComboBox *combo_box;
GtkActionGroup *action_group;
GtkRadioAction *radio_action;
GtkTreeModel *tree_model;
@@ -1789,7 +1801,6 @@ e_mail_shell_view_update_search_filter (EMailShellView *mail_shell_view)
g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view));
shell_view = E_SHELL_VIEW (mail_shell_view);
- shell_content = e_shell_view_get_shell_content (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
shell = e_shell_window_get_shell (shell_window);
@@ -1849,13 +1860,16 @@ e_mail_shell_view_update_search_filter (EMailShellView *mail_shell_view)
}
/* Use any action in the group; doesn't matter which. */
- e_shell_content_set_filter_action (shell_content, radio_action);
+ mail_shell_content = mail_shell_view->priv->mail_shell_content;
+ searchbar = e_mail_shell_content_get_searchbar (mail_shell_content);
+ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
+ e_action_combo_box_set_action (combo_box, radio_action);
ii = MAIL_FILTER_UNREAD_MESSAGES;
- e_shell_content_add_filter_separator_after (shell_content, ii);
+ e_action_combo_box_add_separator_after (combo_box, ii);
ii = MAIL_FILTER_READ_MESSAGES;
- e_shell_content_add_filter_separator_before (shell_content, ii);
+ e_action_combo_box_add_separator_after (combo_box, ii);
g_object_unref (tree_model);
}
diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c
index c152b84817..f1e9805752 100644
--- a/modules/mail/e-mail-shell-view-private.c
+++ b/modules/mail/e-mail-shell-view-private.c
@@ -646,7 +646,7 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view)
/* Populate built-in rules for search entry popup menu.
* Keep the assertions, please. If the conditions aren't
* met we're going to crash anyway, just more mysteriously. */
- context = e_shell_content_get_search_context (shell_content);
+ context = E_SHELL_VIEW_GET_CLASS (shell_view)->search_context;
source = E_FILTER_SOURCE_DEMAND;
while ((rule = e_rule_context_next_rule (context, rule, source))) {
g_assert (ii < MAIL_NUM_SEARCH_RULES);
@@ -696,8 +696,8 @@ e_mail_shell_view_private_finalize (EMailShellView *mail_shell_view)
void
e_mail_shell_view_restore_state (EMailShellView *mail_shell_view)
{
- EShellView *shell_view;
- EShellContent *shell_content;
+ EMailShellContent *mail_shell_content;
+ EShellSearchbar *searchbar;
EMailReader *reader;
const gchar *folder_uri;
gchar *group_name;
@@ -706,17 +706,17 @@ e_mail_shell_view_restore_state (EMailShellView *mail_shell_view)
g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view));
- shell_view = E_SHELL_VIEW (mail_shell_view);
- shell_content = e_shell_view_get_shell_content (shell_view);
+ mail_shell_content = mail_shell_view->priv->mail_shell_content;
+ searchbar = e_mail_shell_content_get_searchbar (mail_shell_content);
- reader = E_MAIL_READER (shell_content);
+ reader = E_MAIL_READER (mail_shell_content);
folder_uri = e_mail_reader_get_folder_uri (reader);
if (folder_uri == NULL)
return;
group_name = g_strdup_printf ("Folder %s", folder_uri);
- e_shell_content_restore_state (shell_content, group_name);
+ e_shell_searchbar_restore_state (searchbar, group_name);
g_free (group_name);
}
diff --git a/modules/mail/e-mail-shell-view-private.h b/modules/mail/e-mail-shell-view-private.h
index bd99da5a1e..44a02eddbd 100644
--- a/modules/mail/e-mail-shell-view-private.h
+++ b/modules/mail/e-mail-shell-view-private.h
@@ -51,6 +51,7 @@
#include "em-folder-properties.h"
#include "em-folder-selector.h"
#include "em-folder-utils.h"
+#include "em-search-context.h"
#include "em-subscribe-editor.h"
#include "em-utils.h"
#include "mail-autofilter.h"
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index 7e1d00393d..de81e131c5 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -87,12 +87,14 @@ static void
mail_shell_view_execute_search (EShellView *shell_view)
{
EMailShellViewPrivate *priv;
+ EMailShellContent *mail_shell_content;
EShell *shell;
EShellWindow *shell_window;
EShellContent *shell_content;
EShellSettings *shell_settings;
+ EShellSearchbar *searchbar;
+ EActionComboBox *combo_box;
EMFormatHTMLDisplay *html_display;
- EMailShellContent *mail_shell_content;
GtkWidget *message_list;
EFilterRule *rule;
EMailReader *reader;
@@ -121,6 +123,7 @@ mail_shell_view_execute_search (EShellView *shell_view)
shell_settings = e_shell_get_shell_settings (shell);
mail_shell_content = E_MAIL_SHELL_CONTENT (shell_content);
+ searchbar = e_mail_shell_content_get_searchbar (mail_shell_content);
reader = E_MAIL_READER (shell_content);
folder = e_mail_reader_get_folder (reader);
@@ -137,7 +140,7 @@ mail_shell_view_execute_search (EShellView *shell_view)
key_file = e_shell_view_get_state_key_file (shell_view);
key = STATE_KEY_SEARCH_TEXT;
- string = e_shell_content_get_search_text (shell_content);
+ string = e_shell_searchbar_get_search_text (searchbar);
group_name = g_strdup_printf ("Folder %s", folder_uri);
if (string != NULL && *string != '\0')
@@ -158,12 +161,12 @@ mail_shell_view_execute_search (EShellView *shell_view)
action = ACTION (MAIL_SEARCH_SUBJECT_OR_ADDRESSES_CONTAIN);
value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
- text = e_shell_content_get_search_text (shell_content);
+ text = e_shell_searchbar_get_search_text (searchbar);
if (value == MAIL_SEARCH_ADVANCED || text == NULL || *text == '\0') {
if (value != MAIL_SEARCH_ADVANCED)
- e_shell_content_set_search_rule (shell_content, NULL);
+ e_shell_view_set_search_rule (shell_view, NULL);
- query = e_shell_content_get_search_rule_as_string (shell_content);
+ query = e_shell_view_get_search_query (shell_view);
if (!query)
query = g_strdup ("");
@@ -177,9 +180,9 @@ mail_shell_view_execute_search (EShellView *shell_view)
g_return_if_fail (value >= 0 && value < MAIL_NUM_SEARCH_RULES);
rule = priv->search_rules[value];
- /* Set the search rule in EShellContent so that "Create
+ /* Set the search rule in EShellView so that "Create
* Search Folder from Search" works for quick searches. */
- e_shell_content_set_search_rule (shell_content, rule);
+ e_shell_view_set_search_rule (shell_view, rule);
for (iter = rule->parts; iter != NULL; iter = iter->next) {
EFilterPart *part = iter->data;
@@ -220,7 +223,8 @@ filter:
/* Apply selected filter. */
- value = e_shell_content_get_filter_value (shell_content);
+ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
+ value = e_action_combo_box_get_current_value (combo_box);
switch (value) {
case MAIL_FILTER_ALL_MESSAGES:
break;
@@ -593,6 +597,7 @@ mail_shell_view_class_init (EMailShellViewClass *class,
shell_view_class->icon_name = "evolution-mail";
shell_view_class->ui_definition = "evolution-mail.ui";
shell_view_class->ui_manager_id = "org.gnome.evolution.mail";
+ shell_view_class->search_context_type = EM_SEARCH_TYPE_CONTEXT;
shell_view_class->search_options = "/mail-search-options";
shell_view_class->search_rules = "searchtypes.xml";
shell_view_class->new_shell_content = e_mail_shell_content_new;
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 2dee1b2206..876b945f8f 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -22,6 +22,7 @@ eshellinclude_HEADERS = \
e-shell-backend.h \
e-shell-common.h \
e-shell-content.h \
+ e-shell-searchbar.h \
e-shell-settings.h \
e-shell-sidebar.h \
e-shell-switcher.h \
@@ -64,6 +65,7 @@ libeshell_la_SOURCES = \
e-shell.c \
e-shell-backend.c \
e-shell-content.c \
+ e-shell-searchbar.c \
e-shell-settings.c \
e-shell-sidebar.c \
e-shell-switcher.c \
diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c
index 6a883d5230..bc24b22222 100644
--- a/shell/e-shell-content.c
+++ b/shell/e-shell-content.c
@@ -31,6 +31,7 @@
#include "widgets/misc/e-hinted-entry.h"
#include "e-shell-backend.h"
+#include "e-shell-searchbar.h"
#include "e-shell-view.h"
#include "e-shell-window-actions.h"
@@ -38,46 +39,18 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_SHELL_CONTENT, EShellContentPrivate))
-#define STATE_KEY_SEARCH_FILTER "SearchFilter"
-#define STATE_KEY_SEARCH_SCOPE "SearchScope"
-#define STATE_KEY_SEARCH_TEXT "SearchText"
-
struct _EShellContentPrivate {
gpointer shell_view; /* weak pointer */
- ERuleContext *search_context;
- EFilterRule *search_rule;
- gchar *system_filename;
- gchar *user_filename;
-
- GtkWidget *search_bar;
+ GtkWidget *searchbar;
- /* Search bar children (not referenced) */
- GtkWidget *filter_combo_box;
- GtkWidget *search_entry;
- GtkWidget *scope_combo_box;
- GtkRadioAction *search_radio; /* to be able to manage radio here */
-
- guint filter_visible : 1;
- guint search_visible : 1;
- guint scope_visible : 1;
+ /* Custom search rules. */
+ gchar *user_filename;
};
enum {
PROP_0,
- PROP_FILTER_ACTION,
- PROP_FILTER_VALUE,
- PROP_FILTER_VISIBLE,
- PROP_SEARCH_CONTEXT,
- PROP_SEARCH_HINT,
- PROP_SEARCH_RULE,
- PROP_SEARCH_TEXT,
- PROP_SEARCH_VISIBLE,
- PROP_SCOPE_ACTION,
- PROP_SCOPE_VALUE,
- PROP_SCOPE_VISIBLE,
- PROP_SEARCH_RADIO_ACTION,
PROP_SHELL_VIEW
};
@@ -98,269 +71,6 @@ shell_content_dialog_rule_changed (GtkWidget *dialog,
}
static void
-shell_content_update_search_widgets (EShellContent *shell_content)
-{
- EShellView *shell_view;
- EShellWindow *shell_window;
- GtkAction *action;
- GtkWidget *widget;
- const gchar *search_text;
- gboolean sensitive;
-
- g_return_if_fail (shell_content != NULL);
-
- shell_view = e_shell_content_get_shell_view (shell_content);
- g_return_if_fail (shell_view != NULL);
-
- /* EShellView subclasses are responsible for actually
- * executing the search. This is all cosmetic stuff. */
-
- widget = shell_content->priv->search_entry;
- shell_window = e_shell_view_get_shell_window (shell_view);
- search_text = e_shell_content_get_search_text (shell_content);
-
- sensitive =
- (search_text != NULL && *search_text != '\0') ||
- (e_shell_content_get_search_rule (shell_content) != NULL);
-
- if (sensitive) {
- GtkStyle *style;
- const GdkColor *fg_color, *bg_color;
-
- style = gtk_widget_get_style (widget);
- fg_color = &style->text[(search_text != NULL && *search_text != '\0') ? GTK_STATE_SELECTED : GTK_STATE_INSENSITIVE];
- bg_color = &style->mid[GTK_STATE_SELECTED];
-
- if (gdk_color_equal (fg_color, bg_color))
- bg_color = &style->base[GTK_STATE_SELECTED];
-
- gtk_widget_modify_base (widget, GTK_STATE_NORMAL, bg_color);
- gtk_widget_modify_text (widget, GTK_STATE_NORMAL, fg_color);
- } else {
- /* Text color will be updated when we move the focus. */
- gtk_widget_modify_base (widget, GTK_STATE_NORMAL, NULL);
- }
-
- action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window);
- gtk_action_set_sensitive (action, sensitive);
-
- action = E_SHELL_WINDOW_ACTION_SEARCH_SAVE (shell_window);
- gtk_action_set_sensitive (action, sensitive);
-}
-
-static void
-shell_content_execute_search_cb (EShellView *shell_view,
- EShellContent *shell_content)
-{
- GtkWidget *widget;
-
- shell_content_update_search_widgets (shell_content);
-
- if (!e_shell_view_is_active (shell_view))
- return;
-
- /* Direct the focus away from the search entry, so that a
- * focus-in event is required before the text can be changed.
- * This will reset the entry to the appropriate visual state. */
- widget = gtk_bin_get_child (GTK_BIN (shell_content));
- if (GTK_IS_PANED (widget))
- widget = gtk_paned_get_child1 (GTK_PANED (widget));
- gtk_widget_grab_focus (widget);
-}
-
-static void
-shell_content_entry_activate_cb (EShellContent *shell_content,
- GtkEntry *entry)
-{
- EShellView *shell_view;
- EShellWindow *shell_window;
- GtkAction *action;
- const gchar *text;
-
- shell_view = e_shell_content_get_shell_view (shell_content);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- text = gtk_entry_get_text (entry);
- if (text && *text)
- action = E_SHELL_WINDOW_ACTION_SEARCH_QUICK (shell_window);
- else
- action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window);
-
- gtk_action_activate (action);
-}
-
-static void
-shell_content_entry_changed_cb (EShellContent *shell_content,
- GtkEntry *entry)
-{
- EShellView *shell_view;
- EShellWindow *shell_window;
- GtkAction *action;
- const gchar *text;
- gboolean sensitive;
-
- shell_view = e_shell_content_get_shell_view (shell_content);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- text = gtk_entry_get_text (entry);
- sensitive = (text != NULL && *text != '\0' && !e_hinted_entry_get_hint_shown (E_HINTED_ENTRY (entry)));
-
- action = E_SHELL_WINDOW_ACTION_SEARCH_QUICK (shell_window);
- gtk_action_set_sensitive (action, sensitive);
-}
-
-static void
-shell_content_entry_icon_press_cb (EShellContent *shell_content,
- GtkEntryIconPosition icon_pos,
- GdkEvent *event)
-{
- EShellView *shell_view;
- EShellWindow *shell_window;
- GtkAction *action;
-
- /* Show the search options menu when the icon is pressed. */
-
- if (icon_pos != GTK_ENTRY_ICON_PRIMARY)
- return;
-
- shell_view = e_shell_content_get_shell_view (shell_content);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- action = E_SHELL_WINDOW_ACTION_SEARCH_OPTIONS (shell_window);
- gtk_action_activate (action);
-}
-
-static void
-shell_content_entry_icon_release_cb (EShellContent *shell_content,
- GtkEntryIconPosition icon_pos,
- GdkEvent *event)
-{
- EShellView *shell_view;
- EShellWindow *shell_window;
- GtkAction *action;
-
- /* Clear the search when the icon is pressed and released. */
-
- if (icon_pos != GTK_ENTRY_ICON_SECONDARY)
- return;
-
- shell_view = e_shell_content_get_shell_view (shell_content);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window);
- gtk_action_activate (action);
-}
-
-static gboolean
-shell_content_entry_key_press_cb (EShellContent *shell_content,
- GdkEventKey *key_event,
- GtkWidget *entry)
-{
- EShellView *shell_view;
- EShellWindow *shell_window;
- GtkAction *action;
- guint mask;
-
- mask = gtk_accelerator_get_default_mod_mask ();
- if ((key_event->state & mask) != GDK_MOD1_MASK)
- return FALSE;
-
- if (key_event->keyval != GDK_Down)
- return FALSE;
-
- shell_view = e_shell_content_get_shell_view (shell_content);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- action = E_SHELL_WINDOW_ACTION_SEARCH_OPTIONS (shell_window);
- gtk_action_activate (action);
-
- return TRUE;
-}
-
-static void
-shell_content_init_search_context (EShellContent *shell_content)
-{
- EShellContentClass *shell_content_class;
- EShellView *shell_view;
- EShellViewClass *shell_view_class;
- EShellBackend *shell_backend;
- ERuleContext *context;
- EFilterRule *rule;
- EFilterPart *part;
- gchar *system_filename;
- gchar *user_filename;
-
- shell_view = e_shell_content_get_shell_view (shell_content);
- shell_backend = e_shell_view_get_shell_backend (shell_view);
- shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view);
- g_return_if_fail (shell_view_class->search_rules != NULL);
-
- shell_content_class = E_SHELL_CONTENT_GET_CLASS (shell_content);
- g_return_if_fail (shell_content_class->new_search_context != NULL);
-
- /* The basename for built-in searches is specified in the
- * shell view class. All built-in search rules live in the
- * same directory. */
- system_filename = g_build_filename (
- EVOLUTION_RULEDIR, shell_view_class->search_rules, NULL);
-
- /* The filename for custom saved searches is always of
- * the form "$(shell_backend_data_dir)/searches.xml". */
- user_filename = g_build_filename (
- e_shell_backend_get_data_dir (shell_backend),
- "searches.xml", NULL);
-
- context = shell_content_class->new_search_context ();
- e_rule_context_add_part_set (
- context, "partset", E_TYPE_FILTER_PART,
- e_rule_context_add_part, e_rule_context_next_part);
- e_rule_context_add_rule_set (
- context, "ruleset", E_TYPE_FILTER_RULE,
- e_rule_context_add_rule, e_rule_context_next_rule);
- e_rule_context_load (context, system_filename, user_filename);
-
- /* XXX Not sure why this is necessary. */
- g_object_set_data_full (
- G_OBJECT (context), "system",
- g_strdup (system_filename), g_free);
- g_object_set_data_full (
- G_OBJECT (context), "user",
- g_strdup (user_filename), g_free);
-
- rule = e_filter_rule_new ();
- part = e_rule_context_next_part (context, NULL);
- if (part == NULL)
- g_warning (
- "Could not load %s search: no parts",
- e_shell_view_get_name (shell_view));
- else
- e_filter_rule_add_part (rule, e_filter_part_clone (part));
-
- shell_content->priv->search_context = context;
- shell_content->priv->system_filename = system_filename;
- shell_content->priv->user_filename = user_filename;
-}
-
-static void
-shell_content_activate_advanced_search (EShellContent *shell_content)
-{
- GtkRadioAction *radio_action;
- const gchar *search_text;
-
- g_return_if_fail (shell_content != NULL);
- g_return_if_fail (shell_content->priv->search_entry != NULL);
-
- /* cannot mix text search with an Advanced Search, thus unsetting search text */
- search_text = e_shell_content_get_search_text (shell_content);
- if (search_text)
- e_shell_content_set_search_text (shell_content, NULL);
-
- radio_action = e_shell_content_get_search_radio_action (shell_content);
- if (radio_action)
- g_object_set (G_OBJECT (radio_action), "current-value", -1, NULL);
-}
-
-static void
shell_content_set_shell_view (EShellContent *shell_content,
EShellView *shell_view)
{
@@ -380,72 +90,6 @@ shell_content_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_FILTER_ACTION:
- e_shell_content_set_filter_action (
- E_SHELL_CONTENT (object),
- g_value_get_object (value));
- return;
-
- case PROP_FILTER_VALUE:
- e_shell_content_set_filter_value (
- E_SHELL_CONTENT (object),
- g_value_get_int (value));
- return;
-
- case PROP_FILTER_VISIBLE:
- e_shell_content_set_filter_visible (
- E_SHELL_CONTENT (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_SEARCH_HINT:
- e_shell_content_set_search_hint (
- E_SHELL_CONTENT (object),
- g_value_get_string (value));
- return;
-
- case PROP_SEARCH_RULE:
- e_shell_content_set_search_rule (
- E_SHELL_CONTENT (object),
- g_value_get_object (value));
- return;
-
- case PROP_SEARCH_TEXT:
- e_shell_content_set_search_text (
- E_SHELL_CONTENT (object),
- g_value_get_string (value));
- return;
-
- case PROP_SEARCH_VISIBLE:
- e_shell_content_set_search_visible (
- E_SHELL_CONTENT (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_SCOPE_ACTION:
- e_shell_content_set_scope_action (
- E_SHELL_CONTENT (object),
- g_value_get_object (value));
- return;
-
- case PROP_SCOPE_VALUE:
- e_shell_content_set_scope_value (
- E_SHELL_CONTENT (object),
- g_value_get_int (value));
- return;
-
- case PROP_SCOPE_VISIBLE:
- e_shell_content_set_scope_visible (
- E_SHELL_CONTENT (object),
- g_value_get_boolean (value));
- return;
-
- case PROP_SEARCH_RADIO_ACTION:
- e_shell_content_set_search_radio_action (
- E_SHELL_CONTENT (object),
- g_value_get_object (value));
- return;
-
case PROP_SHELL_VIEW:
shell_content_set_shell_view (
E_SHELL_CONTENT (object),
@@ -463,78 +107,6 @@ shell_content_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_FILTER_ACTION:
- g_value_set_object (
- value, e_shell_content_get_filter_action (
- E_SHELL_CONTENT (object)));
- return;
-
- case PROP_FILTER_VALUE:
- g_value_set_int (
- value, e_shell_content_get_filter_value (
- E_SHELL_CONTENT (object)));
- return;
-
- case PROP_FILTER_VISIBLE:
- g_value_set_boolean (
- value, e_shell_content_get_filter_visible (
- E_SHELL_CONTENT (object)));
- return;
-
- case PROP_SEARCH_CONTEXT:
- g_value_set_object (
- value, e_shell_content_get_search_context (
- E_SHELL_CONTENT (object)));
- return;
-
- case PROP_SEARCH_HINT:
- g_value_set_string (
- value, e_shell_content_get_search_hint (
- E_SHELL_CONTENT (object)));
- return;
-
- case PROP_SEARCH_RULE:
- g_value_set_object (
- value, e_shell_content_get_search_rule (
- E_SHELL_CONTENT (object)));
- return;
-
- case PROP_SEARCH_TEXT:
- g_value_set_string (
- value, e_shell_content_get_search_text (
- E_SHELL_CONTENT (object)));
- return;
-
- case PROP_SEARCH_VISIBLE:
- g_value_set_boolean (
- value, e_shell_content_get_search_visible (
- E_SHELL_CONTENT (object)));
- return;
-
- case PROP_SCOPE_ACTION:
- g_value_set_object (
- value, e_shell_content_get_scope_action (
- E_SHELL_CONTENT (object)));
- return;
-
- case PROP_SCOPE_VALUE:
- g_value_set_int (
- value, e_shell_content_get_scope_value (
- E_SHELL_CONTENT (object)));
- return;
-
- case PROP_SCOPE_VISIBLE:
- g_value_set_boolean (
- value, e_shell_content_get_scope_visible (
- E_SHELL_CONTENT (object)));
- return;
-
- case PROP_SEARCH_RADIO_ACTION:
- g_value_set_object (
- value, e_shell_content_get_search_radio_action (
- E_SHELL_CONTENT (object)));
- return;
-
case PROP_SHELL_VIEW:
g_value_set_object (
value, e_shell_content_get_shell_view (
@@ -558,85 +130,42 @@ shell_content_dispose (GObject *object)
priv->shell_view = NULL;
}
- if (priv->search_context != NULL) {
- g_object_unref (priv->search_context);
- priv->search_context = NULL;
- }
-
- if (priv->search_radio) {
- g_signal_handlers_disconnect_matched (
- priv->search_radio, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, object);
- g_object_unref (priv->search_radio);
- priv->search_radio = NULL;
- }
-
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-shell_content_finalize (GObject *object)
-{
- EShellContentPrivate *priv;
-
- priv = E_SHELL_CONTENT_GET_PRIVATE (object);
-
- g_free (priv->system_filename);
- g_free (priv->user_filename);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
shell_content_constructed (GObject *object)
{
- EShellView *shell_view;
- EShellWindow *shell_window;
+ EShellContentClass *class;
EShellContent *shell_content;
- GtkSizeGroup *size_group;
- GtkAction *action;
+ EShellBackend *shell_backend;
+ EShellView *shell_view;
GtkWidget *widget;
+ const gchar *data_dir;
shell_content = E_SHELL_CONTENT (object);
shell_view = e_shell_content_get_shell_view (shell_content);
- shell_window = e_shell_view_get_shell_window (shell_view);
- size_group = e_shell_view_get_size_group (shell_view);
-
- g_signal_connect_after (
- shell_view, "execute-search",
- G_CALLBACK (shell_content_execute_search_cb),
- shell_content);
-
- widget = shell_content->priv->search_entry;
-
- action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window);
- e_binding_new (
- action, "sensitive",
- widget, "secondary-icon-sensitive");
- e_binding_new (
- action, "stock-id",
- widget, "secondary-icon-stock");
- e_binding_new (
- action, "tooltip",
- widget, "secondary-icon-tooltip-text");
-
- action = E_SHELL_WINDOW_ACTION_SEARCH_OPTIONS (shell_window);
- e_binding_new (
- action, "sensitive",
- widget, "primary-icon-sensitive");
- e_binding_new (
- action, "stock-id",
- widget, "primary-icon-stock");
- e_binding_new (
- action, "tooltip",
- widget, "primary-icon-tooltip-text");
-
- widget = shell_content->priv->search_bar;
- gtk_size_group_add_widget (size_group, widget);
-
- shell_content_init_search_context (shell_content);
+ shell_backend = e_shell_view_get_shell_backend (shell_view);
+
+ /* XXX Regenerate the filename for custom saved search as done
+ * in shell_view_init_search_context(). ERuleContext ought
+ * to remember the filename when loading rules so you don't
+ * have to keep passing it in when saving rules. */
+ data_dir = e_shell_backend_get_data_dir (shell_backend);
+ shell_content->priv->user_filename =
+ g_build_filename (data_dir, "searches.xml", NULL);
+
+ class = E_SHELL_CONTENT_GET_CLASS (shell_content);
+ if (class->construct_searchbar != NULL)
+ widget = class->construct_searchbar (shell_content);
+ else
+ widget = NULL;
+ if (widget != NULL) {
+ gtk_widget_set_parent (widget, GTK_WIDGET (shell_content));
+ shell_content->priv->searchbar = g_object_ref (widget);
+ gtk_widget_show (widget);
+ }
}
static void
@@ -649,11 +178,11 @@ shell_content_destroy (GtkObject *gtk_object)
/* Unparent the widget before destroying it to avoid
* writing a custom GtkContainer::remove() method. */
- if (priv->search_bar != NULL) {
- gtk_widget_unparent (priv->search_bar);
- gtk_widget_destroy (priv->search_bar);
- g_object_unref (priv->search_bar);
- priv->search_bar = NULL;
+ if (priv->searchbar != NULL) {
+ gtk_widget_unparent (priv->searchbar);
+ gtk_widget_destroy (priv->searchbar);
+ g_object_unref (priv->searchbar);
+ priv->searchbar = NULL;
}
/* Chain up to parent's destroy() method. */
@@ -676,8 +205,10 @@ shell_content_size_request (GtkWidget *widget,
child = gtk_bin_get_child (GTK_BIN (widget));
gtk_widget_size_request (child, requisition);
- child = priv->search_bar;
- gtk_widget_size_request (child, &child_requisition);
+ if (priv->searchbar == NULL)
+ return;
+
+ gtk_widget_size_request (priv->searchbar, &child_requisition);
requisition->width = MAX (requisition->width, child_requisition.width);
requisition->height += child_requisition.height;
}
@@ -695,15 +226,20 @@ shell_content_size_allocate (GtkWidget *widget,
widget->allocation = *allocation;
- child = priv->search_bar;
- gtk_widget_size_request (child, &child_requisition);
+ child = priv->searchbar;
+
+ if (child == NULL)
+ child_requisition.height = 0;
+ else
+ gtk_widget_size_request (child, &child_requisition);
child_allocation.x = allocation->x;
child_allocation.y = allocation->y;
child_allocation.width = allocation->width;
child_allocation.height = child_requisition.height;
- gtk_widget_size_allocate (child, &child_allocation);
+ if (child != NULL)
+ gtk_widget_size_allocate (child, &child_allocation);
child_allocation.y += child_requisition.height;
child_allocation.height =
@@ -724,14 +260,46 @@ shell_content_forall (GtkContainer *container,
priv = E_SHELL_CONTENT_GET_PRIVATE (container);
- if (include_internals)
- callback (priv->search_bar, callback_data);
+ if (include_internals && priv->searchbar != NULL)
+ callback (priv->searchbar, callback_data);
/* Chain up to parent's forall() method. */
GTK_CONTAINER_CLASS (parent_class)->forall (
container, include_internals, callback, callback_data);
}
+static gchar *
+shell_content_get_search_name (EShellContent *shell_content)
+{
+ EShellSearchbar *searchbar;
+ EShellView *shell_view;
+ EFilterRule *rule;
+ const gchar *search_text;
+
+ shell_view = e_shell_content_get_shell_view (shell_content);
+
+ rule = e_shell_view_get_search_rule (shell_view);
+ g_return_val_if_fail (E_IS_FILTER_RULE (rule), NULL);
+
+ searchbar = E_SHELL_SEARCHBAR (shell_content->priv->searchbar);
+ search_text = e_shell_searchbar_get_search_text (searchbar);
+
+ if (search_text == NULL || *search_text == '\0')
+ search_text = "''";
+
+ return g_strdup_printf ("%s %s", rule->name, search_text);
+}
+
+static GtkWidget *
+shell_content_construct_searchbar (EShellContent *shell_content)
+{
+ EShellView *shell_view;
+
+ shell_view = e_shell_content_get_shell_view (shell_content);
+
+ return e_shell_searchbar_new (shell_view);
+}
+
static void
shell_content_class_init (EShellContentClass *class)
{
@@ -747,7 +315,6 @@ shell_content_class_init (EShellContentClass *class)
object_class->set_property = shell_content_set_property;
object_class->get_property = shell_content_get_property;
object_class->dispose = shell_content_dispose;
- object_class->finalize = shell_content_finalize;
object_class->constructed = shell_content_constructed;
gtk_object_class = GTK_OBJECT_CLASS (class);
@@ -760,134 +327,8 @@ shell_content_class_init (EShellContentClass *class)
container_class = GTK_CONTAINER_CLASS (class);
container_class->forall = shell_content_forall;
- class->new_search_context = e_rule_context_new;
-
- g_object_class_install_property (
- object_class,
- PROP_FILTER_ACTION,
- g_param_spec_object (
- "filter-action",
- NULL,
- NULL,
- GTK_TYPE_RADIO_ACTION,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_FILTER_VALUE,
- g_param_spec_int (
- "filter-value",
- NULL,
- NULL,
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_FILTER_VISIBLE,
- g_param_spec_boolean (
- "filter-visible",
- NULL,
- NULL,
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- object_class,
- PROP_SEARCH_CONTEXT,
- g_param_spec_object (
- "search-context",
- NULL,
- NULL,
- E_TYPE_RULE_CONTEXT,
- G_PARAM_READABLE));
-
- g_object_class_install_property (
- object_class,
- PROP_SEARCH_HINT,
- g_param_spec_string (
- "search-hint",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SEARCH_RULE,
- g_param_spec_object (
- "search-rule",
- NULL,
- NULL,
- E_TYPE_FILTER_RULE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SEARCH_TEXT,
- g_param_spec_string (
- "search-text",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SEARCH_VISIBLE,
- g_param_spec_boolean (
- "search-visible",
- NULL,
- NULL,
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- object_class,
- PROP_SCOPE_ACTION,
- g_param_spec_object (
- "scope-action",
- NULL,
- NULL,
- GTK_TYPE_RADIO_ACTION,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SCOPE_VALUE,
- g_param_spec_int (
- "scope-value",
- NULL,
- NULL,
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SCOPE_VISIBLE,
- g_param_spec_boolean (
- "scope-visible",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- object_class,
- PROP_SEARCH_RADIO_ACTION,
- g_param_spec_object (
- "search-radio-action",
- NULL,
- NULL,
- GTK_TYPE_RADIO_ACTION,
- G_PARAM_READWRITE));
+ class->get_search_name = shell_content_get_search_name;
+ class->construct_searchbar = shell_content_construct_searchbar;
/**
* EShellContent:shell-view
@@ -909,128 +350,9 @@ shell_content_class_init (EShellContentClass *class)
static void
shell_content_init (EShellContent *shell_content)
{
- GtkBox *box;
- GtkLabel *label;
- GtkWidget *widget;
-
shell_content->priv = E_SHELL_CONTENT_GET_PRIVATE (shell_content);
GTK_WIDGET_SET_FLAGS (shell_content, GTK_NO_WINDOW);
-
- /*** Build the Search Bar ***/
-
- widget = gtk_hbox_new (FALSE, 24);
- gtk_widget_set_parent (widget, GTK_WIDGET (shell_content));
- shell_content->priv->search_bar = g_object_ref (widget);
- gtk_widget_show (widget);
-
- /* Filter Combo Widgets */
-
- box = GTK_BOX (shell_content->priv->search_bar);
-
- widget = gtk_hbox_new (FALSE, 3);
- gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
-
- e_binding_new (
- shell_content, "filter-visible",
- widget, "visible");
-
- box = GTK_BOX (widget);
-
- /* Translators: The "Show:" label precedes a combo box that
- * allows the user to filter the current view. Examples of
- * items that appear in the combo box are "Unread Messages",
- * "Important Messages", or "Active Appointments". */
- widget = gtk_label_new_with_mnemonic (_("Sho_w:"));
- gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- label = GTK_LABEL (widget);
-
- widget = e_action_combo_box_new ();
- gtk_label_set_mnemonic_widget (label, widget);
- gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
- shell_content->priv->filter_combo_box = widget;
- gtk_widget_show (widget);
-
- /* Search Entry Widgets */
-
- box = GTK_BOX (shell_content->priv->search_bar);
-
- widget = gtk_hbox_new (FALSE, 3);
- gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
-
- e_binding_new (
- shell_content, "search-visible",
- widget, "visible");
-
- box = GTK_BOX (widget);
-
- /* Translators: This is part of the quick search interface.
- * example: Search: [_______________] in [ Current Folder ] */
- widget = gtk_label_new_with_mnemonic (_("Sear_ch:"));
- gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- label = GTK_LABEL (widget);
-
- widget = e_hinted_entry_new ();
- gtk_label_set_mnemonic_widget (label, widget);
- gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
- shell_content->priv->search_entry = widget;
- gtk_widget_show (widget);
-
- g_signal_connect_swapped (
- widget, "activate",
- G_CALLBACK (shell_content_entry_activate_cb),
- shell_content);
-
- g_signal_connect_swapped (
- widget, "changed",
- G_CALLBACK (shell_content_entry_changed_cb),
- shell_content);
-
- g_signal_connect_swapped (
- widget, "icon-press",
- G_CALLBACK (shell_content_entry_icon_press_cb),
- shell_content);
-
- g_signal_connect_swapped (
- widget, "icon-release",
- G_CALLBACK (shell_content_entry_icon_release_cb),
- shell_content);
-
- g_signal_connect_swapped (
- widget, "key-press-event",
- G_CALLBACK (shell_content_entry_key_press_cb),
- shell_content);
-
- /* Scope Combo Widgets */
-
- box = GTK_BOX (shell_content->priv->search_bar);
-
- widget = gtk_hbox_new (FALSE, 3);
- gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
-
- e_binding_new (
- shell_content, "scope-visible",
- widget, "visible");
-
- box = GTK_BOX (widget);
-
- /* Translators: This is part of the quick search interface.
- * example: Search: [_______________] in [ Current Folder ] */
- widget = gtk_label_new_with_mnemonic (_("i_n"));
- gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
-
- label = GTK_LABEL (widget);
-
- widget = e_action_combo_box_new ();
- gtk_label_set_mnemonic_widget (label, widget);
- gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
- shell_content->priv->scope_combo_box = widget;
- gtk_widget_show (widget);
}
GType
@@ -1077,6 +399,24 @@ e_shell_content_new (EShellView *shell_view)
}
/**
+ * e_shell_content_get_searchbar:
+ * @shell_view: an #EShellView
+ *
+ * Returns the search bar widget returned by the
+ * <structfield>construct_searchbar</structfield> method in
+ * #EShellContentClass.
+ *
+ * Returns: the search bar widget
+ **/
+GtkWidget *
+e_shell_content_get_searchbar (EShellContent *shell_content)
+{
+ g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
+
+ return shell_content->priv->searchbar;
+}
+
+/**
* e_shell_content_check_state:
* @shell_content: an #EShellContent
*
@@ -1118,371 +458,27 @@ e_shell_content_get_shell_view (EShellContent *shell_content)
return E_SHELL_VIEW (shell_content->priv->shell_view);
}
-GtkRadioAction *
-e_shell_content_get_filter_action (EShellContent *shell_content)
-{
- EActionComboBox *combo_box;
-
- g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
-
- combo_box = E_ACTION_COMBO_BOX (shell_content->priv->filter_combo_box);
-
- return e_action_combo_box_get_action (combo_box);
-}
-
-void
-e_shell_content_set_filter_action (EShellContent *shell_content,
- GtkRadioAction *filter_action)
-{
- EActionComboBox *combo_box;
-
- g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
-
- combo_box = E_ACTION_COMBO_BOX (shell_content->priv->filter_combo_box);
-
- e_action_combo_box_set_action (combo_box, filter_action);
-
- g_object_notify (G_OBJECT (shell_content), "filter-action");
-}
-
-gint
-e_shell_content_get_filter_value (EShellContent *shell_content)
-{
- EActionComboBox *combo_box;
-
- g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), 0);
-
- combo_box = E_ACTION_COMBO_BOX (shell_content->priv->filter_combo_box);
-
- return e_action_combo_box_get_current_value (combo_box);
-}
-
-void
-e_shell_content_set_filter_value (EShellContent *shell_content,
- gint filter_value)
-{
- EActionComboBox *combo_box;
-
- g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
-
- combo_box = E_ACTION_COMBO_BOX (shell_content->priv->filter_combo_box);
-
- e_action_combo_box_set_current_value (combo_box, filter_value);
-
- g_object_notify (G_OBJECT (shell_content), "filter-value");
-}
-
-gboolean
-e_shell_content_get_filter_visible (EShellContent *shell_content)
-{
- g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), FALSE);
-
- return shell_content->priv->filter_visible;
-}
-
-void
-e_shell_content_set_filter_visible (EShellContent *shell_content,
- gboolean filter_visible)
-{
- g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
-
- shell_content->priv->filter_visible = filter_visible;
-
- g_object_notify (G_OBJECT (shell_content), "filter-visible");
-}
-
-void
-e_shell_content_add_filter_separator_before (EShellContent *shell_content,
- gint action_value)
-{
- EActionComboBox *combo_box;
-
- g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
-
- combo_box = E_ACTION_COMBO_BOX (shell_content->priv->filter_combo_box);
-
- e_action_combo_box_add_separator_before (combo_box, action_value);
-}
-
-void
-e_shell_content_add_filter_separator_after (EShellContent *shell_content,
- gint action_value)
-{
- EActionComboBox *combo_box;
-
- g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
-
- combo_box = E_ACTION_COMBO_BOX (shell_content->priv->filter_combo_box);
-
- e_action_combo_box_add_separator_after (combo_box, action_value);
-}
-
-ERuleContext *
-e_shell_content_get_search_context (EShellContent *shell_content)
-{
- g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
-
- return shell_content->priv->search_context;
-}
-
-const gchar *
-e_shell_content_get_search_hint (EShellContent *shell_content)
-{
- EHintedEntry *entry;
-
- g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
-
- entry = E_HINTED_ENTRY (shell_content->priv->search_entry);
-
- return e_hinted_entry_get_hint (entry);
-}
-
-void
-e_shell_content_set_search_hint (EShellContent *shell_content,
- const gchar *search_hint)
-{
- EHintedEntry *entry;
-
- g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
-
- entry = E_HINTED_ENTRY (shell_content->priv->search_entry);
-
- e_hinted_entry_set_hint (entry, search_hint);
-
- g_object_notify (G_OBJECT (shell_content), "search-hint");
-}
-
-EFilterRule *
-e_shell_content_get_search_rule (EShellContent *shell_content)
-{
- g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
-
- return shell_content->priv->search_rule;
-}
-
-void
-e_shell_content_set_search_rule (EShellContent *shell_content,
- EFilterRule *search_rule)
-{
- g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
-
- if (search_rule != NULL) {
- g_return_if_fail (E_IS_FILTER_RULE (search_rule));
- g_object_ref (search_rule);
- }
-
- if (shell_content->priv->search_rule != NULL)
- g_object_unref (shell_content->priv->search_rule);
-
- shell_content->priv->search_rule = search_rule;
-
- shell_content_update_search_widgets (shell_content);
- g_object_notify (G_OBJECT (shell_content), "search-rule");
-}
-
-/* free returned string with g_free */
+/**
+ * e_shell_content_get_search_name:
+ * @shell_content: an #EShellContent
+ *
+ * Returns a newly-allocated string containing a suitable name for the
+ * current search criteria. This is used as the suggested name in the
+ * Save Search dialog. Free the returned string with g_free().
+ *
+ * Returns: a name for the current search criteria
+ **/
gchar *
-e_shell_content_get_search_rule_as_string (EShellContent *shell_content)
+e_shell_content_get_search_name (EShellContent *shell_content)
{
- EFilterRule *rule;
- GString *str;
+ EShellContentClass *class;
g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
- rule = e_shell_content_get_search_rule (shell_content);
-
- if (!rule)
- return NULL;
-
- str = g_string_new ("");
- e_filter_rule_build_code (rule, str);
+ class = E_SHELL_CONTENT_GET_CLASS (shell_content);
+ g_return_val_if_fail (class->get_search_name != NULL, NULL);
- return g_string_free (str, FALSE);
-}
-
-const gchar *
-e_shell_content_get_search_text (EShellContent *shell_content)
-{
- EHintedEntry *entry;
-
- g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
-
- entry = E_HINTED_ENTRY (shell_content->priv->search_entry);
-
- return e_hinted_entry_get_text (entry);
-}
-
-void
-e_shell_content_set_search_text (EShellContent *shell_content,
- const gchar *search_text)
-{
- EHintedEntry *entry;
-
- g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
-
- entry = E_HINTED_ENTRY (shell_content->priv->search_entry);
-
- e_hinted_entry_set_text (entry, search_text);
-
- shell_content_update_search_widgets (shell_content);
- g_object_notify (G_OBJECT (shell_content), "search-text");
-}
-
-gboolean
-e_shell_content_get_search_visible (EShellContent *shell_content)
-{
- g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), FALSE);
-
- return shell_content->priv->search_visible;
-}
-
-void
-e_shell_content_set_search_visible (EShellContent *shell_content,
- gboolean search_visible)
-{
- g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
-
- shell_content->priv->search_visible = search_visible;
-
- g_object_notify (G_OBJECT (shell_content), "search-visible");
-}
-
-GtkRadioAction *
-e_shell_content_get_scope_action (EShellContent *shell_content)
-{
- EActionComboBox *combo_box;
-
- g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
-
- combo_box = E_ACTION_COMBO_BOX (shell_content->priv->scope_combo_box);
-
- return e_action_combo_box_get_action (combo_box);
-}
-
-void
-e_shell_content_set_scope_action (EShellContent *shell_content,
- GtkRadioAction *scope_action)
-{
- EActionComboBox *combo_box;
-
- g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
-
- combo_box = E_ACTION_COMBO_BOX (shell_content->priv->scope_combo_box);
-
- e_action_combo_box_set_action (combo_box, scope_action);
-
- g_object_notify (G_OBJECT (shell_content), "scope-action");
-}
-
-gint
-e_shell_content_get_scope_value (EShellContent *shell_content)
-{
- EActionComboBox *combo_box;
-
- g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), 0);
-
- combo_box = E_ACTION_COMBO_BOX (shell_content->priv->scope_combo_box);
-
- return e_action_combo_box_get_current_value (combo_box);
-}
-
-void
-e_shell_content_set_scope_value (EShellContent *shell_content,
- gint scope_value)
-{
- EActionComboBox *combo_box;
-
- g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
-
- combo_box = E_ACTION_COMBO_BOX (shell_content->priv->scope_combo_box);
-
- e_action_combo_box_set_current_value (combo_box, scope_value);
-
- g_object_notify (G_OBJECT (shell_content), "scope-value");
-}
-
-gboolean
-e_shell_content_get_scope_visible (EShellContent *shell_content)
-{
- g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), FALSE);
-
- return shell_content->priv->scope_visible;
-}
-
-void
-e_shell_content_set_scope_visible (EShellContent *shell_content,
- gboolean scope_visible)
-{
- g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
-
- shell_content->priv->scope_visible = scope_visible;
-
- g_object_notify (G_OBJECT (shell_content), "scope-visible");
-}
-
-static void
-search_radio_changed_cb (GtkRadioAction *action,
- GtkRadioAction *current,
- EShellContent *shell_content)
-{
- EShellView *shell_view;
- const gchar *search_text;
- const gchar *label;
- gint current_value;
-
- shell_view = e_shell_content_get_shell_view (shell_content);
-
- label = gtk_action_get_label (GTK_ACTION (current));
- e_shell_content_set_search_hint (shell_content, label);
-
- current_value = gtk_radio_action_get_current_value (current);
- search_text = e_shell_content_get_search_text (shell_content);
-
- if (current_value != -1) {
- e_shell_content_set_search_rule (shell_content, NULL);
- e_shell_content_set_search_text (shell_content, search_text);
- if (search_text != NULL && *search_text != '\0')
- e_shell_view_execute_search (shell_view);
- } else if (search_text != NULL) {
- e_shell_content_set_search_text (shell_content, NULL);
- }
-}
-
-void
-e_shell_content_set_search_radio_action (EShellContent *shell_content,
- GtkRadioAction *search_action)
-{
- g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
-
- if (search_action != NULL) {
- g_return_if_fail (GTK_IS_RADIO_ACTION (search_action));
- g_object_ref (search_action);
- }
-
- if (shell_content->priv->search_radio) {
- g_signal_handlers_disconnect_matched (
- shell_content->priv->search_radio,
- G_SIGNAL_MATCH_DATA, 0, 0, NULL,
- search_radio_changed_cb, shell_content);
- g_object_unref (shell_content->priv->search_radio);
- }
-
- shell_content->priv->search_radio = search_action;
-
- if (shell_content->priv->search_radio != NULL)
- g_signal_connect (
- shell_content->priv->search_radio, "changed",
- G_CALLBACK (search_radio_changed_cb), shell_content);
-
- g_object_notify (G_OBJECT (shell_content), "search-radio-action");
-}
-
-GtkRadioAction *
-e_shell_content_get_search_radio_action (EShellContent *shell_content)
-{
- g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
-
- return shell_content->priv->search_radio;
+ return class->get_search_name (shell_content);
}
void
@@ -1504,14 +500,14 @@ e_shell_content_run_advanced_search_dialog (EShellContent *shell_content)
shell_window = e_shell_view_get_shell_window (shell_view);
user_filename = shell_content->priv->user_filename;
- rule = e_shell_content_get_search_rule (shell_content);
+ rule = e_shell_view_get_search_rule (shell_view);
if (rule == NULL)
rule = e_filter_rule_new ();
else
rule = e_filter_rule_clone (rule);
- context = e_shell_content_get_search_context (shell_content);
+ context = E_SHELL_VIEW_GET_CLASS (shell_view)->search_context;
widget = e_filter_rule_get_widget (rule, context);
e_filter_rule_set_source (rule, E_FILTER_SOURCE_INCOMING);
@@ -1548,10 +544,7 @@ run:
goto run;
}
- e_shell_content_set_search_rule (shell_content, rule);
-
- shell_content_activate_advanced_search (shell_content);
- e_shell_view_execute_search (shell_view);
+ e_shell_view_custom_search (shell_view, rule);
if (response == GTK_RESPONSE_APPLY) {
if (!e_rule_context_find_rule (context, rule->name, rule->source))
@@ -1568,13 +561,15 @@ exit:
void
e_shell_content_run_edit_searches_dialog (EShellContent *shell_content)
{
+ EShellView *shell_view;
ERuleContext *context;
ERuleEditor *editor;
const gchar *user_filename;
g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
- context = e_shell_content_get_search_context (shell_content);
+ shell_view = e_shell_content_get_shell_view (shell_content);
+ context = E_SHELL_VIEW_GET_CLASS (shell_view)->search_context;
user_filename = shell_content->priv->user_filename;
editor = e_rule_editor_new (
@@ -1596,7 +591,6 @@ e_shell_content_run_save_search_dialog (EShellContent *shell_content)
GtkWidget *widget;
EFilterRule *rule;
ERuleContext *context;
- const gchar *search_text;
const gchar *user_filename;
gchar *search_name;
gint response;
@@ -1608,19 +602,15 @@ e_shell_content_run_save_search_dialog (EShellContent *shell_content)
shell_window = e_shell_view_get_shell_window (shell_view);
user_filename = shell_content->priv->user_filename;
- rule = e_shell_content_get_search_rule (shell_content);
+ rule = e_shell_view_get_search_rule (shell_view);
g_return_if_fail (E_IS_FILTER_RULE (rule));
rule = e_filter_rule_clone (rule);
- search_text = e_shell_content_get_search_text (shell_content);
- if (search_text == NULL || *search_text == '\0')
- search_text = "''";
-
- search_name = g_strdup_printf ("%s %s", rule->name, search_text);
+ search_name = e_shell_content_get_search_name (shell_content);
e_filter_rule_set_name (rule, search_name);
g_free (search_name);
- context = e_shell_content_get_search_context (shell_content);
+ context = E_SHELL_VIEW_GET_CLASS (shell_view)->search_context;
widget = e_filter_rule_get_widget (rule, context);
e_filter_rule_set_source (rule, E_FILTER_SOURCE_INCOMING);
@@ -1656,83 +646,13 @@ run:
goto run;
}
- e_rule_context_add_rule (context, rule);
+ /* XXX This function steals the rule reference, so
+ * counteract that by referencing it again. */
+ e_rule_context_add_rule (context, g_object_ref (rule));
+
e_rule_context_save (context, user_filename);
exit:
g_object_unref (rule);
gtk_widget_destroy (dialog);
}
-
-void
-e_shell_content_restore_state (EShellContent *shell_content,
- const gchar *group_name)
-{
- EShellView *shell_view;
- EShellWindow *shell_window;
- GKeyFile *key_file;
- GtkAction *action;
- GtkWidget *widget;
- const gchar *search_text;
- const gchar *key;
- gchar *string;
-
- g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
- g_return_if_fail (group_name != NULL);
-
- shell_view = e_shell_content_get_shell_view (shell_content);
- shell_window = e_shell_view_get_shell_window (shell_view);
- key_file = e_shell_view_get_state_key_file (shell_view);
-
- /* Changing the combo boxes triggers searches, so block
- * the search action until the state is fully restored. */
- action = E_SHELL_WINDOW_ACTION_SEARCH_QUICK (shell_window);
- gtk_action_block_activate (action);
- e_shell_view_block_execute_search (shell_view);
-
- key = STATE_KEY_SEARCH_FILTER;
- string = g_key_file_get_string (key_file, group_name, key, NULL);
- if (string != NULL && *string != '\0')
- action = e_shell_window_get_action (shell_window, string);
- else
- action = NULL;
- if (action != NULL)
- gtk_action_activate (action);
- else {
- /* Pick the first combo box item. */
- widget = shell_content->priv->filter_combo_box;
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
- }
- g_free (string);
-
- key = STATE_KEY_SEARCH_SCOPE;
- string = g_key_file_get_string (key_file, group_name, key, NULL);
- if (string != NULL && *string != '\0')
- action = e_shell_window_get_action (shell_window, string);
- else
- action = NULL;
- if (action != NULL)
- gtk_action_activate (action);
- else {
- /* Pick the first combo box item. */
- widget = shell_content->priv->scope_combo_box;
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
- }
- g_free (string);
-
- key = STATE_KEY_SEARCH_TEXT;
- string = g_key_file_get_string (key_file, group_name, key, NULL);
- search_text = e_shell_content_get_search_text (shell_content);
- if (search_text != NULL && *search_text == '\0')
- search_text = NULL;
- if (g_strcmp0 (string, search_text) != 0)
- e_shell_content_set_search_text (shell_content, string);
- g_free (string);
-
- action = E_SHELL_WINDOW_ACTION_SEARCH_QUICK (shell_window);
- gtk_action_unblock_activate (action);
- e_shell_view_unblock_execute_search (shell_view);
-
- /* Now execute the search. */
- e_shell_view_execute_search (shell_view);
-}
diff --git a/shell/e-shell-content.h b/shell/e-shell-content.h
index 9ee9219cfb..3c3332b17b 100644
--- a/shell/e-shell-content.h
+++ b/shell/e-shell-content.h
@@ -29,8 +29,6 @@
#define E_SHELL_CONTENT_H
#include <shell/e-shell-common.h>
-#include <filter/e-filter-rule.h>
-#include <filter/e-rule-context.h>
/* Standard GObject macros */
#define E_TYPE_SHELL_CONTENT \
@@ -74,81 +72,30 @@ struct _EShellContent {
struct _EShellContentClass {
GtkBinClass parent_class;
- /* Factory Methods */
- ERuleContext * (*new_search_context) (void);
-
+ /* Methods */
guint32 (*check_state) (EShellContent *shell_content);
+ gchar * (*get_search_name) (EShellContent *shell_content);
+
+ /* This is a protected method. Not for public use. */
+ GtkWidget * (*construct_searchbar) (EShellContent *shell_content);
};
GType e_shell_content_get_type (void);
GtkWidget * e_shell_content_new (struct _EShellView *shell_view);
+GtkWidget * e_shell_content_get_searchbar (EShellContent *shell_content);
guint32 e_shell_content_check_state (EShellContent *shell_content);
struct _EShellView *
e_shell_content_get_shell_view (EShellContent *shell_content);
-GtkRadioAction *e_shell_content_get_filter_action
- (EShellContent *shell_content);
-void e_shell_content_set_filter_action
- (EShellContent *shell_content,
- GtkRadioAction *filter_action);
-gint e_shell_content_get_filter_value(EShellContent *shell_content);
-void e_shell_content_set_filter_value(EShellContent *shell_content,
- gint filter_value);
-gboolean e_shell_content_get_filter_visible
- (EShellContent *shell_content);
-void e_shell_content_set_filter_visible
- (EShellContent *shell_content,
- gboolean filter_visible);
-void e_shell_content_add_filter_separator_before
- (EShellContent *shell_content,
- gint action_value);
-void e_shell_content_add_filter_separator_after
- (EShellContent *shell_content,
- gint action_value);
-ERuleContext * e_shell_content_get_search_context
- (EShellContent *shell_content);
-const gchar * e_shell_content_get_search_hint (EShellContent *shell_content);
-void e_shell_content_set_search_hint (EShellContent *shell_content,
- const gchar *search_hint);
-EFilterRule * e_shell_content_get_search_rule (EShellContent *shell_content);
-void e_shell_content_set_search_rule (EShellContent *shell_content,
- EFilterRule *search_rule);
-gchar * e_shell_content_get_search_rule_as_string
- (EShellContent *shell_content);
-const gchar * e_shell_content_get_search_text (EShellContent *shell_content);
-void e_shell_content_set_search_text (EShellContent *shell_content,
- const gchar *search_text);
-gboolean e_shell_content_get_search_visible
- (EShellContent *shell_content);
-void e_shell_content_set_search_visible
- (EShellContent *shell_content,
- gboolean search_visible);
-GtkRadioAction *e_shell_content_get_scope_action(EShellContent *shell_content);
-void e_shell_content_set_scope_action(EShellContent *shell_content,
- GtkRadioAction *scope_action);
-gint e_shell_content_get_scope_value (EShellContent *shell_content);
-void e_shell_content_set_scope_value (EShellContent *shell_content,
- gint scope_value);
-gboolean e_shell_content_get_scope_visible
- (EShellContent *shell_content);
-void e_shell_content_set_scope_visible
- (EShellContent *shell_content,
- gboolean scope_visible);
-void e_shell_content_set_search_radio_action
- (EShellContent *shell_content,
- GtkRadioAction *search_action);
-GtkRadioAction *e_shell_content_get_search_radio_action
- (EShellContent *shell_content);
const gchar * e_shell_content_get_view_id (EShellContent *shell_content);
void e_shell_content_set_view_id (EShellContent *shell_content,
const gchar *view_id);
+gchar * e_shell_content_get_search_name (EShellContent *shell_content);
void e_shell_content_run_advanced_search_dialog
(EShellContent *shell_content);
void e_shell_content_run_edit_searches_dialog
(EShellContent *shell_content);
void e_shell_content_run_save_search_dialog
(EShellContent *shell_content);
-void e_shell_content_restore_state (EShellContent *shell_content,
- const gchar *group_name);
G_END_DECLS
diff --git a/shell/e-shell-searchbar.c b/shell/e-shell-searchbar.c
new file mode 100644
index 0000000000..f9b0b2e967
--- /dev/null
+++ b/shell/e-shell-searchbar.c
@@ -0,0 +1,1053 @@
+/*
+ * e-shell-searchbar.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-shell-searchbar.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include "e-util/e-binding.h"
+#include "widgets/misc/e-action-combo-box.h"
+#include "widgets/misc/e-hinted-entry.h"
+
+#include "e-shell-window-actions.h"
+
+#define E_SHELL_SEARCHBAR_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SHELL_SEARCHBAR, EShellSearchbarPrivate))
+
+#define SEARCH_OPTION_ADVANCED (-1)
+
+#define STATE_KEY_SEARCH_FILTER "SearchFilter"
+#define STATE_KEY_SEARCH_SCOPE "SearchScope"
+#define STATE_KEY_SEARCH_TEXT "SearchText"
+
+struct _EShellSearchbarPrivate {
+
+ gpointer shell_view; /* weak pointer */
+
+ GtkRadioAction *search_option;
+ EFilterRule *search_rule;
+
+ /* Child Widgets (not referenced) */
+ GtkWidget *filter_combo_box;
+ GtkWidget *search_entry;
+ GtkWidget *scope_combo_box;
+
+ guint filter_visible : 1;
+ guint search_visible : 1;
+ guint scope_visible : 1;
+};
+
+enum {
+ PROP_0,
+ PROP_FILTER_COMBO_BOX,
+ PROP_FILTER_VISIBLE,
+ PROP_SEARCH_HINT,
+ PROP_SEARCH_OPTION,
+ PROP_SEARCH_TEXT,
+ PROP_SEARCH_VISIBLE,
+ PROP_SCOPE_COMBO_BOX,
+ PROP_SCOPE_VISIBLE,
+ PROP_SHELL_VIEW
+};
+
+static gpointer parent_class;
+
+static void
+shell_searchbar_update_search_widgets (EShellSearchbar *searchbar)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ GtkAction *action;
+ GtkWidget *widget;
+ const gchar *search_text;
+ gboolean sensitive;
+
+ /* EShellView subclasses are responsible for actually
+ * executing the search. This is all cosmetic stuff. */
+
+ widget = searchbar->priv->search_entry;
+ shell_view = e_shell_searchbar_get_shell_view (searchbar);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ search_text = e_shell_searchbar_get_search_text (searchbar);
+
+ sensitive =
+ (search_text != NULL && *search_text != '\0') ||
+ (e_shell_view_get_search_rule (shell_view) != NULL);
+
+ if (sensitive) {
+ GtkStyle *style;
+ const GdkColor *color;
+
+ style = gtk_widget_get_style (widget);
+ color = &style->mid[GTK_STATE_SELECTED];
+
+ gtk_widget_modify_base (widget, GTK_STATE_NORMAL, color);
+ gtk_widget_modify_text (widget, GTK_STATE_NORMAL, NULL);
+ } else {
+ /* Text color will be updated when we move the focus. */
+ gtk_widget_modify_base (widget, GTK_STATE_NORMAL, NULL);
+ }
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_SAVE (shell_window);
+ gtk_action_set_sensitive (action, sensitive);
+}
+
+static void
+shell_searchbar_clear_search_cb (EShellView *shell_view,
+ EShellSearchbar *searchbar)
+{
+ GtkRadioAction *search_option;
+ gint current_value;
+
+ e_shell_searchbar_set_search_text (searchbar, NULL);
+
+ search_option = e_shell_searchbar_get_search_option (searchbar);
+ if (search_option == NULL)
+ return;
+
+ /* Reset the search option if it's set to advanced search. */
+ current_value = gtk_radio_action_get_current_value (search_option);
+ if (current_value == SEARCH_OPTION_ADVANCED)
+ gtk_radio_action_set_current_value (search_option, 0);
+}
+
+static void
+shell_searchbar_custom_search_cb (EShellView *shell_view,
+ EFilterRule *custom_rule,
+ EShellSearchbar *searchbar)
+{
+ GtkRadioAction *search_option;
+ gint value = SEARCH_OPTION_ADVANCED;
+
+ e_shell_searchbar_set_search_text (searchbar, NULL);
+
+ search_option = e_shell_searchbar_get_search_option (searchbar);
+ if (search_option != NULL)
+ gtk_radio_action_set_current_value (search_option, value);
+}
+
+static void
+shell_searchbar_execute_search_cb (EShellView *shell_view,
+ EShellSearchbar *searchbar)
+{
+ GtkWidget *widget;
+
+ shell_searchbar_update_search_widgets (searchbar);
+
+ if (!e_shell_view_is_active (shell_view))
+ return;
+
+ /* Direct the focus away from the search entry, so that a
+ * focus-in event is required before the text can be changed.
+ * This will reset the entry to the appropriate visual state. */
+ widget = searchbar->priv->search_entry;
+ gtk_widget_child_focus (widget, GTK_DIR_TAB_FORWARD);
+}
+
+static void
+shell_searchbar_entry_activate_cb (EShellSearchbar *searchbar)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ GtkAction *action;
+ const gchar *search_text;
+
+ shell_view = e_shell_searchbar_get_shell_view (searchbar);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ search_text = e_shell_searchbar_get_search_text (searchbar);
+ if (search_text != NULL && *search_text != '\0')
+ action = E_SHELL_WINDOW_ACTION_SEARCH_QUICK (shell_window);
+ else
+ action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window);
+
+ gtk_action_activate (action);
+}
+
+static void
+shell_searchbar_entry_changed_cb (EShellSearchbar *searchbar)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ GtkAction *action;
+ const gchar *search_text;
+ gboolean sensitive;
+
+ shell_view = e_shell_searchbar_get_shell_view (searchbar);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ search_text = e_shell_searchbar_get_search_text (searchbar);
+ sensitive = (search_text != NULL && *search_text != '\0');
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_QUICK (shell_window);
+ gtk_action_set_sensitive (action, sensitive);
+}
+
+static void
+shell_searchbar_entry_icon_press_cb (EShellSearchbar *searchbar,
+ GtkEntryIconPosition icon_pos,
+ GdkEvent *event)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ GtkAction *action;
+
+ /* Show the search options menu when the icon is pressed. */
+
+ if (icon_pos != GTK_ENTRY_ICON_PRIMARY)
+ return;
+
+ shell_view = e_shell_searchbar_get_shell_view (searchbar);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_OPTIONS (shell_window);
+ gtk_action_activate (action);
+}
+
+static void
+shell_searchbar_entry_icon_release_cb (EShellSearchbar *searchbar,
+ GtkEntryIconPosition icon_pos,
+ GdkEvent *event)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ GtkAction *action;
+
+ /* Clear the search when the icon is pressed and released. */
+
+ if (icon_pos != GTK_ENTRY_ICON_SECONDARY)
+ return;
+
+ shell_view = e_shell_searchbar_get_shell_view (searchbar);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window);
+ gtk_action_activate (action);
+}
+
+static gboolean
+shell_searchbar_entry_key_press_cb (EShellSearchbar *searchbar,
+ GdkEventKey *key_event,
+ GtkWindow *entry)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ GtkAction *action;
+ guint mask;
+
+ mask = gtk_accelerator_get_default_mod_mask ();
+ if ((key_event->state & mask) != GDK_MOD1_MASK)
+ return FALSE;
+
+ if (key_event->keyval != GDK_Down)
+ return FALSE;
+
+ shell_view = e_shell_searchbar_get_shell_view (searchbar);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_OPTIONS (shell_window);
+ gtk_action_activate (action);
+
+ return TRUE;
+}
+
+static void
+shell_searchbar_option_changed_cb (GtkRadioAction *action,
+ GtkRadioAction *current,
+ EShellSearchbar *searchbar)
+{
+ EShellView *shell_view;
+ const gchar *search_text;
+ const gchar *label;
+ gint current_value;
+
+ shell_view = e_shell_searchbar_get_shell_view (searchbar);
+
+ label = gtk_action_get_label (GTK_ACTION (current));
+ e_shell_searchbar_set_search_hint (searchbar, label);
+
+ current_value = gtk_radio_action_get_current_value (current);
+ search_text = e_shell_searchbar_get_search_text (searchbar);
+
+ if (current_value != SEARCH_OPTION_ADVANCED) {
+ e_shell_view_set_search_rule (shell_view, NULL);
+ e_shell_searchbar_set_search_text (searchbar, search_text);
+ if (search_text != NULL && *search_text != '\0')
+ e_shell_view_execute_search (shell_view);
+ } else if (search_text != NULL)
+ e_shell_searchbar_set_search_text (searchbar, NULL);
+}
+
+static void
+shell_searchbar_set_shell_view (EShellSearchbar *searchbar,
+ EShellView *shell_view)
+{
+ g_return_if_fail (searchbar->priv->shell_view == NULL);
+
+ searchbar->priv->shell_view = shell_view;
+
+ g_object_add_weak_pointer (
+ G_OBJECT (shell_view),
+ &searchbar->priv->shell_view);
+}
+
+static void
+shell_searchbar_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_FILTER_VISIBLE:
+ e_shell_searchbar_set_filter_visible (
+ E_SHELL_SEARCHBAR (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_SEARCH_HINT:
+ e_shell_searchbar_set_search_hint (
+ E_SHELL_SEARCHBAR (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_SEARCH_OPTION:
+ e_shell_searchbar_set_search_option (
+ E_SHELL_SEARCHBAR (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_SEARCH_TEXT:
+ e_shell_searchbar_set_search_text (
+ E_SHELL_SEARCHBAR (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_SEARCH_VISIBLE:
+ e_shell_searchbar_set_search_visible (
+ E_SHELL_SEARCHBAR (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_SCOPE_VISIBLE:
+ e_shell_searchbar_set_scope_visible (
+ E_SHELL_SEARCHBAR (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_SHELL_VIEW:
+ shell_searchbar_set_shell_view (
+ E_SHELL_SEARCHBAR (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+shell_searchbar_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_FILTER_COMBO_BOX:
+ g_value_set_object (
+ value, e_shell_searchbar_get_filter_combo_box (
+ E_SHELL_SEARCHBAR (object)));
+ return;
+
+ case PROP_FILTER_VISIBLE:
+ g_value_set_boolean (
+ value, e_shell_searchbar_get_filter_visible (
+ E_SHELL_SEARCHBAR (object)));
+ return;
+
+ case PROP_SEARCH_HINT:
+ g_value_set_string (
+ value, e_shell_searchbar_get_search_hint (
+ E_SHELL_SEARCHBAR (object)));
+ return;
+
+ case PROP_SEARCH_OPTION:
+ g_value_set_object (
+ value, e_shell_searchbar_get_search_option (
+ E_SHELL_SEARCHBAR (object)));
+ return;
+
+ case PROP_SEARCH_TEXT:
+ g_value_set_string (
+ value, e_shell_searchbar_get_search_text (
+ E_SHELL_SEARCHBAR (object)));
+ return;
+
+ case PROP_SEARCH_VISIBLE:
+ g_value_set_boolean (
+ value, e_shell_searchbar_get_search_visible (
+ E_SHELL_SEARCHBAR (object)));
+ return;
+
+ case PROP_SCOPE_COMBO_BOX:
+ g_value_set_object (
+ value, e_shell_searchbar_get_scope_combo_box (
+ E_SHELL_SEARCHBAR (object)));
+ return;
+
+ case PROP_SCOPE_VISIBLE:
+ g_value_set_boolean (
+ value, e_shell_searchbar_get_scope_visible (
+ E_SHELL_SEARCHBAR (object)));
+ return;
+
+ case PROP_SHELL_VIEW:
+ g_value_set_object (
+ value, e_shell_searchbar_get_shell_view (
+ E_SHELL_SEARCHBAR (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+shell_searchbar_dispose (GObject *object)
+{
+ EShellSearchbarPrivate *priv;
+
+ priv = E_SHELL_SEARCHBAR_GET_PRIVATE (object);
+
+ if (priv->shell_view != NULL) {
+ g_object_remove_weak_pointer (
+ G_OBJECT (priv->shell_view), &priv->shell_view);
+ priv->shell_view = NULL;
+ }
+
+ if (priv->search_option != NULL) {
+ g_signal_handlers_disconnect_matched (
+ priv->search_option, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, object);
+ g_object_unref (priv->search_option);
+ priv->search_option = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+shell_searchbar_constructed (GObject *object)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ EShellSearchbar *searchbar;
+ GtkSizeGroup *size_group;
+ GtkAction *action;
+ GtkWidget *widget;
+
+ searchbar = E_SHELL_SEARCHBAR (object);
+ shell_view = e_shell_searchbar_get_shell_view (searchbar);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ size_group = e_shell_view_get_size_group (shell_view);
+
+ g_signal_connect (
+ shell_view, "clear-search",
+ G_CALLBACK (shell_searchbar_clear_search_cb),
+ searchbar);
+
+ g_signal_connect (
+ shell_view, "custom-search",
+ G_CALLBACK (shell_searchbar_custom_search_cb),
+ searchbar);
+
+ g_signal_connect_after (
+ shell_view, "execute-search",
+ G_CALLBACK (shell_searchbar_execute_search_cb),
+ searchbar);
+
+ widget = searchbar->priv->search_entry;
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window);
+
+ e_binding_new (
+ action, "sensitive",
+ widget, "secondary-icon-sensitive");
+ e_binding_new (
+ action, "stock-id",
+ widget, "secondary-icon-stock");
+ e_binding_new (
+ action, "tooltip",
+ widget, "secondary-icon-tooltip-text");
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_OPTIONS (shell_window);
+
+ e_binding_new (
+ action, "sensitive",
+ widget, "primary-icon-sensitive");
+ e_binding_new (
+ action, "stock-id",
+ widget, "primary-icon-stock");
+ e_binding_new (
+ action, "tooltip",
+ widget, "primary-icon-tooltip-text");
+
+ widget = GTK_WIDGET (searchbar);
+ gtk_size_group_add_widget (size_group, widget);
+}
+
+static void
+shell_searchbar_class_init (EShellSearchbarClass *class)
+{
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EShellSearchbarPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = shell_searchbar_set_property;
+ object_class->get_property = shell_searchbar_get_property;
+ object_class->dispose = shell_searchbar_dispose;
+ object_class->constructed = shell_searchbar_constructed;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_FILTER_COMBO_BOX,
+ g_param_spec_object (
+ "filter-combo-box",
+ NULL,
+ NULL,
+ E_TYPE_ACTION_COMBO_BOX,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_FILTER_VISIBLE,
+ g_param_spec_boolean (
+ "filter-visible",
+ NULL,
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SEARCH_HINT,
+ g_param_spec_string (
+ "search-hint",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SEARCH_OPTION,
+ g_param_spec_object (
+ "search-option",
+ NULL,
+ NULL,
+ GTK_TYPE_RADIO_ACTION,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SEARCH_TEXT,
+ g_param_spec_string (
+ "search-text",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SEARCH_VISIBLE,
+ g_param_spec_boolean (
+ "search-visible",
+ NULL,
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SCOPE_COMBO_BOX,
+ g_param_spec_object (
+ "scope-combo-box",
+ NULL,
+ NULL,
+ E_TYPE_ACTION_COMBO_BOX,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SCOPE_VISIBLE,
+ g_param_spec_boolean (
+ "scope-visible",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ /**
+ * EShellContent:shell-view
+ *
+ * The #EShellView to which the searchbar widget belongs.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL_VIEW,
+ g_param_spec_object (
+ "shell-view",
+ NULL,
+ NULL,
+ E_TYPE_SHELL_VIEW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+shell_searchbar_init (EShellSearchbar *searchbar)
+{
+ GtkBox *box;
+ GtkLabel *label;
+ GtkWidget *widget;
+
+ searchbar->priv = E_SHELL_SEARCHBAR_GET_PRIVATE (searchbar);
+
+ gtk_box_set_spacing (GTK_BOX (searchbar), 24);
+
+ /* Filter Combo Widgets */
+
+ box = GTK_BOX (searchbar);
+
+ widget = gtk_hbox_new (FALSE, 3);
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
+
+ e_binding_new (
+ searchbar, "filter-visible",
+ widget, "visible");
+
+ box = GTK_BOX (widget);
+
+ /* Translators: The "Show:" label precedes a combo box that
+ * allows the user to filter the current view. Examples of
+ * items that appear in the combo box are "Unread Messages",
+ * "Important Messages", or "Active Appointments". */
+ widget = gtk_label_new_with_mnemonic (_("Sho_w:"));
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+
+ label = GTK_LABEL (widget);
+
+ widget = e_action_combo_box_new ();
+ gtk_label_set_mnemonic_widget (label, widget);
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
+ searchbar->priv->filter_combo_box = widget;
+ gtk_widget_show (widget);
+
+ /* Search Entry Widgets */
+
+ box = GTK_BOX (searchbar);
+
+ widget = gtk_hbox_new (FALSE, 3);
+ gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
+
+ e_binding_new (
+ searchbar, "search-visible",
+ widget, "visible");
+
+ box = GTK_BOX (widget);
+
+ /* Translators: This is part of the quick search interface.
+ * example: Search: [_______________] in [ Current Folder ] */
+ widget = gtk_label_new_with_mnemonic (_("Sear_ch:"));
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+
+ label = GTK_LABEL (widget);
+
+ widget = e_hinted_entry_new ();
+ gtk_label_set_mnemonic_widget (label, widget);
+ gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
+ searchbar->priv->search_entry = widget;
+ gtk_widget_show (widget);
+
+ g_signal_connect_swapped (
+ widget, "activate",
+ G_CALLBACK (shell_searchbar_entry_activate_cb),
+ searchbar);
+
+ g_signal_connect_swapped (
+ widget, "changed",
+ G_CALLBACK (shell_searchbar_entry_changed_cb),
+ searchbar);
+
+ g_signal_connect_swapped (
+ widget, "icon-press",
+ G_CALLBACK (shell_searchbar_entry_icon_press_cb),
+ searchbar);
+
+ g_signal_connect_swapped (
+ widget, "icon-release",
+ G_CALLBACK (shell_searchbar_entry_icon_release_cb),
+ searchbar);
+
+ g_signal_connect_swapped (
+ widget, "key-press-event",
+ G_CALLBACK (shell_searchbar_entry_key_press_cb),
+ searchbar);
+
+ /* Scope Combo Widgets */
+
+ box = GTK_BOX (searchbar);
+
+ widget = gtk_hbox_new (FALSE, 3);
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
+
+ e_binding_new (
+ searchbar, "scope-visible",
+ widget, "visible");
+
+ box = GTK_BOX (widget);
+
+ /* Translators: This is part of the quick search interface.
+ * example: Search: [_______________] in [ Current Folder ] */
+ widget = gtk_label_new_with_mnemonic (_("i_n"));
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+
+ label = GTK_LABEL (widget);
+
+ widget = e_action_combo_box_new ();
+ gtk_label_set_mnemonic_widget (label, widget);
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
+ searchbar->priv->scope_combo_box = widget;
+ gtk_widget_show (widget);
+}
+
+GType
+e_shell_searchbar_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (EShellSearchbarClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) shell_searchbar_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EShellSearchbar),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) shell_searchbar_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ GTK_TYPE_BOX, "EShellSearchbar", &type_info, 0);
+ }
+
+ return type;
+}
+
+/**
+ * e_shell_searchbar_new:
+ * @shell_view: an #EShellView
+ *
+ * Creates a new #EShellSearchbar instance.
+ *
+ * Returns: a new #EShellSearchbar instance
+ **/
+GtkWidget *
+e_shell_searchbar_new (EShellView *shell_view)
+{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ return g_object_new (
+ E_TYPE_SHELL_SEARCHBAR, "shell-view", shell_view, NULL);
+}
+
+/**
+ * e_shell_searchbar_get_shell_view:
+ * @searchbar: an #EShellSearchbar
+ *
+ * Returns the #EShellView that was passed to e_shell_searchbar_new().
+ *
+ * Returns: the #EShellView to which @searchbar belongs
+ **/
+EShellView *
+e_shell_searchbar_get_shell_view (EShellSearchbar *searchbar)
+{
+ g_return_val_if_fail (E_IS_SHELL_SEARCHBAR (searchbar), NULL);
+
+ return E_SHELL_VIEW (searchbar->priv->shell_view);
+}
+
+EActionComboBox *
+e_shell_searchbar_get_filter_combo_box (EShellSearchbar *searchbar)
+{
+ g_return_val_if_fail (E_IS_SHELL_SEARCHBAR (searchbar), NULL);
+
+ return E_ACTION_COMBO_BOX (searchbar->priv->filter_combo_box);
+}
+
+gboolean
+e_shell_searchbar_get_filter_visible (EShellSearchbar *searchbar)
+{
+ g_return_val_if_fail (E_IS_SHELL_SEARCHBAR (searchbar), FALSE);
+
+ return searchbar->priv->filter_visible;
+}
+
+void
+e_shell_searchbar_set_filter_visible (EShellSearchbar *searchbar,
+ gboolean filter_visible)
+{
+ g_return_if_fail (E_IS_SHELL_SEARCHBAR (searchbar));
+
+ searchbar->priv->filter_visible = filter_visible;
+
+ g_object_notify (G_OBJECT (searchbar), "filter-visible");
+}
+
+const gchar *
+e_shell_searchbar_get_search_hint (EShellSearchbar *searchbar)
+{
+ EHintedEntry *entry;
+
+ g_return_val_if_fail (E_IS_SHELL_SEARCHBAR (searchbar), NULL);
+
+ entry = E_HINTED_ENTRY (searchbar->priv->search_entry);
+
+ return e_hinted_entry_get_hint (entry);
+}
+
+void
+e_shell_searchbar_set_search_hint (EShellSearchbar *searchbar,
+ const gchar *search_hint)
+{
+ EHintedEntry *entry;
+
+ g_return_if_fail (E_IS_SHELL_SEARCHBAR (searchbar));
+
+ entry = E_HINTED_ENTRY (searchbar->priv->search_entry);
+
+ e_hinted_entry_set_hint (entry, search_hint);
+
+ g_object_notify (G_OBJECT (searchbar), "search-hint");
+}
+
+GtkRadioAction *
+e_shell_searchbar_get_search_option (EShellSearchbar *searchbar)
+{
+ g_return_val_if_fail (E_IS_SHELL_SEARCHBAR (searchbar), NULL);
+
+ return searchbar->priv->search_option;
+}
+
+void
+e_shell_searchbar_set_search_option (EShellSearchbar *searchbar,
+ GtkRadioAction *search_option)
+{
+ g_return_if_fail (E_IS_SHELL_SEARCHBAR (searchbar));
+
+ if (search_option != NULL) {
+ g_return_if_fail (GTK_IS_RADIO_ACTION (search_option));
+ g_object_ref (search_option);
+ }
+
+ if (searchbar->priv->search_option != NULL) {
+ g_signal_handlers_disconnect_matched (
+ searchbar->priv->search_option,
+ G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL,
+ searchbar);
+ g_object_unref (searchbar->priv->search_option);
+ }
+
+ searchbar->priv->search_option = search_option;
+
+ if (search_option != NULL)
+ g_signal_connect (
+ search_option, "changed",
+ G_CALLBACK (shell_searchbar_option_changed_cb),
+ searchbar);
+
+ g_object_notify (G_OBJECT (searchbar), "search-option");
+}
+
+const gchar *
+e_shell_searchbar_get_search_text (EShellSearchbar *searchbar)
+{
+ EHintedEntry *entry;
+
+ g_return_val_if_fail (E_IS_SHELL_SEARCHBAR (searchbar), NULL);
+
+ entry = E_HINTED_ENTRY (searchbar->priv->search_entry);
+
+ return e_hinted_entry_get_text (entry);
+}
+
+void
+e_shell_searchbar_set_search_text (EShellSearchbar *searchbar,
+ const gchar *search_text)
+{
+ EHintedEntry *entry;
+
+ g_return_if_fail (E_IS_SHELL_SEARCHBAR (searchbar));
+
+ entry = E_HINTED_ENTRY (searchbar->priv->search_entry);
+
+ e_hinted_entry_set_text (entry, search_text);
+
+ shell_searchbar_update_search_widgets (searchbar);
+
+ g_object_notify (G_OBJECT (searchbar), "search-text");
+}
+
+gboolean
+e_shell_searchbar_get_search_visible (EShellSearchbar *searchbar)
+{
+ g_return_val_if_fail (E_IS_SHELL_SEARCHBAR (searchbar), FALSE);
+
+ return searchbar->priv->search_visible;
+}
+
+void
+e_shell_searchbar_set_search_visible (EShellSearchbar *searchbar,
+ gboolean search_visible)
+{
+ g_return_if_fail (E_IS_SHELL_SEARCHBAR (searchbar));
+
+ searchbar->priv->search_visible = search_visible;
+
+ g_object_notify (G_OBJECT (searchbar), "search-visible");
+}
+
+EActionComboBox *
+e_shell_searchbar_get_scope_combo_box (EShellSearchbar *searchbar)
+{
+ g_return_val_if_fail (E_IS_SHELL_SEARCHBAR (searchbar), NULL);
+
+ return E_ACTION_COMBO_BOX (searchbar->priv->scope_combo_box);
+}
+
+gboolean
+e_shell_searchbar_get_scope_visible (EShellSearchbar *searchbar)
+{
+ g_return_val_if_fail (E_IS_SHELL_SEARCHBAR (searchbar), FALSE);
+
+ return searchbar->priv->scope_visible;
+}
+
+void
+e_shell_searchbar_set_scope_visible (EShellSearchbar *searchbar,
+ gboolean scope_visible)
+{
+ g_return_if_fail (E_IS_SHELL_SEARCHBAR (searchbar));
+
+ searchbar->priv->scope_visible = scope_visible;
+
+ g_object_notify (G_OBJECT (searchbar), "scope-visible");
+}
+
+void
+e_shell_searchbar_restore_state (EShellSearchbar *searchbar,
+ const gchar *group_name)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ GKeyFile *key_file;
+ GtkAction *action;
+ GtkWidget *widget;
+ const gchar *search_text;
+ const gchar *key;
+ gchar *string;
+
+ g_return_if_fail (E_IS_SHELL_SEARCHBAR (searchbar));
+ g_return_if_fail (group_name != NULL);
+
+ shell_view = e_shell_searchbar_get_shell_view (searchbar);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ key_file = e_shell_view_get_state_key_file (shell_view);
+
+ /* Changing the combo boxes triggers searches, so block
+ * the search action until the state is fully restored. */
+ action = E_SHELL_WINDOW_ACTION_SEARCH_QUICK (shell_window);
+ gtk_action_block_activate (action);
+
+ e_shell_view_block_execute_search (shell_view);
+
+ key = STATE_KEY_SEARCH_FILTER;
+ string = g_key_file_get_string (key_file, group_name, key, NULL);
+ if (string != NULL && *string != '\0')
+ action = e_shell_window_get_action (shell_window, string);
+ else
+ action = NULL;
+ if (action != NULL)
+ gtk_action_activate (action);
+ else {
+ /* Pick the first combo box item. */
+ widget = searchbar->priv->filter_combo_box;
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+ }
+ g_free (string);
+
+ key = STATE_KEY_SEARCH_SCOPE;
+ string = g_key_file_get_string (key_file, group_name, key, NULL);
+ if (string != NULL && *string != '\0')
+ action = e_shell_window_get_action (shell_window, string);
+ else
+ action = NULL;
+ if (action != NULL)
+ gtk_action_activate (action);
+ else {
+ /* Pick the first combo box item. */
+ widget = searchbar->priv->scope_combo_box;
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+ }
+ g_free (string);
+
+ key = STATE_KEY_SEARCH_TEXT;
+ string = g_key_file_get_string (key_file, group_name, key, NULL);
+ search_text = e_shell_searchbar_get_search_text (searchbar);
+ if (search_text != NULL && *search_text == '\0')
+ search_text = NULL;
+ if (g_strcmp0 (string, search_text) != 0)
+ e_shell_searchbar_set_search_text (searchbar, string);
+ g_free (string);
+
+ e_shell_view_unblock_execute_search (shell_view);
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_QUICK (shell_window);
+ gtk_action_unblock_activate (action);
+
+ /* Now execute the search. */
+ e_shell_view_execute_search (shell_view);
+}
diff --git a/shell/e-shell-searchbar.h b/shell/e-shell-searchbar.h
new file mode 100644
index 0000000000..b6104491b4
--- /dev/null
+++ b/shell/e-shell-searchbar.h
@@ -0,0 +1,119 @@
+/*
+ * e-shell-searchbar.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+/**
+ * SECTION: e-shell-searchbar
+ * @short_description: quick search interface
+ * @include: shell/e-shell-searchbar.h
+ **/
+
+#ifndef E_SHELL_SEARCHBAR_H
+#define E_SHELL_SEARCHBAR_H
+
+#include <shell/e-shell-common.h>
+#include <shell/e-shell-view.h>
+#include <misc/e-action-combo-box.h>
+
+/* Standard GObject macros */
+#define E_TYPE_SHELL_SEARCHBAR \
+ (e_shell_searchbar_get_type ())
+#define E_SHELL_SEARCHBAR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_SHELL_SEARCHBAR, EShellSearchbar))
+#define E_SHELL_SEARCHBAR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_SHELL_SEARCHBAR, EShellSearchbarClass))
+#define E_IS_SHELL_SEARCHBAR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_SHELL_SEARCHBAR))
+#define E_IS_SHELL_SEARCHBAR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_SHELL_SEARCHBAR))
+#define E_SHELL_SEARCHBAR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_SHELL_SEARCHBAR, EShellSearchbarClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EShellSearchbar EShellSearchbar;
+typedef struct _EShellSearchbarClass EShellSearchbarClass;
+typedef struct _EShellSearchbarPrivate EShellSearchbarPrivate;
+
+/**
+ * EShellSearchbar:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ **/
+struct _EShellSearchbar {
+ GtkBox parent;
+ EShellSearchbarPrivate *priv;
+};
+
+struct _EShellSearchbarClass {
+ GtkBoxClass parent_class;
+};
+
+GType e_shell_searchbar_get_type (void);
+GtkWidget * e_shell_searchbar_new (EShellView *shell_view);
+EShellView * e_shell_searchbar_get_shell_view(EShellSearchbar *searchbar);
+EActionComboBox *
+ e_shell_searchbar_get_filter_combo_box
+ (EShellSearchbar *searchbar);
+gboolean e_shell_searchbar_get_filter_visible
+ (EShellSearchbar *searchbar);
+void e_shell_searchbar_set_filter_visible
+ (EShellSearchbar *searchbar,
+ gboolean filter_visible);
+const gchar * e_shell_searchbar_get_search_hint
+ (EShellSearchbar *searchbar);
+void e_shell_searchbar_set_search_hint
+ (EShellSearchbar *searchbar,
+ const gchar *search_hint);
+GtkRadioAction *e_shell_searchbar_get_search_option
+ (EShellSearchbar *searchbar);
+void e_shell_searchbar_set_search_option
+ (EShellSearchbar *searchbar,
+ GtkRadioAction *search_option);
+const gchar * e_shell_searchbar_get_search_text
+ (EShellSearchbar *searchbar);
+void e_shell_searchbar_set_search_text
+ (EShellSearchbar *searchbar,
+ const gchar *search_text);
+gboolean e_shell_searchbar_get_search_visible
+ (EShellSearchbar *searchbar);
+void e_shell_searchbar_set_search_visible
+ (EShellSearchbar *searchbar,
+ gboolean search_visible);
+EActionComboBox *
+ e_shell_searchbar_get_scope_combo_box
+ (EShellSearchbar *searchbar);
+gboolean e_shell_searchbar_get_scope_visible
+ (EShellSearchbar *searchbar);
+void e_shell_searchbar_set_scope_visible
+ (EShellSearchbar *searchbar,
+ gboolean scope_visible);
+void e_shell_searchbar_restore_state (EShellSearchbar *searchbar,
+ const gchar *group_name);
+
+G_END_DECLS
+
+#endif /* E_SHELL_SEARCHBAR_H */
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index 2439706224..d87f8b7632 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -26,6 +26,7 @@
#include "e-util/e-util.h"
#include "e-util/e-plugin-ui.h"
+#include "filter/e-rule-context.h"
#include "e-shell-window-actions.h"
@@ -53,6 +54,7 @@ struct _EShellViewPrivate {
GtkWidget *shell_sidebar;
GtkWidget *shell_taskbar;
+ EFilterRule *search_rule;
guint execute_search_blocked;
};
@@ -60,18 +62,21 @@ enum {
PROP_0,
PROP_ACTION,
PROP_PAGE_NUM,
- PROP_TITLE,
+ PROP_SEARCH_RULE,
PROP_SHELL_BACKEND,
PROP_SHELL_CONTENT,
PROP_SHELL_SIDEBAR,
PROP_SHELL_TASKBAR,
PROP_SHELL_WINDOW,
PROP_STATE_KEY_FILE,
+ PROP_TITLE,
PROP_VIEW_ID
};
enum {
TOGGLED,
+ CLEAR_SEARCH,
+ CUSTOM_SEARCH,
EXECUTE_SEARCH,
UPDATE_ACTIONS,
LAST_SIGNAL
@@ -81,6 +86,61 @@ static gpointer parent_class;
static gulong signals[LAST_SIGNAL];
static void
+shell_view_init_search_context (EShellViewClass *class)
+{
+ EShellBackend *shell_backend;
+ ERuleContext *search_context;
+ EFilterRule *rule;
+ EFilterPart *part;
+ const gchar *data_dir;
+ gchar *system_filename;
+ gchar *user_filename;
+
+ shell_backend = class->shell_backend;
+
+ /* Sanity check the class fields we need. */
+ g_return_if_fail (class->search_rules != NULL);
+ g_return_if_fail (E_IS_SHELL_BACKEND (shell_backend));
+
+ /* The basename for built-in searches is specified in the
+ * shell view class. All built-in search rules live in the
+ * same directory. */
+ system_filename = g_build_filename (
+ EVOLUTION_RULEDIR, class->search_rules, NULL);
+
+ /* The filename for custom saved searches is always of
+ * the form "$(shell_backend_data_dir)/searches.xml". */
+ data_dir = e_shell_backend_get_data_dir (shell_backend);
+ user_filename = g_build_filename (data_dir, "searches.xml", NULL);
+
+ /* Create the search context instance. Subclasses may override
+ * the GType so check that it's really an ERuleContext instance. */
+ search_context = g_object_new (class->search_context_type, NULL);
+ g_return_if_fail (E_IS_RULE_CONTEXT (search_context));
+ class->search_context = search_context;
+
+ e_rule_context_add_part_set (
+ search_context, "partset", E_TYPE_FILTER_PART,
+ e_rule_context_add_part, e_rule_context_next_part);
+ e_rule_context_add_rule_set (
+ search_context, "ruleset", E_TYPE_FILTER_RULE,
+ e_rule_context_add_rule, e_rule_context_next_rule);
+ e_rule_context_load (search_context, system_filename, user_filename);
+
+ rule = e_filter_rule_new ();
+ part = e_rule_context_next_part (search_context, NULL);
+ if (part == NULL)
+ g_warning (
+ "Could not load %s search: no parts",
+ G_OBJECT_CLASS_NAME (class));
+ else
+ e_filter_rule_add_part (rule, e_filter_part_clone (part));
+
+ g_free (system_filename);
+ g_free (user_filename);
+}
+
+static void
shell_view_init_view_collection (EShellViewClass *class)
{
EShellBackend *shell_backend;
@@ -249,10 +309,10 @@ shell_view_set_property (GObject *object,
g_value_get_int (value));
return;
- case PROP_TITLE:
- e_shell_view_set_title (
+ case PROP_SEARCH_RULE:
+ e_shell_view_set_search_rule (
E_SHELL_VIEW (object),
- g_value_get_string (value));
+ g_value_get_object (value));
return;
case PROP_SHELL_WINDOW:
@@ -261,6 +321,12 @@ shell_view_set_property (GObject *object,
g_value_get_object (value));
return;
+ case PROP_TITLE:
+ e_shell_view_set_title (
+ E_SHELL_VIEW (object),
+ g_value_get_string (value));
+ return;
+
case PROP_VIEW_ID:
e_shell_view_set_view_id (
E_SHELL_VIEW (object),
@@ -290,9 +356,9 @@ shell_view_get_property (GObject *object,
E_SHELL_VIEW (object)));
return;
- case PROP_TITLE:
- g_value_set_string (
- value, e_shell_view_get_title (
+ case PROP_SEARCH_RULE:
+ g_value_set_object (
+ value, e_shell_view_get_search_rule (
E_SHELL_VIEW (object)));
return;
@@ -331,6 +397,12 @@ shell_view_get_property (GObject *object,
E_SHELL_VIEW (object)));
return;
+ case PROP_TITLE:
+ g_value_set_string (
+ value, e_shell_view_get_title (
+ E_SHELL_VIEW (object)));
+ return;
+
case PROP_VIEW_ID:
g_value_set_string (
value, e_shell_view_get_view_id (
@@ -376,6 +448,11 @@ shell_view_dispose (GObject *object)
priv->shell_taskbar = NULL;
}
+ if (priv->search_rule != NULL) {
+ g_object_unref (priv->search_rule);
+ priv->search_rule = NULL;
+ }
+
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -430,6 +507,21 @@ shell_view_constructed (GObject *object)
}
static void
+shell_view_clear_search (EShellView *shell_view)
+{
+ e_shell_view_set_search_rule (shell_view, NULL);
+ e_shell_view_execute_search (shell_view);
+}
+
+static void
+shell_view_custom_search (EShellView *shell_view,
+ EFilterRule *custom_rule)
+{
+ e_shell_view_set_search_rule (shell_view, custom_rule);
+ e_shell_view_execute_search (shell_view);
+}
+
+static void
shell_view_toggled (EShellView *shell_view)
{
EShellViewPrivate *priv = shell_view->priv;
@@ -475,11 +567,15 @@ shell_view_class_init (EShellViewClass *class)
object_class->finalize = shell_view_finalize;
object_class->constructed = shell_view_constructed;
+ class->search_context_type = E_TYPE_RULE_CONTEXT;
+
/* Default Factories */
class->new_shell_content = e_shell_content_new;
class->new_shell_sidebar = e_shell_sidebar_new;
class->new_shell_taskbar = e_shell_taskbar_new;
+ class->clear_search = shell_view_clear_search;
+ class->custom_search = shell_view_custom_search;
class->toggled = shell_view_toggled;
/**
@@ -516,23 +612,22 @@ shell_view_class_init (EShellViewClass *class)
G_PARAM_READWRITE));
/**
- * EShellView:title
+ * EShellView:search-rule
*
- * The title of the shell view. Also serves as the #EShellWindow
- * title when the shell view is active.
+ * Criteria for the current search results.
**/
g_object_class_install_property (
object_class,
- PROP_TITLE,
- g_param_spec_string (
- "title",
- _("Title"),
- _("The title of the shell view"),
- NULL,
+ PROP_SEARCH_RULE,
+ g_param_spec_object (
+ "search-rule",
+ _("Search Rule"),
+ _("Criteria for the current search results"),
+ E_TYPE_FILTER_RULE,
G_PARAM_READWRITE));
/**
- * EShellView::shell-backend
+ * EShellView:shell-backend
*
* The #EShellBackend for this shell view.
**/
@@ -627,6 +722,22 @@ shell_view_class_init (EShellViewClass *class)
G_PARAM_READABLE));
/**
+ * EShellView:title
+ *
+ * The title of the shell view. Also serves as the #EShellWindow
+ * title when the shell view is active.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_TITLE,
+ g_param_spec_string (
+ "title",
+ _("Title"),
+ _("The title of the shell view"),
+ NULL,
+ G_PARAM_READWRITE));
+
+ /**
* EShellView:view-id
*
* The current #GalView ID.
@@ -665,6 +776,40 @@ shell_view_class_init (EShellViewClass *class)
G_TYPE_NONE, 0);
/**
+ * EShellView::clear-search
+ * @shell_view: the #EShellView which emitted the signal
+ *
+ * Clears the current search. See e_shell_view_clear_search() for
+ * details.
+ **/
+ signals[CLEAR_SEARCH] = g_signal_new (
+ "clear-search",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EShellViewClass, clear_search),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /**
+ * EShellView::custom-search
+ * @shell_view: the #EShellView which emitted the signal
+ * @custom_rule: criteria for the custom search
+ *
+ * Emitted when an advanced or saved search is about to be executed.
+ * See e_shell_view_custom_search() for details.
+ **/
+ signals[CUSTOM_SEARCH] = g_signal_new (
+ "custom-search",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EShellViewClass, custom_search),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ E_TYPE_FILTER_RULE);
+
+ /**
* EShellView::execute-search
* @shell_view: the #EShellView which emitted the signal
*
@@ -709,6 +854,9 @@ shell_view_init (EShellView *shell_view,
{
GtkSizeGroup *size_group;
+ if (class->search_context == NULL)
+ shell_view_init_search_context (class);
+
if (class->view_collection == NULL)
shell_view_init_view_collection (class);
@@ -963,6 +1111,78 @@ e_shell_view_set_page_num (EShellView *shell_view,
}
/**
+ * e_shell_view_get_search_rule:
+ * @shell_view: an #EShellView
+ *
+ * Returns the search criteria used to generate the current search results.
+ *
+ * Returns: the current search criteria
+ **/
+EFilterRule *
+e_shell_view_get_search_rule (EShellView *shell_view)
+{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ return shell_view->priv->search_rule;
+}
+
+/**
+ * e_shell_view_set_search_rule:
+ * @shell_view: an #EShellView
+ * @search_rule: an #EFilterRule
+ *
+ * Sets the search criteria used to generate the current search results.
+ * Note that this will not trigger a search. e_shell_view_execute_search()
+ * must be called explicitly.
+ **/
+void
+e_shell_view_set_search_rule (EShellView *shell_view,
+ EFilterRule *search_rule)
+{
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+
+ if (search_rule != NULL) {
+ g_return_if_fail (E_IS_FILTER_RULE (search_rule));
+ g_object_ref (search_rule);
+ }
+
+ if (shell_view->priv->search_rule != NULL)
+ g_object_unref (shell_view->priv->search_rule);
+
+ shell_view->priv->search_rule = search_rule;
+
+ g_object_notify (G_OBJECT (shell_view), "search-rule");
+}
+
+/**
+ * e_shell_view_get_search_query:
+ * @shell_view: an #EShellView
+ *
+ * Converts the #EShellView:search-rule property to a newly-allocated
+ * S-expression string. If the #EShellView:search-rule property is %NULL
+ * the function returns %NULL.
+ *
+ * Returns: an S-expression string, or %NULL
+ **/
+gchar *
+e_shell_view_get_search_query (EShellView *shell_view)
+{
+ EFilterRule *rule;
+ GString *string;
+
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ rule = e_shell_view_get_search_rule (shell_view);
+ if (rule == NULL)
+ return NULL;
+
+ string = g_string_sized_new (1024);
+ e_filter_rule_build_code (rule, string);
+
+ return g_string_free (string, FALSE);
+}
+
+/**
* e_shell_view_get_size_group:
* @shell_view: an #EShellView
*
@@ -1109,6 +1329,44 @@ e_shell_view_set_state_dirty (EShellView *shell_view)
}
/**
+ * e_shell_view_clear_search:
+ * @shell_view: an #EShellView
+ *
+ * Emits the #EShellView::clear-search signal.
+ *
+ * The default method sets the #EShellView:search-rule property to
+ * %NULL and then emits the #EShellView::execute-search signal.
+ **/
+void
+e_shell_view_clear_search (EShellView *shell_view)
+{
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+
+ g_signal_emit (shell_view, signals[CLEAR_SEARCH], 0);
+}
+
+/**
+ * e_shell_view_custom_search:
+ * @shell_view: an #EShellView
+ * @custom_rule: an #EFilterRule
+ *
+ * Emits the #EShellView::custom-search signal to indicate an advanced
+ * or saved search is about to be executed.
+ *
+ * The default method sets the #EShellView:search-rule property to
+ * @custom_rule and then emits the #EShellView::execute-search signal.
+ **/
+void
+e_shell_view_custom_search (EShellView *shell_view,
+ EFilterRule *custom_rule)
+{
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+ g_return_if_fail (E_IS_FILTER_RULE (custom_rule));
+
+ g_signal_emit (shell_view, signals[CUSTOM_SEARCH], 0, custom_rule);
+}
+
+/**
* e_shell_view_execute_search:
* @shell_view: an #EShellView
*
diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h
index 8cbfabd0ba..60f3fcbdd2 100644
--- a/shell/e-shell-view.h
+++ b/shell/e-shell-view.h
@@ -35,6 +35,8 @@
#include <shell/e-shell-taskbar.h>
#include <shell/e-shell-window.h>
+#include <filter/e-filter-rule.h>
+#include <filter/e-rule-context.h>
#include <menus/gal-view-collection.h>
#include <menus/gal-view-instance.h>
@@ -88,6 +90,11 @@ struct _EShellView {
* @ui_manager_id: The #GtkUIManager ID for #EPluginUI. Plugins
* should use to this ID in their "eplug" files to
* add menu and toolbar items to the shell view.
+ * @search_context_type:GType of the search context, which should be an
+ * instance of ERuleContextClass or a custom subclass.
+ * @search_context: A unique @search_context_type instance is created
+ * automatically for each subclass and shared across
+ * all instances of that subclass.
* @search_options: Widget path in the UI definition to the search
* options popup menu. The menu gets shown when the
* user clicks the "find" icon in the search entry.
@@ -111,6 +118,11 @@ struct _EShellView {
* @toggled: Class method for the #EShellView::toggled signal.
* Subclasses should rarely need to override the
* default behavior.
+ * @custom_search: Class method for the #EShellView::custom-search
+ * signal. This is emitted prior to executing an
+ * advanced or saved search. The default method sets
+ * the #EShellView:search-rule property and then emits
+ * the #EShellView::execute-search signal.
* @execute_search: Class method for the #EShellView::execute-search
* signal. There is no default behavior; subclasses
* should override this.
@@ -134,6 +146,11 @@ struct _EShellViewClass {
* Usually "org.gnome.evolution.$(VIEW_NAME)". */
const gchar *ui_manager_id;
+ /* Search context. Subclasses may override the type.
+ * A unique instance is created for each subclass. */
+ GType search_context_type;
+ ERuleContext *search_context;
+
/* Widget path to the search options popup menu. */
const gchar *search_options;
@@ -153,6 +170,9 @@ struct _EShellViewClass {
/* Signals */
void (*toggled) (EShellView *shell_view);
+ void (*clear_search) (EShellView *shell_view);
+ void (*custom_search) (EShellView *shell_view,
+ EFilterRule *custom_rule);
void (*execute_search) (EShellView *shell_view);
void (*update_actions) (EShellView *shell_view);
};
@@ -170,6 +190,10 @@ gboolean e_shell_view_is_active (EShellView *shell_view);
gint e_shell_view_get_page_num (EShellView *shell_view);
void e_shell_view_set_page_num (EShellView *shell_view,
gint page_num);
+EFilterRule * e_shell_view_get_search_rule (EShellView *shell_view);
+void e_shell_view_set_search_rule (EShellView *shell_view,
+ EFilterRule *search_rule);
+gchar * e_shell_view_get_search_query (EShellView *shell_view);
GtkSizeGroup * e_shell_view_get_size_group (EShellView *shell_view);
EShellBackend * e_shell_view_get_shell_backend (EShellView *shell_view);
EShellContent * e_shell_view_get_shell_content (EShellView *shell_view);
@@ -178,9 +202,14 @@ EShellTaskbar * e_shell_view_get_shell_taskbar (EShellView *shell_view);
EShellWindow * e_shell_view_get_shell_window (EShellView *shell_view);
GKeyFile * e_shell_view_get_state_key_file (EShellView *shell_view);
void e_shell_view_set_state_dirty (EShellView *shell_view);
+void e_shell_view_clear_search (EShellView *shell_view);
+void e_shell_view_custom_search (EShellView *shell_view,
+ EFilterRule *custom_rule);
void e_shell_view_execute_search (EShellView *shell_view);
-void e_shell_view_block_execute_search (EShellView *shell_view);
-void e_shell_view_unblock_execute_search (EShellView *shell_view);
+void e_shell_view_block_execute_search
+ (EShellView *shell_view);
+void e_shell_view_unblock_execute_search
+ (EShellView *shell_view);
void e_shell_view_update_actions (EShellView *shell_view);
GtkWidget * e_shell_view_show_popup_menu (EShellView *shell_view,
const gchar *widget_path,
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
index 03fa5379eb..4483347beb 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -705,7 +705,6 @@ action_custom_rule_cb (GtkAction *action,
{
EFilterRule *rule;
EShellView *shell_view;
- EShellContent *shell_content;
const gchar *view_name;
rule = g_object_get_data (G_OBJECT (action), "rule");
@@ -713,14 +712,11 @@ action_custom_rule_cb (GtkAction *action,
view_name = e_shell_window_get_active_view (shell_window);
shell_view = e_shell_window_get_shell_view (shell_window, view_name);
- shell_content = e_shell_view_get_shell_content (shell_view);
rule = g_object_get_data (G_OBJECT (action), "rule");
g_return_if_fail (E_IS_FILTER_RULE (rule));
- e_shell_content_set_search_rule (shell_content, rule);
-
- e_shell_view_execute_search (shell_view);
+ e_shell_view_custom_search (shell_view, rule);
}
/**
@@ -1044,25 +1040,12 @@ action_search_clear_cb (GtkAction *action,
EShellWindow *shell_window)
{
EShellView *shell_view;
- EShellContent *shell_content;
- GtkRadioAction *search_action;
const gchar *view_name;
view_name = e_shell_window_get_active_view (shell_window);
shell_view = e_shell_window_get_shell_view (shell_window, view_name);
- shell_content = e_shell_view_get_shell_content (shell_view);
-
- e_shell_content_set_search_rule (shell_content, NULL);
- e_shell_content_set_search_text (shell_content, NULL);
-
- /* change from Advanced Search to the first one, so filling a text will do something */
- search_action = e_shell_content_get_search_radio_action (shell_content);
- if (search_action && gtk_radio_action_get_current_value (search_action) == -1)
- gtk_radio_action_set_current_value (search_action, 0);
-
- e_shell_view_execute_search (shell_view);
- e_shell_window_update_search_menu (shell_window);
+ e_shell_view_clear_search (shell_view);
}
/**
@@ -1125,20 +1108,11 @@ static void
action_search_quick_cb (GtkAction *action,
EShellWindow *shell_window)
{
- EShellContent *shell_content;
EShellView *shell_view;
- GtkRadioAction *radio_action;
const gchar *view_name;
view_name = e_shell_window_get_active_view (shell_window);
shell_view = e_shell_window_get_shell_view (shell_window, view_name);
- shell_content = e_shell_view_get_shell_content (shell_view);
-
- radio_action = e_shell_content_get_search_radio_action (shell_content);
- if (radio_action && gtk_radio_action_get_current_value (radio_action) == -1) {
- /* change Advanced Search to a default search type automatically */
- gtk_radio_action_set_current_value (radio_action, 0);
- }
e_shell_view_execute_search (shell_view);
}
@@ -2213,7 +2187,6 @@ e_shell_window_update_view_menu (EShellWindow *shell_window)
void
e_shell_window_update_search_menu (EShellWindow *shell_window)
{
- EShellContent *shell_content;
EShellView *shell_view;
EShellViewClass *shell_view_class;
ERuleContext *context;
@@ -2237,15 +2210,14 @@ e_shell_window_update_search_menu (EShellWindow *shell_window)
* Without this we would crash at E_SHELL_VIEW_GET_CLASS(). */
g_return_if_fail (shell_view != NULL);
- shell_content = e_shell_view_get_shell_content (shell_view);
- context = e_shell_content_get_search_context (shell_content);
shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view);
+ context = shell_view_class->search_context;
source = E_FILTER_SOURCE_INCOMING;
/* Update sensitivity of search actions. */
- sensitive = (e_shell_content_get_search_rule (shell_content) != NULL);
+ sensitive = (e_shell_view_get_search_rule (shell_view) != NULL);
gtk_action_set_sensitive (ACTION (SEARCH_CLEAR), sensitive);
gtk_action_set_sensitive (ACTION (SEARCH_SAVE), sensitive);