diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 097a470f..5caa48a2 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -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, diff --git a/panels/midori-bookmarks.c b/panels/midori-bookmarks.c index 128848d8..1f94c897 100644 --- a/panels/midori-bookmarks.c +++ b/panels/midori-bookmarks.c @@ -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,