]> spindle.queued.net Git - midori/commitdiff
Wrap session saving in a 5 second timeout
authorChristian Dywan <christian@twotoasts.de>
Wed, 2 Sep 2009 21:54:53 +0000 (23:54 +0200)
committerChristian Dywan <christian@twotoasts.de>
Wed, 2 Sep 2009 21:58:53 +0000 (23:58 +0200)
midori/main.c

index 56d69e8fb5fcc140ef38f736b7bdad58cbdcd7c7..7608ad42df6abfab0c630a81fc3caed1cc3b530a 100644 (file)
@@ -978,10 +978,10 @@ midori_app_add_browser_cb (MidoriApp*     app,
     g_object_unref (panel);
 }
 
-static void
-midori_browser_session_cb (MidoriBrowser* browser,
-                           gpointer       pspec,
-                           KatzeArray*    session)
+static guint save_timeout = 0;
+
+static gboolean
+midori_session_save_timeout_cb (KatzeArray* session)
 {
     gchar* config_file;
     GError* error;
@@ -994,6 +994,24 @@ midori_browser_session_cb (MidoriBrowser* browser,
         g_error_free (error);
     }
     g_free (config_file);
+
+    save_timeout = 0;
+    g_object_unref (session);
+
+    return FALSE;
+}
+
+static void
+midori_browser_session_cb (MidoriBrowser* browser,
+                           gpointer       pspec,
+                           KatzeArray*    session)
+{
+    if (!save_timeout)
+    {
+        g_object_ref (session);
+        save_timeout = g_timeout_add_full (G_PRIORITY_LOW, 5000,
+            (GSourceFunc)midori_session_save_timeout_cb, session, NULL);
+    }
 }
 
 static void