From 7d20b8fd5fd28a90852c737f35cef7ba03a2c116 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 1 Nov 2010 14:44:23 -0400 Subject: Utilize the new ESourceSelector:primary-selection property. --- addressbook/gui/widgets/e-addressbook-selector.c | 74 +++++------------------- addressbook/gui/widgets/eab-gui-util.c | 4 +- addressbook/importers/evolution-csv-importer.c | 2 +- addressbook/importers/evolution-ldif-importer.c | 2 +- addressbook/importers/evolution-vcard-importer.c | 2 +- 5 files changed, 19 insertions(+), 65 deletions(-) (limited to 'addressbook') 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); } -- cgit v1.2.3