diff options
author | Radek Doulik <rodo@ximian.com> | 2003-12-01 23:20:49 +0800 |
---|---|---|
committer | Radek Doulik <rodo@src.gnome.org> | 2003-12-01 23:20:49 +0800 |
commit | 2c1e306b97ef82b8576b542884702cb4487c6182 (patch) | |
tree | 7dff79c42c52c89892fc12e7045c9ab1f3429ec3 /composer/e-msg-composer.c | |
parent | d595778e6f897b1b47998c0c3862392358a0ee9c (diff) | |
download | gsoc2013-evolution-2c1e306b97ef82b8576b542884702cb4487c6182.tar.gz gsoc2013-evolution-2c1e306b97ef82b8576b542884702cb4487c6182.tar.zst gsoc2013-evolution-2c1e306b97ef82b8576b542884702cb4487c6182.zip |
autosave fix
2003-11-11 Radek Doulik <rodo@ximian.com>
* e-msg-composer.c (e_msg_composer_set_autosaved): new method to
wrap autosaved flag setting
(e_msg_composer_unset_autosaved): ditto
(e_msg_composer_is_autosaved): new method, says if composer was
autosaved only
(autosave_save_draft): unset changed so that we don't autosave all
the time when anything else than gtkhtml control changed
2003-11-06 Radek Doulik <rodo@ximian.com>
* e-msg-composer.c (autosave_save_draft): call gtkhtml's saved
command to clean is-saved flag, set composer's autosaved flag
(do_exit): complain if last save was just autosave
(e_msg_composer_unset_changed): reset autosaved flag
(save): reset autosaved flag
* e-msg-composer.h: added autosaved flag, it tells whether last
save was autosave or regular save, when changed flag is reset the
autosaved one is reset too
svn path=/trunk/; revision=23526
Diffstat (limited to 'composer/e-msg-composer.c')
-rw-r--r-- | composer/e-msg-composer.c | 58 |
1 files changed, 53 insertions, 5 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index a9a630ae87..c5f59ae298 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -1179,9 +1179,10 @@ save (EMsgComposer *composer, const char *default_filename) e_notice (composer, GTK_MESSAGE_ERROR, _("Error saving file: %s"), tmp); g_free(tmp); - } else + } else { GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "saved", &ev); - + e_msg_composer_unset_autosaved (composer); + } CORBA_exception_free (&ev); g_free (filename); @@ -1232,7 +1233,7 @@ autosave_save_draft (EMsgComposer *composer) if (!e_msg_composer_is_dirty (composer)) return TRUE; - + fd = composer->autosave_fd; file = composer->autosave_file; @@ -1281,6 +1282,13 @@ autosave_save_draft (EMsgComposer *composer) _("Error autosaving message: %s\n %s"), file, strerror(errno)); success = FALSE; + } else { + CORBA_Environment ev; + CORBA_exception_init (&ev); + GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "saved", &ev); + CORBA_exception_free (&ev); + e_msg_composer_unset_changed (composer); + e_msg_composer_set_autosaved (composer); } camel_object_unref (stream); @@ -1515,6 +1523,7 @@ menu_file_save_draft_cb (BonoboUIComponent *uic, void *data, const char *path) { g_signal_emit (data, signals[SAVE_DRAFT], 0, FALSE); e_msg_composer_unset_changed (E_MSG_COMPOSER (data)); + e_msg_composer_unset_autosaved (E_MSG_COMPOSER (data)); } /* Exit dialog. (Displays a "Save composition to 'Drafts' before exiting?" warning before actually exiting.) */ @@ -1526,7 +1535,7 @@ do_exit (EMsgComposer *composer) GtkWidget *dialog; int button; - if (!e_msg_composer_is_dirty (composer)) { + if (!e_msg_composer_is_dirty (composer) && !e_msg_composer_is_autosaved (composer)) { gtk_widget_destroy (GTK_WIDGET (composer)); return; } @@ -1557,6 +1566,7 @@ do_exit (EMsgComposer *composer) /* Save */ g_signal_emit (GTK_OBJECT (composer), signals[SAVE_DRAFT], 0, TRUE); e_msg_composer_unset_changed (composer); + e_msg_composer_unset_autosaved (composer); break; case GTK_RESPONSE_NO: /* Don't save */ @@ -2673,6 +2683,7 @@ init (EMsgComposer *composer) composer->smime_encrypt = FALSE; composer->has_changed = FALSE; + composer->autosaved = FALSE; composer->redirect = FALSE; @@ -4880,7 +4891,6 @@ e_msg_composer_unset_changed (EMsgComposer *composer) composer->has_changed = FALSE; } - gboolean e_msg_composer_is_dirty (EMsgComposer *composer) { @@ -4896,6 +4906,44 @@ e_msg_composer_is_dirty (EMsgComposer *composer) return rv; } +/** + * e_msg_composer_set_autosaved: + * @composer: An EMsgComposer object. + * + * Mark the composer as autosaved, so before the composer gets destroyed + * the user will be prompted about unsaved changes. + **/ +void +e_msg_composer_set_autosaved (EMsgComposer *composer) +{ + g_return_if_fail (E_IS_MSG_COMPOSER (composer)); + + composer->autosaved = TRUE; +} + + +/** + * e_msg_composer_unset_autosaved: + * @composer: An EMsgComposer object. + * + * Mark the composer as unautosaved, so no prompt about unsaved changes + * will appear before destroying the composer. + **/ +void +e_msg_composer_unset_autosaved (EMsgComposer *composer) +{ + g_return_if_fail (E_IS_MSG_COMPOSER (composer)); + + composer->autosaved = FALSE; +} + +gboolean +e_msg_composer_is_autosaved (EMsgComposer *composer) +{ + g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE); + + return composer->autosaved; +} void e_msg_composer_set_enable_autosave (EMsgComposer *composer, gboolean enabled) |