From db9ecaacf2dbf3699c41fa0cbfcdc04439dd8f40 Mon Sep 17 00:00:00 2001 From: Sivaiah Nallagatla Date: Fri, 28 Jan 2005 18:40:16 +0000 Subject: new function to sensitize im types based on supported fields 2005-01-29 Sivaiah Nallagatla * gui/contact-editor/e-contact-editor.c (sensitize_im_types) : new function to sensitize im types based on supported fields (sensitize_im_record) : call sensitize_im_types for each record (sensitize_im) : if none of the im types are supported disable the im entries Fixes #68799 svn path=/trunk/; revision=28603 --- addressbook/gui/contact-editor/e-contact-editor.c | 44 ++++++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'addressbook/gui') diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 363e05dcc9..2cd7984337 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -1538,6 +1538,30 @@ extract_im (EContactEditor *editor) g_free (service_attr_list); } +static void +sensitize_im_types (EContactEditor *editor, GtkWidget *option_menu) +{ + GtkWidget *menu; + GList *item_list, *l; + gint i; + + menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (option_menu)); + l = item_list = gtk_container_get_children (GTK_CONTAINER (menu)); + + for (i = 0; i < G_N_ELEMENTS (im_service); i++) { + GtkWidget *widget; + + if (!l) { + g_warning (G_STRLOC ": Unexpected end of im items in option menu"); + return; + } + + widget = l->data; + gtk_widget_set_sensitive (widget, is_field_supported (editor, im_service [i].field)); + + l = g_list_next (l); + } +} static void sensitize_im_record (EContactEditor *editor, gint record, gboolean enabled) @@ -1568,19 +1592,29 @@ sensitize_im_record (EContactEditor *editor, gint record, gboolean enabled) gtk_widget_set_sensitive (location_option_menu, enabled); #endif gtk_editable_set_editable (GTK_EDITABLE (name_entry), enabled); + sensitize_im_types (editor, service_option_menu); } static void sensitize_im (EContactEditor *editor) { gint i; + gboolean enabled; + gboolean no_ims_supported; + + enabled = editor->target_editable; + no_ims_supported = TRUE; - for (i = 1; i <= IM_SLOTS; i++) { - gboolean enabled = TRUE; - - if (!editor->target_editable) - enabled = FALSE; + for (i = 0; i < G_N_ELEMENTS (im_service); i++) + if (is_field_supported (editor, im_service[i].field)) { + no_ims_supported = FALSE; + break; + } + if (no_ims_supported) + enabled = FALSE; + + for (i = 1; i <= IM_SLOTS; i++) { sensitize_im_record (editor, i, enabled); } } -- cgit v1.2.3