summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Dywan <christian@twotoasts.de>2018-07-31 00:07:13 +0200
committerChristian Dywan <christian@twotoasts.de>2018-07-31 00:07:13 +0200
commitcc85661441ab1c4495fc3508cd6ddf671394aa39 (patch)
tree776df79a5ce9ffc3a4a469077451b2248d2cd135
parent22b6b89e7d03e479b6e81a7c5557e38c0a1d3107 (diff)
downloadmidori-git-tab-item-tab-create.tar.gz
More consistent handling of Tab.item and Tab.createtab-item-tab-create
-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 2897c40c..5c1214da 100644
--- a/core/tally.vala
+++ b/core/tally.vala
@@ -43,9 +43,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) => {