From 635f62d060ad48770ddc2a53aa7a2a6b4be86492 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 23 Sep 2008 11:02:55 +0000 Subject: ** Part of fix for bug #272391 2008-09-23 Milan Crha ** Part of fix for bug #272391 * gui/component/apps_evolution_addressbook.schemas.in: * gui/component/autocompletion-config.c: (struct AutocompletionConfig), (config_control_destroy_notify), (add_section), (show_address_check_toggled_cb), (autocompletion_config_control_new): New UI for Edit->Preferences->Autocompletion, with the checkbox for the key "/apps/evolution/addressbook/completion/show_address" to be able to setup whether show mail address for the autocompleted contact. svn path=/trunk/; revision=36431 --- addressbook/ChangeLog | 12 ++++ .../apps_evolution_addressbook.schemas.in | 12 ++++ addressbook/gui/component/autocompletion-config.c | 69 +++++++++++++++++++++- 3 files changed, 91 insertions(+), 2 deletions(-) diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 942d361544..e04c56cf32 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,15 @@ +2008-09-23 Milan Crha + + ** Part of fix for bug #272391 + + * gui/component/apps_evolution_addressbook.schemas.in: + * gui/component/autocompletion-config.c: (struct AutocompletionConfig), + (config_control_destroy_notify), (add_section), + (show_address_check_toggled_cb), (autocompletion_config_control_new): + New UI for Edit->Preferences->Autocompletion, with the checkbox for + the key "/apps/evolution/addressbook/completion/show_address" to be + able to setup whether show mail address for the autocompleted contact. + 2008-09-19 Sankar P License Changes diff --git a/addressbook/gui/component/apps_evolution_addressbook.schemas.in b/addressbook/gui/component/apps_evolution_addressbook.schemas.in index 010073331e..4a336409df 100644 --- a/addressbook/gui/component/apps_evolution_addressbook.schemas.in +++ b/addressbook/gui/component/apps_evolution_addressbook.schemas.in @@ -27,6 +27,18 @@ + + /schemas/apps/evolution/addressbook/completion/show_address + /apps/evolution/addressbook/completion/show_address + evolution-addressbook + bool + false + + Show autocompleted name with an address + Whether force showing the mail address with the name of the autocompleted contact in the entry. + + + diff --git a/addressbook/gui/component/autocompletion-config.c b/addressbook/gui/component/autocompletion-config.c index 786a3613e3..8c259c6a7a 100644 --- a/addressbook/gui/component/autocompletion-config.c +++ b/addressbook/gui/component/autocompletion-config.c @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -45,6 +46,7 @@ typedef struct { GtkWidget *control_widget; ESourceList *source_list; + GConfClient *gconf; } AutocompletionConfig; static void @@ -84,6 +86,7 @@ config_control_destroy_notify (void *data, AutocompletionConfig *ac = (AutocompletionConfig *) data; g_object_unref (ac->source_list); + g_object_unref (ac->gconf); g_free (ac); } @@ -106,17 +109,76 @@ initialize_selection (AutocompletionConfig *ac) } } +static GtkWidget * +add_section (GtkWidget *vbox, const gchar *caption, gboolean expand) +{ + GtkWidget *label, *hbox, *itembox; + gchar *txt; + + g_return_val_if_fail (vbox != NULL, NULL); + g_return_val_if_fail (caption != NULL, NULL); + + txt = g_strconcat ("", caption, "", NULL); + + label = gtk_label_new (NULL); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_label_set_markup (GTK_LABEL (label), txt); + + g_free (txt); + + /* bold caption of the section */ + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + + hbox = gtk_hbox_new (FALSE, 12); + + /* space on the left for the items in the section */ + gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (""), FALSE, FALSE, 0); + + /* itembox, here will all section items go */ + itembox = gtk_vbox_new (FALSE, 2); + gtk_box_pack_start (GTK_BOX (hbox), itembox, TRUE, TRUE, 0); + + gtk_box_pack_start (GTK_BOX (vbox), hbox, expand, expand, 0); + + return itembox; +} + +static void +show_address_check_toggled_cb (GtkToggleButton *check, AutocompletionConfig *ac) +{ + g_return_if_fail (check != NULL); + g_return_if_fail (ac != NULL); + g_return_if_fail (ac->gconf != NULL); + + gconf_client_set_bool (ac->gconf, FORCE_SHOW_ADDRESS, gtk_toggle_button_get_active (check), NULL); +} + EvolutionConfigControl* autocompletion_config_control_new (void) { AutocompletionConfig *ac; CORBA_Environment ev; - GtkWidget *scrolledwin; + GtkWidget *scrolledwin, *vbox, *itembox, *w; ac = g_new0 (AutocompletionConfig, 1); CORBA_exception_init (&ev); + ac->gconf = gconf_client_get_default (); + + vbox = gtk_vbox_new (FALSE, 6); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); + + itembox = add_section (vbox, _("Autocompletion"), FALSE); + + w = gtk_check_button_new_with_mnemonic (_("Always _show address of the autocompleted contact")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), gconf_client_get_bool (ac->gconf, FORCE_SHOW_ADDRESS, NULL)); + g_signal_connect (w, "toggled", (GCallback)show_address_check_toggled_cb, ac); + gtk_box_pack_start (GTK_BOX (itembox), w, FALSE, FALSE, 0); + + itembox = add_section (vbox, _("Look up in address books"), TRUE); + ac->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? */ @@ -139,7 +201,10 @@ autocompletion_config_control_new (void) gtk_widget_show (ac->control_widget); gtk_widget_show (scrolledwin); - ac->config_control = evolution_config_control_new (scrolledwin); + gtk_widget_show_all (vbox); + gtk_box_pack_start (GTK_BOX (itembox), scrolledwin, TRUE, TRUE, 0); + + ac->config_control = evolution_config_control_new (vbox); g_signal_connect (ac->control_widget, "selection_changed", G_CALLBACK (source_selection_changed), ac); -- cgit v1.2.3