diff options
author | JP Rosevear <jpr@ximian.com> | 2001-10-13 06:09:57 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2001-10-13 06:09:57 +0800 |
commit | 1bd22eb65b2d1fa1cb8a589871337290c1cb258f (patch) | |
tree | 1fb6480c5a86900e4a3bcc34ac80964b9f471162 /calendar/gui/dialogs/comp-editor.c | |
parent | 02c6e327892d45a00722a7f5e5d8c7ef62d3edf7 (diff) | |
download | gsoc2013-evolution-1bd22eb65b2d1fa1cb8a589871337290c1cb258f.tar gsoc2013-evolution-1bd22eb65b2d1fa1cb8a589871337290c1cb258f.tar.gz gsoc2013-evolution-1bd22eb65b2d1fa1cb8a589871337290c1cb258f.tar.bz2 gsoc2013-evolution-1bd22eb65b2d1fa1cb8a589871337290c1cb258f.tar.lz gsoc2013-evolution-1bd22eb65b2d1fa1cb8a589871337290c1cb258f.tar.xz gsoc2013-evolution-1bd22eb65b2d1fa1cb8a589871337290c1cb258f.tar.zst gsoc2013-evolution-1bd22eb65b2d1fa1cb8a589871337290c1cb258f.zip |
return fill_component success
2001-10-12 JP Rosevear <jpr@ximian.com>
* gui/dialogs/alarm-page.c: return fill_component success
* gui/dialogs/task-page.c: ditto
* gui/dialogs/task-details-page.c: ditto
* gui/dialogs/schedule-page.c: ditto
* gui/dialogs/recurrence-page.c: ditto
* gui/dialogs/event-page.c: ditto
* gui/dialogs/meeting-page.c: use e_notice instead of
duplicate_error
(meeting_page_get_cancel_comp): duh, deleted_attendees is an array
now
(meeting_page_fill_component): spew gui errors if there is no
organizer or no attendees, return success
* gui/dialogs/event-editor.c (event_editor_send_comp): always call
parent method and don't send the cancellation comp if the method
is publish
(refresh_meeting_cmd): use the orginal comp to refresh
(forward_cmd): prompt the user for the version they want to send
(current, original)
* gui/dialogs/task-editor.c (forward_cmd): as above
(refresh_task_cmd): ditto
* gui/dialogs/comp-editor-page.c
(comp_editor_page_fill_component): return boolean of whether the
component could be filled or not
* gui/dialogs/comp-editor-page.h: update proto
* gui/dialogs/comp-editor.c (prompt_to_save_changes): take a param
on whether to try and send or not
(comp_editor_get_current_comp): only fill component if its changed
(comp_editor_save_comp): prompt user as well
* gui/dialogs/comp-editor.h: change proto
* gui/itip-utils.c: replace error_dialog with e_notice
(comp_content_type): specify charset
svn path=/trunk/; revision=13635
Diffstat (limited to 'calendar/gui/dialogs/comp-editor.c')
-rw-r--r-- | calendar/gui/dialogs/comp-editor.c | 230 |
1 files changed, 124 insertions, 106 deletions
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 6a51cf75a3..b6d6e233db 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -79,8 +79,6 @@ static void comp_editor_destroy (GtkObject *object); static void real_set_cal_client (CompEditor *editor, CalClient *client); static void real_edit_comp (CompEditor *editor, CalComponent *comp); static void real_send_comp (CompEditor *editor, CalComponentItipMethod method); -static void save_comp (CompEditor *editor); -static void save_comp_with_send (CompEditor *editor); static void delete_comp (CompEditor *editor); static void close_dialog (CompEditor *editor); @@ -273,6 +271,117 @@ comp_editor_destroy (GtkObject *object) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } + +static gboolean +save_comp (CompEditor *editor) +{ + CompEditorPrivate *priv; + CalComponent *clone; + GList *l; + + priv = editor->priv; + + if (!priv->changed) + return TRUE; + + clone = cal_component_clone (priv->comp); + for (l = priv->pages; l != NULL; l = l->next) { + if (!comp_editor_page_fill_component (l->data, clone)) { + gtk_object_unref (GTK_OBJECT (clone)); + return FALSE; + } + } + cal_component_commit_sequence (clone); + gtk_object_unref (GTK_OBJECT (priv->comp)); + priv->comp = clone; + + priv->updating = TRUE; + + if (!cal_client_update_object (priv->client, priv->comp)) { + g_message ("save_comp (): Could not update the object!"); + return FALSE; + } else { + priv->changed = FALSE; + } + + priv->updating = FALSE; + + return TRUE; +} + +static gboolean +save_comp_with_send (CompEditor *editor) +{ + CompEditorPrivate *priv; + gboolean send; + + priv = editor->priv; + + send = priv->changed && priv->needs_send; + + if (!save_comp (editor)) + return FALSE; + + if (send && send_component_dialog (priv->comp)) + comp_editor_send_comp (editor, CAL_COMPONENT_METHOD_REQUEST); + + return TRUE; +} + +static void +delete_comp (CompEditor *editor) +{ + CompEditorPrivate *priv; + const char *uid; + + priv = editor->priv; + + cal_component_get_uid (priv->comp, &uid); + priv->updating = TRUE; + cal_client_remove_object (priv->client, uid); + priv->updating = FALSE; + close_dialog (editor); +} + +static gboolean +prompt_to_save_changes (CompEditor *editor, gboolean send) +{ + CompEditorPrivate *priv; + + priv = editor->priv; + + if (!priv->changed) + return TRUE; + + switch (save_component_dialog (GTK_WINDOW (priv->window))) { + case 0: /* Save */ + if (send && save_comp_with_send (editor)) + return TRUE; + else if (!send && save_comp (editor)) + return TRUE; + else + return FALSE; + case 1: /* Discard */ + return TRUE; + case 2: /* Cancel */ + default: + return FALSE; + } +} + +/* Closes the dialog box and emits the appropriate signals */ +static void +close_dialog (CompEditor *editor) +{ + CompEditorPrivate *priv; + + priv = editor->priv; + + g_assert (priv->window != NULL); + + gtk_object_destroy (GTK_OBJECT (editor)); +} + /** @@ -676,18 +785,20 @@ comp_editor_edit_comp (CompEditor *editor, CalComponent *comp) CalComponent * comp_editor_get_current_comp (CompEditor *editor) { - CompEditorPrivate *priv; + CompEditorPrivate *priv; CalComponent *comp; GList *l; - + g_return_val_if_fail (editor != NULL, NULL); g_return_val_if_fail (IS_COMP_EDITOR (editor), NULL); priv = editor->priv; comp = cal_component_clone (priv->comp); - for (l = priv->pages; l != NULL; l = l->next) - comp_editor_page_fill_component (l->data, comp); + if (priv->changed) { + for (l = priv->pages; l != NULL; l = l->next) + comp_editor_page_fill_component (l->data, comp); + } return comp; } @@ -698,10 +809,10 @@ comp_editor_get_current_comp (CompEditor *editor) * * **/ -void -comp_editor_save_comp (CompEditor *editor) +gboolean +comp_editor_save_comp (CompEditor *editor, gboolean send) { - save_comp (editor); + return prompt_to_save_changes (editor, send); } /** @@ -823,99 +934,6 @@ comp_editor_focus (CompEditor *editor) raise_and_focus (priv->window); } -static void -save_comp (CompEditor *editor) -{ - CompEditorPrivate *priv; - GList *l; - - priv = editor->priv; - - if (!priv->changed) - return; - - for (l = priv->pages; l != NULL; l = l->next) - comp_editor_page_fill_component (l->data, priv->comp); - cal_component_commit_sequence (priv->comp); - - priv->updating = TRUE; - - if (!cal_client_update_object (priv->client, priv->comp)) - g_message ("save_comp (): Could not update the object!"); - else - priv->changed = FALSE; - - priv->updating = FALSE; -} - -static void -save_comp_with_send (CompEditor *editor) -{ - CompEditorPrivate *priv; - gboolean send; - - priv = editor->priv; - - send = priv->changed && priv->needs_send; - - save_comp (editor); - - if (send && send_component_dialog (priv->comp)) - comp_editor_send_comp (editor, CAL_COMPONENT_METHOD_REQUEST); -} - -static void -delete_comp (CompEditor *editor) -{ - CompEditorPrivate *priv; - const char *uid; - - priv = editor->priv; - - cal_component_get_uid (priv->comp, &uid); - priv->updating = TRUE; - cal_client_remove_object (priv->client, uid); - priv->updating = FALSE; - close_dialog (editor); -} - -static gboolean -prompt_to_save_changes (CompEditor *editor) -{ - CompEditorPrivate *priv; - - priv = editor->priv; - - if (!priv->changed) - return TRUE; - - switch (save_component_dialog (GTK_WINDOW (priv->window))) { - case 0: /* Save */ - /* FIXME: If an error occurs here, we should popup a dialog - and then return FALSE. */ - save_comp_with_send (editor); - return TRUE; - case 1: /* Discard */ - return TRUE; - case 2: /* Cancel */ - default: - return FALSE; - } -} - -/* Closes the dialog box and emits the appropriate signals */ -static void -close_dialog (CompEditor *editor) -{ - CompEditorPrivate *priv; - - priv = editor->priv; - - g_assert (priv->window != NULL); - - gtk_object_destroy (GTK_OBJECT (editor)); -} - /* Menu Commands */ static void save_cmd (GtkWidget *widget, gpointer data) @@ -930,8 +948,8 @@ save_close_cmd (GtkWidget *widget, gpointer data) { CompEditor *editor = COMP_EDITOR (data); - save_comp_with_send (editor); - close_dialog (editor); + if (save_comp_with_send (editor)) + close_dialog (editor); } static void @@ -1090,7 +1108,7 @@ close_cmd (GtkWidget *widget, gpointer data) { CompEditor *editor = COMP_EDITOR (data); - if (prompt_to_save_changes (editor)) + if (prompt_to_save_changes (editor, TRUE)) close_dialog (editor); } @@ -1200,7 +1218,7 @@ delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) { CompEditor *editor = COMP_EDITOR (data); - if (prompt_to_save_changes (editor)) + if (prompt_to_save_changes (editor, TRUE)) close_dialog (editor); return TRUE; |