aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2003-11-17 07:18:31 +0800
committerJP Rosevear <jpr@src.gnome.org>2003-11-17 07:18:31 +0800
commit7d9d3e3df88c1696ae8da85f11fa1f908c1a1da1 (patch)
tree1ac868460d4aefcb499ee66a3edc13aafd8fc3a7
parent8b1e261b3e451e1a28176cc1b835634a1a30d0d8 (diff)
downloadgsoc2013-evolution-7d9d3e3df88c1696ae8da85f11fa1f908c1a1da1.tar
gsoc2013-evolution-7d9d3e3df88c1696ae8da85f11fa1f908c1a1da1.tar.gz
gsoc2013-evolution-7d9d3e3df88c1696ae8da85f11fa1f908c1a1da1.tar.bz2
gsoc2013-evolution-7d9d3e3df88c1696ae8da85f11fa1f908c1a1da1.tar.lz
gsoc2013-evolution-7d9d3e3df88c1696ae8da85f11fa1f908c1a1da1.tar.xz
gsoc2013-evolution-7d9d3e3df88c1696ae8da85f11fa1f908c1a1da1.tar.zst
gsoc2013-evolution-7d9d3e3df88c1696ae8da85f11fa1f908c1a1da1.zip
copy in here (update_uris_for_selection): save the selection
2003-11-16 JP Rosevear <jpr@ximian.com> * gui/tasks-component.c (is_in_uids): copy in here (update_uris_for_selection): save the selection (update_selection): update the selection when its changed somewhere else (config_selection_changed_cb): update the selection if the configuration changes (impl_createControls): store the source selector * gui/calendar-config.h: add protos * gui/calendar-config.c (calendar_config_get_tasks_selected): get the list of task lists selected (calendar_config_set_tasks_selected): save it (calendar_config_add_notification_tasks_selected): get notified about it svn path=/trunk/; revision=23374
-rw-r--r--calendar/ChangeLog18
-rw-r--r--calendar/gui/calendar-config.c23
-rw-r--r--calendar/gui/calendar-config.h6
-rw-r--r--calendar/gui/tasks-component.c98
4 files changed, 132 insertions, 13 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index c7c7cae7e5..7183af147d 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,23 @@
2003-11-16 JP Rosevear <jpr@ximian.com>
+ * gui/tasks-component.c (is_in_uids): copy in here
+ (update_uris_for_selection): save the selection
+ (update_selection): update the selection when its changed
+ somewhere else
+ (config_selection_changed_cb): update the selection if the
+ configuration changes
+ (impl_createControls): store the source selector
+
+ * gui/calendar-config.h: add protos
+
+ * gui/calendar-config.c (calendar_config_get_tasks_selected): get
+ the list of task lists selected
+ (calendar_config_set_tasks_selected): save it
+ (calendar_config_add_notification_tasks_selected): get notified
+ about it
+
+2003-11-16 JP Rosevear <jpr@ximian.com>
+
* gui/tasks-component.c (add_uri_for_source): add it via e-tasks
(remove_uri_for_source): remove it via e-tasks
(get_default_task): provide a default for editing
diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c
index 45c54a41fb..913af4acbc 100644
--- a/calendar/gui/calendar-config.c
+++ b/calendar/gui/calendar-config.c
@@ -440,6 +440,29 @@ calendar_config_set_month_vpane_pos (gint vpane_pos)
gconf_client_set_int (config, CALENDAR_CONFIG_MONTH_VPANE_POS, vpane_pos, NULL);
}
+/* The current list of task lists selected */
+GSList *
+calendar_config_get_tasks_selected (void)
+{
+ return gconf_client_get_list (config, CALENDAR_CONFIG_TASKS_SELECTED_TASKS, GCONF_VALUE_STRING, NULL);
+}
+
+void
+calendar_config_set_tasks_selected (GSList *selected)
+{
+ gconf_client_set_list (config, CALENDAR_CONFIG_TASKS_SELECTED_TASKS, GCONF_VALUE_STRING, selected, NULL);
+}
+
+guint
+calendar_config_add_notification_tasks_selected (GConfClientNotifyFunc func, gpointer data)
+{
+ guint id;
+
+ id = gconf_client_notify_add (config, CALENDAR_CONFIG_TASKS_SELECTED_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 8524334116..c7c8dae998 100644
--- a/calendar/gui/calendar-config.h
+++ b/calendar/gui/calendar-config.h
@@ -147,6 +147,12 @@ void calendar_config_set_month_hpane_pos (gint hpane_pos);
gint calendar_config_get_month_vpane_pos (void);
void calendar_config_set_month_vpane_pos (gint vpane_pos);
+/* The current list of task lists selected */
+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 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 ebb671dff8..58448dc646 100644
--- a/calendar/gui/tasks-component.c
+++ b/calendar/gui/tasks-component.c
@@ -38,6 +38,7 @@
#include "e-comp-editor-registry.h"
#include "migration.h"
#include "comp-util.h"
+#include "calendar-config.h"
#include "dialogs/comp-editor.h"
#include "dialogs/task-editor.h"
#include "widgets/misc/e-source-selector.h"
@@ -61,10 +62,13 @@ struct _TasksComponentPrivate {
GSList *source_selection;
ETasks *tasks;
+ GtkWidget *source_selector;
+
+ guint selected_not;
};
/* Utility functions. */
-
+/* FIXME Some of these are duplicated from calendar-component.c */
static void
add_uri_for_source (ESource *source, ETasks *tasks)
{
@@ -98,15 +102,30 @@ 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, TasksComponent *component)
+update_uris_for_selection (TasksComponent *component)
{
TasksComponentPrivate *priv;
- GSList *selection, *l;
+ GSList *selection, *l, *uids_selected = NULL;
- selection = e_source_selector_get_selection (selector);
-
priv = 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;
@@ -119,10 +138,52 @@ update_uris_for_selection (ESourceSelector *selector, TasksComponent *component)
ESource *selected_source = l->data;
add_uri_for_source (selected_source, E_TASKS (priv->tasks));
+ 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_tasks_selected (uids_selected);
+ g_slist_free (uids_selected);
+}
+
+static void
+update_selection (TasksComponent *task_component)
+{
+ TasksComponentPrivate *priv;
+ GSList *selection, *uids_selected, *l;
+
+ priv = task_component->priv;
+
+ /* Get the selection in gconf */
+ uids_selected = calendar_config_get_tasks_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);
}
/* FIXME This is duplicated from comp-editor-factory.c, should it go in comp-util? */
@@ -140,7 +201,7 @@ get_default_task (ECal *ecal)
static void
source_selection_changed_cb (ESourceSelector *selector, TasksComponent *component)
{
- update_uris_for_selection (selector, component);
+ update_uris_for_selection (component);
}
static void
@@ -169,6 +230,12 @@ primary_source_selection_changed_cb (ESourceSelector *selector, TasksComponent *
}
+static void
+config_selection_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
+{
+ update_selection (data);
+}
+
/* GObject methods */
static void
@@ -226,18 +293,17 @@ impl_createControls (PortableServer_Servant servant,
{
TasksComponent *component = TASKS_COMPONENT (bonobo_object_from_servant (servant));
TasksComponentPrivate *priv;
- GtkWidget *selector;
GtkWidget *selector_scrolled_window;
BonoboControl *sidebar_control, *view_control;
priv = component->priv;
/* create sidebar selector */
- selector = e_source_selector_new (priv->source_list);
- gtk_widget_show (selector);
+ priv->source_selector = e_source_selector_new (priv->source_list);
+ gtk_widget_show (priv->source_selector);
selector_scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_container_add (GTK_CONTAINER (selector_scrolled_window), selector);
+ gtk_container_add (GTK_CONTAINER (selector_scrolled_window), priv->source_selector);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (selector_scrolled_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (selector_scrolled_window),
@@ -265,15 +331,21 @@ impl_createControls (PortableServer_Servant servant,
g_signal_connect (view_control, "activate", G_CALLBACK (control_activate_cb), priv->tasks);
- g_signal_connect_object (selector, "selection_changed",
+ g_signal_connect_object (priv->source_selector, "selection_changed",
G_CALLBACK (source_selection_changed_cb),
G_OBJECT (component), 0);
- g_signal_connect_object (selector, "primary_selection_changed",
+ g_signal_connect_object (priv->source_selector, "primary_selection_changed",
G_CALLBACK (primary_source_selection_changed_cb),
G_OBJECT (component), 0);
- update_uris_for_selection (E_SOURCE_SELECTOR (selector), component);
+ /* Load the selection from the last run */
+ update_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,
+ 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);
}