aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/ChangeLog18
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c108
-rw-r--r--addressbook/gui/contact-editor/eab-editor.c1
3 files changed, 113 insertions, 14 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 99e9c5b754..48f41d672e 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,5 +1,23 @@
2004-05-19 Hans Petter Jansson <hpj@ximian.com>
+ * gui/contact-editor/e-contact-editor.c (extract_simple_field):
+ Remove debug output.
+ (real_save_contact): Separate out actual save logic from
+ save_contact ().
+ (save_contact): If the user wants to move the contact from one
+ address book to another, but the source is read-only, as to
+ save a copy instead.
+ (e_contact_editor_is_valid): The dialog should be an error dialog.
+ (app_delete_event_cb): If the target book is read-only, prompt
+ to discard. If the user wants to move but cannot, prompt to save
+ a copy. Also validate.
+
+ * gui/contact-editor/eab-editor.c (eab_editor_prompt_to_save_changes):
+ Remove comment about invalid data dialog, it's not handled here
+ anymore.
+
+2004-05-19 Hans Petter Jansson <hpj@ximian.com>
+
Fixes a number of bugs, adds some unimplemented functionality, and
makes code more structured.
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 191950215a..7d2df033fa 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -1995,11 +1995,9 @@ extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id)
&photo.data, &photo.length)) {
e_contact_set (contact, field_id, &photo);
g_free (photo.data);
- g_print ("Picture set!\n");
}
else {
e_contact_set (contact, E_CONTACT_PHOTO, NULL);
- g_print ("Picture unset!\n");
}
}
else if (GTK_IS_TOGGLE_BUTTON (widget)) {
@@ -2510,17 +2508,10 @@ contact_modified_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs)
/* Emits the signal to request saving a contact */
static void
-save_contact (EContactEditor *ce, gboolean should_close)
+real_save_contact (EContactEditor *ce, gboolean should_close)
{
EditorCloseStruct *ecs;
- extract_all (ce);
- if (!ce->target_book)
- return;
-
- if (!e_contact_editor_is_valid (EAB_EDITOR (ce)))
- return;
-
ecs = g_new0 (EditorCloseStruct, 1);
ecs->ce = ce;
g_object_ref (ecs->ce);
@@ -2545,6 +2536,44 @@ save_contact (EContactEditor *ce, gboolean should_close)
}
static void
+save_contact (EContactEditor *ce, gboolean should_close)
+{
+ extract_all (ce);
+ if (!ce->target_book)
+ return;
+
+ if (!e_contact_editor_is_valid (EAB_EDITOR (ce)))
+ return;
+
+ if (ce->target_editable && !ce->source_editable) {
+ GtkWidget *dialog;
+ gint response;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (ce->app),
+ (GtkDialogFlags) 0,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ _("You are moving the contact from one "
+ "address book to another, but it cannot "
+ "be removed from the source. Do you want "
+ "to save a copy instead?"));
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_YES,
+ NULL);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ if (response == GTK_RESPONSE_CANCEL)
+ return;
+ }
+
+ real_save_contact (ce, should_close);
+}
+
+static void
e_contact_editor_save_contact (EABEditor *editor, gboolean should_close)
{
save_contact (E_CONTACT_EDITOR (editor), should_close);
@@ -2601,7 +2630,7 @@ e_contact_editor_is_valid (EABEditor *editor)
dialog = gtk_message_dialog_new (GTK_WINDOW (ce->app),
0,
- GTK_MESSAGE_INFO,
+ GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
errmsg->str);
result = gtk_dialog_run (GTK_DIALOG (dialog));
@@ -2627,7 +2656,6 @@ e_contact_editor_get_window (EABEditor *editor)
return GTK_WINDOW (E_CONTACT_EDITOR (editor)->app);
}
-
static void
file_save_and_close_cb (GtkWidget *widget, gpointer data)
{
@@ -2657,7 +2685,61 @@ app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
if (ce->in_async_call)
return TRUE;
- if (!eab_editor_prompt_to_save_changes (EAB_EDITOR (ce), GTK_WINDOW (ce->app)))
+ if (!ce->target_editable) {
+ GtkWidget *dialog;
+ gint response;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (widget),
+ (GtkDialogFlags) 0,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ _("The contact cannot be saved to the "
+ "selected address book. Do you want to "
+ "discard changes?"));
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ _("_Discard"), GTK_RESPONSE_YES,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ NULL);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ if (response != GTK_RESPONSE_YES)
+ return TRUE;
+ }
+ else if (!ce->source_editable) {
+ GtkWidget *dialog;
+ gint response;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (widget),
+ (GtkDialogFlags) 0,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ _("You are moving the contact from one "
+ "address book to another, but it cannot "
+ "be removed from the source. Do you want "
+ "to save a copy instead?"));
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ _("_Discard"), GTK_RESPONSE_NO,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_YES,
+ NULL);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ if (response == GTK_RESPONSE_YES) {
+ if (e_contact_editor_is_valid (EAB_EDITOR (ce)))
+ real_save_contact (ce, FALSE);
+ else
+ return TRUE;
+ }
+ else if (response == GTK_RESPONSE_CANCEL)
+ return TRUE;
+ }
+ else if (!eab_editor_prompt_to_save_changes (EAB_EDITOR (ce), GTK_WINDOW (ce->app)))
return TRUE;
eab_editor_close (EAB_EDITOR (ce));
diff --git a/addressbook/gui/contact-editor/eab-editor.c b/addressbook/gui/contact-editor/eab-editor.c
index 354044a607..4e1f6d11fd 100644
--- a/addressbook/gui/contact-editor/eab-editor.c
+++ b/addressbook/gui/contact-editor/eab-editor.c
@@ -256,7 +256,6 @@ eab_editor_prompt_to_save_changes (EABEditor *editor, GtkWindow *window)
switch (eab_prompt_save_dialog (window)) {
case GTK_RESPONSE_YES:
if (!eab_editor_is_valid (editor)) {
- /* XXX pop up dialog about things being invalid */
return FALSE;
}
eab_editor_save_contact (editor, FALSE);