[evolution-data-server/account-mgmt: 34/43] Adapt ESourceSelectorDialog to the new ESource API.



commit 909d35840c3fa739161b58730f081063388eaad9
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Dec 5 14:43:50 2010 -0600

    Adapt ESourceSelectorDialog to the new ESource API.

 .../libedataserverui/libedataserverui-sections.txt |    4 +-
 libedataserverui/e-name-selector-dialog.c          |  111 ++++++-
 libedataserverui/e-name-selector-dialog.h          |    6 +-
 libedataserverui/e-source-selector-dialog.c        |  340 ++++++++++++++------
 libedataserverui/e-source-selector-dialog.h        |   11 +-
 5 files changed, 352 insertions(+), 120 deletions(-)
---
diff --git a/docs/reference/libedataserverui/libedataserverui-sections.txt b/docs/reference/libedataserverui/libedataserverui-sections.txt
index 6e4beca..9e25bfa 100644
--- a/docs/reference/libedataserverui/libedataserverui-sections.txt
+++ b/docs/reference/libedataserverui/libedataserverui-sections.txt
@@ -231,6 +231,7 @@ e_name_selector_get_type
 <TITLE>ENameSelectorDialog</TITLE>
 ENameSelectorDialog
 e_name_selector_dialog_new
+e_name_selector_dialog_get_registry
 e_name_selector_dialog_peek_model
 e_name_selector_dialog_set_model
 e_name_selector_dialog_set_destination_index
@@ -433,8 +434,9 @@ e_source_selector_get_type
 <TITLE>ESourceSelectorDialog</TITLE>
 ESourceSelectorDialog
 e_source_selector_dialog_new
+e_source_selector_dialog_get_registry
+e_source_selector_dialog_get_extension_name
 e_source_selector_dialog_get_selector
-e_source_selector_dialog_select_default_source
 e_source_selector_dialog_peek_primary_selection
 <SUBSECTION Standard>
 E_SOURCE_SELECTOR_DIALOG
diff --git a/libedataserverui/e-name-selector-dialog.c b/libedataserverui/e-name-selector-dialog.c
index 36ad38b..6d1388d 100644
--- a/libedataserverui/e-name-selector-dialog.c
+++ b/libedataserverui/e-name-selector-dialog.c
@@ -32,13 +32,13 @@
 
 #include <libedataserver/e-sexp.h>
 #include <libedataserver/e-categories.h>
+#include <libedataserver/e-source-address-book.h>
 
 #include <libebackend/e-extensible.h>
 
 #include <libebook/e-book-client.h>
 #include <libebook/e-book-client-view.h>
 #include <libebook/e-book-query.h>
-#include <libebook/e-source-address-book.h>
 
 #include "e-source-combo-box.h"
 #include "e-destination-store.h"
@@ -69,6 +69,7 @@ typedef struct {
 } SelData;
 
 struct _ENameSelectorDialogPrivate {
+	ESourceRegistry *registry;
 	ENameSelectorModel *name_selector_model;
 	GtkTreeModelSort *contact_sort;
 	GCancellable *cancellable;
@@ -88,6 +89,11 @@ struct _ENameSelectorDialogPrivate {
 	GtkSizeGroup *dest_label_size_group;
 };
 
+enum {
+	PROP_0,
+	PROP_REGISTRY
+};
+
 static void     search_changed                (ENameSelectorDialog *name_selector_dialog);
 static void     source_changed                (ENameSelectorDialog *name_selector_dialog, ESourceComboBox *source_combo_box);
 static void     transfer_button_clicked       (ENameSelectorDialog *name_selector_dialog, GtkButton *transfer_button);
@@ -148,11 +154,65 @@ name_selector_dialog_populate_categories (ENameSelectorDialog *name_selector_dia
 }
 
 static void
+name_selector_dialog_set_registry (ENameSelectorDialog *name_selector_dialog,
+                                   ESourceRegistry *registry)
+{
+	g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+	g_return_if_fail (name_selector_dialog->priv->registry == NULL);
+
+	name_selector_dialog->priv->registry = g_object_ref (registry);
+}
+
+static void
+name_selector_dialog_set_property (GObject *object,
+                                   guint property_id,
+                                   const GValue *value,
+                                   GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_REGISTRY:
+			name_selector_dialog_set_registry (
+				E_NAME_SELECTOR_DIALOG (object),
+				g_value_get_object (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+name_selector_dialog_get_property (GObject *object,
+                                   guint property_id,
+                                   GValue *value,
+                                   GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_REGISTRY:
+			g_value_set_object (
+				value,
+				e_name_selector_dialog_get_registry (
+				E_NAME_SELECTOR_DIALOG (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
 name_selector_dialog_dispose (GObject *object)
 {
+	ENameSelectorDialogPrivate *priv;
+
+	priv = E_NAME_SELECTOR_DIALOG_GET_PRIVATE (object);
+
 	remove_books (E_NAME_SELECTOR_DIALOG (object));
 	shutdown_name_selector_model (E_NAME_SELECTOR_DIALOG (object));
 
+	if (priv->registry != NULL) {
+		g_object_unref (priv->registry);
+		priv->registry = NULL;
+	}
+
 	/* Chain up to parent's dispose() method. */
 	G_OBJECT_CLASS (e_name_selector_dialog_parent_class)->dispose (object);
 }
@@ -183,6 +243,7 @@ name_selector_dialog_constructed (GObject *object)
 	GtkTreeViewColumn *column;
 	GtkCellRenderer   *cell_renderer;
 	GtkTreeSelection  *selection;
+	ESource *source;
 	gchar *tmp_str;
 	GtkWidget *name_selector_box;
 	GtkWidget *show_contacts_label;
@@ -210,7 +271,7 @@ name_selector_dialog_constructed (GObject *object)
 	GtkWidget *destination_box;
 	GtkWidget *status_message;
 	GtkWidget *source_combo;
-	ESourceRegistry *registry;
+	const gchar *extension_name;
 
 	priv = E_NAME_SELECTOR_DIALOG_GET_PRIVATE (object);
 
@@ -359,7 +420,7 @@ name_selector_dialog_constructed (GObject *object)
 	g_object_unref (G_OBJECT (tmp_relation));
 	g_object_unref (G_OBJECT (tmp_relation_set));
 
-	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (name_selector_dialog))), name_selector_box, TRUE, TRUE, 0);
+	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (object))), name_selector_box, TRUE, TRUE, 0);
 
 	/* Store pointers to relevant widgets */
 
@@ -411,11 +472,11 @@ name_selector_dialog_constructed (GObject *object)
 
 	/* Create source menu */
 
-	registry = e_source_registry_get_default ();
-	source_combo = e_source_combo_box_new (registry, "address-book");
+	extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
+	source_combo = e_source_combo_box_new (priv->registry, extension_name);
 	g_signal_connect_swapped (
 		source_combo, "changed",
-		G_CALLBACK (source_changed), name_selector_dialog);
+		G_CALLBACK (source_changed), object);
 
 	gtk_label_set_mnemonic_widget (GTK_LABEL (AddressBookLabel), source_combo);
 	gtk_widget_show (source_combo);
@@ -432,7 +493,10 @@ name_selector_dialog_constructed (GObject *object)
 
 	/* Display initial source */
 
-	/* TODO: Remember last used source */
+	source = e_source_registry_ref_default_address_book (priv->registry);
+	e_source_combo_box_set_active (
+		E_SOURCE_COMBO_BOX (source_combo), source);
+	g_object_unref (source);
 
 	/* Set up dialog defaults */
 
@@ -463,9 +527,23 @@ e_name_selector_dialog_class_init (ENameSelectorDialogClass *class)
 	g_type_class_add_private (class, sizeof (ENameSelectorDialogPrivate));
 
 	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = name_selector_dialog_set_property;
+	object_class->get_property = name_selector_dialog_get_property;
 	object_class->dispose = name_selector_dialog_dispose;
 	object_class->finalize = name_selector_dialog_finalize;
 	object_class->constructed = name_selector_dialog_constructed;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_REGISTRY,
+		g_param_spec_object (
+			"registry",
+			"Registry",
+			"Data source registry",
+			E_TYPE_SOURCE_REGISTRY,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
 }
 
 static void
@@ -477,15 +555,29 @@ e_name_selector_dialog_init (ENameSelectorDialog *name_selector_dialog)
 
 /**
  * e_name_selector_dialog_new:
+ * @registry: an #ESourceRegistry
  *
  * Creates a new #ENameSelectorDialog.
  *
  * Returns: A new #ENameSelectorDialog.
  **/
 ENameSelectorDialog *
-e_name_selector_dialog_new (void)
+e_name_selector_dialog_new (ESourceRegistry *registry)
 {
-	return g_object_new (E_TYPE_NAME_SELECTOR_DIALOG, NULL);
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
+	return g_object_new (
+		E_TYPE_NAME_SELECTOR_DIALOG,
+		"registry", registry, NULL);
+}
+
+ESourceRegistry *
+e_name_selector_dialog_get_registry (ENameSelectorDialog *name_selector_dialog)
+{
+	g_return_val_if_fail (
+		E_IS_NAME_SELECTOR_DIALOG (name_selector_dialog), NULL);
+
+	return name_selector_dialog->priv->registry;
 }
 
 /* --------- *
@@ -1005,7 +1097,6 @@ source_changed (ENameSelectorDialog *name_selector_dialog,
 	/* Start loading selected book */
 	e_client_utils_open_new (
 		source, E_CLIENT_SOURCE_TYPE_CONTACTS, TRUE, cancellable,
-		e_client_utils_authenticate_handler, parent,
 		book_loaded_cb, g_object_ref (name_selector_dialog));
 
 	g_object_unref (source);
diff --git a/libedataserverui/e-name-selector-dialog.h b/libedataserverui/e-name-selector-dialog.h
index 3138eeb..35d93b3 100644
--- a/libedataserverui/e-name-selector-dialog.h
+++ b/libedataserverui/e-name-selector-dialog.h
@@ -25,6 +25,7 @@
 #define E_NAME_SELECTOR_DIALOG_H
 
 #include <gtk/gtk.h>
+#include <libedataserver/e-source-registry.h>
 #include <libedataserverui/e-contact-store.h>
 #include <libedataserverui/e-name-selector-model.h>
 
@@ -64,7 +65,10 @@ struct _ENameSelectorDialogClass {
 
 GType		e_name_selector_dialog_get_type	(void);
 ENameSelectorDialog *
-		e_name_selector_dialog_new	(void);
+		e_name_selector_dialog_new	(ESourceRegistry *registry);
+ESourceRegistry *
+		e_name_selector_dialog_get_registry
+						(ENameSelectorDialog *name_selector_dialog);
 ENameSelectorModel *
 		e_name_selector_dialog_peek_model
 						(ENameSelectorDialog *name_selector_dialog);
diff --git a/libedataserverui/e-source-selector-dialog.c b/libedataserverui/e-source-selector-dialog.c
index 604e1e1..1699a93 100644
--- a/libedataserverui/e-source-selector-dialog.c
+++ b/libedataserverui/e-source-selector-dialog.c
@@ -34,9 +34,17 @@
 	((obj), E_TYPE_SOURCE_SELECTOR_DIALOG, ESourceSelectorDialogPrivate))
 
 struct _ESourceSelectorDialogPrivate {
-	GtkWidget *source_selector;
-	ESourceList *source_list;
+	GtkWidget *selector;
+	ESourceRegistry *registry;
 	ESource *selected_source;
+	gchar *extension_name;
+};
+
+enum {
+	PROP_0,
+	PROP_EXTENSION_NAME,
+	PROP_REGISTRY,
+	PROP_SELECTOR
 };
 
 G_DEFINE_TYPE (
@@ -72,15 +80,11 @@ primary_selection_changed_cb (ESourceSelector *selector,
 		except_source = g_object_get_data (
 			G_OBJECT (dialog), "except-source");
 
-		if (except_source != NULL) {
-			const gchar *except_uid, *selected_uid;
-
-			except_uid = e_source_get_uid (except_source);
-			selected_uid = e_source_get_uid (priv->selected_source);
-
-			if (except_uid && selected_uid && g_str_equal (except_uid, selected_uid))
+		if (except_source != NULL)
+			if (e_source_equal (except_source, priv->selected_source)) {
+				g_object_unref (priv->selected_source);
 				priv->selected_source = NULL;
-		}
+			}
 	}
 
 	gtk_dialog_set_response_sensitive (
@@ -89,15 +93,90 @@ primary_selection_changed_cb (ESourceSelector *selector,
 }
 
 static void
+source_selector_dialog_set_extension_name (ESourceSelectorDialog *dialog,
+                                           const gchar *extension_name)
+{
+	g_return_if_fail (extension_name != NULL);
+	g_return_if_fail (dialog->priv->extension_name == NULL);
+
+	dialog->priv->extension_name = g_strdup (extension_name);
+}
+
+static void
+source_selector_dialog_set_registry (ESourceSelectorDialog *dialog,
+                                     ESourceRegistry *registry)
+{
+	g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+	g_return_if_fail (dialog->priv->registry == NULL);
+
+	dialog->priv->registry = g_object_ref (registry);
+}
+
+static void
+source_selector_dialog_set_property (GObject *object,
+                                     guint property_id,
+                                     const GValue *value,
+                                     GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_EXTENSION_NAME:
+			source_selector_dialog_set_extension_name (
+				E_SOURCE_SELECTOR_DIALOG (object),
+				g_value_get_string (value));
+			return;
+
+		case PROP_REGISTRY:
+			source_selector_dialog_set_registry (
+				E_SOURCE_SELECTOR_DIALOG (object),
+				g_value_get_object (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+source_selector_dialog_get_property (GObject *object,
+                                     guint property_id,
+                                     GValue *value,
+                                     GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_EXTENSION_NAME:
+			g_value_set_string (
+				value,
+				e_source_selector_dialog_get_extension_name (
+				E_SOURCE_SELECTOR_DIALOG (object)));
+			return;
+
+		case PROP_REGISTRY:
+			g_value_set_object (
+				value,
+				e_source_selector_dialog_get_registry (
+				E_SOURCE_SELECTOR_DIALOG (object)));
+			return;
+
+		case PROP_SELECTOR:
+			g_value_set_object (
+				value,
+				e_source_selector_dialog_get_selector (
+				E_SOURCE_SELECTOR_DIALOG (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
 source_selector_dialog_dispose (GObject *object)
 {
 	ESourceSelectorDialogPrivate *priv;
 
 	priv = E_SOURCE_SELECTOR_DIALOG_GET_PRIVATE (object);
 
-	if (priv->source_list) {
-		g_object_unref (priv->source_list);
-		priv->source_list = NULL;
+	if (priv->registry != NULL) {
+		g_object_unref (priv->registry);
+		priv->registry = NULL;
 	}
 
 	if (priv->selected_source != NULL) {
@@ -110,62 +189,28 @@ source_selector_dialog_dispose (GObject *object)
 }
 
 static void
-source_selector_dialog_constructed (GObject *object)
+source_selector_dialog_finalize (GObject *object)
 {
-	ESourceSelectorDialog *dialog;
-	GtkWidget *action_area;
-	GtkWidget *content_area;
-
-	dialog = E_SOURCE_SELECTOR_DIALOG (object);
-
-	action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
-	content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+	ESourceSelectorDialogPrivate *priv;
 
-	/* prepare the dialog */
-	gtk_window_set_title (GTK_WINDOW (dialog), _("Select destination"));
-	gtk_window_set_default_size (GTK_WINDOW (dialog), 320, 240);
-	gtk_container_set_border_width (GTK_CONTAINER (content_area), 0);
-	gtk_container_set_border_width (GTK_CONTAINER (action_area), 12);
-	gtk_dialog_add_buttons (GTK_DIALOG (dialog),
-				GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-				GTK_STOCK_OK, GTK_RESPONSE_OK,
-				NULL);
-	gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-	gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
-}
+	priv = E_SOURCE_SELECTOR_DIALOG_GET_PRIVATE (object);
 
-static void
-e_source_selector_dialog_class_init (ESourceSelectorDialogClass *class)
-{
-	GObjectClass *object_class;
+	g_free (priv->extension_name);
 
-	g_type_class_add_private (class, sizeof (ESourceSelectorDialogPrivate));
-
-	object_class = G_OBJECT_CLASS (class);
-	object_class->dispose = source_selector_dialog_dispose;
-	object_class->constructed = source_selector_dialog_constructed;
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (e_source_selector_dialog_parent_class)->finalize (object);
 }
 
 static void
-e_source_selector_dialog_init (ESourceSelectorDialog *dialog)
-{
-	dialog->priv = E_SOURCE_SELECTOR_DIALOG_GET_PRIVATE (dialog);
-}
-
-/* Public API */
-
-static GtkWidget *
-setup_dialog (GtkWindow *parent,
-              ESourceSelectorDialog *dialog,
-              ESourceList *source_list)
+source_selector_dialog_constructed (GObject *object)
 {
+	ESourceSelectorDialog *dialog;
 	GtkWidget *label, *hbox;
 	GtkWidget *container;
 	GtkWidget *widget;
 	gchar *label_text;
-	ESourceSelectorDialogPrivate *priv = dialog->priv;
 
-	priv->source_list = g_object_ref (source_list);
+	dialog = E_SOURCE_SELECTOR_DIALOG (object);
 
 	container = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
 
@@ -203,11 +248,13 @@ setup_dialog (GtkWindow *parent,
 
 	container = widget;
 
-	widget = e_source_selector_new (source_list);
-	e_source_selector_show_selection (E_SOURCE_SELECTOR (widget), FALSE);
+	widget = e_source_selector_new (
+		dialog->priv->registry,
+		dialog->priv->extension_name);
+	e_source_selector_set_show_toggles (E_SOURCE_SELECTOR (widget), FALSE);
 	gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
 	gtk_container_add (GTK_CONTAINER (container), widget);
-	dialog->priv->source_selector = widget;
+	dialog->priv->selector = widget;
 	gtk_widget_show (widget);
 
 	g_signal_connect (
@@ -216,78 +263,163 @@ setup_dialog (GtkWindow *parent,
 	g_signal_connect (
 		widget, "primary_selection_changed",
 		G_CALLBACK (primary_selection_changed_cb), dialog);
+}
 
-	return GTK_WIDGET (dialog);
+static void
+e_source_selector_dialog_class_init (ESourceSelectorDialogClass *class)
+{
+	GObjectClass *object_class;
+
+	g_type_class_add_private (class, sizeof (ESourceSelectorDialogPrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = source_selector_dialog_set_property;
+	object_class->get_property = source_selector_dialog_get_property;
+	object_class->dispose = source_selector_dialog_dispose;
+	object_class->finalize = source_selector_dialog_finalize;
+	object_class->constructed = source_selector_dialog_constructed;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_EXTENSION_NAME,
+		g_param_spec_string (
+			"extension-name",
+			NULL,
+			NULL,
+			NULL,
+			G_PARAM_WRITABLE |
+			G_PARAM_CONSTRUCT_ONLY));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_REGISTRY,
+		g_param_spec_object (
+			"registry",
+			NULL,
+			NULL,
+			E_TYPE_SOURCE_REGISTRY,
+			G_PARAM_WRITABLE |
+			G_PARAM_CONSTRUCT_ONLY));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_SELECTOR,
+		g_param_spec_object (
+			"selector",
+			NULL,
+			NULL,
+			E_TYPE_SOURCE_SELECTOR,
+			G_PARAM_READABLE));
+}
+
+static void
+e_source_selector_dialog_init (ESourceSelectorDialog *dialog)
+{
+	GtkWidget *action_area;
+	GtkWidget *content_area;
+
+	dialog->priv = E_SOURCE_SELECTOR_DIALOG_GET_PRIVATE (dialog);
+
+	action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
+	content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+	gtk_window_set_title (GTK_WINDOW (dialog), _("Select destination"));
+	gtk_window_set_default_size (GTK_WINDOW (dialog), 320, 240);
+
+	gtk_widget_ensure_style (GTK_WIDGET (dialog));
+	gtk_container_set_border_width (GTK_CONTAINER (content_area), 0);
+	gtk_container_set_border_width (GTK_CONTAINER (action_area), 12);
+
+	gtk_dialog_add_buttons (
+		GTK_DIALOG (dialog),
+		GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+		GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+	gtk_dialog_set_default_response (
+		GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+	gtk_dialog_set_response_sensitive (
+		GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
 }
 
 /**
  * e_source_selector_dialog_new:
  * @parent: a parent window
- * @source_list: an #ESourceList
+ * @registry: an #ESourceRegistry
+ * @extension_name: the name of an #ESource extension
  *
- * Create a new source selector dialog for the given @list.
+ * Displays a list of sources from @registry having an extension named
+ * @extension_name in a dialog window.  The sources are grouped by backend
+ * or groupware account, which are described by the parent source.
  *
  * Returns: a new #ESourceSelectorDialog
  **/
 GtkWidget *
 e_source_selector_dialog_new (GtkWindow *parent,
-                              ESourceList *source_list)
+                              ESourceRegistry *registry,
+                              const gchar *extension_name)
 {
-	ESourceSelectorDialog *dialog;
-
-	g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), NULL);
-
-	dialog = g_object_new (E_TYPE_SOURCE_SELECTOR_DIALOG, NULL);
-
-	return setup_dialog (parent, dialog, source_list);
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+	g_return_val_if_fail (extension_name != NULL, NULL);
+
+	return g_object_new (
+		E_TYPE_SOURCE_SELECTOR_DIALOG,
+		"transient-for", parent,
+		"registry", registry,
+		"extension-name", extension_name,
+		NULL);
 }
 
 /**
- * e_source_selector_dialog_select_default_source:
+ * e_source_selector_dialog_get_registry:
  * @dialog: an #ESourceSelectorDialog
  *
- * Selects the default source in the dialog.
+ * Returns the #ESourceRegistry passed to e_source_selector_dialog_new().
  *
- * Returns: %TRUE if a default source was selected
+ * Returns: the #ESourceRegistry for @dialog
  *
- * Since: 2.28
+ * Since: 3.6
  **/
-gboolean
-e_source_selector_dialog_select_default_source (ESourceSelectorDialog *dialog)
+ESourceRegistry *
+e_source_selector_dialog_get_registry (ESourceSelectorDialog *dialog)
 {
-	ESourceSelectorDialogPrivate *priv;
-
-	g_return_val_if_fail (E_IS_SOURCE_SELECTOR_DIALOG (dialog), FALSE);
-
-	priv = dialog->priv;
-
-	if (priv->source_list) {
-		ESource *default_source = NULL;
-		GSList *groups, *g;
-
-		groups = e_source_list_peek_groups (priv->source_list);
-		for (g = groups; g != NULL && !default_source; g = g->next) {
-			ESourceGroup *group = E_SOURCE_GROUP (g->data);
-			GSList *sources, *s;
-
-			sources = e_source_group_peek_sources (group);
-
-			for (s = sources; s != NULL && !default_source; s = s->next) {
-				ESource *source = E_SOURCE (s->data);
+	g_return_val_if_fail (E_IS_SOURCE_SELECTOR_DIALOG (dialog), NULL);
 
-				if (source && e_source_get_property (source, "default"))
-					default_source = source;
-			}
+	return dialog->priv->registry;
+}
 
-		}
+/**
+ * e_source_selector_dialog_get_extension_name:
+ * @dialog: an #ESourceSelectorDialog
+ *
+ * Returns the extension name passed to e_source_selector_dialog_new().
+ *
+ * Returns: the extension name for @dialog
+ *
+ * Since: 3.6
+ **/
+const gchar *
+e_source_selector_dialog_get_extension_name (ESourceSelectorDialog *dialog)
+{
+	g_return_val_if_fail (E_IS_SOURCE_SELECTOR_DIALOG (dialog), NULL);
 
-		if (default_source)
-			e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (priv->source_selector), default_source);
+	return dialog->priv->extension_name;
+}
 
-		return default_source != NULL;
-	}
+/**
+ * e_source_selector_dialog_get_selector:
+ * @dialog: an #ESourceSelectorDialog
+ *
+ * Returns the #ESourceSelector widget embedded in @dialog.
+ *
+ * Returns: the #ESourceSelector widget
+ *
+ * Since: 3.6
+ **/
+ESourceSelector *
+e_source_selector_dialog_get_selector (ESourceSelectorDialog *dialog)
+{
+	g_return_val_if_fail (E_IS_SOURCE_SELECTOR_DIALOG (dialog), NULL);
 
-	return FALSE;
+	return E_SOURCE_SELECTOR (dialog->priv->selector);
 }
 
 /**
diff --git a/libedataserverui/e-source-selector-dialog.h b/libedataserverui/e-source-selector-dialog.h
index c207ab2..86eb959 100644
--- a/libedataserverui/e-source-selector-dialog.h
+++ b/libedataserverui/e-source-selector-dialog.h
@@ -25,7 +25,6 @@
 #define E_SOURCE_SELECTOR_DIALOG_H
 
 #include <gtk/gtk.h>
-#include <libedataserver/e-source-list.h>
 #include <libedataserverui/e-source-selector.h>
 
 /* Standard GObject macros */
@@ -64,12 +63,16 @@ struct _ESourceSelectorDialogClass {
 
 GType		e_source_selector_dialog_get_type (void);
 GtkWidget *	e_source_selector_dialog_new	(GtkWindow *parent,
-						 ESourceList *source_list);
+						 ESourceRegistry *registry,
+						 const gchar *extension_name);
+ESourceRegistry *
+		e_source_selector_dialog_get_registry
+						(ESourceSelectorDialog *dialog);
+const gchar *	e_source_selector_dialog_get_extension_name
+						(ESourceSelectorDialog *dialog);
 ESourceSelector *
 		e_source_selector_dialog_get_selector
 						(ESourceSelectorDialog *dialog);
-gboolean	e_source_selector_dialog_select_default_source
-						(ESourceSelectorDialog *dialog);
 ESource *	e_source_selector_dialog_peek_primary_selection
 						(ESourceSelectorDialog *dialog);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]