aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-07-13 00:55:10 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-07-13 04:00:54 +0800
commit0d6061a4ebf34cbe4f640e755372c38bd698ed25 (patch)
tree9ae7c1391e0103d959896b7db9b296bcb61e5f6d /addressbook
parentc4d1d29eaaae6c2668599de0c989f5fe2b189c1e (diff)
downloadgsoc2013-evolution-0d6061a4ebf34cbe4f640e755372c38bd698ed25.tar
gsoc2013-evolution-0d6061a4ebf34cbe4f640e755372c38bd698ed25.tar.gz
gsoc2013-evolution-0d6061a4ebf34cbe4f640e755372c38bd698ed25.tar.bz2
gsoc2013-evolution-0d6061a4ebf34cbe4f640e755372c38bd698ed25.tar.lz
gsoc2013-evolution-0d6061a4ebf34cbe4f640e755372c38bd698ed25.tar.xz
gsoc2013-evolution-0d6061a4ebf34cbe4f640e755372c38bd698ed25.tar.zst
gsoc2013-evolution-0d6061a4ebf34cbe4f640e755372c38bd698ed25.zip
Add a "quit-requested" signal to the shutdown protocol.
The contact and contact-list editors now demonstrate this part of the shutdown protocol. They listen for the "quit-requested" signal from the shell and prompt to save changes, discard changes or cancel. If the user cancels, the editor calls e_shell_cancel_quit() to do just that.
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c40
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.h3
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.c7
-rw-r--r--addressbook/gui/contact-editor/eab-editor.c352
-rw-r--r--addressbook/gui/contact-editor/eab-editor.h100
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.c64
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.h3
7 files changed, 326 insertions, 243 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 69d11b0e3c..d4768ae675 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -2253,7 +2253,7 @@ fill_in_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id)
editor->image_set = TRUE;
}
else {
- gchar *file_name = e_icon_factory_get_icon_filename ("stock_person", 48);
+ gchar *file_name = e_icon_factory_get_icon_filename ("stock_person", GTK_ICON_SIZE_DIALOG);
e_image_chooser_set_from_file (E_IMAGE_CHOOSER (widget), file_name);
editor->image_set = FALSE;
g_free (file_name);
@@ -3518,7 +3518,7 @@ static void
supported_fields_cb (EBook *book, EBookStatus status,
EList *fields, EContactEditor *ce)
{
- if (!g_slist_find ((GSList*)eab_editor_get_all_editors (), ce)) {
+ if (!g_slist_find (eab_editor_get_all_editors (), ce)) {
g_warning ("supported_fields_cb called for book that's still around, but contact editor that's been destroyed.");
return;
}
@@ -3537,7 +3537,7 @@ required_fields_cb (EBook *book, EBookStatus status,
EList *fields, EContactEditor *ce)
{
- if (!g_slist_find ((GSList*)eab_editor_get_all_editors (), ce)) {
+ if (!g_slist_find (eab_editor_get_all_editors (), ce)) {
g_warning ("supported_fields_cb called for book that's still around, but contact editor that's been destroyed.");
return;
}
@@ -3549,31 +3549,22 @@ required_fields_cb (EBook *book, EBookStatus status,
}
-
-static void
-contact_editor_destroy_notify (gpointer data,
- GObject *where_the_object_was)
+EABEditor *
+e_contact_editor_new (EShell *shell,
+ EBook *book,
+ EContact *contact,
+ gboolean is_new_contact,
+ gboolean editable)
{
- eab_editor_remove (EAB_EDITOR (data));
-}
-
-GtkWidget *
-e_contact_editor_new (EBook *book,
- EContact *contact,
- gboolean is_new_contact,
- gboolean editable)
-{
- EContactEditor *ce;
+ EABEditor *editor;
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
g_return_val_if_fail (E_IS_BOOK (book), NULL);
g_return_val_if_fail (E_IS_CONTACT (contact), NULL);
- ce = g_object_new (E_TYPE_CONTACT_EDITOR, NULL);
+ editor = g_object_new (E_TYPE_CONTACT_EDITOR, "shell", shell, NULL);
- eab_editor_add (EAB_EDITOR (ce));
- g_object_weak_ref (G_OBJECT (ce), contact_editor_destroy_notify, ce);
-
- g_object_set (ce,
+ g_object_set (editor,
"source_book", book,
"contact", contact,
"is_new_contact", is_new_contact,
@@ -3581,9 +3572,10 @@ e_contact_editor_new (EBook *book,
NULL);
if (book)
- e_book_async_get_supported_fields (book, (EBookEListCallback)supported_fields_cb, ce);
+ e_book_async_get_supported_fields (
+ book, (EBookEListCallback)supported_fields_cb, editor);
- return GTK_WIDGET (ce);
+ return editor;
}
static void
diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h
index 1000cdc544..6228dc3499 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.h
+++ b/addressbook/gui/contact-editor/e-contact-editor.h
@@ -108,7 +108,8 @@ struct _EContactEditorClass
};
GType e_contact_editor_get_type (void);
-GtkWidget *e_contact_editor_new (EBook *book,
+EABEditor *e_contact_editor_new (EShell *shell,
+ EBook *book,
EContact *contact,
gboolean is_new_contact,
gboolean editable);
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c
index cd81d28690..df3eb6ec58 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.c
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.c
@@ -194,7 +194,12 @@ ce_have_book (EBook *book, EBookStatus status, gpointer closure)
g_warning ("Couldn't open local address book.");
quick_add_unref (qa);
} else {
- GtkWidget *contact_editor = e_contact_editor_new (book, qa->contact, TRUE, TRUE /* XXX */);
+ EShell *shell;
+ EABEditor *contact_editor;
+
+ shell = e_shell_get_default ();
+ contact_editor = e_contact_editor_new (
+ shell, book, qa->contact, TRUE, TRUE /* XXX */);
/* mark it as changed so the Save buttons are enabled when we bring up the dialog. */
g_object_set (contact_editor,
diff --git a/addressbook/gui/contact-editor/eab-editor.c b/addressbook/gui/contact-editor/eab-editor.c
index b5a4683540..554db9aa7b 100644
--- a/addressbook/gui/contact-editor/eab-editor.c
+++ b/addressbook/gui/contact-editor/eab-editor.c
@@ -31,13 +31,19 @@
#include "e-util/e-util.h"
#include "addressbook/gui/widgets/eab-gui-util.h"
-static void eab_editor_default_show (EABEditor *editor);
-static void eab_editor_default_raise (EABEditor *editor);
-static void eab_editor_default_close (EABEditor *editor);
-static void eab_editor_class_init (EABEditorClass *klass);
-static void eab_editor_init (EABEditor *editor);
+#define EAB_EDITOR_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), EAB_TYPE_EDITOR, EABEditorPrivate))
+
+struct _EABEditorPrivate {
+ EShell *shell;
+};
+
+enum {
+ PROP_0,
+ PROP_SHELL
+};
-/* Signal IDs */
enum {
CONTACT_ADDED,
CONTACT_MODIFIED,
@@ -46,97 +52,125 @@ enum {
LAST_SIGNAL
};
-static GSList *all_editors = NULL;
-
-static GtkObjectClass *parent_class = NULL;
-
-static guint editor_signals[LAST_SIGNAL];
+static GSList *all_editors;
+static gpointer parent_class;
+static guint signals[LAST_SIGNAL];
-GType
-eab_editor_get_type (void)
+static void
+eab_editor_quit_requested_cb (EABEditor *editor,
+ EShell *shell)
{
- static GType editor_type = 0;
-
- if (!editor_type) {
- static const GTypeInfo editor_info = {
- sizeof (EABEditorClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) eab_editor_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (EABEditor),
- 0, /* n_preallocs */
- (GInstanceInitFunc) eab_editor_init,
- };
+ GtkWindow *window;
- editor_type = g_type_register_static (G_TYPE_OBJECT, "EABEditor", &editor_info, 0);
- }
+ window = eab_editor_get_window (editor);
- return editor_type;
+ eab_editor_raise (editor);
+ if (!eab_editor_prompt_to_save_changes (editor, window))
+ e_shell_cancel_quit (shell);
}
static void
-eab_editor_default_show (EABEditor *editor)
+eab_editor_set_shell (EABEditor *editor,
+ EShell *shell)
{
- g_warning ("abstract eab_editor_show called");
+ g_return_if_fail (editor->priv->shell == NULL);
+ g_return_if_fail (E_IS_SHELL (shell));
+
+ editor->priv->shell = g_object_ref (shell);
+
+ g_signal_connect_swapped (
+ shell, "quit-requested",
+ G_CALLBACK (eab_editor_quit_requested_cb), editor);
}
static void
-eab_editor_default_close (EABEditor *editor)
+eab_editor_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- g_warning ("abstract eab_editor_close called");
+ switch (property_id) {
+ case PROP_SHELL:
+ eab_editor_set_shell (
+ EAB_EDITOR (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
-eab_editor_default_raise (EABEditor *editor)
+eab_editor_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- g_warning ("abstract eab_editor_raise called");
+ switch (property_id) {
+ case PROP_SHELL:
+ g_value_set_object (
+ value, eab_editor_get_shell (
+ EAB_EDITOR (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
-eab_editor_default_save_contact (EABEditor *editor, gboolean should_close)
+eab_editor_dispose (GObject *object)
{
- g_warning ("abstract eab_editor_save_contact called");
-}
+ EABEditorPrivate *priv;
-static gboolean
-eab_editor_default_is_valid (EABEditor *editor)
-{
- g_warning ("abstract eab_editor_is_valid called");
- return FALSE;
-}
+ priv = EAB_EDITOR_GET_PRIVATE (object);
-static gboolean
-eab_editor_default_is_changed (EABEditor *editor)
-{
- g_warning ("abstract eab_editor_is_changed called");
- return FALSE;
-}
+ if (priv->shell != NULL) {
+ g_signal_handlers_disconnect_matched (
+ priv->shell, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, object);
+ g_object_unref (priv->shell);
+ priv->shell = NULL;
+ }
-static GtkWindow*
-eab_editor_default_get_window (EABEditor *editor)
-{
- g_warning ("abstract eab_editor_get_window called");
- return NULL;
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-eab_editor_class_init (EABEditorClass *klass)
+eab_editor_finalize (GObject *object)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ all_editors = g_slist_remove (all_editors, object);
- parent_class = g_type_class_ref (G_TYPE_OBJECT);
-
- klass->show = eab_editor_default_show;
- klass->close = eab_editor_default_close;
- klass->raise = eab_editor_default_raise;
- klass->save_contact = eab_editor_default_save_contact;
- klass->is_valid = eab_editor_default_is_valid;
- klass->is_changed = eab_editor_default_is_changed;
- klass->get_window = eab_editor_default_get_window;
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
- editor_signals[CONTACT_ADDED] =
+static void
+eab_editor_class_init (EABEditorClass *class)
+{
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EABEditorPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = eab_editor_set_property;
+ object_class->get_property = eab_editor_get_property;
+ object_class->dispose = eab_editor_dispose;
+ object_class->finalize = eab_editor_finalize;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL,
+ g_param_spec_object (
+ "shell",
+ _("Shell"),
+ _("The EShell singleton"),
+ E_TYPE_SHELL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ signals[CONTACT_ADDED] =
g_signal_new ("contact_added",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
@@ -146,7 +180,7 @@ eab_editor_class_init (EABEditorClass *klass)
G_TYPE_NONE, 2,
G_TYPE_INT, G_TYPE_OBJECT);
- editor_signals[CONTACT_MODIFIED] =
+ signals[CONTACT_MODIFIED] =
g_signal_new ("contact_modified",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
@@ -156,7 +190,7 @@ eab_editor_class_init (EABEditorClass *klass)
G_TYPE_NONE, 2,
G_TYPE_INT, G_TYPE_OBJECT);
- editor_signals[CONTACT_DELETED] =
+ signals[CONTACT_DELETED] =
g_signal_new ("contact_deleted",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
@@ -166,7 +200,7 @@ eab_editor_class_init (EABEditorClass *klass)
G_TYPE_NONE, 2,
G_TYPE_INT, G_TYPE_OBJECT);
- editor_signals[EDITOR_CLOSED] =
+ signals[EDITOR_CLOSED] =
g_signal_new ("editor_closed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
@@ -179,78 +213,143 @@ eab_editor_class_init (EABEditorClass *klass)
static void
eab_editor_init (EABEditor *editor)
{
+ editor->priv = EAB_EDITOR_GET_PRIVATE (editor);
+
+ all_editors = g_slist_prepend (all_editors, editor);
+}
+
+GType
+eab_editor_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (EABEditorClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) eab_editor_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EABEditor),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) eab_editor_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ G_TYPE_OBJECT, "EABEditor", &type_info,
+ G_TYPE_FLAG_ABSTRACT);
+ }
+
+ return type;
+}
+
+EShell *
+eab_editor_get_shell (EABEditor *editor)
+{
+ g_return_val_if_fail (EAB_IS_EDITOR (editor), NULL);
+
+ return E_SHELL (editor->priv->shell);
}
-
+GSList *
+eab_editor_get_all_editors (void)
+{
+ return all_editors;
+}
void
eab_editor_show (EABEditor *editor)
{
+ EABEditorClass *class;
+
g_return_if_fail (EAB_IS_EDITOR (editor));
- if (EAB_EDITOR_GET_CLASS(editor)->show)
- EAB_EDITOR_GET_CLASS(editor)->show (editor);
+ class = EAB_EDITOR_GET_CLASS (editor);
+ g_return_if_fail (class->show != NULL);
+
+ class->show (editor);
}
void
eab_editor_close (EABEditor *editor)
{
+ EABEditorClass *class;
+
g_return_if_fail (EAB_IS_EDITOR (editor));
- if (EAB_EDITOR_GET_CLASS(editor)->close)
- EAB_EDITOR_GET_CLASS(editor)->close (editor);
+ class = EAB_EDITOR_GET_CLASS (editor);
+ g_return_if_fail (class->close != NULL);
+
+ class->close (editor);
}
void
eab_editor_raise (EABEditor *editor)
{
+ EABEditorClass *class;
+
g_return_if_fail (EAB_IS_EDITOR (editor));
- if (EAB_EDITOR_GET_CLASS(editor)->raise)
- EAB_EDITOR_GET_CLASS(editor)->raise (editor);
+ class = EAB_EDITOR_GET_CLASS (editor);
+ g_return_if_fail (class->raise != NULL);
+
+ class->raise (editor);
}
void
eab_editor_save_contact (EABEditor *editor, gboolean should_close)
{
+ EABEditorClass *class;
+
g_return_if_fail (EAB_IS_EDITOR (editor));
- if (EAB_EDITOR_GET_CLASS(editor)->save_contact)
- EAB_EDITOR_GET_CLASS(editor)->save_contact (editor, should_close);
+ class = EAB_EDITOR_GET_CLASS (editor);
+ g_return_if_fail (class->save_contact != NULL);
+
+ class->save_contact (editor, should_close);
}
gboolean
eab_editor_is_changed (EABEditor *editor)
{
+ EABEditorClass *class;
+
g_return_val_if_fail (EAB_IS_EDITOR (editor), FALSE);
- if (EAB_EDITOR_GET_CLASS(editor)->is_changed)
- return EAB_EDITOR_GET_CLASS(editor)->is_changed (editor);
- else
- return FALSE;
+ class = EAB_EDITOR_GET_CLASS (editor);
+ g_return_val_if_fail (class->is_changed != NULL, FALSE);
+
+ return class->is_changed (editor);
}
gboolean
eab_editor_is_valid (EABEditor *editor)
{
+ EABEditorClass *class;
+
g_return_val_if_fail (EAB_IS_EDITOR (editor), FALSE);
- if (EAB_EDITOR_GET_CLASS(editor)->is_valid)
- return EAB_EDITOR_GET_CLASS(editor)->is_valid (editor);
- else
- return FALSE;
+ class = EAB_EDITOR_GET_CLASS (editor);
+ g_return_val_if_fail (class->is_valid != NULL, FALSE);
+
+ return class->is_valid (editor);
}
GtkWindow*
eab_editor_get_window (EABEditor *editor)
{
+ EABEditorClass *class;
+
g_return_val_if_fail (EAB_IS_EDITOR (editor), NULL);
- if (EAB_EDITOR_GET_CLASS(editor)->get_window)
- return EAB_EDITOR_GET_CLASS(editor)->get_window (editor);
- else
- return NULL;
+ class = EAB_EDITOR_GET_CLASS (editor);
+ g_return_val_if_fail (class->get_window != NULL, NULL);
+
+ return class->get_window (editor);
}
+
/* This function prompts for saving if editor conents are in changed state and
save or discards or cancels(just returns with out doing anything) according to user input.
Editor gets destoryed in case of save and discard case.
@@ -280,64 +379,37 @@ eab_editor_prompt_to_save_changes (EABEditor *editor, GtkWindow *window)
}
}
-gboolean
-eab_editor_request_close_all (void)
-{
- GSList *p;
- GSList *pnext;
- gboolean retval;
-
- retval = TRUE;
- for (p = all_editors; p != NULL; p = pnext) {
- EABEditor *editor = EAB_EDITOR (p->data);
- GtkWindow *window = eab_editor_get_window (editor);
-
- pnext = p->next;
-
- eab_editor_raise (editor);
- if (! eab_editor_prompt_to_save_changes (editor, window)) {
- retval = FALSE;
- break;
- }
- }
-
- return retval;
-}
-
-const GSList*
-eab_editor_get_all_editors (void)
-{
- return all_editors;
-}
-
void
-eab_editor_contact_added (EABEditor *editor, EBookStatus status, EContact *contact)
+eab_editor_contact_added (EABEditor *editor,
+ EBookStatus status,
+ EContact *contact)
{
g_return_if_fail (EAB_IS_EDITOR (editor));
g_return_if_fail (E_IS_CONTACT (contact));
- g_signal_emit (editor, editor_signals[CONTACT_ADDED], 0,
- status, contact);
+ g_signal_emit (editor, signals[CONTACT_ADDED], 0, status, contact);
}
void
-eab_editor_contact_modified (EABEditor *editor, EBookStatus status, EContact *contact)
+eab_editor_contact_modified (EABEditor *editor,
+ EBookStatus status,
+ EContact *contact)
{
g_return_if_fail (EAB_IS_EDITOR (editor));
g_return_if_fail (E_IS_CONTACT (contact));
- g_signal_emit (editor, editor_signals[CONTACT_MODIFIED], 0,
- status, contact);
+ g_signal_emit (editor, signals[CONTACT_MODIFIED], 0, status, contact);
}
void
-eab_editor_contact_deleted (EABEditor *editor, EBookStatus status, EContact *contact)
+eab_editor_contact_deleted (EABEditor *editor,
+ EBookStatus status,
+ EContact *contact)
{
g_return_if_fail (EAB_IS_EDITOR (editor));
g_return_if_fail (E_IS_CONTACT (contact));
- g_signal_emit (editor, editor_signals[CONTACT_DELETED], 0,
- status, contact);
+ g_signal_emit (editor, signals[CONTACT_DELETED], 0, status, contact);
}
void
@@ -345,21 +417,5 @@ eab_editor_closed (EABEditor *editor)
{
g_return_if_fail (EAB_IS_EDITOR (editor));
- g_signal_emit (editor, editor_signals[EDITOR_CLOSED], 0);
-}
-
-void
-eab_editor_add (EABEditor *editor)
-{
- g_return_if_fail (EAB_IS_EDITOR (editor));
-
- all_editors = g_slist_prepend (all_editors, editor);
-}
-
-void
-eab_editor_remove (EABEditor *editor)
-{
- g_return_if_fail (EAB_IS_EDITOR (editor));
-
- all_editors = g_slist_remove (all_editors, editor);
+ g_signal_emit (editor, signals[EDITOR_CLOSED], 0);
}
diff --git a/addressbook/gui/contact-editor/eab-editor.h b/addressbook/gui/contact-editor/eab-editor.h
index 1b3de4b28a..f3803e7341 100644
--- a/addressbook/gui/contact-editor/eab-editor.h
+++ b/addressbook/gui/contact-editor/eab-editor.h
@@ -24,42 +24,42 @@
#ifndef __EAB_EDITOR_H__
#define __EAB_EDITOR_H__
-#include <glade/glade.h>
-
+#include <gtk/gtk.h>
#include <libebook/e-book.h>
#include <libebook/e-contact.h>
-
-#include <gtk/gtk.h>
+#include <shell/e-shell.h>
+
+/* Standard GObject macros */
+#define EAB_TYPE_EDITOR \
+ (eab_editor_get_type ())
+#define EAB_EDITOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), EAB_TYPE_EDITOR, EABEditor))
+#define EAB_EDITOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), EAB_TYPE_EDITOR, EABEditorClass))
+#define EAB_IS_EDITOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), EAB_TYPE_EDITOR))
+#define EAB_IS_EDITOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), EAB_TYPE_EDITOR))
+#define EAB_EDITOR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), EAB_EDITOR_TYPE, EABEditorClass))
G_BEGIN_DECLS
-/* EABEditor - A dialog displaying information about a contact.
- *
- * The following arguments are available:
- *
- * name type read/write description
- * --------------------------------------------------------------------------------
- * card ECard * RW The card currently being edited
- */
-
-#define EAB_TYPE_EDITOR (eab_editor_get_type ())
-#define EAB_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EAB_TYPE_EDITOR, EABEditor))
-#define EAB_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EAB_TYPE_EDITOR, EABEditorClass))
-#define EAB_IS_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EAB_TYPE_EDITOR))
-#define EAB_IS_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EAB_TYPE_EDITOR))
-#define EAB_EDITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EAB_EDITOR_TYPE, EABEditorClass))
-
+typedef struct _EABEditor EABEditor;
+typedef struct _EABEditorClass EABEditorClass;
+typedef struct _EABEditorPrivate EABEditorPrivate;
-typedef struct _EABEditor EABEditor;
-typedef struct _EABEditorClass EABEditorClass;
-
-struct _EABEditor
-{
+struct _EABEditor {
GObject parent;
+ EABEditorPrivate *priv;
};
-struct _EABEditorClass
-{
+struct _EABEditorClass {
GObjectClass parent_class;
/* virtual functions */
@@ -78,31 +78,35 @@ struct _EABEditorClass
void (* editor_closed) (EABEditor *editor);
};
-GType eab_editor_get_type (void);
+GType eab_editor_get_type (void);
+EShell * eab_editor_get_shell (EABEditor *editor);
+GSList * eab_editor_get_all_editors (void);
/* virtual functions */
-void eab_editor_show (EABEditor *editor);
-void eab_editor_close (EABEditor *editor);
-void eab_editor_raise (EABEditor *editor);
-void eab_editor_save_contact (EABEditor *editor, gboolean should_close);
-gboolean eab_editor_is_valid (EABEditor *editor);
-gboolean eab_editor_is_changed (EABEditor *editor);
-GtkWindow* eab_editor_get_window (EABEditor *editor);
-
-gboolean eab_editor_prompt_to_save_changes (EABEditor *editor, GtkWindow *window);
+void eab_editor_show (EABEditor *editor);
+void eab_editor_close (EABEditor *editor);
+void eab_editor_raise (EABEditor *editor);
+void eab_editor_save_contact (EABEditor *editor,
+ gboolean should_close);
+gboolean eab_editor_is_valid (EABEditor *editor);
+gboolean eab_editor_is_changed (EABEditor *editor);
+GtkWindow * eab_editor_get_window (EABEditor *editor);
+
+gboolean eab_editor_prompt_to_save_changes
+ (EABEditor *editor,
+ GtkWindow *window);
/* these four generate EABEditor signals */
-void eab_editor_contact_added (EABEditor *editor, EBookStatus status, EContact *contact);
-void eab_editor_contact_modified (EABEditor *editor, EBookStatus status, EContact *contact);
-void eab_editor_contact_deleted (EABEditor *editor, EBookStatus status, EContact *contact);
-void eab_editor_closed (EABEditor *editor);
-
-/* these maintain the global list of editors so we can prompt the user
- if there are unsaved changes when they exit. */
-void eab_editor_add (EABEditor *editor);
-void eab_editor_remove (EABEditor *editor);
-gboolean eab_editor_request_close_all (void);
-const GSList* eab_editor_get_all_editors (void);
+void eab_editor_contact_added (EABEditor *editor,
+ EBookStatus status,
+ EContact *contact);
+void eab_editor_contact_modified (EABEditor *editor,
+ EBookStatus status,
+ EContact *contact);
+void eab_editor_contact_deleted (EABEditor *editor,
+ EBookStatus status,
+ EContact *contact);
+void eab_editor_closed (EABEditor *editor);
G_END_DECLS
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 cc64cd5af3..77d91357c5 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -881,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,
@@ -901,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 (
@@ -1319,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));
-}
-
-GtkWidget *
-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,
@@ -1347,7 +1371,7 @@ e_contact_list_editor_new (EBook *book,
"editable", editable,
NULL);
- return GTK_WIDGET (editor);
+ return editor;
}
EBook *
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.h b/addressbook/gui/contact-list-editor/e-contact-list-editor.h
index 5b67fe0126..8e258597aa 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.h
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.h
@@ -68,7 +68,8 @@ struct _EContactListEditorClass
};
GType e_contact_list_editor_get_type (void);
-GtkWidget * e_contact_list_editor_new (EBook *book,
+EABEditor * e_contact_list_editor_new (EShell *shell,
+ EBook *book,
EContact *list_contact,
gboolean is_new_list,
gboolean editable);