Re: [Fwd: [evolution-patches] [resend] patches for #20672 (gtkhtml and mailer)]
- From: Radek Doulík <rodo ximian com>
- To: Michel Dänzer <michel daenzer net>
- Cc: Patches <evolution-patches ximian com>
- Subject: Re: [Fwd: [evolution-patches] [resend] patches for #20672 (gtkhtml and mailer)]
- Date: Tue, 11 Nov 2003 12:49:20 +0100
On Sun, 2003-11-09 at 02:04, Michel Dänzer wrote:
> On Thu, 2003-11-06 at 16:02, Radek Doulík wrote:
> >
> > 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?
>
> It doesn't work very well; e.g. it doesn't autosave once after a
> composer is created,
that's a feature IIRC and my patch doesn't change that behavior. if it's
wanted it has to be done at composer creation time (force an autosave).
> and it degrades to autosaving every time after a
> header change.
right, but it's easy to fix, I forgot to unset changed flag after
autosave is done. I am attaching fixed patch, which also adds wrapper
methods for autosaved flag and separates resetting of changed and
autosaved flags.
> However, I was intrigued by the idea, and after a lot of thinking,
> fiddling and testing, I've finally arrived at a solution which works
> very well even without changing gtkhtml. :) The only minor caveat is
> that if you e.g.
>
> * save the message (as a draft or file)
> * make changes
> * let it autosave
> * undo the changes
> * close the composer
>
> it will no longer realise that the message is actually saved and prompt
> about unsaved changes; similarly for autosave-change-save-undo-autosave,
> but that's even less of an issue. Negligible corner cases IMHO.
>
> I'm curious what you guys think about this.
I found your patch unnecessarily complicated, sorry. I think the
attached patch should work OK now. Do you see any other issues it has?
Best wishes
Radek
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 11 Nov 2003 11:34:19 -0000
@@ -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-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 11 Nov 2003 11:34:30 -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);
-
+ e_msg_composer_unset_autosaved (composer);
+ }
CORBA_exception_free (&ev);
g_free (filename);
@@ -1271,7 +1272,7 @@ autosave_save_draft (EMsgComposer *compo
if (!e_msg_composer_is_dirty (composer))
return TRUE;
-
+
fd = composer->autosave_fd;
file = composer->autosave_file;
@@ -1320,6 +1321,13 @@ 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);
+ e_msg_composer_unset_changed (composer);
+ e_msg_composer_set_autosaved (composer);
}
camel_object_unref (stream);
@@ -1554,6 +1562,7 @@ menu_file_save_draft_cb (BonoboUICompone
{
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.) */
@@ -1565,7 +1574,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;
}
@@ -1596,6 +1605,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 */
@@ -2707,6 +2717,7 @@ init (EMsgComposer *composer)
composer->smime_encrypt = FALSE;
composer->has_changed = FALSE;
+ composer->autosaved = FALSE;
composer->redirect = FALSE;
@@ -4910,7 +4921,6 @@ e_msg_composer_unset_changed (EMsgCompos
composer->has_changed = FALSE;
}
-
gboolean
e_msg_composer_is_dirty (EMsgComposer *composer)
{
@@ -4926,6 +4936,44 @@ e_msg_composer_is_dirty (EMsgComposer *c
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)
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 11 Nov 2003 11:34:30 -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;
@@ -181,6 +182,9 @@ char *e_msg_composer_
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]