So there's no confusion which one is the new, current tab.
}
}
- 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);
}
}
}
}
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) {
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) {
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) {
}
}
- 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);
}
}
VOID:BOOLEAN,STRING
VOID:OBJECT,ENUM,BOOLEAN
VOID:OBJECT,INT,INT
+VOID:OBJECT,OBJECT
VOID:POINTER,INT
VOID:STRING,BOOLEAN
VOID:STRING,INT,STRING
ADD_TAB,
REMOVE_TAB,
MOVE_TAB,
+ SWITCH_TAB,
ACTIVATE_ACTION,
ADD_DOWNLOAD,
SEND_NOTIFICATION,
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),
}
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));
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);
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);