Re: [evolution-patches] 56898 Tasks



Attached is the latest revision of the patch. JPR reminded that
gnome-cal would need the same changes. I also realized that I had to
make this work with the searchbar. All of this should now work together.

-Gary

On Sun, 2004-04-18 at 13:18 +0200, Rodrigo Moya wrote:
> On Thu, 2004-04-15 at 23:07 -0600, Gary Ekker wrote:
> > This patch implements the hide deleted tasks functionality that is
> > missing. See attached patch for details.
> > 
> looks ok
> 
> cheers
> 
> _______________________________________________
> Evolution-patches mailing list
> Evolution-patches lists ximian com
> http://lists.ximian.com/mailman/listinfo/evolution-patches
? 52271.patch
? 56898.patch
? current.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2262
diff -u -r1.2262 ChangeLog
--- ChangeLog	19 Apr 2004 15:19:32 -0000	1.2262
+++ ChangeLog	20 Apr 2004 04:22:01 -0000
@@ -1,3 +1,18 @@
+2004-04-15  Gary Ekker  <gekker novell com>
+
+	* gui/e-tasks.c: (e_tasks_init): Set up the model to use the correct 
+	query. Setup callbacks for gconf changes. Add an idle timeout to hide 
+	completed items.
+	Add update_view, update_view_cb, and 
+	config_hide_completed_tasks_changed_cb to update the model view.
+
+	* gui/gnome-cal.c: ditto
+	
+	* gui/calendar-config.h: Add notifications for hide_completed_tasks
+	settings.
+
+	* gui/calendar-config.c: ditto
+
 2004-04-19  Michael Terry  <mike mterry name>
 
 	* gui/GNOME_Evolution_Calendar.server.in.in:
Index: gui/calendar-config.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/calendar-config.c,v
retrieving revision 1.68
diff -u -r1.68 calendar-config.c
--- gui/calendar-config.c	7 Apr 2004 16:12:22 -0000	1.68
+++ gui/calendar-config.c	20 Apr 2004 04:22:07 -0000
@@ -613,6 +613,15 @@
 	gconf_client_set_bool (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED, hide, NULL);
 }
 
+guint 
+calendar_config_add_notification_hide_completed_tasks (GConfClientNotifyFunc func, gpointer data)
+{
+	guint id;
+	
+	id = gconf_client_notify_add (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED , func, data, NULL, NULL);
+	
+	return id;	
+}
 
 CalUnits
 calendar_config_get_hide_completed_tasks_units	(void)
@@ -656,6 +665,15 @@
 	g_free (units);
 }
 
+guint 
+calendar_config_add_notification_hide_completed_tasks_units (GConfClientNotifyFunc func, gpointer data)
+{
+	guint id;
+	
+	id = gconf_client_notify_add (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_UNITS , func, data, NULL, NULL);
+	
+	return id;	
+}
 
 gint
 calendar_config_get_hide_completed_tasks_value	(void)
@@ -668,6 +686,16 @@
 calendar_config_set_hide_completed_tasks_value	(gint		value)
 {
 	gconf_client_set_int (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_VALUE, value, NULL);
+}
+
+guint 
+calendar_config_add_notification_hide_completed_tasks_value (GConfClientNotifyFunc func, gpointer data)
+{
+	guint id;
+	
+	id = gconf_client_notify_add (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_VALUE , func, data, NULL, NULL);
+	
+	return id;	
 }
 
 /**
Index: gui/calendar-config.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/calendar-config.h,v
retrieving revision 1.33
diff -u -r1.33 calendar-config.h
--- gui/calendar-config.h	7 Apr 2004 16:12:22 -0000	1.33
+++ gui/calendar-config.h	20 Apr 2004 04:22:07 -0000
@@ -173,12 +173,15 @@
 /* Settings to hide completed tasks. */
 gboolean  calendar_config_get_hide_completed_tasks	(void);
 void	  calendar_config_set_hide_completed_tasks	(gboolean	hide);
+guint	  calendar_config_add_notification_hide_completed_tasks (GConfClientNotifyFunc func, gpointer data);
 
 CalUnits  calendar_config_get_hide_completed_tasks_units(void);
 void	  calendar_config_set_hide_completed_tasks_units(CalUnits	units);
+guint	  calendar_config_add_notification_hide_completed_tasks_units (GConfClientNotifyFunc func, gpointer data);
 
 gint	  calendar_config_get_hide_completed_tasks_value(void);
 void	  calendar_config_set_hide_completed_tasks_value(gint		value);
+guint	  calendar_config_add_notification_hide_completed_tasks_value (GConfClientNotifyFunc func, gpointer data);
 
 char*	  calendar_config_get_hide_completed_tasks_sexp (void);
 
Index: gui/e-tasks.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-tasks.c,v
retrieving revision 1.85
diff -u -r1.85 e-tasks.c
--- gui/e-tasks.c	18 Apr 2004 18:01:19 -0000	1.85
+++ gui/e-tasks.c	20 Apr 2004 04:22:11 -0000
@@ -73,6 +73,7 @@
 	GtkWidget *preview;
 	
 	gchar *current_uid;
+	char *sexp;
 
 	/* View instance and the view menus handler */
 	GalViewInstance *view_instance;
@@ -167,12 +168,26 @@
 	ETasks *tasks;
 	ETasksPrivate *priv;
 	ECalModel *model;
+	char *new_sexp = NULL;
+	char *real_sexp = NULL;
 
 	tasks = E_TASKS (data);
 	priv = tasks->priv;
 
+	if (priv->sexp)
+		g_free (priv->sexp);
+	
+	priv->sexp = g_strdup (sexp);
+	
 	model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
-	e_cal_model_set_search_query (model, sexp);
+		
+	if ((new_sexp = calendar_config_get_hide_completed_tasks_sexp()) != NULL) {
+		real_sexp = g_strdup_printf ("(and %s %s)", new_sexp, sexp);
+		e_cal_model_set_search_query (model, real_sexp);
+		g_free (new_sexp);
+		g_free (real_sexp);
+	} else
+		e_cal_model_set_search_query (model, sexp);
 }
 
 /* Callback used when the selected category in the search bar changes */
@@ -228,6 +243,41 @@
 }
 
 static void
+update_view (ETasks *tasks)
+{
+	ETasksPrivate *priv;
+	ECalModel *model;
+	char *real_sexp = NULL;
+	char *new_sexp = NULL;
+	
+	priv = tasks->priv;
+
+	model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
+		
+	if ((new_sexp = calendar_config_get_hide_completed_tasks_sexp()) != NULL) {
+		real_sexp = g_strdup_printf ("(and %s %s)", new_sexp, priv->sexp);
+		e_cal_model_set_search_query (model, real_sexp);
+		g_free (new_sexp);
+		g_free (real_sexp);
+	} else
+		e_cal_model_set_search_query (model, priv->sexp);
+}
+
+static gboolean
+update_view_cb (ETasks *tasks)
+{	
+	update_view (tasks);
+
+	return TRUE;
+}
+
+static void
+config_hide_completed_tasks_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
+{
+	update_view (data);
+}
+
+static void
 model_row_changed_cb (ETableModel *etm, int row, gpointer data)
 {
 	ETasks *tasks;
@@ -290,6 +340,7 @@
 {
 	ETasksPrivate *priv;
 	guint not;
+	guint idle_id = 0;
 
 	priv = tasks->priv;
 	
@@ -298,6 +349,21 @@
 	
 	not = calendar_config_add_notification_timezone (timezone_changed_cb, tasks);
 	priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
+	
+	not = calendar_config_add_notification_hide_completed_tasks (config_hide_completed_tasks_changed_cb, 
+							      tasks);
+	priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
+	
+	not = calendar_config_add_notification_hide_completed_tasks_units (config_hide_completed_tasks_changed_cb, 
+							      tasks);
+	priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
+	
+	not = calendar_config_add_notification_hide_completed_tasks_value (config_hide_completed_tasks_changed_cb, 
+							      tasks);
+	priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
+	
+	/* Idle check to hide completed items */
+	idle_id = g_timeout_add_full (G_PRIORITY_LOW, 60000, (GSourceFunc) update_view_cb, tasks, NULL);	
 }
 
 #define E_TASKS_TABLE_DEFAULT_STATE					\
@@ -396,7 +462,6 @@
 e_tasks_init (ETasks *tasks)
 {
 	ETasksPrivate *priv;
-	ECalModel *model;
 	
 	priv = g_new0 (ETasksPrivate, 1);
 	tasks->priv = priv;
@@ -409,9 +474,9 @@
 	priv->view_instance = NULL;
 	priv->view_menus = NULL;
 	priv->current_uid = NULL;
+	priv->sexp = g_strdup ("#t");
 
-	model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
-	e_cal_model_set_search_query (model, "#t");
+	update_view (tasks);
 }
 
 /* Callback used when the set of categories changes in the calendar client */
@@ -485,7 +550,12 @@
 			g_free (priv->current_uid);
 			priv->current_uid = NULL;
 		}
-
+	
+		if (priv->sexp) {
+			g_free (priv->sexp);
+			priv->sexp = NULL;
+		}
+	
 		if (priv->tasks_view_config) {
 			g_object_unref (priv->tasks_view_config);
 			priv->tasks_view_config = NULL;
Index: gui/gnome-cal.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/gnome-cal.c,v
retrieving revision 1.320
diff -u -r1.320 gnome-cal.c
--- gui/gnome-cal.c	19 Apr 2004 14:41:32 -0000	1.320
+++ gui/gnome-cal.c	20 Apr 2004 04:22:20 -0000
@@ -117,6 +117,7 @@
 	/* Calendar query for the date navigator */
 	GList       *dn_queries; /* list of CalQueries */
 	char        *sexp;
+	char        *todo_sexp;
 	guint        e_cal_view_timeout;
 	
 	/* This is the view currently shown. We use it to keep track of the
@@ -207,6 +208,8 @@
 
 static void update_query (GnomeCalendar *gcal);
 
+static void update_todo_view (GnomeCalendar *gcal);
+
 
 static GtkVBoxClass *parent_class;
 
@@ -671,6 +674,8 @@
 	}
 
 	g_free (real_sexp);
+	
+	update_todo_view (gcal);
 }
 
 static void
@@ -679,6 +684,7 @@
 	GnomeCalendarPrivate *priv;
 	ECalModel *model;
 	int i;
+	char *new_sexp = NULL;
 
 	g_return_if_fail (gcal != NULL);
 	g_return_if_fail (GNOME_IS_CALENDAR (gcal));
@@ -700,8 +706,19 @@
 		e_cal_model_set_search_query (e_calendar_view_get_model (priv->views[i]), sexp);
 
 	/* Set the query on the task pad */
+	if (priv->todo_sexp)
+		g_free (priv->todo_sexp);
+	
 	model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo));
-	e_cal_model_set_search_query (model, sexp);
+		
+	if ((new_sexp = calendar_config_get_hide_completed_tasks_sexp()) != NULL) {
+		priv->todo_sexp = g_strdup_printf ("(and %s %s)", new_sexp, sexp);
+		e_cal_model_set_search_query (model, priv->todo_sexp);
+		g_free (new_sexp);
+	} else {
+		priv->todo_sexp = g_strdup (sexp);
+		e_cal_model_set_search_query (model, sexp);
+	}
 }
 
 /* Returns the current time, for the ECalendarItem. */
@@ -895,10 +912,52 @@
 }
 
 static void
+update_todo_view (GnomeCalendar *gcal)
+{
+	GnomeCalendarPrivate *priv;
+	ECalModel *model;
+	char *sexp = NULL;
+	
+	priv = gcal->priv;
+	
+	/* Set the query on the task pad */
+	if (priv->todo_sexp) {
+		g_free (priv->todo_sexp);
+	}
+	
+	model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo));
+		
+	if ((sexp = calendar_config_get_hide_completed_tasks_sexp()) != NULL) {
+		priv->todo_sexp = g_strdup_printf ("(and %s %s)", sexp, priv->sexp);
+		e_cal_model_set_search_query (model, priv->todo_sexp);
+		g_free (sexp);
+	} else {
+		priv->todo_sexp = g_strdup (priv->sexp);
+		e_cal_model_set_search_query (model, priv->todo_sexp);
+	}
+	
+}
+
+static gboolean
+update_todo_view_cb (GnomeCalendar *gcal)
+{	
+	update_todo_view(gcal);
+
+	return TRUE;
+}
+
+static void
+config_hide_completed_tasks_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
+{
+	update_todo_view (data);
+}
+
+static void
 setup_config (GnomeCalendar *calendar)
 {
 	GnomeCalendarPrivate *priv;
 	guint not;
+	guint idle_id = 0;
 
 	priv = calendar->priv;
 
@@ -912,6 +971,22 @@
 	not = calendar_config_add_notification_timezone (timezone_changed_cb, calendar);
 	priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
 
+	/* Hide completed tasks */
+	not = calendar_config_add_notification_hide_completed_tasks (config_hide_completed_tasks_changed_cb, 
+							      calendar);
+	priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
+	
+	not = calendar_config_add_notification_hide_completed_tasks_units (config_hide_completed_tasks_changed_cb, 
+							      calendar);
+	priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
+	
+	not = calendar_config_add_notification_hide_completed_tasks_value (config_hide_completed_tasks_changed_cb, 
+							      calendar);
+	priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
+	
+	/* Idle check to hide completed items */
+	idle_id = g_timeout_add_full (G_PRIORITY_LOW, 60000, (GSourceFunc) update_todo_view_cb, calendar, NULL);
+	
 	/* Pane positions */
 	priv->hpane_pos = calendar_config_get_hpane_pos ();
 	priv->vpane_pos = calendar_config_get_vpane_pos ();
@@ -927,7 +1002,7 @@
 	gchar *filename;
 	ETable *etable;
 	int i;
-	
+
 	priv = gcal->priv;
 
 	priv->search_bar = cal_search_bar_new ();
@@ -992,7 +1067,8 @@
 	filename = g_build_filename (calendar_component_peek_config_directory (calendar_component_peek ()),
 				     "TaskPad", NULL);
 	e_calendar_table_load_state (E_CALENDAR_TABLE (priv->todo), filename);
-	e_cal_model_set_search_query (e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)), "#t");
+	
+	update_todo_view (gcal);
 	g_free (filename);
 
 	etable = e_calendar_table_get_table (E_CALENDAR_TABLE (priv->todo));
@@ -1088,6 +1164,7 @@
 
 	priv->dn_queries = NULL;	
 	priv->sexp = g_strdup ("#t"); /* Match all */
+	priv->todo_sexp = g_strdup ("#t");
 
 	priv->view_instance = NULL;
 	priv->view_menus = NULL;
@@ -1180,6 +1257,11 @@
 		if (priv->sexp) {
 			g_free (priv->sexp);
 			priv->sexp = NULL;
+		}
+		
+		if (priv->todo_sexp) {
+			g_free (priv->todo_sexp);
+			priv->todo_sexp = NULL;
 		}
 
 		if (priv->e_cal_view_timeout) {


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