Clean up start_pages setting

The value is now of type FuzzyUrl, and the setting is renamed to start_pages.
This commit is contained in:
Florian Bruhin 2017-06-30 19:25:16 +02:00
parent 9cbacf3264
commit c141c33b32
8 changed files with 18 additions and 22 deletions

View File

@ -306,15 +306,9 @@ def _open_startpage(win_id=None):
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=cur_win_id)
if tabbed_browser.count() == 0:
log.init.debug("Opening startpage")
for urlstr in config.val.start_page:
try:
url = urlutils.fuzzy_url(urlstr, do_search=False)
except urlutils.InvalidUrlError as e:
message.error("Error when opening startpage: {}".format(e))
tabbed_browser.tabopen(QUrl('about:blank'))
else:
tabbed_browser.tabopen(url)
log.init.debug("Opening start pages")
for url in config.val.start_pages:
tabbed_browser.tabopen(url)
def _open_special_pages(args):

View File

@ -1192,7 +1192,7 @@ class CommandDispatcher:
@cmdutils.register(instance='command-dispatcher', scope='window')
def home(self):
"""Open main startpage in current tab."""
self.openurl(config.val.start_page[0])
self._current_widget().openurl(config.val.start_pages[0])
def _run_userscript(self, cmd, *args, verbose=False):
"""Run a userscript given as argument.

View File

@ -106,10 +106,10 @@ session_default_name:
desc: The name of the session to save by default, or unset for the last loaded
session.
start_page:
start_pages:
type:
name: List
valtype: String
valtype: FuzzyUrl
default: ["https://start.duckduckgo.com"]
desc: The default page(s) to open at the start.

View File

@ -263,8 +263,8 @@ class TabbedBrowser(tabwidget.TabWidget):
elif last_close == 'blank':
self.openurl(QUrl('about:blank'), newtab=True)
elif last_close == 'startpage':
url = QUrl(config.val.start_page[0])
self.openurl(url, newtab=True)
for url in config.val.start_pages:
self.openurl(url, newtab=True)
elif last_close == 'default-page':
url = config.val.default_page
self.openurl(url, newtab=True)
@ -329,7 +329,7 @@ class TabbedBrowser(tabwidget.TabWidget):
no_history = len(self.widget(0).history) == 1
urls = {
'blank': QUrl('about:blank'),
'startpage': QUrl(config.val.start_page[0]),
'startpage': config.val.start_pages[0],
'default-page': config.val.default_page,
}
first_tab_url = self.widget(0).url()

View File

@ -96,7 +96,7 @@ Feature: Invoking a new process
Scenario: Opening a new qutebrowser instance with no parameters
When I set new_instance_open_target to tab
And I set start_page to ["http://localhost:(port)/data/hello.txt"]
And I set start_pages to ["http://localhost:(port)/data/hello.txt"]
And I open data/title.html
And I spawn a new window
And I wait until data/hello.txt is loaded

View File

@ -327,12 +327,12 @@ Feature: Various utility commands.
# :home
Scenario: :home with single page
When I set start_page to ["http://localhost:(port)/data/hello2.txt"]
When I set start_pages to ["http://localhost:(port)/data/hello2.txt"]
And I run :home
Then data/hello2.txt should be loaded
Scenario: :home with multiple pages
When I set start_page to ["http://localhost:(port)/data/numbers/1.txt", "http://localhost:(port)/data/numbers/2.txt"]
When I set start_pages to ["http://localhost:(port)/data/numbers/1.txt", "http://localhost:(port)/data/numbers/2.txt"]
And I run :home
Then data/numbers/1.txt should be loaded

View File

@ -715,7 +715,7 @@ Feature: Tab management
When I open data/hello.txt
And I run :tab-only
And I set tabs.last_close to startpage
And I set start_page to ["http://localhost:(port)/data/numbers/4.txt", "http://localhost:(port)/data/numbers/5.txt"]
And I set start_pages to ["http://localhost:(port)/data/numbers/4.txt"]
And I run :tab-close
And I wait until data/numbers/4.txt is loaded
And I run :undo
@ -807,14 +807,16 @@ Feature: Tab management
- about:blank (active)
Scenario: last-close = startpage
When I set start_page to ["http://localhost:(port)/data/numbers/7.txt", "http://localhost:(port)/data/numbers/8.txt"]
When I set start_pages to ["http://localhost:(port)/data/numbers/7.txt", "http://localhost:(port)/data/numbers/8.txt"]
And I set tabs.last_close to startpage
And I open data/hello.txt
And I run :tab-only
And I run :tab-close
And I wait until data/numbers/7.txt is loaded
And I wait until data/numbers/8.txt is loaded
Then the following tabs should be open:
- data/numbers/7.txt (active)
- data/numbers/7.txt
- data/numbers/8.txt (active)
Scenario: last-close = default-page
When I set default_page to http://localhost:(port)/data/numbers/9.txt

View File

@ -27,4 +27,4 @@ def invoke_with(quteproc):
quteproc.log_summary("Create a new window")
quteproc.send_ipc([], target_arg='window')
quteproc.wait_for(category='init', module='app',
function='_open_startpage', message='Opening startpage')
function='_open_startpage', message='Opening start pages')