Fix race condition by introducing switch_page (old, new)
So there's no confusion which one is the new, current tab.
This commit is contained in:
parent
7124e36dd5
commit
ec04a1a274
5 changed files with 45 additions and 19 deletions
|
@ -132,17 +132,17 @@ namespace DelayedLoad {
|
|||
}
|
||||
}
|
||||
|
||||
private void tab_changed (GLib.Object window, GLib.ParamSpec pspec) {
|
||||
Midori.Browser browser = window as Midori.Browser;
|
||||
Midori.View? view = browser.tab as Midori.View;
|
||||
private void tab_changed (Midori.View? old_view, Midori.View? new_view) {
|
||||
if (new_view != null) {
|
||||
Midori.App app = get_app ();
|
||||
Midori.Browser browser = app.browser;
|
||||
|
||||
if (view != null) {
|
||||
Katze.Item item = view.get_proxy_item ();
|
||||
Katze.Item item = new_view.get_proxy_item ();
|
||||
item.ref();
|
||||
|
||||
int64 delay = item.get_meta_integer ("delay");
|
||||
if (delay == -2 && view.progress < 1.0) {
|
||||
this.schedule_reload (browser, view);
|
||||
if (delay == -2 && new_view.progress < 1.0) {
|
||||
this.schedule_reload (browser, new_view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -176,11 +176,11 @@ namespace DelayedLoad {
|
|||
}
|
||||
|
||||
private void browser_added (Midori.Browser browser) {
|
||||
browser.notify["tab"].connect (this.tab_changed);
|
||||
browser.switch_tab.connect_after (this.tab_changed);
|
||||
}
|
||||
|
||||
private void browser_removed (Midori.Browser browser) {
|
||||
browser.notify["tab"].disconnect (this.tab_changed);
|
||||
browser.switch_tab.disconnect (this.tab_changed);
|
||||
}
|
||||
|
||||
public void activated (Midori.App app) {
|
||||
|
|
|
@ -462,7 +462,7 @@ namespace HistoryList {
|
|||
tab_added (browser, tab);
|
||||
browser.add_tab.connect (tab_added);
|
||||
browser.remove_tab.connect (tab_removed);
|
||||
browser.notify["tab"].connect (this.tab_changed);
|
||||
browser.switch_tab.connect (this.tab_changed);
|
||||
}
|
||||
|
||||
void browser_removed (Midori.Browser browser) {
|
||||
|
@ -491,7 +491,7 @@ namespace HistoryList {
|
|||
|
||||
browser.add_tab.disconnect (tab_added);
|
||||
browser.remove_tab.disconnect (tab_removed);
|
||||
browser.notify["tab"].disconnect (this.tab_changed);
|
||||
browser.switch_tab.disconnect (this.tab_changed);
|
||||
}
|
||||
|
||||
void tab_added (Midori.Browser browser, Midori.View view) {
|
||||
|
@ -520,21 +520,18 @@ namespace HistoryList {
|
|||
}
|
||||
}
|
||||
|
||||
void tab_changed (GLib.Object window, GLib.ParamSpec pspec) {
|
||||
void tab_changed (Midori.View? old_view, Midori.View? new_view) {
|
||||
if(this.ignoreNextChange) {
|
||||
this.ignoreNextChange = false;
|
||||
} else {
|
||||
Midori.Browser browser = window as Midori.Browser;
|
||||
Midori.View view = null;
|
||||
Midori.View last_view = null;
|
||||
browser.get ("tab", ref view);
|
||||
|
||||
last_view = browser.get_data<Midori.View?> ("history-list-last-change");
|
||||
Midori.Browser browser = history_window as Midori.Browser;
|
||||
Midori.View? last_view
|
||||
= browser.get_data<Midori.View?> ("history-list-last-change");
|
||||
|
||||
if (last_view != null) {
|
||||
this.tab_list_resort (browser, last_view);
|
||||
}
|
||||
browser.set_data<Midori.View?> ("history-list-last-change", view);
|
||||
browser.set_data<Midori.View?> ("history-list-last-change", new_view);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ OBJECT:OBJECT
|
|||
VOID:BOOLEAN,STRING
|
||||
VOID:OBJECT,ENUM,BOOLEAN
|
||||
VOID:OBJECT,INT,INT
|
||||
VOID:OBJECT,OBJECT
|
||||
VOID:POINTER,INT
|
||||
VOID:STRING,BOOLEAN
|
||||
VOID:STRING,INT,STRING
|
||||
|
|
|
@ -145,6 +145,7 @@ enum
|
|||
ADD_TAB,
|
||||
REMOVE_TAB,
|
||||
MOVE_TAB,
|
||||
SWITCH_TAB,
|
||||
ACTIVATE_ACTION,
|
||||
ADD_DOWNLOAD,
|
||||
SEND_NOTIFICATION,
|
||||
|
@ -1884,6 +1885,28 @@ midori_browser_class_init (MidoriBrowserClass* class)
|
|||
G_TYPE_NONE, 3,
|
||||
GTK_TYPE_NOTEBOOK, G_TYPE_INT, G_TYPE_INT);
|
||||
|
||||
/**
|
||||
* MidoriBrowser::switch-tab:
|
||||
* @browser: the object on which the signal is emitted
|
||||
* @old_view: the previous tab
|
||||
* @new_view: the new tab
|
||||
*
|
||||
* Emitted when a tab is switched.
|
||||
* There's no guarantee what the current tab is.
|
||||
*
|
||||
* Since: 0.4.7
|
||||
*/
|
||||
signals[SWITCH_TAB] = g_signal_new (
|
||||
"switch-tab",
|
||||
G_TYPE_FROM_CLASS (class),
|
||||
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
||||
0,
|
||||
0,
|
||||
NULL,
|
||||
midori_cclosure_marshal_VOID__OBJECT_OBJECT,
|
||||
G_TYPE_NONE, 2,
|
||||
G_TYPE_POINTER, G_TYPE_POINTER);
|
||||
|
||||
signals[ACTIVATE_ACTION] = g_signal_new (
|
||||
"activate-action",
|
||||
G_TYPE_FROM_CLASS (class),
|
||||
|
@ -5107,7 +5130,10 @@ midori_browser_switched_tab (MidoriBrowser* browser,
|
|||
}
|
||||
|
||||
if (new_view == NULL)
|
||||
{
|
||||
g_signal_emit (browser, signals[SWITCH_TAB], 0, old_widget, new_view);
|
||||
return;
|
||||
}
|
||||
|
||||
g_return_if_fail (MIDORI_IS_VIEW (new_view));
|
||||
|
||||
|
@ -5123,6 +5149,7 @@ midori_browser_switched_tab (MidoriBrowser* browser,
|
|||
if (browser->proxy_array)
|
||||
katze_item_set_meta_integer (KATZE_ITEM (browser->proxy_array), "current", new_page);
|
||||
g_object_notify (G_OBJECT (browser), "tab");
|
||||
g_signal_emit (browser, signals[SWITCH_TAB], 0, old_widget, new_view);
|
||||
|
||||
_midori_browser_set_statusbar_text (browser, new_view, NULL);
|
||||
_midori_browser_update_interface (browser, new_view);
|
||||
|
|
|
@ -82,6 +82,7 @@ namespace Midori {
|
|||
public signal void add_tab (View tab);
|
||||
[HasEmitter]
|
||||
public signal void remove_tab (View tab);
|
||||
public signal void switch_tab (View? old_view, View? new_view);
|
||||
[HasEmitter]
|
||||
public signal void activate_action (string name);
|
||||
public signal void add_download (GLib.Object download);
|
||||
|
|
Loading…
Reference in a new issue