summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Dywan <christian@twotoasts.de>2018-08-09 12:00:14 +0200
committerGitHub <noreply@github.com>2018-08-09 12:00:14 +0200
commit679aa2644fa9a2a6e2c14b539eee940d7e34c966 (patch)
tree527e6674b0261acde7144b827a9a61e3748b706a
parent6af9c6a330c7b2666aa8689e79211cc66112f885 (diff)
downloadmidori-git-679aa2644fa9a2a6e2c14b539eee940d7e34c966.tar.gz
More consistent handling of Tab.item and Tab.create (#8)
* create normally loads a given request and emits ready_to_show, so we should support this and emulate the same behavior when emitting create. * a new browser tab should get focus. * Tab.item should be set in the case of a delayed load. * tooltips should always be set for the tally.
-rw-r--r--core/browser.vala14
-rw-r--r--core/tab.vala21
-rw-r--r--core/tally.vala7
3 files changed, 28 insertions, 14 deletions
diff --git a/core/browser.vala b/core/browser.vala
index 7b147a4b..2ee9e175 100644
--- a/core/browser.vala
+++ b/core/browser.vala
@@ -223,7 +223,9 @@ namespace Midori {
}
void tab_new_activated () {
- add (new Tab (tab, web_context));
+ var tab = new Tab (tab, web_context);
+ add (tab);
+ tabs.visible_child = tab;
}
void tab_close_activated () {
@@ -238,7 +240,7 @@ namespace Midori {
uint index = trash.get_n_items ();
if (index > 0) {
var item = trash.get_object (index - 1) as DatabaseItem;
- add (new Tab (tab, web_context, item.uri));
+ add (new Tab (tab, web_context, item.uri, item.title));
trash.remove (index - 1);
}
}
@@ -325,8 +327,12 @@ namespace Midori {
public new void add (Tab tab) {
tab.create.connect ((action) => {
- var new_tab = new Tab (tab, web_context, action.get_request ().uri);
- add (new_tab);
+ var new_tab = new Tab (tab, web_context);
+ new_tab.hide ();
+ new_tab.ready_to_show.connect (() => {
+ new_tab.show ();
+ add (new_tab);
+ });
return new_tab;
});
tab.enter_fullscreen.connect (() => {
diff --git a/core/tab.vala b/core/tab.vala
index 3a177711..60c85081 100644
--- a/core/tab.vala
+++ b/core/tab.vala
@@ -42,13 +42,12 @@ namespace Midori {
});
notify["title"].connect ((pspec) => {
display_title = (title != null && title != "") ? title : display_uri;
- if (item != null) {
- item.title = display_title;
- }
+ item.title = display_title;
});
}
- public Tab (Tab? related, WebKit.WebContext web_context, string? uri = null) {
+ public Tab (Tab? related, WebKit.WebContext web_context,
+ string? uri = null, string? title = null) {
Object (related_view: related, web_context: web_context, visible: true);
get_settings ().set_user_agent_with_application_details (
@@ -58,21 +57,23 @@ namespace Midori {
if (pinned) {
load_uri (uri ?? "about:blank");
} else {
- load_uri_delayed.begin (uri);
+ load_uri_delayed.begin (uri, title);
}
}
- async void load_uri_delayed (string? uri) {
+ async void load_uri_delayed (string? uri, string? title) {
display_uri = uri ?? "about:blank";
- display_title = display_uri;
+ display_title = title ?? display_uri;
+ item = new DatabaseItem (display_uri, display_title, 0);
// Get title from history
try {
var history = HistoryDatabase.get_default ();
var items = yield history.query (display_title, 1);
- item = items.nth_data (0);
+ var item = items.nth_data (0);
if (item != null) {
display_title = item.title;
+ this.item = item;
}
} catch (DatabaseError error) {
debug ("Failed to lookup title in history: %s", error.message);
@@ -223,7 +224,9 @@ namespace Midori {
bool has_ctrl = (action.get_modifiers () & Gdk.ModifierType.CONTROL_MASK) != 0;
if (action.get_mouse_button () == 2
|| (has_ctrl && action.get_mouse_button () == 1)) {
- create (action);
+ var tab = ((Tab)create (action));
+ tab.load_request (action.get_request ());
+ tab.ready_to_show ();
decision.ignore ();
return true;
}
diff --git a/core/tally.vala b/core/tally.vala
index a3cd4683..16382349 100644
--- a/core/tally.vala
+++ b/core/tally.vala
@@ -45,9 +45,14 @@ namespace Midori {
Gtk.Button close;
public Tally (Tab tab) {
- Object (tab: tab, uri: tab.display_uri, title: tab.display_title, visible: tab.visible);
+ Object (tab: tab,
+ uri: tab.display_uri,
+ title: tab.display_title,
+ tooltip_text: tab.display_title,
+ visible: tab.visible);
tab.bind_property ("display-uri", this, "uri");
tab.bind_property ("display-title", this, "title");
+ tab.bind_property ("display-title", this, "tooltip-text");
tab.bind_property ("visible", this, "visible");
close.clicked.connect (() => { tab.try_close (); });
tab.notify["is-loading"].connect ((pspec) => {