aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/component/addressbook-config.c
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui/component/addressbook-config.c')
-rw-r--r--addressbook/gui/component/addressbook-config.c79
1 files changed, 58 insertions, 21 deletions
diff --git a/addressbook/gui/component/addressbook-config.c b/addressbook/gui/component/addressbook-config.c
index 33feb391ab..5061e6368b 100644
--- a/addressbook/gui/component/addressbook-config.c
+++ b/addressbook/gui/component/addressbook-config.c
@@ -29,15 +29,19 @@ struct _AddressbookSourceDialog {
GtkWidget *name;
GtkWidget *host;
+
+ GtkWidget *auth_checkbutton;
+ GtkWidget *auth_optionmenu;
+ GtkWidget *auth_notebook;
GtkWidget *email;
- GtkWidget *email_label;
+ GtkWidget *binddn;
+ int auth;
GtkWidget *port;
GtkWidget *rootdn;
GtkWidget *limit;
GtkWidget *scope_optionmenu;
AddressbookLDAPScopeType ldap_scope;
- GtkWidget *auth_checkbutton;
gint id; /* button we closed the dialog with */
@@ -83,14 +87,14 @@ auth_checkbutton_changed (GtkWidget *item, AddressbookSourceDialog *dialog)
/* make sure the change is reflected by the state of the dialog's OK button */
addressbook_source_edit_changed (item, dialog);
- gtk_widget_set_sensitive (dialog->email_label,
+ gtk_widget_set_sensitive (dialog->auth_optionmenu,
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->auth_checkbutton)));
+ gtk_widget_set_sensitive (dialog->auth_notebook,
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->auth_checkbutton)));
- gtk_entry_set_editable (GTK_ENTRY(dialog->email),
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->auth_checkbutton)));
}
static void
-option_menuitem_activated (GtkWidget *item, AddressbookSourceDialog *dialog)
+scope_optionmenu_activated (GtkWidget *item, AddressbookSourceDialog *dialog)
{
/* make sure the change is reflected by the state of the dialog's OK button */
addressbook_source_edit_changed (item, dialog);
@@ -99,6 +103,18 @@ option_menuitem_activated (GtkWidget *item, AddressbookSourceDialog *dialog)
item);
}
+static void
+auth_optionmenu_activated (GtkWidget *item, AddressbookSourceDialog *dialog)
+{
+ /* make sure the change is reflected by the state of the dialog's OK button */
+ addressbook_source_edit_changed (item, dialog);
+
+ dialog->auth = g_list_index (gtk_container_children (GTK_CONTAINER (item->parent)),
+ item) + 1;
+
+ gtk_notebook_set_page (GTK_NOTEBOOK(dialog->auth_notebook), dialog->auth - 1);
+}
+
typedef struct {
GtkWidget *notebook;
int page_num;
@@ -132,18 +148,24 @@ addressbook_source_dialog_set_source (AddressbookSourceDialog *dialog, Addressbo
e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->name), source ? source->name : "");
e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->host), source ? source->host : "");
e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->email), source ? source->email_addr : "");
+ e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->binddn), source ? source->binddn : "");
e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->port), source ? source->port : "389");
e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->rootdn), source ? source->rootdn : "");
+
string = g_strdup_printf ("%d", source ? source->limit : 100);
e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->limit), string);
g_free (string);
- gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->scope_optionmenu), source ? source->scope : ADDRESSBOOK_LDAP_SCOPE_ONELEVEL);
+ dialog->auth = source ? source->auth : ADDRESSBOOK_LDAP_AUTH_NONE;
+ if (dialog->auth != ADDRESSBOOK_LDAP_AUTH_NONE)
+ gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->auth_optionmenu), dialog->auth - 1);
+
dialog->ldap_scope = source ? source->scope : ADDRESSBOOK_LDAP_SCOPE_ONELEVEL;
+ gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->scope_optionmenu), dialog->ldap_scope);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(dialog->auth_checkbutton), source && source->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE);
- gtk_widget_set_sensitive (dialog->email_label, source && source->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE);
- gtk_entry_set_editable (GTK_ENTRY(dialog->email), source && source->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(dialog->auth_checkbutton), source && source->auth != ADDRESSBOOK_LDAP_AUTH_NONE);
+ gtk_widget_set_sensitive (dialog->auth_optionmenu, source && source->auth != ADDRESSBOOK_LDAP_AUTH_NONE);
+ gtk_widget_set_sensitive (dialog->auth_notebook, source && source->auth != ADDRESSBOOK_LDAP_AUTH_NONE);
}
static AddressbookSource *
@@ -154,12 +176,12 @@ addressbook_source_dialog_get_source (AddressbookSourceDialog *dialog)
source->name = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->name));
source->host = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->host));
source->email_addr = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->email));
+ source->binddn = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->binddn));
source->port = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->port));
source->rootdn = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->rootdn));
source->limit = atoi(e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->limit)));
source->scope = dialog->ldap_scope;
- source->auth = (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->auth_checkbutton))
- ? ADDRESSBOOK_LDAP_AUTH_SIMPLE : ADDRESSBOOK_LDAP_AUTH_NONE);
+ source->auth = dialog->auth;
addressbook_storage_init_source_uri (source);
@@ -173,12 +195,20 @@ addressbook_source_dialog_ok_clicked (GtkWidget *widget, AddressbookSourceDialog
}
static void
-add_activate_cb (GtkWidget *item, AddressbookSourceDialog *dialog)
+add_scope_activate_cb (GtkWidget *item, AddressbookSourceDialog *dialog)
+{
+ gtk_signal_connect (GTK_OBJECT (item), "activate",
+ GTK_SIGNAL_FUNC (scope_optionmenu_activated), dialog);
+}
+
+static void
+add_auth_activate_cb (GtkWidget *item, AddressbookSourceDialog *dialog)
{
gtk_signal_connect (GTK_OBJECT (item), "activate",
- GTK_SIGNAL_FUNC (option_menuitem_activated), dialog);
+ GTK_SIGNAL_FUNC (auth_optionmenu_activated), dialog);
}
+
static AddressbookSourceDialog*
addressbook_source_dialog (GladeXML *gui, AddressbookSource *source, GtkWidget *parent)
{
@@ -214,18 +244,25 @@ addressbook_source_dialog (GladeXML *gui, AddressbookSource *source, GtkWidget *
GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog);
add_focus_handler (dialog->host, dialog->basic_notebook, 1);
- dialog->email = glade_xml_get_widget (gui, "email-address-entry");
- gtk_signal_connect (GTK_OBJECT (dialog->email), "changed",
- GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog);
- add_focus_handler (dialog->email, dialog->basic_notebook, 2);
-
- dialog->email_label = glade_xml_get_widget (gui, "email-address-label");
+ /* BASIC -> AUTH STUFF */
+ dialog->auth_notebook = glade_xml_get_widget (gui, "auth-notebook");
dialog->auth_checkbutton = glade_xml_get_widget (gui, "auth-checkbutton");
add_focus_handler (dialog->auth_checkbutton, dialog->basic_notebook, 2);
gtk_signal_connect (GTK_OBJECT (dialog->auth_checkbutton), "toggled",
GTK_SIGNAL_FUNC (auth_checkbutton_changed), dialog);
+ dialog->auth_optionmenu = glade_xml_get_widget (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);
+ add_focus_handler (dialog->auth_optionmenu, dialog->basic_notebook, 3);
+
+ dialog->email = glade_xml_get_widget (gui, "email-entry");
+ add_focus_handler (dialog->email, dialog->basic_notebook, 4);
+
+ dialog->binddn = glade_xml_get_widget (gui, "dn-entry");
+ add_focus_handler (dialog->binddn, dialog->basic_notebook, 5);
+
/* ADVANCED STUFF */
dialog->port = glade_xml_get_widget (gui, "port-entry");
gtk_signal_connect (GTK_OBJECT (dialog->port), "changed",
@@ -240,7 +277,7 @@ addressbook_source_dialog (GladeXML *gui, AddressbookSource *source, GtkWidget *
dialog->scope_optionmenu = glade_xml_get_widget (gui, "scope-optionmenu");
add_focus_handler (dialog->scope_optionmenu, dialog->advanced_notebook, 2);
menu = gtk_option_menu_get_menu (GTK_OPTION_MENU(dialog->scope_optionmenu));
- gtk_container_foreach (GTK_CONTAINER (menu), (GtkCallback)add_activate_cb, dialog);
+ gtk_container_foreach (GTK_CONTAINER (menu), (GtkCallback)add_scope_activate_cb, dialog);
dialog->limit = glade_xml_get_widget (gui, "limit-entry");
gtk_signal_connect (GTK_OBJECT (dialog->limit), "changed",