Re: [Fwd: [evolution-patches] [resend] patches for #20672 (gtkhtml and mailer)]



Hi Michel,

I thought about that bug again and I think we don't need any change on
gtkhtml's side. I am attaching composer fix (autosave.fix) and your
evolution-changed.diff patch. Could you test that the fix works for you?
(I tested it here, but to be sure I didn't miss anything)

Jeff, Michael could you review these patches?

Cheers
Radek

On Tue, 2003-09-16 at 01:10, Michel Dänzer wrote:
> On Mon, 2003-09-15 at 13:53, Radek Doulík wrote:
> > On Fri, 2003-09-12 at 23:14, Larry Ewing wrote:
> > > > > I'm not strongly opposed to this patch and rodo's approval is enough 
> > > > > that I wouldn't mind it going in I would just like to avoid the 
> > > > > autosaved references if possible.
> > > > 
> > > > Would you prefer a gtkhtml command to retrieve the undo step counter?
> > > > Using that the composer could implement the autosave logic.
> > > > 
> > > 
> > > That seems pretty reasonable.  Any thoughts Radek?
> > 
> > Yeah, it can be done this way as well. On the other hand we already have
> > the same mechanism for saved/is-saved, so it makes sense implement
> > autosaved/is-autosaved the same way.
> 
> I guess the difference is that saving is a much more common concept than
> autosaving.
> 
> > If we do autosave counter outside, we should probably also remove
> > saved/is-saved and use undo counter as well.
> 
> Care would have to be taken not to break backwards compatibility.
> 
> > I personally prefer to have save, autosave counters inside gtkhtml. They
> > use gtkhtml's commands so it doesn't add any new complicated API. The
> > reason I implemented saved/is-saved this way was that users of
> > libgtkhtml may find the way how to handle saving easier. (we don't have
> > much documentation :) Last time I was asked about saving (implementing
> > dirty flag) by bighead on irc, so it may not be so clear though ;-)
> 
> Another possibility would be a generic way to set a marker in the undo
> queue and check if it's still up to date. Might be a better abstraction
> from the underlying implementation.
> 
> > I wouldn't mind either approach.
> 
> Let me know which one you guys are going to apply, and I'll whip it up.
> :)
> 
> 
> Meanwhile, could this patch be applied? It fixes a few cases where the
> composer isn't marked as dirty when it should be.
-- 
Radek Doulík <rodo ximian com>
Ximian, Inc.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/composer/ChangeLog,v
retrieving revision 1.544.2.16
diff -u -p -r1.544.2.16 ChangeLog
--- ChangeLog	6 Oct 2003 17:07:16 -0000	1.544.2.16
+++ ChangeLog	6 Nov 2003 14:48:10 -0000
@@ -1,3 +1,15 @@
+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-09-26  Jeffrey Stedfast  <fejj ximian com>
 
 	* e-msg-composer.c (save): Don't blindly claim that the file
Index: e-msg-composer.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.c,v
retrieving revision 1.395.2.8
diff -u -p -r1.395.2.8 e-msg-composer.c
--- e-msg-composer.c	6 Oct 2003 17:07:16 -0000	1.395.2.8
+++ e-msg-composer.c	6 Nov 2003 14:48:21 -0000
@@ -1218,9 +1218,10 @@ save (EMsgComposer *composer, const char
 		
 		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);
-
+		composer->autosaved = FALSE;
+	}
 	CORBA_exception_free (&ev);
 	
 	g_free (filename);
@@ -1320,6 +1321,12 @@ autosave_save_draft (EMsgComposer *compo
 			  _("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);
+		composer->autosaved = TRUE;
 	}
 	
 	camel_object_unref (stream);
@@ -1565,7 +1572,7 @@ do_exit (EMsgComposer *composer)
 	GtkWidget *dialog;
 	int button;
 	
-	if (!e_msg_composer_is_dirty (composer)) {
+	if (!e_msg_composer_is_dirty (composer) && !composer->autosaved) {
 		gtk_widget_destroy (GTK_WIDGET (composer));
 		return;
 	}
@@ -2707,6 +2714,7 @@ init (EMsgComposer *composer)
 	composer->smime_encrypt            = FALSE;
 	
 	composer->has_changed              = FALSE;
+	composer->autosaved                = FALSE;
 	
 	composer->redirect                 = FALSE;
 	
@@ -4908,6 +4916,7 @@ e_msg_composer_unset_changed (EMsgCompos
 	g_return_if_fail (E_IS_MSG_COMPOSER (composer));
 	
 	composer->has_changed = FALSE;
+	composer->autosaved = FALSE;
 }
 
 
Index: e-msg-composer.h
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.h,v
retrieving revision 1.83
diff -u -p -r1.83 e-msg-composer.h
--- e-msg-composer.h	20 May 2003 18:26:09 -0000	1.83
+++ e-msg-composer.h	6 Nov 2003 14:48:23 -0000
@@ -94,6 +94,7 @@ struct _EMsgComposer {
 	guint32 view_cc                : 1;
 	guint32 view_subject           : 1;
 	guint32 has_changed            : 1;
+	guint32 autosaved              : 1;
 	
 	guint32 mode_post              : 1;
 	
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
@@ -0,0 +0,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]