aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/contact-editor
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui/contact-editor')
-rw-r--r--addressbook/gui/contact-editor/Makefile.am11
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c99
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.h15
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.c31
-rw-r--r--addressbook/gui/contact-editor/eab-editor.c398
-rw-r--r--addressbook/gui/contact-editor/eab-editor.h101
6 files changed, 362 insertions, 293 deletions
diff --git a/addressbook/gui/contact-editor/Makefile.am b/addressbook/gui/contact-editor/Makefile.am
index 36ba4c90a8..29ddb6ee9c 100644
--- a/addressbook/gui/contact-editor/Makefile.am
+++ b/addressbook/gui/contact-editor/Makefile.am
@@ -29,10 +29,13 @@ libecontacteditor_la_SOURCES = \
libecontacteditor_la_LDFLAGS = $(NO_UNDEFINED)
-libecontacteditor_la_LIBADD = \
- $(WIN32_BOOTSTRAP_LIBS) \
- $(top_builddir)/widgets/misc/libemiscwidgets.la \
- $(top_builddir)/e-util/libeutil.la \
+libecontacteditor_la_LIBADD = \
+ $(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/widgets/misc/libemiscwidgets.la \
+ $(top_builddir)/addressbook/util/libeabutil.la \
+ $(top_builddir)/addressbook/gui/widgets/libeabwidgets.la \
+ $(top_builddir)/addressbook/gui/merging/libeabbookmerging.la \
+ $(top_builddir)/addressbook/printing/libecontactprint.la \
$(EVOLUTION_ADDRESSBOOK_LIBS)
glade_DATA = \
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index fc4c8ff8df..007436e7da 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -33,7 +33,6 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libedataserverui/e-categories-dialog.h>
-#include <misc/e-gui-utils.h>
#include <libebook/e-address-western.h>
#include <libedataserverui/e-category-completion.h>
@@ -41,7 +40,7 @@
#include <camel/camel.h>
-#include "addressbook/gui/component/addressbook.h"
+#include "addressbook/util/addressbook.h"
#include "addressbook/printing/e-contact-print.h"
#include "addressbook/gui/widgets/eab-gui-util.h"
#include "e-util/e-util.h"
@@ -49,9 +48,9 @@
#include "misc/e-dateedit.h"
#include "misc/e-image-chooser.h"
#include "misc/e-url-entry.h"
-#include "shell/evolution-shell-component-utils.h"
#include "e-util/e-icon-factory.h"
#include "e-util/e-util-private.h"
+#include "shell/e-shell.h"
#include "eab-contact-merging.h"
@@ -198,6 +197,54 @@ static const gint email_default [] = { 0, 1, 2, 2 };
#define STRING_IS_EMPTY(x) (!(x) || !(*(x)))
#define STRING_MAKE_NON_NULL(x) ((x) ? (x) : "")
+static void
+e_contact_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 contact"), status);
+}
+
+static void
+e_contact_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 contact"), status);
+}
+
+static void
+e_contact_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 contact"), status);
+}
+
+static void
+e_contact_editor_closed (EABEditor *editor)
+{
+ g_object_unref (editor);
+}
+
GType
e_contact_editor_get_type (void)
{
@@ -241,6 +288,10 @@ e_contact_editor_class_init (EContactEditorClass *klass)
editor_class->save_contact = e_contact_editor_save_contact;
editor_class->is_changed = e_contact_editor_is_changed;
editor_class->get_window = e_contact_editor_get_window;
+ editor_class->contact_added = e_contact_editor_contact_added;
+ editor_class->contact_modified = e_contact_editor_contact_modified;
+ editor_class->contact_deleted = e_contact_editor_contact_deleted;
+ editor_class->editor_closed = e_contact_editor_closed;
g_object_class_install_property (object_class, PROP_SOURCE_BOOK,
g_param_spec_object ("source_book",
@@ -3322,6 +3373,7 @@ static void
e_contact_editor_init (EContactEditor *e_contact_editor)
{
GladeXML *gui;
+ EShell *shell;
GtkWidget *widget, *label;
GtkEntryCompletion *completion;
gchar *gladefile;
@@ -3399,6 +3451,10 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
/* show window */
gtk_widget_show (e_contact_editor->app);
+
+ /* FIXME Shell should be passed in. */
+ shell = e_shell_get_default ();
+ e_shell_watch_window (shell, GTK_WINDOW (e_contact_editor->app));
}
static void
@@ -3455,7 +3511,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;
}
@@ -3474,7 +3530,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;
}
@@ -3485,30 +3541,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));
-}
-
-EContactEditor *
-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,
@@ -3516,9 +3564,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 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 cdd9c2e8da..9a83831eff 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.h
+++ b/addressbook/gui/contact-editor/e-contact-editor.h
@@ -23,7 +23,6 @@
#ifndef __E_CONTACT_EDITOR_H__
#define __E_CONTACT_EDITOR_H__
-#include <bonobo/bonobo-ui-component.h>
#include <glade/glade.h>
#include "addressbook/gui/contact-editor/eab-editor.h"
@@ -62,9 +61,6 @@ struct _EContactEditor
EBook *target_book;
EContact *contact;
- /* UI handler */
- BonoboUIComponent *uic;
-
GladeXML *gui;
GtkWidget *app;
@@ -110,11 +106,12 @@ struct _EContactEditorClass
EABEditorClass parent_class;
};
-EContactEditor *e_contact_editor_new (EBook *book,
- EContact *contact,
- gboolean is_new_contact,
- gboolean editable);
-GType e_contact_editor_get_type (void);
+GType e_contact_editor_get_type (void);
+EABEditor *e_contact_editor_new (EShell *shell,
+ EBook *book,
+ EContact *contact,
+ gboolean is_new_contact,
+ gboolean editable);
G_END_DECLS
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c
index 0f6552ba18..bb40e9a79d 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.c
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.c
@@ -28,7 +28,7 @@
#include <libebook/e-book.h>
#include <libebook/e-contact.h>
#include <libedataserverui/e-source-combo-box.h>
-#include <addressbook/gui/component/addressbook.h>
+#include <addressbook/util/addressbook.h>
#include <addressbook/util/eab-book-util.h>
#include "e-contact-editor.h"
#include "e-contact-quick-add.h"
@@ -49,7 +49,7 @@ struct _QuickAdd {
GtkWidget *dialog;
GtkWidget *name_entry;
GtkWidget *email_entry;
- GtkWidget *option_menu;
+ GtkWidget *combo_box;
gint refs;
@@ -193,7 +193,12 @@ ce_have_book (EBook *book, EBookStatus status, gpointer closure)
g_warning ("Couldn't open local address book.");
quick_add_unref (qa);
} else {
- EContactEditor *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,
@@ -284,7 +289,7 @@ sanitize_widgets (QuickAdd *qa)
g_return_if_fail (qa->dialog != NULL);
/* do not call here e_book_is_writable (qa->book), because it requires opened book, which takes time for remote books */
- enabled = qa->book != NULL && e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->option_menu));
+ enabled = qa->book != NULL && e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->combo_box));
gtk_dialog_set_response_sensitive (GTK_DIALOG (qa->dialog), QUICK_ADD_RESPONSE_EDIT_FULL, enabled);
gtk_dialog_set_response_sensitive (GTK_DIALOG (qa->dialog), GTK_RESPONSE_OK, enabled);
@@ -355,13 +360,13 @@ build_quick_add_dialog (QuickAdd *qa)
gconf_client = gconf_client_get_default ();
source_list = e_source_list_new_for_gconf (gconf_client, "/apps/evolution/addressbook/sources");
g_object_unref (gconf_client);
- qa->option_menu = e_source_combo_box_new (source_list);
+ qa->combo_box = e_source_combo_box_new (source_list);
book = e_book_new_default_addressbook (NULL);
e_source_combo_box_set_active (
- E_SOURCE_COMBO_BOX (qa->option_menu),
+ E_SOURCE_COMBO_BOX (qa->combo_box),
e_book_get_source (book));
- if (!e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->option_menu))) {
+ if (!e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->combo_box))) {
/* this means the e_book_new_default_addressbook didn't find any "default" nor "system" source,
and created new one for us. That is wrong, choose one from combo instead. */
@@ -371,9 +376,9 @@ build_quick_add_dialog (QuickAdd *qa)
}
book = e_book_new (e_source_list_peek_source_any (source_list), NULL);
- e_source_combo_box_set_active (E_SOURCE_COMBO_BOX (qa->option_menu), e_book_get_source (book));
+ e_source_combo_box_set_active (E_SOURCE_COMBO_BOX (qa->combo_box), e_book_get_source (book));
- if (!e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->option_menu))) {
+ if (!e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->combo_box))) {
/* Does it failed again? What is going on? */
if (book)
g_object_unref (book);
@@ -386,9 +391,9 @@ build_quick_add_dialog (QuickAdd *qa)
qa->book = NULL;
}
qa->book = book;
- source_changed (E_SOURCE_COMBO_BOX (qa->option_menu), qa);
+ source_changed (E_SOURCE_COMBO_BOX (qa->combo_box), qa);
g_signal_connect (
- qa->option_menu, "changed",
+ qa->combo_box, "changed",
G_CALLBACK (source_changed), qa);
g_object_unref (source_list);
@@ -420,13 +425,13 @@ build_quick_add_dialog (QuickAdd *qa)
GTK_EXPAND | GTK_FILL, 0, xpad, ypad);
label = gtk_label_new_with_mnemonic (_("_Select Address Book"));
- gtk_label_set_mnemonic_widget ((GtkLabel *)label, qa->option_menu);
+ gtk_label_set_mnemonic_widget ((GtkLabel *)label, qa->combo_box);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach (table, label,
0, 1, 2, 3,
GTK_FILL, 0, xpad, ypad);
- gtk_table_attach (table, qa->option_menu,
+ gtk_table_attach (table, qa->combo_box,
1, 2, 2, 3,
GTK_EXPAND | GTK_FILL, 0, xpad, ypad);
diff --git a/addressbook/gui/contact-editor/eab-editor.c b/addressbook/gui/contact-editor/eab-editor.c
index 19c3d9c7e3..554db9aa7b 100644
--- a/addressbook/gui/contact-editor/eab-editor.c
+++ b/addressbook/gui/contact-editor/eab-editor.c
@@ -28,16 +28,22 @@
#include <glib/gi18n.h>
#include "eab-editor.h"
-#include "addressbook/gui/widgets/eab-gui-util.h"
#include "e-util/e-util.h"
+#include "addressbook/gui/widgets/eab-gui-util.h"
+
+#define EAB_EDITOR_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), EAB_TYPE_EDITOR, EABEditorPrivate))
+
+struct _EABEditorPrivate {
+ EShell *shell;
+};
-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);
+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 GSList *all_editors;
+static gpointer parent_class;
+static guint signals[LAST_SIGNAL];
-static guint editor_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,108 +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;
-}
-
-gboolean
-eab_editor_confirm_delete (GtkWindow *parent, gboolean plural, gboolean is_list, gchar *name)
-{
- GtkWidget *dialog;
- gint result;
- gchar *msg;
-
- if (is_list) {
- /* contact list(s) */
- if (!plural)
- msg = g_strdup_printf (_("Are you sure you want\nto delete contact list (%s)?"),
- name?name:"");
- else
- msg = g_strdup (_("Are you sure you want\nto delete these contact lists?"));
- }
- else {
- /* contact(s) */
- if (!plural)
- msg = g_strdup_printf (_("Are you sure you want\nto delete contact (%s)?"),
- name?name:"");
- else
- msg = g_strdup (_("Are you sure you want\nto delete these contacts?"));
- }
-
- dialog = gtk_message_dialog_new (parent,
- 0,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- "%s",
- msg);
- g_free (msg);
-
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT,
- NULL);
-
- result = gtk_dialog_run(GTK_DIALOG (dialog));
-
- gtk_widget_destroy (dialog);
-
- return (result == GTK_RESPONSE_ACCEPT);
-}
-
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
@@ -389,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 6d70107643..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 <bonobo/bonobo-ui-component.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 _EABEditor EABEditor;
+typedef struct _EABEditorClass EABEditorClass;
+typedef struct _EABEditorPrivate EABEditorPrivate;
-struct _EABEditor
-{
+struct _EABEditor {
GObject parent;
+ EABEditorPrivate *priv;
};
-struct _EABEditorClass
-{
+struct _EABEditorClass {
GObjectClass parent_class;
/* virtual functions */
@@ -78,32 +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);
-gboolean eab_editor_confirm_delete (GtkWindow *parent, gboolean plural, gboolean is_list, gchar *name);
+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