aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
authorChris Toshok <toshok@helixcode.com>2000-12-31 04:12:33 +0800
committerChris Toshok <toshok@src.gnome.org>2000-12-31 04:12:33 +0800
commitb941c6f04cef47d9d9038a5e8e41f60a3819ef84 (patch)
tree8d95612d96f9a1dbd3fa62c62fcb1bf9a3c21d99 /addressbook/gui
parentc4dfc8669bf21acf8c06cc7f79d0864c8e3d4fab (diff)
downloadgsoc2013-evolution-b941c6f04cef47d9d9038a5e8e41f60a3819ef84.tar
gsoc2013-evolution-b941c6f04cef47d9d9038a5e8e41f60a3819ef84.tar.gz
gsoc2013-evolution-b941c6f04cef47d9d9038a5e8e41f60a3819ef84.tar.bz2
gsoc2013-evolution-b941c6f04cef47d9d9038a5e8e41f60a3819ef84.tar.lz
gsoc2013-evolution-b941c6f04cef47d9d9038a5e8e41f60a3819ef84.tar.xz
gsoc2013-evolution-b941c6f04cef47d9d9038a5e8e41f60a3819ef84.tar.zst
gsoc2013-evolution-b941c6f04cef47d9d9038a5e8e41f60a3819ef84.zip
copy the dialog's source, destroy the dialog after we're done, and make
2000-12-30 Chris Toshok <toshok@helixcode.com> * gui/component/addressbook-config.c (edit_source_clicked): copy the dialog's source, destroy the dialog after we're done, and make sure to update both columns in the clist. (add_source_clicked): copy the dialog's source, and destroy the dialog when we're done. (addressbook_source_dialog_destroy): free up all the dialog's memory. * gui/component/addressbook.c (set_prop): allow file: uri's that point to files, not just dirs that contain addressbook.db. The rule is the addressbook file has to end in .db. * gui/component/addressbook-storage.c (file_source_foreach): contactserver => contactfile. cut and paste error. (addressbook_storage_init_source_uri): use file://%s to build the uri. * gui/component/e-ldap-server-dialog.[ch]: forgot to remove these in my last commit. svn path=/trunk/; revision=7199
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/component/addressbook-config.c33
-rw-r--r--addressbook/gui/component/addressbook-storage.c4
-rw-r--r--addressbook/gui/component/addressbook.c17
-rw-r--r--addressbook/gui/component/e-ldap-server-dialog.c142
-rw-r--r--addressbook/gui/component/e-ldap-server-dialog.h9
-rw-r--r--addressbook/gui/component/ldap-server-dialog.glade.h11
6 files changed, 45 insertions, 171 deletions
diff --git a/addressbook/gui/component/addressbook-config.c b/addressbook/gui/component/addressbook-config.c
index 57e21340c7..ae15b7aaf1 100644
--- a/addressbook/gui/component/addressbook-config.c
+++ b/addressbook/gui/component/addressbook-config.c
@@ -552,6 +552,26 @@ addressbook_source_dialog_ok_clicked (GtkWidget *widget, AddressbookSourceDialog
dialog->source = addressbook_source_dialog_get_source (dialog);
}
+static void
+addressbook_source_dialog_destroy (AddressbookSourceDialog *dialog)
+{
+ GList *s;
+
+ for (s = dialog->source_pages; s; s = s->next) {
+ AddressbookSourcePageItem *source_item = s->data;
+
+ g_list_foreach (source_item->auths, (GFunc)g_free, NULL);
+ g_list_free (source_item->auths);
+ g_free (source_item);
+ }
+
+ g_list_free (dialog->source_pages);
+
+ if (dialog->source)
+ addressbook_source_free (dialog->source);
+ g_free (dialog);
+}
+
static AddressbookSourceDialog*
addressbook_source_dialog (AddressbookSource *source, GtkWidget *parent)
{
@@ -715,7 +735,7 @@ add_source_clicked (GtkWidget *widget, AddressbookDialog *dialog)
sdialog = addressbook_config_source (NULL, dialog->dialog);
if (sdialog->id == 0) {
/* Ok was clicked */
- AddressbookSource *source = sdialog->source;
+ AddressbookSource *source = addressbook_source_copy(sdialog->source);
gint row;
gchar *text[2];
@@ -727,6 +747,8 @@ add_source_clicked (GtkWidget *widget, AddressbookDialog *dialog)
gnome_property_box_changed (GNOME_PROPERTY_BOX (dialog->dialog));
update_sensitivity (dialog);
}
+
+ addressbook_source_dialog_destroy (sdialog);
}
static void
@@ -740,12 +762,16 @@ edit_source_clicked (GtkWidget *widget, AddressbookDialog *dialog)
sdialog = addressbook_config_source (source, dialog->dialog);
if (sdialog->id == 0) {
/* Ok was clicked */
- source = sdialog->source;
- e_utf8_gtk_clist_set_text (GTK_CLIST (dialog->clistSources), dialog->source_row, 0, source->uri);
+ source = addressbook_source_copy(sdialog->source);
+
+ 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->uri);
gtk_clist_set_row_data (GTK_CLIST (dialog->clistSources), dialog->source_row, source);
gnome_property_box_changed (GNOME_PROPERTY_BOX (dialog->dialog));
update_sensitivity (dialog);
}
+
+ addressbook_source_dialog_destroy (sdialog);
}
static void
@@ -786,7 +812,6 @@ static void
addressbook_dialog_close (GnomePropertyBox *property_box, AddressbookDialog *dialog)
{
gtk_object_unref (GTK_OBJECT (dialog->gui));
- /* more stuff dude */
g_free (dialog);
}
diff --git a/addressbook/gui/component/addressbook-storage.c b/addressbook/gui/component/addressbook-storage.c
index af4613b9a2..e1b02ec93a 100644
--- a/addressbook/gui/component/addressbook-storage.c
+++ b/addressbook/gui/component/addressbook-storage.c
@@ -202,7 +202,7 @@ addressbook_storage_init_source_uri (AddressbookSource *source)
source->ldap.host, source->ldap.port,
source->ldap.rootdn, ldap_unparse_scope(source->ldap.scope));
else
- source->uri = g_strdup_printf ("file:%s",
+ source->uri = g_strdup_printf ("file://%s",
source->file.path);
}
@@ -330,7 +330,7 @@ static void
file_source_foreach (AddressbookSource *source, xmlNode *root)
{
xmlNode *source_root = xmlNewNode (NULL,
- (xmlChar *) "contactserver");
+ (xmlChar *) "contactfile");
xmlAddChild (root, source_root);
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index 49367bd041..bdad6ae04c 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -432,9 +432,20 @@ set_prop (BonoboPropertyBag *bag,
view->uri = g_strdup(BONOBO_ARG_GET_STRING (arg));
if (!strncmp (view->uri, "file:", 5)) {
- char *file_name = g_concat_dir_and_file(view->uri + 7, "addressbook.db");
- uri_data = g_strdup_printf("file://%s", file_name);
- g_free(file_name);
+
+ if (strlen (view->uri + 7) > 3
+ && !strcmp (view->uri + strlen(view->uri) - 3, ".db")) {
+ /* it's a .db file */
+ uri_data = g_strdup (view->uri);
+ }
+ else {
+ char *file_name;
+ /* we assume it's a dir and glom addressbook.db onto the end. */
+ file_name = g_concat_dir_and_file(view->uri + 7, "addressbook.db");
+ uri_data = g_strdup_printf("file://%s", file_name);
+ g_free(file_name);
+ }
+
}
else {
uri_data = g_strdup (view->uri);
diff --git a/addressbook/gui/component/e-ldap-server-dialog.c b/addressbook/gui/component/e-ldap-server-dialog.c
deleted file mode 100644
index 172f43280b..0000000000
--- a/addressbook/gui/component/e-ldap-server-dialog.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-ldap-server-dialog.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Toshok <toshok@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-
-#include <gnome.h>
-#include <glade/glade.h>
-#include "e-ldap-server-dialog.h"
-
-typedef struct {
- GladeXML *gui;
- GtkWidget *dialog;
- ELDAPServer *server;
-} ELDAPServerDialog;
-
-static void
-fill_in_server_info (ELDAPServerDialog *dialog)
-{
- ELDAPServer *ldap_server = dialog->server;
- GtkEditable *editable;
- int position;
-
- /* the name */
- position = 0;
- editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "name-entry"));
- gtk_editable_delete_text (editable, 0, -1);
- gtk_editable_insert_text (editable, ldap_server->name, strlen (ldap_server->name), &position);
-
- /* the server description */
- position = 0;
- editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "description-entry"));
- gtk_editable_delete_text (editable, 0, -1);
- gtk_editable_insert_text (editable, ldap_server->description, strlen (ldap_server->description), &position);
-
- /* the server hostname */
- position = 0;
- editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "server-entry"));
- gtk_editable_delete_text (editable, 0, -1);
- gtk_editable_insert_text (editable, ldap_server->host, strlen (ldap_server->host), &position);
-
- /* the server port */
- position = 0;
- editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "port-entry"));
- gtk_editable_delete_text (editable, 0, -1);
- gtk_editable_insert_text (editable, ldap_server->port, strlen (ldap_server->port), &position);
-
- /* the root dn */
- position = 0;
- editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "root-dn-entry"));
- gtk_editable_delete_text (editable, 0, -1);
- gtk_editable_insert_text (editable, ldap_server->rootdn, strlen (ldap_server->rootdn), &position);
-}
-
-static void
-extract_server_info (ELDAPServerDialog *dialog)
-{
- ELDAPServer *ldap_server = dialog->server;
- GtkEditable *editable;
- char *description, *server, *port, *rootdn, *name;
-
- /* the server name */
- editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "name-entry"));
- name = gtk_editable_get_chars(editable, 0, -1);
- if (name && *name) {
- if (ldap_server->name)
- g_free(ldap_server->name);
- ldap_server->name = name;
- }
-
- /* the server description */
- editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "description-entry"));
- description = gtk_editable_get_chars(editable, 0, -1);
- if (description && *description) {
- if (ldap_server->description)
- g_free(ldap_server->description);
- ldap_server->description = description;
- }
-
- /* the server hostname */
- editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "server-entry"));
- server = gtk_editable_get_chars(editable, 0, -1);
- if (server && *server) {
- if (ldap_server->host)
- g_free(ldap_server->host);
- ldap_server->host = server;
- }
-
- /* the server port */
- editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "port-entry"));
- port = gtk_editable_get_chars(editable, 0, -1);
- if (port && *port) {
- if (ldap_server->port)
- g_free (ldap_server->port);
- ldap_server->port = port;
- }
-
- /* the root dn */
- editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "root-dn-entry"));
- rootdn = gtk_editable_get_chars(editable, 0, -1);
- if (rootdn && *rootdn) {
- if (ldap_server->rootdn)
- g_free (ldap_server->rootdn);
- ldap_server->rootdn = rootdn;
- }
-}
-
-void
-e_ldap_server_editor_show(ELDAPServer *server)
-{
- ELDAPServerDialog *dialog = g_new0 (ELDAPServerDialog, 1);
-
- dialog->server = server;
- dialog->gui = glade_xml_new (EVOLUTION_GLADEDIR "/ldap-server-dialog.glade", NULL);
-
- dialog->dialog = glade_xml_get_widget(dialog->gui, "ldap-server-dialog");
-
- fill_in_server_info (dialog);
-
- gnome_dialog_run (GNOME_DIALOG(dialog->dialog));
-
- extract_server_info (dialog);
-
- gnome_dialog_close (GNOME_DIALOG(dialog->dialog));
-}
diff --git a/addressbook/gui/component/e-ldap-server-dialog.h b/addressbook/gui/component/e-ldap-server-dialog.h
deleted file mode 100644
index e5ae169f5c..0000000000
--- a/addressbook/gui/component/e-ldap-server-dialog.h
+++ /dev/null
@@ -1,9 +0,0 @@
-
-#ifndef __E_LDAP_SERVER_DIALOG_H__
-#define __E_LDAP_SERVER_DIALOG_H__
-
-#include "e-ldap-storage.h"
-
-void e_ldap_server_editor_show(ELDAPServer *server);
-
-#endif /* __E_LDAP_SERVER_DIALOG_H__ */
diff --git a/addressbook/gui/component/ldap-server-dialog.glade.h b/addressbook/gui/component/ldap-server-dialog.glade.h
deleted file mode 100644
index aa42511b90..0000000000
--- a/addressbook/gui/component/ldap-server-dialog.glade.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * Translatable strings file generated by extract-ui.
- * Add this file to your project's POTFILES.in
- * DO NOT compile it as part of your application.
- */
-
-gchar *s = N_("Description:");
-gchar *s = N_("LDAP Server:");
-gchar *s = N_("Name:");
-gchar *s = N_("Port Number:");
-gchar *s = N_("Root DN:");