evolution-3.6.4/modules/addressbook/autocompletion-config.c

No issues found

  1 /*
  2  * e-shell-config-autocompletion.h - Configuration page for addressbook autocompletion.
  3  *
  4  * This program is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2 of the License, or (at your option) version 3.
  8  *
  9  * This program is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with the program; if not, see <http://www.gnu.org/licenses/>
 16  *
 17  *
 18  * Authors:
 19  *		Chris Toshok <toshok@ximian.com>
 20  *
 21  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 22  *
 23  */
 24 
 25 #include "autocompletion-config.h"
 26 
 27 #include <glib/gi18n.h>
 28 #include <libedataserverui/libedataserverui.h>
 29 
 30 #include "e-util/e-datetime-format.h"
 31 #include "misc/e-autocomplete-selector.h"
 32 
 33 static GtkWidget *
 34 add_section (GtkWidget *container,
 35              const gchar *caption,
 36              gboolean expand)
 37 {
 38 	GtkWidget *widget;
 39 	gchar *markup;
 40 
 41 	widget = gtk_vbox_new (FALSE, 6);
 42 	gtk_box_pack_start (GTK_BOX (container), widget, expand, expand, 0);
 43 	gtk_widget_show (widget);
 44 
 45 	container = widget;
 46 
 47 	markup = g_markup_printf_escaped ("<b>%s</b>", caption);
 48 	widget = gtk_label_new (markup);
 49 	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
 50 	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
 51 	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
 52 	gtk_widget_show (widget);
 53 	g_free (markup);
 54 
 55 	widget = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
 56 	gtk_alignment_set_padding (GTK_ALIGNMENT (widget), 0, 0, 12, 0);
 57 	gtk_box_pack_start (GTK_BOX (container), widget, expand, expand, 0);
 58 	gtk_widget_show (widget);
 59 
 60 	container = widget;
 61 
 62 	widget = gtk_vbox_new (FALSE, 6);
 63 	gtk_container_add (GTK_CONTAINER (container), widget);
 64 	gtk_widget_show (widget);
 65 
 66 	return widget;
 67 }
 68 
 69 GtkWidget *
 70 autocompletion_config_new (EPreferencesWindow *window)
 71 {
 72 	EShellSettings *shell_settings;
 73 	ESourceRegistry *registry;
 74 	GtkWidget *container;
 75 	GtkWidget *itembox;
 76 	GtkWidget *widget;
 77 	GtkWidget *vbox;
 78 	EShell *shell;
 79 
 80 	shell = e_preferences_window_get_shell (window);
 81 
 82 	g_return_val_if_fail (E_IS_SHELL (shell), NULL);
 83 
 84 	registry = e_shell_get_registry (shell);
 85 	shell_settings = e_shell_get_shell_settings (shell);
 86 
 87 	vbox = gtk_vbox_new (FALSE, 12);
 88 	gtk_widget_show (vbox);
 89 
 90 	itembox = add_section (vbox, _("Date/Time Format"), FALSE);
 91 
 92 	widget = gtk_table_new (1, 3, FALSE);
 93 	gtk_box_pack_start (GTK_BOX (itembox), widget, TRUE, TRUE, 0);
 94 	e_datetime_format_add_setup_widget (
 95 		widget, 0, "addressbook", "table",
 96 		DTFormatKindDateTime, _("_Table column:"));
 97 	gtk_widget_show (widget);
 98 
 99 	itembox = add_section (vbox, _("Address formatting"), FALSE);
100 
101 	widget = gtk_check_button_new_with_mnemonic (
102 		_("_Format address according to standard of its destination country"));
103 	g_object_bind_property (
104 		shell_settings, "enable-address-formatting",
105 		widget, "active",
106 		G_BINDING_BIDIRECTIONAL |
107 		G_BINDING_SYNC_CREATE);
108 	gtk_box_pack_start (GTK_BOX (itembox), widget, FALSE, FALSE, 0);
109 	gtk_widget_show (widget);
110 
111 	itembox = add_section (vbox, _("Autocompletion"), TRUE);
112 
113 	widget = gtk_check_button_new_with_mnemonic (
114 		_("Always _show address of the autocompleted contact"));
115 	g_object_bind_property (
116 		shell_settings, "book-completion-show-address",
117 		widget, "active",
118 		G_BINDING_BIDIRECTIONAL |
119 		G_BINDING_SYNC_CREATE);
120 	gtk_box_pack_start (GTK_BOX (itembox), widget, FALSE, FALSE, 0);
121 	gtk_widget_show (widget);
122 
123 	widget = gtk_scrolled_window_new (NULL, NULL);
124 	gtk_scrolled_window_set_policy (
125 		GTK_SCROLLED_WINDOW (widget),
126 		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
127 	gtk_scrolled_window_set_shadow_type (
128 		GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
129 	gtk_box_pack_start (GTK_BOX (itembox), widget, TRUE, TRUE, 0);
130 	gtk_widget_show (widget);
131 
132 	container = widget;
133 
134 	widget = e_autocomplete_selector_new (registry);
135 	gtk_container_add (GTK_CONTAINER (container), widget);
136 	gtk_widget_show (widget);
137 
138 	return vbox;
139 }