Commit 3d61f99b authored by Nico Alt's avatar Nico Alt

Make window property of application public

Sometimes it seems to work. Only in startup classes it can't access
it...

Also fix do_shutdown function.
parent ffe817bd
......@@ -37,8 +37,8 @@ class Application(Gtk.Application):
# pylint: disable=arguments-differ
def do_shutdown(self):
self.api.stop()
self._window.hide()
Gio.Application.quit(self)
self.window.hide()
Gio.Application.do_shutdown(self)
@staticmethod
def _set_application_name(name):
......@@ -61,7 +61,7 @@ class Application(Gtk.Application):
# pylint: disable=access-member-before-definition
def _setup_window(self):
if not hasattr(self, "_window") or self._window is None:
self._window = Window()
self._window.show()
self._window.present()
if not hasattr(self, "window") or self.window is None:
self.window = Window()
self.window.show()
self.window.present()
......@@ -18,9 +18,8 @@ class AddContactContainer(Container):
STACK_NAME = "add_contact_flow_stack"
HEADERS_NAME = "add_contact_flow_headers"
def __init__(self, window):
def __init__(self):
super().__init__()
self._window = window
self._setup_view()
self._load_content()
......@@ -45,7 +44,7 @@ class AddContactContainer(Container):
def _setup_add_contact_flow_headers(self):
add_contact_flow_headers = self.builder.get_object(self.HEADERS_NAME)
add_contact_flow_headers.show_all()
self._window.set_titlebar(add_contact_flow_headers)
APP().window.set_titlebar(add_contact_flow_headers)
def _setup_link_keystroke_listener(self):
their_link_entry = self.builder.get_object("their_link_entry")
......@@ -136,5 +135,6 @@ class AddContactContainer(Container):
alias = self.builder.get_object("alias_entry").get_text()
contacts.add_pending(their_link, alias)
# pylint: disable=no-self-use
def _back_to_main_window(self):
GLib.idle_add(self._window.back_to_main, None)
GLib.idle_add(APP().window.show_main_container)
......@@ -42,17 +42,18 @@ def test_quit(mocker):
api_stop_mock = mocker.patch("briar_wrapper.api.Api.stop")
window_mock = mocker.patch("briar_gtk.window.Window")
window_hide_mock = mocker.patch("briar_gtk.window.Window.hide")
quit_mock = mocker.patch("gi.repository.Gio.Application.quit")
do_shutdown_mock = mocker.patch(
"gi.repository.Gio.Application.do_shutdown")
application = Application()
application.api = api_mock
application._window = window_mock
application.window = window_mock
application.quit()
application.do_shutdown()
api_stop_mock.assert_called_once()
window_hide_mock.assert_called_once()
quit_mock.assert_called_once()
do_shutdown_mock.assert_called_once()
def test_set_application_name(mocker):
......@@ -121,7 +122,7 @@ def test_setup_window_has_attribute(mocker):
window_mock = Mock()
application = Application()
application._window = window_mock
application.window = window_mock
application._setup_window()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment