aboutsummaryrefslogtreecommitdiffstats
path: root/modules/addressbook/autocompletion-config.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-06-25 00:59:33 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-06-25 06:29:22 +0800
commitf0d3f3afdfa314e1e8cd7d8da790878008a46aad (patch)
tree7116e2a18c7bd50633b2f8de42b5377af1e8172a /modules/addressbook/autocompletion-config.c
parent94302ea73cde0b470faad653f752406f19f202d7 (diff)
downloadgsoc2013-evolution-f0d3f3afdfa314e1e8cd7d8da790878008a46aad.tar
gsoc2013-evolution-f0d3f3afdfa314e1e8cd7d8da790878008a46aad.tar.gz
gsoc2013-evolution-f0d3f3afdfa314e1e8cd7d8da790878008a46aad.tar.bz2
gsoc2013-evolution-f0d3f3afdfa314e1e8cd7d8da790878008a46aad.tar.lz
gsoc2013-evolution-f0d3f3afdfa314e1e8cd7d8da790878008a46aad.tar.xz
gsoc2013-evolution-f0d3f3afdfa314e1e8cd7d8da790878008a46aad.tar.zst
gsoc2013-evolution-f0d3f3afdfa314e1e8cd7d8da790878008a46aad.zip
Radically reorganize source code.
- Collect all shell modules into a new top-level 'modules' directory: $(top_srcdir)/modules/addressbook $(top_srcdir)/modules/calendar $(top_srcdir)/modules/mail Nothing is allowed to link to these, not plugins nor other modules. THIS SOLVES BUG #571275 AND OPENS THE DOOR TO PORTING TO MAC OS X. - Mimic the libevolution-mail-shared library from master (except drop the "shared" suffix) and have libevolution-mail-importers and all mail-related plugins link to it. - Discard the a11y subdirectories and have the files live alongside their counterpart widgets.
Diffstat (limited to 'modules/addressbook/autocompletion-config.c')
-rw-r--r--modules/addressbook/autocompletion-config.c137
1 files changed, 137 insertions, 0 deletions
diff --git a/modules/addressbook/autocompletion-config.c b/modules/addressbook/autocompletion-config.c
new file mode 100644
index 0000000000..370c1a1e7e
--- /dev/null
+++ b/modules/addressbook/autocompletion-config.c
@@ -0,0 +1,137 @@
+/*
+ * e-shell-config-autocompletion.h - Configuration page for addressbook autocompletion.
+ *
+ * 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/>
+ *
+ *
+ * Authors:
+ * Chris Toshok <toshok@ximian.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "autocompletion-config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+#include <libedataserver/e-source-list.h>
+#include <libedataserverui/e-source-selector.h>
+#include <libedataserverui/e-name-selector-entry.h>
+
+#include "widgets/misc/e-preferences-window.h"
+
+static void
+source_selection_changed_cb (ESourceSelector *source_selector)
+{
+ ESourceList *source_list;
+ GSList *selection;
+ GSList *l;
+ GSList *groups;
+
+ source_list = e_source_selector_get_source_list (source_selector);
+
+ /* first we clear all the completion flags from all sources */
+ for (groups = e_source_list_peek_groups (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 (source_selector);
+ for (l = selection; l; l = l->next) {
+ ESource *source = E_SOURCE (l->data);
+
+ e_source_set_property (source, "completion", "true");
+ }
+ e_source_selector_free_selection (selection);
+
+ /* XXX we should pop up a dialog if this fails */
+ e_source_list_sync (source_list, NULL);
+}
+
+static void
+initialize_selection (ESourceSelector *source_selector)
+{
+ ESourceList *source_list;
+ GSList *groups;
+
+ source_list = e_source_selector_get_source_list (source_selector);
+
+ for (groups = e_source_list_peek_groups (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 gchar *completion;
+
+ completion = e_source_get_property (source, "completion");
+ if (completion && !g_ascii_strcasecmp (completion, "true"))
+ e_source_selector_select_source (source_selector, source);
+ }
+ }
+}
+
+void
+autocompletion_config_init (EShell *shell)
+{
+ ESourceList *source_list;
+ GtkWidget *scrolled_window;
+ GtkWidget *source_selector;
+ GtkWidget *preferences_window;
+
+ g_return_if_fail (E_IS_SHELL (shell));
+
+ 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); */
+
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (
+ GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (
+ GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN);
+ gtk_widget_show (scrolled_window);
+
+ source_selector = e_source_selector_new (source_list);
+ g_signal_connect (
+ source_selector, "selection_changed",
+ G_CALLBACK (source_selection_changed_cb), NULL);
+ gtk_container_add (GTK_CONTAINER (scrolled_window), source_selector);
+ gtk_widget_show (source_selector);
+
+ initialize_selection (E_SOURCE_SELECTOR (source_selector));
+
+ preferences_window = e_shell_get_preferences_window (shell);
+
+ e_preferences_window_add_page (
+ E_PREFERENCES_WINDOW (preferences_window),
+ "autocompletion",
+ "preferences-autocompletion",
+ _("Autocompletion"),
+ scrolled_window,
+ 200);
+}