aboutsummaryrefslogtreecommitdiffstats
path: root/modules/calendar
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-09-03 03:21:35 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-09-03 03:26:49 +0800
commit53268d5516083c47607dbd3acbbd6bafd6d15747 (patch)
treec2a35758d36f00a2ce51633674c811eb1c5070ba /modules/calendar
parent5cbcdddfe769c0df81122b8d4944507f4739a618 (diff)
downloadgsoc2013-evolution-53268d5516083c47607dbd3acbbd6bafd6d15747.tar.gz
gsoc2013-evolution-53268d5516083c47607dbd3acbbd6bafd6d15747.tar.zst
gsoc2013-evolution-53268d5516083c47607dbd3acbbd6bafd6d15747.zip
Introduce an EShellView::execute-search signal.
This addresses bug #593896 but is also a cleaner design than before. It introduces an EShellView::execute-search signal and renames the "search-execute" action to "search-quick" to clarify that it's only meant for the "quick" search bar in the main window. Shell view subclasses should implement the execute_search() method to actually execute a search. e_shell_view_execute_search() emits the new signal.
Diffstat (limited to 'modules/calendar')
-rw-r--r--modules/calendar/e-cal-shell-view-actions.c30
-rw-r--r--modules/calendar/e-cal-shell-view-private.c155
-rw-r--r--modules/calendar/e-cal-shell-view.c157
-rw-r--r--modules/calendar/e-memo-shell-view-actions.c30
-rw-r--r--modules/calendar/e-memo-shell-view-private.c107
-rw-r--r--modules/calendar/e-memo-shell-view-private.h2
-rw-r--r--modules/calendar/e-memo-shell-view.c104
-rw-r--r--modules/calendar/e-task-shell-view-actions.c30
-rw-r--r--modules/calendar/e-task-shell-view-private.c182
-rw-r--r--modules/calendar/e-task-shell-view-private.h2
-rw-r--r--modules/calendar/e-task-shell-view.c177
11 files changed, 445 insertions, 531 deletions
diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c
index b36c94b8d1..3dfb4888e7 100644
--- a/modules/calendar/e-cal-shell-view-actions.c
+++ b/modules/calendar/e-cal-shell-view-actions.c
@@ -1154,33 +1154,11 @@ action_gal_save_custom_view_cb (GtkAction *action,
}
static void
-action_search_execute_cb (GtkAction *action,
- ECalShellView *cal_shell_view)
-{
- EShellView *shell_view;
-
- /* All shell views respond to the activation of this action,
- * which is defined by EShellWindow. But only the currently
- * active shell view proceeds with executing the search. */
- shell_view = E_SHELL_VIEW (cal_shell_view);
- if (!e_shell_view_is_active (shell_view))
- return;
-
- e_cal_shell_view_execute_search (cal_shell_view);
-}
-
-static void
action_search_filter_cb (GtkRadioAction *action,
GtkRadioAction *current,
- ECalShellView *cal_shell_view)
+ EShellView *shell_view)
{
- EShellView *shell_view;
- EShellWindow *shell_window;
-
- shell_view = E_SHELL_VIEW (cal_shell_view);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- gtk_action_activate (ACTION (SEARCH_EXECUTE));
+ e_shell_view_execute_search (shell_view);
}
static GtkActionEntry calendar_entries[] = {
@@ -1696,10 +1674,6 @@ e_cal_shell_view_actions_init (ECalShellView *cal_shell_view)
ACTION (GAL_SAVE_CUSTOM_VIEW), "activate",
G_CALLBACK (action_gal_save_custom_view_cb), cal_shell_view);
- g_signal_connect (
- ACTION (SEARCH_EXECUTE), "activate",
- G_CALLBACK (action_search_execute_cb), cal_shell_view);
-
/* Initialize the memo and task pad actions. */
e_cal_shell_view_memopad_actions_init (cal_shell_view);
e_cal_shell_view_taskpad_actions_init (cal_shell_view);
diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c
index 3fe59945f5..d88c148bca 100644
--- a/modules/calendar/e-cal-shell-view-private.c
+++ b/modules/calendar/e-cal-shell-view-private.c
@@ -581,161 +581,6 @@ e_cal_shell_view_private_finalize (ECalShellView *cal_shell_view)
}
void
-e_cal_shell_view_execute_search (ECalShellView *cal_shell_view)
-{
- ECalShellContent *cal_shell_content;
- ECalShellSidebar *cal_shell_sidebar;
- EShellView *shell_view;
- EShellWindow *shell_window;
- EShellContent *shell_content;
- GnomeCalendar *calendar;
- ECalendar *date_navigator;
- GtkRadioAction *action;
- GString *string;
- FilterRule *rule;
- const gchar *format;
- const gchar *text;
- time_t start_range;
- time_t end_range;
- gboolean range_search;
- gchar *start, *end;
- gchar *query;
- gchar *temp;
- gint value;
-
- shell_view = E_SHELL_VIEW (cal_shell_view);
- shell_content = e_shell_view_get_shell_content (shell_view);
- text = e_shell_content_get_search_text (shell_content);
-
- shell_window = e_shell_view_get_shell_window (shell_view);
- action = GTK_RADIO_ACTION (ACTION (CALENDAR_SEARCH_ANY_FIELD_CONTAINS));
- value = gtk_radio_action_get_current_value (action);
-
- if (text == NULL || *text == '\0') {
- text = "";
- value = CALENDAR_SEARCH_SUMMARY_CONTAINS;
- }
-
- switch (value) {
- default:
- text = "";
- /* fall through */
-
- case CALENDAR_SEARCH_SUMMARY_CONTAINS:
- format = "(contains? \"summary\" %s)";
- break;
-
- case CALENDAR_SEARCH_DESCRIPTION_CONTAINS:
- format = "(contains? \"description\" %s)";
- break;
-
- case CALENDAR_SEARCH_ANY_FIELD_CONTAINS:
- format = "(contains? \"any\" %s)";
- break;
- }
-
- /* Build the query. */
- string = g_string_new ("");
- e_sexp_encode_string (string, text);
- query = g_strdup_printf (format, string->str);
- g_string_free (string, TRUE);
-
- range_search = FALSE;
- start_range = end_range = 0;
-
- /* Apply selected filter. */
- value = e_shell_content_get_filter_value (shell_content);
- switch (value) {
- case CALENDAR_FILTER_ANY_CATEGORY:
- break;
-
- case CALENDAR_FILTER_UNMATCHED:
- temp = g_strdup_printf (
- "(and (has-categories? #f) %s)", query);
- g_free (query);
- query = temp;
- break;
-
- case CALENDAR_FILTER_ACTIVE_APPOINTMENTS:
- /* Show a year's worth of appointments. */
- start_range = time (NULL);
- end_range = time_add_day (start_range, 365);
- start = isodate_from_time_t (start_range);
- end = isodate_from_time_t (end_range);
-
- temp = g_strdup_printf (
- "(and %s (occur-in-time-range? "
- "(make-time \"%s\") (make-time \"%s\")))",
- query, start, end);
- g_free (query);
- query = temp;
-
- range_search = TRUE;
- break;
-
- case CALENDAR_FILTER_NEXT_7_DAYS_APPOINTMENTS:
- start_range = time (NULL);
- end_range = time_add_day (start_range, 7);
- start = isodate_from_time_t (start_range);
- end = isodate_from_time_t (end_range);
-
- temp = g_strdup_printf (
- "(and %s (occur-in-time-range? "
- "(make-time \"%s\") (make-time \"%s\")))",
- query, start, end);
- g_free (query);
- query = temp;
-
- range_search = TRUE;
- break;
-
- default:
- {
- GList *categories;
- const gchar *category_name;
-
- categories = e_categories_get_list ();
- category_name = g_list_nth_data (categories, value);
- g_list_free (categories);
-
- temp = g_strdup_printf (
- "(and (has-categories? \"%s\") %s)",
- category_name, query);
- g_free (query);
- query = temp;
- break;
- }
- }
-
- /* XXX This is wrong. We need to programmatically construct a
- * FilterRule, tell it to build code, and pass the resulting
- * expressing string to ECalModel. */
- rule = filter_rule_new ();
- e_shell_content_set_search_rule (shell_content, rule);
- g_object_unref (rule);
-
- cal_shell_sidebar = cal_shell_view->priv->cal_shell_sidebar;
- date_navigator = e_cal_shell_sidebar_get_date_navigator (cal_shell_sidebar);
-
- if (range_search) {
- /* Switch to list view and hide the date navigator. */
- action = GTK_RADIO_ACTION (ACTION (CALENDAR_VIEW_LIST));
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
- gtk_widget_hide (GTK_WIDGET (date_navigator));
- } else {
- /* Ensure the date navigator is visible. */
- gtk_widget_show (GTK_WIDGET (date_navigator));
- }
-
- /* Submit the query. */
- cal_shell_content = cal_shell_view->priv->cal_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);
- g_free (query);
-}
-
-void
e_cal_shell_view_open_event (ECalShellView *cal_shell_view,
ECalModelComponent *comp_data)
{
diff --git a/modules/calendar/e-cal-shell-view.c b/modules/calendar/e-cal-shell-view.c
index d9d21799b9..32f12b605f 100644
--- a/modules/calendar/e-cal-shell-view.c
+++ b/modules/calendar/e-cal-shell-view.c
@@ -52,6 +52,162 @@ cal_shell_view_constructed (GObject *object)
}
static void
+cal_shell_view_execute_search (EShellView *shell_view)
+{
+ ECalShellContent *cal_shell_content;
+ ECalShellSidebar *cal_shell_sidebar;
+ EShellWindow *shell_window;
+ EShellContent *shell_content;
+ EShellSidebar *shell_sidebar;
+ GnomeCalendar *calendar;
+ ECalendar *date_navigator;
+ GtkRadioAction *action;
+ GString *string;
+ FilterRule *rule;
+ const gchar *format;
+ const gchar *text;
+ time_t start_range;
+ time_t end_range;
+ gboolean range_search;
+ gchar *start, *end;
+ gchar *query;
+ gchar *temp;
+ gint value;
+
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+ shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
+
+ action = GTK_RADIO_ACTION (ACTION (CALENDAR_SEARCH_ANY_FIELD_CONTAINS));
+ value = gtk_radio_action_get_current_value (action);
+
+ text = e_shell_content_get_search_text (shell_content);
+
+ if (text == NULL || *text == '\0') {
+ text = "";
+ value = CALENDAR_SEARCH_SUMMARY_CONTAINS;
+ }
+
+ switch (value) {
+ default:
+ text = "";
+ /* fall through */
+
+ case CALENDAR_SEARCH_SUMMARY_CONTAINS:
+ format = "(contains? \"summary\" %s)";
+ break;
+
+ case CALENDAR_SEARCH_DESCRIPTION_CONTAINS:
+ format = "(contains? \"description\" %s)";
+ break;
+
+ case CALENDAR_SEARCH_ANY_FIELD_CONTAINS:
+ format = "(contains? \"any\" %s)";
+ break;
+ }
+
+ /* Build the query. */
+ string = g_string_new ("");
+ e_sexp_encode_string (string, text);
+ query = g_strdup_printf (format, string->str);
+ g_string_free (string, TRUE);
+
+ range_search = FALSE;
+ start_range = end_range = 0;
+
+ /* Apply selected filter. */
+ value = e_shell_content_get_filter_value (shell_content);
+ switch (value) {
+ case CALENDAR_FILTER_ANY_CATEGORY:
+ break;
+
+ case CALENDAR_FILTER_UNMATCHED:
+ temp = g_strdup_printf (
+ "(and (has-categories? #f) %s)", query);
+ g_free (query);
+ query = temp;
+ break;
+
+ case CALENDAR_FILTER_ACTIVE_APPOINTMENTS:
+ /* Show a year's worth of appointments. */
+ start_range = time (NULL);
+ end_range = time_add_day (start_range, 365);
+ start = isodate_from_time_t (start_range);
+ end = isodate_from_time_t (end_range);
+
+ temp = g_strdup_printf (
+ "(and %s (occur-in-time-range? "
+ "(make-time \"%s\") (make-time \"%s\")))",
+ query, start, end);
+ g_free (query);
+ query = temp;
+
+ range_search = TRUE;
+ break;
+
+ case CALENDAR_FILTER_NEXT_7_DAYS_APPOINTMENTS:
+ start_range = time (NULL);
+ end_range = time_add_day (start_range, 7);
+ start = isodate_from_time_t (start_range);
+ end = isodate_from_time_t (end_range);
+
+ temp = g_strdup_printf (
+ "(and %s (occur-in-time-range? "
+ "(make-time \"%s\") (make-time \"%s\")))",
+ query, start, end);
+ g_free (query);
+ query = temp;
+
+ range_search = TRUE;
+ break;
+
+ default:
+ {
+ GList *categories;
+ const gchar *category_name;
+
+ categories = e_categories_get_list ();
+ category_name = g_list_nth_data (categories, value);
+ g_list_free (categories);
+
+ temp = g_strdup_printf (
+ "(and (has-categories? \"%s\") %s)",
+ category_name, query);
+ g_free (query);
+ query = temp;
+ break;
+ }
+ }
+
+ /* XXX This is wrong. We need to programmatically construct a
+ * FilterRule, tell it to build code, and pass the resulting
+ * expressing string to ECalModel. */
+ rule = filter_rule_new ();
+ e_shell_content_set_search_rule (shell_content, rule);
+ g_object_unref (rule);
+
+ cal_shell_sidebar = E_CAL_SHELL_SIDEBAR (shell_sidebar);
+ date_navigator = e_cal_shell_sidebar_get_date_navigator (cal_shell_sidebar);
+
+ if (range_search) {
+ /* Switch to list view and hide the date navigator. */
+ action = GTK_RADIO_ACTION (ACTION (CALENDAR_VIEW_LIST));
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+ gtk_widget_hide (GTK_WIDGET (date_navigator));
+ } else {
+ /* Ensure the date navigator is visible. */
+ gtk_widget_show (GTK_WIDGET (date_navigator));
+ }
+
+ /* 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);
+ g_free (query);
+}
+
+static void
cal_shell_view_update_actions (EShellView *shell_view)
{
#if 0
@@ -178,6 +334,7 @@ cal_shell_view_class_init (ECalShellViewClass *class,
shell_view_class->search_rules = "caltypes.xml";
shell_view_class->new_shell_content = e_cal_shell_content_new;
shell_view_class->new_shell_sidebar = e_cal_shell_sidebar_new;
+ shell_view_class->execute_search = cal_shell_view_execute_search;
shell_view_class->update_actions = cal_shell_view_update_actions;
}
diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c
index 991c99b5d1..99761b2c74 100644
--- a/modules/calendar/e-memo-shell-view-actions.c
+++ b/modules/calendar/e-memo-shell-view-actions.c
@@ -554,33 +554,11 @@ action_memo_view_cb (GtkRadioAction *action,
}
static void
-action_search_execute_cb (GtkAction *action,
- EMemoShellView *memo_shell_view)
-{
- EShellView *shell_view;
-
- /* All shell views respond to the activation of this action,
- * which is defined by EShellWindow. But only the currently
- * active shell view proceeds with executing the search. */
- shell_view = E_SHELL_VIEW (memo_shell_view);
- if (!e_shell_view_is_active (shell_view))
- return;
-
- e_memo_shell_view_execute_search (memo_shell_view);
-}
-
-static void
action_search_filter_cb (GtkRadioAction *action,
GtkRadioAction *current,
- EMemoShellView *memo_shell_view)
+ EShellView *shell_view)
{
- EShellView *shell_view;
- EShellWindow *shell_window;
-
- shell_view = E_SHELL_VIEW (memo_shell_view);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- gtk_action_activate (ACTION (SEARCH_EXECUTE));
+ e_shell_view_execute_search (shell_view);
}
static GtkActionEntry memo_entries[] = {
@@ -930,10 +908,6 @@ e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view)
ACTION (GAL_SAVE_CUSTOM_VIEW), "activate",
G_CALLBACK (action_gal_save_custom_view_cb), memo_shell_view);
- g_signal_connect (
- ACTION (SEARCH_EXECUTE), "activate",
- G_CALLBACK (action_search_execute_cb), memo_shell_view);
-
e_binding_new (
ACTION (MEMO_PREVIEW), "active",
ACTION (MEMO_VIEW_CLASSIC), "sensitive");
diff --git a/modules/calendar/e-memo-shell-view-private.c b/modules/calendar/e-memo-shell-view-private.c
index da321d5c19..f1d331fab3 100644
--- a/modules/calendar/e-memo-shell-view-private.c
+++ b/modules/calendar/e-memo-shell-view-private.c
@@ -276,8 +276,6 @@ e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view)
e_memo_shell_view_update_sidebar (memo_shell_view);
e_memo_shell_view_update_search_filter (memo_shell_view);
e_memo_shell_view_update_timezone (memo_shell_view);
-
- e_memo_shell_view_execute_search (memo_shell_view);
}
void
@@ -304,111 +302,6 @@ e_memo_shell_view_private_finalize (EMemoShellView *memo_shell_view)
}
void
-e_memo_shell_view_execute_search (EMemoShellView *memo_shell_view)
-{
- EMemoShellContent *memo_shell_content;
- EShellView *shell_view;
- EShellWindow *shell_window;
- EShellContent *shell_content;
- GtkRadioAction *action;
- GString *string;
- ECalComponentPreview *memo_preview;
- EMemoTable *memo_table;
- ECalModel *model;
- FilterRule *rule;
- const gchar *format;
- const gchar *text;
- gchar *query;
- gchar *temp;
- gint value;
-
- shell_view = E_SHELL_VIEW (memo_shell_view);
- shell_content = e_shell_view_get_shell_content (shell_view);
- text = e_shell_content_get_search_text (shell_content);
-
- shell_window = e_shell_view_get_shell_window (shell_view);
- action = GTK_RADIO_ACTION (ACTION (MEMO_SEARCH_ANY_FIELD_CONTAINS));
- value = gtk_radio_action_get_current_value (action);
-
- if (text == NULL || *text == '\0') {
- text = "";
- value = MEMO_SEARCH_SUMMARY_CONTAINS;
- }
-
- switch (value) {
- default:
- text = "";
- /* fall through */
-
- case MEMO_SEARCH_SUMMARY_CONTAINS:
- format = "(contains? \"summary\" %s)";
- break;
-
- case MEMO_SEARCH_DESCRIPTION_CONTAINS:
- format = "(contains? \"description\" %s)";
- break;
-
- case MEMO_SEARCH_ANY_FIELD_CONTAINS:
- format = "(contains? \"any\" %s)";
- break;
- }
-
- /* Build the query. */
- string = g_string_new ("");
- e_sexp_encode_string (string, text);
- query = g_strdup_printf (format, string->str);
- g_string_free (string, TRUE);
-
- /* Apply selected filter. */
- value = e_shell_content_get_filter_value (shell_content);
- switch (value) {
- case MEMO_FILTER_ANY_CATEGORY:
- break;
-
- case MEMO_FILTER_UNMATCHED:
- temp = g_strdup_printf (
- "(and (has-categories? #f) %s", query);
- g_free (query);
- query = temp;
- break;
-
- default:
- {
- GList *categories;
- const gchar *category_name;
-
- categories = e_categories_get_list ();
- category_name = g_list_nth_data (categories, value);
- g_list_free (categories);
-
- temp = g_strdup_printf (
- "(and (has-categories? \"%s\") %s)",
- category_name, query);
- g_free (query);
- query = temp;
- }
- }
-
- /* XXX This is wrong. We need to programmatically construct a
- * FilterRule, tell it to build code, and pass the resulting
- * expression string to ECalModel. */
- rule = filter_rule_new ();
- e_shell_content_set_search_rule (shell_content, rule);
- g_object_unref (rule);
-
- /* Submit the query. */
- memo_shell_content = memo_shell_view->priv->memo_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);
- g_free (query);
-
- memo_preview =
- e_memo_shell_content_get_memo_preview (memo_shell_content);
- e_cal_component_preview_clear (memo_preview);
-}
-
-void
e_memo_shell_view_open_memo (EMemoShellView *memo_shell_view,
ECalModelComponent *comp_data)
{
diff --git a/modules/calendar/e-memo-shell-view-private.h b/modules/calendar/e-memo-shell-view-private.h
index 857e924363..276e6e5d30 100644
--- a/modules/calendar/e-memo-shell-view-private.h
+++ b/modules/calendar/e-memo-shell-view-private.h
@@ -108,8 +108,6 @@ void e_memo_shell_view_private_finalize
void e_memo_shell_view_actions_init
(EMemoShellView *memo_shell_view);
-void e_memo_shell_view_execute_search
- (EMemoShellView *memo_shell_view);
void e_memo_shell_view_open_memo
(EMemoShellView *memo_shell_view,
ECalModelComponent *comp_data);
diff --git a/modules/calendar/e-memo-shell-view.c b/modules/calendar/e-memo-shell-view.c
index e2964b061c..54dea9c444 100644
--- a/modules/calendar/e-memo-shell-view.c
+++ b/modules/calendar/e-memo-shell-view.c
@@ -52,6 +52,109 @@ memo_shell_view_constructed (GObject *object)
}
static void
+memo_shell_view_execute_search (EShellView *shell_view)
+{
+ EMemoShellContent *memo_shell_content;
+ EShellWindow *shell_window;
+ EShellContent *shell_content;
+ GtkRadioAction *action;
+ GString *string;
+ ECalComponentPreview *memo_preview;
+ EMemoTable *memo_table;
+ ECalModel *model;
+ FilterRule *rule;
+ const gchar *format;
+ const gchar *text;
+ gchar *query;
+ gchar *temp;
+ gint value;
+
+ shell_content = e_shell_view_get_shell_content (shell_view);
+ text = e_shell_content_get_search_text (shell_content);
+
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ action = GTK_RADIO_ACTION (ACTION (MEMO_SEARCH_ANY_FIELD_CONTAINS));
+ value = gtk_radio_action_get_current_value (action);
+
+ if (text == NULL || *text == '\0') {
+ text = "";
+ value = MEMO_SEARCH_SUMMARY_CONTAINS;
+ }
+
+ switch (value) {
+ default:
+ text = "";
+ /* fall through */
+
+ case MEMO_SEARCH_SUMMARY_CONTAINS:
+ format = "(contains? \"summary\" %s)";
+ break;
+
+ case MEMO_SEARCH_DESCRIPTION_CONTAINS:
+ format = "(contains? \"description\" %s)";
+ break;
+
+ case MEMO_SEARCH_ANY_FIELD_CONTAINS:
+ format = "(contains? \"any\" %s)";
+ break;
+ }
+
+ /* Build the query. */
+ string = g_string_new ("");
+ e_sexp_encode_string (string, text);
+ query = g_strdup_printf (format, string->str);
+ g_string_free (string, TRUE);
+
+ /* Apply selected filter. */
+ value = e_shell_content_get_filter_value (shell_content);
+ switch (value) {
+ case MEMO_FILTER_ANY_CATEGORY:
+ break;
+
+ case MEMO_FILTER_UNMATCHED:
+ temp = g_strdup_printf (
+ "(and (has-categories? #f) %s", query);
+ g_free (query);
+ query = temp;
+ break;
+
+ default:
+ {
+ GList *categories;
+ const gchar *category_name;
+
+ categories = e_categories_get_list ();
+ category_name = g_list_nth_data (categories, value);
+ g_list_free (categories);
+
+ temp = g_strdup_printf (
+ "(and (has-categories? \"%s\") %s)",
+ category_name, query);
+ g_free (query);
+ query = temp;
+ }
+ }
+
+ /* XXX This is wrong. We need to programmatically construct a
+ * FilterRule, tell it to build code, and pass the resulting
+ * expression string to ECalModel. */
+ rule = filter_rule_new ();
+ e_shell_content_set_search_rule (shell_content, rule);
+ g_object_unref (rule);
+
+ /* 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);
+ g_free (query);
+
+ memo_preview =
+ e_memo_shell_content_get_memo_preview (memo_shell_content);
+ e_cal_component_preview_clear (memo_preview);
+}
+
+static void
memo_shell_view_update_actions (EShellView *shell_view)
{
EMemoShellViewPrivate *priv;
@@ -181,6 +284,7 @@ memo_shell_view_class_init (EMemoShellViewClass *class,
shell_view_class->search_rules = "memotypes.xml";
shell_view_class->new_shell_content = e_memo_shell_content_new;
shell_view_class->new_shell_sidebar = e_memo_shell_sidebar_new;
+ shell_view_class->execute_search = memo_shell_view_execute_search;
shell_view_class->update_actions = memo_shell_view_update_actions;
}
diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c
index 7b70ec1902..7833873832 100644
--- a/modules/calendar/e-task-shell-view-actions.c
+++ b/modules/calendar/e-task-shell-view-actions.c
@@ -42,33 +42,11 @@ action_gal_save_custom_view_cb (GtkAction *action,
}
static void
-action_search_execute_cb (GtkAction *action,
- ETaskShellView *task_shell_view)
-{
- EShellView *shell_view;
-
- /* All shell views respond to the activation of this action,
- * which is defined by EShellWindow. But only the currently
- * active shell view proceeds with executing the search. */
- shell_view = E_SHELL_VIEW (task_shell_view);
- if (!e_shell_view_is_active (shell_view))
- return;
-
- e_task_shell_view_execute_search (task_shell_view);
-}
-
-static void
action_search_filter_cb (GtkRadioAction *action,
GtkRadioAction *current,
- ETaskShellView *task_shell_view)
+ EShellView *shell_view)
{
- EShellView *shell_view;
- EShellWindow *shell_window;
-
- shell_view = E_SHELL_VIEW (task_shell_view);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- gtk_action_activate (ACTION (SEARCH_EXECUTE));
+ e_shell_view_execute_search (shell_view);
}
static void
@@ -1130,10 +1108,6 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view)
ACTION (GAL_SAVE_CUSTOM_VIEW), "activate",
G_CALLBACK (action_gal_save_custom_view_cb), task_shell_view);
- g_signal_connect (
- ACTION (SEARCH_EXECUTE), "activate",
- G_CALLBACK (action_search_execute_cb), task_shell_view);
-
e_binding_new (
ACTION (TASK_PREVIEW), "active",
ACTION (TASK_VIEW_CLASSIC), "sensitive");
diff --git a/modules/calendar/e-task-shell-view-private.c b/modules/calendar/e-task-shell-view-private.c
index 3b49ddbc5b..87bb6984dc 100644
--- a/modules/calendar/e-task-shell-view-private.c
+++ b/modules/calendar/e-task-shell-view-private.c
@@ -41,7 +41,7 @@ task_shell_view_process_completed_tasks (ETaskShellView *task_shell_view)
/* Search query takes whether to show completed tasks into account,
* so if the preference has changed we need to update the query. */
- e_task_shell_view_execute_search (task_shell_view);
+ e_shell_view_execute_search (E_SHELL_VIEW (task_shell_view));
g_list_free (clients);
}
@@ -354,8 +354,6 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view)
e_task_shell_view_update_sidebar (task_shell_view);
e_task_shell_view_update_search_filter (task_shell_view);
e_task_shell_view_update_timezone (task_shell_view);
-
- e_task_shell_view_execute_search (task_shell_view);
}
void
@@ -387,184 +385,6 @@ e_task_shell_view_private_finalize (ETaskShellView *task_shell_view)
}
void
-e_task_shell_view_execute_search (ETaskShellView *task_shell_view)
-{
- ETaskShellContent *task_shell_content;
- EShellView *shell_view;
- EShellWindow *shell_window;
- EShellContent *shell_content;
- GtkRadioAction *action;
- GString *string;
- ECalComponentPreview *task_preview;
- ECalendarTable *task_table;
- ECalModel *model;
- FilterRule *rule;
- const gchar *format;
- const gchar *text;
- time_t start_range;
- time_t end_range;
- gchar *start, *end;
- gchar *query;
- gchar *temp;
- gint value;
-
- shell_view = E_SHELL_VIEW (task_shell_view);
- shell_content = e_shell_view_get_shell_content (shell_view);
- text = e_shell_content_get_search_text (shell_content);
-
- shell_window = e_shell_view_get_shell_window (shell_view);
- action = GTK_RADIO_ACTION (ACTION (TASK_SEARCH_ANY_FIELD_CONTAINS));
- value = gtk_radio_action_get_current_value (action);
-
- if (text == NULL || *text == '\0') {
- text = "";
- value = TASK_SEARCH_SUMMARY_CONTAINS;
- }
-
- switch (value) {
- default:
- text = "";
- /* fall through */
-
- case TASK_SEARCH_SUMMARY_CONTAINS:
- format = "(contains? \"summary\" %s)";
- break;
-
- case TASK_SEARCH_DESCRIPTION_CONTAINS:
- format = "(contains? \"description\" %s)";
- break;
-
- case TASK_SEARCH_ANY_FIELD_CONTAINS:
- format = "(contains? \"any\" %s)";
- break;
- }
-
- /* Build the query. */
- string = g_string_new ("");
- e_sexp_encode_string (string, text);
- query = g_strdup_printf (format, string->str);
- g_string_free (string, TRUE);
-
- /* Apply selected filter. */
- value = e_shell_content_get_filter_value (shell_content);
- switch (value) {
- case TASK_FILTER_ANY_CATEGORY:
- break;
-
- case TASK_FILTER_UNMATCHED:
- temp = g_strdup_printf (
- "(and (has-categories? #f) %s)", query);
- g_free (query);
- query = temp;
- break;
-
- case TASK_FILTER_NEXT_7_DAYS_TASKS:
- start_range = time (NULL);
- end_range = time_add_day (start_range, 7);
- start = isodate_from_time_t (start_range);
- end = isodate_from_time_t (end_range);
-
- temp = g_strdup_printf (
- "(and %s (due-in-time-range? "
- "(make-time \"%s\") (make-time \"%s\")))",
- query, start, end);
- g_free (query);
- query = temp;
- break;
-
- case TASK_FILTER_ACTIVE_TASKS:
- start_range = time (NULL);
- end_range = time_add_day (start_range, 365);
- start = isodate_from_time_t (start_range);
- end = isodate_from_time_t (end_range);
-
- temp = g_strdup_printf (
- "(and %s (due-in-time-range? "
- "(make-time \"%s\") (make-time \"%s\")) "
- "(not (is-completed?)))",
- query, start, end);
- g_free (query);
- query = temp;
- break;
-
- case TASK_FILTER_OVERDUE_TASKS:
- start_range = 0;
- end_range = time (NULL);
- start = isodate_from_time_t (start_range);
- end = isodate_from_time_t (end_range);
-
- temp = g_strdup_printf (
- "(and %s (due-in-time-range? "
- "(make-time \"%s\") (make-time \"%s\")) "
- "(not (is-completed?)))",
- query, start, end);
- g_free (query);
- query = temp;
- break;
-
- case TASK_FILTER_COMPLETED_TASKS:
- temp = g_strdup_printf (
- "(and (is-completed?) %s)", query);
- g_free (query);
- query = temp;
- break;
-
- case TASK_FILTER_TASKS_WITH_ATTACHMENTS:
- temp = g_strdup_printf (
- "(and (has-attachments?) %s)", query);
- g_free (query);
- query = temp;
- break;
-
- default:
- {
- GList *categories;
- const gchar *category_name;
-
- categories = e_categories_get_list ();
- category_name = g_list_nth_data (categories, value);
- g_list_free (categories);
-
- temp = g_strdup_printf (
- "(and (has-categories? \"%s\") %s)",
- category_name, query);
- g_free (query);
- query = temp;
- break;
- }
- }
-
- /* Honor the user's preference to hide completed tasks. */
- temp = calendar_config_get_hide_completed_tasks_sexp (FALSE);
- if (temp != NULL) {
- gchar *temp2;
-
- temp2 = g_strdup_printf ("(and %s %s)", temp, query);
- g_free (query);
- g_free (temp);
- query = temp2;
- }
-
- /* XXX This is wrong. We need to programmatically construct a
- * FilterRule, tell it to build code, and pass the resulting
- * expression string to ECalModel. */
- rule = filter_rule_new ();
- e_shell_content_set_search_rule (shell_content, rule);
- g_object_unref (rule);
-
- /* Submit the query. */
- task_shell_content = task_shell_view->priv->task_shell_content;
- task_table = e_task_shell_content_get_task_table (task_shell_content);
- model = e_calendar_table_get_model (task_table);
- e_cal_model_set_search_query (model, query);
- g_free (query);
-
- task_preview =
- e_task_shell_content_get_task_preview (task_shell_content);
- e_cal_component_preview_clear (task_preview);
-}
-
-void
e_task_shell_view_open_task (ETaskShellView *task_shell_view,
ECalModelComponent *comp_data)
{
diff --git a/modules/calendar/e-task-shell-view-private.h b/modules/calendar/e-task-shell-view-private.h
index e612069bed..b369b4c948 100644
--- a/modules/calendar/e-task-shell-view-private.h
+++ b/modules/calendar/e-task-shell-view-private.h
@@ -120,8 +120,6 @@ void e_task_shell_view_private_finalize
void e_task_shell_view_actions_init
(ETaskShellView *task_shell_view);
-void e_task_shell_view_execute_search
- (ETaskShellView *task_shell_view);
void e_task_shell_view_open_task
(ETaskShellView *task_shell_view,
ECalModelComponent *comp_data);
diff --git a/modules/calendar/e-task-shell-view.c b/modules/calendar/e-task-shell-view.c
index b1298eaa29..7237b1cddd 100644
--- a/modules/calendar/e-task-shell-view.c
+++ b/modules/calendar/e-task-shell-view.c
@@ -91,6 +91,182 @@ task_shell_view_constructed (GObject *object)
}
static void
+task_shell_view_execute_search (EShellView *shell_view)
+{
+ ETaskShellContent *task_shell_content;
+ EShellWindow *shell_window;
+ EShellContent *shell_content;
+ GtkRadioAction *action;
+ GString *string;
+ ECalComponentPreview *task_preview;
+ ECalendarTable *task_table;
+ ECalModel *model;
+ FilterRule *rule;
+ const gchar *format;
+ const gchar *text;
+ time_t start_range;
+ time_t end_range;
+ gchar *start, *end;
+ gchar *query;
+ gchar *temp;
+ gint value;
+
+ shell_content = e_shell_view_get_shell_content (shell_view);
+ text = e_shell_content_get_search_text (shell_content);
+
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ action = GTK_RADIO_ACTION (ACTION (TASK_SEARCH_ANY_FIELD_CONTAINS));
+ value = gtk_radio_action_get_current_value (action);
+
+ if (text == NULL || *text == '\0') {
+ text = "";
+ value = TASK_SEARCH_SUMMARY_CONTAINS;
+ }
+
+ switch (value) {
+ default:
+ text = "";
+ /* fall through */
+
+ case TASK_SEARCH_SUMMARY_CONTAINS:
+ format = "(contains? \"summary\" %s)";
+ break;
+
+ case TASK_SEARCH_DESCRIPTION_CONTAINS:
+ format = "(contains? \"description\" %s)";
+ break;
+
+ case TASK_SEARCH_ANY_FIELD_CONTAINS:
+ format = "(contains? \"any\" %s)";
+ break;
+ }
+
+ /* Build the query. */
+ string = g_string_new ("");
+ e_sexp_encode_string (string, text);
+ query = g_strdup_printf (format, string->str);
+ g_string_free (string, TRUE);
+
+ /* Apply selected filter. */
+ value = e_shell_content_get_filter_value (shell_content);
+ switch (value) {
+ case TASK_FILTER_ANY_CATEGORY:
+ break;
+
+ case TASK_FILTER_UNMATCHED:
+ temp = g_strdup_printf (
+ "(and (has-categories? #f) %s)", query);
+ g_free (query);
+ query = temp;
+ break;
+
+ case TASK_FILTER_NEXT_7_DAYS_TASKS:
+ start_range = time (NULL);
+ end_range = time_add_day (start_range, 7);
+ start = isodate_from_time_t (start_range);
+ end = isodate_from_time_t (end_range);
+
+ temp = g_strdup_printf (
+ "(and %s (due-in-time-range? "
+ "(make-time \"%s\") (make-time \"%s\")))",
+ query, start, end);
+ g_free (query);
+ query = temp;
+ break;
+
+ case TASK_FILTER_ACTIVE_TASKS:
+ start_range = time (NULL);
+ end_range = time_add_day (start_range, 365);
+ start = isodate_from_time_t (start_range);
+ end = isodate_from_time_t (end_range);
+
+ temp = g_strdup_printf (
+ "(and %s (due-in-time-range? "
+ "(make-time \"%s\") (make-time \"%s\")) "
+ "(not (is-completed?)))",
+ query, start, end);
+ g_free (query);
+ query = temp;
+ break;
+
+ case TASK_FILTER_OVERDUE_TASKS:
+ start_range = 0;
+ end_range = time (NULL);
+ start = isodate_from_time_t (start_range);
+ end = isodate_from_time_t (end_range);
+
+ temp = g_strdup_printf (
+ "(and %s (due-in-time-range? "
+ "(make-time \"%s\") (make-time \"%s\")) "
+ "(not (is-completed?)))",
+ query, start, end);
+ g_free (query);
+ query = temp;
+ break;
+
+ case TASK_FILTER_COMPLETED_TASKS:
+ temp = g_strdup_printf (
+ "(and (is-completed?) %s)", query);
+ g_free (query);
+ query = temp;
+ break;
+
+ case TASK_FILTER_TASKS_WITH_ATTACHMENTS:
+ temp = g_strdup_printf (
+ "(and (has-attachments?) %s)", query);
+ g_free (query);
+ query = temp;
+ break;
+
+ default:
+ {
+ GList *categories;
+ const gchar *category_name;
+
+ categories = e_categories_get_list ();
+ category_name = g_list_nth_data (categories, value);
+ g_list_free (categories);
+
+ temp = g_strdup_printf (
+ "(and (has-categories? \"%s\") %s)",
+ category_name, query);
+ g_free (query);
+ query = temp;
+ break;
+ }
+ }
+
+ /* Honor the user's preference to hide completed tasks. */
+ temp = calendar_config_get_hide_completed_tasks_sexp (FALSE);
+ if (temp != NULL) {
+ gchar *temp2;
+
+ temp2 = g_strdup_printf ("(and %s %s)", temp, query);
+ g_free (query);
+ g_free (temp);
+ query = temp2;
+ }
+
+ /* XXX This is wrong. We need to programmatically construct a
+ * FilterRule, tell it to build code, and pass the resulting
+ * expression string to ECalModel. */
+ rule = filter_rule_new ();
+ e_shell_content_set_search_rule (shell_content, rule);
+ g_object_unref (rule);
+
+ /* Submit the query. */
+ task_shell_content = E_TASK_SHELL_CONTENT (shell_content);
+ task_table = e_task_shell_content_get_task_table (task_shell_content);
+ model = e_calendar_table_get_model (task_table);
+ e_cal_model_set_search_query (model, query);
+ g_free (query);
+
+ task_preview =
+ e_task_shell_content_get_task_preview (task_shell_content);
+ e_cal_component_preview_clear (task_preview);
+}
+
+static void
task_shell_view_update_actions (EShellView *shell_view)
{
ETaskShellViewPrivate *priv;
@@ -255,6 +431,7 @@ task_shell_view_class_init (ETaskShellViewClass *class,
shell_view_class->search_rules = "tasktypes.xml";
shell_view_class->new_shell_content = e_task_shell_content_new;
shell_view_class->new_shell_sidebar = e_task_shell_sidebar_new;
+ shell_view_class->execute_search = task_shell_view_execute_search;
shell_view_class->update_actions = task_shell_view_update_actions;
g_object_class_install_property (