]> spindle.queued.net Git - midori/commitdiff
Do monitor changes of bookmarks and save on any change
authorChristian Dywan <christian@twotoasts.de>
Fri, 16 Jan 2009 04:04:42 +0000 (05:04 +0100)
committerChristian Dywan <christian@twotoasts.de>
Fri, 16 Jan 2009 04:04:42 +0000 (05:04 +0100)
midori/main.c

index 0a84b1e8a76a235cd16fdf708e3a24955d74e27a..f15f6304008ad9242705cb8f8a01287e6d929b3f 100644 (file)
@@ -1048,6 +1048,24 @@ katze_array_to_file (KatzeArray*  array,
     return TRUE;
 }
 
+static void
+midori_bookmarks_notify_item_cb (KatzeArray* folder,
+                                 GParamSpec* pspec,
+                                 KatzeArray* bookmarks)
+{
+    gchar* config_file;
+    GError* error;
+
+    config_file = build_config_filename ("bookmarks.xbel");
+    error = NULL;
+    if (!katze_array_to_file (bookmarks, config_file, &error))
+    {
+        g_warning (_("The bookmarks couldn't be saved. %s"), error->message);
+        g_error_free (error);
+    }
+    g_free (config_file);
+}
+
 static void
 midori_bookmarks_add_item_cb (KatzeArray* folder,
                               GObject*    item,
@@ -1081,6 +1099,9 @@ midori_bookmarks_add_item_cb (KatzeArray* folder,
         g_signal_connect_after (item, "remove-item",
             G_CALLBACK (midori_bookmarks_remove_item_cb), NULL);
     }
+
+    g_signal_connect_after (item, "notify",
+        G_CALLBACK (midori_bookmarks_notify_item_cb), NULL);
 }
 
 static void
@@ -2197,6 +2218,8 @@ main (int    argc,
                 g_signal_connect_after (item, "remove-item",
                     G_CALLBACK (midori_bookmarks_remove_item_cb), NULL);
             }
+            g_signal_connect_after (item, "notify",
+                G_CALLBACK (midori_bookmarks_notify_item_cb), bookmarks);
         }
     }
     g_signal_connect_after (trash, "add-item",