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
This commit is contained in:
8
2003-11-19 03:55:31 +00:00
committed by JP Rosevear
parent 2fc9309f2a
commit 28aef9afc7
6 changed files with 225 additions and 36 deletions

View File

@ -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

View File

@ -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)
{
@ -149,6 +169,28 @@ update_uris_for_selection (CalendarComponent *calendar_component)
g_slist_free (uids_selected);
}
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)
{
@ -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,

View File

@ -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"

View File

@ -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)
{

View File

@ -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);

View File

@ -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)
{
@ -149,6 +169,28 @@ update_uris_for_selection (TasksComponent *component)
g_slist_free (uids_selected);
}
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)
{
@ -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,