gnome-applets r11115 - trunk/stickynotes



Author: callum
Date: Sun Nov  9 04:13:52 2008
New Revision: 11115
URL: http://svn.gnome.org/viewvc/gnome-applets?rev=11115&view=rev

Log:
Reduce stickynotes I/O by batching saves of the configuration to once per minutes (or applet deletion. See bug 458902.

Modified:
   trunk/stickynotes/ChangeLog
   trunk/stickynotes/stickynotes.c
   trunk/stickynotes/stickynotes.h
   trunk/stickynotes/stickynotes_applet_callbacks.c

Modified: trunk/stickynotes/stickynotes.c
==============================================================================
--- trunk/stickynotes/stickynotes.c	(original)
+++ trunk/stickynotes/stickynotes.c	Sun Nov  9 04:13:52 2008
@@ -35,6 +35,8 @@
 /* Stop gcc complaining about xmlChar's signedness */
 #define XML_CHAR(str) ((xmlChar *) (str))
 
+static gboolean save_scheduled = FALSE;
+
 static void response_cb (GtkWidget *dialog, gint id, gpointer data);
 
 /* Based on a function found in wnck */
@@ -716,7 +718,7 @@
 
 /* Save all sticky notes in an XML configuration file */
 void
-stickynotes_save (void)
+stickynotes_save_now (void)
 {
 	WnckScreen *wnck_screen;
 	const gchar *title;
@@ -821,6 +823,18 @@
 	}
 	
 	xmlFreeDoc(doc);
+
+	save_scheduled = FALSE;
+}
+
+void
+stickynotes_save (void)
+{
+  /* If a save isn't already schedules, save everything a minute from now. */
+  if (!save_scheduled) {
+    g_timeout_add (60*1000, (GSourceFunc) stickynotes_save_now, NULL);
+    save_scheduled = TRUE;
+  }
 }
 
 /* Load all sticky notes from an XML configuration file */

Modified: trunk/stickynotes/stickynotes.h
==============================================================================
--- trunk/stickynotes/stickynotes.h	(original)
+++ trunk/stickynotes/stickynotes.h	Sun Nov  9 04:13:52 2008
@@ -87,6 +87,7 @@
 void stickynotes_add(GdkScreen *screen);
 void stickynotes_remove(StickyNote *note);
 void stickynotes_save(void);
+void stickynotes_save_now (void);
 void stickynotes_load(GdkScreen *screen);
 
 #endif /* __STICKYNOTES_H__ */

Modified: trunk/stickynotes/stickynotes_applet_callbacks.c
==============================================================================
--- trunk/stickynotes/stickynotes_applet_callbacks.c	(original)
+++ trunk/stickynotes/stickynotes_applet_callbacks.c	Sun Nov  9 04:13:52 2008
@@ -241,6 +241,8 @@
 {
 	GList *notes;
 	
+	stickynotes_save_now ();
+
 	if (applet->destroy_all_dialog != NULL)
 		gtk_widget_destroy (applet->destroy_all_dialog);
 



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