aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-07-28 01:26:13 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-07-28 01:26:13 +0800
commitb4c93f77e655cfd0a2a740502d7b67bc60df4523 (patch)
tree52102ff28062c32127b058b3ae79cb88a523120d /modules
parentad465a7c1fbea59767741ae5e56a94b5f5f7c6a1 (diff)
downloadgsoc2013-evolution-b4c93f77e655cfd0a2a740502d7b67bc60df4523.tar
gsoc2013-evolution-b4c93f77e655cfd0a2a740502d7b67bc60df4523.tar.gz
gsoc2013-evolution-b4c93f77e655cfd0a2a740502d7b67bc60df4523.tar.bz2
gsoc2013-evolution-b4c93f77e655cfd0a2a740502d7b67bc60df4523.tar.lz
gsoc2013-evolution-b4c93f77e655cfd0a2a740502d7b67bc60df4523.tar.xz
gsoc2013-evolution-b4c93f77e655cfd0a2a740502d7b67bc60df4523.tar.zst
gsoc2013-evolution-b4c93f77e655cfd0a2a740502d7b67bc60df4523.zip
Kill CalSearchBar.
Move calendar search logic to ECalShellView.
Diffstat (limited to 'modules')
-rw-r--r--modules/addressbook/e-book-shell-view-private.c6
-rw-r--r--modules/calendar/e-cal-shell-view-private.c151
-rw-r--r--modules/calendar/e-memo-shell-view-private.c6
-rw-r--r--modules/calendar/e-task-shell-view-private.c6
4 files changed, 159 insertions, 10 deletions
diff --git a/modules/addressbook/e-book-shell-view-private.c b/modules/addressbook/e-book-shell-view-private.c
index f930e6d478..6770800dbd 100644
--- a/modules/addressbook/e-book-shell-view-private.c
+++ b/modules/addressbook/e-book-shell-view-private.c
@@ -522,7 +522,7 @@ e_book_shell_view_execute_search (EBookShellView *book_shell_view)
EShellView *shell_view;
EShellWindow *shell_window;
EShellContent *shell_content;
- GtkAction *action;
+ GtkRadioAction *action;
GString *string;
EAddressbookView *view;
EAddressbookModel *model;
@@ -541,8 +541,8 @@ e_book_shell_view_execute_search (EBookShellView *book_shell_view)
text = e_shell_content_get_search_text (shell_content);
shell_window = e_shell_view_get_shell_window (shell_view);
- action = ACTION (CONTACT_SEARCH_ANY_FIELD_CONTAINS);
- value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
+ action = GTK_RADIO_ACTION (ACTION (CONTACT_SEARCH_ANY_FIELD_CONTAINS));
+ value = gtk_radio_action_get_current_value (action);
if (text == NULL || *text == '\0') {
text = "";
diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c
index 9af8e98740..19d29a05fb 100644
--- a/modules/calendar/e-cal-shell-view-private.c
+++ b/modules/calendar/e-cal-shell-view-private.c
@@ -417,7 +417,156 @@ e_cal_shell_view_private_finalize (ECalShellView *cal_shell_view)
void
e_cal_shell_view_execute_search (ECalShellView *cal_shell_view)
{
- /* FIXME */
+ ECalShellContent *cal_shell_content;
+ ECalShellSidebar *cal_shell_sidebar;
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ EShellContent *shell_content;
+ GnomeCalendar *calendar;
+ ECalendar *mini_calendar;
+ 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 (CAL_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;
+ range_start = range_end = 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;
+ mini_calendar = e_cal_shell_sidebar_get_mini_calendar (cal_shell_sidebar);
+
+ if (range_search) {
+ /* Switch to list view and hide the mini calendar. */
+ action = GTK_RADIO_ACTION (ACTION (CALENDAR_VIEW_LIST));
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+ gtk_widget_hide (GTK_WIDGET (mini_calendar));
+ } else {
+ /* Ensure the mini calendar is visible. */
+ gtk_widget_show (GTK_WIDGET (mini_calendar));
+ }
+
+ /* 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
diff --git a/modules/calendar/e-memo-shell-view-private.c b/modules/calendar/e-memo-shell-view-private.c
index 69d6c0afe2..4953a388d3 100644
--- a/modules/calendar/e-memo-shell-view-private.c
+++ b/modules/calendar/e-memo-shell-view-private.c
@@ -303,7 +303,7 @@ e_memo_shell_view_execute_search (EMemoShellView *memo_shell_view)
EShellView *shell_view;
EShellWindow *shell_window;
EShellContent *shell_content;
- GtkAction *action;
+ GtkRadioAction *action;
GString *string;
ECalComponentPreview *memo_preview;
EMemoTable *memo_table;
@@ -320,8 +320,8 @@ e_memo_shell_view_execute_search (EMemoShellView *memo_shell_view)
text = e_shell_content_get_search_text (shell_content);
shell_window = e_shell_view_get_shell_window (shell_view);
- action = ACTION (MEMO_SEARCH_ANY_FIELD_CONTAINS);
- value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
+ action = GTK_RADIO_ACTION (ACTION (MEMO_SEARCH_ANY_FIELD_CONTAINS));
+ value = gtk_radio_action_get_current_value (action);
if (text == NULL || *text == '\0') {
text = "";
diff --git a/modules/calendar/e-task-shell-view-private.c b/modules/calendar/e-task-shell-view-private.c
index d6fd8e35aa..be281f1c6e 100644
--- a/modules/calendar/e-task-shell-view-private.c
+++ b/modules/calendar/e-task-shell-view-private.c
@@ -412,7 +412,7 @@ e_task_shell_view_execute_search (ETaskShellView *task_shell_view)
EShellView *shell_view;
EShellWindow *shell_window;
EShellContent *shell_content;
- GtkAction *action;
+ GtkRadioAction *action;
GString *string;
ECalComponentPreview *task_preview;
ECalendarTable *task_table;
@@ -432,8 +432,8 @@ e_task_shell_view_execute_search (ETaskShellView *task_shell_view)
text = e_shell_content_get_search_text (shell_content);
shell_window = e_shell_view_get_shell_window (shell_view);
- action = ACTION (TASK_SEARCH_ANY_FIELD_CONTAINS);
- value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
+ action = GTK_RADIO_ACTION (ACTION (TASK_SEARCH_ANY_FIELD_CONTAINS));
+ value = gtk_radio_action_get_current_value (action);
if (text == NULL || *text == '\0') {
text = "";