[evolution-patches] Patches for bug #20672



      * gtkhtml3.0-autosaved.diff: Add new "autosaved" and
        "is-autosaved" GtkHTML commands to set an autosave mark and
        query whether there have been changes since the mark was set.
      * evolution-autosaved.diff: Use these and and a new composer field
        to keep track of whether the message needs to be autosaved. This
        fixes the bug, as messages no longer get autosaved
        unnecessarily.
      * evolution-changed.diff: Fix a few cases where the composer
        didn't get marked as dirty when it should.


Please apply, feedback appreciated.


-- 
Earthling Michel Dänzer   \  Debian (powerpc), XFree86 and DRI developer
Software libre enthusiast  \     http://svcs.affero.net/rm.php?r=daenzer
Index: src/ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.1822
diff -p -u -r1.1822 ChangeLog
--- src/ChangeLog	10 Jul 2003 16:33:34 -0000	1.1822
+++ src/ChangeLog	16 Jul 2003 00:56:07 -0000
@@ -1,0 +1,20 @@
+2003-07-16  Michel Dänzer  <michel daenzer net>
+
+	* htmlengine.h (struct _HTMLEngine): Add autosaved_step_count field.
+
+	* htmlengine.c (html_engine_init): Initialize
+	engine->autosaved_step_count to -1.
+	(html_engine_autosaved): New, set mark in undo queue when contents
+	were autosaved.
+	(html_engine_is_autosaved): New, return whether the undo queue is
+	currently at the autosave mark.
+
+	* gtkhtml-enums.h (GtkHTMLCommandType): Add
+	GTK_HTML_COMMAND_AUTOSAVED and GTK_HTML_COMMAND_IS_AUTOSAVED.
+
+	* gtkhtml-properties.c (_gtk_html_command_values): Ditto, for new
+	"autosaved" and "is-autosaved" commands.
+
+	* gtkhtml.c (command): Ditto, call html_engine_autosaved() and
+	html_engine_is_autosaved(), respectively.
+
Index: src/htmlengine.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine.h,v
retrieving revision 1.170
diff -p -u -r1.170 htmlengine.h
--- src/htmlengine.h	1 Jan 1997 08:09:08 -0000	1.170
+++ src/htmlengine.h	14 Jul 2003 09:43:46 -0000
@@ -269,6 +269,7 @@ struct _HTMLEngine {
 
 	gboolean save_data;
 	gint saved_step_count;
+	gint autosaved_step_count;
 
 	gboolean expose;
 	gboolean need_update;
@@ -301,6 +302,8 @@ void        html_engine_unrealize     (H
 
 void      html_engine_saved     (HTMLEngine *e);
 gboolean  html_engine_is_saved  (HTMLEngine *e);
+void      html_engine_autosaved (HTMLEngine *e);
+gboolean  html_engine_is_autosaved (HTMLEngine *e);
 
 /* Editability control.  */
 void      html_engine_set_editable  (HTMLEngine *e,
Index: src/htmlengine.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine.c,v
retrieving revision 1.549
diff -p -u -r1.549 htmlengine.c
--- src/htmlengine.c	1 Jan 1997 08:51:31 -0000	1.549
+++ src/htmlengine.c	14 Jul 2003 09:43:46 -0000
@@ -3655,7 +3655,7 @@ html_engine_init (HTMLEngine *engine)
 
 	engine->block = FALSE;
 	engine->save_data = FALSE;
-	engine->saved_step_count = -1;
+	engine->saved_step_count = engine->autosaved_step_count = -1;
 
 	engine->map_table = NULL;
 
@@ -5770,6 +5770,18 @@ void
 html_engine_saved (HTMLEngine *e)
 {
 	e->saved_step_count = html_undo_get_step_count (e->undo);
+}
+
+gboolean
+html_engine_is_autosaved (HTMLEngine *e)
+{
+	return e->autosaved_step_count != -1 && e->autosaved_step_count == html_undo_get_step_count (e->undo);
+}
+
+void
+html_engine_autosaved (HTMLEngine *e)
+{
+	e->autosaved_step_count = html_undo_get_step_count (e->undo);
 }
 
 static void
Index: src/gtkhtml-enums.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml-enums.h,v
retrieving revision 1.35
diff -p -u -r1.35 gtkhtml-enums.h
--- src/gtkhtml-enums.h	19 May 2003 14:41:02 -0000	1.35
+++ src/gtkhtml-enums.h	14 Jul 2003 09:43:41 -0000
@@ -219,6 +219,9 @@ typedef enum {
 	GTK_HTML_COMMAND_CELL_RSPAN_INC,
 	GTK_HTML_COMMAND_CELL_CSPAN_DEC,
 	GTK_HTML_COMMAND_CELL_RSPAN_DEC,
+
+	GTK_HTML_COMMAND_AUTOSAVED,
+	GTK_HTML_COMMAND_IS_AUTOSAVED,
 } GtkHTMLCommandType;
 
 typedef enum {
Index: src/gtkhtml-properties.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml-properties.c,v
retrieving revision 1.95
diff -p -u -r1.95 gtkhtml-properties.c
--- src/gtkhtml-properties.c	25 Jun 2003 18:15:46 -0000	1.95
+++ src/gtkhtml-properties.c	14 Jul 2003 09:43:41 -0000
@@ -254,6 +254,8 @@ static GEnumValue _gtk_html_command_valu
 	{ GTK_HTML_COMMAND_CELL_RSPAN_INC, "GTK_HTML_COMMAND_CELL_RSPAN_INC", "rspan-inc" },
 	{ GTK_HTML_COMMAND_CELL_CSPAN_DEC, "GTK_HTML_COMMAND_CELL_CSPAN_DEC", "cspan-dec" },
 	{ GTK_HTML_COMMAND_CELL_RSPAN_DEC, "GTK_HTML_COMMAND_CELL_RSPAN_DEC", "rspan-dec" },
+	{ GTK_HTML_COMMAND_AUTOSAVED, "GTK_HTML_COMMAND_AUTOSAVED", "autosaved" },
+	{ GTK_HTML_COMMAND_IS_AUTOSAVED, "GTK_HTML_COMMAND_IS_AUTOSAVED", "is-autosaved" },
 	{ 0, NULL, NULL }
 };
 
Index: src/gtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.c,v
retrieving revision 1.524
diff -p -u -r1.524 gtkhtml.c
--- src/gtkhtml.c	1 Jan 1997 08:09:08 -0000	1.524
+++ src/gtkhtml.c	14 Jul 2003 09:43:43 -0000
@@ -4502,6 +4502,12 @@ command (GtkHTML *html, GtkHTMLCommandTy
 	case GTK_HTML_COMMAND_CELL_RSPAN_DEC:
 		rv = html_engine_rspan_delta (html->engine, -1);
 		break;
+	case GTK_HTML_COMMAND_AUTOSAVED:
+		html_engine_autosaved (html->engine);
+		break;
+	case GTK_HTML_COMMAND_IS_AUTOSAVED:
+		rv = html_engine_is_autosaved (html->engine);
+		break;
 	default:
 		html->binding_handled = FALSE;
 	}
Index: composer/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/composer/ChangeLog,v
retrieving revision 1.549
diff -p -u -r1.549 ChangeLog
--- composer/ChangeLog	7 Jul 2003 21:33:14 -0000	1.549
+++ composer/ChangeLog	16 Jul 2003 00:37:12 -0000
@@ -1,0 +1,14 @@
+2003-07-16  Michel Dänzer  <michel daenzer net>
+
+	* e-msg-composer.h (struct _EMsgComposer): Add
+	has_changed_autosave field.
+
+	* e-msg-composer.c (autosave_save_draft): Use new
+	composer->has_changed_autosave field and new GtkHTML engine
+	"is-autosaved" command to determine whether the message needs to
+	be autosaved. Fixes bug #20672.
+	(init): Initialize composer->has_changed_autosave to TRUE to
+	make sure the message gets autosaved the first time.
+	(e_msg_composer_set_changed): Set composer->has_changed_autosave
+	to TRUE to make sure the message gets autosaved the next time.
+
Index: composer/e-msg-composer.h
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.h,v
retrieving revision 1.83
diff -p -u -r1.83 e-msg-composer.h
--- composer/e-msg-composer.h	20 May 2003 18:26:09 -0000	1.83
+++ composer/e-msg-composer.h	15 Jul 2003 23:45:51 -0000
@@ -94,6 +94,7 @@ struct _EMsgComposer {
 	guint32 view_cc                : 1;
 	guint32 view_subject           : 1;
 	guint32 has_changed            : 1;
+	guint32 has_changed_autosave   : 1;
 	
 	guint32 mode_post              : 1;
 	
Index: composer/e-msg-composer.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.c,v
retrieving revision 1.399
diff -p -u -r1.399 e-msg-composer.c
--- composer/e-msg-composer.c	7 Jul 2003 21:33:14 -0000	1.399
+++ composer/e-msg-composer.c	15 Jul 2003 23:45:51 -0000
@@ -1248,11 +1248,20 @@ autosave_save_draft (EMsgComposer *compo
 	CamelStream *stream;
 	char *file;
 	int fd, camelfd;
+	CORBA_Environment ev;
+	gboolean rv = FALSE;
 	gboolean success = TRUE;
 	
-	if (!e_msg_composer_is_dirty (composer))
-		return TRUE;
-	
+	if (!composer->has_changed_autosave) {
+		CORBA_exception_init (&ev);
+		rv = GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "is-autosaved", &ev);
+		CORBA_exception_free (&ev);
+
+		if (rv) {
+			return TRUE;
+		}
+	}
+
 	fd = composer->autosave_fd;
 	file = composer->autosave_file;
 	
@@ -1301,6 +1310,12 @@ autosave_save_draft (EMsgComposer *compo
 			  _("Error autosaving message: %s\n %s"), file, strerror(errno));
 		
 		success = FALSE;
+	} else {
+		CORBA_exception_init (&ev);
+		GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "autosaved", &ev);
+		CORBA_exception_free (&ev);
+
+		composer->has_changed_autosave = FALSE;
 	}
 	
 	camel_object_unref (stream);
@@ -2689,6 +2709,7 @@ init (EMsgComposer *composer)
 	composer->smime_encrypt            = FALSE;
 	
 	composer->has_changed              = FALSE;
+	composer->has_changed_autosave     = TRUE;
 	
 	composer->redirect                 = FALSE;
 	
@@ -4865,6 +4886,7 @@ e_msg_composer_set_changed (EMsgComposer
 	g_return_if_fail (E_IS_MSG_COMPOSER (composer));
 	
 	composer->has_changed = TRUE;
+	composer->has_changed_autosave = TRUE;
 }
 
 
Index: composer/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/composer/ChangeLog,v
retrieving revision 1.549
diff -p -u -r1.549 ChangeLog
--- composer/ChangeLog	7 Jul 2003 21:33:14 -0000	1.549
+++ composer/ChangeLog	16 Jul 2003 00:34:15 -0000
@@ -1,0 +1,8 @@
+2003-07-16  Michel Dänzer  <michel daenzer net>
+
+	* e-msg-composer-hdrs.c (from_changed): Also send HDRS_CHANGED
+	signal.
+
+	* e-msg-composer.c (menu_changed_charset_cb): Mark the composer
+	as changed.
+
Index: composer/e-msg-composer-hdrs.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer-hdrs.c,v
retrieving revision 1.114
diff -p -u -r1.114 e-msg-composer-hdrs.c
--- composer/e-msg-composer-hdrs.c	17 Jun 2003 19:47:53 -0000	1.114
+++ composer/e-msg-composer-hdrs.c	15 Jul 2003 23:45:47 -0000
@@ -191,6 +191,7 @@ from_changed (GtkWidget *item, gpointer 
 	gtk_entry_set_text (GTK_ENTRY (hdrs->priv->reply_to.entry), reply_to ? reply_to : "");
 	
 	g_signal_emit (hdrs, signals [FROM_CHANGED], 0);
+	g_signal_emit (hdrs, signals [HDRS_CHANGED], 0);
 }
 
 static void
Index: composer/e-msg-composer.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.c,v
retrieving revision 1.399
diff -p -u -r1.399 e-msg-composer.c
--- composer/e-msg-composer.c	7 Jul 2003 21:33:14 -0000	1.399
+++ composer/e-msg-composer.c	15 Jul 2003 23:45:51 -0000
@@ -1915,14 +1930,19 @@ menu_changed_charset_cb (BonoboUICompone
 			 const char                  *state,
 			 gpointer                     user_data)
 {
+	EMsgComposer *composer = E_MSG_COMPOSER (user_data);
+
 	if (type != Bonobo_UIComponent_STATE_CHANGED)
 		return;
 	
 	if (atoi (state)) {
 		/* Charset menu names are "Charset-%s" where %s is the charset name */
-		g_free (E_MSG_COMPOSER (user_data)->charset);
-		E_MSG_COMPOSER (user_data)->charset = g_strdup (path + strlen ("Charset-"));
+		g_free (composer->charset);
+		composer->charset = g_strdup (path + strlen ("Charset-"));
 	}
+	
+	/* Mark the composer as changed so it prompts about unsaved changes on close */
+	e_msg_composer_set_changed (composer);
 }
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]