aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-11-02 02:44:23 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2010-11-10 06:33:21 +0800
commit26afa6081c3d9826dbae78236dd712fad8b7c340 (patch)
tree531e8587a88bc408b91341a98e20fbd934cbb344
parentf5460f323b2581af28764b96635b2d3a0f1548c9 (diff)
downloadgsoc2013-evolution-26afa6081c3d9826dbae78236dd712fad8b7c340.tar
gsoc2013-evolution-26afa6081c3d9826dbae78236dd712fad8b7c340.tar.gz
gsoc2013-evolution-26afa6081c3d9826dbae78236dd712fad8b7c340.tar.bz2
gsoc2013-evolution-26afa6081c3d9826dbae78236dd712fad8b7c340.tar.lz
gsoc2013-evolution-26afa6081c3d9826dbae78236dd712fad8b7c340.tar.xz
gsoc2013-evolution-26afa6081c3d9826dbae78236dd712fad8b7c340.tar.zst
gsoc2013-evolution-26afa6081c3d9826dbae78236dd712fad8b7c340.zip
Utilize the new ESourceSelector:primary-selection property.
-rw-r--r--addressbook/gui/widgets/e-addressbook-selector.c74
-rw-r--r--addressbook/gui/widgets/eab-gui-util.c4
-rw-r--r--addressbook/importers/evolution-csv-importer.c2
-rw-r--r--addressbook/importers/evolution-ldif-importer.c2
-rw-r--r--addressbook/importers/evolution-vcard-importer.c2
-rw-r--r--calendar/gui/apps_evolution_calendar.schemas.in15
-rw-r--r--calendar/importers/icalendar-importer.c4
-rw-r--r--doc/reference/shell/tmpl/e-util.sgml4
-rw-r--r--e-util/e-util.c81
-rw-r--r--e-util/e-util.h16
-rw-r--r--modules/addressbook/apps_evolution_addressbook.schemas.in14
-rw-r--r--modules/addressbook/e-book-shell-settings.c4
-rw-r--r--modules/addressbook/e-book-shell-sidebar.c19
-rw-r--r--modules/addressbook/e-book-shell-view-actions.c4
-rw-r--r--modules/addressbook/e-book-shell-view-private.c2
-rw-r--r--modules/calendar/e-cal-attachment-handler.c2
-rw-r--r--modules/calendar/e-cal-shell-sidebar.c45
-rw-r--r--modules/calendar/e-cal-shell-view-actions.c10
-rw-r--r--modules/calendar/e-memo-shell-sidebar.c45
-rw-r--r--modules/calendar/e-memo-shell-view-actions.c10
-rw-r--r--modules/calendar/e-task-shell-sidebar.c45
-rw-r--r--modules/calendar/e-task-shell-view-actions.c10
-rw-r--r--plugins/contacts-map/contacts-map.c2
-rw-r--r--plugins/save-calendar/csv-format.c2
-rw-r--r--plugins/save-calendar/ical-format.c2
-rw-r--r--plugins/save-calendar/rdf-format.c2
26 files changed, 224 insertions, 198 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-selector.c b/addressbook/gui/widgets/e-addressbook-selector.c
index d746964364..2402b00e84 100644
--- a/addressbook/gui/widgets/e-addressbook-selector.c
+++ b/addressbook/gui/widgets/e-addressbook-selector.c
@@ -29,9 +29,6 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_ADDRESSBOOK_SELECTOR, EAddressbookSelectorPrivate))
-#define PRIMARY_ADDRESSBOOK_KEY \
- "/apps/evolution/addressbook/display/primary_addressbook"
-
typedef struct _MergeContext MergeContext;
struct _EAddressbookSelectorPrivate {
@@ -149,45 +146,26 @@ addressbook_selector_merge_next_cb (EBook *book,
static void
addressbook_selector_load_primary_source (ESourceSelector *selector)
{
- GConfClient *client;
ESourceList *source_list;
ESource *source = NULL;
- const gchar *key;
- gchar *uid;
-
- /* XXX If ESourceSelector had a "primary-uid" property,
- * we could just bind the GConf key to it. */
+ GSList *groups;
source_list = e_source_selector_get_source_list (selector);
- client = gconf_client_get_default ();
- key = PRIMARY_ADDRESSBOOK_KEY;
- uid = gconf_client_get_string (client, key, NULL);
- g_object_unref (client);
-
- if (uid != NULL) {
- source = e_source_list_peek_source_by_uid (source_list, uid);
- g_free (uid);
- }
-
- if (source == NULL) {
- GSList *groups;
-
- /* Dig up the first source in the source list.
- * XXX libedataserver should provide API for this. */
- groups = e_source_list_peek_groups (source_list);
- while (groups != NULL) {
- ESourceGroup *source_group = groups->data;
- GSList *sources;
-
- sources = e_source_group_peek_sources (source_group);
- if (sources != NULL) {
- source = sources->data;
- break;
- }
-
- groups = g_slist_next (groups);
+ /* Dig up the first source in the source list.
+ * XXX libedataserver should provide API for this. */
+ groups = e_source_list_peek_groups (source_list);
+ while (groups != NULL) {
+ ESourceGroup *source_group = groups->data;
+ GSList *sources;
+
+ sources = e_source_group_peek_sources (source_group);
+ if (sources != NULL) {
+ source = sources->data;
+ break;
}
+
+ groups = g_slist_next (groups);
}
if (source != NULL)
@@ -254,28 +232,6 @@ addressbook_selector_constructed (GObject *object)
addressbook_selector_load_primary_source (selector);
}
-static void
-addressbook_selector_primary_selection_changed (ESourceSelector *selector)
-{
- ESource *source;
- GConfClient *client;
- const gchar *key;
- const gchar *string;
-
- /* XXX If ESourceSelector had a "primary-uid" property,
- * we could just bind the GConf key to it. */
-
- source = e_source_selector_peek_primary_selection (selector);
- if (source == NULL)
- return;
-
- client = gconf_client_get_default ();
- key = PRIMARY_ADDRESSBOOK_KEY;
- string = e_source_peek_uid (source);
- gconf_client_set_string (client, key, string, NULL);
- g_object_unref (client);
-}
-
static gboolean
addressbook_selector_data_dropped (ESourceSelector *selector,
GtkSelectionData *selection_data,
@@ -341,8 +297,6 @@ addressbook_selector_class_init (EAddressbookSelectorClass *class)
object_class->constructed = addressbook_selector_constructed;
selector_class = E_SOURCE_SELECTOR_CLASS (class);
- selector_class->primary_selection_changed =
- addressbook_selector_primary_selection_changed;
selector_class->data_dropped = addressbook_selector_data_dropped;
g_object_class_install_property (
diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c
index ebf4558f50..51e00fd17d 100644
--- a/addressbook/gui/widgets/eab-gui-util.c
+++ b/addressbook/gui/widgets/eab-gui-util.c
@@ -218,7 +218,7 @@ source_selection_changed_cb (ESourceSelector *selector, GtkWidget *ok_button)
ESource *except_source = NULL, *selected;
except_source = g_object_get_data (G_OBJECT (ok_button), "except-source");
- selected = e_source_selector_peek_primary_selection (selector);
+ selected = e_source_selector_get_primary_selection (selector);
gtk_widget_set_sensitive (ok_button, selected && selected != except_source);
}
@@ -274,7 +274,7 @@ eab_select_source (ESource *except_source, const gchar *title, const gchar *mess
response = gtk_dialog_run (GTK_DIALOG (dialog));
if (response == GTK_RESPONSE_ACCEPT)
- source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (selector));
+ source = e_source_selector_get_primary_selection (E_SOURCE_SELECTOR (selector));
else
source = NULL;
diff --git a/addressbook/importers/evolution-csv-importer.c b/addressbook/importers/evolution-csv-importer.c
index 3e86679c96..970ada7fd6 100644
--- a/addressbook/importers/evolution-csv-importer.c
+++ b/addressbook/importers/evolution-csv-importer.c
@@ -727,7 +727,7 @@ static void
primary_selection_changed_cb (ESourceSelector *selector, EImportTarget *target)
{
g_datalist_set_data_full(&target->data, "csv-source",
- g_object_ref (e_source_selector_peek_primary_selection (selector)),
+ g_object_ref (e_source_selector_get_primary_selection (selector)),
g_object_unref);
}
diff --git a/addressbook/importers/evolution-ldif-importer.c b/addressbook/importers/evolution-ldif-importer.c
index 246eebc9ee..15627bad5a 100644
--- a/addressbook/importers/evolution-ldif-importer.c
+++ b/addressbook/importers/evolution-ldif-importer.c
@@ -525,7 +525,7 @@ static void
primary_selection_changed_cb (ESourceSelector *selector, EImportTarget *target)
{
g_datalist_set_data_full(&target->data, "ldif-source",
- g_object_ref (e_source_selector_peek_primary_selection (selector)),
+ g_object_ref (e_source_selector_get_primary_selection (selector)),
g_object_unref);
}
diff --git a/addressbook/importers/evolution-vcard-importer.c b/addressbook/importers/evolution-vcard-importer.c
index efdf3b362c..5cad56a767 100644
--- a/addressbook/importers/evolution-vcard-importer.c
+++ b/addressbook/importers/evolution-vcard-importer.c
@@ -385,7 +385,7 @@ static void
primary_selection_changed_cb (ESourceSelector *selector, EImportTarget *target)
{
g_datalist_set_data_full(&target->data, "vcard-source",
- g_object_ref (e_source_selector_peek_primary_selection (selector)),
+ g_object_ref (e_source_selector_get_primary_selection (selector)),
g_object_unref);
}
diff --git a/calendar/gui/apps_evolution_calendar.schemas.in b/calendar/gui/apps_evolution_calendar.schemas.in
index 70590ee0ca..c37bbbd1fb 100644
--- a/calendar/gui/apps_evolution_calendar.schemas.in
+++ b/calendar/gui/apps_evolution_calendar.schemas.in
@@ -10,7 +10,10 @@
<type>string</type>
<locale name="C">
<short>Primary calendar</short>
- <long>URI of the highlighted ("primary") calendar</long>
+ <long>
+ The UID of the selected (or "primary") calendar in the
+ sidebar of the "Calendar" view.
+ </long>
</locale>
</schema>
@@ -512,7 +515,10 @@
<type>string</type>
<locale name="C">
<short>Primary memo list</short>
- <long>URI of the highlighted ("primary") memo list</long>
+ <long>
+ The UID of the selected (or "primary") memo list in the
+ sidebar of the "Memos" view.
+ </long>
</locale>
</schema>
@@ -525,7 +531,10 @@
<type>string</type>
<locale name="C">
<short>Primary task list</short>
- <long>URI of the highlighted ("primary") task list</long>
+ <long>
+ The UID of the selected (or "primary") task list in the
+ sidebar of the "Tasks" view.
+ </long>
</locale>
</schema>
diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c
index 45de793778..8e20e19bcf 100644
--- a/calendar/importers/icalendar-importer.c
+++ b/calendar/importers/icalendar-importer.c
@@ -206,7 +206,7 @@ static void
button_toggled_cb (GtkWidget *widget, struct _selector_data *sd)
{
g_datalist_set_data_full(&sd->target->data, "primary-source",
- g_object_ref (e_source_selector_peek_primary_selection ((ESourceSelector *)sd->selector)),
+ g_object_ref (e_source_selector_get_primary_selection ((ESourceSelector *)sd->selector)),
g_object_unref);
g_datalist_set_data(&sd->target->data, "primary-type", GINT_TO_POINTER(import_type_map[sd->page]));
gtk_notebook_set_current_page ((GtkNotebook *)sd->notebook, sd->page);
@@ -216,7 +216,7 @@ static void
primary_selection_changed_cb (ESourceSelector *selector, EImportTarget *target)
{
g_datalist_set_data_full(&target->data, "primary-source",
- g_object_ref (e_source_selector_peek_primary_selection (selector)),
+ g_object_ref (e_source_selector_get_primary_selection (selector)),
g_object_unref);
}
diff --git a/doc/reference/shell/tmpl/e-util.sgml b/doc/reference/shell/tmpl/e-util.sgml
index 01810abbc2..c784438e40 100644
--- a/doc/reference/shell/tmpl/e-util.sgml
+++ b/doc/reference/shell/tmpl/e-util.sgml
@@ -343,7 +343,7 @@ Miscellaneous Utilities
@binding:
@source_value:
@target_value:
-@user_data:
+@not_used:
@Returns:
@@ -355,7 +355,7 @@ Miscellaneous Utilities
@binding:
@source_value:
@target_value:
-@user_data:
+@not_used:
@Returns:
diff --git a/e-util/e-util.c b/e-util/e-util.c
index f27b3f3660..abc6ccc377 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -1507,7 +1507,7 @@ e_util_set_source_combo_box_list (GtkWidget *source_combo_box,
* @binding: a #GBinding
* @source_value: a #GValue of type #GDK_TYPE_COLOR
* @target_value: a #GValue of type #G_TYPE_STRING
- * @user_data: not used
+ * @not_used: not used
*
* Transforms a #GdkColor value to a color string specification.
*
@@ -1517,7 +1517,7 @@ gboolean
e_binding_transform_color_to_string (GBinding *binding,
const GValue *source_value,
GValue *target_value,
- gpointer user_data)
+ gpointer not_used)
{
const GdkColor *color;
gchar *string;
@@ -1537,7 +1537,7 @@ e_binding_transform_color_to_string (GBinding *binding,
* @binding: a #GBinding
* @source_value: a #GValue of type #G_TYPE_STRING
* @target_value: a #GValue of type #GDK_TYPE_COLOR
- * @user_data: not used
+ * @not_used: not used
*
* Transforms a color string specification to a #GdkColor.
*
@@ -1547,7 +1547,7 @@ gboolean
e_binding_transform_string_to_color (GBinding *binding,
const GValue *source_value,
GValue *target_value,
- gpointer user_data)
+ gpointer not_used)
{
GdkColor color;
const gchar *string;
@@ -1563,3 +1563,76 @@ e_binding_transform_string_to_color (GBinding *binding,
return success;
}
+
+/**
+ * e_binding_transform_source_to_uid:
+ * @binding: a #GBinding
+ * @source_value: a #GValue of type #E_TYPE_SOURCE
+ * @target_value: a #GValue of type #G_TYPE_STRING
+ * @source_list: an #ESourceList
+ *
+ * Transforms an #ESource object to its UID string.
+ *
+ * Returns: %TRUE if @source_value was an #ESource object
+ **/
+gboolean
+e_binding_transform_source_to_uid (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ ESourceList *source_list)
+{
+ ESource *source;
+ const gchar *string;
+ gboolean success = FALSE;
+
+ g_return_val_if_fail (G_IS_BINDING (binding), FALSE);
+ g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), FALSE);
+
+ source = g_value_get_object (source_value);
+ if (E_IS_SOURCE (source)) {
+ string = e_source_peek_uid (source);
+ g_value_set_string (target_value, string);
+ success = TRUE;
+ }
+
+ return success;
+}
+
+/**
+ * e_binding_transform_uid_to_source:
+ * @binding: a #GBinding
+ * @source_value: a #GValue of type #G_TYPE_STRING
+ * @target_value: a #GValue of type #E_TYPE_SOURCe
+ * @source_list: an #ESourceList
+ *
+ * Transforms an #ESource UID string to the corresponding #ESource object
+ * in @source_list.
+ *
+ * Returns: %TRUE if @source_list had an #ESource object with a matching
+ * UID string
+ **/
+gboolean
+e_binding_transform_uid_to_source (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ ESourceList *source_list)
+{
+ ESource *source;
+ const gchar *string;
+ gboolean success = FALSE;
+
+ g_return_val_if_fail (G_IS_BINDING (binding), FALSE);
+ g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), FALSE);
+
+ string = g_value_get_string (source_value);
+ if (string == NULL || *string == '\0')
+ return FALSE;
+
+ source = e_source_list_peek_source_by_uid (source_list, string);
+ if (source != NULL) {
+ g_value_set_object (target_value, source);
+ success = TRUE;
+ }
+
+ return success;
+}
diff --git a/e-util/e-util.h b/e-util/e-util.h
index d4f29c9c34..4e982bf248 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -31,6 +31,8 @@
#include <e-util/e-marshal.h>
#include <e-util/e-util-enums.h>
+#include <libedataserver/e-source-list.h>
+
/* e_get_user_data_dir() used to live here, so #include its new home
* for backward-compatibility (not that we really care about that). */
#include <libedataserver/e-data-server-util.h>
@@ -148,12 +150,22 @@ gboolean e_binding_transform_color_to_string
(GBinding *binding,
const GValue *source_value,
GValue *target_value,
- gpointer user_data);
+ gpointer not_used);
gboolean e_binding_transform_string_to_color
(GBinding *binding,
const GValue *source_value,
GValue *target_value,
- gpointer user_data);
+ gpointer not_used);
+gboolean e_binding_transform_source_to_uid
+ (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ ESourceList *source_list);
+gboolean e_binding_transform_uid_to_source
+ (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ ESourceList *source_list);
G_END_DECLS
diff --git a/modules/addressbook/apps_evolution_addressbook.schemas.in b/modules/addressbook/apps_evolution_addressbook.schemas.in
index 7ce3902c82..03e6006527 100644
--- a/modules/addressbook/apps_evolution_addressbook.schemas.in
+++ b/modules/addressbook/apps_evolution_addressbook.schemas.in
@@ -73,6 +73,20 @@
</schema>
<schema>
+ <key>/schemas/apps/evolution/addressbook/display/primary_addressbook</key>
+ <applyto>/apps/evolution/addressbook/display/primary_addressbook</applyto>
+ <owner>evolution-addressbook</owner>
+ <type>string</type>
+ <locale name="C">
+ <short>Primary address book</short>
+ <long>
+ The UID of the selected (or "primary") address book in the
+ sidebar of the "Contacts" view.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/evolution/addressbook/display/hpane_position</key>
<applyto>/apps/evolution/addressbook/display/hpane_position</applyto>
<owner>evolution-addressbook</owner>
diff --git a/modules/addressbook/e-book-shell-settings.c b/modules/addressbook/e-book-shell-settings.c
index 6d6802a1a2..d8d86b5d82 100644
--- a/modules/addressbook/e-book-shell-settings.c
+++ b/modules/addressbook/e-book-shell-settings.c
@@ -27,4 +27,8 @@ e_book_shell_backend_init_settings (EShell *shell)
e_shell_settings_install_property_for_key (
"book-completion-show-address",
"/apps/evolution/addressbook/completion/show_address");
+
+ e_shell_settings_install_property_for_key (
+ "book-primary-selection",
+ "/apps/evolution/addressbook/display/primary_addressbook");
}
diff --git a/modules/addressbook/e-book-shell-sidebar.c b/modules/addressbook/e-book-shell-sidebar.c
index 5ff6c2902c..3c61f5e55d 100644
--- a/modules/addressbook/e-book-shell-sidebar.c
+++ b/modules/addressbook/e-book-shell-sidebar.c
@@ -24,6 +24,8 @@
#include <string.h>
#include <glib/gi18n.h>
+#include <e-util/e-util.h>
+
#include "e-book-shell-view.h"
#include "e-book-shell-backend.h"
#include "e-addressbook-selector.h"
@@ -81,9 +83,11 @@ static void
book_shell_sidebar_constructed (GObject *object)
{
EBookShellSidebarPrivate *priv;
+ EShell *shell;
EShellView *shell_view;
EShellBackend *shell_backend;
EShellSidebar *shell_sidebar;
+ EShellSettings *shell_settings;
ESourceList *source_list;
GtkContainer *container;
GtkWidget *widget;
@@ -97,6 +101,9 @@ book_shell_sidebar_constructed (GObject *object)
shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
shell_backend = e_shell_view_get_shell_backend (shell_view);
+ shell = e_shell_backend_get_shell (shell_backend);
+ shell_settings = e_shell_get_shell_settings (shell);
+
source_list = e_book_shell_backend_get_source_list (
E_BOOK_SHELL_BACKEND (shell_backend));
@@ -118,6 +125,16 @@ book_shell_sidebar_constructed (GObject *object)
gtk_container_add (GTK_CONTAINER (container), widget);
priv->selector = g_object_ref (widget);
gtk_widget_show (widget);
+
+ g_object_bind_property_full (
+ shell_settings, "book-primary-selection",
+ widget, "primary-selection",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE,
+ (GBindingTransformFunc) e_binding_transform_uid_to_source,
+ (GBindingTransformFunc) e_binding_transform_source_to_uid,
+ g_object_ref (source_list),
+ (GDestroyNotify) g_object_unref);
}
static guint32
@@ -132,7 +149,7 @@ book_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
book_shell_sidebar = E_BOOK_SHELL_SIDEBAR (shell_sidebar);
selector = e_book_shell_sidebar_get_selector (book_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
if (source != NULL) {
const gchar *uri;
diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c
index 9c13e599a7..7dec37968d 100644
--- a/modules/addressbook/e-book-shell-view-actions.c
+++ b/modules/addressbook/e-book-shell-view-actions.c
@@ -65,7 +65,7 @@ action_address_book_delete_cb (GtkAction *action,
book_shell_sidebar = book_shell_view->priv->book_shell_sidebar;
selector = e_book_shell_sidebar_get_selector (book_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (source != NULL);
response = e_alert_run_dialog_for_args (
@@ -179,7 +179,7 @@ action_address_book_properties_cb (GtkAction *action,
book_shell_sidebar = book_shell_view->priv->book_shell_sidebar;
selector = e_book_shell_sidebar_get_selector (book_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (source != NULL);
uid = e_source_peek_uid (source);
diff --git a/modules/addressbook/e-book-shell-view-private.c b/modules/addressbook/e-book-shell-view-private.c
index 542c4e1178..097e6128d5 100644
--- a/modules/addressbook/e-book-shell-view-private.c
+++ b/modules/addressbook/e-book-shell-view-private.c
@@ -226,7 +226,7 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view,
shell_window = e_shell_view_get_shell_window (shell_view);
book_shell_content = book_shell_view->priv->book_shell_content;
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
if (source == NULL)
return;
diff --git a/modules/calendar/e-cal-attachment-handler.c b/modules/calendar/e-cal-attachment-handler.c
index 8fd2080769..a9f5237ecc 100644
--- a/modules/calendar/e-cal-attachment-handler.c
+++ b/modules/calendar/e-cal-attachment-handler.c
@@ -296,7 +296,7 @@ attachment_handler_run_dialog (GtkWindow *parent,
if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
goto exit;
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
if (source == NULL)
goto exit;
diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c
index 965cc9fa60..66a1102cb7 100644
--- a/modules/calendar/e-cal-shell-sidebar.c
+++ b/modules/calendar/e-cal-shell-sidebar.c
@@ -406,31 +406,12 @@ static void
cal_shell_sidebar_primary_selection_changed_cb (ECalShellSidebar *cal_shell_sidebar,
ESourceSelector *selector)
{
- EShell *shell;
- EShellView *shell_view;
- EShellWindow *shell_window;
- EShellSidebar *shell_sidebar;
- EShellSettings *shell_settings;
ESource *source;
- /* XXX ESourceSelector needs a "primary-selection-uid" property
- * so we can just bind the property with GConfBridge. */
-
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
if (source == NULL)
return;
- shell_sidebar = E_SHELL_SIDEBAR (cal_shell_sidebar);
- shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- shell = e_shell_window_get_shell (shell_window);
- shell_settings = e_shell_get_shell_settings (shell);
-
- e_shell_settings_set_string (
- shell_settings, "cal-primary-calendar",
- e_source_peek_uid (source));
-
cal_shell_sidebar_set_default (cal_shell_sidebar, source);
}
@@ -451,7 +432,6 @@ cal_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
GSList *list, *iter;
GObject *object;
const gchar *key;
- gchar *uid;
priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar);
@@ -477,19 +457,20 @@ cal_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
G_CALLBACK (cal_shell_sidebar_primary_selection_changed_cb),
shell_sidebar);
- source = NULL;
- uid = e_shell_settings_get_string (
- shell_settings, "cal-primary-calendar");
- if (uid != NULL)
- source = e_source_list_peek_source_by_uid (source_list, uid);
- if (source == NULL)
- source = e_source_list_peek_source_any (source_list);
- if (source != NULL)
- e_source_selector_set_primary_selection (selector, source);
- g_free (uid);
+ g_object_bind_property_full (
+ shell_settings, "cal-primary-calendar",
+ selector, "primary-selection",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE,
+ (GBindingTransformFunc) e_binding_transform_uid_to_source,
+ (GBindingTransformFunc) e_binding_transform_source_to_uid,
+ g_object_ref (source_list),
+ (GDestroyNotify) g_object_unref);
list = calendar_config_get_calendars_selected ();
for (iter = list; iter != NULL; iter = iter->next) {
+ gchar *uid;
+
uid = iter->data;
source = e_source_list_peek_source_by_uid (source_list, uid);
g_free (uid);
@@ -733,7 +714,7 @@ cal_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
cal_shell_sidebar = E_CAL_SHELL_SIDEBAR (shell_sidebar);
selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
if (source != NULL) {
ECal *client;
diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c
index 16b5ecfb34..bce4fc4266 100644
--- a/modules/calendar/e-cal-shell-view-actions.c
+++ b/modules/calendar/e-cal-shell-view-actions.c
@@ -42,7 +42,7 @@ action_calendar_copy_cb (GtkAction *action,
cal_shell_sidebar = cal_shell_view->priv->cal_shell_sidebar;
selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (E_IS_SOURCE (source));
copy_source_dialog (
@@ -84,7 +84,7 @@ action_calendar_delete_cb (GtkAction *action,
cal_shell_sidebar = cal_shell_view->priv->cal_shell_sidebar;
selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (E_IS_SOURCE (source));
/* Ask for confirmation. */
@@ -268,7 +268,7 @@ action_calendar_properties_cb (GtkAction *action,
cal_shell_sidebar = cal_shell_view->priv->cal_shell_sidebar;
selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (E_IS_SOURCE (source));
/* XXX Does this -really- need a source group parameter? */
@@ -370,7 +370,7 @@ action_calendar_refresh_cb (GtkAction *action,
model = e_cal_shell_content_get_model (cal_shell_content);
selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (E_IS_SOURCE (source));
uri = e_source_get_uri (source);
@@ -415,7 +415,7 @@ action_calendar_select_one_cb (GtkAction *action,
cal_shell_sidebar = cal_shell_view->priv->cal_shell_sidebar;
selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
- primary = e_source_selector_peek_primary_selection (selector);
+ primary = e_source_selector_get_primary_selection (selector);
g_return_if_fail (primary != NULL);
e_source_selector_select_exclusive (selector, primary);
diff --git a/modules/calendar/e-memo-shell-sidebar.c b/modules/calendar/e-memo-shell-sidebar.c
index f463394fbd..04292af2fd 100644
--- a/modules/calendar/e-memo-shell-sidebar.c
+++ b/modules/calendar/e-memo-shell-sidebar.c
@@ -400,31 +400,12 @@ static void
memo_shell_sidebar_primary_selection_changed_cb (EMemoShellSidebar *memo_shell_sidebar,
ESourceSelector *selector)
{
- EShell *shell;
- EShellView *shell_view;
- EShellWindow *shell_window;
- EShellSidebar *shell_sidebar;
- EShellSettings *shell_settings;
ESource *source;
- /* XXX ESourceSelector needs a "primary-selection-uid" property
- * so we can just bind the property with GConfBridge. */
-
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
if (source == NULL)
return;
- shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar);
- shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- shell = e_shell_window_get_shell (shell_window);
- shell_settings = e_shell_get_shell_settings (shell);
-
- e_shell_settings_set_string (
- shell_settings, "cal-primary-memo-list",
- e_source_peek_uid (source));
-
memo_shell_sidebar_set_default (memo_shell_sidebar, source);
}
@@ -442,7 +423,6 @@ memo_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
ESource *source;
GtkTreeModel *model;
GSList *list, *iter;
- gchar *uid;
priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar);
@@ -468,19 +448,20 @@ memo_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
G_CALLBACK (memo_shell_sidebar_primary_selection_changed_cb),
shell_sidebar);
- source = NULL;
- uid = e_shell_settings_get_string (
- shell_settings, "cal-primary-memo-list");
- if (uid != NULL)
- source = e_source_list_peek_source_by_uid (source_list, uid);
- if (source == NULL)
- source = e_source_list_peek_source_any (source_list);
- if (source != NULL)
- e_source_selector_set_primary_selection (selector, source);
- g_free (uid);
+ g_object_bind_property_full (
+ shell_settings, "cal-primary-memo-list",
+ selector, "primary-selection",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE,
+ (GBindingTransformFunc) e_binding_transform_uid_to_source,
+ (GBindingTransformFunc) e_binding_transform_source_to_uid,
+ g_object_ref (source_list),
+ (GDestroyNotify) g_object_unref);
list = calendar_config_get_memos_selected ();
for (iter = list; iter != NULL; iter = iter->next) {
+ gchar *uid;
+
uid = iter->data;
source = e_source_list_peek_source_by_uid (source_list, uid);
g_free (uid);
@@ -635,7 +616,7 @@ memo_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
memo_shell_sidebar = E_MEMO_SHELL_SIDEBAR (shell_sidebar);
selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
if (source != NULL) {
ECal *client;
diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c
index a30d0f1b1f..bebeba1110 100644
--- a/modules/calendar/e-memo-shell-view-actions.c
+++ b/modules/calendar/e-memo-shell-view-actions.c
@@ -112,7 +112,7 @@ action_memo_list_copy_cb (GtkAction *action,
memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (E_IS_SOURCE (source));
copy_source_dialog (
@@ -152,7 +152,7 @@ action_memo_list_delete_cb (GtkAction *action,
memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (E_IS_SOURCE (source));
/* Ask for confirmation. */
@@ -249,7 +249,7 @@ action_memo_list_properties_cb (GtkAction *action,
memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (E_IS_SOURCE (source));
calendar_setup_edit_memo_list (GTK_WINDOW (shell_window), source);
@@ -274,7 +274,7 @@ action_memo_list_refresh_cb (GtkAction *action,
model = e_memo_shell_content_get_memo_model (memo_shell_content);
selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (E_IS_SOURCE (source));
uri = e_source_get_uri (source);
@@ -319,7 +319,7 @@ action_memo_list_select_one_cb (GtkAction *action,
memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
- primary = e_source_selector_peek_primary_selection (selector);
+ primary = e_source_selector_get_primary_selection (selector);
g_return_if_fail (primary != NULL);
e_source_selector_select_exclusive (selector, primary);
diff --git a/modules/calendar/e-task-shell-sidebar.c b/modules/calendar/e-task-shell-sidebar.c
index b50e463e8a..580cee286f 100644
--- a/modules/calendar/e-task-shell-sidebar.c
+++ b/modules/calendar/e-task-shell-sidebar.c
@@ -400,31 +400,12 @@ static void
task_shell_sidebar_primary_selection_changed_cb (ETaskShellSidebar *task_shell_sidebar,
ESourceSelector *selector)
{
- EShell *shell;
- EShellView *shell_view;
- EShellWindow *shell_window;
- EShellSidebar *shell_sidebar;
- EShellSettings *shell_settings;
ESource *source;
- /* XXX ESourceSelector needs a "primary-selection-uid" property
- * so we can just bind the property with GConfBridge. */
-
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
if (source == NULL)
return;
- shell_sidebar = E_SHELL_SIDEBAR (task_shell_sidebar);
- shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- shell = e_shell_window_get_shell (shell_window);
- shell_settings = e_shell_get_shell_settings (shell);
-
- e_shell_settings_set_string (
- shell_settings, "cal-primary-task-list",
- e_source_peek_uid (source));
-
task_shell_sidebar_set_default (task_shell_sidebar, source);
}
@@ -442,7 +423,6 @@ task_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
ESource *source;
GtkTreeModel *model;
GSList *list, *iter;
- gchar *uid;
priv = E_TASK_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar);
@@ -468,19 +448,20 @@ task_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
G_CALLBACK (task_shell_sidebar_primary_selection_changed_cb),
shell_sidebar);
- source = NULL;
- uid = e_shell_settings_get_string (
- shell_settings, "cal-primary-task-list");
- if (uid != NULL)
- source = e_source_list_peek_source_by_uid (source_list, uid);
- if (source == NULL)
- source = e_source_list_peek_source_any (source_list);
- if (source != NULL)
- e_source_selector_set_primary_selection (selector, source);
- g_free (uid);
+ g_object_bind_property_full (
+ shell_settings, "cal-primary-task-list",
+ selector, "primary-selection",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE,
+ (GBindingTransformFunc) e_binding_transform_uid_to_source,
+ (GBindingTransformFunc) e_binding_transform_source_to_uid,
+ g_object_ref (source_list),
+ (GDestroyNotify) g_object_unref);
list = calendar_config_get_tasks_selected ();
for (iter = list; iter != NULL; iter = iter->next) {
+ gchar *uid;
+
uid = iter->data;
source = e_source_list_peek_source_by_uid (source_list, uid);
g_free (uid);
@@ -635,7 +616,7 @@ task_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
task_shell_sidebar = E_TASK_SHELL_SIDEBAR (shell_sidebar);
selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
if (source != NULL) {
ECal *client;
diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c
index b792c829bc..8ab9082ee0 100644
--- a/modules/calendar/e-task-shell-view-actions.c
+++ b/modules/calendar/e-task-shell-view-actions.c
@@ -135,7 +135,7 @@ action_task_list_copy_cb (GtkAction *action,
task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (E_IS_SOURCE (source));
copy_source_dialog (
@@ -175,7 +175,7 @@ action_task_list_delete_cb (GtkAction *action,
task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (E_IS_SOURCE (source));
/* Ask for confirmation. */
@@ -272,7 +272,7 @@ action_task_list_properties_cb (GtkAction *action,
task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (E_IS_SOURCE (source));
calendar_setup_edit_task_list (GTK_WINDOW (shell_window), source);
@@ -297,7 +297,7 @@ action_task_list_refresh_cb (GtkAction *action,
model = e_task_shell_content_get_task_model (task_shell_content);
selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (E_IS_SOURCE (source));
uri = e_source_get_uri (source);
@@ -342,7 +342,7 @@ action_task_list_select_one_cb (GtkAction *action,
task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
- primary = e_source_selector_peek_primary_selection (selector);
+ primary = e_source_selector_get_primary_selection (selector);
g_return_if_fail (primary != NULL);
e_source_selector_select_exclusive (selector, primary);
diff --git a/plugins/contacts-map/contacts-map.c b/plugins/contacts-map/contacts-map.c
index bb46be65e6..24297e0243 100644
--- a/plugins/contacts-map/contacts-map.c
+++ b/plugins/contacts-map/contacts-map.c
@@ -112,7 +112,7 @@ show_map_general (ESourceSelector *selector)
gdouble *min_lng = NULL;
gdouble *max_lng = NULL;
- primary_source = (ESource*)e_source_selector_peek_primary_selection (selector);
+ primary_source = (ESource*)e_source_selector_get_primary_selection (selector);
uri = e_source_get_uri (primary_source);
book = e_book_new_from_uri (uri, NULL);
diff --git a/plugins/save-calendar/csv-format.c b/plugins/save-calendar/csv-format.c
index 58dd9ac5af..6b147d88a2 100644
--- a/plugins/save-calendar/csv-format.c
+++ b/plugins/save-calendar/csv-format.c
@@ -327,7 +327,7 @@ do_save_calendar_csv (FormatHandler *handler,
if (!dest_uri)
return;
- primary_source = e_source_selector_peek_primary_selection (selector);
+ primary_source = e_source_selector_get_primary_selection (selector);
/* open source client */
source_client = e_auth_new_cal_from_source (primary_source, type);
diff --git a/plugins/save-calendar/ical-format.c b/plugins/save-calendar/ical-format.c
index 2458a14c1d..fa4f6a5515 100644
--- a/plugins/save-calendar/ical-format.c
+++ b/plugins/save-calendar/ical-format.c
@@ -90,7 +90,7 @@ do_save_calendar_ical (FormatHandler *handler, ESourceSelector *selector, ECalSo
GList *objects;
icalcomponent *top_level = NULL;
- primary_source = e_source_selector_peek_primary_selection (selector);
+ primary_source = e_source_selector_get_primary_selection (selector);
if (!dest_uri)
return;
diff --git a/plugins/save-calendar/rdf-format.c b/plugins/save-calendar/rdf-format.c
index 8014fe9ddf..462f4f2a31 100644
--- a/plugins/save-calendar/rdf-format.c
+++ b/plugins/save-calendar/rdf-format.c
@@ -191,7 +191,7 @@ do_save_calendar_rdf (FormatHandler *handler, ESourceSelector *selector, ECalSou
if (!dest_uri)
return;
- primary_source = e_source_selector_peek_primary_selection (selector);
+ primary_source = e_source_selector_get_primary_selection (selector);
/* open source client */
source_client = e_auth_new_cal_from_source (primary_source, type);