aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2003-12-07 07:19:01 +0800
committerChris Toshok <toshok@src.gnome.org>2003-12-07 07:19:01 +0800
commit268185761bcdee059f5d3b52937ee3c5667b79e5 (patch)
tree216d48a6a918be7189be161451f52ba4e5205f59
parent7c13868fae6c2ddc4aa3ab951929ec410e73f284 (diff)
downloadgsoc2013-evolution-268185761bcdee059f5d3b52937ee3c5667b79e5.tar
gsoc2013-evolution-268185761bcdee059f5d3b52937ee3c5667b79e5.tar.gz
gsoc2013-evolution-268185761bcdee059f5d3b52937ee3c5667b79e5.tar.bz2
gsoc2013-evolution-268185761bcdee059f5d3b52937ee3c5667b79e5.tar.lz
gsoc2013-evolution-268185761bcdee059f5d3b52937ee3c5667b79e5.tar.xz
gsoc2013-evolution-268185761bcdee059f5d3b52937ee3c5667b79e5.tar.zst
gsoc2013-evolution-268185761bcdee059f5d3b52937ee3c5667b79e5.zip
change prototype to fix warning, and change the comment to read
2003-12-06 Chris Toshok <toshok@ximian.com> * gui/component/select-names/e-select-names-manager.c (open_book_cb): change prototype to fix warning, and change the comment to read load_source instead of load_uri (which isn't what we use anymore.) (update_completion_books): just use our source list for this. check the "completion" source property. (source_list_changed): recreate the completion books. (e_select_names_manager_init): connect to the source_list's changed signal. (e_select_names_manager_dispose): don't need to free the completion_uids list anymore. * gui/component/select-names/e-select-names-config.c (e_select_names_config_get_completion_books, e_select_names_config_set_completion_books, e_select_names_config_add_notification_completion_books): remove. * gui/component/select-names/e-select-names-config.h: remove the completion books calls, since we can just use the source list. * gui/component/component-factory.c (factory): create the autocompletion control. * gui/component/autocompletion-config.[ch]: new config control for selecting completion folders. Uses e-source-selector. Could probably be beautified a bit. * gui/component/Makefile.am (libevolution_addressbook_la_SOURCES): add autocompletion-config.[ch] * gui/component/GNOME_Evolution_Addressbook.server.in.in: remove the ldap config control server, and add the autocompletion one. svn path=/trunk/; revision=23663
-rw-r--r--addressbook/ChangeLog35
-rw-r--r--addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in51
-rw-r--r--addressbook/gui/component/Makefile.am2
-rw-r--r--addressbook/gui/component/autocompletion-config.c150
-rw-r--r--addressbook/gui/component/autocompletion-config.h30
-rw-r--r--addressbook/gui/component/component-factory.c4
-rw-r--r--addressbook/gui/component/select-names/e-select-names-config.c29
-rw-r--r--addressbook/gui/component/select-names/e-select-names-config.h5
-rw-r--r--addressbook/gui/component/select-names/e-select-names-manager.c59
-rw-r--r--addressbook/gui/component/select-names/e-select-names-manager.h1
10 files changed, 264 insertions, 102 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 882300601e..a68d11b86c 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,38 @@
+2003-12-06 Chris Toshok <toshok@ximian.com>
+
+ * gui/component/select-names/e-select-names-manager.c
+ (open_book_cb): change prototype to fix warning, and change the
+ comment to read load_source instead of load_uri (which isn't what
+ we use anymore.)
+ (update_completion_books): just use our source list for this.
+ check the "completion" source property.
+ (source_list_changed): recreate the completion books.
+ (e_select_names_manager_init): connect to the source_list's
+ changed signal.
+ (e_select_names_manager_dispose): don't need to free the
+ completion_uids list anymore.
+
+ * gui/component/select-names/e-select-names-config.c
+ (e_select_names_config_get_completion_books,
+ e_select_names_config_set_completion_books,
+ e_select_names_config_add_notification_completion_books): remove.
+
+ * gui/component/select-names/e-select-names-config.h: remove the
+ completion books calls, since we can just use the source list.
+
+ * gui/component/component-factory.c (factory): create the
+ autocompletion control.
+
+ * gui/component/autocompletion-config.[ch]: new config control for
+ selecting completion folders. Uses e-source-selector. Could
+ probably be beautified a bit.
+
+ * gui/component/Makefile.am (libevolution_addressbook_la_SOURCES):
+ add autocompletion-config.[ch]
+
+ * gui/component/GNOME_Evolution_Addressbook.server.in.in: remove
+ the ldap config control server, and add the autocompletion one.
+
2003-12-06 JP Rosevear <jpr@ximian.com>
* */Makefile.am: Remove hard coded disable deprecated flags
diff --git a/addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in b/addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in
index df47e0cffe..fb55b0df58 100644
--- a/addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in
+++ b/addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in
@@ -93,34 +93,6 @@
</oaf_server>
-<oaf_server iid="OAFIID:GNOME_Evolution_LDAPStorage_ConfigControl:@VERSION@"
- type="factory"
- location="OAFIID:GNOME_Evolution_Addressbook_Factory:@VERSION@">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/ConfigControl:@VERSION@"/>
- </oaf_attribute>
-
- <oaf_attribute name="evolution2:config_item:title" type="string"
- _value="Directory Servers"/>
-
- <oaf_attribute name="evolution2:config_item:description" type="string"
- _value="Configure access to LDAP directory servers here"/>
-
- <oaf_attribute name="evolution2:config_item:icon_name" type="string"
- value="ldap-settings.png"/>
-
- <oaf_attribute name="evolution2:config_item:type" type="stringv">
- <item value="contacts/ldap"/>
- </oaf_attribute>
-
- <oaf_attribute name="evolution2:config_item:priority" type="string" value="-6"/>
-
- <oaf_attribute name="name" type="string"
- _value="Evolution Addressbook LDAP Configuration Control"/>
-
-</oaf_server>
-
<oaf_server iid="OAFIID:GNOME_Evolution_SMime_CertificateManager_ConfigControl:@VERSION@"
type="factory"
location="OAFIID:GNOME_Evolution_Addressbook_Factory:@VERSION@">
@@ -145,4 +117,27 @@
</oaf_server>
+<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_Autocompletion_ConfigControl:@VERSION@"
+ type="factory"
+ location="OAFIID:GNOME_Evolution_Addressbook_Factory:@VERSION@">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/Evolution/ConfigControl:@VERSION@"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="evolution2:config_item:title" type="string"
+ _value="Autocompletion"/>
+
+ <oaf_attribute name="evolution2:config_item:description" type="string"
+ _value="Configure autocomple here"/>
+
+ <oaf_attribute name="evolution2:config_item:icon_name" type="string"
+ value="folder-settings.png"/>
+
+ <oaf_attribute name="evolution2:config_item:priority" type="string" value="-9"/>
+
+ <oaf_attribute name="name" type="string"
+ _value="Evolution folder settings configuration control"/>
+</oaf_server>
+
</oaf_info>
diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am
index ec2b5bd02a..09dcb8e537 100644
--- a/addressbook/gui/component/Makefile.am
+++ b/addressbook/gui/component/Makefile.am
@@ -29,6 +29,8 @@ libevolution_addressbook_la_SOURCES = \
addressbook-component.h \
addressbook-config.c \
addressbook-config.h \
+ autocompletion-config.c \
+ autocompletion-config.h \
addressbook.c \
addressbook.h \
component-factory.c
diff --git a/addressbook/gui/component/autocompletion-config.c b/addressbook/gui/component/autocompletion-config.c
new file mode 100644
index 0000000000..05898f6688
--- /dev/null
+++ b/addressbook/gui/component/autocompletion-config.c
@@ -0,0 +1,150 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-shell-config-autocompletion.h - Configuration page for addressbook autocompletion.
+ *
+ * Copyright (C) 2003 Novell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Chris Toshok <toshok@ximian.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "autocompletion-config.h"
+
+#include "Evolution.h"
+
+#include <bonobo/bonobo-exception.h>
+
+#include "e-source-selector.h"
+#include <libedataserver/e-source-list.h>
+#include <libgnome/gnome-i18n.h>
+#include <gtk/gtkwidget.h>
+#include <gtk/gtksignal.h>
+
+
+typedef struct {
+ EvolutionConfigControl *config_control;
+
+ GtkWidget *control_widget;
+
+ ESourceList *source_list;
+} AutocompletionConfig;
+
+static void
+source_selection_changed (ESourceSelector *selector,
+ AutocompletionConfig *ac)
+{
+ evolution_config_control_changed (ac->config_control);
+}
+
+static void
+config_control_destroy_notify (void *data,
+ GObject *where_the_config_control_was)
+{
+ AutocompletionConfig *ac = (AutocompletionConfig *) data;
+
+ g_object_unref (ac->source_list);
+
+ g_free (ac);
+}
+
+
+static void
+config_control_apply_callback (EvolutionConfigControl *config_control,
+ AutocompletionConfig *ac)
+{
+ GSList *selection;
+ GSList *l;
+ GSList *groups;
+
+ /* first we clear all the completion flags from all sources */
+ for (groups = e_source_list_peek_groups (ac->source_list); groups; groups = groups->next) {
+ ESourceGroup *group = E_SOURCE_GROUP (groups->data);
+ GSList *sources;
+ for (sources = e_source_group_peek_sources (group); sources; sources = sources->next) {
+ ESource *source = E_SOURCE (sources->data);
+
+ e_source_set_property (source, "completion", NULL);
+ }
+ }
+
+ /* then we loop over the selector's selection, setting the
+ property on those sources */
+ selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (ac->control_widget));
+ for (l = selection; l; l = l->next) {
+ e_source_set_property (E_SOURCE (l->data), "completion", "true");
+ }
+ e_source_selector_free_selection (selection);
+
+ e_source_list_sync (ac->source_list, NULL); /* XXX we should pop up a dialog if this fails */
+}
+
+static void
+initialize_selection (AutocompletionConfig *ac)
+{
+ GSList *groups;
+
+ for (groups = e_source_list_peek_groups (ac->source_list); groups; groups = groups->next) {
+ ESourceGroup *group = E_SOURCE_GROUP (groups->data);
+ GSList *sources;
+ for (sources = e_source_group_peek_sources (group); sources; sources = sources->next) {
+ ESource *source = E_SOURCE (sources->data);
+ const char *completion = e_source_get_property (source, "completion");
+ if (completion && !g_ascii_strcasecmp (completion, "true"))
+ e_source_selector_select_source (E_SOURCE_SELECTOR (ac->control_widget),
+ source);
+ }
+ }
+}
+
+EvolutionConfigControl*
+autocompletion_config_control_new (void)
+{
+ AutocompletionConfig *ac;
+ CORBA_Environment ev;
+
+ ac = g_new0 (AutocompletionConfig, 1);
+
+ CORBA_exception_init (&ev);
+
+ ac->source_list = e_source_list_new_for_gconf_default ("/apps/evolution/addressbook/sources");
+ /* XXX should we watch for the source list to change and
+ update it in the control? what about our local changes? */
+ /* g_signal_connect (ac->source_list, "changed", G_CALLBACK (source_list_changed), ac); */
+
+ ac->control_widget = e_source_selector_new (ac->source_list);
+
+ initialize_selection (ac);
+
+ gtk_widget_show (ac->control_widget);
+
+ ac->config_control = evolution_config_control_new (ac->control_widget);
+
+ g_signal_connect (ac->control_widget, "selection_changed",
+ G_CALLBACK (source_selection_changed), ac);
+ g_signal_connect (ac->config_control, "apply",
+ G_CALLBACK (config_control_apply_callback), ac);
+
+ g_object_weak_ref (G_OBJECT (ac->config_control), config_control_destroy_notify, ac);
+
+ CORBA_exception_free (&ev);
+
+ return ac->config_control;
+}
+
diff --git a/addressbook/gui/component/autocompletion-config.h b/addressbook/gui/component/autocompletion-config.h
new file mode 100644
index 0000000000..86f056477e
--- /dev/null
+++ b/addressbook/gui/component/autocompletion-config.h
@@ -0,0 +1,30 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-shell-config-autocompletion.h - Configuration page for addressbook autocompletion.
+ *
+ * Copyright (C) 2003 Novell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Chris Toshok <toshok@ximian.com>
+ */
+
+#ifndef _AUTOCOMPLETION_CONFIG_H
+#define _AUTOCOMPLETION_CONFIG_H
+
+#include "evolution-config-control.h"
+
+EvolutionConfigControl* autocompletion_config_control_new (void);
+
+#endif /* _AUTOCOMPLETION_CONFIG_H */
diff --git a/addressbook/gui/component/component-factory.c b/addressbook/gui/component/component-factory.c
index 82a766d070..08bf146691 100644
--- a/addressbook/gui/component/component-factory.c
+++ b/addressbook/gui/component/component-factory.c
@@ -26,6 +26,7 @@
#include "addressbook.h"
#include "addressbook-component.h"
#include "addressbook-config.h"
+#include "autocompletion-config.h"
#include "eab-popup-control.h"
#include "eab-vcard-control.h"
#include "select-names/e-select-names-bonobo.h"
@@ -43,6 +44,7 @@
#define ADDRESS_POPUP_ID "OAFIID:GNOME_Evolution_Addressbook_AddressPopup:" BASE_VERSION
#define SELECT_NAMES_ID "OAFIID:GNOME_Evolution_Addressbook_SelectNames:" BASE_VERSION
#define LDAP_STORAGE_CONFIG_CONTROL_ID "OAFIID:GNOME_Evolution_LDAPStorage_ConfigControl:" BASE_VERSION
+#define COMPLETION_CONFIG_CONTROL_ID "OAFIID:GNOME_Evolution_Addressbook_Autocompletion_ConfigControl:" BASE_VERSION
#define CERTIFICATE_MANAGER_CONFIG_CONTROL_ID "OAFIID:GNOME_Evolution_SMime_CertificateManager_ConfigControl:" BASE_VERSION
@@ -64,6 +66,8 @@ factory (BonoboGenericFactory *factory,
}
if (strcmp (component_id, ADDRESS_POPUP_ID) == 0)
return BONOBO_OBJECT (eab_popup_control_new ());
+ if (strcmp (component_id, COMPLETION_CONFIG_CONTROL_ID) == 0)
+ return BONOBO_OBJECT (autocompletion_config_control_new ());
#if 0
/* Config control is dead */
if (strcmp (component_id, LDAP_STORAGE_CONFIG_CONTROL_ID) == 0)
diff --git a/addressbook/gui/component/select-names/e-select-names-config.c b/addressbook/gui/component/select-names/e-select-names-config.c
index 1792a8a061..8335ed7c3b 100644
--- a/addressbook/gui/component/select-names/e-select-names-config.c
+++ b/addressbook/gui/component/select-names/e-select-names-config.c
@@ -59,35 +59,6 @@ e_select_names_config_remove_notification (guint id)
gconf_client_notify_remove (config, id);
}
-/* The current list of completion books */
-GSList *
-e_select_names_config_get_completion_books (void)
-{
- e_select_names_config_init ();
-
- return gconf_client_get_list (config, SELECT_NAMES_CONFIG_COMPLETION_BOOKS, GCONF_VALUE_STRING, NULL);
-}
-
-void
-e_select_names_config_set_completion_books (GSList *selected)
-{
- e_select_names_config_init ();
-
- gconf_client_set_list (config, SELECT_NAMES_CONFIG_COMPLETION_BOOKS, GCONF_VALUE_STRING, selected, NULL);
-}
-
-guint
-e_select_names_config_add_notification_completion_books (GConfClientNotifyFunc func, gpointer data)
-{
- guint id;
-
- e_select_names_config_init ();
-
- id = gconf_client_notify_add (config, SELECT_NAMES_CONFIG_COMPLETION_BOOKS, func, data, NULL, NULL);
-
- return id;
-}
-
char *
e_select_names_config_get_last_completion_book (void)
{
diff --git a/addressbook/gui/component/select-names/e-select-names-config.h b/addressbook/gui/component/select-names/e-select-names-config.h
index 9247e43337..12d2c1314d 100644
--- a/addressbook/gui/component/select-names/e-select-names-config.h
+++ b/addressbook/gui/component/select-names/e-select-names-config.h
@@ -29,11 +29,6 @@
void e_select_names_config_remove_notification (guint id);
-/* The current list of completion uris */
-GSList *e_select_names_config_get_completion_books (void);
-void e_select_names_config_set_completion_books (GSList *selected);
-guint e_select_names_config_add_notification_completion_books (GConfClientNotifyFunc func, gpointer data);
-
/* The last completion book */
char *e_select_names_config_get_last_completion_book (void);
void e_select_names_config_set_last_completion_book (const char *last_completion_book);
diff --git a/addressbook/gui/component/select-names/e-select-names-manager.c b/addressbook/gui/component/select-names/e-select-names-manager.c
index 41b355eea8..1b7cbbb38e 100644
--- a/addressbook/gui/component/select-names/e-select-names-manager.c
+++ b/addressbook/gui/component/select-names/e-select-names-manager.c
@@ -374,8 +374,10 @@ e_select_names_manager_discard_saved_models (ESelectNamesManager *manager)
/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */
static void
-open_book_cb (EBook *book, EBookStatus status, ESelectNamesManager *manager)
+open_book_cb (EBook *book, EBookStatus status, gpointer user_data)
{
+ ESelectNamesManager *manager = E_SELECT_NAMES_MANAGER (user_data);
+
if (status == E_BOOK_ERROR_OK) {
GList *l;
for (l = manager->entries; l; l = l->next) {
@@ -387,40 +389,34 @@ open_book_cb (EBook *book, EBookStatus status, ESelectNamesManager *manager)
g_object_ref (book);
}
- g_object_unref (manager); /* unref ourself (matches ref before the load_uri call below) */
+ g_object_unref (manager); /* unref ourself (matches ref before the load_source call below) */
}
static void
update_completion_books (ESelectNamesManager *manager)
{
- GSList *completion_uids, *l;
-
- /* Get the selection in gconf */
- completion_uids = e_select_names_config_get_completion_books ();
+ GSList *groups;
/* Add all the completion books */
- for (l = completion_uids; l; l = l->next) {
- char *uid = l->data;
- ESource *source;
-
- source = e_source_list_peek_source_by_uid (manager->source_list, uid);
- if (source) {
- EBook *book;
-
- book = e_book_new ();
-
- addressbook_load_source (book, source, (EBookCallback)open_book_cb, manager);
+ for (groups = e_source_list_peek_groups (manager->source_list); groups; groups = groups->next) {
+ ESourceGroup *group = E_SOURCE_GROUP (groups->data);
+ GSList *sources;
+
+ for (sources = e_source_group_peek_sources (group); sources; sources = sources->next) {
+ ESource *source = E_SOURCE (sources->data);
+ const char *completion = e_source_get_property (source, "completion");
+ if (completion && !g_ascii_strcasecmp (completion, "true")) {
+ EBook *book = e_book_new ();
+ g_object_ref (manager);
+ addressbook_load_source (book, source, open_book_cb, manager);
+ }
}
-
- g_free (uid);
}
- g_slist_free (completion_uids);
}
static void
-config_completion_books_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
+source_list_changed (ESourceList *source_list, ESelectNamesManager *manager)
{
- ESelectNamesManager *manager = data;
GList *l;
for (l = manager->entries; l; l = l->next) {
@@ -428,9 +424,6 @@ config_completion_books_changed_cb (GConfClient *client, guint id, GConfEntry *e
e_select_names_completion_clear_books (E_SELECT_NAMES_COMPLETION (entry->comp));
}
- g_slist_foreach (manager->completion_uids, (GFunc)g_free, NULL);
- g_slist_free (manager->completion_uids);
-
g_list_foreach (manager->completion_books, (GFunc)g_object_unref, NULL);
g_list_free (manager->completion_books);
manager->completion_books = NULL;
@@ -625,17 +618,14 @@ e_select_names_manager_init (ESelectNamesManager *manager)
manager->entries = NULL;
manager->source_list = e_source_list_new_for_gconf_default ("/apps/evolution/addressbook/sources");
-
- manager->completion_uids = e_select_names_config_get_completion_books ();
+ g_signal_connect (manager->source_list, "changed", G_CALLBACK (source_list_changed), manager);
+
manager->completion_books = NULL;
manager->minimum_query_length = e_select_names_config_get_min_query_length ();
update_completion_books (manager);
- not = e_select_names_config_add_notification_completion_books (config_completion_books_changed_cb, manager);
- manager->notifications = g_list_append (manager->notifications, GUINT_TO_POINTER (not));
-
not = e_select_names_config_add_notification_min_query_length (config_min_query_length_changed_cb, manager);
manager->notifications = g_list_append (manager->notifications, GUINT_TO_POINTER (not));
}
@@ -669,15 +659,6 @@ e_select_names_manager_dispose (GObject *object)
manager->source_list = NULL;
}
- if (manager->completion_uids) {
- GSList *l;
-
- for (l = manager->completion_uids; l; l = l->next)
- g_free (l->data);
- g_slist_free (manager->completion_uids);
- manager->completion_uids = NULL;
- }
-
if (manager->completion_books) {
g_list_foreach (manager->completion_books, (GFunc) g_object_unref, NULL);
g_list_free (manager->completion_books);
diff --git a/addressbook/gui/component/select-names/e-select-names-manager.h b/addressbook/gui/component/select-names/e-select-names-manager.h
index 18bead5512..0830d299d5 100644
--- a/addressbook/gui/component/select-names/e-select-names-manager.h
+++ b/addressbook/gui/component/select-names/e-select-names-manager.h
@@ -33,7 +33,6 @@ struct _ESelectNamesManager {
ESelectNames *names;
ESourceList *source_list;
- GSList *completion_uids;
GList *completion_books;
int minimum_query_length;