aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--composer/ChangeLog22
-rw-r--r--composer/e-msg-composer.c58
-rw-r--r--composer/e-msg-composer.h4
3 files changed, 79 insertions, 5 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 158b0d0a2f..653ed19a83 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,25 @@
+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
+
2003-11-30 Ettore Perazzoli <ettore@ximian.com>
* e-msg-composer-hdrs.c (create_headers): #if 0 the "post to"
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)
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index 734b4c8760..dcc308cac0 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -98,6 +98,7 @@ struct _EMsgComposer {
guint32 view_cc : 1;
guint32 view_subject : 1;
guint32 has_changed : 1;
+ guint32 autosaved : 1;
guint32 mode_post : 1;
@@ -185,6 +186,9 @@ char *e_msg_composer_guess_mime_type (const
void e_msg_composer_set_changed (EMsgComposer *composer);
void e_msg_composer_unset_changed (EMsgComposer *composer);
gboolean e_msg_composer_is_dirty (EMsgComposer *composer);
+void e_msg_composer_set_autosaved (EMsgComposer *composer);
+void e_msg_composer_unset_autosaved (EMsgComposer *composer);
+gboolean e_msg_composer_is_autosaved (EMsgComposer *composer);
void e_msg_composer_set_enable_autosave (EMsgComposer *composer,
gboolean enabled);