Re: [evolution-patches] 56898 Tasks
- From: Gary Ekker <gekker novell com>
- To: JP Rosevear <jpr ximian com>
- Cc: evolution-patches lists ximian com
- Subject: Re: [evolution-patches] 56898 Tasks
- Date: Mon, 26 Apr 2004 10:20:19 -0600
On Fri, 2004-04-23 at 11:32 -0400, JP Rosevear wrote:
> On Mon, 2004-04-19 at 22:58 -0600, Gary Ekker wrote:
> > 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.
>
> Seems to work, some comments below.
>
> > 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);
> > }
>
> Couldn't we just call update_view here after assigning the priv->sexp?
> Now that I look, storing priv->sexp seems pretty useless doesn't it?
>
> > /* 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);
> > }
>
> A nit, but an idle is a bit different that a timeout (you want the
> timeout though).
>
>
> -JP
>
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2273
diff -u -r1.2273 ChangeLog
--- ChangeLog 23 Apr 2004 19:13:11 -0000 1.2273
+++ ChangeLog 26 Apr 2004 16:23:42 -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-23 Rodney Dawes <dobey ximian com>
* gui/alarm-notify/notify-main.c (main): Call e_icon_factory_init ()
Index: gui/e-tasks.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-tasks.c,v
retrieving revision 1.88
diff -u -r1.88 e-tasks.c
--- gui/e-tasks.c 21 Apr 2004 17:58:09 -0000 1.88
+++ gui/e-tasks.c 26 Apr 2004 16:23:42 -0000
@@ -73,6 +73,7 @@
GtkWidget *preview;
gchar *current_uid;
+ char *sexp;
/* View instance and the view menus handler */
GalViewInstance *view_instance;
@@ -165,12 +166,18 @@
ETasks *tasks;
ETasksPrivate *priv;
ECalModel *model;
+ char *new_sexp = NULL;
+ char *real_sexp = NULL;
tasks = E_TASKS (data);
priv = tasks->priv;
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
- e_cal_model_set_search_query (model, sexp);
+ if (priv->sexp)
+ g_free (priv->sexp);
+
+ priv->sexp = g_strdup (sexp);
+
+ update_view (tasks);
}
/* Callback used when the selected category in the search bar changes */
@@ -227,6 +234,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;
@@ -289,6 +331,7 @@
{
ETasksPrivate *priv;
guint not;
+ guint timeout_id = 0;
priv = tasks->priv;
@@ -297,6 +340,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));
+
+ /* Timeout check to hide completed items */
+ timeout_id = g_timeout_add_full (G_PRIORITY_LOW, 60000, (GSourceFunc) update_view_cb, tasks, NULL);
}
#define E_TASKS_TABLE_DEFAULT_STATE \
@@ -394,7 +452,6 @@
e_tasks_init (ETasks *tasks)
{
ETasksPrivate *priv;
- ECalModel *model;
priv = g_new0 (ETasksPrivate, 1);
tasks->priv = priv;
@@ -407,9 +464,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 */
@@ -475,7 +532,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.322
diff -u -r1.322 gnome-cal.c
--- gui/gnome-cal.c 21 Apr 2004 17:58:09 -0000 1.322
+++ gui/gnome-cal.c 26 Apr 2004 16:23:42 -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
@@ -205,6 +206,8 @@
static void update_query (GnomeCalendar *gcal);
+static void update_todo_view (GnomeCalendar *gcal);
+
static GtkVBoxClass *parent_class;
@@ -669,6 +672,8 @@
}
g_free (real_sexp);
+
+ update_todo_view (gcal);
}
static void
@@ -677,6 +682,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));
@@ -698,8 +704,7 @@
e_cal_model_set_search_query (e_calendar_view_get_model (priv->views[i]), sexp);
/* Set the query on the task pad */
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo));
- e_cal_model_set_search_query (model, sexp);
+ update_todo_view (gcal);
}
/* Returns the current time, for the ECalendarItem. */
@@ -893,10 +898,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 timeout_id = 0;
priv = calendar->priv;
@@ -910,6 +957,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));
+
+ /* Timeout check to hide completed items */
+ timeout_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 ();
@@ -925,7 +988,7 @@
gchar *filename;
ETable *etable;
int i;
-
+
priv = gcal->priv;
priv->search_bar = cal_search_bar_new ();
@@ -990,7 +1053,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));
@@ -1086,6 +1150,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;
@@ -1178,6 +1243,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) {
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 26 Apr 2004 16:23:42 -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/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 26 Apr 2004 16:23:42 -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;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]