From f55377e7f3f0068144c1e9707c37184122facacb Mon Sep 17 00:00:00 2001 From: Alexander Butenko Date: Mon, 14 Jun 2010 03:00:05 -0400 Subject: [PATCH] Fix selecting a directory while adding a new bookmark Allow folders to be removed --- TODO | 3 +-- midori/midori-browser.c | 35 ++++++++++++++++++++++------------- panels/midori-bookmarks.c | 4 +++- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/TODO b/TODO index 212bae12..6d51e175 100644 --- a/TODO +++ b/TODO @@ -98,5 +98,4 @@ BOOKMARK ISSUES: . Bookmark toolbar is broken . Import is broken . Integration with locationbar search - . Can't remove folder - . Can't select folder while adding new bookmark + . Remove separator from submenu before showing it diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 7d73626b..b3d8bce7 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -720,10 +720,17 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser, GtkWidget* combo_folder; GtkWidget* check_toolbar; GtkWidget* check_app; + #if HAVE_SQLITE + sqlite3* db; + #endif if (!browser->bookmarks || !gtk_widget_get_visible (GTK_WIDGET (browser))) return; + #if HAVE_SQLITE + db = g_object_get_data (G_OBJECT (browser->bookmarks), "db"); + #endif + if (is_folder) title = new_bookmark ? _("New folder") : _("Edit folder"); else @@ -815,8 +822,12 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser, { GtkListStore* model; GtkCellRenderer* renderer; - KatzeItem* item; + #if HAVE_SQLITE guint i, n; + sqlite3_stmt* statement; + gint result; + const gchar* sqlcmd; + #endif hbox = gtk_hbox_new (FALSE, 8); gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); @@ -833,22 +844,25 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser, 0, _("Toplevel folder"), 1, PANGO_ELLIPSIZE_END, -1); gtk_combo_box_set_active (GTK_COMBO_BOX (combo_folder), 0); + #if HAVE_SQLITE i = 0; n = 1; - while ((item = katze_array_get_nth_item (browser->bookmarks, i++))) + sqlcmd = "SELECT title from bookmarks where type=0"; + result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL); + while ((result = sqlite3_step (statement)) == SQLITE_ROW) { - if (KATZE_IS_ARRAY (item) && item != bookmark) - { - const gchar* name = katze_item_get_name (item); + const unsigned char* name = sqlite3_column_text (statement, 0); gtk_list_store_insert_with_values (model, NULL, G_MAXINT, 0, name, 1, PANGO_ELLIPSIZE_END, -1); - if (katze_item_get_parent (bookmark) == item) - gtk_combo_box_set_active (GTK_COMBO_BOX (combo_folder), n); + /* FIXME: Not working */ + /*if (katze_item_get_parent (bookmark) == item) + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_folder), n);*/ n++; - } } if (n < 2) gtk_widget_set_sensitive (combo_folder, FALSE); + #endif + gtk_box_pack_start (GTK_BOX (hbox), combo_folder, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (content_area), hbox); gtk_widget_show_all (hbox); @@ -902,11 +916,6 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser, { 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))); diff --git a/panels/midori-bookmarks.c b/panels/midori-bookmarks.c index 8c9c71ff..598e94b2 100644 --- a/panels/midori-bookmarks.c +++ b/panels/midori-bookmarks.c @@ -274,7 +274,9 @@ midori_bookmarks_remove_item_from_db (sqlite3* db, katze_item_get_uri (item)); else sqlcmd = sqlite3_mprintf ( - "DELETE FROM bookmarks WHERE folder = '%q'", katze_item_get_name (item)); + "DELETE FROM bookmarks WHERE folder = '%q' OR title = '%q'", + katze_item_get_name (item), + katze_item_get_name (item)); if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK) { -- 2.39.5