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.c1821
1 files changed, 302 insertions, 1519 deletions
diff --git a/addressbook/gui/component/addressbook-config.c b/addressbook/gui/component/addressbook-config.c
index ea59748b8e..8dfed83c59 100644
--- a/addressbook/gui/component/addressbook-config.c
+++ b/addressbook/gui/component/addressbook-config.c
@@ -1,733 +1,192 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors:
- * Chris Toshok <toshok@ximian.com>
- * Chris Lahey <clahey@ximian.com>
- **/
-
-/*#define STANDALONE*/
-/*#define NEW_ADVANCED_UI*/
#include <config.h>
-#include "addressbook-config.h"
-
-#include "addressbook.h"
-#include "addressbook-storage.h"
-
-#include "evolution-config-control.h"
-#include <shell/e-folder-list.h>
-
-#include <gal/widgets/e-unicode.h>
-#include <gal/e-table/e-table-memory-store.h>
-#include <gal/e-table/e-table-scrolled.h>
-#include <e-util/e-html-utils.h>
-
-#include <gtkhtml/gtkhtml.h>
-
+#include <glib.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-dialog.h>
#include <libgnomeui/gnome-stock.h>
-
-#include <bonobo/bonobo-generic-factory.h>
-
#include <glade/glade.h>
+#include <gal/widgets/e-unicode.h>
+#include <gtkhtml/gtkhtml.h>
+#include <e-util/e-html-utils.h>
+#include "addressbook-config.h"
+#include "addressbook-storage.h"
-#include <stdlib.h>
-#include <sys/time.h>
-
-#ifdef HAVE_LDAP
-#include "ldap.h"
-#include "ldap_schema.h"
-#endif
-
-#define LDAP_PORT_STRING "389"
-#define LDAPS_PORT_STRING "636"
-
-#define GLADE_FILE_NAME "ldap-config.glade"
-#define CONFIG_CONTROL_FACTORY_ID "OAFIID:GNOME_Evolution_Addressbook_ConfigControlFactory"
-#define LDAP_CONFIG_CONTROL_ID "OAFIID:GNOME_Evolution_LDAPStorage_ConfigControl"
-
-#ifdef HAVE_LDAP
-GtkWidget* addressbook_dialog_create_sources_table (char *name, char *string1, char *string2,
- int num1, int num2);
-GtkWidget* supported_bases_create_table (char *name, char *string1, char *string2,
- int num1, int num2);
-
-#ifdef NEW_ADVANCED_UI
-GtkWidget* objectclasses_create_server_table (char *name, char *string1, char *string2,
- int num1, int num2);
-GtkWidget* objectclasses_create_evolution_table (char *name, char *string1, char *string2,
- int num1, int num2);
-#endif
-
-/* default objectclasses */
-#define TOP "top"
-#define PERSON "person"
-#define ORGANIZATIONALPERSON "organizationalPerson"
-#define INETORGPERSON "inetOrgPerson"
-#define EVOLUTIONPERSON "evolutionPerson"
-#define CALENTRY "calEntry"
-
-
-typedef struct {
- GtkWidget *notebook;
- int page_num;
-} FocusHelpClosure;
-
-static void
-focus_help (GtkWidget *w, GdkEventFocus *event, FocusHelpClosure *closure)
-{
- gtk_notebook_set_page (GTK_NOTEBOOK(closure->notebook), closure->page_num);
-}
-
-static void
-add_focus_handler (GtkWidget *widget, GtkWidget *notebook, int page_num)
-{
- FocusHelpClosure *focus_closure = g_new0 (FocusHelpClosure, 1);
- focus_closure->notebook = notebook;
- focus_closure->page_num = page_num;
-
- gtk_signal_connect_full (GTK_OBJECT (widget),
- "focus_in_event" /* XXX */,
- (GtkSignalFunc) focus_help, NULL,
- focus_closure,
- (GtkDestroyNotify) g_free,
- FALSE, FALSE);
-}
-
-
-typedef struct {
- EvolutionConfigControl *config_control;
- GtkWidget *page;
+typedef struct _AddressbookSourceDialog AddressbookSourceDialog;
+typedef struct _AddressbookSourcePageItem AddressbookSourcePageItem;
+struct _AddressbookSourceDialog {
GladeXML *gui;
- GNOME_Evolution_Shell shell;
-
- GtkWidget *sourcesTable;
- ETableModel *sourcesModel;
- GtkWidget *addSource;
- GtkWidget *editSource;
- GtkWidget *deleteSource;
-
-} AddressbookDialog;
-typedef struct {
- AddressbookDialog *addressbook_dialog;
- GladeXML *gui;
+ GtkWidget *dialog;
- GtkWidget *window;
- GtkWidget *druid; /* only used (obviously) in the druid */
+ GtkWidget *notebook;
+ GtkWidget *basic_notebook;
+ GtkWidget *advanced_notebook;
- /* info page fields */
- GtkSignalFunc general_modify_func;
+ GtkWidget *name;
GtkWidget *host;
+
+ GtkWidget *auth_checkbutton;
GtkWidget *auth_optionmenu;
- AddressbookLDAPAuthType auth;
- GtkWidget *auth_label_notebook;
- GtkWidget *auth_entry_notebook;
+ GtkWidget *auth_notebook;
GtkWidget *email;
GtkWidget *binddn;
+ int auth;
- /* connecting page fields */
- GtkSignalFunc connecting_modify_func;
- GtkWidget *port_combo;
- GtkWidget *ssl_optionmenu;
- AddressbookLDAPSSLType ssl;
-
- /* searching page fields */
- GtkSignalFunc searching_modify_func;
+ GtkWidget *port;
GtkWidget *rootdn;
- AddressbookLDAPScopeType scope;
GtkWidget *scope_optionmenu;
- GtkWidget *timeout_scale;
- GtkWidget *limit_spinbutton;
-
- /* display name page fields */
- GtkWidget *display_name;
- gboolean display_name_changed; /* only used in the druid */
-
- gboolean schema_query_successful;
-
-#ifdef NEW_ADVANCED_UI
- /* objectclasses tab fields */
- GPtrArray *server_objectclasses; /* the objectclasses available on the server */
- GPtrArray *evolution_objectclasses; /* the objectclasses evolution will use */
- GPtrArray *default_objectclasses; /* the objectclasses we default to (actually the
- intersection between defaults and server_objectclasses) */
- GtkSignalFunc objectclasses_modify_func;
- GtkWidget *objectclasses_server_table;
- ETableModel *objectclasses_server_model;
- GtkWidget *objectclasses_evolution_table;
- ETableModel *objectclasses_evolution_model;
- GtkWidget *objectclasses_add_button;
- GtkWidget *objectclasses_remove_button;
-
- /* refs we keep around so we can add/hide the tabs */
- GtkWidget *objectclasses_tab;
- GtkWidget *objectclasses_label;
- GtkWidget *mappings_tab;
- GtkWidget *mappings_label;
- GtkWidget *dn_customization_tab;
- GtkWidget *dn_customization_label;
-#endif
-
- /* stuff for the account editor window */
- int source_model_row;
- GtkWidget *ok_button;
- GtkWidget *apply_button;
- GtkWidget *close_button;
- GtkWidget *advanced_button_notebook;
- GtkWidget *notebook; /* the toplevel notebook */
-
- gboolean advanced;
-
-} AddressbookSourceDialog;
-
-
-/* ldap api foo */
-static LDAP *
-addressbook_ldap_init (GtkWidget *window, AddressbookSource *source)
-{
- LDAP *ldap = ldap_init (source->host, atoi(source->port));
-
- if (!ldap) {
- GtkWidget *dialog;
- dialog = gnome_error_dialog_parented (_("Failed to connect to LDAP server"), GTK_WINDOW(window));
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
- return NULL;
- }
-
- /* XXX do TLS if it's configured in */
-
- return ldap;
-}
-
-static int
-addressbook_ldap_auth (GtkWidget *window, AddressbookSource *source, LDAP *ldap)
-{
- int ldap_error;
-
- /* XXX use auth info from source */
- ldap_error = ldap_simple_bind_s (ldap, NULL, NULL);
- if (LDAP_SUCCESS != ldap_error) {
- GtkWidget *dialog;
- dialog = gnome_error_dialog_parented (_("Failed to authenticate with LDAP server"), GTK_WINDOW (window));
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
- }
- return ldap_error;
-
-}
-
-static int
-addressbook_root_dse_query (GtkWindow *window, AddressbookSource *source, LDAP *ldap, char **attrs, LDAPMessage **resp)
-{
- int ldap_error;
- struct timeval timeout;
-
- /* 3 second timeout */
- timeout.tv_sec = 3;
- timeout.tv_usec = 0;
-
- ldap_error = ldap_search_ext_s (ldap,
- LDAP_ROOT_DSE, LDAP_SCOPE_BASE,
- "(objectclass=*)",
- attrs, 0, NULL, NULL, &timeout, LDAP_NO_LIMIT, resp);
- if (LDAP_SUCCESS != ldap_error) {
- GtkWidget *dialog;
- dialog = gnome_error_dialog_parented (_("Could not perform query on Root DSE"), window);
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
- }
-
- return ldap_error;
-}
-
-
-static AddressbookSource *
-addressbook_dialog_get_source (AddressbookSourceDialog *dialog)
-{
- AddressbookSource *source = g_new0 (AddressbookSource, 1);
-
- source->name = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->display_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 (GTK_COMBO(dialog->port_combo)->entry));
- 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_spinbutton)));
- source->scope = dialog->scope;
- source->auth = dialog->auth;
- source->ssl = dialog->ssl;
-
- addressbook_storage_init_source_uri (source);
-
- return source;
-}
-
-static void
-addressbook_source_dialog_set_source (AddressbookSourceDialog *dialog, AddressbookSource *source)
-{
- char *string;
- e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->display_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 (GTK_COMBO(dialog->port_combo)->entry), source ? source->port : LDAP_PORT_STRING);
- 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_spinbutton), string);
- g_free (string);
-
- dialog->auth = source ? source->auth : ADDRESSBOOK_LDAP_AUTH_NONE;
- gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->auth_optionmenu), dialog->auth);
- if (dialog->auth != ADDRESSBOOK_LDAP_AUTH_NONE) {
- gtk_notebook_set_page (GTK_NOTEBOOK(dialog->auth_label_notebook), dialog->auth - 1);
- gtk_notebook_set_page (GTK_NOTEBOOK(dialog->auth_entry_notebook), dialog->auth - 1);
- }
- gtk_widget_set_sensitive (dialog->auth_label_notebook, dialog->auth != ADDRESSBOOK_LDAP_AUTH_NONE);
- gtk_widget_set_sensitive (dialog->auth_entry_notebook, dialog->auth != ADDRESSBOOK_LDAP_AUTH_NONE);
-
- dialog->scope = source ? source->scope : ADDRESSBOOK_LDAP_SCOPE_ONELEVEL;
- gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->scope_optionmenu), dialog->scope);
-
- dialog->ssl = source ? source->auth : ADDRESSBOOK_LDAP_SSL_WHENEVER_POSSIBLE;
- gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->ssl_optionmenu), dialog->ssl);
-}
-
-static void
-addressbook_source_dialog_destroy (GtkWidget *widget, AddressbookSourceDialog *dialog)
-{
-#ifdef NEW_ADVANCED_UI
-#define IF_UNREF(x) if (x) gtk_object_unref (GTK_OBJECT ((x)))
-
- int i;
-
- if (dialog->server_objectclasses) {
- for (i = 0; i < dialog->server_objectclasses->len; i ++)
- ldap_objectclass_free (g_ptr_array_index (dialog->server_objectclasses, i));
- g_ptr_array_free (dialog->server_objectclasses, TRUE);
- }
-
- if (dialog->evolution_objectclasses) {
- for (i = 0; i < dialog->evolution_objectclasses->len; i ++)
- ldap_objectclass_free (g_ptr_array_index (dialog->evolution_objectclasses, i));
- g_ptr_array_free (dialog->evolution_objectclasses, TRUE);
- }
-
- if (dialog->default_objectclasses) {
- for (i = 0; i < dialog->default_objectclasses->len; i ++)
- ldap_objectclass_free (g_ptr_array_index (dialog->default_objectclasses, i));
- g_ptr_array_free (dialog->default_objectclasses, TRUE);
- }
-
- IF_UNREF (dialog->objectclasses_server_model);
- IF_UNREF (dialog->objectclasses_evolution_model);
-
- IF_UNREF (dialog->objectclasses_tab);
- IF_UNREF (dialog->objectclasses_label);
- IF_UNREF (dialog->mappings_tab);
- IF_UNREF (dialog->mappings_label);
- IF_UNREF (dialog->dn_customization_tab);
- IF_UNREF (dialog->dn_customization_label);
-
-#undef IF_UNREF
-#endif
-
- gtk_object_destroy (GTK_OBJECT (dialog->gui));
-
- g_free (dialog);
-}
-
-static void
-addressbook_add_server_druid_cancel (GtkWidget *widget, AddressbookSourceDialog *dialog)
-{
- gtk_widget_destroy (dialog->window);
-}
-
-static void
-addressbook_add_server_druid_finish (GnomeDruidPage *druid_page, GtkWidget *gnome_druid, AddressbookSourceDialog *sdialog)
-{
- AddressbookSource *source = addressbook_dialog_get_source (sdialog);
- AddressbookDialog *dialog = sdialog->addressbook_dialog;
-
- printf ("in finish (%s,%s)\n", source->name, source->host);
-
- e_table_memory_store_insert (E_TABLE_MEMORY_STORE (dialog->sourcesModel),
- -1, source, source->name, source->host);
-
- evolution_config_control_changed (dialog->config_control);
+ AddressbookLDAPScopeType ldap_scope;
- /* tear down the widgets */
- gtk_widget_destroy (sdialog->window);
-}
-
-static void
-reparent_to_vbox (AddressbookSourceDialog *dialog, char *vbox_name, char *widget_name)
-{
- GtkWidget *vbox, *widget;
-
- vbox = glade_xml_get_widget (dialog->gui, vbox_name);
- widget = glade_xml_get_widget (dialog->gui, widget_name);
+ gint id; /* button we closed the dialog with */
- gtk_widget_reparent (widget, vbox);
- gtk_box_set_child_packing (GTK_BOX (vbox), widget, TRUE, TRUE, 0, GTK_PACK_START);
-}
+ AddressbookSource *source; /* our result if the Ok button was clicked */
+};
static void
-auth_optionmenu_activated (GtkWidget *item, AddressbookSourceDialog *dialog)
+addressbook_source_edit_changed (GtkWidget *item, AddressbookSourceDialog *dialog)
{
- dialog->auth = g_list_index (gtk_container_children (GTK_CONTAINER (item->parent)),
- item);
+ char *data;
+ gboolean complete = TRUE;
- dialog->general_modify_func (item, dialog);
-
- if (dialog->auth == 0) {
- gtk_widget_set_sensitive (dialog->auth_label_notebook, FALSE);
- gtk_widget_set_sensitive (dialog->auth_entry_notebook, FALSE);
- }
- else {
- gtk_widget_set_sensitive (dialog->auth_label_notebook, TRUE);
- gtk_widget_set_sensitive (dialog->auth_entry_notebook, TRUE);
- gtk_notebook_set_page (GTK_NOTEBOOK(dialog->auth_label_notebook), dialog->auth - 1);
- gtk_notebook_set_page (GTK_NOTEBOOK(dialog->auth_entry_notebook), dialog->auth - 1);
+ if (complete) {
+ data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (dialog->name), 0, -1);
+ if (!data || !*data)
+ complete = FALSE;
+ g_free (data);
}
-}
-static void
-add_auth_activate_cb (GtkWidget *item, AddressbookSourceDialog *dialog)
-{
- gtk_signal_connect (GTK_OBJECT (item), "activate",
- GTK_SIGNAL_FUNC (auth_optionmenu_activated), dialog);
-}
-
-static void
-setup_general_tab (AddressbookSourceDialog *dialog, GtkSignalFunc modify_func)
-{
- GtkWidget *general_tab_help;
- GtkWidget *menu;
-
- general_tab_help = glade_xml_get_widget (dialog->gui, "general-tab-help");
-
- dialog->general_modify_func = modify_func;
- dialog->host = glade_xml_get_widget (dialog->gui, "server-name-entry");
- gtk_signal_connect (GTK_OBJECT (dialog->host), "changed",
- modify_func, dialog);
- add_focus_handler (dialog->host, general_tab_help, 0);
-
- dialog->auth_label_notebook = glade_xml_get_widget (dialog->gui, "auth-label-notebook");
- dialog->auth_entry_notebook = glade_xml_get_widget (dialog->gui, "auth-entry-notebook");
- dialog->email = glade_xml_get_widget (dialog->gui, "email-entry");
- gtk_signal_connect (GTK_OBJECT (dialog->email), "changed",
- modify_func, dialog);
- add_focus_handler (dialog->email, general_tab_help, 1);
- dialog->binddn = glade_xml_get_widget (dialog->gui, "dn-entry");
- gtk_signal_connect (GTK_OBJECT (dialog->binddn), "changed",
- modify_func, dialog);
- add_focus_handler (dialog->binddn, general_tab_help, 2);
-
- 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);
- add_focus_handler (dialog->auth_optionmenu, general_tab_help, 3);
-}
+ if (complete) {
+ if (complete) {
+ data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (dialog->host), 0, -1);
+ if (!data || !*data)
+ complete = FALSE;
+ g_free (data);
+ }
-static gboolean
-general_tab_check (AddressbookSourceDialog *dialog)
-{
- gboolean valid = TRUE;
- char *string;
-
- string = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->host));
- if (!string || !string[0])
- valid = FALSE;
- g_free (string);
-
- if (valid) {
- if (dialog->auth != ADDRESSBOOK_LDAP_AUTH_NONE) {
- if (dialog->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE_BINDDN)
- string = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->binddn));
- else
- string = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->email));
-
- if (!string || !string[0])
- valid = FALSE;
- g_free (string);
+ if (complete) {
+ data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (dialog->port), 0, -1);
+ if (!data || !*data)
+ complete = FALSE;
+ /* XXX more validation on port here */
+ g_free (data);
}
}
- return valid;
+ gnome_dialog_set_sensitive (GNOME_DIALOG (dialog->dialog), 0, complete);
}
static void
-druid_info_page_modify_cb (GtkWidget *item, AddressbookSourceDialog *dialog)
+auth_checkbutton_changed (GtkWidget *item, AddressbookSourceDialog *dialog)
{
- gnome_druid_set_buttons_sensitive (GNOME_DRUID(dialog->druid),
- TRUE, /* back */
- general_tab_check (dialog), /* next */
- TRUE /* cancel */);
-}
+ /* make sure the change is reflected by the state of the dialog's OK button */
+ addressbook_source_edit_changed (item, dialog);
-static void
-druid_info_page_prepare (GnomeDruidPage *dpage, GtkWidget *gdruid, AddressbookSourceDialog *dialog)
-{
- druid_info_page_modify_cb (NULL, dialog);
- /* stick the focus in the hostname field */
- gtk_widget_grab_focus (dialog->host);
+ 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)));
}
-
-/* connecting page */
static void
-ssl_optionmenu_activated (GtkWidget *item, AddressbookSourceDialog *dialog)
+scope_optionmenu_activated (GtkWidget *item, AddressbookSourceDialog *dialog)
{
- dialog->ssl = g_list_index (gtk_container_children (GTK_CONTAINER (item->parent)),
- item);
+ /* make sure the change is reflected by the state of the dialog's OK button */
+ addressbook_source_edit_changed (item, dialog);
- dialog->connecting_modify_func (item, dialog);
+ dialog->ldap_scope = g_list_index (gtk_container_children (GTK_CONTAINER (item->parent)),
+ item);
}
static void
-ssl_optionmenu_selected (GtkWidget *item, AddressbookSourceDialog *dialog)
+auth_optionmenu_activated (GtkWidget *item, AddressbookSourceDialog *dialog)
{
- GtkWidget *connecting_tab_help;
- int ssl_type = g_list_index (gtk_container_children (GTK_CONTAINER (item->parent)),
- item);
+ /* make sure the change is reflected by the state of the dialog's OK button */
+ addressbook_source_edit_changed (item, dialog);
- connecting_tab_help = glade_xml_get_widget (dialog->gui, "connecting-tab-help");
+ dialog->auth = g_list_index (gtk_container_children (GTK_CONTAINER (item->parent)),
+ item) + 1;
- gtk_notebook_set_page (GTK_NOTEBOOK(connecting_tab_help), ssl_type + 1);
+ gtk_notebook_set_page (GTK_NOTEBOOK(dialog->auth_notebook), dialog->auth - 1);
}
-static void
-add_ssl_activate_cb (GtkWidget *item, AddressbookSourceDialog *dialog)
-{
- gtk_signal_connect (GTK_OBJECT (item), "activate",
- GTK_SIGNAL_FUNC (ssl_optionmenu_activated), dialog);
- gtk_signal_connect (GTK_OBJECT (item), "select",
- GTK_SIGNAL_FUNC (ssl_optionmenu_selected), dialog);
-}
+typedef struct {
+ GtkWidget *notebook;
+ int page_num;
+} FocusHelpClosure;
static void
-port_changed_func (GtkWidget *item, AddressbookSourceDialog *dialog)
+focus_help (GtkWidget *w, GdkEventFocus *event, FocusHelpClosure *closure)
{
- /* if the port value is ldaps, set the SSL/TLS option menu to
- Always and desensitize it */
- char *string = e_utf8_gtk_entry_get_text (GTK_ENTRY (item));
-
- dialog->connecting_modify_func (item, dialog);
-
- if (!strcmp (string, LDAPS_PORT_STRING)) {
- dialog->ssl = ADDRESSBOOK_LDAP_SSL_ALWAYS;
- gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->ssl_optionmenu),
- dialog->ssl);
-
- gtk_widget_set_sensitive (dialog->ssl_optionmenu, FALSE);
- }
- else {
- gtk_widget_set_sensitive (dialog->ssl_optionmenu, TRUE);
- }
-
-
- g_free (string);
+ gtk_notebook_set_page (GTK_NOTEBOOK(closure->notebook), closure->page_num);
}
static void
-setup_connecting_tab (AddressbookSourceDialog *dialog, GtkSignalFunc modify_func)
-{
- GtkWidget *menu;
- GtkWidget *connecting_tab_help;
-
- dialog->connecting_modify_func = modify_func;
-
- connecting_tab_help = glade_xml_get_widget (dialog->gui, "connecting-tab-help");
-
- dialog->port_combo = glade_xml_get_widget (dialog->gui, "port-combo");
- add_focus_handler (dialog->port_combo, connecting_tab_help, 0);
- add_focus_handler (GTK_COMBO(dialog->port_combo)->entry, connecting_tab_help, 0);
- gtk_signal_connect (GTK_OBJECT (GTK_COMBO(dialog->port_combo)->entry), "changed",
- modify_func, dialog);
- gtk_signal_connect (GTK_OBJECT (GTK_COMBO(dialog->port_combo)->entry), "changed",
- port_changed_func, dialog);
- dialog->ssl_optionmenu = glade_xml_get_widget (dialog->gui, "ssl-optionmenu");
- menu = gtk_option_menu_get_menu (GTK_OPTION_MENU(dialog->ssl_optionmenu));
- gtk_container_foreach (GTK_CONTAINER (menu), (GtkCallback)add_ssl_activate_cb, dialog);
-}
-
-static gboolean
-connecting_tab_check (AddressbookSourceDialog *dialog)
+add_focus_handler (GtkWidget *widget, GtkWidget *notebook, int page_num)
{
- gboolean valid = TRUE;
- char *string;
-
- string = e_utf8_gtk_entry_get_text (GTK_ENTRY (GTK_COMBO(dialog->port_combo)->entry));
- if (!string || !string[0])
- valid = FALSE;
- g_free (string);
-
- return valid;
-}
+ FocusHelpClosure *focus_closure = g_new0 (FocusHelpClosure, 1);
+ focus_closure->notebook = notebook;
+ focus_closure->page_num = page_num;
-static void
-druid_connecting_page_modify_cb (GtkWidget *item, AddressbookSourceDialog *dialog)
-{
- gnome_druid_set_buttons_sensitive (GNOME_DRUID(dialog->druid),
- TRUE, /* back */
- connecting_tab_check (dialog), /* next */
- TRUE /* cancel */);
+ gtk_signal_connect_full (GTK_OBJECT (widget),
+ "focus_in_event" /* XXX */,
+ (GtkSignalFunc) focus_help, NULL,
+ focus_closure,
+ (GtkDestroyNotify) g_free,
+ FALSE, FALSE);
}
static void
-druid_connecting_page_prepare (GnomeDruidPage *dpage, GtkWidget *gdruid, AddressbookSourceDialog *dialog)
-{
- druid_connecting_page_modify_cb (NULL, dialog);
- /* stick the focus in the port combo */
- gtk_widget_grab_focus (GTK_COMBO(dialog->port_combo)->entry);
-}
-
-
-/* searching page */
-static ETableMemoryStoreColumnInfo bases_table_columns[] = {
- E_TABLE_MEMORY_STORE_STRING,
- E_TABLE_MEMORY_STORE_TERMINATOR
-};
-
-#define BASES_TABLE_SPEC \
-"<ETableSpecification cursor-mode=\"line\" no-headers=\"true\"> \
- <ETableColumn model_col= \"0\" _title=\"Base\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
- <ETableState> \
- <column source=\"0\"/> \
- <grouping></grouping> \
- </ETableState> \
-</ETableSpecification>"
-
-GtkWidget*
-supported_bases_create_table (char *name, char *string1, char *string2, int num1, int num2)
-{
- GtkWidget *table;
- ETableModel *model;
-
- model = e_table_memory_store_new (bases_table_columns);
-
- table = e_table_scrolled_new (model, NULL, BASES_TABLE_SPEC, NULL);
-
- gtk_object_set_data (GTK_OBJECT (table), "model", model);
-
- return table;
-}
-
-static gboolean
-do_ldap_root_dse_query (GtkWidget *dialog, ETableModel *model, AddressbookSource *source, char ***rvalues)
+addressbook_source_dialog_set_source (AddressbookSourceDialog *dialog, AddressbookSource *source)
{
- LDAP* ldap;
- char *attrs[2];
- int ldap_error;
- char **values;
- LDAPMessage *resp;
- int i;
-
- ldap = addressbook_ldap_init (dialog, source);
- if (!ldap)
- return FALSE;
-
- if (LDAP_SUCCESS != addressbook_ldap_auth (dialog, source, ldap))
- goto fail;
-
- attrs[0] = "namingContexts";
- attrs[1] = NULL;
-
- ldap_error = addressbook_root_dse_query (GTK_WINDOW (dialog), source, ldap, attrs, &resp);
-
- if (ldap_error != LDAP_SUCCESS)
- goto fail;
+ 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 : "");
- values = ldap_get_values (ldap, resp, "namingContexts");
- if (!values || values[0] == NULL) {
- GtkWidget *error_dialog;
- error_dialog = gnome_ok_dialog_parented (_("The server responded with no supported search bases"), GTK_WINDOW (dialog));
- gtk_window_set_modal (GTK_WINDOW (error_dialog), TRUE);
- goto fail;
+ 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);
+ gtk_notebook_set_page (GTK_NOTEBOOK(dialog->auth_notebook), dialog->auth - 1);
}
- for (i = 0; values[i]; i++)
- e_table_memory_store_insert (E_TABLE_MEMORY_STORE (model),
- -1, GINT_TO_POINTER(i), values[i]);
-
- *rvalues = values;
+ dialog->ldap_scope = source ? source->scope : ADDRESSBOOK_LDAP_SCOPE_ONELEVEL;
+ gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->scope_optionmenu), dialog->ldap_scope);
- ldap_unbind_s (ldap);
- return TRUE;
-
- fail:
- ldap_unbind_s (ldap);
- return FALSE;
+ 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 void
-search_base_selection_model_changed (ESelectionModel *selection_model, GtkWidget *dialog)
-{
- gnome_dialog_set_sensitive (GNOME_DIALOG (dialog),
- 0 /* OK */, e_selection_model_selected_count (selection_model) == 1);
-}
-
-static void
-query_for_supported_bases (GtkWidget *button, AddressbookSourceDialog *sdialog)
+static AddressbookSource *
+addressbook_source_dialog_get_source (AddressbookSourceDialog *dialog)
{
- ESelectionModel *selection_model;
- AddressbookSource *source = addressbook_dialog_get_source (sdialog);
- GtkWidget *dialog;
- GtkWidget *supported_bases_table;
- ETableModel *model;
- int id;
- char **values;
-
- dialog = glade_xml_get_widget (sdialog->gui, "supported-bases-dialog");
-
- supported_bases_table = glade_xml_get_widget (sdialog->gui, "supported-bases-table");
- selection_model = e_table_get_selection_model (e_table_scrolled_get_table (E_TABLE_SCROLLED(supported_bases_table)));
- model = gtk_object_get_data (GTK_OBJECT (supported_bases_table), "model");
-
- gtk_signal_connect (GTK_OBJECT (selection_model), "selection_changed",
- search_base_selection_model_changed, dialog);
-
- search_base_selection_model_changed (selection_model, dialog);
-
- if (do_ldap_root_dse_query (dialog, model, source, &values)) {
- gnome_dialog_close_hides (GNOME_DIALOG(dialog), TRUE);
-
- id = gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
-
- if (id == 0) {
- int i;
- /* OK was clicked */
-
- /* ugh. */
- for (i = 0; values[i]; i ++) {
- if (e_selection_model_is_row_selected (selection_model, i)) {
- e_utf8_gtk_entry_set_text (GTK_ENTRY (sdialog->rootdn), values[i]);
- break; /* single selection, so we can quit when we've found it. */
- }
- }
- }
-
- ldap_value_free (values);
+ AddressbookSource *source = g_new0 (AddressbookSource, 1);
- e_table_memory_store_clear (E_TABLE_MEMORY_STORE (model));
- }
+ 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->scope = dialog->ldap_scope;
+ source->auth = dialog->auth;
- addressbook_source_free (source);
+ addressbook_storage_init_source_uri (source);
- gtk_object_unref (GTK_OBJECT (selection_model));
+ return source;
}
static void
-scope_optionmenu_activated (GtkWidget *item, AddressbookSourceDialog *dialog)
+addressbook_source_dialog_ok_clicked (GtkWidget *widget, AddressbookSourceDialog *dialog)
{
- dialog->scope = g_list_index (gtk_container_children (GTK_CONTAINER (item->parent)),
- item);
-
- dialog->searching_modify_func (item, dialog);
+ dialog->source = addressbook_source_dialog_get_source (dialog);
}
static void
@@ -738,707 +197,199 @@ add_scope_activate_cb (GtkWidget *item, AddressbookSourceDialog *dialog)
}
static void
-setup_searching_tab (AddressbookSourceDialog *dialog, GtkSignalFunc modify_func)
-{
- GtkWidget *menu;
- GtkWidget *rootdn_button;
- GtkWidget *searching_tab_help;
-
- dialog->searching_modify_func = modify_func;
-
- searching_tab_help = glade_xml_get_widget (dialog->gui, "searching-tab-help");
-
- dialog->rootdn = glade_xml_get_widget (dialog->gui, "rootdn-entry");
- add_focus_handler (dialog->rootdn, searching_tab_help, 0);
- if (modify_func)
- gtk_signal_connect (GTK_OBJECT (dialog->rootdn), "changed",
- modify_func, dialog);
-
- dialog->scope_optionmenu = glade_xml_get_widget (dialog->gui, "scope-optionmenu");
- add_focus_handler (dialog->scope_optionmenu, searching_tab_help, 1);
- menu = gtk_option_menu_get_menu (GTK_OPTION_MENU(dialog->scope_optionmenu));
- gtk_container_foreach (GTK_CONTAINER (menu), (GtkCallback)add_scope_activate_cb, dialog);
-
- dialog->timeout_scale = glade_xml_get_widget (dialog->gui, "timeout-scale");
- add_focus_handler (dialog->timeout_scale, searching_tab_help, 2);
- if (modify_func)
- gtk_signal_connect (GTK_OBJECT (GTK_RANGE(dialog->timeout_scale)->adjustment),
- "value_changed",
- modify_func, dialog);
-
- dialog->limit_spinbutton = glade_xml_get_widget (dialog->gui, "download-limit-spinbutton");
- if (modify_func)
- gtk_signal_connect (GTK_OBJECT (dialog->limit_spinbutton), "changed",
- modify_func, dialog);
-
- /* special handling for the "Show Supported Bases button" */
- rootdn_button = glade_xml_get_widget (dialog->gui, "rootdn-button");
- gtk_signal_connect (GTK_OBJECT (rootdn_button), "clicked",
- GTK_SIGNAL_FUNC(query_for_supported_bases), dialog);
-}
-
-static void
-druid_searching_page_prepare (GnomeDruidPage *dpage, GtkWidget *gdruid, AddressbookSourceDialog *dialog)
-{
- gnome_druid_set_buttons_sensitive (GNOME_DRUID(dialog->druid),
- TRUE, /* back */
- TRUE, /* next */
- TRUE /* cancel */);
-}
-
-
-/* display name page */
-static gboolean
-display_name_check (AddressbookSourceDialog *dialog)
-{
- gboolean valid = TRUE;
- char *string;
-
- string = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->display_name));
- if (!string || !string[0])
- valid = FALSE;
- g_free (string);
-
- return valid;
-}
-
-static void
-display_name_page_prepare (GtkWidget *page, GtkWidget *gnome_druid, AddressbookSourceDialog *dialog)
-{
- if (!dialog->display_name_changed) {
- char *server_name = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->host));
- e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->display_name), server_name);
- g_free (server_name);
- }
-
- gnome_druid_set_buttons_sensitive (GNOME_DRUID(dialog->druid),
- TRUE, /* back */
- display_name_check (dialog), /* next */
- TRUE /* cancel */);
-}
-
-static void
-druid_display_name_page_modify_cb (GtkWidget *item, AddressbookSourceDialog *dialog)
+add_auth_activate_cb (GtkWidget *item, AddressbookSourceDialog *dialog)
{
- dialog->display_name_changed = TRUE;
- display_name_page_prepare (NULL, NULL, dialog);
+ gtk_signal_connect (GTK_OBJECT (item), "activate",
+ GTK_SIGNAL_FUNC (auth_optionmenu_activated), dialog);
}
-
-#ifdef NEW_ADVANCED_UI
-/* objectclasses page */
-static ETableMemoryStoreColumnInfo objectclasses_table_columns[] = {
- E_TABLE_MEMORY_STORE_STRING,
- E_TABLE_MEMORY_STORE_TERMINATOR
-};
-#define OBJECTCLASSES_TABLE_SPEC \
-"<ETableSpecification cursor-mode=\"line\" no-headers=\"true\"> \
- <ETableColumn model_col= \"0\" _title=\"Objectclass\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
- <ETableState> \
- <column source=\"0\"/> \
- <grouping> <leaf column=\"0\" ascending=\"true\"/> </grouping> \
- </ETableState> \
-</ETableSpecification>"
-
-GtkWidget*
-objectclasses_create_server_table (char *name, char *string1, char *string2,
- int num1, int num2)
+static AddressbookSourceDialog*
+addressbook_source_dialog (GladeXML *gui, AddressbookSource *source, GtkWidget *parent)
{
- GtkWidget *table;
- ETableModel *model;
-
- model = e_table_memory_store_new (objectclasses_table_columns);
-
- table = e_table_scrolled_new (model, NULL, OBJECTCLASSES_TABLE_SPEC, NULL);
+ AddressbookSourceDialog *dialog = g_new0 (AddressbookSourceDialog, 1);
+ GtkWidget *menu;
- gtk_object_set_data (GTK_OBJECT (table), "model", model);
+ dialog->gui = gui;
- return table;
-}
+ dialog->dialog = glade_xml_get_widget (gui, "add_addressbook");
-GtkWidget*
-objectclasses_create_evolution_table (char *name, char *string1, char *string2,
- int num1, int num2)
-{
- GtkWidget *table;
- ETableModel *model;
+ if (source)
+ gtk_window_set_title (GTK_WINDOW (dialog->dialog), _("Edit Addressbook"));
- model = e_table_memory_store_new (objectclasses_table_columns);
+ gtk_window_set_modal (GTK_WINDOW (dialog->dialog), TRUE);
+ gtk_window_set_policy (GTK_WINDOW (dialog->dialog),
+ FALSE, TRUE, FALSE);
- table = e_table_scrolled_new (model, NULL, OBJECTCLASSES_TABLE_SPEC, NULL);
+ gnome_dialog_set_parent (GNOME_DIALOG (dialog->dialog),
+ GTK_WINDOW (parent));
- gtk_object_set_data (GTK_OBJECT (table), "model", model);
+ dialog->notebook = glade_xml_get_widget (gui, "add-addressbook-notebook");
+ dialog->basic_notebook = glade_xml_get_widget (gui, "basic-notebook");
+ dialog->advanced_notebook = glade_xml_get_widget (gui, "advanced-notebook");
- return table;
-}
+ /* BASIC STUFF */
+ dialog->name = glade_xml_get_widget (gui, "account-name-entry");
+ gtk_signal_connect (GTK_OBJECT (dialog->name), "changed",
+ GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog);
+ add_focus_handler (dialog->name, dialog->basic_notebook, 0);
-static void
-objectclasses_add_foreach (int model_row, AddressbookSourceDialog *dialog)
-{
- LDAPObjectClass *oc = e_table_memory_get_data (E_TABLE_MEMORY (dialog->objectclasses_server_model), model_row);
- e_table_memory_store_remove (E_TABLE_MEMORY_STORE (dialog->objectclasses_server_model), model_row);
- /* XXX remove from the server array */
- e_table_memory_store_insert (E_TABLE_MEMORY_STORE (dialog->objectclasses_evolution_model),
- -1, oc, oc->oc_names[0]);
- /* XXX add to the evolution array */
-}
+ dialog->host = glade_xml_get_widget (gui, "server-name-entry");
+ gtk_signal_connect (GTK_OBJECT (dialog->host), "changed",
+ GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog);
+ add_focus_handler (dialog->host, dialog->basic_notebook, 1);
-static void
-objectclasses_add (GtkWidget *item, AddressbookSourceDialog *dialog)
-{
- ESelectionModel *esm = e_table_get_selection_model (e_table_scrolled_get_table (E_TABLE_SCROLLED(dialog->objectclasses_server_table)));
+ /* BASIC -> AUTH STUFF */
+ dialog->auth_notebook = glade_xml_get_widget (gui, "auth-notebook");
- e_selection_model_foreach (esm, (EForeachFunc)objectclasses_add_foreach, dialog);
- dialog->objectclasses_modify_func (item, dialog);
-}
-
-static void
-objectclasses_server_double_click (ETable *et, int row, int col, GdkEvent *event, AddressbookSourceDialog *dialog)
-{
- objectclasses_add_foreach (row, dialog);
- dialog->objectclasses_modify_func (GTK_WIDGET (et), dialog);
-}
+ 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);
-static void
-objectclasses_remove_foreach (int model_row, AddressbookSourceDialog *dialog)
-{
- LDAPObjectClass *oc = e_table_memory_get_data (E_TABLE_MEMORY (dialog->objectclasses_evolution_model), model_row);
- e_table_memory_store_remove (E_TABLE_MEMORY_STORE (dialog->objectclasses_evolution_model), model_row);
- /* XXX remove from the evolution array */
- e_table_memory_store_insert (E_TABLE_MEMORY_STORE (dialog->objectclasses_server_model),
- -1, oc, oc->oc_names[0]);
- /* XXX add to the server array */
-}
+ 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);
-static void
-objectclasses_remove (GtkWidget *item, AddressbookSourceDialog *dialog)
-{
- ESelectionModel *esm = e_table_get_selection_model (e_table_scrolled_get_table (E_TABLE_SCROLLED(dialog->objectclasses_evolution_table)));
+ dialog->email = glade_xml_get_widget (gui, "email-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, 4);
- e_selection_model_foreach (esm, (EForeachFunc)objectclasses_add_foreach, dialog);
+ dialog->binddn = glade_xml_get_widget (gui, "dn-entry");
+ gtk_signal_connect (GTK_OBJECT (dialog->binddn), "changed",
+ GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog);
+ 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",
+ GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog);
+ add_focus_handler (dialog->port, dialog->advanced_notebook, 0);
+
+ dialog->rootdn = glade_xml_get_widget (gui, "rootdn-entry");
+ gtk_signal_connect (GTK_OBJECT (dialog->rootdn), "changed",
+ GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog);
+ add_focus_handler (dialog->rootdn, dialog->advanced_notebook, 1);
+
+ 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_scope_activate_cb, dialog);
- dialog->objectclasses_modify_func (item, dialog);
-}
+ /* fill in source info if there is some */
+ addressbook_source_dialog_set_source (dialog, source);
-static void
-objectclasses_evolution_double_click (ETable *et, int row, int col, GdkEvent *event, AddressbookSourceDialog *dialog)
-{
- objectclasses_remove_foreach (row, dialog);
- dialog->objectclasses_modify_func (GTK_WIDGET (et), dialog);
-}
+ /* always start out on the first page. */
+ gtk_notebook_set_page (GTK_NOTEBOOK (dialog->notebook), 0);
-static void
-objectclasses_restore_default (GtkWidget *item, AddressbookSourceDialog *dialog)
-{
- int i;
+ gnome_dialog_set_sensitive (GNOME_DIALOG (dialog->dialog), 0, FALSE);
- dialog->objectclasses_modify_func (item, dialog);
-
- /* clear out our evolution list */
- for (i = 0; i < dialog->evolution_objectclasses->len; i ++) {
- g_ptr_array_add (dialog->server_objectclasses, g_ptr_array_index (dialog->evolution_objectclasses, i));
- }
- g_ptr_array_set_size (dialog->evolution_objectclasses, 0);
-
- e_table_memory_store_clear (E_TABLE_MEMORY_STORE (dialog->objectclasses_evolution_model));
-
- for (i = 0; i < dialog->default_objectclasses->len; i++) {
- LDAPObjectClass *oc = g_ptr_array_index (dialog->default_objectclasses, i);
- g_ptr_array_add (dialog->evolution_objectclasses, oc);
- e_table_memory_store_insert (E_TABLE_MEMORY_STORE (dialog->objectclasses_evolution_model),
- i, oc, oc->oc_names[0]);
- }
-}
-
-static void
-server_selection_model_changed (ESelectionModel *selection_model, AddressbookSourceDialog *dialog)
-{
- gtk_widget_set_sensitive (dialog->objectclasses_add_button,
- e_selection_model_selected_count (selection_model) > 0);
-}
+ gnome_dialog_button_connect( GNOME_DIALOG (dialog->dialog), 0,
+ GTK_SIGNAL_FUNC (addressbook_source_dialog_ok_clicked),
+ dialog);
-static void
-evolution_selection_model_changed (ESelectionModel *selection_model, AddressbookSourceDialog *dialog)
-{
- gtk_widget_set_sensitive (dialog->objectclasses_remove_button,
- e_selection_model_selected_count (selection_model) > 0);
-}
+ /* and set focus to be the Account field (the first editable
+ field on the first page) */
+ gtk_widget_grab_focus (dialog->name);
-static void
-setup_objectclasses_tab (AddressbookSourceDialog *dialog, GtkSignalFunc modify_func)
-{
- ETable *table;
- GtkWidget *restore_default;
- ESelectionModel *esm;
-
- dialog->server_objectclasses = g_ptr_array_new ();
- dialog->evolution_objectclasses = g_ptr_array_new ();
- dialog->default_objectclasses = g_ptr_array_new ();
-
- dialog->objectclasses_modify_func = modify_func;
-
- dialog->objectclasses_server_table = glade_xml_get_widget (dialog->gui, "objectclasses-server-table");
- dialog->objectclasses_server_model = gtk_object_get_data (GTK_OBJECT (dialog->objectclasses_server_table), "model");
-
- dialog->objectclasses_evolution_table = glade_xml_get_widget (dialog->gui, "objectclasses-evolution-table");
- dialog->objectclasses_evolution_model = gtk_object_get_data (GTK_OBJECT (dialog->objectclasses_evolution_table), "model");
-
- table = e_table_scrolled_get_table (E_TABLE_SCROLLED(dialog->objectclasses_server_table));
- gtk_signal_connect (GTK_OBJECT (table), "double_click",
- GTK_SIGNAL_FUNC (objectclasses_server_double_click), dialog);
- esm = e_table_get_selection_model (table);
- gtk_signal_connect (GTK_OBJECT (esm), "selection_changed",
- server_selection_model_changed, dialog);
-
- table = e_table_scrolled_get_table (E_TABLE_SCROLLED(dialog->objectclasses_evolution_table));
- gtk_signal_connect (GTK_OBJECT (table), "double_click",
- GTK_SIGNAL_FUNC (objectclasses_evolution_double_click), dialog);
- esm = e_table_get_selection_model (table);
- gtk_signal_connect (GTK_OBJECT (esm), "selection_changed",
- evolution_selection_model_changed, dialog);
-
- dialog->objectclasses_add_button = glade_xml_get_widget (dialog->gui, "objectclasses-add-button");
- gtk_signal_connect (GTK_OBJECT (dialog->objectclasses_add_button), "clicked",
- GTK_SIGNAL_FUNC(objectclasses_add), dialog);
-
- dialog->objectclasses_remove_button = glade_xml_get_widget (dialog->gui, "objectclasses-remove-button");
- gtk_signal_connect (GTK_OBJECT (dialog->objectclasses_remove_button), "clicked",
- GTK_SIGNAL_FUNC(objectclasses_remove), dialog);
-
- restore_default = glade_xml_get_widget (dialog->gui, "objectclasses-default-button");
- gtk_signal_connect (GTK_OBJECT (restore_default), "clicked",
- GTK_SIGNAL_FUNC(objectclasses_restore_default), dialog);
+ return dialog;
}
-#endif
-
static AddressbookSourceDialog *
-addressbook_add_server_druid (AddressbookDialog *dialog)
-{
- AddressbookSourceDialog *sdialog = g_new0 (AddressbookSourceDialog, 1);
- GtkWidget *page;
-
- sdialog->addressbook_dialog = dialog;
-
- sdialog->gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, NULL);
-
- sdialog->window = glade_xml_get_widget (sdialog->gui, "account-druid-window");
- sdialog->druid = glade_xml_get_widget (sdialog->gui, "account-druid");
-
- /* info page */
- page = glade_xml_get_widget (sdialog->gui, "add-server-druid-info-page");
- reparent_to_vbox (sdialog, "account-druid-general-vbox", "general-tab");
- setup_general_tab (sdialog, GTK_SIGNAL_FUNC (druid_info_page_modify_cb));
- gtk_signal_connect (GTK_OBJECT(page), "prepare",
- GTK_SIGNAL_FUNC(druid_info_page_prepare), sdialog);
-
- /* connecting page */
- page = glade_xml_get_widget (sdialog->gui, "add-server-druid-connecting-page");
- reparent_to_vbox (sdialog, "account-druid-connecting-vbox", "connecting-tab");
- setup_connecting_tab (sdialog, druid_connecting_page_modify_cb);
- gtk_signal_connect (GTK_OBJECT(page), "prepare",
- GTK_SIGNAL_FUNC(druid_connecting_page_prepare), sdialog);
-
- /* searching page */
- page = glade_xml_get_widget (sdialog->gui, "add-server-druid-searching-page");
- reparent_to_vbox (sdialog, "account-druid-searching-vbox", "searching-tab");
- setup_searching_tab (sdialog, NULL);
- gtk_signal_connect (GTK_OBJECT(page), "prepare",
- GTK_SIGNAL_FUNC(druid_searching_page_prepare), sdialog);
-
- /* display name page */
- page = glade_xml_get_widget (sdialog->gui, "add-server-druid-display-name-page");
- sdialog->display_name = glade_xml_get_widget (sdialog->gui, "druid-display-name-entry");
- gtk_signal_connect (GTK_OBJECT (sdialog->display_name), "changed",
- druid_display_name_page_modify_cb, sdialog);
- gtk_signal_connect (GTK_OBJECT(page), "prepare",
- GTK_SIGNAL_FUNC(display_name_page_prepare), sdialog);
-
- page = glade_xml_get_widget (sdialog->gui, "add-server-druid-finish-page");
- gtk_signal_connect (GTK_OBJECT(page), "finish",
- GTK_SIGNAL_FUNC(addressbook_add_server_druid_finish), sdialog);
- gtk_signal_connect (GTK_OBJECT(sdialog->druid), "cancel",
- GTK_SIGNAL_FUNC(addressbook_add_server_druid_cancel), sdialog);
- gtk_signal_connect (GTK_OBJECT(sdialog->window), "destroy",
- GTK_SIGNAL_FUNC(addressbook_source_dialog_destroy), sdialog);
-
- gtk_window_set_modal (GTK_WINDOW (sdialog->window), TRUE);
-
- gtk_widget_show (sdialog->window);
-
- return sdialog;
-}
-
-static void
-editor_modify_cb (GtkWidget *item, AddressbookSourceDialog *dialog)
-{
- gboolean valid = TRUE;
-
- valid = display_name_check (dialog);
- if (valid)
- valid = general_tab_check (dialog);
-#if 0
- if (valid)
- valid = connecting_tab_check (dialog);
- if (valid)
- valid = searching_tab_check (dialog);
-#endif
-
- gtk_widget_set_sensitive (dialog->ok_button, valid);
- gtk_widget_set_sensitive (dialog->apply_button, valid);
-}
-
-static void
-set_advanced_button_state (AddressbookSourceDialog *dialog)
+addressbook_config_source_with_gui (GladeXML *gui, AddressbookSource *source, GtkWidget *parent)
{
- if (dialog->advanced) {
- gtk_notebook_set_page (GTK_NOTEBOOK(dialog->advanced_button_notebook), 0);
-#ifdef NEW_ADVANCED_UI
- gtk_notebook_append_page (GTK_NOTEBOOK(dialog->notebook), dialog->objectclasses_tab, dialog->objectclasses_label);
- gtk_notebook_append_page (GTK_NOTEBOOK(dialog->notebook), dialog->mappings_tab, dialog->mappings_label);
- gtk_notebook_append_page (GTK_NOTEBOOK(dialog->notebook), dialog->dn_customization_tab, dialog->dn_customization_label);
-#endif
- }
- else {
- gtk_notebook_set_page (GTK_NOTEBOOK(dialog->advanced_button_notebook), 1);
-
- /* hide the advanced tabs of the main notebook */
- gtk_notebook_remove_page (GTK_NOTEBOOK(dialog->notebook), 5);
- gtk_notebook_remove_page (GTK_NOTEBOOK(dialog->notebook), 4);
- gtk_notebook_remove_page (GTK_NOTEBOOK(dialog->notebook), 3);
- }
-}
-
-#ifdef NEW_ADVANCED_UI
-static void
-advanced_button_clicked (GtkWidget *button, AddressbookSourceDialog *dialog)
-{
- dialog->advanced = !dialog->advanced;
- set_advanced_button_state (dialog);
-}
-
-static gboolean
-do_schema_query (AddressbookSourceDialog *sdialog)
-{
- LDAP *ldap;
- int ldap_error;
- char *schema_dn;
- char *attrs[3];
- char **values;
- int i;
- AddressbookSource *source = addressbook_dialog_get_source (sdialog);
- LDAPMessage *resp;
- struct timeval timeout;
-
- ldap = addressbook_ldap_init (sdialog->window, source);
- if (!ldap)
- goto fail;
-
- if (LDAP_SUCCESS != addressbook_ldap_auth (sdialog->window, source, ldap))
- goto fail;
-
- attrs[0] = "subschemaSubentry";
- attrs[1] = NULL;
-
- ldap_error = addressbook_root_dse_query (sdialog->window, source, ldap, attrs, &resp);
-
- if (ldap_error != LDAP_SUCCESS)
- goto fail;
-
- values = ldap_get_values (ldap, resp, "subschemaSubentry");
- if (!values || values[0] == NULL) {
- GtkWidget *dialog;
- dialog = gnome_ok_dialog_parented (_("This server does not support LDAPv3 schema information"), GTK_WINDOW (sdialog->window));
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
- goto fail;
- }
+ AddressbookSourceDialog* dialog;
- schema_dn = g_strdup (values[0]);
+ dialog = addressbook_source_dialog (gui, source, parent);
- ldap_value_free (values);
- ldap_msgfree (resp);
-
- attrs[0] = "objectClasses";
- attrs[1] = NULL;
-
- /* 3 second timeout */
- timeout.tv_sec = 3;
- timeout.tv_usec = 0;
-
- ldap_error = ldap_search_ext_s (ldap, schema_dn, LDAP_SCOPE_BASE,
- "(objectClass=subschema)", attrs, 0,
- NULL, NULL, &timeout, LDAP_NO_LIMIT, &resp);
- if (LDAP_SUCCESS != ldap_error) {
- GtkWidget *dialog;
- dialog = gnome_error_dialog_parented (_("Error retrieving schema information"), GTK_WINDOW (sdialog->window));
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
- goto fail;
- }
-
- values = ldap_get_values (ldap, resp, "objectClasses");
- if (!values) {
- GtkWidget *dialog;
- dialog = gnome_error_dialog_parented (_("Server did not respond with valid schema information"), GTK_WINDOW (sdialog->window));
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
- goto fail;
- }
-
- for (i = 0; values[i]; i ++) {
- int j;
- int code;
- const char *err;
- LDAPObjectClass *oc = ldap_str2objectclass (values[i], &code, &err, 0);
-
- if (!oc)
- continue;
-
- /* we fill in the default list of classes here */
- for (j = 0; oc->oc_names[j]; j ++) {
- if (!g_strcasecmp (oc->oc_names[j], EVOLUTIONPERSON) ||
- !g_strcasecmp (oc->oc_names[j], INETORGPERSON) ||
- !g_strcasecmp (oc->oc_names[j], ORGANIZATIONALPERSON) ||
- !g_strcasecmp (oc->oc_names[j], PERSON) ||
- !g_strcasecmp (oc->oc_names[j], CALENTRY) ||
- !g_strcasecmp (oc->oc_names[j], TOP))
- g_ptr_array_add (sdialog->default_objectclasses, oc);
- }
-
- g_ptr_array_add (sdialog->server_objectclasses, oc);
- }
+ gnome_dialog_close_hides (GNOME_DIALOG(dialog->dialog), TRUE);
- addressbook_source_free (source);
- ldap_unbind_s (ldap);
- return TRUE;
+ dialog->id = gnome_dialog_run_and_close (GNOME_DIALOG (dialog->dialog));
- fail:
- addressbook_source_free (source);
- if (ldap)
- ldap_unbind_s (ldap);
- return FALSE;
+ return dialog;
}
-static void
-edit_dialog_switch_page (GtkNotebook *notebook,
- GtkNotebookPage *page, guint page_num,
- AddressbookSourceDialog *sdialog)
+void
+addressbook_create_new_source (const char *new_source, GtkWidget *parent)
{
- if (page_num >= 3 && !sdialog->schema_query_successful) {
- int i;
+ AddressbookSourceDialog *dialog;
+ GladeXML *gui;
- gtk_widget_set_sensitive (GTK_WIDGET (notebook), FALSE);
+ gui = glade_xml_new (EVOLUTION_GLADEDIR "/addressbook-config.glade", NULL);
- sdialog->schema_query_successful = do_schema_query (sdialog);
+ dialog = addressbook_source_dialog (gui, NULL, parent);
- if (sdialog->schema_query_successful) {
- /* fill in the objectclasses model */
- for (i = 0; i < sdialog->server_objectclasses->len; i ++) {
- LDAPObjectClass *oc = g_ptr_array_index (sdialog->server_objectclasses, i);
- e_table_memory_store_insert (E_TABLE_MEMORY_STORE (sdialog->objectclasses_server_model),
- -1, oc, oc->oc_names[0]);
- }
- gtk_widget_set_sensitive (page->child, TRUE);
- }
- else {
- gtk_widget_set_sensitive (page->child, FALSE);
- }
+ e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->name), new_source);
- gtk_widget_set_sensitive (GTK_WIDGET (notebook), TRUE);
- }
-}
-#endif
+ gnome_dialog_close_hides (GNOME_DIALOG(dialog->dialog), TRUE);
-static gboolean
-edit_dialog_store_change (AddressbookSourceDialog *sdialog)
-{
- AddressbookSource *source = addressbook_dialog_get_source (sdialog);
- AddressbookDialog *dialog = sdialog->addressbook_dialog;
- AddressbookSource *old_source;
+ dialog->id = gnome_dialog_run_and_close (GNOME_DIALOG (dialog->dialog));
+
+ gtk_object_unref (GTK_OBJECT (dialog->gui));
- /* check the display name for uniqueness */
- if (FALSE /* XXX */) {
- return FALSE;
+ if (dialog->id == 0) {
+ /* Ok was clicked */
+ addressbook_storage_add_source (addressbook_source_copy(dialog->source));
+ addressbook_storage_write_sources();
}
+}
- /* store the new source in the addressbook dialog */
- old_source = e_table_memory_get_data (E_TABLE_MEMORY (dialog->sourcesModel), sdialog->source_model_row);
- addressbook_source_free (old_source);
- e_table_memory_store_remove (E_TABLE_MEMORY_STORE (dialog->sourcesModel),
- sdialog->source_model_row);
-
- e_table_memory_store_insert (E_TABLE_MEMORY_STORE (dialog->sourcesModel),
- sdialog->source_model_row, source, source->name, source->host);
-
- /* and let the config control know about the change */
- evolution_config_control_changed (dialog->config_control);
+
- return TRUE;
-}
+typedef struct {
+ GladeXML *gui;
+ GNOME_Evolution_Shell shell;
+ GtkWidget *dialog;
+ GtkWidget *clistSources;
+ GtkWidget *addSource;
+ GtkWidget *editSource;
+ GtkWidget *deleteSource;
+ gint source_row;
+} AddressbookDialog;
static void
-edit_dialog_apply_clicked (GtkWidget *item, AddressbookSourceDialog *sdialog)
+update_sensitivity (AddressbookDialog *dialog)
{
- if (!edit_dialog_store_change (sdialog))
- return;
+ gboolean sensitive = dialog->source_row != -1;
- /* resensitize the buttons */
- gtk_widget_set_sensitive (sdialog->ok_button, FALSE);
- gtk_widget_set_sensitive (sdialog->apply_button, FALSE);
+ gtk_widget_set_sensitive (dialog->editSource, sensitive);
+ gtk_widget_set_sensitive (dialog->deleteSource, sensitive);
}
static void
-edit_dialog_close_clicked (GtkWidget *item, AddressbookSourceDialog *sdialog)
+add_source_clicked (GtkWidget *widget, AddressbookDialog *dialog)
{
- gtk_widget_destroy (sdialog->window);
-}
+ AddressbookSourceDialog *sdialog;
-static void
-edit_dialog_ok_clicked (GtkWidget *item, AddressbookSourceDialog *sdialog)
-{
- if (edit_dialog_store_change (sdialog))
- edit_dialog_close_clicked (item, sdialog);
-}
+ sdialog = addressbook_config_source_with_gui (dialog->gui, NULL, dialog->dialog);
+ if (sdialog->id == 0) {
+ /* Ok was clicked */
+ AddressbookSource *source = addressbook_source_copy(sdialog->source);
+ gint row;
+ gchar *text[2];
-static AddressbookSourceDialog*
-addressbook_edit_server_dialog (AddressbookDialog *dialog, AddressbookSource *source, int model_row)
-{
- AddressbookSourceDialog *sdialog = g_new0 (AddressbookSourceDialog, 1);
- GtkWidget *general_tab_help;
- GtkWidget *fewer_options_button, *more_options_button;
-
- sdialog->addressbook_dialog = dialog;
- sdialog->source_model_row = model_row;
-
- sdialog->gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, NULL);
-
- sdialog->window = glade_xml_get_widget (sdialog->gui, "account-editor-window");
-
- /* general tab */
- general_tab_help = glade_xml_get_widget (dialog->gui, "general-tab-help");
- reparent_to_vbox (sdialog, "account-editor-general-vbox", "general-tab");
- setup_general_tab (sdialog, GTK_SIGNAL_FUNC (editor_modify_cb));
- sdialog->display_name = glade_xml_get_widget (sdialog->gui, "account-editor-display-name-entry");
- gtk_signal_connect (GTK_OBJECT (sdialog->display_name), "changed",
- editor_modify_cb, sdialog);
- add_focus_handler (sdialog->display_name, general_tab_help, 4);
-
- /* connecting tab */
- reparent_to_vbox (sdialog, "account-editor-connecting-vbox", "connecting-tab");
- setup_connecting_tab (sdialog, GTK_SIGNAL_FUNC (editor_modify_cb));
-
- /* searching tab */
- reparent_to_vbox (sdialog, "account-editor-searching-vbox", "searching-tab");
- setup_searching_tab (sdialog, GTK_SIGNAL_FUNC (editor_modify_cb));
-
-#ifdef NEW_ADVANCED_UI
- /* objectclasses tab */
- reparent_to_vbox (sdialog, "account-editor-objectclasses-vbox", "objectclasses-tab");
- setup_objectclasses_tab (sdialog, GTK_SIGNAL_FUNC (editor_modify_cb));
-
- /* mappings tab */
- reparent_to_vbox (sdialog, "account-editor-mappings-vbox", "mappings-tab");
- /* XXX setup_mappings_tab */
-
- /* dn customization tab */
- reparent_to_vbox (sdialog, "account-editor-dn-customization-vbox", "dn-customization-tab");
- /* XXX setup_dn_customization_tab */
-#endif
-
- sdialog->ok_button = glade_xml_get_widget (sdialog->gui, "account-editor-ok-button");
- sdialog->apply_button = glade_xml_get_widget (sdialog->gui, "account-editor-apply-button");
- sdialog->close_button = glade_xml_get_widget (sdialog->gui, "account-editor-close-button");
-
- sdialog->advanced_button_notebook = glade_xml_get_widget (sdialog->gui, "account-editor-advanced-button-notebook");
- fewer_options_button = glade_xml_get_widget (sdialog->gui, "account-editor-fewer-options-button");
- more_options_button = glade_xml_get_widget (sdialog->gui, "account-editor-more-options-button");
-
- sdialog->notebook = glade_xml_get_widget (sdialog->gui, "account-editor-notebook");
-#ifdef NEW_ADVANCED_UI
- sdialog->objectclasses_label = glade_xml_get_widget (sdialog->gui, "account-editor-objectclasses-label");
- gtk_object_ref (GTK_OBJECT (sdialog->objectclasses_label));
- sdialog->objectclasses_tab = glade_xml_get_widget (sdialog->gui, "account-editor-objectclasses-vbox");
- gtk_object_ref (GTK_OBJECT (sdialog->objectclasses_tab));
- sdialog->mappings_label = glade_xml_get_widget (sdialog->gui, "account-editor-mappings-label");
- gtk_object_ref (GTK_OBJECT (sdialog->mappings_label));
- sdialog->mappings_tab = glade_xml_get_widget (sdialog->gui, "account-editor-mappings-vbox");
- gtk_object_ref (GTK_OBJECT (sdialog->mappings_tab));
- sdialog->dn_customization_label = glade_xml_get_widget (sdialog->gui, "account-editor-dn-customization-label");
- gtk_object_ref (GTK_OBJECT (sdialog->dn_customization_label));
- sdialog->dn_customization_tab = glade_xml_get_widget (sdialog->gui, "account-editor-dn-customization-vbox");
- gtk_object_ref (GTK_OBJECT (sdialog->dn_customization_tab));
-#endif
-
- addressbook_source_dialog_set_source (sdialog, source);
-
- set_advanced_button_state (sdialog);
-
-#ifdef NEW_ADVANCED_UI
- gtk_signal_connect (GTK_OBJECT (fewer_options_button),
- "clicked", advanced_button_clicked, sdialog);
- gtk_signal_connect (GTK_OBJECT (more_options_button),
- "clicked", advanced_button_clicked, sdialog);
-
-#else
- gtk_widget_hide (sdialog->advanced_button_notebook);
-#endif
-
-#ifdef NEW_ADVANCED_UI
- /* set up a signal handler to query for schema info if the user switches to the advanced tabs */
- gtk_signal_connect (GTK_OBJECT (sdialog->notebook), "switch_page",
- GTK_SIGNAL_FUNC (edit_dialog_switch_page), sdialog);
-#endif
-
- gtk_signal_connect (GTK_OBJECT (sdialog->ok_button),
- "clicked", GTK_SIGNAL_FUNC(edit_dialog_ok_clicked), sdialog);
- gtk_signal_connect (GTK_OBJECT (sdialog->apply_button),
- "clicked", GTK_SIGNAL_FUNC(edit_dialog_apply_clicked), sdialog);
- gtk_signal_connect (GTK_OBJECT (sdialog->close_button),
- "clicked", GTK_SIGNAL_FUNC(edit_dialog_close_clicked), sdialog);
- gtk_signal_connect (GTK_OBJECT(sdialog->window), "destroy",
- GTK_SIGNAL_FUNC(addressbook_source_dialog_destroy), sdialog);
-
- gtk_widget_set_sensitive (sdialog->ok_button, FALSE);
- gtk_widget_set_sensitive (sdialog->apply_button, FALSE);
-
- gtk_window_set_modal (GTK_WINDOW (sdialog->window), TRUE);
-
- gtk_widget_show (sdialog->window);
-
- return sdialog;
-}
+ text[0] = source->name;
+ text[1] = source->host;
-static void
-add_source_clicked (GtkWidget *widget, AddressbookDialog *dialog)
-{
- addressbook_add_server_druid (dialog);
+ row = e_utf8_gtk_clist_append (GTK_CLIST(dialog->clistSources), text);
+ gtk_clist_set_row_data_full (GTK_CLIST(dialog->clistSources), row, source, (GtkDestroyNotify) addressbook_source_free);
+ gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 0, TRUE);
+ gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 1, TRUE);
+ update_sensitivity (dialog);
+ }
}
static void
edit_source_clicked (GtkWidget *widget, AddressbookDialog *dialog)
{
- int i;
- ESelectionModel *selection_model;
- int row_count;
-
- selection_model = e_table_get_selection_model (e_table_scrolled_get_table (E_TABLE_SCROLLED(dialog->sourcesTable)));
- row_count = e_selection_model_row_count (selection_model);
-
- for (i = 0; i < row_count; i ++) {
- if (e_selection_model_is_row_selected (selection_model, i)) {
- AddressbookSource *source = e_table_memory_get_data (E_TABLE_MEMORY(dialog->sourcesModel), i);
- AddressbookSourceDialog *sdialog;
- sdialog = addressbook_edit_server_dialog (dialog, source, i);
- break; /* single select so we're done now */
- }
- }
-
-#if 0
AddressbookSource *source;
AddressbookSourceDialog *sdialog;
source = gtk_clist_get_row_data (GTK_CLIST (dialog->clistSources), dialog->source_row);
- sdialog = addressbook_config_source_with_gui (dialog->gui, source, dialog->page);
+ sdialog = addressbook_config_source_with_gui (dialog->gui, source, dialog->dialog);
if (sdialog->id == 0) {
/* Ok was clicked */
source = addressbook_source_copy(sdialog->source);
@@ -1446,302 +397,134 @@ edit_source_clicked (GtkWidget *widget, AddressbookDialog *dialog)
e_utf8_gtk_clist_set_text (GTK_CLIST (dialog->clistSources), dialog->source_row, 0, source->name);
e_utf8_gtk_clist_set_text (GTK_CLIST (dialog->clistSources), dialog->source_row, 1, source->host);
gtk_clist_set_row_data (GTK_CLIST (dialog->clistSources), dialog->source_row, source);
-
- evolution_config_control_changed (dialog->config_control);
-
+ gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 0, TRUE);
+ gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 1, TRUE);
update_sensitivity (dialog);
}
-#endif
}
static void
delete_source_clicked (GtkWidget *widget, AddressbookDialog *dialog)
{
- int i;
- ESelectionModel *selection_model;
- int row_count;
-
- selection_model = e_table_get_selection_model (e_table_scrolled_get_table (E_TABLE_SCROLLED(dialog->sourcesTable)));
- row_count = e_selection_model_row_count (selection_model);
-
- for (i = 0; i < row_count; i ++) {
- if (e_selection_model_is_row_selected (selection_model, i)) {
- AddressbookSource *source = e_table_memory_get_data (E_TABLE_MEMORY(dialog->sourcesModel), i);
- e_table_memory_store_remove (E_TABLE_MEMORY_STORE (dialog->sourcesModel), i);
- addressbook_source_free (source);
-
- break; /* single select so we're done now */
- }
- }
-
- evolution_config_control_changed (dialog->config_control);
+ gtk_clist_remove (GTK_CLIST (dialog->clistSources), dialog->source_row);
+ dialog->source_row = -1;
+ gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 0, TRUE);
+ gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 1, TRUE);
+ update_sensitivity (dialog);
}
static void
-ldap_config_control_destroy_callback (EvolutionConfigControl *config_control,
- void *data)
+sources_select_row (GtkWidget *widget, gint row, gint column,
+ GdkEventButton *event, AddressbookDialog *dialog)
{
- AddressbookDialog *dialog;
+ dialog->source_row = row;
- dialog = (AddressbookDialog *) data;
+ update_sensitivity (dialog);
+}
+static void
+addressbook_dialog_close (GtkWidget *w, AddressbookDialog *dialog)
+{
+ gtk_widget_destroy (dialog->dialog);
gtk_object_unref (GTK_OBJECT (dialog->gui));
-
- /* XXX free more stuff here */
-
g_free (dialog);
}
static void
-ldap_config_control_apply_callback (EvolutionConfigControl *config_control,
- void *data)
+addressbook_dialog_apply (GtkWidget *w, AddressbookDialog *dialog)
{
- AddressbookDialog *dialog;
int i;
- int count;
-
- dialog = (AddressbookDialog *) data;
addressbook_storage_clear_sources();
- count = e_table_model_row_count (E_TABLE_MODEL (dialog->sourcesModel));
-
- for (i = 0; i < count; i ++) {
- AddressbookSource *source = e_table_memory_get_data (E_TABLE_MEMORY (dialog->sourcesModel), i);
+ for (i = 0; i < GTK_CLIST(dialog->clistSources)->rows; i ++) {
+ AddressbookSource *source = (AddressbookSource*)gtk_clist_get_row_data (GTK_CLIST (dialog->clistSources), i);
addressbook_storage_add_source (addressbook_source_copy (source));
}
addressbook_storage_write_sources();
+
+ gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 0, FALSE);
+ gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 1, FALSE);
}
static void
-sources_selection_changed (ESelectionModel *esm, AddressbookDialog *dialog)
+addressbook_dialog_ok (GtkWidget *w, AddressbookDialog *dialog)
{
- gboolean sensitive = e_selection_model_selected_count (esm) == 1;
-
- gtk_widget_set_sensitive (dialog->editSource, sensitive);
- gtk_widget_set_sensitive (dialog->deleteSource, sensitive);
+ addressbook_dialog_apply(w, dialog);
+ addressbook_dialog_close(w, dialog);
}
-static AddressbookDialog *
-ldap_dialog_new (GNOME_Evolution_Shell shell)
+void
+addressbook_config (GNOME_Evolution_Shell shell)
{
AddressbookDialog *dialog;
+ GladeXML *gui;
+ GtkWidget *clist;
GList *l;
- ESelectionModel *esm;
dialog = g_new0 (AddressbookDialog, 1);
- dialog->gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, NULL);
+ dialog->source_row = -1;
+
+ gui = glade_xml_new (EVOLUTION_GLADEDIR "/addressbook-config.glade", NULL);
+ dialog->gui = gui;
dialog->shell = shell;
- dialog->sourcesTable = glade_xml_get_widget (dialog->gui, "sourcesTable");
- dialog->sourcesModel = gtk_object_get_data (GTK_OBJECT (dialog->sourcesTable), "model");
+ dialog->dialog = glade_xml_get_widget (gui, "addressbook_sources");
+
+ clist = glade_xml_get_widget (gui, "clistSources");
+ dialog->clistSources = clist;
- dialog->addSource = glade_xml_get_widget (dialog->gui, "addSource");
+ gtk_clist_column_titles_passive (GTK_CLIST (clist));
+ gtk_clist_set_column_width (GTK_CLIST (clist), 0, 80);
+
+ dialog->addSource = glade_xml_get_widget (gui, "addSource");
gtk_signal_connect (GTK_OBJECT(dialog->addSource), "clicked",
GTK_SIGNAL_FUNC (add_source_clicked),
dialog);
- dialog->editSource = glade_xml_get_widget (dialog->gui, "editSource");
+ dialog->editSource = glade_xml_get_widget (gui, "editSource");
gtk_signal_connect (GTK_OBJECT(dialog->editSource), "clicked",
GTK_SIGNAL_FUNC (edit_source_clicked),
dialog);
- dialog->deleteSource = glade_xml_get_widget (dialog->gui, "deleteSource");
+ dialog->deleteSource = glade_xml_get_widget (gui, "deleteSource");
gtk_signal_connect (GTK_OBJECT(dialog->deleteSource), "clicked",
GTK_SIGNAL_FUNC (delete_source_clicked),
dialog);
+ gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 0, FALSE);
+ gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 1, FALSE);
+ update_sensitivity (dialog);
+
l = addressbook_storage_get_sources ();
for (; l != NULL; l = l->next) {
AddressbookSource *source;
+ gint row;
+ gchar *text[2];
source = addressbook_source_copy ((AddressbookSource*)l->data);
- e_table_memory_store_insert (E_TABLE_MEMORY_STORE (dialog->sourcesModel),
- -1, source, source->name, source->host);
- }
-
- esm = e_table_get_selection_model (e_table_scrolled_get_table (E_TABLE_SCROLLED(dialog->sourcesTable)));
- gtk_signal_connect (GTK_OBJECT (esm), "selection_changed",
- GTK_SIGNAL_FUNC (sources_selection_changed), dialog);
-
- sources_selection_changed (esm, dialog);
-
- dialog->page = glade_xml_get_widget (dialog->gui, "addressbook-sources");
-
- return dialog;
-}
+ text[0] = source->name;
+ text[1] = source->host;
-static ETableMemoryStoreColumnInfo sources_table_columns[] = {
- E_TABLE_MEMORY_STORE_STRING,
- E_TABLE_MEMORY_STORE_STRING,
- E_TABLE_MEMORY_STORE_TERMINATOR
-};
-
-#define SOURCES_TABLE_SPEC \
-"<ETableSpecification cursor-mode=\"line\"> \
- <ETableColumn model_col= \"0\" _title=\"Account Name\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
- <ETableColumn model_col= \"1\" _title=\"Server Name\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
- <ETableState> \
- <column source=\"0\"/> \
- <column source=\"1\"/> \
- <grouping></grouping> \
- </ETableState> \
-</ETableSpecification>"
-
-GtkWidget*
-addressbook_dialog_create_sources_table (char *name, char *string1, char *string2, int num1, int num2)
-{
- GtkWidget *table;
- ETableModel *model;
-
- model = e_table_memory_store_new (sources_table_columns);
-
- table = e_table_scrolled_new (model, NULL, SOURCES_TABLE_SPEC, NULL);
-
- gtk_object_set_data (GTK_OBJECT (table), "model", model);
-
- return table;
-}
-#endif /* HAVE_LDAP */
-
-static EvolutionConfigControl *
-ldap_config_control_new (GNOME_Evolution_Shell shell)
-{
- GtkWidget *control_widget;
- EvolutionConfigControl *control;
-
-#ifdef HAVE_LDAP
- AddressbookDialog *dialog;
-
- dialog = ldap_dialog_new (shell);
-
- control_widget = dialog->page;
-
- gtk_widget_ref (control_widget);
-
- gtk_container_remove (GTK_CONTAINER (control_widget->parent), control_widget);
-#else
- control_widget = gtk_label_new (_("LDAP was not enabled in this build of Evolution"));
- gtk_widget_set_sensitive (control_widget, FALSE);
- gtk_widget_show (control_widget);
-#endif
-
- control = evolution_config_control_new (control_widget);
-
-#ifdef HAVE_LDAP
- dialog->config_control = control;
- gtk_signal_connect (GTK_OBJECT (dialog->config_control), "apply",
- GTK_SIGNAL_FUNC (ldap_config_control_apply_callback), dialog);
- gtk_signal_connect (GTK_OBJECT (dialog->config_control), "destroy",
- GTK_SIGNAL_FUNC (ldap_config_control_destroy_callback), dialog);
-
- gtk_widget_unref (dialog->page);
-#endif
-
- return control;
-}
-
-
-/* Implementation of the factory for the configuration control. */
-
-static BonoboGenericFactory *factory = NULL;
-
-static BonoboObject *
-config_control_factory_fn (BonoboGenericFactory *factory,
- const char *component_id,
- void *data)
-{
- GNOME_Evolution_Shell shell;
- EvolutionConfigControl *control;
-
- shell = (GNOME_Evolution_Shell) data;
-
- if (!strcmp (component_id, LDAP_CONFIG_CONTROL_ID)) {
- control = ldap_config_control_new (shell);
- } else {
- control = NULL;
- g_assert_not_reached ();
- }
-
- return BONOBO_OBJECT (control);
-}
-
-gboolean
-addressbook_config_register_factory (GNOME_Evolution_Shell shell)
-{
- g_return_val_if_fail (shell != CORBA_OBJECT_NIL, FALSE);
-
- factory = bonobo_generic_factory_new_multi (CONFIG_CONTROL_FACTORY_ID,
- config_control_factory_fn,
- shell);
-
- if (factory != NULL) {
- return TRUE;
- } else {
- g_warning ("Cannot register factory %s", CONFIG_CONTROL_FACTORY_ID);
- return FALSE;
- }
-}
-
-void
-addressbook_config_create_new_source (const char *new_source, GtkWidget *parent)
-{
-#ifdef HAVE_LDAP
-#if 0
- AddressbookSourceDialog *dialog;
- GladeXML *gui;
-
- gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, NULL);
-
- dialog = addressbook_source_dialog (gui, NULL, parent);
-
- e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->name), new_source);
-
- gnome_dialog_close_hides (GNOME_DIALOG(dialog->dialog), TRUE);
-
- dialog->id = gnome_dialog_run_and_close (GNOME_DIALOG (dialog->dialog));
-
- gtk_object_unref (GTK_OBJECT (dialog->gui));
-
- if (dialog->id == 0) {
- /* Ok was clicked */
- addressbook_storage_add_source (addressbook_source_copy(dialog->source));
- addressbook_storage_write_sources();
+ row = e_utf8_gtk_clist_append (GTK_CLIST(clist), text);
+ gtk_clist_set_row_data_full (GTK_CLIST(clist), row, source, (GtkDestroyNotify) addressbook_source_free);
}
-#endif
-#endif /* HAVE_LDAP */
-}
-#ifdef STANDALONE
-int
-main(int argc, char **argv)
-{
- AddressbookDialog *dialog;
-
- gnome_init_with_popt_table ("evolution-addressbook", "0.0",
- argc, argv, oaf_popt_options, 0, NULL);
-
- glade_gnome_init ();
-
- bindtextdomain (PACKAGE, EVOLUTION_LOCALEDIR);
- textdomain (PACKAGE);
-
-#if 0
- g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
-#endif
-
- gtk_widget_push_visual (gdk_rgb_get_visual ());
- gtk_widget_push_colormap (gdk_rgb_get_cmap ());
+ gtk_signal_connect (GTK_OBJECT (clist), "select_row",
+ GTK_SIGNAL_FUNC (sources_select_row),
+ dialog);
- dialog = ldap_dialog_new (NULL);
+ gnome_dialog_button_connect (GNOME_DIALOG(dialog->dialog),
+ 0 /* OK */, addressbook_dialog_ok, dialog);
- gtk_widget_show (glade_xml_get_widget (dialog->gui, "addressbook-sources-window"));
+ gnome_dialog_button_connect (GNOME_DIALOG(dialog->dialog),
+ 1 /* APPLY */, addressbook_dialog_apply, dialog);
- gtk_main();
+ gnome_dialog_button_connect (GNOME_DIALOG(dialog->dialog),
+ 2 /* CLOSE */, addressbook_dialog_close, dialog);
- return 0;
+ gnome_dialog_run (GNOME_DIALOG(dialog->dialog));
}
-#endif