summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Dywan <christian@twotoasts.de>2018-07-16 19:03:19 +0200
committerChristian Dywan <christian@twotoasts.de>2018-07-18 00:19:20 +0200
commit429613db84552930c795de3743e383bc65cf727a (patch)
treea79f731d4818e8a67fb9ced47e761ccd3d7409cf
parent961f439fccbd02aebeaa69ee9f052ab695971a61 (diff)
downloadmidori-git-delayed-load.tar.gz
Delayed loading of tabsdelayed-load
-rw-r--r--core/browser.vala7
-rw-r--r--core/database.vala4
-rw-r--r--core/tab.vala37
-rw-r--r--core/tally.vala4
4 files changed, 42 insertions, 10 deletions
diff --git a/core/browser.vala b/core/browser.vala
index b96e5e72..ff51f2b2 100644
--- a/core/browser.vala
+++ b/core/browser.vala
@@ -126,7 +126,7 @@ namespace Midori {
urlbar.notify["uri"].connect ((pspec) => {
if (urlbar.uri.has_prefix ("javascript:")) {
tab.run_javascript.begin (urlbar.uri.substring (11, -1), null);
- } else if (urlbar.uri != tab.uri) {
+ } else if (urlbar.uri != tab.display_uri) {
tab.load_uri (urlbar.uri);
}
});
@@ -146,7 +146,7 @@ namespace Midori {
title = tab.display_title;
urlbar.secure = tab.secure;
statusbar.label = tab.link_uri;
- urlbar.uri = tab.uri;
+ urlbar.uri = tab.display_uri;
navigationbar.visible = !tab.pinned;
bindings.append (tab.bind_property ("can-go-back", go_back, "sensitive"));
bindings.append (tab.bind_property ("can-go-forward", go_forward, "sensitive"));
@@ -156,8 +156,9 @@ namespace Midori {
bindings.append (tab.bind_property ("display-title", this, "title"));
bindings.append (tab.bind_property ("secure", urlbar, "secure"));
bindings.append (tab.bind_property ("link-uri", statusbar, "label"));
- bindings.append (tab.bind_property ("uri", urlbar, "uri"));
+ bindings.append (tab.bind_property ("display-uri", urlbar, "uri"));
bindings.append (tab.bind_property ("pinned", navigationbar, "visible", BindingFlags.INVERT_BOOLEAN));
+ tab.grab_focus ();
} else {
var previous_tab = tabs.get_children ().nth_data (0);
if (previous_tab == null)
diff --git a/core/database.vala b/core/database.vala
index 9fc0612d..36c217f8 100644
--- a/core/database.vala
+++ b/core/database.vala
@@ -445,14 +445,14 @@ namespace Midori {
*/
public async bool update (DatabaseItem item) throws DatabaseError {
string sqlcmd = """
- UPDATE %s SET TITLE=:title WHERE uri = :uri AND date=:date
+ UPDATE %s SET title=:title WHERE uri = :uri AND date=:date
""".printf (table);
DatabaseStatement statement;
try {
statement = prepare (sqlcmd,
":uri", typeof (string), item.uri,
":title", typeof (string), item.title,
- ":date", typeof (int64), item.uri);
+ ":date", typeof (int64), item.date);
if (statement.exec ()) {
if (_items != null) {
items_changed (_items.index (item), 0, 0);
diff --git a/core/tab.vala b/core/tab.vala
index f7837cff..7d19655e 100644
--- a/core/tab.vala
+++ b/core/tab.vala
@@ -17,6 +17,7 @@ namespace Midori {
public new bool can_go_back { get; protected set; }
public new bool can_go_forward { get; protected set; }
public DatabaseItem? item { get; protected set; default = null; }
+ public string display_uri { get; protected set; }
public string display_title { get; protected set; }
public bool pinned { get; set; }
public bool secure { get; protected set; }
@@ -35,12 +36,12 @@ namespace Midori {
notify["estimated-load-progress"].connect (update_progress);
notify["is-loading"].connect (update_progress);
notify["uri"].connect ((pspec) => {
- display_title = uri;
+ display_uri = uri;
can_go_back = base.can_go_back ();
can_go_forward = base.can_go_forward ();
});
notify["title"].connect ((pspec) => {
- display_title = (title != null && title != "") ? title : uri;
+ display_title = (title != null && title != "") ? title : display_uri;
if (item != null) {
item.title = display_title;
}
@@ -53,7 +54,37 @@ namespace Midori {
get_settings ().set_user_agent_with_application_details (
Config.PROJECT_NAME, Config.CORE_VERSION);
get_settings ().enable_developer_extras = true;
- load_uri (uri ?? "about:blank");
+
+ if (pinned) {
+ load_uri (uri ?? "about:blank");
+ } else {
+ load_uri_delayed.begin (uri);
+ }
+ }
+
+ async void load_uri_delayed (string? uri) {
+ display_uri = uri ?? "about:blank";
+ display_title = display_uri;
+
+ // Get title from history
+ try {
+ var history = HistoryDatabase.get_default ();
+ var items = yield history.query (display_title, 1);
+ item = items.nth_data (0);
+ if (item != null) {
+ display_title = item.title;
+ }
+ } catch (DatabaseError error) {
+ debug ("Failed to lookup title in history: %s", error.message);
+ }
+ }
+
+ public override bool focus_in_event (Gdk.EventFocus event) {
+ // Delayed load on focus
+ if (display_uri != uri) {
+ load_uri (display_uri);
+ }
+ return true;
}
void update_progress (ParamSpec pspec) {
diff --git a/core/tally.vala b/core/tally.vala
index aae8ceed..2897c40c 100644
--- a/core/tally.vala
+++ b/core/tally.vala
@@ -43,8 +43,8 @@ namespace Midori {
Gtk.Button close;
public Tally (Tab tab) {
- Object (tab: tab, uri: tab.uri, title: tab.display_title, visible: tab.visible);
- tab.bind_property ("uri", this, "uri");
+ Object (tab: tab, uri: tab.display_uri, title: tab.display_title, visible: tab.visible);
+ tab.bind_property ("display-uri", this, "uri");
tab.bind_property ("display-title", this, "title");
tab.bind_property ("visible", this, "visible");
close.clicked.connect (() => { tab.try_close (); });