aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2003-12-06 05:46:18 +0800
committerJP Rosevear <jpr@src.gnome.org>2003-12-06 05:46:18 +0800
commit4b5f82028ea07df810b81cf04bfe9e4792e1ecb2 (patch)
treebf0683a9d181cf802f4e11ad424b1b5c31ea7518
parentb57968e1216d9bdeddb8e6e3fbc8e61ce101cc17 (diff)
downloadgsoc2013-evolution-4b5f82028ea07df810b81cf04bfe9e4792e1ecb2.tar.gz
gsoc2013-evolution-4b5f82028ea07df810b81cf04bfe9e4792e1ecb2.tar.zst
gsoc2013-evolution-4b5f82028ea07df810b81cf04bfe9e4792e1ecb2.zip
no more custom widget for the selection of the search source
2003-12-05 JP Rosevear <jpr@ximian.com> * gui/component/select-names/select-names.glade: no more custom widget for the selection of the search source * gui/component/select-names/e-select-names.h: add member * gui/component/select-names/e-select-names.etspec: update model column * gui/component/select-names/e-select-names.c (find_first_source): find the first source in the list (addressbook_model_set_source): we have the source to set directly now (source_selected): listen for the source item to change (e_select_names_init): create a source option menu and hook it up (e_select_names_dispose): destroy the source list (e_select_names_new): do away with the config setup here * gui/component/select-names/e-select-names-manager.h: update members * gui/component/select-names/e-select-names-manager.c (update_completion_books): add books based on source uid (config_completion_books_changed_cb): handle the completion list changing (config_min_query_length_changed_cb): handle minimum query length changing (e_select_names_manager_new): we don't do the settings stuff here any more (e_select_names_manager_init): do the initial set up here for the book loaded and listen for changes (e_select_names_manager_dispose): destroy the new stuff * gui/component/select-names/e-select-names-config.[hc]: config information * gui/component/select-names/e-select-names-config-keys.h: the config keys * gui/component/select-names/e-select-names-bonobo.c (impl_SelectNames_activate_dialog): do away with the shell client stuff * gui/component/select-names/Makefile.am: build new files svn path=/trunk/; revision=23654
-rw-r--r--addressbook/ChangeLog46
-rw-r--r--addressbook/gui/component/select-names/Makefile.am3
-rw-r--r--addressbook/gui/component/select-names/e-select-names-bonobo.c16
-rw-r--r--addressbook/gui/component/select-names/e-select-names-config-keys.h39
-rw-r--r--addressbook/gui/component/select-names/e-select-names-config.c146
-rw-r--r--addressbook/gui/component/select-names/e-select-names-config.h48
-rw-r--r--addressbook/gui/component/select-names/e-select-names-manager.c171
-rw-r--r--addressbook/gui/component/select-names/e-select-names-manager.h8
-rw-r--r--addressbook/gui/component/select-names/e-select-names.c134
-rw-r--r--addressbook/gui/component/select-names/e-select-names.etspec2
-rw-r--r--addressbook/gui/component/select-names/e-select-names.h14
-rw-r--r--addressbook/gui/component/select-names/select-names.glade21
12 files changed, 439 insertions, 209 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 392d90a69a..2623783e93 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,49 @@
+2003-12-05 JP Rosevear <jpr@ximian.com>
+
+ * gui/component/select-names/select-names.glade: no more custom
+ widget for the selection of the search source
+
+ * gui/component/select-names/e-select-names.h: add member
+
+ * gui/component/select-names/e-select-names.etspec: update model
+ column
+
+ * gui/component/select-names/e-select-names.c (find_first_source):
+ find the first source in the list
+ (addressbook_model_set_source): we have the source to set directly
+ now
+ (source_selected): listen for the source item to change
+ (e_select_names_init): create a source option menu and hook it up
+ (e_select_names_dispose): destroy the source list
+ (e_select_names_new): do away with the config setup here
+
+ * gui/component/select-names/e-select-names-manager.h: update
+ members
+
+ * gui/component/select-names/e-select-names-manager.c
+ (update_completion_books): add books based on source uid
+ (config_completion_books_changed_cb): handle the completion list
+ changing
+ (config_min_query_length_changed_cb): handle minimum query length
+ changing
+ (e_select_names_manager_new): we don't do the settings stuff here
+ any more
+ (e_select_names_manager_init): do the initial set up here for the
+ book loaded and listen for changes
+ (e_select_names_manager_dispose): destroy the new stuff
+
+ * gui/component/select-names/e-select-names-config.[hc]: config
+ information
+
+ * gui/component/select-names/e-select-names-config-keys.h: the
+ config keys
+
+ * gui/component/select-names/e-select-names-bonobo.c
+ (impl_SelectNames_activate_dialog): do away with the shell client
+ stuff
+
+ * gui/component/select-names/Makefile.am: build new files
+
2003-12-05 Chris Toshok <toshok@ximian.com>
* gui/widgets/e-addressbook-model.c (book_view_loaded): call
diff --git a/addressbook/gui/component/select-names/Makefile.am b/addressbook/gui/component/select-names/Makefile.am
index b2a5e9e1aa..5b8a822149 100644
--- a/addressbook/gui/component/select-names/Makefile.am
+++ b/addressbook/gui/component/select-names/Makefile.am
@@ -54,6 +54,9 @@ libeselectnames_la_SOURCES = \
e-select-names-bonobo.h \
e-select-names-completion.c \
e-select-names-completion.h \
+ e-select-names-config.c \
+ e-select-names-config.h \
+ e-select-names-config-keys.h \
e-select-names-manager.c \
e-select-names-manager.h \
e-select-names-model.c \
diff --git a/addressbook/gui/component/select-names/e-select-names-bonobo.c b/addressbook/gui/component/select-names/e-select-names-bonobo.c
index c4fe9d257d..1977abe95f 100644
--- a/addressbook/gui/component/select-names/e-select-names-bonobo.c
+++ b/addressbook/gui/component/select-names/e-select-names-bonobo.c
@@ -489,27 +489,13 @@ impl_SelectNames_activate_dialog (PortableServer_Servant servant,
const CORBA_char *section_id,
CORBA_Environment *ev)
{
-#if 0 /* FIXME */
ESelectNamesBonobo *select_names;
ESelectNamesBonoboPrivate *priv;
- EvolutionShellClient *shell_client;
- GNOME_Evolution_Shell shell;
select_names = E_SELECT_NAMES_BONOBO (bonobo_object (servant));
priv = select_names->priv;
- shell = bonobo_activation_activate_from_id (
- "OAFIID:GNOME_Evolution_Shell:" BASE_VERSION,
- Bonobo_ACTIVATION_FLAG_EXISTING_ONLY,
- NULL, ev);
- if (BONOBO_EX (ev))
- return;
-
- shell_client = evolution_shell_client_new (shell);
- e_select_names_manager_activate_dialog (priv->manager, shell_client,
- section_id);
- g_object_unref (shell_client);
-#endif
+ e_select_names_manager_activate_dialog (priv->manager, section_id);
}
diff --git a/addressbook/gui/component/select-names/e-select-names-config-keys.h b/addressbook/gui/component/select-names/e-select-names-config-keys.h
new file mode 100644
index 0000000000..e0f08c3019
--- /dev/null
+++ b/addressbook/gui/component/select-names/e-select-names-config-keys.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Authors :
+ * JP Rosevear <jpr@ximian.com>
+ *
+ * Copyright 2003, Ximian, 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
+ */
+
+#ifndef _E_SELECT_NAMES_CONFIG_KEYS_H_
+#define _E_SELECT_NAMES_CONFIG_KEYS_H_
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define SELECT_NAMES_CONFIG_PREFIX "/apps/evolution/addressbook/completion"
+
+/* Display settings */
+#define SELECT_NAMES_CONFIG_COMPLETION_BOOKS SELECT_NAMES_CONFIG_PREFIX "/books"
+#define SELECT_NAMES_CONFIG_LAST_COMPLETION_BOOK SELECT_NAMES_CONFIG_PREFIX "/last_book"
+#define SELECT_NAMES_CONFIG_MIN_QUERY_LENGTH SELECT_NAMES_CONFIG_PREFIX "/minimum_query_length"
+
+G_END_DECLS
+
+#endif
diff --git a/addressbook/gui/component/select-names/e-select-names-config.c b/addressbook/gui/component/select-names/e-select-names-config.c
new file mode 100644
index 0000000000..1792a8a061
--- /dev/null
+++ b/addressbook/gui/component/select-names/e-select-names-config.c
@@ -0,0 +1,146 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * Authors :
+ * Damon Chaplin <damon@ximian.com>
+ * Rodrigo Moya <rodrigo@ximian.com>
+ *
+ * Copyright 2000, Ximian, Inc.
+ * Copyright 2000, Ximian, 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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+
+#include "e-select-names-config-keys.h"
+#include "e-select-names-config.h"
+
+static GConfClient *config = NULL;
+
+static void
+do_cleanup (void)
+{
+ g_object_unref (config);
+ config = NULL;
+}
+
+static void
+e_select_names_config_init (void)
+{
+ if (config)
+ return;
+
+ config = gconf_client_get_default ();
+ g_atexit ((GVoidFunc) do_cleanup);
+
+ gconf_client_add_dir (config, SELECT_NAMES_CONFIG_PREFIX, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
+}
+
+void
+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)
+{
+ e_select_names_config_init ();
+
+ return gconf_client_get_string (config, SELECT_NAMES_CONFIG_LAST_COMPLETION_BOOK, NULL);
+}
+
+void
+e_select_names_config_set_last_completion_book (const char *last_completion_book)
+{
+ e_select_names_config_init ();
+
+ gconf_client_set_string (config, SELECT_NAMES_CONFIG_LAST_COMPLETION_BOOK, last_completion_book, NULL);
+}
+
+guint
+e_select_names_config_add_notification_last_completion_book (GConfClientNotifyFunc func, gpointer data)
+{
+ guint id;
+
+ e_select_names_config_init ();
+
+ id = gconf_client_notify_add (config, SELECT_NAMES_CONFIG_LAST_COMPLETION_BOOK, func, data, NULL, NULL);
+
+ return id;
+}
+
+gint
+e_select_names_config_get_min_query_length (void)
+{
+ e_select_names_config_init ();
+
+ return gconf_client_get_int (config, SELECT_NAMES_CONFIG_MIN_QUERY_LENGTH, NULL);
+}
+
+
+void
+e_select_names_config_set_min_query_length (gint day_end_hour)
+{
+ e_select_names_config_init ();
+
+ gconf_client_set_int (config, SELECT_NAMES_CONFIG_MIN_QUERY_LENGTH, day_end_hour, NULL);
+}
+
+guint
+e_select_names_config_add_notification_min_query_length (GConfClientNotifyFunc func, gpointer data)
+{
+ guint id;
+
+ e_select_names_config_init ();
+
+ id = gconf_client_notify_add (config, SELECT_NAMES_CONFIG_MIN_QUERY_LENGTH, func, data, NULL, NULL);
+
+ return id;
+}
diff --git a/addressbook/gui/component/select-names/e-select-names-config.h b/addressbook/gui/component/select-names/e-select-names-config.h
new file mode 100644
index 0000000000..9247e43337
--- /dev/null
+++ b/addressbook/gui/component/select-names/e-select-names-config.h
@@ -0,0 +1,48 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Authors :
+ * Damon Chaplin <damon@ximian.com>
+ * Rodrigo Moya <rodrigo@ximian.com>
+ *
+ * Copyright 2000, Ximian, Inc.
+ * Copyright 2000, Ximian, 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
+ */
+
+#ifndef _E_SELECT_NAMES_CONFIG_H_
+#define _E_SELECT_NAMES_CONFIG_H_
+
+#include <gconf/gconf-client.h>
+
+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);
+guint e_select_names_config_add_notification_last_completion_book (GConfClientNotifyFunc func, gpointer data);
+
+
+/* The minimum query length */
+gint e_select_names_config_get_min_query_length (void);
+void e_select_names_config_set_min_query_length (gint day_end_hour);
+guint e_select_names_config_add_notification_min_query_length (GConfClientNotifyFunc func, gpointer data);
+
+#endif /* _E_SELECT_NAMES_CONFIG_H_ */
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 b7b91b42d0..41b355eea8 100644
--- a/addressbook/gui/component/select-names/e-select-names-manager.c
+++ b/addressbook/gui/component/select-names/e-select-names-manager.c
@@ -16,6 +16,7 @@
#include <gal/e-text/e-entry.h>
#include <libgnome/gnome-i18n.h>
+#include "e-select-names-config.h"
#include "e-select-names-manager.h"
#include "e-select-names-marshal.h"
#include "e-select-names-model.h"
@@ -372,7 +373,6 @@ e_select_names_manager_discard_saved_models (ESelectNamesManager *manager)
/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */
-
static void
open_book_cb (EBook *book, EBookStatus status, ESelectNamesManager *manager)
{
@@ -391,93 +391,67 @@ open_book_cb (EBook *book, EBookStatus status, ESelectNamesManager *manager)
}
static void
-load_completion_books (ESelectNamesManager *manager)
+update_completion_books (ESelectNamesManager *manager)
{
-#if 0
- EFolderListItem *folders = e_folder_list_parse_xml (manager->cached_folder_list);
- EFolderListItem *f;
-
- for (f = folders; f && f->physical_uri; f++) {
- EBook *book = e_book_new ();
- ESourceGroup *group;
- ESource *source;
+ GSList *completion_uids, *l;
- g_object_ref (manager); /* ref ourself before our async call */
+ /* Get the selection in gconf */
+ completion_uids = e_select_names_config_get_completion_books ();
- /* FIXME: Store source UIDs in folder list and use those to get sources */
- group = e_source_group_new ("", f->physical_uri);
- source = e_source_new ("", "");
- e_source_set_group (source, group);
+ /* 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;
- addressbook_load_source (book, source, (EBookCallback)open_book_cb, manager);
+ book = e_book_new ();
- g_object_unref (group);
- g_object_unref (source);
+ addressbook_load_source (book, source, (EBookCallback)open_book_cb, manager);
+ }
+
+ g_free (uid);
}
- e_folder_list_free_items (folders);
-#endif
+ g_slist_free (completion_uids);
}
static void
-read_completion_settings_from_db (ESelectNamesManager *manager, EConfigListener *db)
+config_completion_books_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
{
- char *val;
- long ival;
-
- val = e_config_listener_get_string (db, "/apps/evolution/addressbook/completion/uris");
-
- if (val) {
- g_free (manager->cached_folder_list);
- manager->cached_folder_list = val;
- load_completion_books(manager);
+ ESelectNamesManager *manager = data;
+ GList *l;
+
+ for (l = manager->entries; l; l = l->next) {
+ ESelectNamesManagerEntry *entry = l->data;
+ e_select_names_completion_clear_books (E_SELECT_NAMES_COMPLETION (entry->comp));
}
- ival = e_config_listener_get_long (db, "/apps/evolution/addressbook/completion/minimum_query_length");
- if (ival <= 0) ival = DEFAULT_MINIMUM_QUERY_LENGTH;
+ g_slist_foreach (manager->completion_uids, (GFunc)g_free, NULL);
+ g_slist_free (manager->completion_uids);
- manager->minimum_query_length = ival;
+ g_list_foreach (manager->completion_books, (GFunc)g_object_unref, NULL);
+ g_list_free (manager->completion_books);
+ manager->completion_books = NULL;
+
+ update_completion_books (manager);
}
static void
-db_listener (EConfigListener *db, const char *key,
- ESelectNamesManager *manager)
+config_min_query_length_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
{
+ ESelectNamesManager *manager = data;
GList *l;
-
- if (!strcmp (key, "/apps/evolution/addressbook/completion/uris")) {
- char *val = e_config_listener_get_string (db, key);
-
- if (!val)
- return;
-
- if (!manager->cached_folder_list || strcmp (val, manager->cached_folder_list)) {
- for (l = manager->entries; l; l = l->next) {
- ESelectNamesManagerEntry *entry = l->data;
- e_select_names_completion_clear_books (E_SELECT_NAMES_COMPLETION (entry->comp));
- }
-
- g_list_foreach (manager->completion_books, (GFunc)g_object_unref, NULL);
- g_list_free (manager->completion_books);
- manager->completion_books = NULL;
-
- g_free (manager->cached_folder_list);
- manager->cached_folder_list = val;
- load_completion_books (manager);
- }
- }
- else if (!strcmp (key, "/apps/evolution/addressbook/completion/minimum_query_length")) {
- long ival = e_config_listener_get_long (db, key);
-
- if (ival <= 0)
- ival = DEFAULT_MINIMUM_QUERY_LENGTH;
-
- manager->minimum_query_length = ival;
-
- for (l = manager->entries; l; l = l->next) {
- ESelectNamesManagerEntry *entry = l->data;
- e_select_names_completion_set_minimum_query_length (E_SELECT_NAMES_COMPLETION(entry->comp),
- manager->minimum_query_length);
- }
+
+ manager->minimum_query_length = e_select_names_config_get_min_query_length ();
+ if (manager->minimum_query_length <= 0)
+ manager->minimum_query_length = DEFAULT_MINIMUM_QUERY_LENGTH;
+
+ for (l = manager->entries; l; l = l->next) {
+ ESelectNamesManagerEntry *entry = l->data;
+ e_select_names_completion_set_minimum_query_length (E_SELECT_NAMES_COMPLETION(entry->comp),
+ manager->minimum_query_length);
}
}
@@ -490,15 +464,6 @@ ESelectNamesManager *
e_select_names_manager_new (void)
{
ESelectNamesManager *manager = g_object_new (E_TYPE_SELECT_NAMES_MANAGER, NULL);
- EConfigListener *db;
-
- db = eab_get_config_database();
-
- manager->listener_id = g_signal_connect (db,
- "key_changed",
- G_CALLBACK (db_listener), manager);
-
- read_completion_settings_from_db (manager, db);
return manager;
}
@@ -654,10 +619,25 @@ e_select_names_manager_activate_dialog (ESelectNamesManager *manager,
static void
e_select_names_manager_init (ESelectNamesManager *manager)
{
+ guint not;
+
manager->sections = NULL;
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 ();
manager->completion_books = NULL;
- manager->cached_folder_list = 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));
}
static void
@@ -684,22 +664,35 @@ e_select_names_manager_dispose (GObject *object)
manager->entries = NULL;
}
+ if (manager->source_list) {
+ g_object_unref (manager->source_list);
+ 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);
manager->completion_books = NULL;
}
- if (manager->listener_id) {
- g_signal_handler_disconnect (eab_get_config_database(), manager->listener_id);
- manager->listener_id = 0;
- }
-
- if (manager->cached_folder_list) {
- g_free (manager->cached_folder_list);
- manager->cached_folder_list = NULL;
+ if (manager->notifications) {
+ GList *l;
+
+ for (l = manager->notifications; l; l = l->next)
+ e_select_names_config_remove_notification (GPOINTER_TO_UINT (l->data));
+ g_list_free (manager->notifications);
+ manager->notifications = NULL;
}
-
+
if (G_OBJECT_CLASS (parent_class)->dispose)
G_OBJECT_CLASS (parent_class)->dispose (object);
}
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 f5fb4aa451..18bead5512 100644
--- a/addressbook/gui/component/select-names/e-select-names-manager.h
+++ b/addressbook/gui/component/select-names/e-select-names-manager.h
@@ -32,13 +32,13 @@ struct _ESelectNamesManager {
ESelectNames *names;
+ ESourceList *source_list;
+ GSList *completion_uids;
GList *completion_books;
-
+
int minimum_query_length;
- gulong listener_id;
-
- char *cached_folder_list;
+ GList *notifications;
};
struct _ESelectNamesManagerClass {
diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c
index 488ed10f0a..3925857447 100644
--- a/addressbook/gui/component/select-names/e-select-names.c
+++ b/addressbook/gui/component/select-names/e-select-names.c
@@ -36,6 +36,7 @@
#include <addressbook/gui/component/addressbook-component.h>
#include <addressbook/gui/component/addressbook.h>
+#include "e-select-names-config.h"
#include "e-select-names.h"
#include "e-select-names-table-model.h"
#include <gal/widgets/e-categories-master-list-option-menu.h>
@@ -106,7 +107,6 @@ e_select_names_class_init (ESelectNamesClass *klass)
}
GtkWidget *e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int num1, int num2);
-GtkWidget *e_addressbook_create_folder_selector(char *name, char *string1, char *string2, int num1, int num2);
static void
search_result (EABModel *model, EBookViewStatus status, ESelectNames *esn)
@@ -126,36 +126,37 @@ set_book(EBook *book, EBookStatus status, ESelectNames *esn)
g_object_unref(esn);
}
+static ESource *
+find_first_source (ESourceList *source_list)
+{
+ GSList *groups, *sources, *l, *m;
+
+ groups = e_source_list_peek_groups (source_list);
+ for (l = groups; l; l = l->next) {
+ ESourceGroup *group = l->data;
+
+ sources = e_source_group_peek_sources (group);
+ for (m = sources; m; m = m->next) {
+ ESource *source = m->data;
+
+ return source;
+ }
+ }
+
+ return NULL;
+}
+
static void
-addressbook_model_set_uri(ESelectNames *e_select_names, EABModel *model, const char *uri)
+addressbook_model_set_source (ESelectNames *e_select_names, EABModel *model, ESource *source)
{
EBook *book;
- ESourceGroup *group;
- ESource *source;
-
- /* If uri == the current uri, then we don't have to do anything */
- book = eab_model_get_ebook (model);
- if (book) {
- const gchar *current_uri = e_book_get_uri (book);
- if (current_uri && !strcmp (uri, current_uri)) {
- return;
- }
- }
book = e_book_new();
g_object_ref(e_select_names);
g_object_ref(model);
- /* FIXME: Store source UIDs in last_used etc. and use that to get sources */
- group = e_source_group_new ("", uri);
- source = e_source_new ("", "");
- e_source_set_group (source, group);
-
addressbook_load_source (book, source, (EBookCallback) set_book, e_select_names);
-
- g_object_unref (group);
- g_object_unref (source);
}
static void *
@@ -331,23 +332,12 @@ e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int n
return table;
}
-GtkWidget *
-e_addressbook_create_folder_selector(char *name, char *string1, char *string2, int num1, int num2)
-{
- return gtk_label_new ("FIXME");
-}
-
-#if 0 /* FIXME */
static void
-folder_selected (EvolutionFolderSelectorButton *button, GNOME_Evolution_Folder *folder,
- ESelectNames *e_select_names)
+source_selected (ESourceOptionMenu *menu, ESource *source, ESelectNames *e_select_names)
{
- addressbook_model_set_uri(e_select_names, e_select_names->model, folder->physicalUri);
-
- e_config_listener_set_string (eab_get_config_database(),
- "/apps/evolution/addressbook/select_names/last_used_uri", folder->physicalUri);
+ addressbook_model_set_source (e_select_names, e_select_names->model, source);
+ e_select_names_config_set_last_completion_book (e_source_peek_uid (source));
}
-#endif
static void
update_query (GtkWidget *widget, ESelectNames *e_select_names)
@@ -479,11 +469,25 @@ static void
e_select_names_init (ESelectNames *e_select_names)
{
GladeXML *gui;
- GtkWidget *widget, *button;
-
+ GtkWidget *widget, *button, *table, *esom;
+ ESource *source = NULL;
+ char *uid;
+
+ /* FIXME What to do on error/NULL ? */
+ e_select_names->source_list = e_source_list_new_for_gconf_default ("/apps/evolution/addressbook/sources");
+
gui = glade_xml_new (EVOLUTION_GLADEDIR "/select-names.glade", NULL, NULL);
e_select_names->gui = gui;
+ /* Add the source menu */
+ esom = e_source_option_menu_new (e_select_names->source_list);
+ g_signal_connect (esom, "source_selected", G_CALLBACK (source_selected), e_select_names);
+ gtk_widget_show (esom);
+
+ table = glade_xml_get_widget (gui, "show_contacts_table");
+ gtk_table_attach (GTK_TABLE (table), esom, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
+
+ /* Set up the rest of the widgets */
e_select_names->children = g_hash_table_new(g_str_hash, g_str_equal);
e_select_names->child_count = 0;
e_select_names->def = NULL;
@@ -559,19 +563,25 @@ e_select_names_init (ESelectNames *e_select_names)
g_signal_connect(button, "clicked",
G_CALLBACK(update_query), e_select_names);
- button = glade_xml_get_widget (gui, "folder-selector");
-#if 0 /* FIXME */
- if (button && EVOLUTION_IS_FOLDER_SELECTOR_BUTTON (button))
- g_signal_connect(button, "selected",
- G_CALLBACK(folder_selected), e_select_names);
-#endif
- gtk_widget_show (button);
-
g_signal_connect (e_table_scrolled_get_table (e_select_names->table), "double_click",
G_CALLBACK (add_address), e_select_names);
g_signal_connect (e_table_scrolled_get_table (e_select_names->table), "selection_change",
G_CALLBACK (selection_change), e_select_names);
selection_change (e_table_scrolled_get_table (e_select_names->table), e_select_names);
+
+ /* Select a source for to display initially */
+ uid = e_select_names_config_get_last_completion_book ();
+ if (uid) {
+ source = e_source_list_peek_source_by_uid (e_select_names->source_list, uid);
+ g_free (uid);
+ }
+
+ if (!source)
+ source = find_first_source (e_select_names->source_list);
+
+ /* FIXME What if we still can't find a source? */
+ e_source_option_menu_select (E_SOURCE_OPTION_MENU (esom), source);
+
}
static void e_select_names_child_free(char *key, ESelectNamesChild *child, ESelectNames *e_select_names)
@@ -590,6 +600,11 @@ e_select_names_dispose (GObject *object)
{
ESelectNames *e_select_names = E_SELECT_NAMES(object);
+ if (e_select_names->source_list) {
+ g_object_unref (e_select_names->source_list);
+ e_select_names->source_list = NULL;
+ }
+
if (e_select_names->status_id) {
g_signal_handler_disconnect(e_select_names->model, e_select_names->status_id);
e_select_names->status_id = 0;
@@ -637,36 +652,9 @@ GtkWidget*
e_select_names_new (void)
{
ESelectNames *e_select_names;
- const char *selector_types[] = { "contacts/*", NULL };
- char *contacts_uri;
- GtkWidget *button;
- EConfigListener *db;
-
+
e_select_names = g_object_new (E_TYPE_SELECT_NAMES, NULL);
- db = eab_get_config_database ();
- contacts_uri = e_config_listener_get_string_with_default (
- db, "/apps/evolution/addressbook/select_names/last_used_uri",
- NULL, NULL);
-#if notyet
- if (!contacts_uri)
- contacts_uri = g_strdup (e_book_get_default_book_uri ());
-#endif
-
- button = glade_xml_get_widget (e_select_names->gui, "folder-selector");
-
-#if 0 /* FIXME */
- evolution_folder_selector_button_construct (EVOLUTION_FOLDER_SELECTOR_BUTTON (button),
- shell_client,
- _("Find contact in"),
- contacts_uri,
- selector_types);
-#endif
-
- addressbook_model_set_uri(e_select_names, e_select_names->model, contacts_uri);
-
- g_free (contacts_uri);
-
return GTK_WIDGET (e_select_names);
}
diff --git a/addressbook/gui/component/select-names/e-select-names.etspec b/addressbook/gui/component/select-names/e-select-names.etspec
index 114f84cc8c..7a260887ff 100644
--- a/addressbook/gui/component/select-names/e-select-names.etspec
+++ b/addressbook/gui/component/select-names/e-select-names.etspec
@@ -1,5 +1,5 @@
<ETableSpecification no-headers="true" cursor-mode="line">
- <ETableColumn model_col= "44" _title="Name" expansion="1.0" minimum_width="20" resizable="true" cell="string" compare="collate" search="string"/>
+ <ETableColumn model_col= "69" _title="Name" expansion="1.0" minimum_width="20" resizable="true" cell="string" compare="collate" search="string"/>
<ETableState>
<column source="0"/>
<grouping> <leaf column="0" ascending="true"/> </grouping>
diff --git a/addressbook/gui/component/select-names/e-select-names.h b/addressbook/gui/component/select-names/e-select-names.h
index 3624e40073..e927932d13 100644
--- a/addressbook/gui/component/select-names/e-select-names.h
+++ b/addressbook/gui/component/select-names/e-select-names.h
@@ -26,15 +26,14 @@
#include <glade/glade.h>
#include <gal/e-table/e-table.h>
#include <gal/e-table/e-table-scrolled.h>
+#include <libedataserver/e-source-list.h>
+#include <widgets/misc/e-source-option-menu.h>
#include "e-addressbook-model.h"
#include "e-select-names-model.h"
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
+G_BEGIN_DECLS
/* ESelectNames - A dialog displaying information about a contact.
*
@@ -58,6 +57,8 @@ struct _ESelectNames
{
GtkDialog parent;
+ ESourceList *source_list;
+
/* item specific fields */
GladeXML *gui;
@@ -95,9 +96,6 @@ void e_select_names_add_section (ESelectNames *e_select_names,
void e_select_names_set_default (ESelectNames *e_select_names,
const char *id);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
+G_END_DECLS
#endif /* __E_SELECT_NAMES_H__ */
diff --git a/addressbook/gui/component/select-names/select-names.glade b/addressbook/gui/component/select-names/select-names.glade
index 7ff1b4ebc7..bf63b9dfa4 100644
--- a/addressbook/gui/component/select-names/select-names.glade
+++ b/addressbook/gui/component/select-names/select-names.glade
@@ -2,6 +2,7 @@
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
+<requires lib="gnome"/>
<widget class="GtkDialog" id="dialog-top">
<property name="border_width">12</property>
@@ -307,7 +308,7 @@ select one from the list below:</property>
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
<child>
- <widget class="GtkTable" id="table5">
+ <widget class="GtkTable" id="show_contacts_table">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="n_rows">2</property>
@@ -390,24 +391,6 @@ select one from the list below:</property>
<property name="y_options">fill</property>
</packing>
</child>
-
- <child>
- <widget class="Custom" id="folder-selector">
- <property name="visible">True</property>
- <property name="creation_function">e_addressbook_create_folder_selector</property>
- <property name="int1">0</property>
- <property name="int2">0</property>
- <property name="last_modification_time">Mon, 15 Jul 2002 02:21:32 GMT</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">0</property>
- <property name="bottom_attach">1</property>
- <property name="x_options">fill</property>
- <property name="y_options">fill</property>
- </packing>
- </child>
</widget>
</child>