]> spindle.queued.net Git - midori/commitdiff
Update bookmark for export from sqlite database
authorAlexander Butenko <a.butenka@gmail.com>
Fri, 23 Jul 2010 17:51:28 +0000 (13:51 -0400)
committerChristian Dywan <christian@twotoasts.de>
Fri, 23 Jul 2010 20:04:43 +0000 (22:04 +0200)
midori/midori-browser.c
panels/midori-bookmarks.c

index 097a470ffde075d10cfb70201468d57cf9b1ff1b..5caa48a2a8da369c2faf1ca3bf88c3029e916f22 100644 (file)
@@ -173,6 +173,11 @@ midori_bookmarks_import_array_db (sqlite3*    db,
                                   KatzeArray* array,
                                   gchar*      folder);
 
+void
+midori_bookmarks_export_array_db (sqlite3*     db,
+                                  KatzeArray*  array,
+                                  const gchar* folder);
+
 void
 midori_bookmarks_insert_item_db (sqlite3*   db,
                                  KatzeItem* item,
@@ -4110,6 +4115,7 @@ _action_bookmarks_export_activate (GtkAction*     action,
     GtkWidget* file_dialog;
     gchar* path = NULL;
     GError* error;
+    sqlite3* db;
 
     if (!browser->bookmarks || !gtk_widget_get_visible (GTK_WIDGET (browser)))
         return;
@@ -4126,6 +4132,8 @@ _action_bookmarks_export_activate (GtkAction*     action,
         return;
 
     error = NULL;
+    db = g_object_get_data (G_OBJECT (browser->history), "db");
+    midori_bookmarks_export_array_db (db, browser->bookmarks, "");
     if (!midori_array_to_file (browser->bookmarks, path, "xbel", &error))
     {
         sokoke_message_dialog (GTK_MESSAGE_ERROR,
index 128848d82c625d60fd8dc263f58f367794adb2c4..1f94c897ce6be2761d46b9e8396ee5ae7732b58c 100644 (file)
@@ -122,6 +122,35 @@ midori_bookmarks_get_stock_id (MidoriViewable* viewable)
     return STOCK_BOOKMARKS;
 }
 
+void
+midori_bookmarks_export_array_db (sqlite3*     db,
+                                  KatzeArray*  array,
+                                  const gchar* folder)
+{
+    gchar* sqlcmd;
+    KatzeArray* root_array;
+    KatzeArray* subarray;
+    KatzeItem* item;
+    int i = 0;
+
+    sqlcmd = g_strdup_printf ("SELECT * FROM bookmarks where folder='%s'", folder);
+    root_array = katze_array_from_sqlite (db, sqlcmd);
+    g_free (sqlcmd);
+
+    while ((item = katze_array_get_nth_item (KATZE_ARRAY (root_array), i++)))
+    {
+        if (KATZE_ITEM_IS_FOLDER (item))
+        {
+            subarray = katze_array_new (KATZE_TYPE_ARRAY);
+            katze_item_set_name (KATZE_ITEM (subarray), katze_item_get_name (item));
+            midori_bookmarks_export_array_db (db, subarray, katze_item_get_name (item));
+            katze_array_add_item (array, subarray);
+        }
+        else
+            katze_array_add_item (array, item);
+    }
+}
+
 void
 midori_bookmarks_import_array_db (sqlite3*     db,
                                   KatzeArray*  array,