aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJörgen Scheibengruber <mfcn@gmx.de>2008-07-21 12:10:09 +0800
committerBharath Acharya <abharath@src.gnome.org>2008-07-21 12:10:09 +0800
commit2f7cca97077d08faefd8c1b84c1c051401bb0308 (patch)
tree1930323bf161100ec92c934f2d88692095c7d358
parent0aa642c443dea52bec45217e6981b7b9210eac0d (diff)
downloadgsoc2013-evolution-2f7cca97077d08faefd8c1b84c1c051401bb0308.tar.gz
gsoc2013-evolution-2f7cca97077d08faefd8c1b84c1c051401bb0308.tar.zst
gsoc2013-evolution-2f7cca97077d08faefd8c1b84c1c051401bb0308.zip
Committing on behalf of Jörgen Scheibengruber <mfcn@gmx.de>
2008-05-24 Jörgen Scheibengruber <mfcn@gmx.de> * Makefile.am: * google-contacts-source.c (ensure_google_contacts_source_group), (remove_google_contacts_source_group), (on_username_entry_changed), (on_update_cb_toggled), (on_interval_sb_value_changed), (plugin_google_contacts): * google-contacts-source.h: * google-source.c (e_plugin_lib_enable): * org-gnome-evolution-google.eplug.xml: Added a UI for the addressbook part svn path=/trunk/; revision=35797
-rw-r--r--plugins/google-account-setup/ChangeLog12
-rw-r--r--plugins/google-account-setup/Makefile.am5
-rw-r--r--plugins/google-account-setup/google-contacts-source.c264
-rw-r--r--plugins/google-account-setup/google-contacts-source.h30
-rw-r--r--plugins/google-account-setup/google-source.c5
-rw-r--r--plugins/google-account-setup/org-gnome-evolution-google.eplug.xml12
6 files changed, 324 insertions, 4 deletions
diff --git a/plugins/google-account-setup/ChangeLog b/plugins/google-account-setup/ChangeLog
index a1019c05e7..186c224f21 100644
--- a/plugins/google-account-setup/ChangeLog
+++ b/plugins/google-account-setup/ChangeLog
@@ -1,3 +1,15 @@
+2008-05-24 Jörgen Scheibengruber <mfcn@gmx.de>
+
+ * Makefile.am:
+ * google-contacts-source.c (ensure_google_contacts_source_group),
+ (remove_google_contacts_source_group), (on_username_entry_changed),
+ (on_update_cb_toggled), (on_interval_sb_value_changed),
+ (plugin_google_contacts):
+ * google-contacts-source.h:
+ * google-source.c (e_plugin_lib_enable):
+ * org-gnome-evolution-google.eplug.xml:
+ Added a UI for the addressbook part
+
2008-03-31 Suman Manjunath <msuman@novell.com>
** Fix for bug #346555
diff --git a/plugins/google-account-setup/Makefile.am b/plugins/google-account-setup/Makefile.am
index 898083c65a..d1c385b172 100644
--- a/plugins/google-account-setup/Makefile.am
+++ b/plugins/google-account-setup/Makefile.am
@@ -1,5 +1,6 @@
INCLUDES = \
$(EVOLUTION_CALENDAR_CFLAGS) \
+ $(EVOLUTION_ADDRESSBOOK_CFLAGS) \
-I . \
-I$(top_srcdir) \
-DCALDAV_GLADEDIR=\""$(gladedir)"\"
@@ -10,7 +11,9 @@ plugin_DATA = org-gnome-evolution-google.eplug
plugin_LTLIBRARIES = liborg-gnome-evolution-google.la
liborg_gnome_evolution_google_la_SOURCES = \
- google-source.c
+ google-source.c \
+ google-contacts-source.h \
+ google-contacts-source.c
liborg_gnome_evolution_google_la_LIBADD = \
$(EVOLUTION_CALENDAR_LIBS) \
diff --git a/plugins/google-account-setup/google-contacts-source.c b/plugins/google-account-setup/google-contacts-source.c
new file mode 100644
index 0000000000..64d3363ea9
--- /dev/null
+++ b/plugins/google-account-setup/google-contacts-source.c
@@ -0,0 +1,264 @@
+/*
+ * Copyright 2008, Joergen Scheibengruber <joergen.scheibengruber@googlemail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * 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 this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h>
+#include <string.h>
+
+#include <glib/gi18n-lib.h>
+#include <glib.h>
+
+#include <gtk/gtk.h>
+
+#include <e-util/e-config.h>
+#include <e-util/e-plugin.h>
+#include <addressbook/gui/widgets/eab-config.h>
+
+#include <libedataserver/e-source.h>
+#include <libedataserver/e-source-list.h>
+#include <libedataserver/e-url.h>
+#include <libedataserver/e-account-list.h>
+
+#include "google-contacts-source.h"
+
+
+void
+ensure_google_contacts_source_group (void)
+{
+ ESourceList *source_list;
+ ESourceGroup *group;
+
+ source_list = e_source_list_new_for_gconf_default ("/apps/evolution/addressbook/sources");
+
+ if (source_list == NULL) {
+ return;
+ }
+
+ group = e_source_list_peek_group_by_name (source_list, _("Google"));
+
+ if (group == NULL) {
+ gboolean res;
+
+ group = e_source_group_new (_("Google"), "google://");
+ res = e_source_list_add_group (source_list, group, -1);
+
+ if (res == FALSE) {
+ g_warning ("Could not add Google source group!");
+ } else {
+ e_source_list_sync (source_list, NULL);
+ }
+
+ g_object_unref (group);
+ }
+ g_object_unref (source_list);
+}
+
+void
+remove_google_contacts_source_group (void)
+{
+ ESourceList *source_list;
+ ESourceGroup *group;
+
+ source_list = e_source_list_new_for_gconf_default ("/apps/evolution/addressbook/sources");
+
+ if (source_list == NULL) {
+ return;
+ }
+
+ group = e_source_list_peek_group_by_name (source_list, _("Google"));
+
+ if (group) {
+ GSList *sources;
+
+ sources = e_source_group_peek_sources (group);
+
+ if (NULL == sources) {
+ e_source_list_remove_group (source_list, group);
+ e_source_list_sync (source_list, NULL);
+ }
+ }
+ g_object_unref (source_list);
+}
+
+static void
+on_username_entry_changed (GtkEntry *entry, gpointer user_data)
+{
+ ESource *source = user_data;
+ const char *text;
+ char *username;
+
+ text = gtk_entry_get_text (entry);
+
+ if (strstr (text, "@")) {
+ username = g_strdup (text);
+ } else {
+ username = g_strdup_printf ("%s@gmail.com", text);
+ }
+
+ e_source_set_relative_uri (source, username);
+ e_source_set_property (source, "username", username);
+ e_source_set_property (source, "auth", "plain/password");
+ g_free (username);
+}
+
+static void
+on_update_cb_toggled (GtkToggleButton *tb, gpointer user_data)
+{
+ ESource *source = user_data;
+ GtkWidget *sb = g_object_get_data (G_OBJECT (tb), "sb");
+
+ gtk_widget_set_sensitive (sb, gtk_toggle_button_get_active (tb));
+ if (gtk_toggle_button_get_active (tb)) {
+ gdouble value;
+ char *value_string;
+
+ value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (sb));
+ value_string = g_strdup_printf ("%d", (int)(value * 60.0));
+ e_source_set_property (source, "refresh-interval", value_string);
+ g_free (value_string);
+ } else {
+ e_source_set_property (source, "refresh-interval", "-1");
+ }
+}
+
+static void
+on_interval_sb_value_changed (GtkSpinButton *sb, gpointer user_data)
+{
+ ESource *source = user_data;
+ gdouble value;
+ char *value_string;
+
+ value = gtk_spin_button_get_value (sb);
+ value_string = g_strdup_printf ("%d", (int)(value * 60.0));
+ e_source_set_property (source, "refresh-interval", value_string);
+ g_free (value_string);
+}
+
+GtkWidget *
+plugin_google_contacts (EPlugin *epl,
+ EConfigHookItemFactoryData *data)
+{
+ EABConfigTargetSource *t = (EABConfigTargetSource *) data->target;
+ ESource *source;
+ ESourceGroup *group;
+ const char *base_uri;
+ const char *username;
+ const char *refresh_interval_str;
+ int refresh_interval;
+ GtkWidget *parent;
+ GtkWidget *vbox;
+
+ GtkWidget *section;
+ GtkWidget *vbox2;
+
+ GtkWidget *hbox;
+ GtkWidget *spacer;
+ GtkWidget *label;
+ GtkWidget *username_entry;
+
+ GtkWidget *update_cb;
+ GtkWidget *interval_sb;
+
+
+ source = t->source;
+ group = e_source_peek_group (source);
+
+ base_uri = e_source_group_peek_base_uri (group);
+
+ g_object_set_data_full (G_OBJECT (epl), "widget", NULL,
+ (GDestroyNotify)gtk_widget_destroy);
+
+ if (strcmp (base_uri, "google://")) {
+ return NULL;
+ }
+
+ /* Build up the UI */
+ parent = data->parent;
+ vbox = gtk_widget_get_ancestor (gtk_widget_get_parent (parent), GTK_TYPE_VBOX);
+
+ vbox2 = gtk_vbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
+
+ section = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (section), _("<b>Server</b>"));
+ gtk_misc_set_alignment (GTK_MISC (section), 0.0, 0.0);
+ gtk_box_pack_start (GTK_BOX (vbox2), section, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 10);
+ gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, TRUE, 0);
+
+ spacer = gtk_label_new (" ");
+ gtk_box_pack_start (GTK_BOX (hbox), spacer, FALSE, FALSE, 0);
+
+ label = gtk_label_new (_("Username:"));
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ username_entry = gtk_entry_new ();
+ username = e_source_get_property (source, "username");
+ if (username) {
+ gtk_entry_set_text (GTK_ENTRY (username_entry), username);
+ }
+ gtk_box_pack_start (GTK_BOX (hbox), username_entry, TRUE, TRUE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 10);
+ gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, TRUE, 0);
+
+ spacer = gtk_label_new (" ");
+ gtk_box_pack_start (GTK_BOX (hbox), spacer, FALSE, FALSE, 0);
+
+ refresh_interval_str = e_source_get_property (source, "refresh-interval");
+ if (refresh_interval_str &&
+ (1 == sscanf (refresh_interval_str, "%d", &refresh_interval))) {
+ } else {
+ refresh_interval = -1;
+ }
+ update_cb = gtk_check_button_new_with_label (_("Update every"));
+ gtk_box_pack_start (GTK_BOX (hbox), update_cb, FALSE, FALSE, 0);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (update_cb),
+ refresh_interval > 0);
+
+ interval_sb = gtk_spin_button_new_with_range (1, 60, 1);
+ gtk_widget_set_sensitive (interval_sb,
+ refresh_interval > 0);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (interval_sb),
+ refresh_interval > 0 ? refresh_interval / 60 : 30);
+ gtk_box_pack_start (GTK_BOX (hbox), interval_sb, FALSE, FALSE, 0);
+
+ label = gtk_label_new (_("minute(s)"));
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ gtk_widget_show_all (vbox2);
+
+ g_object_set_data (G_OBJECT (update_cb), "sb", interval_sb);
+ g_object_set_data_full (G_OBJECT (epl), "widget", vbox2,
+ (GDestroyNotify)gtk_widget_destroy);
+
+ g_signal_connect (G_OBJECT (username_entry), "changed",
+ G_CALLBACK (on_username_entry_changed),
+ source);
+ g_signal_connect (G_OBJECT (update_cb), "toggled",
+ G_CALLBACK (on_update_cb_toggled),
+ source);
+ g_signal_connect (G_OBJECT (interval_sb), "value-changed",
+ G_CALLBACK (on_interval_sb_value_changed),
+ source);
+
+ return NULL;
+}
+
+
diff --git a/plugins/google-account-setup/google-contacts-source.h b/plugins/google-account-setup/google-contacts-source.h
new file mode 100644
index 0000000000..17421fb232
--- /dev/null
+++ b/plugins/google-account-setup/google-contacts-source.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2008, Joergen Scheibengruber <joergen.scheibengruber@googlemail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * 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 this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __GOOGLE_CONTACTS_SOURCE_H__
+#define __GOOGLE_CONTACTS_SOURCE_H__
+
+GtkWidget *plugin_google_contacts (EPlugin *epl,
+ EConfigHookItemFactoryData *data);
+
+void ensure_google_contacts_source_group (void);
+
+void remove_google_contacts_source_group (void);
+
+#endif
diff --git a/plugins/google-account-setup/google-source.c b/plugins/google-account-setup/google-source.c
index d586b3027e..7e73b5b8ba 100644
--- a/plugins/google-account-setup/google-source.c
+++ b/plugins/google-account-setup/google-source.c
@@ -41,6 +41,8 @@
#include <libedataserver/e-account-list.h>
#include <libecal/e-cal.h>
+#include "google-contacts-source.h"
+
#define CALENDAR_LOCATION "http://www.google.com/calendar/feeds/"
#define d(x)
@@ -96,6 +98,9 @@ e_plugin_lib_enable (EPluginLib *ep, int enable)
if (enable) {
d(printf ("\n Google Eplugin starting up ...\n"));
ensure_google_source_group ();
+ ensure_google_contacts_source_group ();
+ } else {
+ remove_google_contacts_source_group ();
}
return 0;
diff --git a/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml b/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml
index d6087ad748..a172ba8923 100644
--- a/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml
+++ b/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml
@@ -3,11 +3,17 @@
<e-plugin id="org.gnome.evolution.google" type="shlib" _name="Google sources"
location="@PLUGINDIR@/liborg-gnome-evolution-google@SOEXT@" load-on-startup="false" localedir = "@LOCALEDIR@">
<author name="Ebby Wiselyn" email="ebbywiselyn@gmail.com"/>
- <_description>A plugin to setup google calendar.</_description>
-
+ <author name="Joergen Scheibengruber" email="joergen.scheibengruber@googlemail.com"/>
+ <_description>A plugin to setup google calendar and contacts.</_description>
+
<hook class="org.gnome.evolution.calendar.config:1.0">
<group target="source" id="org.gnome.evolution.calendar.calendarProperties">
- <item type="item_table" path="00.general/00.source/15.google" factory="plugin_google"/>
+ <item type="item_table" path="00.general/00.source/15.google" factory="plugin_google"/>
+ </group>
+ </hook>
+ <hook class="org.gnome.evolution.addressbook.config:1.0">
+ <group target="source" id="com.novell.evolution.addressbook.config.accountEditor">
+ <item type="item" path="00.general/10.display/00.google" factory="plugin_google_contacts"/>
</group>
</hook>
</e-plugin>