Update bookmark for export from sqlite database

This commit is contained in:
Alexander Butenko 2010-07-23 13:51:28 -04:00 committed by Christian Dywan
parent 5e250cc70d
commit 9e3e3fc491
2 changed files with 37 additions and 0 deletions

View 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,

View 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,