diff options
Diffstat (limited to 'midori')
-rw-r--r-- | midori/midori-bookmarks-db.c | 255 | ||||
-rw-r--r-- | midori/midori-bookmarksdatabase.vala | 101 | ||||
-rw-r--r-- | midori/midori-database.vala | 44 | ||||
-rw-r--r-- | midori/midori-history.c | 26 | ||||
-rw-r--r-- | midori/midori-historydatabase.vala | 10 | ||||
-rw-r--r-- | midori/midori-locationaction.c | 6 | ||||
-rw-r--r-- | midori/midori-panel.c | 6 | ||||
-rw-r--r-- | midori/midori-preferences.c | 3 | ||||
-rw-r--r-- | midori/midori-privatedata.c | 3 | ||||
-rw-r--r-- | midori/midori-tab.vala | 2 | ||||
-rw-r--r-- | midori/midori-view.c | 6 | ||||
-rw-r--r-- | midori/midori.vapi | 3 | ||||
-rw-r--r-- | midori/wscript_build | 58 |
13 files changed, 186 insertions, 337 deletions
diff --git a/midori/midori-bookmarks-db.c b/midori/midori-bookmarks-db.c index 1b569c79..2d2c6407 100644 --- a/midori/midori-bookmarks-db.c +++ b/midori/midori-bookmarks-db.c @@ -149,7 +149,7 @@ midori_bookmarks_db_init (MidoriBookmarksDb* bookmarks) bookmarks->db = NULL; bookmarks->all_items = g_hash_table_new (item_hash, item_equal); - katze_item_set_meta_integer (KATZE_ITEM (bookmarks), "id", 0); + katze_item_set_meta_integer (KATZE_ITEM (bookmarks), "id", -1); katze_item_set_name (KATZE_ITEM (bookmarks), _("Bookmarks")); g_hash_table_insert (bookmarks->all_items, bookmarks, bookmarks); /* g_object_ref (bookmarks); */ @@ -229,13 +229,11 @@ _midori_bookmarks_db_add_item (KatzeArray* array, db_parent = midori_bookmarks_db_get_item_parent (bookmarks, item); - g_return_if_fail (db_parent); - if (parent == db_parent) { if (IS_MIDORI_BOOKMARKS_DB (parent)) KATZE_ARRAY_CLASS (midori_bookmarks_db_parent_class)->update (parent); - else + else if (KATZE_IS_ARRAY (parent)) katze_array_update (parent); return; } @@ -244,6 +242,8 @@ _midori_bookmarks_db_add_item (KatzeArray* array, KATZE_ARRAY_CLASS (midori_bookmarks_db_parent_class)->add_item (parent, item); else if (KATZE_IS_ARRAY (parent)) katze_array_add_item (parent, item); + + g_assert (parent == katze_item_get_parent (KATZE_ITEM (item))); } /** @@ -311,7 +311,6 @@ _midori_bookmarks_db_move_item (KatzeArray* array, gpointer item, gint position) { - MidoriBookmarksDb *bookmarks; KatzeArray* parent; g_return_if_fail (IS_MIDORI_BOOKMARKS_DB (array)); @@ -685,73 +684,6 @@ midori_bookmarks_db_remove_item (MidoriBookmarksDb* bookmarks, KatzeItem* item) katze_array_remove_item (KATZE_ARRAY (bookmarks), item); } -#define _APPEND_TO_SQL_ERRORMSG(custom_errmsg) \ - do { \ - if (sql_errmsg) \ - { \ - g_string_append_printf (errmsg_str, "%s : %s\n", custom_errmsg, sql_errmsg); \ - sqlite3_free (sql_errmsg); \ - } \ - else \ - g_string_append (errmsg_str, custom_errmsg); \ - } while (0) - -static gboolean -midori_bookmarks_db_import_from_old_db (sqlite3* db, - const gchar* oldfile, - gchar** errmsg) -{ - gint sql_errcode; - gboolean failure = FALSE; - gchar* sql_errmsg = NULL; - GString* errmsg_str = g_string_new (NULL); - gchar* attach_stmt = sqlite3_mprintf ("ATTACH DATABASE %Q AS old_db;", oldfile); - const gchar* convert_stmts = - "BEGIN TRANSACTION;" - "INSERT INTO main.bookmarks (parentid, title, uri, desc, app, toolbar) " - "SELECT NULL AS parentid, title, uri, desc, app, toolbar " - "FROM old_db.bookmarks;" - "UPDATE main.bookmarks SET parentid = (" - "SELECT id FROM main.bookmarks AS b1 WHERE b1.title = (" - "SELECT folder FROM old_db.bookmarks WHERE title = main.bookmarks.title));" - "COMMIT;"; - const gchar* detach_stmt = "DETACH DATABASE old_db;"; - - *errmsg = NULL; - sql_errcode = sqlite3_exec (db, attach_stmt, NULL, NULL, &sql_errmsg); - sqlite3_free (attach_stmt); - - if (sql_errcode != SQLITE_OK) - { - _APPEND_TO_SQL_ERRORMSG (_("failed to ATTACH old db")); - goto convert_failed; - } - - if (sqlite3_exec (db, convert_stmts, NULL, NULL, &sql_errmsg) != SQLITE_OK) - { - failure = TRUE; - _APPEND_TO_SQL_ERRORMSG (_("failed to import from old db")); - - /* try to get back to previous state */ - if (sqlite3_exec (db, "ROLLBACK TRANSACTION;", NULL, NULL, &sql_errmsg) != SQLITE_OK) - _APPEND_TO_SQL_ERRORMSG (_("failed to rollback the transaction")); - } - - if (sqlite3_exec (db, detach_stmt, NULL, NULL, &sql_errmsg) != SQLITE_OK) - _APPEND_TO_SQL_ERRORMSG (_("failed to DETACH ")); - - if (failure) - { - convert_failed: - *errmsg = g_string_free (errmsg_str, FALSE); - g_print ("ERRORR: %s\n", errmsg_str->str); - return FALSE; - } - - return TRUE; -} -#undef _APPEND_TO_SQL_ERRORMSG - static void midori_bookmarks_db_dbtracer (void* dummy, const char* query) @@ -771,177 +703,33 @@ midori_bookmarks_db_dbtracer (void* dummy, MidoriBookmarksDb* midori_bookmarks_db_new (char** errmsg) { - sqlite3* db; - gchar* oldfile; - gchar* newfile; - gboolean newfile_did_exist, oldfile_exists; - const gchar* create_stmt; - gchar* sql_errmsg = NULL; - gchar* import_errmsg = NULL; - KatzeArray* array; - MidoriBookmarksDb* bookmarks; + MidoriBookmarksDatabase* database; + GError* error = NULL; + sqlite3* db; + MidoriBookmarksDb* bookmarks; g_return_val_if_fail (errmsg != NULL, NULL); - oldfile = midori_paths_get_config_filename_for_writing ("bookmarks.db"); - oldfile_exists = g_access (oldfile, F_OK) == 0; - newfile = midori_paths_get_config_filename_for_writing ("bookmarks_v2.db"); - newfile_did_exist = g_access (newfile, F_OK) == 0; - - /* sqlite3_open will create the file if it did not exists already */ - if (sqlite3_open (newfile, &db) != SQLITE_OK) + database = midori_bookmarks_database_new (&error); + + if (error != NULL) { - *errmsg = g_strdup_printf (_("Failed to open database: %s\n"), - db ? sqlite3_errmsg (db) : "(db = NULL)"); - goto init_failed; + *errmsg = g_strdup (error->message); + g_error_free (error); + return NULL; } + db = midori_database_get_db (MIDORI_DATABASE (database)); + g_return_val_if_fail (db != NULL, NULL); + if (midori_debug ("bookmarks")) sqlite3_trace (db, midori_bookmarks_db_dbtracer, NULL); - create_stmt = /* Table structure */ - "CREATE TABLE IF NOT EXISTS bookmarks " - "(id INTEGER PRIMARY KEY AUTOINCREMENT, " - "parentid INTEGER DEFAULT NULL, " - "title TEXT, uri TEXT, desc TEXT, app INTEGER, toolbar INTEGER, " - "pos_panel INTEGER, pos_bar INTEGER, " - "created DATE DEFAULT CURRENT_TIMESTAMP, " - "last_visit DATE, visit_count INTEGER DEFAULT 0, " - "nick TEXT, " - "FOREIGN KEY(parentid) REFERENCES bookmarks(id) " - "ON DELETE CASCADE); PRAGMA foreign_keys = ON;" - - /* trigger: insert panel position */ - "CREATE TRIGGER IF NOT EXISTS bookmarkInsertPosPanel " - "AFTER INSERT ON bookmarks FOR EACH ROW " - "BEGIN UPDATE bookmarks SET pos_panel = (" - "SELECT ifnull(MAX(pos_panel),0)+1 FROM bookmarks WHERE " - "(NEW.parentid IS NOT NULL AND parentid = NEW.parentid) " - "OR (NEW.parentid IS NULL AND parentid IS NULL)) " - "WHERE id = NEW.id; END;" - - /* trigger: insert Bookmarkbar position */ - "CREATE TRIGGER IF NOT EXISTS bookmarkInsertPosBar " - "AFTER INSERT ON bookmarks FOR EACH ROW WHEN NEW.toolbar=1 " - "BEGIN UPDATE bookmarks SET pos_bar = (" - "SELECT ifnull(MAX(pos_bar),0)+1 FROM bookmarks WHERE " - "((NEW.parentid IS NOT NULL AND parentid = NEW.parentid) " - "OR (NEW.parentid IS NULL AND parentid IS NULL)) AND toolbar=1) " - "WHERE id = NEW.id; END;" - - /* trigger: update panel position */ - "CREATE TRIGGER IF NOT EXISTS bookmarkUpdatePosPanel " - "BEFORE UPDATE OF parentid ON bookmarks FOR EACH ROW " - "WHEN ((NEW.parentid IS NULL OR OLD.parentid IS NULL) " - "AND NEW.parentid IS NOT OLD.parentid) OR " - "((NEW.parentid IS NOT NULL AND OLD.parentid IS NOT NULL) " - "AND NEW.parentid!=OLD.parentid) " - "BEGIN UPDATE bookmarks SET pos_panel = pos_panel-1 " - "WHERE ((OLD.parentid IS NOT NULL AND parentid = OLD.parentid) " - "OR (OLD.parentid IS NULL AND parentid IS NULL)) AND pos_panel > OLD.pos_panel; " - "UPDATE bookmarks SET pos_panel = (" - "SELECT ifnull(MAX(pos_panel),0)+1 FROM bookmarks " - "WHERE (NEW.parentid IS NOT NULL AND parentid = NEW.parentid) " - "OR (NEW.parentid IS NULL AND parentid IS NULL)) " - "WHERE id = OLD.id; END;" - - /* trigger: update Bookmarkbar position */ - "CREATE TRIGGER IF NOT EXISTS bookmarkUpdatePosBar0 " - "AFTER UPDATE OF parentid, toolbar ON bookmarks FOR EACH ROW " - "WHEN ((NEW.parentid IS NULL OR OLD.parentid IS NULL) " - "AND NEW.parentid IS NOT OLD.parentid) " - "OR ((NEW.parentid IS NOT NULL AND OLD.parentid IS NOT NULL) " - "AND NEW.parentid!=OLD.parentid) OR (OLD.toolbar=1 AND NEW.toolbar=0) " - "BEGIN UPDATE bookmarks SET pos_bar = NULL WHERE id = NEW.id; " - "UPDATE bookmarks SET pos_bar = pos_bar-1 " - "WHERE ((OLD.parentid IS NOT NULL AND parentid = OLD.parentid) " - "OR (OLD.parentid IS NULL AND parentid IS NULL)) AND pos_bar > OLD.pos_bar; END;" - - /* trigger: update Bookmarkbar position */ - "CREATE TRIGGER IF NOT EXISTS bookmarkUpdatePosBar1 " - "BEFORE UPDATE OF parentid, toolbar ON bookmarks FOR EACH ROW " - "WHEN ((NEW.parentid IS NULL OR OLD.parentid IS NULL) " - "AND NEW.parentid IS NOT OLD.parentid) OR " - "((NEW.parentid IS NOT NULL AND OLD.parentid IS NOT NULL) " - "AND NEW.parentid!=OLD.parentid) OR (OLD.toolbar=0 AND NEW.toolbar=1) " - "BEGIN UPDATE bookmarks SET pos_bar = (" - "SELECT ifnull(MAX(pos_bar),0)+1 FROM bookmarks WHERE " - "(NEW.parentid IS NOT NULL AND parentid = NEW.parentid) " - "OR (NEW.parentid IS NULL AND parentid IS NULL)) " - "WHERE id = OLD.id; END;" - - /* trigger: delete panel position */ - "CREATE TRIGGER IF NOT EXISTS bookmarkDeletePosPanel " - "AFTER DELETE ON bookmarks FOR EACH ROW " - "BEGIN UPDATE bookmarks SET pos_panel = pos_panel-1 " - "WHERE ((OLD.parentid IS NOT NULL AND parentid = OLD.parentid) " - "OR (OLD.parentid IS NULL AND parentid IS NULL)) AND pos_panel > OLD.pos_panel; END;" - - /* trigger: delete Bookmarkbar position */ - "CREATE TRIGGER IF NOT EXISTS bookmarkDeletePosBar " - "AFTER DELETE ON bookmarks FOR EACH ROW WHEN OLD.toolbar=1 " - "BEGIN UPDATE bookmarks SET pos_bar = pos_bar-1 " - "WHERE ((OLD.parentid IS NOT NULL AND parentid = OLD.parentid) " - "OR (OLD.parentid IS NULL AND parentid IS NULL)) AND pos_bar > OLD.pos_bar; END;"; - - - if (newfile_did_exist) - { - const gchar* setup_stmt = "PRAGMA foreign_keys = ON;"; - /* initial setup */ - if (sqlite3_exec (db, setup_stmt, NULL, NULL, &sql_errmsg) != SQLITE_OK) - { - *errmsg = g_strdup_printf (_("Couldn't setup bookmarks: %s\n"), - sql_errmsg ? sql_errmsg : "(err = NULL)"); - sqlite3_free (sql_errmsg); - goto init_failed; - } - - /* we are done */ - goto init_success; - } - else - { - /* initial creation */ - if (sqlite3_exec (db, create_stmt, NULL, NULL, &sql_errmsg) != SQLITE_OK) - { - *errmsg = g_strdup_printf (_("Couldn't create bookmarks table: %s\n"), - sql_errmsg ? sql_errmsg : "(err = NULL)"); - sqlite3_free (sql_errmsg); - - /* we can as well remove the new file */ - g_unlink (newfile); - goto init_failed; - } - - } - - if (oldfile_exists) - /* import from old db */ - if (!midori_bookmarks_db_import_from_old_db (db, oldfile, &import_errmsg)) - { - *errmsg = g_strdup_printf (_("Couldn't import from old database: %s\n"), - import_errmsg ? import_errmsg : "(err = NULL)"); - g_free (import_errmsg); - } + bookmarks = MIDORI_BOOKMARKS_DB (g_object_new (TYPE_MIDORI_BOOKMARKS_DB, NULL)); + bookmarks->db = db; - init_success: - g_free (newfile); - g_free (oldfile); - bookmarks = MIDORI_BOOKMARKS_DB (g_object_new (TYPE_MIDORI_BOOKMARKS_DB, NULL)); - bookmarks->db = db; - - g_object_set_data (G_OBJECT (bookmarks), "db", db); - return bookmarks; - - init_failed: - g_free (newfile); - g_free (oldfile); - - if (db) - sqlite3_close (db); - - return NULL; + g_object_set_data (G_OBJECT (bookmarks), "db", db); + return bookmarks; } /** @@ -1024,7 +812,6 @@ midori_bookmarks_db_array_from_statement (sqlite3_stmt* stmt, { gint i; KatzeItem* item; - KatzeItem* found; item = katze_item_new (); for (i = 0; i < cols; i++) diff --git a/midori/midori-bookmarksdatabase.vala b/midori/midori-bookmarksdatabase.vala new file mode 100644 index 00000000..c678035b --- /dev/null +++ b/midori/midori-bookmarksdatabase.vala @@ -0,0 +1,101 @@ +/* + Copyright (C) 2013 Andre Auzi <aauzi@free.fr> + Copyright (C) 2013 Christian Dywan <christian@twotoats.de> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + See the file COPYING for the full license text. +*/ + +namespace Midori { + public class BookmarksDatabase : Midori.Database { + public BookmarksDatabase () throws DatabaseError { + Object (path: "bookmarks.db"); + preinit (); + init (); + exec ("PRAGMA foreign_keys = ON;"); + } + + protected void preinit () throws DatabaseError { + string dbfile = Paths.get_config_filename_for_writing (path); + string olddbfile = dbfile + ".old"; + string dbfile_v2 = Paths.get_config_filename_for_reading ("bookmarks_v2.db"); + + if (Posix.access (dbfile_v2, Posix.F_OK) == 0) { + if (Posix.access (dbfile, Posix.F_OK) == 0) { + if (Posix.access (olddbfile, Posix.F_OK) == 0) + Posix.unlink (olddbfile); + GLib.FileUtils.rename (dbfile, olddbfile); + } + + GLib.FileUtils.rename (dbfile_v2, dbfile); + + if (Sqlite.Database.open_v2 (dbfile, out _db) != Sqlite.OK) + throw new DatabaseError.OPEN ("Failed to open database %s".printf (path)); + + Sqlite.Statement stmt; + if (db.prepare_v2 ("PRAGMA user_version;", -1, out stmt, null) != Sqlite.OK) + throw new DatabaseError.EXECUTE ("Failed to compile statement %s".printf (db.errmsg ())); + if (stmt.step () != Sqlite.ROW) + throw new DatabaseError.EXECUTE ("Failed to get row %s".printf (db.errmsg ())); + int64 user_version = stmt.column_int64 (0); + + if (user_version == 0) { + exec ("PRAGMA user_version = 1;"); + } + + _db = null; + } else if (Posix.access (dbfile, Posix.F_OK) == 0) { + + if (Sqlite.Database.open_v2 (dbfile, out _db) != Sqlite.OK) + throw new DatabaseError.OPEN ("Failed to open database %s".printf (path)); + + Sqlite.Statement stmt; + if (db.prepare_v2 ("PRAGMA user_version;", -1, out stmt, null) != Sqlite.OK) + throw new DatabaseError.EXECUTE ("Failed to compile statement %s".printf (db.errmsg ())); + if (stmt.step () != Sqlite.ROW) + throw new DatabaseError.EXECUTE ("Failed to get row %s".printf (db.errmsg ())); + int64 user_version = stmt.column_int64 (0); + + _db = null; + + if (user_version == 0) { + if (Posix.access (olddbfile, Posix.F_OK) == 0) + Posix.unlink (olddbfile); + + GLib.FileUtils.rename (dbfile, olddbfile); + + if (Sqlite.Database.open_v2 (dbfile, out _db) != Sqlite.OK) + throw new DatabaseError.OPEN ("Failed to open database %s".printf (path)); + + exec_script ("Create"); + + if (db.exec ("ATTACH DATABASE '%s' AS old_db;".printf (olddbfile)) != Sqlite.OK) + throw new DatabaseError.EXECUTE ("Failed to attach old database : %s (%s)".printf (olddbfile, db.errmsg ())); + + bool failure = false; + try { + exec_script ("Import_old_db_bookmarks"); + } catch (DatabaseError error) { + if (error is DatabaseError.EXECUTE) + failure = true; + else + throw error; + } + + /* try to get back to previous state */ + if (failure) + exec ("ROLLBACK TRANSACTION;"); + + exec ("DETACH DATABASE old_db;"); + exec ("PRAGMA user_version = 1;"); + + _db = null; + } + } + } + } +} diff --git a/midori/midori-database.vala b/midori/midori-database.vala index 1b612518..df4608ba 100644 --- a/midori/midori-database.vala +++ b/midori/midori-database.vala @@ -12,7 +12,8 @@ namespace Midori { public errordomain DatabaseError { OPEN, - SCHEMA, + NAMING, + FILENAME, EXECUTE, } @@ -48,22 +49,53 @@ namespace Midori { if (db.exec ("PRAGMA journal_mode = WAL; PRAGMA cache_size = 32100;") != Sqlite.OK) db.exec ("PRAGMA synchronous = NORMAL; PRAGMA temp_store = MEMORY;"); + db.exec ("PRAGMA count_changes = OFF;"); + int64 user_version; + Sqlite.Statement stmt; + if (db.prepare_v2 ("PRAGMA user_version;", -1, out stmt, null) != Sqlite.OK) + throw new DatabaseError.EXECUTE ("Failed to compile statement %s".printf (db.errmsg ())); + if (stmt.step () != Sqlite.ROW) + throw new DatabaseError.EXECUTE ("Failed to get row %s".printf (db.errmsg ())); + user_version = stmt.column_int64 (0); + + if (user_version == 0) { + exec_script ("Create"); + user_version = 1; + exec ("PRAGMA user_version = " + user_version.to_string ()); + } + + while (true) { + try { + exec_script ("Update" + user_version.to_string ()); + } catch (DatabaseError error) { + if (error is DatabaseError.FILENAME) + break; + throw error; + } + user_version = user_version + 1; + exec ("PRAGMA user_version = " + user_version.to_string ()); + } + + first_use = !exists; + return true; + } + + public bool exec_script (string filename) throws DatabaseError { string basename = Path.get_basename (path); string[] parts = basename.split ("."); if (!(parts != null && parts[0] != null && parts[1] != null)) - throw new DatabaseError.SCHEMA ("Failed to deduce schema filename from %s".printf (path)); - string schema_filename = Midori.Paths.get_res_filename (parts[0] + "/Create.sql"); + throw new DatabaseError.NAMING ("Failed to deduce schema filename from %s".printf (path)); + string schema_filename = Midori.Paths.get_res_filename (parts[0] + "/" + filename + ".sql"); string schema; try { FileUtils.get_contents (schema_filename, out schema, null); } catch (Error error) { - throw new DatabaseError.SCHEMA ("Failed to open schema: %s".printf (schema_filename)); + throw new DatabaseError.FILENAME ("Failed to open schema: %s".printf (schema_filename)); } + schema = "BEGIN TRANSACTION; %s; COMMIT;".printf (schema); if (db.exec (schema) != Sqlite.OK) throw new DatabaseError.EXECUTE ("Failed to execute schema: %s".printf (schema)); - - first_use = !exists; return true; } diff --git a/midori/midori-history.c b/midori/midori-history.c index d97919a1..11c18f07 100644 --- a/midori/midori-history.c +++ b/midori/midori-history.c @@ -33,11 +33,6 @@ midori_history_new (char** errmsg) MidoriHistoryDatabase* database; GError* error = NULL; sqlite3* db; - gboolean has_day = FALSE; - sqlite3_stmt* stmt; - gint result; - gchar* sql; - gchar* bookmarks_filename; KatzeArray* array; g_return_val_if_fail (errmsg != NULL, NULL); @@ -53,27 +48,6 @@ midori_history_new (char** errmsg) db = midori_database_get_db (MIDORI_DATABASE (database)); g_return_val_if_fail (db != NULL, NULL); - sqlite3_prepare_v2 (db, "SELECT day FROM history LIMIT 1", -1, &stmt, NULL); - result = sqlite3_step (stmt); - if (result == SQLITE_ROW) - has_day = TRUE; - sqlite3_finalize (stmt); - - if (!has_day) - sqlite3_exec (db, - "BEGIN TRANSACTION;" - "CREATE TEMPORARY TABLE backup (uri text, title text, date integer);" - "INSERT INTO backup SELECT uri,title,date FROM history;" - "DROP TABLE history;" - "CREATE TABLE history (uri text, title text, date integer, day integer);" - "INSERT INTO history SELECT uri,title,date," - "julianday(date(date,'unixepoch','start of day','+1 day'))" - " - julianday('0001-01-01','start of day')" - "FROM backup;" - "DROP TABLE backup;" - "COMMIT;", - NULL, NULL, errmsg); - array = katze_array_new (KATZE_TYPE_ARRAY); g_object_set_data (G_OBJECT (array), "db", db); g_signal_connect (array, "clear", diff --git a/midori/midori-historydatabase.vala b/midori/midori-historydatabase.vala index 58ae4ff1..aeb630a7 100644 --- a/midori/midori-historydatabase.vala +++ b/midori/midori-historydatabase.vala @@ -39,8 +39,14 @@ namespace Midori { public HistoryDatabase (GLib.Object? app) throws DatabaseError { Object (path: "history.db"); init (); - string bookmarks_filename = Midori.Paths.get_config_filename_for_writing ("bookmarks_v2.db"); - exec ("ATTACH DATABASE '%s' AS bookmarks".printf (bookmarks_filename)); + Midori.BookmarksDatabase bookmarks_database = new Midori.BookmarksDatabase (); + exec ("ATTACH DATABASE '%s' AS bookmarks".printf (bookmarks_database.path)); + + try { + exec ("SELECT day FROM history LIMIT 1"); + } catch (Error error) { + exec_script ("Day"); + } } public async List<HistoryItem>? query (string sqlcmd, string? filter, int day, int max_items, Cancellable cancellable) { diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c index 949fbd0f..14d7c582 100644 --- a/midori/midori-locationaction.c +++ b/midori/midori-locationaction.c @@ -1448,11 +1448,13 @@ midori_location_action_icon_released_cb (GtkWidget* widget, gint button, GtkAction* action) { - /* The dialog should "toggle" like a menu, as far as users go - FIXME: Half-working: the dialog closes but re-opens */ + /* The dialog should "toggle" like a menu, as far as users go */ static GtkWidget* dialog = NULL; if (icon_pos == GTK_ENTRY_ICON_PRIMARY && dialog != NULL) + { gtk_widget_destroy (dialog); + return; // Previously code was running on and the widget was being rebuilt + } if (icon_pos == GTK_ENTRY_ICON_PRIMARY) { diff --git a/midori/midori-panel.c b/midori/midori-panel.c index 7a0cdf28..d57e1b16 100644 --- a/midori/midori-panel.c +++ b/midori/midori-panel.c @@ -536,6 +536,12 @@ static void midori_panel_action_activate_cb (GtkRadioAction* action, MidoriPanel* panel) { + gtk_toggle_action_set_active ( + gtk_action_group_get_action ( + midori_browser_get_action_group ( + midori_browser_get_for_widget (GTK_WIDGET (panel))), + "Panel"), + TRUE); GtkWidget* viewable = g_object_get_data (G_OBJECT (action), "viewable"); gint n = midori_panel_page_num (panel, viewable); diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c index 910ef115..70cca722 100644 --- a/midori/midori-preferences.c +++ b/midori/midori-preferences.c @@ -25,9 +25,6 @@ #include <libsoup/soup-cache.h> #include <config.h> -#if HAVE_LIBNOTIFY - #include <libnotify/notify.h> -#endif struct _MidoriPreferences { diff --git a/midori/midori-privatedata.c b/midori/midori-privatedata.c index ecce66a4..c95e7a0d 100644 --- a/midori/midori-privatedata.c +++ b/midori/midori-privatedata.c @@ -147,7 +147,10 @@ midori_private_data_get_dialog (MidoriBrowser* browser) G_CALLBACK (midori_private_data_dialog_response_cb), browser); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT); #endif + /* Elementary */ katze_widget_add_class (button, "noundo"); + /* GNOME Shell */ + katze_widget_add_class (button, "destructive-action"); screen = gtk_widget_get_screen (GTK_WIDGET (browser)); if (screen) gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_CLEAR); diff --git a/midori/midori-tab.vala b/midori/midori-tab.vala index 36c34ee2..ee36553b 100644 --- a/midori/midori-tab.vala +++ b/midori/midori-tab.vala @@ -151,7 +151,7 @@ namespace Midori { #endif public bool can_view_source () { - if (is_blank () || special || view_source) + if (view_source) return false; string content_type = ContentType.from_mime_type (mime_type); #if HAVE_WIN32 diff --git a/midori/midori-view.c b/midori/midori-view.c index 56a836a0..339b44c5 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -541,10 +541,8 @@ static void midori_view_update_load_status (MidoriView* view, MidoriLoadStatus load_status) { - if (midori_tab_get_load_status (MIDORI_TAB (view)) == load_status) - return; - - midori_tab_set_load_status (MIDORI_TAB (view), load_status); + if (midori_tab_get_load_status (MIDORI_TAB (view)) != load_status) + midori_tab_set_load_status (MIDORI_TAB (view), load_status); #ifdef HAVE_GRANITE if (view->tab) diff --git a/midori/midori.vapi b/midori/midori.vapi index 50518a6f..6acb2645 100644 --- a/midori/midori.vapi +++ b/midori/midori.vapi @@ -256,6 +256,7 @@ namespace Midori { [CCode (cheader_filename = "midori/sokoke.h", lower_case_cprefix = "sokoke_")] namespace Sokoke { + public static string magic_uri (string uri, bool allow_search, bool allow_relative); public static uint gtk_action_count_modifiers (Gtk.Action action); #if HAVE_WIN32 public static string get_win32_desktop_lnk_path_for_filename (string filename); @@ -263,7 +264,7 @@ namespace Midori { #endif } - #if !HAVE_WIN32 + #if HAVE_EXECINFO_H [CCode (lower_case_cprefix = "")] namespace Linux { [CCode (cheader_filename = "execinfo.h", array_length = false)] diff --git a/midori/wscript_build b/midori/wscript_build deleted file mode 100644 index be4d1fc9..00000000 --- a/midori/wscript_build +++ /dev/null @@ -1,58 +0,0 @@ -#! /usr/bin/env python -# WAF build script for midori -# This file is licensed under the terms of the expat license, see the file EXPAT. - -import Options -import platform -import os - -progressive = True -libs = 'M UNIQUE LIBSOUP GMODULE GTHREAD LIBIDN GIO GTK SQLITE ' \ - 'LIBNOTIFY WEBKIT JAVASCRIPTCOREGTK LIBXML X11 XSS WS2_32 ' \ - 'GCR GRANITE ZEITGEIST OLE32 UUID ' - -if Options.commands['build'] or Options.commands['check']: - blddir = str (bld.bldnode)[6:] # dir:// + absolute path - duplicate_vapi = blddir + '/default/midori/midori-core.vapi' - if os.path.exists (duplicate_vapi): - os.remove (duplicate_vapi) - -if progressive: - obj = bld.new_task_gen ('cc', 'staticlib') - obj.target = 'midori-core' - obj.find_sources_in_dirs ('../katze . ../panels ../toolbars', exts=['.vala']) - obj.env.append_value ('CCFLAGS', '-w') - obj.uselib = libs - obj.vapi_dirs = '../midori ../katze' - obj.packages = 'glib-2.0 gmodule-2.0 gio-2.0 libsoup-2.4 posix sqlite3' - if bld.env['HAVE_WEBKIT2']: - obj.packages += ' webkit2gtk-3.0' - else: - obj.packages += ' webkitgtk-3.0' - if bld.env['HAVE_GTK3']: - obj.packages += ' gtk+-3.0' - else: - obj.packages += ' gtk+-2.0' - if bld.env['HAVE_GRANITE']: - obj.packages += ' granite' - obj.install_path = None - bld.add_group () - - obj = bld.new_task_gen ('cc', 'staticlib') - obj.target = 'midori-c' - obj.includes = '.. ../katze . ../toolbars' - obj.find_sources_in_dirs ('../katze . ../panels ../toolbars', exts=['.c'], excludes=['main.c']) - obj.uselib = libs - obj.uselib_local = 'midori-core' - obj.add_marshal_file ('marshal.list', 'midori_cclosure_marshal') - obj.install_path = None - bld.add_group () - - obj = bld.new_task_gen ('cc', 'program') - obj.target = 'midori' - obj.includes = '.. ../katze . ../panels' - obj.source = './main.c' - obj.uselib = libs - obj.uselib_local = 'midori-c' - if bld.env['WINRC']: - obj.source += ' ../data/midori.rc' |