aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/contact-list-editor/e-contact-list-editor.c
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui/contact-list-editor/e-contact-list-editor.c')
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.c280
1 files changed, 177 insertions, 103 deletions
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
index e62958a72e..77d91357c5 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -34,10 +34,8 @@
#include <libedataserverui/e-source-combo-box.h>
-#include "shell/evolution-shell-component-utils.h"
-
-#include "addressbook/gui/component/addressbook.h"
#include "addressbook/gui/widgets/eab-gui-util.h"
+#include "addressbook/util/addressbook.h"
#include "addressbook/util/eab-book-util.h"
#include "eab-editor.h"
@@ -883,6 +881,36 @@ contact_list_editor_create_name_selector (gchar *name,
gint int1,
gint int2);
+static gpointer
+contact_editor_fudge_new (EBook *book,
+ EContact *contact,
+ gboolean is_new,
+ gboolean editable)
+{
+ EShell *shell = e_shell_get_default ();
+
+ /* XXX Putting this function signature in libedataserverui
+ * was a terrible idea. Now we're stuck with it. */
+
+ return e_contact_editor_new (
+ shell, book, contact, is_new, editable);
+}
+
+static gpointer
+contact_list_editor_fudge_new (EBook *book,
+ EContact *contact,
+ gboolean is_new,
+ gboolean editable)
+{
+ EShell *shell = e_shell_get_default ();
+
+ /* XXX Putting this function signature in libedataserverui
+ * was a terrible idea. Now we're stuck with it. */
+
+ return e_contact_list_editor_new (
+ shell, book, contact, is_new, editable);
+}
+
GtkWidget *
contact_list_editor_create_name_selector (gchar *name,
gchar *string1,
@@ -903,9 +931,9 @@ contact_list_editor_create_name_selector (gchar *name,
name_selector, "Members");
e_name_selector_entry_set_contact_editor_func (
- name_selector_entry, e_contact_editor_new);
+ name_selector_entry, contact_editor_fudge_new);
e_name_selector_entry_set_contact_list_editor_func (
- name_selector_entry, e_contact_list_editor_new);
+ name_selector_entry, contact_list_editor_fudge_new);
gtk_widget_show (GTK_WIDGET (name_selector_entry));
g_signal_connect (
@@ -924,87 +952,6 @@ contact_list_editor_create_name_selector (gchar *name,
return GTK_WIDGET (name_selector_entry);
}
-/**************************** EABEditor Callbacks ****************************/
-
-static void
-contact_list_editor_show (EABEditor *editor)
-{
- gtk_widget_show (WIDGET (DIALOG));
-}
-
-static void
-contact_list_editor_close (EABEditor *editor)
-{
- gtk_widget_destroy (WIDGET (DIALOG));
- eab_editor_closed (editor);
-}
-
-static void
-contact_list_editor_raise (EABEditor *editor)
-{
- gdk_window_raise (WIDGET (DIALOG)->window);
-}
-
-static void
-contact_list_editor_save_contact (EABEditor *eab_editor,
- gboolean should_close)
-{
- EContactListEditor *editor = E_CONTACT_LIST_EDITOR (eab_editor);
- EContactListEditorPrivate *priv = editor->priv;
- EditorCloseStruct *ecs;
- EContact *contact;
-
- contact = e_contact_list_editor_get_contact (editor);
-
- if (priv->book == NULL)
- return;
-
- ecs = g_new (EditorCloseStruct, 1);
- ecs->editor = g_object_ref (editor);
- ecs->should_close = should_close;
-
- gtk_widget_set_sensitive (WIDGET (DIALOG), FALSE);
- priv->in_async_call = TRUE;
-
- if (priv->is_new_list)
- eab_merging_book_add_contact (
- priv->book, contact, (EBookIdCallback)
- contact_list_editor_list_added_cb, ecs);
- else
- eab_merging_book_commit_contact (
- priv->book, contact, (EBookCallback)
- contact_list_editor_list_modified_cb, ecs);
-
- priv->changed = FALSE;
-}
-
-static gboolean
-contact_list_editor_is_valid (EABEditor *editor)
-{
- GtkEditable *editable;
- gboolean valid;
- gchar *chars;
-
- editable = GTK_EDITABLE (WIDGET (LIST_NAME_ENTRY));
- chars = gtk_editable_get_chars (editable, 0, -1);
- valid = (chars != NULL && *chars != '\0');
- g_free (chars);
-
- return valid;
-}
-
-static gboolean
-contact_list_editor_is_changed (EABEditor *editor)
-{
- return E_CONTACT_LIST_EDITOR_GET_PRIVATE (editor)->changed;
-}
-
-static GtkWindow*
-contact_list_editor_get_window (EABEditor *editor)
-{
- return GTK_WINDOW (WIDGET (DIALOG));
-}
-
/***************************** GObject Callbacks *****************************/
static GObject *
@@ -1114,6 +1061,135 @@ contact_list_editor_dispose (GObject *object)
G_OBJECT_CLASS (parent_class)->dispose (object);
}
+/**************************** EABEditor Callbacks ****************************/
+
+static void
+contact_list_editor_show (EABEditor *editor)
+{
+ gtk_widget_show (WIDGET (DIALOG));
+}
+
+static void
+contact_list_editor_close (EABEditor *editor)
+{
+ gtk_widget_destroy (WIDGET (DIALOG));
+ eab_editor_closed (editor);
+}
+
+static void
+contact_list_editor_raise (EABEditor *editor)
+{
+ gdk_window_raise (WIDGET (DIALOG)->window);
+}
+
+static void
+contact_list_editor_save_contact (EABEditor *eab_editor,
+ gboolean should_close)
+{
+ EContactListEditor *editor = E_CONTACT_LIST_EDITOR (eab_editor);
+ EContactListEditorPrivate *priv = editor->priv;
+ EditorCloseStruct *ecs;
+ EContact *contact;
+
+ contact = e_contact_list_editor_get_contact (editor);
+
+ if (priv->book == NULL)
+ return;
+
+ ecs = g_new (EditorCloseStruct, 1);
+ ecs->editor = g_object_ref (editor);
+ ecs->should_close = should_close;
+
+ gtk_widget_set_sensitive (WIDGET (DIALOG), FALSE);
+ priv->in_async_call = TRUE;
+
+ if (priv->is_new_list)
+ eab_merging_book_add_contact (
+ priv->book, contact, (EBookIdCallback)
+ contact_list_editor_list_added_cb, ecs);
+ else
+ eab_merging_book_commit_contact (
+ priv->book, contact, (EBookCallback)
+ contact_list_editor_list_modified_cb, ecs);
+
+ priv->changed = FALSE;
+}
+
+static gboolean
+contact_list_editor_is_valid (EABEditor *editor)
+{
+ GtkEditable *editable;
+ gboolean valid;
+ gchar *chars;
+
+ editable = GTK_EDITABLE (WIDGET (LIST_NAME_ENTRY));
+ chars = gtk_editable_get_chars (editable, 0, -1);
+ valid = (chars != NULL && *chars != '\0');
+ g_free (chars);
+
+ return valid;
+}
+
+static gboolean
+contact_list_editor_is_changed (EABEditor *editor)
+{
+ return E_CONTACT_LIST_EDITOR_GET_PRIVATE (editor)->changed;
+}
+
+static GtkWindow *
+contact_list_editor_get_window (EABEditor *editor)
+{
+ return GTK_WINDOW (WIDGET (DIALOG));
+}
+
+static void
+contact_list_editor_contact_added (EABEditor *editor,
+ EBookStatus status,
+ EContact *contact)
+{
+ if (status == E_BOOK_ERROR_OK)
+ return;
+
+ if (status == E_BOOK_ERROR_CANCELLED)
+ return;
+
+ eab_error_dialog (_("Error adding list"), status);
+}
+
+static void
+contact_list_editor_contact_modified (EABEditor *editor,
+ EBookStatus status,
+ EContact *contact)
+{
+ if (status == E_BOOK_ERROR_OK)
+ return;
+
+ if (status == E_BOOK_ERROR_CANCELLED)
+ return;
+
+ eab_error_dialog (_("Error modifying list"), status);
+}
+
+static void
+contact_list_editor_contact_deleted (EABEditor *editor,
+ EBookStatus status,
+ EContact *contact)
+{
+ if (status == E_BOOK_ERROR_OK)
+ return;
+
+ if (status == E_BOOK_ERROR_CANCELLED)
+ return;
+
+ eab_error_dialog (_("Error removing list"), status);
+}
+
+static void
+contact_list_editor_closed (EABEditor *editor)
+{
+ g_object_unref (editor);
+}
+
/****************************** GType Callbacks ******************************/
static void
@@ -1139,6 +1215,10 @@ contact_list_editor_class_init (EContactListEditorClass *class)
editor_class->is_valid = contact_list_editor_is_valid;
editor_class->is_changed = contact_list_editor_is_changed;
editor_class->get_window = contact_list_editor_get_window;
+ editor_class->contact_added = contact_list_editor_contact_added;
+ editor_class->contact_modified = contact_list_editor_contact_modified;
+ editor_class->contact_deleted = contact_list_editor_contact_deleted;
+ editor_class->editor_closed = contact_list_editor_closed;
g_object_class_install_property (
object_class,
@@ -1269,26 +1349,20 @@ e_contact_list_editor_get_type (void)
return type;
}
-static void
-contact_list_editor_destroy_notify (gpointer data,
- GObject *where_the_object_was)
-{
- eab_editor_remove (EAB_EDITOR (data));
-}
-
-EContactListEditor *
-e_contact_list_editor_new (EBook *book,
- EContact *list_contact,
- gboolean is_new_list,
- gboolean editable)
+EABEditor *
+e_contact_list_editor_new (EShell *shell,
+ EBook *book,
+ EContact *list_contact,
+ gboolean is_new_list,
+ gboolean editable)
{
- EContactListEditor *editor;
+ EABEditor *editor;
- editor = g_object_new (E_TYPE_CONTACT_LIST_EDITOR, NULL);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
- eab_editor_add (EAB_EDITOR (editor));
- g_object_weak_ref (
- G_OBJECT (editor), contact_list_editor_destroy_notify, editor);
+ editor = g_object_new (
+ E_TYPE_CONTACT_LIST_EDITOR,
+ "shell", shell, NULL);
g_object_set (editor,
"book", book,