From 09d9615964ee2536d994f949279b87a371a57564 Mon Sep 17 00:00:00 2001 From: Alexander Butenko Date: Mon, 14 Jun 2010 02:39:42 -0400 Subject: [PATCH] Refresh bookmark sidebar on new items --- TODO | 3 ++- midori/midori-browser.c | 10 ++++++++++ panels/midori-bookmarks.c | 19 +++++++++++++------ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index 67a6603f..212bae12 100644 --- a/TODO +++ b/TODO @@ -94,8 +94,9 @@ TODO: BOOKMARK ISSUES: . Show on toolbar is not working - . Refresh of sidebar is not done . Bookmark menu is not populated . Bookmark toolbar is broken . Import is broken . Integration with locationbar search + . Can't remove folder + . Can't select folder while adding new bookmark diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 2628cf5a..7d73626b 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -935,7 +935,17 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser, #if HAVE_SQLITE midori_bookmarks_remove_item_from_db (db, bookmark); if (!strcmp (selected, _("Toplevel folder"))) + { + GtkTreeView* treeview; + GtkTreeModel* model; + midori_bookmarks_insert_item_db (db, bookmark, ""); + treeview = g_object_get_data (G_OBJECT (browser->bookmarks), "treeview"); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview)); + /* FIXME: We need to add item in the end of the list */ + gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), + NULL, NULL, 999, 0, bookmark, -1); + } else midori_bookmarks_insert_item_db (db, bookmark, selected); #endif diff --git a/panels/midori-bookmarks.c b/panels/midori-bookmarks.c index 68731d65..8c9c71ff 100644 --- a/panels/midori-bookmarks.c +++ b/panels/midori-bookmarks.c @@ -474,6 +474,7 @@ midori_bookmarks_set_app (MidoriBookmarks* bookmarks, g_object_ref (app); bookmarks->array = katze_object_get_object (app, "bookmarks"); + g_object_set_data (G_OBJECT (bookmarks->array), "treeview", bookmarks->treeview); #if HAVE_SQLITE midori_bookmarks_read_from_db (bookmarks, GTK_TREE_STORE (model), NULL, ""); @@ -729,13 +730,19 @@ midori_bookmarks_delete_activate_cb (GtkWidget* menuitem, #if HAVE_SQLITE sqlite3* db; #endif + GtkTreeModel* model; + GtkTreeIter iter; - item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem"); - #if HAVE_SQLITE - db = g_object_get_data (G_OBJECT (bookmarks->array), "db"); - midori_bookmarks_remove_item_from_db (db, item); - #endif - /* FIXME: Refresh menu */ + if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (bookmarks->treeview), + &model, &iter)) + { + item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem"); + #if HAVE_SQLITE + db = g_object_get_data (G_OBJECT (bookmarks->array), "db"); + midori_bookmarks_remove_item_from_db (db, item); + #endif + gtk_tree_store_remove (GTK_TREE_STORE (model), &iter); + } } static void