Introduce midori_array_query_recursive
This effectively fixes bookmark export. Fixes: https://bugs.launchpad.net/bugs/906837
This commit is contained in:
parent
5261fdcf87
commit
81250720de
3 changed files with 60 additions and 15 deletions
|
@ -1067,28 +1067,32 @@ katze_array_from_sqlite (sqlite3* db,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* midori_array_query:
|
* midori_array_query_recursive:
|
||||||
* @array: the main bookmark array
|
* @array: the main bookmark array
|
||||||
* @fields: comma separated list of fields
|
* @fields: comma separated list of fields
|
||||||
* @condition: condition, like "folder = '%q'"
|
* @condition: condition, like "folder = '%q'"
|
||||||
* @value: a value to be inserted if @condition contains %q
|
* @value: a value to be inserted if @condition contains %q
|
||||||
|
* @recursive: if %TRUE include children
|
||||||
*
|
*
|
||||||
* Stores the result in a #KatzeArray.
|
* Stores the result in a #KatzeArray.
|
||||||
*
|
*
|
||||||
* Return value: a #KatzeArray on success, %NULL otherwise
|
* Return value: a #KatzeArray on success, %NULL otherwise
|
||||||
*
|
*
|
||||||
* Since: 0.4.3
|
* Since: 0.4.4
|
||||||
**/
|
**/
|
||||||
KatzeArray*
|
KatzeArray*
|
||||||
midori_array_query (KatzeArray* bookmarks,
|
midori_array_query_recursive (KatzeArray* bookmarks,
|
||||||
const gchar* fields,
|
const gchar* fields,
|
||||||
const gchar* condition,
|
const gchar* condition,
|
||||||
const gchar* value)
|
const gchar* value,
|
||||||
|
gboolean recursive)
|
||||||
{
|
{
|
||||||
sqlite3* db;
|
sqlite3* db;
|
||||||
gchar* sqlcmd;
|
gchar* sqlcmd;
|
||||||
char* sqlcmd_value;
|
char* sqlcmd_value;
|
||||||
KatzeArray* array;
|
KatzeArray* array;
|
||||||
|
KatzeItem* item;
|
||||||
|
GList* list;
|
||||||
|
|
||||||
g_return_val_if_fail (KATZE_IS_ARRAY (bookmarks), NULL);
|
g_return_val_if_fail (KATZE_IS_ARRAY (bookmarks), NULL);
|
||||||
g_return_val_if_fail (fields, NULL);
|
g_return_val_if_fail (fields, NULL);
|
||||||
|
@ -1108,6 +1112,47 @@ midori_array_query (KatzeArray* bookmarks,
|
||||||
else
|
else
|
||||||
array = katze_array_from_sqlite (db, sqlcmd);
|
array = katze_array_from_sqlite (db, sqlcmd);
|
||||||
g_free (sqlcmd);
|
g_free (sqlcmd);
|
||||||
|
|
||||||
|
if (!recursive)
|
||||||
|
return array;
|
||||||
|
|
||||||
|
KATZE_ARRAY_FOREACH_ITEM_L (item, array, list)
|
||||||
|
{
|
||||||
|
if (KATZE_ITEM_IS_FOLDER (item))
|
||||||
|
{
|
||||||
|
KatzeArray* subarray = midori_array_query_recursive (bookmarks,
|
||||||
|
fields, "folder='%q'", item->name, TRUE);
|
||||||
|
katze_item_set_name (KATZE_ITEM (subarray), item->name);
|
||||||
|
katze_array_add_item (array, subarray);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
katze_array_add_item (array, item);
|
||||||
|
}
|
||||||
|
g_list_free (list);
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* midori_array_query:
|
||||||
|
* @array: the main bookmark array
|
||||||
|
* @fields: comma separated list of fields
|
||||||
|
* @condition: condition, like "folder = '%q'"
|
||||||
|
* @value: a value to be inserted if @condition contains %q
|
||||||
|
*
|
||||||
|
* Stores the result in a #KatzeArray.
|
||||||
|
*
|
||||||
|
* Return value: a #KatzeArray on success, %NULL otherwise
|
||||||
|
*
|
||||||
|
* Since: 0.4.3
|
||||||
|
*
|
||||||
|
* Deprecated: 0.4.4: Use midori_array_query_recursive() instead.
|
||||||
|
**/
|
||||||
|
KatzeArray*
|
||||||
|
midori_array_query (KatzeArray* bookmarks,
|
||||||
|
const gchar* fields,
|
||||||
|
const gchar* condition,
|
||||||
|
const gchar* value)
|
||||||
|
{
|
||||||
|
return midori_array_query_recursive (bookmarks, fields, condition, value, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,13 @@ midori_array_query (KatzeArray* array,
|
||||||
const gchar* condition,
|
const gchar* condition,
|
||||||
const gchar* value);
|
const gchar* value);
|
||||||
|
|
||||||
|
KatzeArray*
|
||||||
|
midori_array_query_recursive (KatzeArray* array,
|
||||||
|
const gchar* fields,
|
||||||
|
const gchar* condition,
|
||||||
|
const gchar* value,
|
||||||
|
gboolean recursive);
|
||||||
|
|
||||||
KatzeArray*
|
KatzeArray*
|
||||||
katze_array_from_sqlite (sqlite3* db,
|
katze_array_from_sqlite (sqlite3* db,
|
||||||
const gchar* sqlcmd);
|
const gchar* sqlcmd);
|
||||||
|
|
|
@ -177,11 +177,6 @@ midori_bookmarks_import_array_db (sqlite3* db,
|
||||||
KatzeArray* array,
|
KatzeArray* array,
|
||||||
gchar* folder);
|
gchar* folder);
|
||||||
|
|
||||||
void
|
|
||||||
midori_bookmarks_export_array_db (sqlite3* db,
|
|
||||||
KatzeArray* array,
|
|
||||||
const gchar* folder);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
midori_browser_open_bookmark (MidoriBrowser* browser,
|
midori_browser_open_bookmark (MidoriBrowser* browser,
|
||||||
KatzeItem* item);
|
KatzeItem* item);
|
||||||
|
@ -4348,7 +4343,6 @@ _action_bookmarks_export_activate (GtkAction* action,
|
||||||
const gchar* format;
|
const gchar* format;
|
||||||
gchar* path = NULL;
|
gchar* path = NULL;
|
||||||
GError* error;
|
GError* error;
|
||||||
sqlite3* db;
|
|
||||||
KatzeArray* bookmarks;
|
KatzeArray* bookmarks;
|
||||||
|
|
||||||
if (!browser->bookmarks || !gtk_widget_get_visible (GTK_WIDGET (browser)))
|
if (!browser->bookmarks || !gtk_widget_get_visible (GTK_WIDGET (browser)))
|
||||||
|
@ -4389,9 +4383,8 @@ wrong_format:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
db = g_object_get_data (G_OBJECT (browser->history), "db");
|
bookmarks = midori_array_query_recursive (browser->bookmarks,
|
||||||
bookmarks = katze_array_new (KATZE_TYPE_ARRAY);
|
"*", "folder='%q'", "", TRUE);
|
||||||
midori_bookmarks_export_array_db (db, bookmarks, "");
|
|
||||||
if (!midori_array_to_file (bookmarks, path, format, &error))
|
if (!midori_array_to_file (bookmarks, path, format, &error))
|
||||||
{
|
{
|
||||||
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
||||||
|
|
Loading…
Reference in a new issue