Index: gnome-applets/stickynotes/ChangeLog
===================================================================
--- gnome-applets.orig/stickynotes/ChangeLog
+++ gnome-applets/stickynotes/ChangeLog
@@ -1,3 +1,17 @@
+2006-10-11  Tom Tromey  <tromey@redhat.com>
+
+	Bug #340769:
+	* stickynotes.schemas.in: Removed autosave_time.
+	* stickynotes_applet_callbacks.h (applet_save_cb): Removed.
+	* stickynotes_applet_callbacks.c (applet_save_cb): Removed.
+	* stickynotes.c (timeout_happened): New function.
+	(buffer_changed): Likewise.
+	(stickynote_new_aux): Attach to 'changed' signal on text buffer.
+	* stickynotes_applet.c (stickynotes_applet_init): Initialize new
+	field.  Don't install timeout.
+	* stickynotes_applet.h (StickyNotes): Added 'last_timeout_data'
+	field.
+
 2006-10-09  Tom Tromey  <tromey@redhat.com>
 
 	Bug #340766:
Index: gnome-applets/stickynotes/stickynotes.c
===================================================================
--- gnome-applets.orig/stickynotes/stickynotes.c
+++ gnome-applets/stickynotes/stickynotes.c
@@ -61,6 +61,27 @@ set_icon_geometry  (GdkWindow *window,
                        (guchar *)&data, 4);
 }
 
+/* Called when a timeout occurs.  */
+static gboolean
+timeout_happened (gpointer data)
+{
+	if (GPOINTER_TO_UINT (data) == stickynotes->last_timeout_data)
+		stickynotes_save ();
+	return FALSE;
+}
+
+/* Called when a text buffer is changed.  */
+static void
+buffer_changed (GtkTextBuffer *buffer, gpointer data)
+{
+	/* When a buffer is changed, we set a 10 second timer.  When
+	   the timer triggers, we will save the buffer if there have
+	   been no subsequent changes.  */
+	++stickynotes->last_timeout_data;
+	g_timeout_add (1000 * 10, (GSourceFunc) timeout_happened,
+		       GUINT_TO_POINTER (stickynotes->last_timeout_data));
+}
+
 /* Create a new (empty) Sticky Note at a specific position 
    and with specific size */
 StickyNote *
@@ -250,6 +271,10 @@ stickynote_new_aux (GdkScreen *screen, g
 	g_object_unref(menu);
 	g_object_unref(window);
 
+	g_signal_connect (gtk_text_view_get_buffer(GTK_TEXT_VIEW(note->w_body)),
+			  "changed",
+			  G_CALLBACK (buffer_changed), NULL);
+
 	return note;
 }
 
Index: gnome-applets/stickynotes/stickynotes_applet.c
===================================================================
--- gnome-applets.orig/stickynotes/stickynotes_applet.c
+++ gnome-applets/stickynotes/stickynotes_applet.c
@@ -129,6 +129,7 @@ stickynotes_applet_init (PanelApplet *pa
 
 	stickynotes->notes = NULL;
 	stickynotes->applets = NULL;
+	stickynotes->last_timeout_data = 0;
 
 	/* Register size for icons */
 	gtk_icon_size_register ("stickynotes_icon_size", 8,8);
@@ -176,16 +177,6 @@ stickynotes_applet_init (PanelApplet *pa
 	/* Load sticky notes */
 	stickynotes_load (gtk_widget_get_screen (GTK_WIDGET (panel_applet)));
 	
-	/* Auto-save every so minutes (default 5) */
-	timeout = gconf_client_get_int (stickynotes->gconf,
-				GCONF_PATH "/settings/autosave_time", NULL);
-	if (timeout <= 0)
-	{
-		g_warning ("No default timeout, is the schema installed?");
-		timeout = 5;
-	}
-	g_timeout_add (1000 * 60 * timeout,
-		      (GSourceFunc) applet_save_cb, NULL);
 	install_check_click_on_desktop ();
 }
 
Index: gnome-applets/stickynotes/stickynotes_applet.h
===================================================================
--- gnome-applets.orig/stickynotes/stickynotes_applet.h
+++ gnome-applets/stickynotes/stickynotes_applet.h
@@ -65,6 +65,8 @@ typedef struct
 
 	GConfClient *gconf;		/* GConf Client */
 	GtkTooltips *tooltips;		/* Tooltips */
+
+	guint last_timeout_data;
 } StickyNotes;
 
 /* Sticky Notes Icons */
Index: gnome-applets/stickynotes/stickynotes_applet_callbacks.c
===================================================================
--- gnome-applets.orig/stickynotes/stickynotes_applet_callbacks.c
+++ gnome-applets/stickynotes/stickynotes_applet_callbacks.c
@@ -132,14 +132,6 @@ gboolean applet_focus_cb(GtkWidget *widg
 	return FALSE;
 }
 
-/* Applet Callback : Save all sticky notes. */
-gboolean applet_save_cb(StickyNotesApplet *applet)
-{
-	stickynotes_save();
-
-	return TRUE;
-}
-
 static GdkFilterReturn desktop_window_event_filter (GdkXEvent *xevent,
 						    GdkEvent  *event,
 						    gpointer   data)
Index: gnome-applets/stickynotes/stickynotes_applet_callbacks.h
===================================================================
--- gnome-applets.orig/stickynotes/stickynotes_applet_callbacks.h
+++ gnome-applets/stickynotes/stickynotes_applet_callbacks.h
@@ -27,7 +27,6 @@ gboolean applet_button_cb(GtkWidget *wid
 gboolean applet_key_cb(GtkWidget *widget, GdkEventKey *event, StickyNotesApplet *applet);
 gboolean applet_cross_cb(GtkWidget *widget, GdkEventCrossing *event, StickyNotesApplet *applet);
 gboolean applet_focus_cb(GtkWidget *widget, GdkEventFocus *event, StickyNotesApplet *applet);
-gboolean applet_save_cb(StickyNotesApplet *applet);
 void install_check_click_on_desktop (void);
 void applet_change_orient_cb(PanelApplet *panel_applet, PanelAppletOrient orient, StickyNotesApplet *applet);
 void applet_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, StickyNotesApplet *applet);
Index: gnome-applets/stickynotes/stickynotes.schemas.in
===================================================================
--- gnome-applets.orig/stickynotes/stickynotes.schemas.in
+++ gnome-applets/stickynotes/stickynotes.schemas.in
@@ -86,18 +86,6 @@
 </schema>
 
 <schema>
-	<key>/schemas/apps/stickynotes_applet/settings/autosave_time</key>
-	<applyto>/apps/stickynotes_applet/settings/autosave_time</applyto>
-	<owner>stickynotes_applet</owner>
-	<type>int</type>
-	<default>5</default>
-	<locale name="C">
-		<short>Autosave timeout in minutes</short>
-		<long>Every time the specified number of minutes pass, the sticky notes are automatically saved.</long>
-	</locale>
-</schema>
-
-<schema>
 	<key>/schemas/apps/stickynotes_applet/settings/date_format</key>
 	<applyto>/apps/stickynotes_applet/settings/date_format</applyto>
 	<owner>stickynotes_applet</owner>
