[evolution/gnome-2-32] Bug #629462 - Tasks 'Due' filters don't work properly



commit 65567c122a4f93ab10576ad5a175fc438e14a5e7
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 29 11:40:04 2010 +0200

    Bug #629462 - Tasks 'Due' filters don't work properly

 calendar/gui/e-cal-model.c           |   13 +++++++++++--
 calendar/gui/e-calendar-view.c       |    4 ++++
 modules/calendar/e-cal-shell-view.c  |   13 ++++++++-----
 modules/calendar/e-task-shell-view.c |   19 +++++++++++--------
 4 files changed, 34 insertions(+), 15 deletions(-)
---
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index 70d20c3..dbcd10c 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -227,6 +227,16 @@ cal_model_get_property (GObject *object,
 }
 
 static void
+cal_model_constructed (GObject *object)
+{
+	e_extensible_load_extensions (E_EXTENSIBLE (object));
+
+	/* Chain up to parent's constructed() method. */
+	if (G_OBJECT_CLASS (parent_class)->constructed)
+		G_OBJECT_CLASS (parent_class)->constructed (object);
+}
+
+static void
 cal_model_dispose (GObject *object)
 {
 	ECalModelPrivate *priv;
@@ -302,6 +312,7 @@ e_cal_model_class_init (ECalModelClass *class)
 	object_class = G_OBJECT_CLASS (class);
 	object_class->set_property = cal_model_set_property;
 	object_class->get_property = cal_model_get_property;
+	object_class->constructed = cal_model_constructed;
 	object_class->dispose = cal_model_dispose;
 	object_class->finalize = cal_model_finalize;
 
@@ -465,8 +476,6 @@ e_cal_model_init (ECalModel *model)
 	model->priv->notify_modified = NULL;
 	model->priv->notify_removed = NULL;
 	model->priv->notify_lock = g_mutex_new ();
-
-	e_extensible_load_extensions (E_EXTENSIBLE (model));
 }
 
 /* ETableModel methods */
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index 2bc7eef..339cfb9 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -350,6 +350,10 @@ calendar_view_constructed (GObject *object)
 	 * the GType accurately.  See GInstanceInitFunc documentation
 	 * for details of the problem. */
 	e_extensible_load_extensions (E_EXTENSIBLE (object));
+
+	/* Chain up to parent's constructed() method. */
+	if (G_OBJECT_CLASS (e_calendar_view_parent_class)->constructed)
+		G_OBJECT_CLASS (e_calendar_view_parent_class)->constructed (object);
 }
 
 static void
diff --git a/modules/calendar/e-cal-shell-view.c b/modules/calendar/e-cal-shell-view.c
index 19c8042..f9985f5 100644
--- a/modules/calendar/e-cal-shell-view.c
+++ b/modules/calendar/e-cal-shell-view.c
@@ -66,6 +66,7 @@ cal_shell_view_execute_search (EShellView *shell_view)
 	GtkRadioAction *action;
 	time_t start_range;
 	time_t end_range;
+	time_t now_time;
 	gboolean range_search;
 	gchar *start, *end;
 	gchar *query;
@@ -81,6 +82,9 @@ cal_shell_view_execute_search (EShellView *shell_view)
 
 	searchbar = e_cal_shell_content_get_searchbar (cal_shell_content);
 
+	calendar = e_cal_shell_content_get_calendar (cal_shell_content);
+	now_time = time_day_begin (icaltime_as_timet (icaltime_current_time_with_zone (e_cal_model_get_timezone (gnome_calendar_get_model (calendar)))));
+
 	action = GTK_RADIO_ACTION (ACTION (CALENDAR_SEARCH_ANY_FIELD_CONTAINS));
 	value = gtk_radio_action_get_current_value (action);
 
@@ -145,8 +149,8 @@ cal_shell_view_execute_search (EShellView *shell_view)
 
 		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_range = now_time;
+			end_range = time_day_end (time_add_day (start_range, 365));
 			start = isodate_from_time_t (start_range);
 			end = isodate_from_time_t (end_range);
 
@@ -161,8 +165,8 @@ cal_shell_view_execute_search (EShellView *shell_view)
 			break;
 
 		case CALENDAR_FILTER_NEXT_7_DAYS_APPOINTMENTS:
-			start_range = time (NULL);
-			end_range = time_add_day (start_range, 7);
+			start_range = now_time;
+			end_range = time_day_end (time_add_day (start_range, 7));
 			start = isodate_from_time_t (start_range);
 			end = isodate_from_time_t (end_range);
 
@@ -207,7 +211,6 @@ cal_shell_view_execute_search (EShellView *shell_view)
 	}
 
 	/* Submit the query. */
-	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);
diff --git a/modules/calendar/e-task-shell-view.c b/modules/calendar/e-task-shell-view.c
index b2146f5..3bf0eb6 100644
--- a/modules/calendar/e-task-shell-view.c
+++ b/modules/calendar/e-task-shell-view.c
@@ -106,6 +106,7 @@ task_shell_view_execute_search (EShellView *shell_view)
 	ECalModel *model;
 	time_t start_range;
 	time_t end_range;
+	time_t now_time;
 	gchar *start, *end;
 	gchar *query;
 	gchar *temp;
@@ -117,6 +118,11 @@ task_shell_view_execute_search (EShellView *shell_view)
 	task_shell_content = E_TASK_SHELL_CONTENT (shell_content);
 	searchbar = e_task_shell_content_get_searchbar (task_shell_content);
 
+	task_shell_content = E_TASK_SHELL_CONTENT (shell_content);
+	task_table = e_task_shell_content_get_task_table (task_shell_content);
+	model = e_task_table_get_model (task_table);
+	now_time = time_day_begin (icaltime_as_timet (icaltime_current_time_with_zone (e_cal_model_get_timezone (model))));
+
 	action = GTK_RADIO_ACTION (ACTION (TASK_SEARCH_ANY_FIELD_CONTAINS));
 	value = gtk_radio_action_get_current_value (action);
 
@@ -177,8 +183,8 @@ task_shell_view_execute_search (EShellView *shell_view)
 			break;
 
 		case TASK_FILTER_NEXT_7_DAYS_TASKS:
-			start_range = time (NULL);
-			end_range = time_add_day (start_range, 7);
+			start_range = now_time;
+			end_range = time_day_end (time_add_day (start_range, 7));
 			start = isodate_from_time_t (start_range);
 			end = isodate_from_time_t (end_range);
 
@@ -191,8 +197,8 @@ task_shell_view_execute_search (EShellView *shell_view)
 			break;
 
 		case TASK_FILTER_ACTIVE_TASKS:
-			start_range = time (NULL);
-			end_range = time_add_day (start_range, 365);
+			start_range = now_time;
+			end_range = time_day_end (time_add_day (start_range, 365));
 			start = isodate_from_time_t (start_range);
 			end = isodate_from_time_t (end_range);
 
@@ -207,7 +213,7 @@ task_shell_view_execute_search (EShellView *shell_view)
 
 		case TASK_FILTER_OVERDUE_TASKS:
 			start_range = 0;
-			end_range = time (NULL);
+			end_range = time_day_end (now_time);
 			start = isodate_from_time_t (start_range);
 			end = isodate_from_time_t (end_range);
 
@@ -264,9 +270,6 @@ task_shell_view_execute_search (EShellView *shell_view)
 	}
 
 	/* 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_task_table_get_model (task_table);
 	e_cal_model_set_search_query (model, query);
 	g_free (query);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]