aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGary Ekker <gekker@novell.com>2004-05-01 05:33:11 +0800
committerGary Ekker <gekker@src.gnome.org>2004-05-01 05:33:11 +0800
commit8acc05254177f038ff5f93fed69fac376851a7d8 (patch)
tree22920664c6f513ad105b1e3e0f81103087a684dc
parent343d0d815a4b59c13316e7125ef392be7ccdefcb (diff)
downloadgsoc2013-evolution-8acc05254177f038ff5f93fed69fac376851a7d8.tar
gsoc2013-evolution-8acc05254177f038ff5f93fed69fac376851a7d8.tar.gz
gsoc2013-evolution-8acc05254177f038ff5f93fed69fac376851a7d8.tar.bz2
gsoc2013-evolution-8acc05254177f038ff5f93fed69fac376851a7d8.tar.lz
gsoc2013-evolution-8acc05254177f038ff5f93fed69fac376851a7d8.tar.xz
gsoc2013-evolution-8acc05254177f038ff5f93fed69fac376851a7d8.tar.zst
gsoc2013-evolution-8acc05254177f038ff5f93fed69fac376851a7d8.zip
Set up the model to use the correct query. Setup callbacks for gconf
2004-04-30 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 svn path=/trunk/; revision=25727
-rw-r--r--calendar/ChangeLog15
-rw-r--r--calendar/gui/calendar-config.c28
-rw-r--r--calendar/gui/calendar-config.h3
-rw-r--r--calendar/gui/e-tasks.c75
-rw-r--r--calendar/gui/gnome-cal.c78
5 files changed, 189 insertions, 10 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 297315d513..771b4fcfd9 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,18 @@
+2004-04-30 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-30 Not Zed <NotZed@Ximian.com>
* gui/dialogs/meeting-page.c (get_widgets): make the entry
diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c
index 4f8b7c59e8..e0b10dd87e 100644
--- a/calendar/gui/calendar-config.c
+++ b/calendar/gui/calendar-config.c
@@ -613,6 +613,15 @@ calendar_config_set_hide_completed_tasks (gboolean hide)
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 @@ calendar_config_set_hide_completed_tasks_units (CalUnits cu)
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)
@@ -670,6 +688,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;
+}
+
/**
* calendar_config_get_confirm_delete:
*
diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h
index 238ba55a83..e2dc4405b8 100644
--- a/calendar/gui/calendar-config.h
+++ b/calendar/gui/calendar-config.h
@@ -173,12 +173,15 @@ void calendar_config_set_tasks_overdue_color (const char *color);
/* 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);
diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c
index e48e954c12..729e5456c7 100644
--- a/calendar/gui/e-tasks.c
+++ b/calendar/gui/e-tasks.c
@@ -74,6 +74,7 @@ struct _ETasksPrivate {
GtkWidget *preview;
gchar *current_uid;
+ char *sexp;
/* View instance and the view menus handler */
GalViewInstance *view_instance;
@@ -87,6 +88,7 @@ static void e_tasks_class_init (ETasksClass *class);
static void e_tasks_init (ETasks *tasks);
static void setup_widgets (ETasks *tasks);
static void e_tasks_destroy (GtkObject *object);
+static void update_view (ETasks *tasks);
static void backend_error_cb (ECal *client, const char *message, gpointer data);
@@ -168,12 +170,18 @@ search_bar_sexp_changed_cb (CalSearchBar *cal_search, const char *sexp, gpointer
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 */
@@ -230,6 +238,41 @@ timezone_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer
}
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;
@@ -292,6 +335,7 @@ setup_config (ETasks *tasks)
{
ETasksPrivate *priv;
guint not;
+ guint timeout_id = 0;
priv = tasks->priv;
@@ -300,6 +344,21 @@ setup_config (ETasks *tasks)
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 \
@@ -421,7 +480,6 @@ static void
e_tasks_init (ETasks *tasks)
{
ETasksPrivate *priv;
- ECalModel *model;
priv = g_new0 (ETasksPrivate, 1);
tasks->priv = priv;
@@ -434,9 +492,9 @@ e_tasks_init (ETasks *tasks)
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 */
@@ -502,7 +560,12 @@ e_tasks_destroy (GtkObject *object)
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;
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index de218b4233..b35a524995 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -121,6 +121,7 @@ struct _GnomeCalendarPrivate {
/* 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
@@ -210,6 +211,8 @@ static void gnome_calendar_notify_dates_shown_changed (GnomeCalendar *gcal);
static void update_query (GnomeCalendar *gcal);
+static void update_todo_view (GnomeCalendar *gcal);
+
static GtkVBoxClass *parent_class;
@@ -697,6 +700,8 @@ update_query (GnomeCalendar *gcal)
}
g_free (real_sexp);
+
+ update_todo_view (gcal);
}
static void
@@ -705,6 +710,7 @@ set_search_query (GnomeCalendar *gcal, const char *sexp)
GnomeCalendarPrivate *priv;
ECalModel *model;
int i;
+ char *new_sexp = NULL;
g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
@@ -726,8 +732,7 @@ set_search_query (GnomeCalendar *gcal, const char *sexp)
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. */
@@ -921,10 +926,52 @@ timezone_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer
}
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;
@@ -938,6 +985,22 @@ setup_config (GnomeCalendar *calendar)
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 ();
@@ -953,7 +1016,7 @@ setup_widgets (GnomeCalendar *gcal)
gchar *filename;
ETable *etable;
int i;
-
+
priv = gcal->priv;
priv->search_bar = cal_search_bar_new ();
@@ -1018,7 +1081,8 @@ setup_widgets (GnomeCalendar *gcal)
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));
@@ -1114,6 +1178,7 @@ gnome_calendar_init (GnomeCalendar *gcal)
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;
@@ -1207,6 +1272,11 @@ gnome_calendar_destroy (GtkObject *object)
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) {
g_source_remove (priv->e_cal_view_timeout);