From: Alexander Butenko Date: Mon, 19 Jul 2010 19:07:26 +0000 (+0200) Subject: Attach bookmark table and union bookmarks in location completion X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a098e2656d681c38180e9f3779433e1100e5905;p=midori Attach bookmark table and union bookmarks in location completion --- diff --git a/midori/main.c b/midori/main.c index b8c823cc..35f9b99c 100644 --- a/midori/main.c +++ b/midori/main.c @@ -351,12 +351,14 @@ search_engines_save_to_file (KatzeArray* search_engines, static sqlite3* midori_history_initialize (KatzeArray* array, const gchar* filename, + const gchar* bookmarks_filename, char** errmsg) { sqlite3* db; gboolean has_day; sqlite3_stmt* stmt; gint result; + gchar* sql; has_day = FALSE; @@ -401,6 +403,11 @@ midori_history_initialize (KatzeArray* array, "DROP TABLE backup;" "COMMIT;", NULL, NULL, errmsg); + + sql = g_strdup_printf ("ATTACH DATABASE '%s' AS bookmarks", bookmarks_filename); + sqlite3_exec (db, sql, NULL, NULL, errmsg); + g_free (sql); + return db; } @@ -1546,6 +1553,7 @@ main (int argc, gchar** extensions; MidoriWebSettings* settings; gchar* config_file; + gchar* bookmarks_file; MidoriStartup load_on_startup; KatzeArray* search_engines; KatzeArray* bookmarks; @@ -1881,9 +1889,9 @@ main (int argc, midori_startup_timer ("Search read: \t%f"); bookmarks = katze_array_new (KATZE_TYPE_ARRAY); - katze_assign (config_file, build_config_filename ("bookmarks.db")); + bookmarks_file = build_config_filename ("bookmarks.db"); errmsg = NULL; - if ((db = midori_bookmarks_initialize (bookmarks, config_file, &errmsg)) == NULL) + if ((db = midori_bookmarks_initialize (bookmarks, bookmarks_file, &errmsg)) == NULL) { g_string_append_printf (error_messages, _("Bookmarks couldn't be loaded: %s\n"), errmsg); @@ -1938,12 +1946,13 @@ main (int argc, katze_assign (config_file, build_config_filename ("history.db")); errmsg = NULL; - if ((db = midori_history_initialize (history, config_file, &errmsg)) == NULL) + if ((db = midori_history_initialize (history, config_file, bookmarks_file ,&errmsg)) == NULL) { g_string_append_printf (error_messages, _("The history couldn't be loaded: %s\n"), errmsg); g_free (errmsg); } + g_free (bookmarks_file); g_object_set_data (G_OBJECT (history), "db", db); midori_startup_timer ("History read: \t%f"); diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c index 3d4baec7..927e80e9 100644 --- a/midori/midori-locationaction.c +++ b/midori/midori-locationaction.c @@ -361,6 +361,9 @@ midori_location_action_popup_timeout_cb (gpointer data) "UNION ALL " "SELECT type, replace(uri, '%s', title) AS uri, title, count() AS ct FROM search_view " "WHERE title LIKE ?1 GROUP BY uri " + "UNION ALL " + "SELECT '1' AS type, uri, title, '100' AS ct FROM bookmarks " + "WHERE title LIKE ?1 AND uri !='' " "ORDER BY ct DESC LIMIT ?2"; sqlite3_prepare_v2 (db, sqlcmd, strlen (sqlcmd) + 1, &stmt, NULL); }