aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/tasks-component.c
diff options
context:
space:
mode:
author8 <jpr@ximian.com>2003-11-19 11:55:31 +0800
committerJP Rosevear <jpr@src.gnome.org>2003-11-19 11:55:31 +0800
commit28aef9afc71eb2d2606171bbc94d72dfa325ed07 (patch)
tree8e04efa4dc84d2f67f607f7667127a9d45f22633 /calendar/gui/tasks-component.c
parent2fc9309f2aa4bc82ca97b10a4206170c69411754 (diff)
downloadgsoc2013-evolution-28aef9afc71eb2d2606171bbc94d72dfa325ed07.tar
gsoc2013-evolution-28aef9afc71eb2d2606171bbc94d72dfa325ed07.tar.gz
gsoc2013-evolution-28aef9afc71eb2d2606171bbc94d72dfa325ed07.tar.bz2
gsoc2013-evolution-28aef9afc71eb2d2606171bbc94d72dfa325ed07.tar.lz
gsoc2013-evolution-28aef9afc71eb2d2606171bbc94d72dfa325ed07.tar.xz
gsoc2013-evolution-28aef9afc71eb2d2606171bbc94d72dfa325ed07.tar.zst
gsoc2013-evolution-28aef9afc71eb2d2606171bbc94d72dfa325ed07.zip
add protos
2003-11-18 <jpr@ximian.com> * gui/calendar-config.h: add protos * gui/calendar-config.c (calendar_config_get_primary_calendar): get the primary calendar (calendar_config_set_primary_calendar): set it (calendar_config_add_notification_primary_calendar): set notifications for it (calendar_config_get_primary_tasks): get the primary task list (calendar_config_set_primary_tasks): set it (calendar_config_add_notification_primary_tasks): set notifications for it * gui/calendar-config-keys.h: add primary keys * gui/calendar-component.c (find_first_source): find any source (update_uri_for_primary_selection): set the default uri and save the source uid (update_primary_selection): set the primary selection (primary_source_selection_changed_cb): use above (impl_createControls): set the primary selection * gui/tasks-component.c: as above svn path=/trunk/; revision=23434
Diffstat (limited to 'calendar/gui/tasks-component.c')
-rw-r--r--calendar/gui/tasks-component.c90
1 files changed, 69 insertions, 21 deletions
diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c
index e548326b3a..95ebd55304 100644
--- a/calendar/gui/tasks-component.c
+++ b/calendar/gui/tasks-component.c
@@ -117,6 +117,26 @@ is_in_uids (GSList *uids, ESource *source)
return FALSE;
}
+static ESource *
+find_first_source (ESourceList *source_list)
+{
+ GSList *groups, *sources, *l, *m;
+
+ groups = e_source_list_peek_groups (source_list);
+ for (l = groups; l; l = l->next) {
+ ESourceGroup *group = l->data;
+
+ sources = e_source_group_peek_sources (group);
+ for (m = sources; m; m = m->next) {
+ ESource *source = m->data;
+
+ return source;
+ }
+ }
+
+ return NULL;
+}
+
static void
update_uris_for_selection (TasksComponent *component)
{
@@ -150,6 +170,28 @@ update_uris_for_selection (TasksComponent *component)
}
static void
+update_uri_for_primary_selection (TasksComponent *component)
+{
+ TasksComponentPrivate *priv;
+ ESource *source;
+ char *uri;
+
+ priv = component->priv;
+
+ source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->source_selector));
+ if (!source)
+ return;
+
+ /* Set the default */
+ uri = e_source_get_uri (source);
+ e_tasks_set_default_uri (priv->tasks, uri);
+ g_free (uri);
+
+ /* Save the selection for next time we start up */
+ calendar_config_set_primary_tasks (e_source_peek_uid (source));
+}
+
+static void
update_selection (TasksComponent *task_component)
{
TasksComponentPrivate *priv;
@@ -186,6 +228,31 @@ update_selection (TasksComponent *task_component)
g_slist_free (uids_selected);
}
+static void
+update_primary_selection (TasksComponent *component)
+{
+ TasksComponentPrivate *priv;
+ ESource *source;
+ char *uid;
+
+ priv = component->priv;
+
+ uid = calendar_config_get_primary_tasks ();
+ if (uid) {
+ source = e_source_list_peek_source_by_uid (priv->source_list, uid);
+ g_free (uid);
+
+ e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (priv->source_selector), source);
+ } else {
+ ESource *source;
+
+ /* Try to create a default if there isn't one */
+ source = find_first_source (priv->source_list);
+ if (source)
+ e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (priv->source_selector), source);
+ }
+}
+
/* FIXME This is duplicated from comp-editor-factory.c, should it go in comp-util? */
static ECalComponent *
get_default_task (ECal *ecal)
@@ -325,27 +392,7 @@ source_selection_changed_cb (ESourceSelector *selector, TasksComponent *componen
static void
primary_source_selection_changed_cb (ESourceSelector *selector, TasksComponent *component)
{
- TasksComponentPrivate *priv;
- ESource *source;
- ECal *client;
- char *uri;
- ECalModel *model;
-
- priv = component->priv;
-
- source = e_source_selector_peek_primary_selection (selector);
- if (!source)
- return;
-
- /* Set the default */
- uri = e_source_get_uri (source);
- model = e_calendar_table_get_model (e_tasks_get_calendar_table (E_TASKS (priv->tasks)));
- client = e_cal_model_get_client_for_uri (model, uri);
- if (client)
- e_cal_model_set_default_client (model, client);
-
- g_free (uri);
-
+ update_uri_for_primary_selection (component);
}
static void
@@ -461,6 +508,7 @@ impl_createControls (PortableServer_Servant servant,
/* Load the selection from the last run */
update_selection (component);
+ update_primary_selection (component);
/* If it gets fiddled with, ie from another evolution window, update it */
priv->selected_not = calendar_config_add_notification_calendars_selected (config_selection_changed_cb,