[evolution/account-mgmt: 38/55] Add 'cal-config-contacts' module.



commit 6a8a86df224d7373e1a12bfb3fffd6ec3b2f2e99
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Jan 19 15:23:12 2011 -0500

    Add 'cal-config-contacts' module.
    
    Registers the "Contacts" backend in ECalSourceConfig widgets.

 configure.ac                                       |    1 +
 modules/Makefile.am                                |    1 +
 modules/cal-config-contacts/Makefile.am            |   32 +++
 modules/cal-config-contacts/e-contacts-selector.c  |  115 +++++++++
 modules/cal-config-contacts/e-contacts-selector.h  |   65 +++++
 modules/cal-config-contacts/e-source-contacts.c    |  139 +++++++++++
 modules/cal-config-contacts/e-source-contacts.h    |   70 ++++++
 .../evolution-cal-config-contacts.c                |  256 ++++++++++++++++++++
 8 files changed, 679 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6e54481..8a1cc96 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1624,6 +1624,7 @@ modules/book-config-ldap/Makefile
 modules/book-config-local/Makefile
 modules/book-config-webdav/Makefile
 modules/cal-config-caldav/Makefile
+modules/cal-config-contacts/Makefile
 modules/cal-config-local/Makefile
 modules/composer-autosave/Makefile
 modules/mailto-handler/Makefile
diff --git a/modules/Makefile.am b/modules/Makefile.am
index 71b7d07..ecfeae7 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -25,6 +25,7 @@ SUBDIRS = \
 	book-config-local \
 	book-config-webdav \
 	cal-config-caldav \
+	cal-config-contacts \
 	cal-config-local \
 	composer-autosave \
 	mailto-handler \
diff --git a/modules/cal-config-contacts/Makefile.am b/modules/cal-config-contacts/Makefile.am
new file mode 100644
index 0000000..59367b9
--- /dev/null
+++ b/modules/cal-config-contacts/Makefile.am
@@ -0,0 +1,32 @@
+module_LTLIBRARIES = module-cal-config-contacts.la
+
+module_cal_config_contacts_la_CPPFLAGS = \
+	$(AM_CPPFLAGS)						\
+	-I$(top_srcdir)						\
+	-I$(top_srcdir)/widgets					\
+	-DG_LOG_DOMAIN=\"evolution-cal-config-contacts\"	\
+	$(EVOLUTION_DATA_SERVER_CFLAGS)				\
+	$(GNOME_PLATFORM_CFLAGS)
+
+module_cal_config_contacts_la_SOURCES = \
+	evolution-cal-config-contacts.c				\
+	e-contacts-selector.c					\
+	e-contacts-selector.h					\
+	e-source-contacts.c					\
+	e-source-contacts.h
+
+module_cal_config_contacts_la_LIBADD = \
+	$(top_builddir)/e-util/libeutil.la			\
+	$(top_builddir)/widgets/misc/libemiscwidgets.la		\
+	$(top_builddir)/addressbook/printing/libecontactprint.la \
+	$(top_builddir)/addressbook/gui/merging/libeabbookmerging.la \
+	$(top_builddir)/addressbook/gui/widgets/libeabwidgets.la \
+	$(top_builddir)/addressbook/util/libeabutil.la		\
+	$(top_builddir)/calendar/gui/libevolution-calendar.la	\
+	$(EVOLUTION_DATA_SERVER_LIBS)				\
+	$(GNOME_PLATFORM_LIBS)
+
+module_cal_config_contacts_la_LDFLAGS = \
+	-module -avoid-version $(NO_UNDEFINED)
+
+-include $(top_srcdir)/git.mk
diff --git a/modules/cal-config-contacts/e-contacts-selector.c b/modules/cal-config-contacts/e-contacts-selector.c
new file mode 100644
index 0000000..80b1075
--- /dev/null
+++ b/modules/cal-config-contacts/e-contacts-selector.c
@@ -0,0 +1,115 @@
+/*
+ * e-contacts-selector.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-contacts-selector.h"
+
+#include <libedataserver/e-source-address-book.h>
+
+#include "e-source-contacts.h"
+
+G_DEFINE_DYNAMIC_TYPE (
+	EContactsSelector,
+	e_contacts_selector,
+	E_TYPE_SOURCE_SELECTOR)
+
+static gboolean
+contacts_selector_get_source_selected (ESourceSelector *selector,
+                                       ESource *source)
+{
+	ESourceContacts *extension;
+	const gchar *extension_name;
+
+	extension_name = e_source_selector_get_extension_name (selector);
+
+	/* Make sure this source is an address book. */
+	if (!e_source_has_extension (source, extension_name))
+		return FALSE;
+
+	extension_name = E_SOURCE_EXTENSION_CONTACTS_BACKEND;
+	extension = e_source_get_extension (source, extension_name);
+	g_return_val_if_fail (E_IS_SOURCE_CONTACTS (extension), FALSE);
+
+	return e_source_contacts_get_include_me (extension);
+}
+
+static void
+contacts_selector_set_source_selected (ESourceSelector *selector,
+                                       ESource *source,
+                                       gboolean selected)
+{
+	ESourceContacts *extension;
+	const gchar *extension_name;
+
+	/* Make sure this source is an address book. */
+	extension_name = e_source_selector_get_extension_name (selector);
+	if (!e_source_has_extension (source, extension_name))
+		return;
+
+	extension_name = E_SOURCE_EXTENSION_CONTACTS_BACKEND;
+	extension = e_source_get_extension (source, extension_name);
+	g_return_if_fail (E_IS_SOURCE_CONTACTS (extension));
+
+	if (selected != e_source_contacts_get_include_me (extension)) {
+		e_source_contacts_set_include_me (extension, selected);
+		e_source_selector_queue_write (selector, source);
+	}
+}
+
+static void
+e_contacts_selector_class_init (EContactsSelectorClass *class)
+{
+	ESourceSelectorClass *source_selector_class;
+
+	source_selector_class = E_SOURCE_SELECTOR_CLASS (class);
+	source_selector_class->get_source_selected =
+				contacts_selector_get_source_selected;
+	source_selector_class->set_source_selected =
+				contacts_selector_set_source_selected;
+}
+
+static void
+e_contacts_selector_class_finalize (EContactsSelectorClass *class)
+{
+}
+
+static void
+e_contacts_selector_init (EContactsSelector *selector)
+{
+	e_source_selector_set_show_colors (
+		E_SOURCE_SELECTOR (selector), FALSE);
+}
+
+void
+e_contacts_selector_type_register (GTypeModule *type_module)
+{
+	/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
+	 *     function, so we have to wrap it with a public function in
+	 *     order to register types from a separate compilation unit. */
+	e_contacts_selector_register_type (type_module);
+}
+
+GtkWidget *
+e_contacts_selector_new (ESourceRegistry *registry)
+{
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
+	return g_object_new (
+		E_TYPE_CONTACTS_SELECTOR,
+		"extension-name", E_SOURCE_EXTENSION_ADDRESS_BOOK,
+		"registry", registry, NULL);
+}
diff --git a/modules/cal-config-contacts/e-contacts-selector.h b/modules/cal-config-contacts/e-contacts-selector.h
new file mode 100644
index 0000000..0afb021
--- /dev/null
+++ b/modules/cal-config-contacts/e-contacts-selector.h
@@ -0,0 +1,65 @@
+/*
+ * e-contacts-selector.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_CONTACTS_SELECTOR_H
+#define E_CONTACTS_SELECTOR_H
+
+#include <libedataserverui/e-source-selector.h>
+
+/* Standard GObject macros */
+#define E_TYPE_CONTACTS_SELECTOR \
+	(e_contacts_selector_get_type ())
+#define E_CONTACTS_SELECTOR(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_CONTACTS_SELECTOR, EContactsSelector))
+#define E_CONTACTS_SELECTOR_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_CONTACTS_SELECTOR, EContactsSelectorClass))
+#define E_IS_CONTACTS_SELECTOR(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_CONTACTS_SELECTOR))
+#define E_IS_CONTACTS_SELECTOR_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_CONTACTS_SELECTOR))
+#define E_CONTACTS_SELECTOR_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_CONTACTS_SELECTOR, EContactsSelectorClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EContactsSelector EContactsSelector;
+typedef struct _EContactsSelectorClass EContactsSelectorClass;
+typedef struct _EContactsSelectorPrivate EContactsSelectorPrivate;
+
+struct _EContactsSelector {
+	ESourceSelector parent;
+	EContactsSelectorPrivate *priv;
+};
+
+struct _EContactsSelectorClass {
+	ESourceSelectorClass parent_class;
+};
+
+GType		e_contacts_selector_get_type	(void);
+void		e_contacts_selector_type_register
+						(GTypeModule *type_module);
+GtkWidget *	e_contacts_selector_new		(ESourceRegistry *registry);
+
+G_END_DECLS
+
+#endif /* E_CONTACTS_SELECTOR_H */
diff --git a/modules/cal-config-contacts/e-source-contacts.c b/modules/cal-config-contacts/e-source-contacts.c
new file mode 100644
index 0000000..32ba589
--- /dev/null
+++ b/modules/cal-config-contacts/e-source-contacts.c
@@ -0,0 +1,139 @@
+/*
+ * e-source-contacts.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <webcal://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-source-contacts.h"
+
+#define E_SOURCE_CONTACTS_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_SOURCE_CONTACTS, ESourceContactsPrivate))
+
+struct _ESourceContactsPrivate {
+	gboolean include_me;
+};
+
+enum {
+	PROP_0,
+	PROP_INCLUDE_ME
+};
+
+G_DEFINE_DYNAMIC_TYPE (
+	ESourceContacts,
+	e_source_contacts,
+	E_TYPE_SOURCE_EXTENSION)
+
+static void
+source_contacts_set_property (GObject *object,
+                              guint property_id,
+                              const GValue *value,
+                              GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_INCLUDE_ME:
+			e_source_contacts_set_include_me (
+				E_SOURCE_CONTACTS (object),
+				g_value_get_boolean (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+source_contacts_get_property (GObject *object,
+                              guint property_id,
+                              GValue *value,
+                              GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_INCLUDE_ME:
+			g_value_set_boolean (
+				value,
+				e_source_contacts_get_include_me (
+				E_SOURCE_CONTACTS (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+e_source_contacts_class_init (ESourceContactsClass *class)
+{
+	GObjectClass *object_class;
+	ESourceExtensionClass *extension_class;
+
+	g_type_class_add_private (class, sizeof (ESourceContactsPrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = source_contacts_set_property;
+	object_class->get_property = source_contacts_get_property;
+
+	extension_class = E_SOURCE_EXTENSION_CLASS (class);
+	extension_class->name = E_SOURCE_EXTENSION_CONTACTS_BACKEND;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_INCLUDE_ME,
+		g_param_spec_boolean (
+			"include-me",
+			"Include Me",
+			"Include this address book in the contacts calendar",
+			TRUE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT |
+			E_SOURCE_PARAM_SETTING));
+}
+
+static void
+e_source_contacts_class_finalize (ESourceContactsClass *class)
+{
+}
+
+static void
+e_source_contacts_init (ESourceContacts *extension)
+{
+	extension->priv = E_SOURCE_CONTACTS_GET_PRIVATE (extension);
+}
+
+void
+e_source_contacts_type_register (GTypeModule *type_module)
+{
+	/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
+	 *     function, so we have to wrap it with a public function in
+	 *     order to register types from a separate compilation unit. */
+	e_source_contacts_register_type (type_module);
+}
+
+gboolean
+e_source_contacts_get_include_me (ESourceContacts *extension)
+{
+	g_return_val_if_fail (E_IS_SOURCE_CONTACTS (extension), FALSE);
+
+	return extension->priv->include_me;
+}
+
+void
+e_source_contacts_set_include_me (ESourceContacts *extension,
+                                  gboolean include_me)
+{
+	g_return_if_fail (E_IS_SOURCE_CONTACTS (extension));
+
+	extension->priv->include_me = include_me;
+
+	g_object_notify (G_OBJECT (extension), "include-me");
+}
diff --git a/modules/cal-config-contacts/e-source-contacts.h b/modules/cal-config-contacts/e-source-contacts.h
new file mode 100644
index 0000000..95d9b83
--- /dev/null
+++ b/modules/cal-config-contacts/e-source-contacts.h
@@ -0,0 +1,70 @@
+/*
+ * e-source-contacts.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <webcal://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_SOURCE_CONTACTS_H
+#define E_SOURCE_CONTACTS_H
+
+#include <libedataserver/e-source-extension.h>
+
+/* Standard GObject macros */
+#define E_TYPE_SOURCE_CONTACTS \
+	(e_source_contacts_get_type ())
+#define E_SOURCE_CONTACTS(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_SOURCE_CONTACTS, ESourceContacts))
+#define E_SOURCE_CONTACTS_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_SOURCE_CONTACTS, ESourceContactsClass))
+#define E_IS_SOURCE_CONTACTS(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_SOURCE_CONTACTS))
+#define E_IS_SOURCE_CONTACTS_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_SOURCE_CONTACTS))
+#define E_SOURCE_CONTACTS_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_SOURCE_CONTACTS, ESourceContactsClass))
+
+#define E_SOURCE_EXTENSION_CONTACTS_BACKEND "Contacts Backend"
+
+G_BEGIN_DECLS
+
+typedef struct _ESourceContacts ESourceContacts;
+typedef struct _ESourceContactsClass ESourceContactsClass;
+typedef struct _ESourceContactsPrivate ESourceContactsPrivate;
+
+struct _ESourceContacts {
+	ESourceExtension parent;
+	ESourceContactsPrivate *priv;
+};
+
+struct _ESourceContactsClass {
+	ESourceExtensionClass parent_class;
+};
+
+GType		e_source_contacts_get_type	(void);
+void		e_source_contacts_type_register	(GTypeModule *type_module);
+gboolean	e_source_contacts_get_include_me
+						(ESourceContacts *extension);
+void		e_source_contacts_set_include_me
+						(ESourceContacts *extension,
+						 gboolean include_me);
+
+G_END_DECLS
+
+#endif /* E_SOURCE_CONTACTS_H */
diff --git a/modules/cal-config-contacts/evolution-cal-config-contacts.c b/modules/cal-config-contacts/evolution-cal-config-contacts.c
new file mode 100644
index 0000000..6b0fa89
--- /dev/null
+++ b/modules/cal-config-contacts/evolution-cal-config-contacts.c
@@ -0,0 +1,256 @@
+/*
+ * evolution-cal-config-contacts.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <libebackend/e-extension.h>
+
+#include <misc/e-source-config-backend.h>
+#include <calendar/gui/e-cal-source-config.h>
+#include <addressbook/gui/widgets/e-book-source-config.h>
+
+#include "e-contacts-selector.h"
+#include "e-source-contacts.h"
+
+/* This file contains two extension classes: an ESourceConfigBackend
+ * for "contacts" calendars and an EExtension for EBookSourceConfig. */
+
+/**************************** ECalConfigContacts *****************************/
+
+typedef ESourceConfigBackend ECalConfigContacts;
+typedef ESourceConfigBackendClass ECalConfigContactsClass;
+
+/* Forward Declarations */
+GType e_cal_config_contacts_get_type (void);
+
+G_DEFINE_DYNAMIC_TYPE (
+	ECalConfigContacts,
+	e_cal_config_contacts,
+	E_TYPE_SOURCE_CONFIG_BACKEND)
+
+static gboolean
+cal_config_contacts_allow_creation (ESourceConfigBackend *backend)
+{
+	return FALSE;
+}
+
+static void
+cal_config_contacts_insert_widgets (ESourceConfigBackend *backend,
+                                    ESource *scratch_source)
+{
+	ESourceConfig *config;
+	ESourceRegistry *registry;
+	GtkWidget *container;
+	GtkWidget *widget;
+
+	config = e_source_config_backend_get_config (backend);
+	registry = e_source_config_get_registry (config);
+
+	/* Extra padding between the selector and the options above. */
+	widget = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
+	gtk_alignment_set_padding (GTK_ALIGNMENT (widget), 12, 0, 0, 0);
+	e_source_config_insert_widget (config, scratch_source, NULL, widget);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	widget = gtk_label_new (_("Choose which address books to use."));
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_container_add (GTK_CONTAINER (container), widget);
+	gtk_widget_show (widget);
+
+	widget = gtk_scrolled_window_new (NULL, NULL);
+	gtk_scrolled_window_set_policy (
+		GTK_SCROLLED_WINDOW (widget),
+		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+	gtk_scrolled_window_set_shadow_type (
+		GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
+	gtk_widget_set_size_request (widget, 320, 200);
+	e_source_config_insert_widget (config, scratch_source, NULL, widget);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	widget = e_contacts_selector_new (registry);
+	gtk_container_add (GTK_CONTAINER (container), widget);
+	gtk_widget_show (widget);
+}
+
+static void
+e_cal_config_contacts_class_init (ESourceConfigBackendClass *class)
+{
+	EExtensionClass *extension_class;
+
+	extension_class = E_EXTENSION_CLASS (class);
+	extension_class->extensible_type = E_TYPE_CAL_SOURCE_CONFIG;
+
+	class->parent_uid = "contacts-stub";
+	class->backend_name = "contacts";
+	class->allow_creation = cal_config_contacts_allow_creation;
+	class->insert_widgets = cal_config_contacts_insert_widgets;
+}
+
+static void
+e_cal_config_contacts_class_finalize (ESourceConfigBackendClass *class)
+{
+}
+
+static void
+e_cal_config_contacts_init (ESourceConfigBackend *backend)
+{
+}
+
+/*************************** EBookConfigBirthdays ****************************/
+
+/* Standard GObject macros */
+#define E_TYPE_BOOK_CONFIG_BIRTHDAYS \
+	(e_book_config_birthdays_get_type ())
+#define E_BOOK_CONFIG_BIRTHDAYS(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_BOOK_CONFIG_BIRTHDAYS, EBookConfigBirthdays))
+
+typedef struct _EBookConfigBirthdays EBookConfigBirthdays;
+typedef struct _EBookConfigBirthdaysClass EBookConfigBirthdaysClass;
+
+struct _EBookConfigBirthdays {
+	EExtension parent;
+	GtkWidget *button;
+};
+
+struct _EBookConfigBirthdaysClass {
+	EExtensionClass parent_class;
+};
+
+/* Forward Declarations */
+GType e_book_config_birthdays_get_type (void);
+
+G_DEFINE_DYNAMIC_TYPE (
+	EBookConfigBirthdays,
+	e_book_config_birthdays,
+	E_TYPE_EXTENSION)
+
+static ESourceConfig *
+book_config_birthdays_get_config (EBookConfigBirthdays *birthdays)
+{
+	EExtensible *extensible;
+
+	extensible = e_extension_get_extensible (E_EXTENSION (birthdays));
+
+	return E_SOURCE_CONFIG (extensible);
+}
+
+static void
+book_config_birthdays_dispose (GObject *object)
+{
+	EBookConfigBirthdays *birthdays;
+
+	birthdays = E_BOOK_CONFIG_BIRTHDAYS (object);
+
+	if (birthdays->button != NULL) {
+		g_object_unref (birthdays->button);
+		birthdays->button = NULL;
+	}
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (e_book_config_birthdays_parent_class)->dispose (object);
+}
+
+static void
+book_config_birthdays_init_candidate (ESourceConfig *config,
+                                      ESource *scratch_source,
+                                      EBookConfigBirthdays *birthdays)
+{
+	ESourceExtension *extension;
+	const gchar *extension_name;
+
+	extension_name = E_SOURCE_EXTENSION_CONTACTS_BACKEND;
+	extension = e_source_get_extension (scratch_source, extension_name);
+
+	g_object_bind_property (
+		extension, "include-me",
+		birthdays->button, "active",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+}
+
+static void
+book_config_birthdays_constructed (GObject *object)
+{
+	ESourceConfig *config;
+	EBookConfigBirthdays *birthdays;
+	GtkWidget *widget;
+	const gchar *label;
+
+	birthdays = E_BOOK_CONFIG_BIRTHDAYS (object);
+	config = book_config_birthdays_get_config (birthdays);
+
+	label = _("Use in Birthdays & Anniversaries calendar");
+	widget = gtk_check_button_new_with_label (label);
+	e_source_config_insert_widget (config, NULL, NULL, widget);
+	birthdays->button = g_object_ref_sink (widget);
+	gtk_widget_show (widget);
+
+	g_signal_connect (
+		config, "init-candidate",
+		G_CALLBACK (book_config_birthdays_init_candidate),
+		birthdays);
+}
+
+static void
+e_book_config_birthdays_class_init (EBookConfigBirthdaysClass *class)
+{
+	GObjectClass *object_class;
+	EExtensionClass *extension_class;
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->dispose = book_config_birthdays_dispose;
+	object_class->constructed = book_config_birthdays_constructed;
+
+	extension_class = E_EXTENSION_CLASS (class);
+	extension_class->extensible_type = E_TYPE_BOOK_SOURCE_CONFIG;
+}
+
+static void
+e_book_config_birthdays_class_finalize (EBookConfigBirthdaysClass *class)
+{
+}
+
+static void
+e_book_config_birthdays_init (EBookConfigBirthdays *birthdays)
+{
+}
+
+/* Module Entry Points */
+void e_module_load (GTypeModule *type_module);
+void e_module_unload (GTypeModule *type_module);
+
+G_MODULE_EXPORT void
+e_module_load (GTypeModule *type_module)
+{
+	e_source_contacts_type_register (type_module);
+	e_contacts_selector_type_register (type_module);
+
+	e_cal_config_contacts_register_type (type_module);
+	e_book_config_birthdays_register_type (type_module);
+}
+
+G_MODULE_EXPORT void
+e_module_unload (GTypeModule *type_module)
+{
+}



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