aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/bbdb
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2007-10-23 02:49:30 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2007-10-23 02:49:30 +0800
commitb37af8f269484ebd836996c140ea718885954ca3 (patch)
tree8ed883fcc7c60b5200be9438514902accd991cd1 /plugins/bbdb
parent16af69fb17d52a18b0c308e8ed137f71d2dba1fa (diff)
downloadgsoc2013-evolution-b37af8f269484ebd836996c140ea718885954ca3.tar.gz
gsoc2013-evolution-b37af8f269484ebd836996c140ea718885954ca3.tar.zst
gsoc2013-evolution-b37af8f269484ebd836996c140ea718885954ca3.zip
** Fixes part of bug #417999
2007-10-22 Matthew Barnes <mbarnes@redhat.com> ** Fixes part of bug #417999 * addressbook/gui/contact-editor/contact-editor.glade: * addressbook/gui/contact-editor/e-contact-editor.c: * addressbook/gui/contact-editor/e-contact-quick-add.c: * addressbook/gui/contact-list-editor/contact-list-editor.c: * addressbook/gui/contact-list-editor/contact-list-editor.glade: * calendar/gui/dialogs/event-page.c: * calendar/gui/dialogs/event-page.glade: * calendar/gui/dialogs/memo-page.c: * calendar/gui/dialogs/memo-page.glade: * calendar/gui/dialogs/task-page.c: * calendar/gui/dialogs/task-page.glade: * calendar/gui/e-itip-control.c: * plugins/bbdb/bbdb.c: * plugins/bbdb/gaimbuddies.c: * plugins/itip-formatter/itip-view.c: * widgets/misc/e-pilot-settings.c: Use ESourceComboBox instead of ESourceOptionMenu (deprecated). svn path=/trunk/; revision=34408
Diffstat (limited to 'plugins/bbdb')
-rw-r--r--plugins/bbdb/ChangeLog8
-rw-r--r--plugins/bbdb/bbdb.c132
-rw-r--r--plugins/bbdb/gaimbuddies.c2
3 files changed, 117 insertions, 25 deletions
diff --git a/plugins/bbdb/ChangeLog b/plugins/bbdb/ChangeLog
index bb17fd32c8..78810928ba 100644
--- a/plugins/bbdb/ChangeLog
+++ b/plugins/bbdb/ChangeLog
@@ -1,3 +1,11 @@
+2007-10-22 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #417999
+
+ * bbdb.c:
+ * gaimbuddies.c:
+ Use ESourceComboBox instead of ESourceOptionMenu (deprecated).
+
2007-10-09 Matthew Barnes <mbarnes@redhat.com>
** Fixes part of bug #437579
diff --git a/plugins/bbdb/bbdb.c b/plugins/bbdb/bbdb.c
index 17eb26f176..a4b363af51 100644
--- a/plugins/bbdb/bbdb.c
+++ b/plugins/bbdb/bbdb.c
@@ -40,7 +40,7 @@
#include <string.h>
#include <libebook/e-book.h>
-#include <libedataserverui/e-source-option-menu.h>
+#include <libedataserverui/e-source-combo-box.h>
#include <e-util/e-config.h>
#include <mail/em-config.h>
@@ -71,10 +71,49 @@ static gboolean bbdb_timeout (gpointer data);
static void bbdb_do_it (EBook *book, const char *name, const char *email);
static void add_email_to_contact (EContact *contact, const char *email);
static void enable_toggled_cb (GtkWidget *widget, gpointer data);
-static void source_changed_cb (GtkWidget *widget, ESource *source, gpointer data);
+static void source_changed_cb (ESourceComboBox *source_combo_box, struct bbdb_stuff *stuff);
static GtkWidget *create_addressbook_option_menu (struct bbdb_stuff *stuff, int type);
static void cleanup_cb (GObject *o, gpointer data);
+static ESource *
+find_esource_by_uri (ESourceList *source_list, const gchar *target_uri)
+{
+ GSList *groups;
+
+ /* XXX This would be unnecessary if the plugin had stored
+ * the addressbook's UID instead of the URI in GConf.
+ * Too late to change it now, I suppose. */
+
+ if (source_list == NULL || target_uri == NULL)
+ return NULL;
+
+ groups = e_source_list_peek_groups (source_list);
+
+ while (groups != NULL) {
+ GSList *sources;
+
+ sources = e_source_group_peek_sources (groups->data);
+
+ while (sources != NULL) {
+ gchar *uri;
+ gboolean match;
+
+ uri = e_source_get_uri (sources->data);
+ match = (strcmp (uri, target_uri) == 0);
+ g_free (uri);
+
+ if (match)
+ return sources->data;
+
+ sources = g_slist_next (sources);
+ }
+
+ groups = g_slist_next (groups);
+ }
+
+ return NULL;
+}
+
int
e_plugin_lib_enable (EPluginLib *ep, int enable)
{
@@ -343,8 +382,23 @@ enable_toggled_cb (GtkWidget *widget, gpointer data)
gtk_widget_set_sensitive (stuff->option_menu, active);
if (active && !gconf_client_get_string (stuff->target->gconf, GCONF_KEY_WHICH_ADDRESSBOOK, NULL)) {
- selected_source = e_source_option_menu_peek_selected (E_SOURCE_OPTION_MENU (stuff->option_menu));
- gconf_client_set_string (stuff->target->gconf, GCONF_KEY_WHICH_ADDRESSBOOK, e_source_get_uri (selected_source), NULL);
+ const gchar *uri = NULL;
+ GError *error = NULL;
+
+ selected_source = e_source_combo_box_get_active (
+ E_SOURCE_COMBO_BOX (stuff->option_menu));
+ if (selected_source != NULL)
+ uri = e_source_get_uri (selected_source);
+
+ gconf_client_set_string (
+ stuff->target->gconf,
+ GCONF_KEY_WHICH_ADDRESSBOOK,
+ uri, &error);
+
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
}
}
@@ -362,7 +416,8 @@ enable_gaim_toggled_cb (GtkWidget *widget, gpointer data)
gtk_widget_set_sensitive (stuff->gaim_option_menu, active);
if (active && !gconf_client_get_string (stuff->target->gconf, GCONF_KEY_WHICH_ADDRESSBOOK_GAIM, NULL)) {
- selected_source = e_source_option_menu_peek_selected (E_SOURCE_OPTION_MENU (stuff->gaim_option_menu));
+ selected_source = e_source_combo_box_get_active (
+ E_SOURCE_COMBO_BOX (stuff->gaim_option_menu));
gconf_client_set_string (stuff->target->gconf, GCONF_KEY_WHICH_ADDRESSBOOK_GAIM, e_source_get_uri (selected_source), NULL);
}
}
@@ -374,48 +429,77 @@ synchronize_button_clicked_cb (GtkWidget *button)
}
static void
-source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
+source_changed_cb (ESourceComboBox *source_combo_box,
+ struct bbdb_stuff *stuff)
{
- struct bbdb_stuff *stuff = (struct bbdb_stuff *) data;
-
- gconf_client_set_string (stuff->target->gconf, GCONF_KEY_WHICH_ADDRESSBOOK, e_source_get_uri (source), NULL);
+ ESource *source;
+ GError *error = NULL;
+
+ source = e_source_combo_box_get_active (source_combo_box);
+ g_return_if_fail (source != NULL);
+
+ gconf_client_set_string (
+ stuff->target->gconf,
+ GCONF_KEY_WHICH_ADDRESSBOOK,
+ e_source_get_uri (source), &error);
+
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
}
static void
-gaim_source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
+gaim_source_changed_cb (ESourceComboBox *source_combo_box,
+ struct bbdb_stuff *stuff)
{
- struct bbdb_stuff *stuff = (struct bbdb_stuff *) data;
- gconf_client_set_string (stuff->target->gconf, GCONF_KEY_WHICH_ADDRESSBOOK_GAIM, e_source_get_uri (source), NULL);
+ ESource *source;
+ GError *error = NULL;
+
+ source = e_source_combo_box_get_active (source_combo_box);
+ g_return_if_fail (source != NULL);
+
+ gconf_client_set_string (
+ stuff->target->gconf,
+ GCONF_KEY_WHICH_ADDRESSBOOK_GAIM,
+ e_source_get_uri (source), &error);
+
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
}
static GtkWidget *
create_addressbook_option_menu (struct bbdb_stuff *stuff, int type)
{
- GtkWidget *menu;
+ GtkWidget *combo_box;
ESourceList *source_list;
- char *selected_source_uri;
ESource *selected_source;
+ char *selected_source_uri;
GConfClient *gconf = stuff->target->gconf;
source_list = e_source_list_new_for_gconf (gconf, "/apps/evolution/addressbook/sources");
- menu = e_source_option_menu_new (source_list);
+ combo_box = e_source_combo_box_new (source_list);
if (type == GAIM_ADDRESSBOOK)
selected_source_uri = gconf_client_get_string (gconf, GCONF_KEY_WHICH_ADDRESSBOOK_GAIM, NULL);
else
selected_source_uri = gconf_client_get_string (gconf, GCONF_KEY_WHICH_ADDRESSBOOK, NULL);
- if (selected_source_uri != NULL) {
- selected_source = e_source_new_with_absolute_uri ("", selected_source_uri);
- e_source_option_menu_select (E_SOURCE_OPTION_MENU (menu), selected_source);
- g_free (selected_source_uri);
- }
+ selected_source = find_esource_by_uri (
+ source_list, selected_source_uri);
+ g_free (selected_source_uri);
+
+ if (selected_source != NULL)
+ e_source_combo_box_set_active (
+ E_SOURCE_COMBO_BOX (combo_box), selected_source);
- gtk_widget_show (menu);
+ gtk_widget_show (combo_box);
stuff->source_list = source_list;
- return menu;
+ return combo_box;
}
GtkWidget *
@@ -481,7 +565,7 @@ bbdb_page_factory (EPlugin *ep, EConfigHookItemFactoryData *hook_data)
/* Source selection option menu */
option = create_addressbook_option_menu (stuff, AUTOMATIC_CONTACTS_ADDRESSBOOK);
- g_signal_connect (option, "source_selected", G_CALLBACK (source_changed_cb), stuff);
+ g_signal_connect (option, "changed", G_CALLBACK (source_changed_cb), stuff);
gtk_widget_set_sensitive (option, gconf_client_get_bool (target->gconf, GCONF_KEY_ENABLE, NULL));
gtk_box_pack_start (GTK_BOX (inner_vbox), option, FALSE, FALSE, 0);
stuff->option_menu = option;
@@ -517,7 +601,7 @@ bbdb_page_factory (EPlugin *ep, EConfigHookItemFactoryData *hook_data)
/* Gaim Source Selection Option Menu */
gaim_option = create_addressbook_option_menu (stuff, GAIM_ADDRESSBOOK);
- g_signal_connect (gaim_option, "source_selected", G_CALLBACK (gaim_source_changed_cb), stuff);
+ g_signal_connect (gaim_option, "changed", G_CALLBACK (gaim_source_changed_cb), stuff);
gtk_widget_set_sensitive (gaim_option, gconf_client_get_bool (target->gconf, GCONF_KEY_ENABLE_GAIM, NULL));
gtk_box_pack_start (GTK_BOX (inner_vbox), gaim_option, FALSE, FALSE, 0);
stuff->gaim_option_menu = gaim_option;
diff --git a/plugins/bbdb/gaimbuddies.c b/plugins/bbdb/gaimbuddies.c
index 09a2f1d6c6..6c91b06be4 100644
--- a/plugins/bbdb/gaimbuddies.c
+++ b/plugins/bbdb/gaimbuddies.c
@@ -44,7 +44,7 @@
#include <string.h>
#include <libebook/e-book.h>
-#include <libedataserverui/e-source-option-menu.h>
+#include <libedataserverui/e-source-combo-box.h>
#include <sys/time.h>
#include <sys/stat.h>