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 | |
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
-rw-r--r-- | calendar/ChangeLog | 25 | ||||
-rw-r--r-- | calendar/gui/calendar-component.c | 84 | ||||
-rw-r--r-- | calendar/gui/calendar-config-keys.h | 2 | ||||
-rw-r--r-- | calendar/gui/calendar-config.c | 50 | ||||
-rw-r--r-- | calendar/gui/calendar-config.h | 10 | ||||
-rw-r--r-- | calendar/gui/tasks-component.c | 90 |
6 files changed, 225 insertions, 36 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 0cf8d90886..4d45314a24 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,28 @@ +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 + 2003-11-18 JP Rosevear <jpr@ximian.com> * gui/Makefile.am: remove db3 include 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, diff --git a/calendar/gui/calendar-config-keys.h b/calendar/gui/calendar-config-keys.h index 6d0754db6f..55181d2769 100644 --- a/calendar/gui/calendar-config-keys.h +++ b/calendar/gui/calendar-config-keys.h @@ -30,6 +30,7 @@ G_BEGIN_DECLS /* Display settings */ #define CALENDAR_CONFIG_TIMEZONE CALENDAR_CONFIG_PREFIX "/display/timezone" #define CALENDAR_CONFIG_SELECTED_CALENDARS CALENDAR_CONFIG_PREFIX "/display/selected_calendars" +#define CALENDAR_CONFIG_PRIMARY_CALENDAR CALENDAR_CONFIG_PREFIX "/display/primary_calendar" #define CALENDAR_CONFIG_24HOUR CALENDAR_CONFIG_PREFIX "/display/use_24hour_format" #define CALENDAR_CONFIG_WEEK_START CALENDAR_CONFIG_PREFIX "/display/week_start_day" #define CALENDAR_CONFIG_DAY_START_HOUR CALENDAR_CONFIG_PREFIX "/display/day_start_hour" @@ -53,6 +54,7 @@ G_BEGIN_DECLS /* Task display settings */ #define CALENDAR_CONFIG_TASKS_SELECTED_TASKS CALENDAR_CONFIG_PREFIX "/tasks/selected_tasks" +#define CALENDAR_CONFIG_PRIMARY_TASKS CALENDAR_CONFIG_PREFIX "/display/primary_tasks" #define CALENDAR_CONFIG_TASKS_HIDE_COMPLETED CALENDAR_CONFIG_PREFIX "/tasks/hide_completed" #define CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_UNITS CALENDAR_CONFIG_PREFIX "/tasks/hide_completed_units" #define CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_VALUE CALENDAR_CONFIG_PREFIX "/tasks/hide_completed_value" diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index 913af4acbc..3c12c381ac 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -119,6 +119,7 @@ units_to_string (CalUnits units) * Calendar Settings. */ +/* The current list of calendars selected */ GSList * calendar_config_get_calendars_selected (void) { @@ -141,6 +142,31 @@ calendar_config_add_notification_calendars_selected (GConfClientNotifyFunc func, return id; } +/* The primary calendar */ +char * +calendar_config_get_primary_calendar (void) +{ + return gconf_client_get_string (config, CALENDAR_CONFIG_PRIMARY_CALENDAR, NULL); +} + +void +calendar_config_set_primary_calendar (const char *primary_uid) +{ + gconf_client_set_string (config, CALENDAR_CONFIG_PRIMARY_CALENDAR, primary_uid, NULL); +} + + +guint +calendar_config_add_notification_primary_calendar (GConfClientNotifyFunc func, gpointer data) +{ + guint id; + + id = gconf_client_notify_add (config, CALENDAR_CONFIG_PRIMARY_CALENDAR, func, data, NULL, NULL); + + return id; +} + + /* The current timezone, e.g. "Europe/London". It may be NULL, in which case you should assume UTC (though Evolution will show the timezone-setting dialog the next time a calendar or task folder is selected). */ @@ -463,6 +489,30 @@ calendar_config_add_notification_tasks_selected (GConfClientNotifyFunc func, gpo return id; } +/* The primary task list */ +char * +calendar_config_get_primary_tasks (void) +{ + return gconf_client_get_string (config, CALENDAR_CONFIG_PRIMARY_TASKS, NULL); +} + +void +calendar_config_set_primary_tasks (const char *primary_uid) +{ + gconf_client_set_string (config, CALENDAR_CONFIG_PRIMARY_TASKS, primary_uid, NULL); +} + + +guint +calendar_config_add_notification_primary_tasks (GConfClientNotifyFunc func, gpointer data) +{ + guint id; + + id = gconf_client_notify_add (config, CALENDAR_CONFIG_PRIMARY_TASKS, func, data, NULL, NULL); + + return id; +} + gint calendar_config_get_task_vpane_pos (void) { diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h index c7c8dae998..ff34febd91 100644 --- a/calendar/gui/calendar-config.h +++ b/calendar/gui/calendar-config.h @@ -73,6 +73,11 @@ GSList *calendar_config_get_calendars_selected (void); void calendar_config_set_calendars_selected (GSList *selected); guint calendar_config_add_notification_calendars_selected (GConfClientNotifyFunc func, gpointer data); +/* The primary calendar */ +char *calendar_config_get_primary_calendar (void); +void calendar_config_set_primary_calendar (const char *primary_uid); +guint calendar_config_add_notification_primary_calendar (GConfClientNotifyFunc func, gpointer data); + /* The current timezone, e.g. "Europe/London". */ gchar* calendar_config_get_timezone (void); void calendar_config_set_timezone (gchar *timezone); @@ -152,6 +157,11 @@ GSList *calendar_config_get_tasks_selected (void); void calendar_config_set_tasks_selected (GSList *selected); guint calendar_config_add_notification_tasks_selected (GConfClientNotifyFunc func, gpointer data); +/* The primary calendar */ +char *calendar_config_get_primary_tasks (void); +void calendar_config_set_primary_tasks (const char *primary_uid); +guint calendar_config_add_notification_primary_tasks (GConfClientNotifyFunc func, gpointer data); + /* The pane position */ gint calendar_config_get_task_vpane_pos (void); void calendar_config_set_task_vpane_pos (gint vpane_pos); 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, |