From 24a1104dc750659679f9440945e5dbe93a681058 Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 4 Jan 2019 18:03:33 -0500 Subject: [PATCH 1/4] Implement pinned.tab.frozen setting (issue #4400) Implement a new setting, `pinned.tab.frozen` (boolean), which when false allows a user to navigate to new URLs in a pinned tab (default behavior is to have `pinned.tab.frozen = true`, in which no navigation is allowed). issue URL: https://github.com/qutebrowser/qutebrowser/issues/4400 Changes to be committed: modified: qutebrowser/browser/browsertab.py Add `navigation_blocked` method to AbstractTab, which returns true if navigation is allowed on a tab. modified: qutebrowser/browser/commands.py Change `openurl` to use `navigation_blocked` method of a tab to determine behavior while navigating a pinned tab. modified: qutebrowser/components/misccommands.py Change `home` to use `navigation_blocked` method of a tab to determine behavior while navigating a pinned tab. modified: qutebrowser/config/configdata.yml Add `pinned.tab.frozen` config. modified: tests/end2end/features/tabs.feature Add tests for :open and :home on pinned tabs with `pinned.tab.frozen` set to false --- qutebrowser/browser/browsertab.py | 4 ++++ qutebrowser/browser/commands.py | 7 ++++--- qutebrowser/components/misccommands.py | 2 +- qutebrowser/config/configdata.yml | 5 +++++ tests/end2end/features/tabs.feature | 18 ++++++++++++++++++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index 029394657..80871a254 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -943,6 +943,10 @@ class AbstractTab(QWidget): evt.posted = True QApplication.postEvent(recipient, evt) + def navigation_blocked(self) -> bool: + """Test if navigation is allowed on the current tab.""" + return self.data.pinned and config.val.pinned.tab.frozen + @pyqtSlot(QUrl) def _on_before_load_started(self, url: QUrl) -> None: """Adjust the title if we are going to visit a URL soon.""" diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 571e06d8b..c47811701 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -316,10 +316,11 @@ class CommandDispatcher: else: # Explicit count with a tab that doesn't exist. return - elif curtab.data.pinned: - message.info("Tab is pinned!") else: - curtab.load_url(cur_url) + if curtab.navigation_blocked(): + message.info("Tab is pinned!") + else: + curtab.load_url(cur_url) def _parse_url(self, url, *, force_search=False): """Parse a URL or quickmark or search query. diff --git a/qutebrowser/components/misccommands.py b/qutebrowser/components/misccommands.py index eaf45f40d..a65bdd235 100644 --- a/qutebrowser/components/misccommands.py +++ b/qutebrowser/components/misccommands.py @@ -118,7 +118,7 @@ def printpage(tab: apitypes.Tab, @cmdutils.argument('tab', value=cmdutils.Value.cur_tab) def home(tab: apitypes.Tab) -> None: """Open main startpage in current tab.""" - if tab.data.pinned: + if tab.navigation_blocked(): message.info("Tab is pinned!") else: tab.load_url(config.val.url.start_pages[0]) diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index bed4d9659..15b3eb446 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -2917,3 +2917,8 @@ bindings.commands: * register: Entered when qutebrowser is waiting for a register name/key for commands like `:set-mark`. + +pinned.tab.frozen: + type: Bool + default: True + desc: If true, then pinned tabs cannot have their URL changed. diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index 7f4d4635c..ec6400458 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -1289,6 +1289,14 @@ Feature: Tab management And the following tabs should be open: - data/numbers/1.txt (active) (pinned) + Scenario: :tab-pin open url with pinned.tab.frozen = false + When I set pinned.tab.frozen to false + And I open data/numbers/1.txt + And I run :tab-pin + And I open data/numbers/2.txt + Then the following tabs should be open: + - data/numbers/2.txt (active) (pinned) + Scenario: :home on a pinned tab When I open data/numbers/1.txt And I run :tab-pin @@ -1297,6 +1305,16 @@ Feature: Tab management And the following tabs should be open: - data/numbers/1.txt (active) (pinned) + Scenario: :home on a pinned tab with pinned.tab.frozen = false + When I set url.start_pages to ["http://localhost:(port)/data/numbers/2.txt"] + And I set pinned.tab.frozen to false + And I open data/numbers/1.txt + And I run :tab-pin + And I run :home + Then data/numbers/2.txt should be loaded + And the following tabs should be open: + - data/numbers/2.txt (active) (pinned) + Scenario: Cloning a pinned tab When I open data/numbers/1.txt And I run :tab-pin From 9662d3aa252dc31c574c52299b9abc6560d6334c Mon Sep 17 00:00:00 2001 From: adam Date: Sat, 5 Jan 2019 23:21:59 -0500 Subject: [PATCH 2/4] Change commands.py to maintain old indent level Changes to be committed: modified: qutebrowser/browser/commands.py --- qutebrowser/browser/commands.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index c47811701..6ae47f9d9 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -316,11 +316,10 @@ class CommandDispatcher: else: # Explicit count with a tab that doesn't exist. return + elif curtab.navigation_blocked(): + message.info("Tab is pinned!") else: - if curtab.navigation_blocked(): - message.info("Tab is pinned!") - else: - curtab.load_url(cur_url) + curtab.load_url(cur_url) def _parse_url(self, url, *, force_search=False): """Parse a URL or quickmark or search query. From 5cd988ae52eeadb85d97bfa95c2773c0e3f4e7a8 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 6 Jan 2019 20:53:26 -0500 Subject: [PATCH 3/4] Change config option to in tabs.pinned group Changes to be committed: modified: qutebrowser/browser/browsertab.py modified: qutebrowser/config/configdata.yml modified: tests/end2end/features/tabs.feature Changed pinned.tabs.frozen to be tabs.pinned.frozen in all of these files. --- qutebrowser/browser/browsertab.py | 2 +- qutebrowser/config/configdata.yml | 10 +++++----- tests/end2end/features/tabs.feature | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index 80871a254..55ab89a20 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -945,7 +945,7 @@ class AbstractTab(QWidget): def navigation_blocked(self) -> bool: """Test if navigation is allowed on the current tab.""" - return self.data.pinned and config.val.pinned.tab.frozen + return self.data.pinned and config.val.tabs.pinned.frozen @pyqtSlot(QUrl) def _on_before_load_started(self, url: QUrl) -> None: diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 15b3eb446..f6313cc88 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1768,6 +1768,11 @@ tabs.pinned.shrink: type: Bool desc: Shrink pinned tabs down to their contents. +tabs.pinned.frozen: + type: Bool + default: True + desc: If true, then pinned tabs cannot have their URL changed. + tabs.wrap: default: true type: Bool @@ -2917,8 +2922,3 @@ bindings.commands: * register: Entered when qutebrowser is waiting for a register name/key for commands like `:set-mark`. - -pinned.tab.frozen: - type: Bool - default: True - desc: If true, then pinned tabs cannot have their URL changed. diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index ec6400458..804f72bbf 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -1289,8 +1289,8 @@ Feature: Tab management And the following tabs should be open: - data/numbers/1.txt (active) (pinned) - Scenario: :tab-pin open url with pinned.tab.frozen = false - When I set pinned.tab.frozen to false + Scenario: :tab-pin open url with tabs.pinned.frozen = false + When I set tabs.pinned.frozen to false And I open data/numbers/1.txt And I run :tab-pin And I open data/numbers/2.txt @@ -1305,9 +1305,9 @@ Feature: Tab management And the following tabs should be open: - data/numbers/1.txt (active) (pinned) - Scenario: :home on a pinned tab with pinned.tab.frozen = false + Scenario: :home on a pinned tab with tabs.pinned.frozen = false When I set url.start_pages to ["http://localhost:(port)/data/numbers/2.txt"] - And I set pinned.tab.frozen to false + And I set tabs.pinned.frozen to false And I open data/numbers/1.txt And I run :tab-pin And I run :home From 65ae7ca455b2520f5f78ec4ab497cdb073259602 Mon Sep 17 00:00:00 2001 From: adam Date: Mon, 7 Jan 2019 15:42:01 -0500 Subject: [PATCH 4/4] Make option desc imperative As given in commit https://github.com/qutebrowser/qutebrowser/commit/494aceec451e307b0227b0fdd0f86d419dbc11d1 Changes to be committed: modified: qutebrowser/config/configdata.yml --- qutebrowser/config/configdata.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index f6313cc88..b6d4736ae 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1771,7 +1771,7 @@ tabs.pinned.shrink: tabs.pinned.frozen: type: Bool default: True - desc: If true, then pinned tabs cannot have their URL changed. + desc: Force pinned tabs to stay at fixed URL. tabs.wrap: default: true