GValue* value,
GParamSpec* pspec);
+#if HAVE_SQLITE
+void
+midori_bookmarks_insert_item_db (sqlite3* db,
+ KatzeItem* item,
+ gchar* folder);
+
+void
+midori_bookmarks_remove_item_from_db (sqlite3* db,
+ KatzeItem* item);
+#endif
+
static void
midori_browser_new_history_item (MidoriBrowser* browser,
KatzeItem** item);
{
gchar* selected;
KatzeArray* folder;
+ #if HAVE_SQLITE
+ sqlite3* db;
+
+ db = g_object_get_data (G_OBJECT (browser->bookmarks), "db");
+ #endif
katze_item_set_name (bookmark,
gtk_entry_get_text (GTK_ENTRY (entry_title)));
folder = browser->bookmarks;
selected = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combo_folder));
- if (strcmp (selected, _("Toplevel folder")))
- {
- guint i = 0;
- KatzeItem* item;
- while ((item = katze_array_get_nth_item (browser->bookmarks, i++)))
- if (KATZE_IS_ARRAY (item))
- if (!g_strcmp0 (katze_item_get_name (item), selected))
- {
- folder = KATZE_ARRAY (item);
- break;
- }
- }
+
+ #if HAVE_SQLITE
+ midori_bookmarks_remove_item_from_db (db, bookmark);
+ if (!strcmp (selected, _("Toplevel folder")))
+ midori_bookmarks_insert_item_db (db, bookmark, "");
+ else
+ midori_bookmarks_insert_item_db (db, bookmark, selected);
+ #endif
g_free (selected);
- if (folder != katze_item_get_parent (bookmark) && folder != browser->bookmarks)
- {
- katze_array_remove_item (katze_item_get_parent (bookmark), bookmark);
- new_bookmark = TRUE;
- }
- if (new_bookmark)
- katze_array_add_item (folder, bookmark);
}
gtk_widget_destroy (dialog);
}
if (KATZE_IS_ARRAY (list->data))
midori_bookmarks_import_array_db (list->data, db);
item = (KatzeItem*) list->data;
- midori_bookmarks_insert_item_db (db, item);
+ midori_bookmarks_insert_item_db (db, item, NULL);
}
}
void
midori_bookmarks_insert_item_db (sqlite3* db,
- KatzeItem* item)
+ KatzeItem* item,
+ gchar* folder)
{
gchar* sqlcmd;
char* errmsg = NULL;
else
type = 0;
- if (katze_item_get_name (katze_item_get_parent (item)))
+ if (folder)
+ parent = g_strdup (folder);
+ else if (katze_item_get_name (katze_item_get_parent (item)))
parent = g_strdup (katze_item_get_name (katze_item_get_parent (item)));
else
parent = g_strdup ("");
sqlite3_free (sqlcmd);
}
-static void
-midori_bookmarks_remove_item_from_db (MidoriBookmarks* bookmarks,
- KatzeItem* item)
+void
+midori_bookmarks_remove_item_from_db (sqlite3* db,
+ KatzeItem* item)
{
gchar* sqlcmd;
- sqlite3* db;
char* errmsg = NULL;
- db = g_object_get_data (G_OBJECT (bookmarks->array), "db");
-
if (katze_item_get_uri (item))
sqlcmd = sqlite3_mprintf (
- "DELETE FROM bookmarks WHERE uri = '%q' AND"
- " title = '%q'",
- katze_item_get_uri (item),
- katze_item_get_name (item));
+ "DELETE FROM bookmarks WHERE uri = '%q'",
+ katze_item_get_uri (item));
else
sqlcmd = sqlite3_mprintf (
"DELETE FROM bookmarks WHERE folder = '%q'", katze_item_get_name (item));
sqlite3_free (errmsg);
}
- g_debug ("%s", sqlcmd);
sqlite3_free (sqlcmd);
}
#endif
gtk_tree_model_get (model, &iter, 0, &item, -1);
- is_separator = !KATZE_IS_ARRAY (item) && !katze_item_get_uri (item);
+ is_separator = item && !katze_item_get_uri (item);
if (!is_separator)
{
MidoriBrowser* browser = midori_browser_get_for_widget (toolitem);
midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, FALSE);
}
-
g_object_unref (item);
}
}
{
GtkTreeModel* model;
GtkTreeIter iter;
+ #if HAVE_SQLITE
+ sqlite3* db;
+
+ db = g_object_get_data (G_OBJECT (bookmarks->array), "db");
+ #endif
if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (bookmarks->treeview),
&model, &iter))
gtk_tree_model_get (model, &iter, 0, &item, -1);
#if HAVE_SQLITE
- midori_bookmarks_remove_item_from_db (bookmarks, item);
+ midori_bookmarks_remove_item_from_db (db, item);
#endif
gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
MidoriBookmarks* bookmarks)
{
KatzeItem* item;
+ #if HAVE_SQLITE
+ sqlite3* db;
+ #endif
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
#if HAVE_SQLITE
- midori_bookmarks_remove_item_from_db (bookmarks, item);
+ db = g_object_get_data (G_OBJECT (bookmarks->array), "db");
+ midori_bookmarks_remove_item_from_db (db, item);
#endif
/* FIXME: Refresh menu */
}