aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/ChangeLog34
-rw-r--r--addressbook/contact-editor/e-contact-editor.c14
-rw-r--r--addressbook/contact-editor/e-contact-editor.h1
-rw-r--r--addressbook/gui/component/addressbook.c76
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c14
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.h1
-rw-r--r--addressbook/gui/widgets/Makefile.am2
-rw-r--r--addressbook/gui/widgets/e-addressbook-table-adapter.c11
-rw-r--r--addressbook/gui/widgets/e-addressbook-util.c160
-rw-r--r--addressbook/gui/widgets/e-addressbook-util.h41
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c124
-rw-r--r--addressbook/gui/widgets/e-minicard-view.c71
-rw-r--r--addressbook/gui/widgets/e-minicard.c72
13 files changed, 295 insertions, 326 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 7f0be25a56..77769698ff 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,37 @@
+2001-06-08 Chris Toshok <toshok@ximian.com>
+
+ * contact-editor/e-contact-editor.c (e_contact_editor_new): remove
+ the gtk_widget_show call...
+ (e_contact_editor_show): and put it here.
+
+ * contact-editor/e-contact-editor.h: add prototype for
+ e_contact_editor_show.
+
+ * gui/widgets/e-minicard.c (e_minicard_event): call
+ e_addressbook_show_contact_editor.
+ (card_modified_cb): call e_addressbook_error_dialog if status !=
+ SUCCESS.
+
+ * gui/widgets/e-minicard-view.c (e_minicard_view_event): call
+ e_addressbook_show_contact_editor. also, use card_modified_cb as
+ the commit_card callback.
+
+ * gui/widgets/e-addressbook-view.c (table_double_click): clean
+ this area up alot, call e_addressbook_show_contact_editor.
+ (card_deleted_cb): call e_addressbook_error_dialog.
+
+ * gui/widgets/e-addressbook-table-adapter.c
+ (card_modified_cb): new function, call e_addressbook_error_dialog
+ if the status != SUCCESS.
+ (addressbook_set_value_at): use card_modified_cb as the callback
+ for e_book_commit_card.
+
+ * gui/widgets/Makefile.am (libeminicard_a_SOURCES): add
+ e-addressbook-util.[ch].
+
+ * gui/component/addressbook.c (new_contact_cb): use
+ e_addressbook_show_contact_editor here.
+
2001-06-05 Christopher James Lahey <clahey@ximian.com>
* contact-editor/e-contact-editor.c (categories_clicked): Remove
diff --git a/addressbook/contact-editor/e-contact-editor.c b/addressbook/contact-editor/e-contact-editor.c
index 7c427ef6c7..664b442303 100644
--- a/addressbook/contact-editor/e-contact-editor.c
+++ b/addressbook/contact-editor/e-contact-editor.c
@@ -1066,7 +1066,6 @@ e_contact_editor_new (ECard *card,
"is_read_only", is_read_only,
NULL);
- gtk_widget_show (ce->app);
return ce;
}
@@ -2129,6 +2128,19 @@ e_contact_editor_raise (EContactEditor *editor)
gdk_window_raise (GTK_WIDGET (editor->app)->window);
}
+/**
+ * e_contact_editor_show:
+ * @ce: The %EContactEditor object.
+ *
+ * Shows the dialog associated with this %EContactEditor object.
+ */
+void
+e_contact_editor_show (EContactEditor *ce)
+{
+ gtk_widget_show (ce->app);
+}
+
+
GtkWidget *
e_contact_editor_create_date(gchar *name,
gchar *string1, gchar *string2,
diff --git a/addressbook/contact-editor/e-contact-editor.h b/addressbook/contact-editor/e-contact-editor.h
index bc54dd02b0..09de660681 100644
--- a/addressbook/contact-editor/e-contact-editor.h
+++ b/addressbook/contact-editor/e-contact-editor.h
@@ -111,6 +111,7 @@ EContactEditor *e_contact_editor_new (ECard *card,
EList *writable_fields,
gboolean is_read_only);
GtkType e_contact_editor_get_type (void);
+void e_contact_editor_show (EContactEditor *editor);
void e_contact_editor_raise (EContactEditor *editor);
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index e75f83b663..1ae42755ca 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -31,6 +31,7 @@
#include "addressbook.h"
#include "addressbook/gui/search/e-addressbook-search-dialog.h"
#include "addressbook/gui/widgets/e-addressbook-view.h"
+#include "addressbook/gui/widgets/e-addressbook-util.h"
#include "addressbook/printing/e-contact-print.h"
#include <ebook/e-book.h>
@@ -52,79 +53,6 @@ typedef struct {
} AddressbookView;
static void
-card_added_cb (EBook* book, EBookStatus status, const char *id,
- gpointer user_data)
-{
- g_print ("%s: %s(): a card was added\n", __FILE__, __FUNCTION__);
-}
-
-static void
-card_modified_cb (EBook* book, EBookStatus status,
- gpointer user_data)
-{
- g_print ("%s: %s(): a card was modified\n", __FILE__, __FUNCTION__);
-}
-
-/* Callback for the add_card signal from the contact editor */
-static void
-add_card_cb (EContactEditor *ce, ECard *card, gpointer data)
-{
- EBook *book;
-
- book = E_BOOK (data);
- e_book_add_card (book, card, card_added_cb, NULL);
-}
-
-/* Callback for the commit_card signal from the contact editor */
-static void
-commit_card_cb (EContactEditor *ce, ECard *card, gpointer data)
-{
- EBook *book;
-
- book = E_BOOK (data);
- e_book_commit_card (book, card, card_modified_cb, NULL);
-}
-
-/* Callback for the delete_card signal from the contact editor */
-static void
-delete_card_cb (EContactEditor *ce, ECard *card, gpointer data)
-{
- EBook *book;
-
- book = E_BOOK (data);
- e_book_remove_card (book, card, card_modified_cb, NULL);
-}
-
-/* Callback used when the contact editor is closed */
-static void
-editor_closed_cb (EContactEditor *ce, gpointer data)
-{
- gtk_object_unref (GTK_OBJECT (ce));
-}
-
-static void
-supported_fields_cb (EBook *book, EBookStatus status, EList *fields, gpointer closure)
-{
- EContactEditor *ce;
- ECard *card;
-
- card = e_card_new("");
-
- ce = e_contact_editor_new (card, TRUE, fields, FALSE);
-
- gtk_signal_connect (GTK_OBJECT (ce), "add_card",
- GTK_SIGNAL_FUNC (add_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "commit_card",
- GTK_SIGNAL_FUNC (commit_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "delete_card",
- GTK_SIGNAL_FUNC (delete_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
- GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
-
- gtk_object_sink(GTK_OBJECT(card));
-}
-
-static void
new_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path)
{
EBook *book;
@@ -136,7 +64,7 @@ new_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path)
g_assert (E_IS_BOOK (book));
- e_book_get_supported_fields (book, supported_fields_cb, view);
+ e_addressbook_show_contact_editor (book, NULL, e_addressbook_view_can_create (view->view));
}
static void
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 7c427ef6c7..664b442303 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -1066,7 +1066,6 @@ e_contact_editor_new (ECard *card,
"is_read_only", is_read_only,
NULL);
- gtk_widget_show (ce->app);
return ce;
}
@@ -2129,6 +2128,19 @@ e_contact_editor_raise (EContactEditor *editor)
gdk_window_raise (GTK_WIDGET (editor->app)->window);
}
+/**
+ * e_contact_editor_show:
+ * @ce: The %EContactEditor object.
+ *
+ * Shows the dialog associated with this %EContactEditor object.
+ */
+void
+e_contact_editor_show (EContactEditor *ce)
+{
+ gtk_widget_show (ce->app);
+}
+
+
GtkWidget *
e_contact_editor_create_date(gchar *name,
gchar *string1, gchar *string2,
diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h
index bc54dd02b0..09de660681 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.h
+++ b/addressbook/gui/contact-editor/e-contact-editor.h
@@ -111,6 +111,7 @@ EContactEditor *e_contact_editor_new (ECard *card,
EList *writable_fields,
gboolean is_read_only);
GtkType e_contact_editor_get_type (void);
+void e_contact_editor_show (EContactEditor *editor);
void e_contact_editor_raise (EContactEditor *editor);
diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am
index 27db6b3b5c..92b925d199 100644
--- a/addressbook/gui/widgets/Makefile.am
+++ b/addressbook/gui/widgets/Makefile.am
@@ -23,6 +23,8 @@ libeminicard_a_SOURCES = \
e-addressbook-table-adapter.h \
e-addressbook-model.c \
e-addressbook-model.h \
+ e-addressbook-util.c \
+ e-addressbook-util.h \
e-addressbook-view.c \
e-addressbook-view.h \
e-minicard-control.c \
diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c
index 47a664df59..5ddc8acdfb 100644
--- a/addressbook/gui/widgets/e-addressbook-table-adapter.c
+++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c
@@ -3,6 +3,7 @@
#include <config.h>
#include "e-addressbook-model.h"
#include "e-addressbook-table-adapter.h"
+#include "e-addressbook-util.h"
#include <gnome-xml/tree.h>
#include <gnome-xml/parser.h>
#include <gnome-xml/xmlmemory.h>
@@ -109,6 +110,14 @@ addressbook_value_at (ETableModel *etc, int col, int row)
/* This function sets the value at a particular point in our ETableModel. */
static void
+card_modified_cb (EBook* book, EBookStatus status,
+ gpointer user_data)
+{
+ g_print ("%s: %s(): a card was modified\n", __FILE__, __FUNCTION__);
+ if (status != E_BOOK_STATUS_SUCCESS)
+ e_addressbook_error_dialog (_("Error modifying card"), status);
+}
+static void
addressbook_set_value_at (ETableModel *etc, int col, int row, const void *val)
{
EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(etc);
@@ -127,7 +136,7 @@ addressbook_set_value_at (ETableModel *etc, int col, int row, const void *val)
NULL);
e_book_commit_card(e_addressbook_model_get_ebook(priv->model),
- card, NULL, NULL);
+ card, card_modified_cb, NULL);
/* XXX do we need this? shouldn't the commit_card generate a changed signal? */
e_table_model_cell_changed(etc, col, row);
diff --git a/addressbook/gui/widgets/e-addressbook-util.c b/addressbook/gui/widgets/e-addressbook-util.c
new file mode 100644
index 0000000000..55d3ce503e
--- /dev/null
+++ b/addressbook/gui/widgets/e-addressbook-util.c
@@ -0,0 +1,160 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * e-table-field-chooser.c
+ * Copyright (C) 2001 Ximian, Inc.
+ * Author: Chris Toshok <toshok@ximian.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 <config.h>
+
+#include <gnome.h>
+
+#include "e-addressbook-util.h"
+#include "e-contact-editor.h"
+
+void
+e_addressbook_error_dialog (const gchar *msg, EBookStatus status)
+{
+ static char *status_to_string[] = {
+ N_("Success"),
+ N_("Unknown error"),
+ N_("Repository offline"),
+ N_("Permission denied"),
+ N_("Card not found"),
+ N_("Protocol not supported"),
+ N_("Canceled"),
+ N_("Other error")
+ };
+ char *error_msg;
+
+ error_msg = g_strdup_printf ("%s: %s", msg, status_to_string [status]);
+
+ gtk_widget_show (gnome_error_dialog (error_msg));
+
+ g_free (error_msg);
+}
+
+
+static void
+card_added_cb (EBook* book, EBookStatus status, const char *id,
+ gpointer user_data)
+{
+ g_print ("%s: %s(): a card was added\n", __FILE__, __FUNCTION__);
+ if (status != E_BOOK_STATUS_SUCCESS)
+ e_addressbook_error_dialog (_("Error adding card"), status);
+}
+
+static void
+card_modified_cb (EBook* book, EBookStatus status,
+ gpointer user_data)
+{
+ g_print ("%s: %s(): a card was modified\n", __FILE__, __FUNCTION__);
+ if (status != E_BOOK_STATUS_SUCCESS)
+ e_addressbook_error_dialog (_("Error modifying card"), status);
+}
+
+static void
+card_removed_cb (EBook* book, EBookStatus status,
+ gpointer user_data)
+{
+ g_print ("%s: %s(): a card was removed\n", __FILE__, __FUNCTION__);
+ if (status != E_BOOK_STATUS_SUCCESS)
+ e_addressbook_error_dialog (_("Error removing card"), status);
+}
+
+/* Callback for the add_card signal from the contact editor */
+static void
+add_card_cb (EContactEditor *ce, ECard *card, gpointer data)
+{
+ EBook *book;
+
+ book = E_BOOK (data);
+ e_book_add_card (book, card, card_added_cb, NULL);
+}
+
+/* Callback for the commit_card signal from the contact editor */
+static void
+commit_card_cb (EContactEditor *ce, ECard *card, gpointer data)
+{
+ EBook *book;
+
+ book = E_BOOK (data);
+ e_book_commit_card (book, card, card_modified_cb, NULL);
+}
+
+/* Callback for the delete_card signal from the contact editor */
+static void
+delete_card_cb (EContactEditor *ce, ECard *card, gpointer data)
+{
+ EBook *book;
+
+ book = E_BOOK (data);
+ e_book_remove_card (book, card, card_removed_cb, NULL);
+}
+
+/* Callback used when the contact editor is closed */
+static void
+editor_closed_cb (EContactEditor *ce, gpointer data)
+{
+ gtk_object_unref (GTK_OBJECT (ce));
+}
+
+typedef struct {
+ ECard *card;
+ gboolean editable;
+} SupportedFieldsClosure;
+
+static void
+supported_fields_cb (EBook *book, EBookStatus status,
+ EList *fields, EContactEditor *ce)
+{
+ gtk_object_set (GTK_OBJECT (ce),
+ "writable_fields", fields,
+ NULL);
+
+ gtk_signal_connect (GTK_OBJECT (ce), "add_card",
+ GTK_SIGNAL_FUNC (add_card_cb), book);
+ gtk_signal_connect (GTK_OBJECT (ce), "commit_card",
+ GTK_SIGNAL_FUNC (commit_card_cb), book);
+ gtk_signal_connect (GTK_OBJECT (ce), "delete_card",
+ GTK_SIGNAL_FUNC (delete_card_cb), book);
+ gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
+ GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
+
+ e_contact_editor_show (ce);
+}
+
+EContactEditor *
+e_addressbook_show_contact_editor (EBook *book, ECard *card,
+ gboolean editable)
+{
+ EContactEditor *ce;
+ gboolean new_card = FALSE;
+
+ if (card == NULL) {
+ new_card = TRUE;
+ card = e_card_new ("");
+ }
+
+ ce = e_contact_editor_new (card, new_card, NULL,
+ !editable);
+
+ e_book_get_supported_fields (book, (EBookFieldsCallback)supported_fields_cb, ce);
+
+ return ce;
+}
diff --git a/addressbook/gui/widgets/e-addressbook-util.h b/addressbook/gui/widgets/e-addressbook-util.h
new file mode 100644
index 0000000000..f40a1b825a
--- /dev/null
+++ b/addressbook/gui/widgets/e-addressbook-util.h
@@ -0,0 +1,41 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* e-addressbook-util.h
+ * Copyright (C) 2001 Ximian, Inc.
+ * Author: Chris Toshok <toshok@ximian.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.
+ */
+#ifndef __E_ADDRESSBOOK_UTIL_H__
+#define __E_ADDRESSBOOK_UTIL_H__
+
+#include "addressbook/backend/ebook/e-book.h"
+#include "addressbook/contact-editor/e-contact-editor.h"
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+void e_addressbook_error_dialog (const gchar *msg,
+ EBookStatus status);
+EContactEditor* e_addressbook_show_contact_editor (EBook *book, ECard *card,
+ gboolean editable);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __E_ADDRESSBOOK_UTIL_H__ */
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index 6b73e0c92e..99dc600e94 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -48,6 +48,7 @@
#include "e-addressbook-view.h"
#include "e-addressbook-model.h"
+#include "e-addressbook-util.h"
#include "e-addressbook-table-adapter.h"
#include "e-addressbook-reflow-adapter.h"
#include "e-minicard-view-widget.h"
@@ -75,8 +76,6 @@ static void selection_get (GtkWidget *invisible, GtkSelectionData *selection_dat
guint info, guint time_stamp, EAddressbookView *view);
static void invisible_destroyed (GtkWidget *invisible, EAddressbookView *view);
-static void e_book_error_dialog (const gchar *msg, EBookStatus status);
-
static GtkTableClass *parent_class = NULL;
/* The arguments we take */
@@ -467,97 +466,6 @@ create_minicard_view (EAddressbookView *view)
gtk_object_unref (GTK_OBJECT (adapter));
}
-
-static void
-card_added_cb (EBook* book, EBookStatus status, const char *id,
- gpointer user_data)
-{
- g_print ("%s: %s(): a card was added\n", __FILE__, __FUNCTION__);
- if (status != E_BOOK_STATUS_SUCCESS)
- e_book_error_dialog (_("Error adding card"), status);
-}
-
-static void
-card_modified_cb (EBook* book, EBookStatus status,
- gpointer user_data)
-{
- g_print ("%s: %s(): a card was modified\n", __FILE__, __FUNCTION__);
- if (status != E_BOOK_STATUS_SUCCESS)
- e_book_error_dialog (_("Error modifying card"), status);
-}
-
-static void
-card_removed_cb (EBook* book, EBookStatus status,
- gpointer user_data)
-{
- g_print ("%s: %s(): a card was removed\n", __FILE__, __FUNCTION__);
- if (status != E_BOOK_STATUS_SUCCESS)
- e_book_error_dialog (_("Error removing card"), status);
-}
-
-/* Callback for the add_card signal from the contact editor */
-static void
-add_card_cb (EContactEditor *ce, ECard *card, gpointer data)
-{
- EBook *book;
-
- book = E_BOOK (data);
- e_book_add_card (book, card, card_added_cb, NULL);
-}
-
-/* Callback for the commit_card signal from the contact editor */
-static void
-commit_card_cb (EContactEditor *ce, ECard *card, gpointer data)
-{
- EBook *book;
-
- book = E_BOOK (data);
- e_book_commit_card (book, card, card_modified_cb, NULL);
-}
-
-/* Callback for the delete_card signal from the contact editor */
-static void
-delete_card_cb (EContactEditor *ce, ECard *card, gpointer data)
-{
- EBook *book;
-
- book = E_BOOK (data);
- e_book_remove_card (book, card, card_removed_cb, NULL);
-}
-
-/* Callback used when the contact editor is closed */
-static void
-editor_closed_cb (EContactEditor *ce, gpointer data)
-{
- gtk_object_unref (GTK_OBJECT (ce));
-}
-
-typedef struct {
- EAddressbookView *view;
- ECard *card;
-} CardAndView;
-
-static void
-supported_fields_cb (EBook *book, EBookStatus status, EList *fields, CardAndView *card_and_view)
-{
- EContactEditor *ce;
-
- ce = e_contact_editor_new (card_and_view->card, FALSE, fields, !card_and_view->view->editable);
-
- gtk_signal_connect (GTK_OBJECT (ce), "add_card",
- GTK_SIGNAL_FUNC (add_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "commit_card",
- GTK_SIGNAL_FUNC (commit_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "delete_card",
- GTK_SIGNAL_FUNC (delete_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
- GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
-
- gtk_object_unref(GTK_OBJECT(card_and_view->card));
-
- g_free (card_and_view);
-}
-
static void
table_double_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EAddressbookView *view)
{
@@ -565,7 +473,6 @@ table_double_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, E
EAddressbookModel *model = view->model;
ECard *card = e_addressbook_model_get_card(model, row);
EBook *book;
- CardAndView *card_and_view;
gtk_object_get(GTK_OBJECT(model),
"book", &book,
@@ -573,10 +480,7 @@ table_double_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, E
g_assert (E_IS_BOOK (book));
- card_and_view = g_new (CardAndView, 1);
- card_and_view->card = card;
- card_and_view->view = view;
- e_book_get_supported_fields (book, (EBookFieldsCallback)supported_fields_cb, card_and_view);
+ e_addressbook_show_contact_editor (book, card, view->editable);
}
}
@@ -1174,7 +1078,7 @@ card_deleted_cb (EBook* book, EBookStatus status, gpointer user_data)
emit_status_message (view, _("Done."));
if (status != E_BOOK_STATUS_SUCCESS) {
- e_book_error_dialog (_("Error removing card"), status);
+ e_addressbook_error_dialog (_("Error removing card"), status);
}
}
@@ -1217,28 +1121,6 @@ invisible_destroyed (GtkWidget *invisible, EAddressbookView *view)
}
static void
-e_book_error_dialog (const gchar *msg, EBookStatus status)
-{
- static char *status_to_string[] = {
- N_("Success"),
- N_("Unknown error"),
- N_("Repository offline"),
- N_("Permission denied"),
- N_("Card not found"),
- N_("Protocol not supported"),
- N_("Canceled"),
- N_("Other error")
- };
- char *error_msg;
-
- error_msg = g_strdup_printf ("%s: %s", msg, status_to_string [status]);
-
- gtk_widget_show (gnome_error_dialog (error_msg));
-
- g_free (error_msg);
-}
-
-static void
selection_get (GtkWidget *invisible,
GtkSelectionData *selection_data,
guint info,
diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c
index 3a9cf6923e..66b25401a5 100644
--- a/addressbook/gui/widgets/e-minicard-view.c
+++ b/addressbook/gui/widgets/e-minicard-view.c
@@ -144,71 +144,6 @@ e_minicard_view_drag_begin (EAddressbookReflowAdapter *adapter, GdkEvent *event,
}
static void
-card_added_cb (EBook* book, EBookStatus status, const char *id,
- gpointer user_data)
-{
- g_print ("%s: %s(): a card was added\n", __FILE__, __FUNCTION__);
-}
-
-static void
-card_changed_cb (EBook* book, EBookStatus status, gpointer user_data)
-{
- g_print ("%s: %s(): a card was changed with status %d\n", __FILE__, __FUNCTION__, status);
-}
-
-/* Callback for the add_card signal from the contact editor */
-static void
-add_card_cb (EContactEditor *ce, ECard *card, gpointer data)
-{
- EBook *book;
-
- book = E_BOOK (data);
- e_book_add_card (book, card, card_added_cb, NULL);
-}
-
-/* Callback for the commit_card signal from the contact editor */
-static void
-commit_card_cb (EContactEditor *ce, ECard *card, gpointer data)
-{
- EBook *book;
-
- book = E_BOOK (data);
- e_book_commit_card (book, card, card_changed_cb, NULL);
-}
-
-/* Callback used when the contact editor is closed */
-static void
-editor_closed_cb (EContactEditor *ce, gpointer data)
-{
- gtk_object_unref (GTK_OBJECT (ce));
-}
-
-static void
-supported_fields_cb (EBook *book, EBookStatus status, EList *fields, EMinicardView *view)
-{
- ECard *card;
- EContactEditor *ce;
- gboolean editable;
-
- card = e_card_new("");
-
- gtk_object_get (GTK_OBJECT (view->adapter),
- "editable", &editable,
- NULL);
-
- ce = e_contact_editor_new (card, TRUE, fields, !editable);
-
- gtk_signal_connect (GTK_OBJECT (ce), "add_card",
- GTK_SIGNAL_FUNC (add_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "commit_card",
- GTK_SIGNAL_FUNC (commit_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
- GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
-
- gtk_object_sink(GTK_OBJECT(card));
-}
-
-static void
adapter_changed (EMinicardView *view)
{
char *empty_message;
@@ -321,14 +256,14 @@ e_minicard_view_event (GnomeCanvasItem *item, GdkEvent *event)
if (((GdkEventButton *)event)->button == 1)
{
EBook *book;
+ gboolean editable;
gtk_object_get(GTK_OBJECT(view), "book", &book, NULL);
+ gtk_object_get(GTK_OBJECT(view->adapter), "editable", &editable, NULL);
g_assert (E_IS_BOOK (book));
- e_book_get_supported_fields (book,
- (EBookFieldsCallback)supported_fields_cb,
- view);
+ e_addressbook_show_contact_editor (book, NULL, editable);
}
return TRUE;
default:
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index 167e977d12..cf93f52423 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -32,6 +32,7 @@
#include <gal/widgets/e-canvas-utils.h>
#include <gal/widgets/e-canvas.h>
#include "addressbook/backend/ebook/e-book.h"
+#include "e-addressbook-util.h"
#include "e-minicard.h"
#include "e-minicard-label.h"
#include "e-minicard-view.h"
@@ -427,45 +428,11 @@ e_minicard_unrealize (GnomeCanvasItem *item)
}
static void
-card_added_cb (EBook* book, EBookStatus status, const char *id, gpointer user_data)
+card_modified_cb (EBook* book, EBookStatus status, gpointer user_data)
{
- g_print ("%s: %s(): a card was added\n", __FILE__, __FUNCTION__);
-}
-
-static void
-card_changed_cb (EBook* book, EBookStatus status, gpointer user_data)
-{
- g_print ("%s: %s(): a card was changed with status %d\n", __FILE__, __FUNCTION__, status);
-}
-
-/* Callback for the add_card signal from the contact editor */
-static void
-add_card_cb (EContactEditor *ce, ECard *card, gpointer data)
-{
- EBook *book;
-
- book = E_BOOK (data);
- e_book_add_card (book, card, card_added_cb, NULL);
-}
-
-/* Callback for the commit_card signal from the contact editor */
-static void
-commit_card_cb (EContactEditor *ce, ECard *card, gpointer data)
-{
- EBook *book;
-
- book = E_BOOK (data);
- e_book_commit_card (book, card, card_changed_cb, NULL);
-}
-
-/* Callback for the commit_card signal from the contact editor */
-static void
-delete_card_cb (EContactEditor *ce, ECard *card, gpointer data)
-{
- EBook *book;
-
- book = E_BOOK (data);
- e_book_remove_card (book, card, card_changed_cb, NULL);
+ g_print ("%s: %s(): a card was modified\n", __FILE__, __FUNCTION__);
+ if (status != E_BOOK_STATUS_SUCCESS)
+ e_addressbook_error_dialog (_("Error modifying card"), status);
}
/* Callback used when the contact editor is closed */
@@ -477,24 +444,6 @@ editor_closed_cb (EContactEditor *ce, gpointer data)
minicard->editor = NULL;
}
-static void
-supported_fields_cb (EBook *book, EBookStatus status, EList *fields, EMinicard *e_minicard)
-{
- e_minicard->editor = e_contact_editor_new (e_minicard->card, FALSE, fields, !e_minicard->editable);
-
- if (book != NULL) {
- gtk_signal_connect (GTK_OBJECT (e_minicard->editor), "add_card",
- GTK_SIGNAL_FUNC (add_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (e_minicard->editor), "commit_card",
- GTK_SIGNAL_FUNC (commit_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (e_minicard->editor), "delete_card",
- GTK_SIGNAL_FUNC (delete_card_cb), book);
- }
-
- gtk_signal_connect (GTK_OBJECT (e_minicard->editor), "editor_closed",
- GTK_SIGNAL_FUNC (editor_closed_cb), e_minicard);
-}
-
static gboolean
e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
{
@@ -532,7 +481,7 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
/* Add the card in the contact editor to our ebook */
e_book_commit_card (book,
e_minicard->card,
- card_changed_cb,
+ card_modified_cb,
NULL);
} else {
remodel(e_minicard);
@@ -588,9 +537,12 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
}
if (book != NULL) {
- e_book_get_supported_fields (book,
- (EBookFieldsCallback)supported_fields_cb,
- e_minicard);
+ e_minicard->editor = e_addressbook_show_contact_editor (book, e_minicard->card, e_minicard->editable);
+ gtk_object_ref (GTK_OBJECT (e_minicard->editor));
+
+ gtk_signal_connect (GTK_OBJECT (e_minicard->editor), "editor_closed",
+ GTK_SIGNAL_FUNC (editor_closed_cb), e_minicard);
+
}
}
return TRUE;