From: Alexander Butenko Date: Sun, 13 Jun 2010 21:28:22 +0000 (-0400) Subject: Use extra attributes of a bookmark X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=954939fdd153c87360117cb772d706d9e5f1e762;p=midori Use extra attributes of a bookmark --- diff --git a/midori/main.c b/midori/main.c index 388c9d5f..ab7de931 100644 --- a/midori/main.c +++ b/midori/main.c @@ -447,7 +447,8 @@ midori_bookmarks_initialize (KatzeArray* array, if (sqlite3_exec (db, "CREATE TABLE IF NOT EXISTS " - "bookmarks (uri text, title text, folder text, type integer);", + "bookmarks (uri text, title text, folder text, type integer, " + "desc text, app integer, toolbar integer);", NULL, NULL, errmsg) != SQLITE_OK) return NULL; return db; diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 67f6ee53..2628cf5a 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -912,6 +912,7 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser, gtk_entry_get_text (GTK_ENTRY (entry_title))); katze_item_set_text (bookmark, gtk_entry_get_text (GTK_ENTRY (entry_desc))); + /* FIXME: Toolbar is not working?? */ katze_item_set_meta_integer (bookmark, "toolbar", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_toolbar)) ? 1 : -1); diff --git a/panels/midori-bookmarks.c b/panels/midori-bookmarks.c index b98b4ed9..68731d65 100644 --- a/panels/midori-bookmarks.c +++ b/panels/midori-bookmarks.c @@ -151,7 +151,7 @@ midori_bookmarks_read_from_db (MidoriBookmarks* bookmarks, db = g_object_get_data (G_OBJECT (bookmarks->array), "db"); - sqlcmd = "SELECT uri, title, type from bookmarks where folder = ?" + sqlcmd = "SELECT uri, title, type, app, toolbar from bookmarks where folder = ?" " ORDER BY type DESC"; result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL); sqlite3_bind_text (statement, 1, g_strdup(folder), -1, g_free); @@ -162,6 +162,8 @@ midori_bookmarks_read_from_db (MidoriBookmarks* bookmarks, while ((result = sqlite3_step (statement)) == SQLITE_ROW) { gint type; + gint app; + gint toolbar; KatzeItem* item; const unsigned char* uri; const unsigned char* title; @@ -169,9 +171,18 @@ midori_bookmarks_read_from_db (MidoriBookmarks* bookmarks, uri = sqlite3_column_text (statement, 0); title = sqlite3_column_text (statement, 1); type = sqlite3_column_int64 (statement, 2); + app = sqlite3_column_int64 (statement, 3); + toolbar = sqlite3_column_int64 (statement, 4); + + + if (app == 0) + app = -1; + if (toolbar == 0) + toolbar = -1; item = katze_item_new (); katze_item_set_name (item, (gchar*)title); + katze_item_set_meta_integer (item, "toolbar", toolbar); /* type 0 -- folder, 1 -- entry */ if (type == 0) @@ -188,6 +199,7 @@ midori_bookmarks_read_from_db (MidoriBookmarks* bookmarks, continue; katze_item_set_uri (item, (gchar*)uri); + katze_item_set_meta_integer (item, "app", app); gtk_tree_store_insert_with_values (model, NULL, parent, 0, 0, item, -1); } @@ -223,17 +235,25 @@ midori_bookmarks_insert_item_db (sqlite3* db, else parent = g_strdup (""); + if (katze_item_get_meta_integer (item, "toolbar") == -1) + katze_item_set_meta_integer (item, "toolbar", 0); + + if (katze_item_get_meta_integer (item, "app") == -1) + katze_item_set_meta_integer (item, "app", 0); + sqlcmd = sqlite3_mprintf ( - "INSERT into bookmarks (uri, title, folder, type) values" - " ('%q', '%q', '%q', %u)", + "INSERT into bookmarks (uri, title, folder, type, toolbar, app) values" + " ('%q', '%q', '%q', %u, %u, %u)", katze_item_get_uri (item), katze_item_get_name (item), parent, - type); + type, + katze_item_get_meta_integer (item, "toolbar"), + katze_item_get_meta_integer (item, "app")); if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK) { - g_printerr (_("Failed to remove history item: %s\n"), errmsg); + g_printerr (_("Failed to add bookmark item: %s\n"), errmsg); sqlite3_free (errmsg); }