diff options
author | JP Rosevear <jpr@ximian.com> | 2003-11-15 04:49:01 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2003-11-15 04:49:01 +0800 |
commit | 50a2665bff9c48dc25701194157802e836db9290 (patch) | |
tree | c437b9969f3549bf715a845df73d1861b8896494 /calendar | |
parent | 40711386d6bff4321c410f8dde035c2e1a8527df (diff) | |
download | gsoc2013-evolution-50a2665bff9c48dc25701194157802e836db9290.tar gsoc2013-evolution-50a2665bff9c48dc25701194157802e836db9290.tar.gz gsoc2013-evolution-50a2665bff9c48dc25701194157802e836db9290.tar.bz2 gsoc2013-evolution-50a2665bff9c48dc25701194157802e836db9290.tar.lz gsoc2013-evolution-50a2665bff9c48dc25701194157802e836db9290.tar.xz gsoc2013-evolution-50a2665bff9c48dc25701194157802e836db9290.tar.zst gsoc2013-evolution-50a2665bff9c48dc25701194157802e836db9290.zip |
config accessor (calendar_config_set_calendars_selected): ditto
2003-11-14 JP Rosevear <jpr@ximian.com>
* gui/calendar-config.c (calendar_config_get_calendars_selected):
config accessor
(calendar_config_set_calendars_selected): ditto
(calendar_config_add_notification_calendars_selected): config
notification
* gui/calendar-config.h: add protos
* gui/calendar-config-keys.h: add new key
* gui/calendar-component.c (is_in_uids): util function
(update_uris_for_selection): save the selection in the
configuration
(update_selection): update the selection from the config info
(source_selection_changed_cb): only pass one param
(config_selection_changed_cb): listen for config changes
(impl_dispose): remove config notification
(impl_createControls): use bonobo_exception_set; add a config
notification
2003-11-14 JP Rosevear <jpr@ximian.com>
* test-source-list.c (on_idle_do_stuff): we only need the uid to
remove and peek at stuff
* e-source-list.h: update proto types
* e-source-list.c (e_source_list_peek_source_by_uid): allow peek
by uid only
(e_source_list_remove_source_by_uid): allow removal by uid only
svn path=/trunk/; revision=23362
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 22 | ||||
-rw-r--r-- | calendar/gui/calendar-component.c | 118 | ||||
-rw-r--r-- | calendar/gui/calendar-config-keys.h | 2 | ||||
-rw-r--r-- | calendar/gui/calendar-config.c | 22 | ||||
-rw-r--r-- | calendar/gui/calendar-config.h | 5 |
5 files changed, 147 insertions, 22 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index a01392384c..c4f4fb033e 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,25 @@ +2003-11-14 JP Rosevear <jpr@ximian.com> + + * gui/calendar-config.c (calendar_config_get_calendars_selected): + config accessor + (calendar_config_set_calendars_selected): ditto + (calendar_config_add_notification_calendars_selected): config + notification + + * gui/calendar-config.h: add protos + + * gui/calendar-config-keys.h: add new key + + * gui/calendar-component.c (is_in_uids): util function + (update_uris_for_selection): save the selection in the + configuration + (update_selection): update the selection from the config info + (source_selection_changed_cb): only pass one param + (config_selection_changed_cb): listen for config changes + (impl_dispose): remove config notification + (impl_createControls): use bonobo_exception_set; add a config + notification + 2003-11-13 Ettore Perazzoli <ettore@ximian.com> * gui/tasks-component.c (impl__get_userCreatableItems): New. diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index 4794f3b2ee..24880e98d0 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -27,6 +27,7 @@ #include <string.h> +#include "calendar-config.h" #include "calendar-component.h" #include "calendar-commands.h" #include "gnome-cal.h" @@ -37,6 +38,7 @@ #include <bonobo/bonobo-control.h> #include <bonobo/bonobo-i18n.h> +#include <bonobo/bonobo-exception.h> #include <gtk/gtkimage.h> #include <gtk/gtkimagemenuitem.h> #include <gtk/gtkmessagedialog.h> @@ -65,6 +67,8 @@ struct _CalendarComponentPrivate { GnomeCalendar *calendar; GtkWidget *source_selector; + + guint selected_not; }; @@ -103,16 +107,31 @@ is_in_selection (GSList *selection, ESource *source) return FALSE; } +static gboolean +is_in_uids (GSList *uids, ESource *source) +{ + GSList *l; + + for (l = uids; l; l = l->next) { + const char *uid = l->data; + + if (!strcmp (uid, e_source_peek_uid (source))) + return TRUE; + } + + return FALSE; +} + static void -update_uris_for_selection (ESourceSelector *selector, CalendarComponent *calendar_component) +update_uris_for_selection (CalendarComponent *calendar_component) { CalendarComponentPrivate *priv; - GSList *selection, *l; + GSList *selection, *l, *uids_selected = NULL; - selection = e_source_selector_get_selection (selector); - priv = calendar_component->priv; + selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (priv->source_selector)); + for (l = priv->source_selection; l; l = l->next) { ESource *old_selected_source = l->data; @@ -124,10 +143,52 @@ update_uris_for_selection (ESourceSelector *selector, CalendarComponent *calenda ESource *selected_source = l->data; add_uri_for_source (selected_source, priv->calendar); + uids_selected = g_slist_append (uids_selected, (char *)e_source_peek_uid (selected_source)); } - + e_source_selector_free_selection (priv->source_selection); priv->source_selection = selection; + + /* Save the selection for next time we start up */ + calendar_config_set_calendars_selected (uids_selected); + g_slist_free (uids_selected); +} + +static void +update_selection (CalendarComponent *calendar_component) +{ + CalendarComponentPrivate *priv; + GSList *selection, *uids_selected, *l; + + priv = calendar_component->priv; + + /* Get the selection in gconf */ + uids_selected = calendar_config_get_calendars_selected (); + + /* Remove any that aren't there any more */ + selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (priv->source_selector)); + + for (l = selection; l; l = l->next) { + ESource *source = l->data; + + if (!is_in_uids (uids_selected, source)) + e_source_selector_unselect_source (E_SOURCE_SELECTOR (priv->source_selector), source); + } + + e_source_selector_free_selection (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->source_list, uid); + if (source) + e_source_selector_select_source (E_SOURCE_SELECTOR (priv->source_selector), source); + + g_free (uid); + } + g_slist_free (uids_selected); } /* Callbacks. */ @@ -206,7 +267,7 @@ new_calendar_cb (GtkWidget *widget, ESourceSelector *selector) } static void -fill_popup_menu_callback (ESourceSelector *selector, GtkMenu *menu, CalendarComponent *comp) +fill_popup_menu_cb (ESourceSelector *selector, GtkMenu *menu, CalendarComponent *comp) { add_popup_menu_item (menu, _("New Calendar"), NULL, G_CALLBACK (new_calendar_cb), comp); add_popup_menu_item (menu, _("Delete"), GTK_STOCK_DELETE, G_CALLBACK (delete_calendar_cb), comp); @@ -214,15 +275,15 @@ fill_popup_menu_callback (ESourceSelector *selector, GtkMenu *menu, CalendarComp } static void -source_selection_changed_callback (ESourceSelector *selector, - CalendarComponent *calendar_component) +source_selection_changed_cb (ESourceSelector *selector, + CalendarComponent *calendar_component) { - update_uris_for_selection (selector, calendar_component); + update_uris_for_selection (calendar_component); } static void -primary_source_selection_changed_callback (ESourceSelector *selector, - CalendarComponent *calendar_component) +primary_source_selection_changed_cb (ESourceSelector *selector, + CalendarComponent *calendar_component) { CalendarComponentPrivate *priv; ESource *source; @@ -241,6 +302,12 @@ primary_source_selection_changed_callback (ESourceSelector *selector, } +static void +config_selection_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + update_selection (data); +} + /* GObject methods. */ static void @@ -263,6 +330,11 @@ impl_dispose (GObject *object) priv->gconf_client = NULL; } + if (priv->selected_not) { + calendar_config_remove_notification (priv->selected_not); + priv->selected_not = 0; + } + (* G_OBJECT_CLASS (parent_class)->dispose) (object); } @@ -305,7 +377,7 @@ impl_createControls (PortableServer_Servant servant, GtkWidget *selector_scrolled_window; BonoboControl *sidebar_control; BonoboControl *view_control; - + priv = calendar_component->priv; /* Create sidebar selector */ @@ -328,9 +400,7 @@ impl_createControls (PortableServer_Servant servant, priv->calendar = GNOME_CALENDAR (gnome_calendar_new ()); if (!priv->calendar) { g_warning (G_STRLOC ": could not create the calendar widget!"); - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_Component_Failed, - NULL); + bonobo_exception_set (ev, ex_GNOME_Evolution_Component_Failed); return; } @@ -339,9 +409,7 @@ impl_createControls (PortableServer_Servant servant, view_control = bonobo_control_new (GTK_WIDGET (priv->calendar)); if (!view_control) { g_warning (G_STRLOC ": could not create the control!"); - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_Component_Failed, - NULL); + bonobo_exception_set (ev, ex_GNOME_Evolution_Component_Failed); return; } g_object_set_data (G_OBJECT (priv->calendar), "control", view_control); @@ -349,17 +417,23 @@ impl_createControls (PortableServer_Servant servant, g_signal_connect (view_control, "activate", G_CALLBACK (control_activate_cb), priv->calendar); g_signal_connect_object (priv->source_selector, "selection_changed", - G_CALLBACK (source_selection_changed_callback), + G_CALLBACK (source_selection_changed_cb), G_OBJECT (calendar_component), 0); g_signal_connect_object (priv->source_selector, "primary_selection_changed", - G_CALLBACK (primary_source_selection_changed_callback), + G_CALLBACK (primary_source_selection_changed_cb), G_OBJECT (calendar_component), 0); g_signal_connect_object (priv->source_selector, "fill_popup_menu", - G_CALLBACK (fill_popup_menu_callback), + G_CALLBACK (fill_popup_menu_cb), G_OBJECT (calendar_component), 0); - update_uris_for_selection (E_SOURCE_SELECTOR (priv->source_selector), calendar_component); + /* Load the selection from the last run */ + update_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, + calendar_component); + + /* Return the controls */ *corba_sidebar_control = CORBA_Object_duplicate (BONOBO_OBJREF (sidebar_control), ev); *corba_view_control = CORBA_Object_duplicate (BONOBO_OBJREF (view_control), ev); } diff --git a/calendar/gui/calendar-config-keys.h b/calendar/gui/calendar-config-keys.h index f6e7c023c6..6d0754db6f 100644 --- a/calendar/gui/calendar-config-keys.h +++ b/calendar/gui/calendar-config-keys.h @@ -29,6 +29,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_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" @@ -51,6 +52,7 @@ G_BEGIN_DECLS #define CALENDAR_CONFIG_DN_SHOW_WEEK_NUMBERS CALENDAR_CONFIG_PREFIX "/date_navigator/show_week_numbers" /* Task display settings */ +#define CALENDAR_CONFIG_TASKS_SELECTED_TASKS CALENDAR_CONFIG_PREFIX "/tasks/selected_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 250328fa10..45c54a41fb 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -119,6 +119,28 @@ units_to_string (CalUnits units) * Calendar Settings. */ +GSList * +calendar_config_get_calendars_selected (void) +{ + return gconf_client_get_list (config, CALENDAR_CONFIG_SELECTED_CALENDARS, GCONF_VALUE_STRING, NULL); +} + +void +calendar_config_set_calendars_selected (GSList *selected) +{ + gconf_client_set_list (config, CALENDAR_CONFIG_SELECTED_CALENDARS, GCONF_VALUE_STRING, selected, NULL); +} + +guint +calendar_config_add_notification_calendars_selected (GConfClientNotifyFunc func, gpointer data) +{ + guint id; + + id = gconf_client_notify_add (config, CALENDAR_CONFIG_SELECTED_CALENDARS, 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). */ diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h index ad9c8531e5..8524334116 100644 --- a/calendar/gui/calendar-config.h +++ b/calendar/gui/calendar-config.h @@ -68,6 +68,11 @@ void calendar_config_remove_notification (guint id); * Calendar Settings. */ +/* The current list of calendars selected */ +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 current timezone, e.g. "Europe/London". */ gchar* calendar_config_get_timezone (void); void calendar_config_set_timezone (gchar *timezone); |