From 3f4b0efb112cdc935ababe0647b0a4906a1d4748 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Mon, 21 Jun 2004 21:49:01 +0000 Subject: remove the auth-entry-notebook in the edit dialog, and rename the auth 2004-06-21 Chris Toshok * gui/component/ldap-config.glade: remove the auth-entry-notebook in the edit dialog, and rename the auth entry to... auth-entry. * gui/component/addressbook-config.c (source_to_dialog_new): nuke - it's identical to source_to_dialog. (dialog_to_source): we only have one auth entry now. fill it in properly. (source_to_dialog): fill in the auth entry properly based on the auth type, and remove auth_entry_notebook references. (auth_optionmenu_activated): remove auth_entry_notebook references. (setup_general_tab): same, and use auth-entry instead of email-entry/dn-entry. (general_tab_check): use auth_principle instead of email/binddn. (add_folder_modify): same. (addressbook_add_server_dialog): put setup_connecting_tab inside the ifdef HAVE_LDAP, and call source_to_dialog instead of source_to_dialog_new. (addressbook_config_edit_source): always call setup_general_tab. * gui/component/addressbook-config.h (AddressbookLDAPScopeType): reorder to match order in option menu (we should really remove BASE altogether.. it's useless for searching.) * gui/component/addressbook-view.c (update_command_state): macroize this, annoying seeing the same 4 lines repeated 15 times. svn path=/trunk/; revision=26445 --- addressbook/gui/component/addressbook-config.c | 111 +++-------------- addressbook/gui/component/addressbook-config.h | 2 +- addressbook/gui/component/addressbook-view.c | 96 +++++---------- addressbook/gui/component/ldap-config.glade | 157 ++++++++++--------------- 4 files changed, 108 insertions(+), 258 deletions(-) (limited to 'addressbook/gui') diff --git a/addressbook/gui/component/addressbook-config.c b/addressbook/gui/component/addressbook-config.c index b2e7798277..0ed3b67b28 100644 --- a/addressbook/gui/component/addressbook-config.c +++ b/addressbook/gui/component/addressbook-config.c @@ -91,10 +91,7 @@ struct _AddressbookSourceDialog { GtkWidget *host; GtkWidget *auth_optionmenu; AddressbookLDAPAuthType auth; - GtkWidget *auth_label_notebook; - GtkWidget *auth_entry_notebook; - GtkWidget *email; - GtkWidget *binddn; + GtkWidget *auth_principal; /* connecting page fields */ ModifyFunc connecting_modify_func; @@ -224,8 +221,10 @@ dialog_to_source (AddressbookSourceDialog *dialog, ESource *source, gboolean tem if (!strcmp ("ldap://", e_source_group_peek_base_uri (dialog->source_group))) { #ifdef HAVE_LDAP - e_source_set_property (source, "email_addr", gtk_entry_get_text (GTK_ENTRY (dialog->email))); - e_source_set_property (source, "binddn", gtk_entry_get_text (GTK_ENTRY (dialog->binddn))); + if (dialog->auth != ADDRESSBOOK_LDAP_AUTH_NONE) + e_source_set_property (source, + dialog->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE_EMAIL ? "email_addr" : "binddn", + gtk_entry_get_text (GTK_ENTRY (dialog->auth_principal))); str = g_strdup_printf ("%d", gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (dialog->limit_spinbutton))); e_source_set_property (source, "limit", str); g_free (str); @@ -331,59 +330,6 @@ source_to_uri_parts (ESource *source, gchar **host, gchar **rootdn, #define SOURCE_PROP_STRING(source, prop) \ (source && e_source_get_property (source, prop) ? e_source_get_property (source, prop) : "") - -static void -source_to_dialog_new (AddressbookSourceDialog *dialog) -{ - ESource *source = dialog->source; - - gtk_entry_set_text (GTK_ENTRY (dialog->display_name), source ? e_source_peek_name (source) : ""); - -#ifdef HAVE_LDAP - gtk_entry_set_text (GTK_ENTRY (dialog->email), SOURCE_PROP_STRING (source, "email_addr")); - if (dialog->binddn) - gtk_entry_set_text (GTK_ENTRY (dialog->binddn), SOURCE_PROP_STRING (source, "binddn")); - gtk_spin_button_set_value ( GTK_SPIN_BUTTON (dialog->limit_spinbutton), - g_strtod ( source && e_source_get_property (source, "limit") ? - e_source_get_property (source, "limit") : "100", NULL)); - gtk_adjustment_set_value (GTK_RANGE(dialog->timeout_scale)->adjustment, - g_strtod ( source && e_source_get_property (source, "timeout") ? - e_source_get_property (source, "timeout") : "3", NULL)); - - dialog->auth = source && e_source_get_property (source, "auth") ? - ldap_parse_auth (e_source_get_property (source, "auth")) : ADDRESSBOOK_LDAP_AUTH_NONE; - dialog->ssl = source && e_source_get_property (source, "ssl") ? - ldap_parse_ssl (e_source_get_property (source, "ssl")) : ADDRESSBOOK_LDAP_SSL_WHENEVER_POSSIBLE; - - if (source && !strcmp ("ldap://", e_source_group_peek_base_uri (dialog->source_group))) { - gchar *host; - gchar *rootdn; - AddressbookLDAPScopeType scope; - gint port; - - if (source_to_uri_parts (source, &host, &rootdn, &scope, &port)) { - gchar *port_str; - - gtk_entry_set_text (GTK_ENTRY (dialog->host), host); - gtk_entry_set_text (GTK_ENTRY (dialog->rootdn), rootdn); - - dialog->scope = scope; - - port_str = g_strdup_printf ("%d", port); - gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (dialog->port_combo)->entry), port_str); - g_free (port_str); - - g_free (host); - g_free (rootdn); - } - } - - gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->auth_optionmenu), dialog->auth); - gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->scope_optionmenu), dialog->scope); - gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->ssl_optionmenu), dialog->ssl); -#endif -} - static void source_to_dialog (AddressbookSourceDialog *dialog) { @@ -392,8 +338,6 @@ source_to_dialog (AddressbookSourceDialog *dialog) gtk_entry_set_text (GTK_ENTRY (dialog->display_name), source ? e_source_peek_name (source) : ""); #ifdef HAVE_LDAP - gtk_entry_set_text (GTK_ENTRY (dialog->email), SOURCE_PROP_STRING (source, "email_addr")); - gtk_entry_set_text (GTK_ENTRY (dialog->binddn), SOURCE_PROP_STRING (source, "binddn")); gtk_spin_button_set_value ( GTK_SPIN_BUTTON (dialog->limit_spinbutton), g_strtod ( source && e_source_get_property (source, "limit") ? e_source_get_property (source, "limit") : "100", NULL)); @@ -406,6 +350,11 @@ source_to_dialog (AddressbookSourceDialog *dialog) dialog->ssl = source && e_source_get_property (source, "ssl") ? ldap_parse_ssl (e_source_get_property (source, "ssl")) : ADDRESSBOOK_LDAP_SSL_WHENEVER_POSSIBLE; + if (dialog->auth != ADDRESSBOOK_LDAP_AUTH_NONE) + gtk_entry_set_text (GTK_ENTRY (dialog->auth_principal), + SOURCE_PROP_STRING (source, + dialog->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE_EMAIL ? "email_addr" : "binddn")); + if (source && !strcmp ("ldap://", e_source_group_peek_base_uri (dialog->source_group))) { gchar *host; gchar *rootdn; @@ -430,11 +379,6 @@ source_to_dialog (AddressbookSourceDialog *dialog) } gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->auth_optionmenu), dialog->auth); - if (dialog->auth != ADDRESSBOOK_LDAP_AUTH_NONE) { - gtk_notebook_set_current_page (GTK_NOTEBOOK(dialog->auth_entry_notebook), dialog->auth - 1); - } - gtk_widget_set_sensitive (dialog->auth_entry_notebook, dialog->auth != ADDRESSBOOK_LDAP_AUTH_NONE); - gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->scope_optionmenu), dialog->scope); gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->ssl_optionmenu), dialog->ssl); #endif @@ -531,14 +475,6 @@ auth_optionmenu_activated (GtkWidget *item, AddressbookSourceDialog *dialog) item); dialog->general_modify_func (item, dialog); - - if (dialog->auth == 0) { - gtk_widget_set_sensitive (dialog->auth_entry_notebook, FALSE); - } - else { - gtk_widget_set_sensitive (dialog->auth_entry_notebook, TRUE); - gtk_notebook_set_current_page (GTK_NOTEBOOK(dialog->auth_entry_notebook), dialog->auth - 1); - } } static void @@ -559,16 +495,10 @@ setup_general_tab (AddressbookSourceDialog *dialog, ModifyFunc modify_func) g_signal_connect (dialog->host, "changed", G_CALLBACK (modify_func), dialog); - dialog->auth_entry_notebook = glade_xml_get_widget (dialog->gui, "auth-entry-notebook"); - dialog->email = glade_xml_get_widget (dialog->gui, "email-entry"); - g_signal_connect (dialog->email, "changed", + dialog->auth_principal = glade_xml_get_widget (dialog->gui, "auth-entry"); + g_signal_connect (dialog->auth_principal, "changed", G_CALLBACK (modify_func), dialog); - dialog->binddn = glade_xml_get_widget (dialog->gui, "dn-entry"); - if (dialog->binddn) - g_signal_connect (dialog->binddn, "changed", - G_CALLBACK (modify_func), dialog); - dialog->auth_optionmenu = glade_xml_get_widget (dialog->gui, "auth-optionmenu"); menu = gtk_option_menu_get_menu (GTK_OPTION_MENU(dialog->auth_optionmenu)); gtk_container_foreach (GTK_CONTAINER (menu), (GtkCallback)add_auth_activate_cb, dialog); @@ -589,10 +519,7 @@ general_tab_check (AddressbookSourceDialog *dialog) if (valid) { if (dialog->auth != ADDRESSBOOK_LDAP_AUTH_NONE) { - if (dialog->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE_BINDDN) - string = gtk_entry_get_text (GTK_ENTRY (dialog->binddn)); - else - string = gtk_entry_get_text (GTK_ENTRY (dialog->email)); + string = gtk_entry_get_text (GTK_ENTRY (dialog->auth_principal)); if (!string || !string[0]) valid = FALSE; @@ -927,7 +854,7 @@ add_folder_modify (GtkWidget *widget, AddressbookSourceDialog *sdialog) gtk_widget_set_sensitive (sdialog->auth_frame, remote); #ifdef HAVE_LDAP - gtk_widget_set_sensitive (sdialog->email, sdialog->auth != ADDRESSBOOK_LDAP_AUTH_NONE); + gtk_widget_set_sensitive (sdialog->auth_principal, sdialog->auth != ADDRESSBOOK_LDAP_AUTH_NONE); if (valid) valid = general_tab_check (sdialog); @@ -1022,9 +949,10 @@ addressbook_add_server_dialog (void) setup_general_tab (sdialog, add_folder_modify); #ifdef HAVE_LDAP + setup_connecting_tab (sdialog, add_folder_modify); + setup_searching_tab (sdialog, add_folder_modify); #endif - setup_connecting_tab (sdialog, add_folder_modify); sdialog->auth_frame = glade_xml_get_widget (sdialog->gui, "authentication-frame"); sdialog->server_frame = glade_xml_get_widget (sdialog->gui, "server-frame"); @@ -1043,7 +971,7 @@ addressbook_add_server_dialog (void) g_object_unref (gconf_client); /* make sure we fill in the default values */ - source_to_dialog_new (sdialog); + source_to_dialog (sdialog); gtk_window_set_type_hint (GTK_WINDOW (sdialog->window), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_modal (GTK_WINDOW (sdialog->window), TRUE); @@ -1276,14 +1204,11 @@ addressbook_config_edit_source (GtkWidget *parent, ESource *source) g_signal_connect (sdialog->display_name, "changed", G_CALLBACK (editor_modify_cb), sdialog); -#ifdef HAVE_LDAP - setup_general_tab (sdialog, editor_modify_cb); - +#ifdef HAVE_LDAP setup_connecting_tab (sdialog, editor_modify_cb); setup_searching_tab (sdialog, editor_modify_cb); - #endif sdialog->notebook = glade_xml_get_widget (sdialog->gui, "account-editor-notebook"); diff --git a/addressbook/gui/component/addressbook-config.h b/addressbook/gui/component/addressbook-config.h index b5800bc123..9f8259ce49 100644 --- a/addressbook/gui/component/addressbook-config.h +++ b/addressbook/gui/component/addressbook-config.h @@ -34,9 +34,9 @@ typedef enum { } AddressbookLDAPAuthType; typedef enum { + ADDRESSBOOK_LDAP_SCOPE_BASE, ADDRESSBOOK_LDAP_SCOPE_ONELEVEL, ADDRESSBOOK_LDAP_SCOPE_SUBTREE, - ADDRESSBOOK_LDAP_SCOPE_BASE, ADDRESSBOOK_LDAP_SCOPE_LAST } AddressbookLDAPScopeType; diff --git a/addressbook/gui/component/addressbook-view.c b/addressbook/gui/component/addressbook-view.c index d11236e283..149bf3521b 100644 --- a/addressbook/gui/component/addressbook-view.c +++ b/addressbook/gui/component/addressbook-view.c @@ -323,74 +323,31 @@ update_command_state (EABView *eav, AddressbookView *view) uic = bonobo_control_get_ui_component (priv->folder_view_control); if (bonobo_ui_component_get_container (uic) != CORBA_OBJECT_NIL) { - bonobo_ui_component_set_prop (uic, - "/commands/ContactsSaveAsVCard", - "sensitive", - eab_view_can_save_as (eav) ? "1" : "0", NULL); - bonobo_ui_component_set_prop (uic, - "/commands/ContactsView", - "sensitive", - eab_view_can_view (eav) ? "1" : "0", NULL); +#define SET_SENSITIVE(verb,f) \ + bonobo_ui_component_set_prop (uic, (verb), "sensitive", (f)(eav) ? "1" : "0", NULL) - /* Print Contact */ - bonobo_ui_component_set_prop (uic, - "/commands/ContactsPrint", - "sensitive", - eab_view_can_print (eav) ? "1" : "0", NULL); + SET_SENSITIVE ("/commands/ContactsSaveAsVCard", eab_view_can_save_as); + SET_SENSITIVE ("/commands/ContactsView", eab_view_can_view); /* Print Contact */ - bonobo_ui_component_set_prop (uic, - "/commands/ContactsPrintPreview", - "sensitive", - eab_view_can_print (eav) ? "1" : "0", NULL); + SET_SENSITIVE ("/commands/ContactsPrint", eab_view_can_print); + SET_SENSITIVE ("/commands/ContactsPrintPreview", eab_view_can_print); /* Delete Contact */ - bonobo_ui_component_set_prop (uic, - "/commands/ContactDelete", - "sensitive", - eab_view_can_delete (eav) ? "1" : "0", NULL); - - bonobo_ui_component_set_prop (uic, - "/commands/ContactsCut", - "sensitive", - eab_view_can_cut (eav) ? "1" : "0", NULL); - bonobo_ui_component_set_prop (uic, - "/commands/ContactsCopy", - "sensitive", - eab_view_can_copy (eav) ? "1" : "0", NULL); - bonobo_ui_component_set_prop (uic, - "/commands/ContactsPaste", - "sensitive", - eab_view_can_paste (eav) ? "1" : "0", NULL); - bonobo_ui_component_set_prop (uic, - "/commands/ContactsSelectAll", - "sensitive", - eab_view_can_select_all (eav) ? "1" : "0", NULL); - - bonobo_ui_component_set_prop (uic, - "/commands/ContactsSendContactToOther", - "sensitive", - eab_view_can_send (eav) ? "1" : "0", NULL); - - bonobo_ui_component_set_prop (uic, - "/commands/ContactsSendMessageToContact", - "sensitive", - eab_view_can_send_to (eav) ? "1" : "0", NULL); - - bonobo_ui_component_set_prop (uic, - "/commands/ContactsMoveToFolder", - "sensitive", - eab_view_can_move_to_folder (eav) ? "1" : "0", NULL); - bonobo_ui_component_set_prop (uic, - "/commands/ContactsCopyToFolder", - "sensitive", - eab_view_can_copy_to_folder (eav) ? "1" : "0", NULL); + SET_SENSITIVE ("/commands/ContactDelete", eab_view_can_delete); + SET_SENSITIVE ("/commands/ContactsCut", eab_view_can_cut); + + SET_SENSITIVE ("/commands/ContactsCopy", eab_view_can_copy); + SET_SENSITIVE ("/commands/ContactsPaste", eab_view_can_paste); + SET_SENSITIVE ("/commands/ContactsSelectAll", eab_view_can_select_all); + SET_SENSITIVE ("/commands/ContactsSendContactToOther", eab_view_can_send); + SET_SENSITIVE ("/commands/ContactsSendMessageToContact", eab_view_can_send_to); + SET_SENSITIVE ("/commands/ContactsMoveToFolder", eab_view_can_move_to_folder); + SET_SENSITIVE ("/commands/ContactsCopyToFolder", eab_view_can_copy_to_folder); /* Stop */ - bonobo_ui_component_set_prop (uic, - "/commands/ContactStop", - "sensitive", - eab_view_can_stop (eav) ? "1" : "0", NULL); + SET_SENSITIVE ("/commands/ContactStop", eab_view_can_stop); +#undef SET_SENSITIVE } g_object_unref (view); @@ -1149,6 +1106,7 @@ activate_source (AddressbookView *view, /* we don't have a view for this uid already set up. */ GtkWidget *label = gtk_label_new (uid); + GError *error = NULL; uid_view = eab_view_new (); @@ -1175,13 +1133,19 @@ activate_source (AddressbookView *view, g_signal_connect (uid_view, "command_state_change", G_CALLBACK(update_command_state), view); - book = e_book_new (source, NULL); + book = e_book_new (source, &error); - data = g_new (BookOpenData, 1); - data->view = g_object_ref (uid_view); - data->source = g_object_ref (source); + if (book) { + data = g_new (BookOpenData, 1); + data->view = g_object_ref (uid_view); + data->source = g_object_ref (source); - addressbook_load (book, book_open_cb, data); + addressbook_load (book, book_open_cb, data); + } + else { + g_warning ("error loading addressbook : %s", error->message); + g_error_free (error); + } } gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), diff --git a/addressbook/gui/component/ldap-config.glade b/addressbook/gui/component/ldap-config.glade index 326bfb5cc3..fa4c6d2734 100644 --- a/addressbook/gui/component/ldap-config.glade +++ b/addressbook/gui/component/ldap-config.glade @@ -10,6 +10,11 @@ False True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -495,7 +500,7 @@ 0.5 0 0 - email-entry + auth-entry 0 @@ -508,7 +513,7 @@ - + True True True @@ -727,6 +732,7 @@ True True GTK_RELIEF_NORMAL + True @@ -735,6 +741,10 @@ 0.5 0 0 + 0 + 0 + 0 + 0 @@ -1202,6 +1212,7 @@ gtk-cancel True GTK_RELIEF_NORMAL + True @@ -1211,6 +1222,7 @@ True True GTK_RELIEF_NORMAL + True @@ -1219,6 +1231,10 @@ 0.5 0 0 + 0 + 0 + 0 + 0 @@ -1288,6 +1304,11 @@ False True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST False @@ -1309,6 +1330,7 @@ gtk-cancel True GTK_RELIEF_NORMAL + True -6 @@ -1321,6 +1343,7 @@ gtk-ok True GTK_RELIEF_NORMAL + True -5 @@ -1841,7 +1864,6 @@ 0.5 0 0 - email-entry 0 @@ -1853,101 +1875,6 @@ - - - True - False - False - False - GTK_POS_TOP - False - False - - - - True - Evolution will use this email address to authenticate you with the server. - True - True - True - 0 - - True - * - False - - - True - True - - - - - - True - label549 - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - True - True - True - 0 - - True - * - False - - - False - True - - - - - - True - label550 - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - 1 - 2 - 1 - 2 - expand|shrink|fill - shrink|fill - - - True @@ -1994,6 +1921,28 @@ shrink + + + + True + Evolution will use this email address to authenticate you with the server. + True + True + True + 0 + + True + * + False + + + 1 + 2 + 1 + 2 + + + 0 @@ -2256,6 +2205,7 @@ True True GTK_RELIEF_NORMAL + True @@ -2264,6 +2214,10 @@ 0.5 0 0 + 0 + 0 + 0 + 0 @@ -2650,6 +2604,11 @@ 200 True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST False @@ -2671,6 +2630,7 @@ gtk-cancel True GTK_RELIEF_NORMAL + True -6 @@ -2683,6 +2643,7 @@ gtk-ok True GTK_RELIEF_NORMAL + True -5 -- cgit v1.2.3