[Xfce4-commits] <midori:master> Update bookmark for export from sqlite database

Christian Dywan noreply at xfce.org
Fri Jul 23 22:06:10 CEST 2010


Updating branch refs/heads/master
         to 9e3e3fc4916362a1e3a58cc7de27c53ad9c3280a (commit)
       from 5e250cc70d97d02b4eb397eaffd0c4a02140f0b3 (commit)

commit 9e3e3fc4916362a1e3a58cc7de27c53ad9c3280a
Author: Alexander Butenko <a.butenka at gmail.com>
Date:   Fri Jul 23 13:51:28 2010 -0400

    Update bookmark for export from sqlite database

 midori/midori-browser.c   |    8 ++++++++
 panels/midori-bookmarks.c |   29 +++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 097a470..5caa48a 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -174,6 +174,11 @@ midori_bookmarks_import_array_db (sqlite3*    db,
                                   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,
                                  gchar*     folder);
@@ -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,
diff --git a/panels/midori-bookmarks.c b/panels/midori-bookmarks.c
index 128848d..1f94c89 100644
--- a/panels/midori-bookmarks.c
+++ b/panels/midori-bookmarks.c
@@ -123,6 +123,35 @@ midori_bookmarks_get_stock_id (MidoriViewable* viewable)
 }
 
 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,
                                   const gchar* folder)



More information about the Xfce4-commits mailing list