Fixed handling of bookmark meta data

sqlite doesn't store negative value but rather 0 and 1, so we
work with these values now. As a side effect it makes the code
easier to read.
This commit is contained in:
Alexander Butenko 2010-06-19 09:56:50 -04:00 committed by Christian Dywan
parent 633b7ed294
commit 053048d05e
3 changed files with 4 additions and 19 deletions

1
TODO
View file

@ -93,7 +93,6 @@ TODO:
. Prevent dead tabs: download, aborted page . Prevent dead tabs: download, aborted page
BOOKMARK ISSUES: BOOKMARK ISSUES:
. Show on toolbar is not working
. Bookmark menu is not populated . Bookmark menu is not populated
. Bookmark toolbar is broken . Bookmark toolbar is broken
. Import is broken . Import is broken

View file

@ -893,7 +893,7 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
check_toolbar = gtk_check_button_new_with_mnemonic (_("Show in the tool_bar")); check_toolbar = gtk_check_button_new_with_mnemonic (_("Show in the tool_bar"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_toolbar), gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_toolbar),
katze_item_get_meta_string (bookmark, "toolbar") != NULL); katze_item_get_meta_integer (bookmark, "toolbar"));
gtk_box_pack_start (GTK_BOX (hbox), check_toolbar, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), check_toolbar, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (content_area), hbox); gtk_container_add (GTK_CONTAINER (content_area), hbox);
gtk_widget_show_all (hbox); gtk_widget_show_all (hbox);
@ -908,7 +908,7 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
check_app = gtk_check_button_new_with_mnemonic (_("Run as _web application")); check_app = gtk_check_button_new_with_mnemonic (_("Run as _web application"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_app), gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_app),
katze_item_get_meta_string (bookmark, "app") != NULL); katze_item_get_meta_integer (bookmark, "app"));
gtk_box_pack_start (GTK_BOX (hbox), check_app, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), check_app, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (content_area), hbox); gtk_container_add (GTK_CONTAINER (content_area), hbox);
gtk_widget_show_all (hbox); gtk_widget_show_all (hbox);
@ -926,15 +926,13 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
gtk_entry_get_text (GTK_ENTRY (entry_desc))); gtk_entry_get_text (GTK_ENTRY (entry_desc)));
/* FIXME: Toolbar is not working?? */ /* FIXME: Toolbar is not working?? */
katze_item_set_meta_integer (bookmark, "toolbar", katze_item_set_meta_integer (bookmark, "toolbar",
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_toolbar)) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_toolbar)));
? 1 : -1);
if (!KATZE_IS_ARRAY (bookmark)) if (!KATZE_IS_ARRAY (bookmark))
{ {
katze_item_set_uri (bookmark, katze_item_set_uri (bookmark,
gtk_entry_get_text (GTK_ENTRY (entry_uri))); gtk_entry_get_text (GTK_ENTRY (entry_uri)));
katze_item_set_meta_integer (bookmark, "app", katze_item_set_meta_integer (bookmark, "app",
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_app)) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_app)));
? 1 : -1);
} }
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_toolbar))) if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_toolbar)))

View file

@ -174,12 +174,6 @@ midori_bookmarks_read_from_db (MidoriBookmarks* bookmarks,
app = sqlite3_column_int64 (statement, 3); app = sqlite3_column_int64 (statement, 3);
toolbar = sqlite3_column_int64 (statement, 4); toolbar = sqlite3_column_int64 (statement, 4);
if (app == 0)
app = -1;
if (toolbar == 0)
toolbar = -1;
item = katze_item_new (); item = katze_item_new ();
katze_item_set_name (item, (gchar*)title); katze_item_set_name (item, (gchar*)title);
katze_item_set_meta_integer (item, "toolbar", toolbar); katze_item_set_meta_integer (item, "toolbar", toolbar);
@ -235,12 +229,6 @@ midori_bookmarks_insert_item_db (sqlite3* db,
else else
parent = g_strdup (""); 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 ( sqlcmd = sqlite3_mprintf (
"INSERT into bookmarks (uri, title, folder, type, toolbar, app) values" "INSERT into bookmarks (uri, title, folder, type, toolbar, app) values"
" ('%q', '%q', '%q', %u, %u, %u)", " ('%q', '%q', '%q', %u, %u, %u)",