From 2d089faf78be7db81c7e02273d827a50455086fe Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 15 Oct 2009 16:51:19 +0200 Subject: Bug #373297 - Option for autocomplete in address book preferences --- plugins/default-source/default-source.c | 41 +++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'plugins/default-source/default-source.c') diff --git a/plugins/default-source/default-source.c b/plugins/default-source/default-source.c index 198d2f2671..1d8a7e0299 100644 --- a/plugins/default-source/default-source.c +++ b/plugins/default-source/default-source.c @@ -30,9 +30,13 @@ #include #include #include -GtkWidget* org_gnome_default_book (EPlugin *epl, EConfigHookItemFactoryData *data); + +GtkWidget *org_gnome_default_book (EPlugin *epl, EConfigHookItemFactoryData *data); +GtkWidget *org_gnome_autocomplete_book (EPlugin *epl, EConfigHookItemFactoryData *data); + void commit_default_calendar (EPlugin *epl, EConfigTarget *target); void commit_default_book (EPlugin *epl, EConfigTarget *target); + void commit_default_calendar (EPlugin *epl, EConfigTarget *target) { @@ -59,7 +63,7 @@ commit_default_book (EPlugin *epl, EConfigTarget *target) } static void -default_source_changed (GtkWidget *check_box, ESource *source) +default_source_changed (GtkWidget *check_box, ESource *source) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_box))) @@ -68,6 +72,16 @@ default_source_changed (GtkWidget *check_box, ESource *source) e_source_set_property (source, "default", NULL); } +static void +autocomplete_book_changed (GtkWidget *check_box, ESource *source) +{ + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_box))) + e_source_set_property (source, "completion", "true"); + else + e_source_set_property (source, "completion", NULL); +} + GtkWidget * org_gnome_default_book (EPlugin *epl, EConfigHookItemFactoryData *data) { @@ -92,6 +106,29 @@ org_gnome_default_book (EPlugin *epl, EConfigHookItemFactoryData *data) return widget; } +GtkWidget * +org_gnome_autocomplete_book (EPlugin *epl, EConfigHookItemFactoryData *data) +{ + GtkWidget *widget; + ESource *source; + EABConfigTargetSource *book_target; + + if (data->old) + return data->old; + + widget = gtk_check_button_new_with_mnemonic (_("A_utocomplete with this address book")); + book_target = (EABConfigTargetSource *) data->target; + source = book_target->source; + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), e_source_get_property (source, "completion") && g_str_equal (e_source_get_property (source, "completion"), "true")); + gtk_container_add (GTK_CONTAINER (data->parent), widget); + + g_signal_connect (GTK_TOGGLE_BUTTON (widget), "toggled", G_CALLBACK (autocomplete_book_changed), source); + gtk_widget_show (widget); + + return widget; +} + static const gchar * get_calendar_option_caption (ECalSourceType source_type) { -- cgit v1.2.3