From 16c067e32da5236d5357c086ac54a674d4e0f883 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 28 Sep 2014 22:46:37 +0200 Subject: [PATCH] Simplify showing of main windows. --- qutebrowser/app.py | 6 +----- qutebrowser/browser/commands.py | 2 +- qutebrowser/widgets/mainwindow.py | 9 +++++++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 0e4b152f8..cb7ad2dcf 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -114,10 +114,6 @@ class Application(QApplication): log.init.debug("Connecting signals...") self._connect_signals() - log.init.debug("Showing mainwindow...") - if not args.nowindow: - objreg.get('main-window', scope='window', window=0).show() - log.init.debug("Applying python hacks...") self._python_hacks() @@ -155,7 +151,7 @@ class Application(QApplication): download_manager = downloads.DownloadManager(self) objreg.register('download-manager', download_manager) log.init.debug("Initializing main window...") - mainwindow.create_window() + mainwindow.create_window(False if self._args.nowindow else True) log.init.debug("Initializing debug console...") debug_console = console.ConsoleWidget() objreg.register('debug-console', debug_console) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index d63f4ba7b..5043c2c76 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -108,7 +108,7 @@ class CommandDispatcher: elif window: # We have to import this here to avoid a circular import. from qutebrowser.widgets import mainwindow - win_id = mainwindow.create_window() + win_id = mainwindow.create_window(True) tabbed_browser = objreg.get('tabbed-browser', scope='window', window=win_id) tabbed_browser.tabopen(url) diff --git a/qutebrowser/widgets/mainwindow.py b/qutebrowser/widgets/mainwindow.py index 11caa3414..5bae11c4a 100644 --- a/qutebrowser/widgets/mainwindow.py +++ b/qutebrowser/widgets/mainwindow.py @@ -39,14 +39,19 @@ from qutebrowser.browser import hints win_id_gen = itertools.count(0) -def create_window(): +def create_window(show): """Create a new main window. + Args: + show: Show the window after creating. + Return: The new window id. """ win_id = next(win_id_gen) - MainWindow(win_id) + win = MainWindow(win_id) + if show: + win.show() return win_id