From: André Stösel Date: Mon, 13 Dec 2010 19:19:30 +0000 (+0100) Subject: Be sure to end up at last opened tab after closing X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4e94b4f193be2e58fd17cf06ca1e43be119d1f1;p=midori Be sure to end up at last opened tab after closing --- diff --git a/extensions/history-list.vala b/extensions/history-list.vala index 3bb1d98e..d6b24a3a 100644 --- a/extensions/history-list.vala +++ b/extensions/history-list.vala @@ -1,5 +1,5 @@ /* - Copyright (C) 2010 André Stösel + Copyright (C) 2010 André Stösel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -187,6 +187,13 @@ private class HistoryList : Midori.Extension { return false; } public void walk (Gtk.Action action, Browser browser, Type type, int step) { + Midori.View? view = null; + view = browser.get_data ("history-list-last-change"); + if (view != null) { + this.tab_list_resort (browser, view); + browser.set_data ("history-list-last-change", null); + } + if (this.history_window == null || this.history_window.get_type () != type) { if (this.history_window == null) { this.modifier_count = Midori.Sokoke.gtk_action_count_modifiers (action); @@ -264,6 +271,8 @@ private class HistoryList : Midori.Extension { new GLib.PtrArray ()); browser.set_data ("history-list-tab-history-new", new GLib.PtrArray ()); + browser.set_data ("history-list-last-change", null); + foreach (var tab in browser.get_tabs ()) tab_added (browser, tab); browser.add_tab.connect (tab_added); @@ -271,7 +280,8 @@ private class HistoryList : Midori.Extension { browser.notify["tab"].connect (this.tab_changed); } void browser_removed (Midori.Browser browser) { - string[] callbacks = { "HistoryListNextTab", "HistoryListPreviousTab" }; + string[] callbacks = { "HistoryListNextTab", "HistoryListPreviousTab", + "HistoryListNextNewTab", "HistoryListPreviousNewTab" }; Gtk.ActionGroup action_group; action_group = browser.get_action_group (); @@ -294,12 +304,28 @@ private class HistoryList : Midori.Extension { unowned GLib.PtrArray list_new = browser.get_data ("history-list-tab-history-new"); list.remove (view); list_new.remove (view); + browser.set_data ("history-list-last-change", null); + + if ((int) list.len > 0 || (int) list_new.len > 0) { + var hw = new TabWindow (browser); + hw.make_update (); + hw.destroy (); + } } void tab_changed (GLib.Object window, GLib.ParamSpec pspec) { 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 ("history-list-last-change"); + + if (last_view != null) { + this.tab_list_resort (browser, last_view); + } + browser.set_data ("history-list-last-change", view); + } + void tab_list_resort (Midori.Browser browser, Midori.View view) { unowned GLib.PtrArray list = browser.get_data ("history-list-tab-history"); unowned GLib.PtrArray list_new = browser.get_data ("history-list-tab-history-new"); list.remove (view); @@ -320,8 +346,8 @@ private class HistoryList : Midori.Extension { internal HistoryList () { GLib.Object (name: _("History List"), description: _("Switch tabs with Ctrl+Tab sorted by last usage"), - version: "0.2", - authors: "André Stösel "); + version: "0.3", + authors: "André Stösel "); activate.connect (activated); deactivate.connect (deactivated); }