diff options
author | JP Rosevear <jpr@ximian.com> | 2004-03-27 04:38:03 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2004-03-27 04:38:03 +0800 |
commit | f231743ff15a88a11d8a9140b357ecef4ca5985b (patch) | |
tree | 35c1d5d2efc8bacbebc989e0d7b2f7403bc7191b /calendar/gui/calendar-component.c | |
parent | 6c4c8684de1fcb81bf1ee3803e9d9b6c204605f8 (diff) | |
download | gsoc2013-evolution-f231743ff15a88a11d8a9140b357ecef4ca5985b.tar.gz gsoc2013-evolution-f231743ff15a88a11d8a9140b357ecef4ca5985b.tar.zst gsoc2013-evolution-f231743ff15a88a11d8a9140b357ecef4ca5985b.zip |
Fixes #55648
2004-03-26 JP Rosevear <jpr@ximian.com>
Fixes #55648
* gui/print.c (print_todo_details): get the default from the model
* gui/gnome-cal.h: remove and update protos
* gui/gnome-cal.c (update_query): the clients and client_list
members are now arrays of source types
(setup_widgets): default the query to everything for tasks, cast
the config items
(gnome_calendar_init): init all the client hashs
(gnome_calendar_destroy): clean them up, clean up all categories
(client_cal_opened_cb): handle based on source type
(append_category_cb): don't track the size in the closure
(client_categories_changed_cb): do all the merging here
(backend_died_cb): handle based on source type
(gnome_calendar_construct): we don't special case the task stuff
any more
(gnome_calendar_get_default_client): return the default of the
current view
(gnome_calendar_add_source): take a source type argument and
append accordingly
(gnome_calendar_remove_source): similar, but remove accordingly
(gnome_calendar_set_default_source): take a source type argument and
set the default accordingly
(gnome_calendar_new_task): use the default of the task model
* gui/e-calendar-view.c (e_calendar_view_add_event): kill warning
* gui/calendar-component.c (update_uris_for_selection): pass
source type when adding/removing
(update_uri_for_primary_selection): ditto
(update_task_selection): make sure we show the correct list of
tasks
(update_primary_task_selection): make sure we track the primary
task correctly
(delete_calendar_cb): pass source type when removing
(config_primary_selection_changed_cb): config listener callback
for tasks
(config_tasks_selection_changed_cb): ditto
(impl_createControls): load the initial task selection, listen for
changes
(calendar_component_init): get the source lists
* gui/calendar-commands.c (sensitize_taskpad_commands): get the
task pad and then the default client from that
svn path=/trunk/; revision=25201
Diffstat (limited to 'calendar/gui/calendar-component.c')
-rw-r--r-- | calendar/gui/calendar-component.c | 98 |
1 files changed, 92 insertions, 6 deletions
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index cac131ed6d..0f6b0393ef 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -76,8 +76,12 @@ struct _CalendarComponentPrivate { GConfClient *gconf_client; int gconf_notify_id; + ESourceList *source_list; GSList *source_selection; + + ESourceList *task_source_list; + GSList *task_source_selection; GnomeCalendar *calendar; GtkWidget *source_selector; @@ -140,13 +144,13 @@ update_uris_for_selection (CalendarComponent *calendar_component) ESource *old_selected_source = l->data; if (!is_in_selection (selection, old_selected_source)) - gnome_calendar_remove_event_source (priv->calendar, old_selected_source); + gnome_calendar_remove_source (priv->calendar, E_CAL_SOURCE_TYPE_EVENT, old_selected_source); } for (l = selection; l; l = l->next) { ESource *selected_source = l->data; - if (gnome_calendar_add_event_source (priv->calendar, selected_source)) + if (gnome_calendar_add_source (priv->calendar, E_CAL_SOURCE_TYPE_EVENT, selected_source)) uids_selected = g_slist_append (uids_selected, (char *) e_source_peek_uid (selected_source)); } @@ -171,7 +175,7 @@ update_uri_for_primary_selection (CalendarComponent *calendar_component) return; /* Set the default */ - gnome_calendar_set_default_source (priv->calendar, source); + gnome_calendar_set_default_source (priv->calendar, E_CAL_SOURCE_TYPE_EVENT, source); /* Make sure we are embedded first */ calendar_control_sensitize_calendar_commands (priv->view_control, priv->calendar, TRUE); @@ -218,6 +222,43 @@ update_selection (CalendarComponent *calendar_component) } static void +update_task_selection (CalendarComponent *calendar_component) +{ + CalendarComponentPrivate *priv; + GSList *uids_selected, *l; + + priv = calendar_component->priv; + + /* Get the selection in gconf */ + uids_selected = calendar_config_get_tasks_selected (); + + /* Remove any that aren't there any more */ + for (l = priv->task_source_selection; l; l = l->next) { + char *uid = l->data; + ESource *source; + + source = e_source_list_peek_source_by_uid (priv->task_source_list, uid); + if (!is_in_uids (uids_selected, source)) + gnome_calendar_remove_source (priv->calendar, E_CAL_SOURCE_TYPE_TODO, source); + + g_free (uid); + } + g_slist_free (priv->task_source_selection); + + /* Make sure the whole selection is there */ + for (l = uids_selected; l; l = l->next) { + char *uid = l->data; + ESource *source; + + source = e_source_list_peek_source_by_uid (priv->task_source_list, uid); + if (!gnome_calendar_add_source (priv->calendar, E_CAL_SOURCE_TYPE_TODO, source)) + /* FIXME do something */; + } + + priv->task_source_selection = uids_selected; +} + +static void update_primary_selection (CalendarComponent *calendar_component) { CalendarComponentPrivate *priv; @@ -242,6 +283,25 @@ update_primary_selection (CalendarComponent *calendar_component) } } +static void +update_primary_task_selection (CalendarComponent *calendar_component) +{ + CalendarComponentPrivate *priv; + ESource *source = NULL; + char *uid; + + priv = calendar_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); + } + + if (source) + gnome_calendar_set_default_source (priv->calendar, E_CAL_SOURCE_TYPE_TODO, source); +} + /* Callbacks. */ static void add_popup_menu_item (GtkMenu *menu, const char *label, const char *pixmap, @@ -324,7 +384,7 @@ delete_calendar_cb (GtkWidget *widget, CalendarComponent *comp) if (e_cal_remove (cal, NULL)) { if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (priv->source_selector), selected_source)) { - gnome_calendar_remove_event_source (priv->calendar, selected_source); + gnome_calendar_remove_source (priv->calendar, E_CAL_SOURCE_TYPE_EVENT, selected_source); e_source_selector_unselect_source (E_SOURCE_SELECTOR (priv->source_selector), selected_source); } @@ -409,6 +469,19 @@ config_primary_selection_changed_cb (GConfClient *client, guint id, GConfEntry * update_primary_selection (data); } +static void +config_tasks_selection_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + update_task_selection (data); +} + + +static void +config_primary_tasks_selection_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + update_primary_task_selection (data); +} + static gboolean init_calendar_publishing_cb (gpointer data) { @@ -810,8 +883,10 @@ 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 update */ + update_task_selection (calendar_component); + update_primary_task_selection (calendar_component); + + /* If the selection changes elsewhere, update it */ not = calendar_config_add_notification_calendars_selected (config_selection_changed_cb, calendar_component); priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); @@ -820,6 +895,14 @@ impl_createControls (PortableServer_Servant servant, calendar_component); priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + not = calendar_config_add_notification_tasks_selected (config_tasks_selection_changed_cb, + calendar_component); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + + not = calendar_config_add_notification_primary_tasks (config_primary_tasks_selection_changed_cb, + calendar_component); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + /* Return the controls */ *corba_sidebar_control = CORBA_Object_duplicate (BONOBO_OBJREF (sidebar_control), ev); *corba_view_control = CORBA_Object_duplicate (BONOBO_OBJREF (priv->view_control), ev); @@ -1046,8 +1129,11 @@ calendar_component_init (CalendarComponent *component) * calendar_component_peek_gconf_client(). */ priv->gconf_client = gconf_client_get_default (); + /* FIXME Use ecal convenience functions */ priv->source_list = e_source_list_new_for_gconf (priv->gconf_client, "/apps/evolution/calendar/sources"); + priv->task_source_list = e_source_list_new_for_gconf (priv->gconf_client, + "/apps/evolution/tasks/sources"); priv->activity_handler = e_activity_handler_new (); |