Ticket #3534: 0001-Undo-close-tab-SL-3534.patch

File 0001-Undo-close-tab-SL-3534.patch, 2.4 KB (added by humitos, 11 years ago)
  • browser.py

    From b668100ce6c872baee8d5c3c7bd09622d656f46f Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Mon, 24 Sep 2012 13:45:48 -0300
    Subject: [PATCH Browse] Undo close tab SL #3534
    
    Browse manages a list of 10 recently closed tab to be able to re-open
    them (the most recently closed is opened firstly) by pressing
    Ctrl+Shift+T.
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     browser.py     | 13 +++++++++++++
     webactivity.py | 11 +++++++++--
     2 files changed, 22 insertions(+), 2 deletions(-)
    
    diff --git a/browser.py b/browser.py
    index de546f2..8f960cc 100644
    a b  
    1919import os
    2020import time
    2121import re
     22import collections
    2223from gettext import gettext as _
    2324
    2425from gi.repository import GObject
    class TabbedView(BrowserNotebook): 
    99100        self._update_closing_buttons()
    100101        self._update_tab_sizes()
    101102
     103        # LIFO queue of closed tabs (10 tabs max)
     104        self.closed_tabs = collections.deque(maxlen=10)
     105
     106    def get_last_closed_tab(self):
     107        try:
     108            uri = self.closed_tabs.pop()
     109        except IndexError:
     110            uri = None
     111        return uri
     112
    102113    def normalize_or_autosearch_url(self, url):
    103114        """Normalize the url input or return a url for search.
    104115
    class TabbedView(BrowserNotebook): 
    164175        self._update_tab_sizes()
    165176
    166177    def __page_removed_cb(self, notebook, child, pagenum):
     178        self.closed_tabs.append(child._browser.props.uri)
     179
    167180        if self.get_n_pages():
    168181            self._update_closing_buttons()
    169182            self._update_tab_sizes()
  • webactivity.py

    diff --git a/webactivity.py b/webactivity.py
    index 24f3b44..2559fa7 100644
    a b class WebActivity(activity.Activity): 
    428428    def _key_press_cb(self, widget, event):
    429429        key_name = Gdk.keyval_name(event.keyval)
    430430        browser = self._tabbed_view.props.current_browser
    431 
    432         if event.get_state() & Gdk.ModifierType.CONTROL_MASK:
     431        state = event.get_state()
     432
     433        if state & Gdk.ModifierType.CONTROL_MASK:
     434            if state & Gdk.ModifierType.SHIFT_MASK:
     435                if key_name == 'T':
     436                    uri = self._tabbed_view.get_last_closed_tab()
     437                    if uri is not None:
     438                        self._tabbed_view.current_browser.emit('new-tab', uri)
     439                    return True
    433440
    434441            if key_name == 'd':
    435442                self._add_link()