aboutsummaryrefslogtreecommitdiffstats
path: root/modules/addressbook/autocompletion-config.c
blob: d39ea53382202989e40fc8ea25b9b309385851c9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
 * 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 <glib/gi18n.h>

static GtkWidget *
add_section (GtkWidget *container,
             const gchar *caption,
             gboolean expand)
{
    GtkWidget *widget;
    gchar *markup;

    widget = gtk_vbox_new (FALSE, 6);
    gtk_box_pack_start (GTK_BOX (container), widget, expand, expand, 0);
    gtk_widget_show (widget);

    container = widget;

    markup = g_markup_printf_escaped ("<b>%s</b>", caption);
    widget = gtk_label_new (markup);
    gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
    gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
    gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
    gtk_widget_show (widget);
    g_free (markup);

    widget = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
    gtk_alignment_set_padding (GTK_ALIGNMENT (widget), 0, 0, 12, 0);
    gtk_box_pack_start (GTK_BOX (container), widget, expand, expand, 0);
    gtk_widget_show (widget);

    container = widget;

    widget = gtk_vbox_new (FALSE, 6);
    gtk_container_add (GTK_CONTAINER (container), widget);
    gtk_widget_show (widget);

    return widget;
}

GtkWidget *
autocompletion_config_new (EPreferencesWindow *window)
{
    EShellSettings *shell_settings;
    ESourceRegistry *registry;
    GtkWidget *container;
    GtkWidget *itembox;
    GtkWidget *widget;
    GtkWidget *vbox;
    EShell *shell;

    shell = e_preferences_window_get_shell (window);

    g_return_val_if_fail (E_IS_SHELL (shell), NULL);

    registry = e_shell_get_registry (shell);
    shell_settings = e_shell_get_shell_settings (shell);

    vbox = gtk_vbox_new (FALSE, 12);
    gtk_widget_show (vbox);

    itembox = add_section (vbox, _("Date/Time Format"), FALSE);

    widget = gtk_table_new (1, 3, FALSE);
    gtk_box_pack_start (GTK_BOX (itembox), widget, TRUE, TRUE, 0);
    e_datetime_format_add_setup_widget (
        widget, 0, "addressbook", "table",
        DTFormatKindDateTime, _("_Table column:"));
    gtk_widget_show (widget);

    itembox = add_section (vbox, _("Address formatting"), FALSE);

    widget = gtk_check_button_new_with_mnemonic (
        _("_Format address according to standard of its destination country"));
    g_object_bind_property (
        shell_settings, "enable-address-formatting",
        widget, "active",
        G_BINDING_BIDIRECTIONAL |
        G_BINDING_SYNC_CREATE);
    gtk_box_pack_start (GTK_BOX (itembox), widget, FALSE, FALSE, 0);
    gtk_widget_show (widget);

    itembox = add_section (vbox, _("Autocompletion"), TRUE);

    widget = gtk_check_button_new_with_mnemonic (
        _("Always _show address of the autocompleted contact"));
    g_object_bind_property (
        shell_settings, "book-completion-show-address",
        widget, "active",
        G_BINDING_BIDIRECTIONAL |
        G_BINDING_SYNC_CREATE);
    gtk_box_pack_start (GTK_BOX (itembox), widget, FALSE, FALSE, 0);
    gtk_widget_show (widget);

    widget = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (
        GTK_SCROLLED_WINDOW (widget),
        GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_shadow_type (
        GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
    gtk_box_pack_start (GTK_BOX (itembox), widget, TRUE, TRUE, 0);
    gtk_widget_show (widget);

    container = widget;

    widget = e_autocomplete_selector_new (registry);
    gtk_container_add (GTK_CONTAINER (container), widget);
    gtk_widget_show (widget);

    return vbox;
}