diff options
author | 8 <jpr@ximian.com> | 2003-11-19 11:55:31 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2003-11-19 11:55:31 +0800 |
commit | 28aef9afc71eb2d2606171bbc94d72dfa325ed07 (patch) | |
tree | 8e04efa4dc84d2f67f607f7667127a9d45f22633 /calendar/gui/calendar-component.c | |
parent | 2fc9309f2aa4bc82ca97b10a4206170c69411754 (diff) | |
download | gsoc2013-evolution-28aef9afc71eb2d2606171bbc94d72dfa325ed07.tar.gz 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/calendar-component.c')
-rw-r--r-- | calendar/gui/calendar-component.c | 84 |
1 files changed, 69 insertions, 15 deletions
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index 6305cda984..97e6b2654b 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-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 (CalendarComponent *calendar_component) { @@ -150,6 +170,28 @@ update_uris_for_selection (CalendarComponent *calendar_component) } static void +update_uri_for_primary_selection (CalendarComponent *calendar_component) +{ + CalendarComponentPrivate *priv; + ESource *source; + char *uri; + + priv = calendar_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); + gnome_calendar_set_default_uri (priv->calendar, uri); + g_free (uri); + + /* Save the selection for next time we start up */ + calendar_config_set_primary_calendar (e_source_peek_uid (source)); +} + +static void update_selection (CalendarComponent *calendar_component) { CalendarComponentPrivate *priv; @@ -186,6 +228,31 @@ update_selection (CalendarComponent *calendar_component) g_slist_free (uids_selected); } +static void +update_primary_selection (CalendarComponent *calendar_component) +{ + CalendarComponentPrivate *priv; + ESource *source; + char *uid; + + priv = calendar_component->priv; + + uid = calendar_config_get_primary_calendar (); + 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_event (ECal *client, gboolean all_day) @@ -354,21 +421,7 @@ static void primary_source_selection_changed_cb (ESourceSelector *selector, CalendarComponent *calendar_component) { - CalendarComponentPrivate *priv; - ESource *source; - char *uri; - - priv = calendar_component->priv; - - source = e_source_selector_peek_primary_selection (selector); - if (!source) - return; - - /* Set the default */ - uri = e_source_get_uri (source); - gnome_calendar_set_default_uri (priv->calendar, uri); - g_free (uri); - + update_uri_for_primary_selection (calendar_component); } static void @@ -497,6 +550,7 @@ impl_createControls (PortableServer_Servant servant, /* Load the selection from the last run */ update_selection (calendar_component); + update_primary_selection (calendar_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, |