[Pkg-sugar-commit] [sugar-browse-activity] 03/05: Add shortcut to close the current tab

Jonas Smedegaard dr at jones.dk
Mon Apr 20 09:47:54 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag v149.4
in repository sugar-browse-activity.

commit 8c9130e7533e41d637a7bc1cc70307e8bf945808
Author: Manuel Quiñones <manuq at laptop.org>
Date:   Thu Sep 5 11:02:03 2013 -0300

    Add shortcut to close the current tab
    
    And improve the code of the tab close
    
    Fixes #4590
---
 browser.py     | 27 ++++++++++++---------------
 webactivity.py |  3 +++
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/browser.py b/browser.py
index 397b4fd..18c16ab 100644
--- a/browser.py
+++ b/browser.py
@@ -286,20 +286,12 @@ class TabbedView(BrowserNotebook):
     def on_add_tab(self, gobject):
         self.add_tab()
 
-    def __tab_close_cb(self, label, tab_page):
-        if tab_page.props.browser == self.props.current_browser:
-            # Current browser was just closed. The next tab of it has
-            # to take the focus.
-            current_page_num = self.page_num(tab_page)
-
-            if self.get_n_pages() - 1 == current_page_num:
-                # This tab was the last. Grab the left one.
-                page_to_focus = current_page_num - 1
-            else:
-                # This tab was in the middle. Grab the right one.
-                page_to_focus = current_page_num + 1
-            nth_page = self.get_nth_page(page_to_focus)
-            nth_page.props.browser.grab_focus()
+    def close_tab(self, tab_page=None):
+        if self.get_n_pages() == 1:
+            return
+
+        if tab_page is None:
+            tab_page = self.get_nth_page(self.get_current_page())
 
         if isinstance(tab_page, PDFTabPage):
             if tab_page.props.browser.props.load_status < \
@@ -307,7 +299,12 @@ class TabbedView(BrowserNotebook):
                 tab_page.cancel_download()
 
         self.remove_page(self.page_num(tab_page))
-        tab_page.destroy()
+
+        current_page = self.get_nth_page(self.get_current_page())
+        current_page.props.browser.grab_focus()
+
+    def __tab_close_cb(self, label, tab_page):
+        self.close_tab(tab_page)
 
     def _update_tab_sizes(self):
         """Update tab widths based in the amount of tabs."""
diff --git a/webactivity.py b/webactivity.py
index 3c0d337..3232f9d 100644
--- a/webactivity.py
+++ b/webactivity.py
@@ -505,6 +505,9 @@ class WebActivity(activity.Activity):
                 browser.reload()
             elif Gdk.keyval_name(event.keyval) == "t":
                 self._tabbed_view.add_tab()
+            elif key_name == 'w':
+                _logger.debug('keyboard: close tab')
+                self._tabbed_view.close_tab()
             else:
                 return False
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-sugar/sugar-browse-activity.git



More information about the pkg-sugar-commit mailing list