Skip to content
Snippets Groups Projects
Commit c9740f3a authored by Nico's avatar Nico
Browse files

Use name view instead of container in Window

parent 1a58be08
No related branches found
No related tags found
1 merge request!89Refactor MainWindowContainer and others into several controllers/views
......@@ -64,34 +64,34 @@ class WindowActions(Actions):
# pylint: disable=unused-argument
def _back_to_sidebar(self, action, parameter):
if isinstance(self.widget.current_controller, MainWindowController):
self.widget.current_controller.close_private_chat()
if isinstance(self.widget.main_window_controller, MainWindowController):
self.widget.main_window_controller.close_private_chat()
# pylint: disable=unused-argument
def _delete_all_messages_dialog(self, action, parameter):
self.widget.current_controller.open_delete_all_messages_dialog()
self.widget.main_window_controller.open_delete_all_messages_dialog()
# pylint: disable=unused-argument
def _delete_contact_dialog(self, action, parameter):
self.widget.current_controller.open_delete_contact_dialog()
self.widget.main_window_controller.open_delete_contact_dialog()
# pylint: disable=unused-argument
def _change_alias_contact_dialog(self, action, parameter):
self.widget.current_controller.open_change_contact_alias_dialog()
self.widget.main_window_controller.open_change_contact_alias_dialog()
# pylint: disable=unused-argument
def _open_about_page(self, action, parameter):
self.widget.current_controller.open_about_page()
self.widget.main_window_controller.open_about_page()
# pylint: disable=unused-argument
def _open_add_contact(self, action, parameter):
self.widget.show_add_contact_container()
self.widget.show_add_contact_view()
# pylint: disable=unused-argument
def _open_main_window(self, action, parameter):
self.widget.show_main_container()
self.widget.show_main_window_view()
# pylint: disable=unused-argument
def _open_private_chat(self, action, contact_id):
self.widget.current_controller.open_private_chat(
self.widget.main_window_controller.open_private_chat(
contact_id.get_int32())
......@@ -63,7 +63,7 @@ class AddContactView(Gtk.Overlay):
return
alias_error_label.hide()
self._add_contact()
APP().window.show_main_container()
APP().window.show_main_window_view()
def _setup_view(self):
self._add_from_resource(self.ADD_CONTACT_UI)
......
......@@ -80,7 +80,7 @@ class LoginView(Gtk.Overlay):
def _login_completed(self, succeeded):
function = self._login_failed
if succeeded:
function = self._window.show_main_container
function = self._window.show_main_window_view
GLib.idle_add(function)
def _login_failed(self):
......
......@@ -142,7 +142,7 @@ class RegistrationView(Gtk.Overlay):
def _registration_completed(self, succeeded):
function = self._registration_failed
if succeeded:
function = self._window.show_main_container
function = self._window.show_main_window_view
GLib.idle_add(function)
def _registration_failed(self):
......
......@@ -22,18 +22,21 @@ class Window(Gtk.ApplicationWindow):
DEFAULT_WINDOW_SIZE = (900, 600)
def __init__(self):
self.main_window_controller = None
self._initialize_gtk_application_window()
WindowActions(self)
self._setup_content()
self._setup_focus_listener()
def show_main_container(self):
self.current_container.destroy()
self._setup_main_container()
def show_main_window_view(self):
self._current_view.destroy()
self._setup_main_window_view()
def show_add_contact_container(self):
self.current_container.destroy()
self._setup_add_contact_container()
def show_add_contact_view(self):
self._current_view.destroy()
if self.main_window_controller is not None:
self.main_window_controller = None
self._setup_add_contact_view()
# pylint: disable=arguments-differ,unused-argument
def do_delete_event(self, event):
......@@ -70,7 +73,7 @@ class Window(Gtk.ApplicationWindow):
def _setup_content(self):
self._resize_window(self.DEFAULT_WINDOW_SIZE)
self._setup_startup_container()
self._setup_startup_view()
def _setup_focus_listener(self):
self.connect("focus-in-event", self._on_focus_change)
......@@ -93,25 +96,24 @@ class Window(Gtk.ApplicationWindow):
isinstance(size[0], int) and\
isinstance(size[1], int)
def _setup_container(self, container):
self.current_container = container
self.current_container.show_all()
self.add(self.current_container)
def _setup_view(self, view):
self._current_view = view
self._current_view.show_all()
self.add(self._current_view)
def _setup_startup_container(self):
self._setup_container(StartupView(self))
def _setup_startup_view(self):
self._setup_view(StartupView(self))
def _setup_main_container(self):
def _setup_main_window_view(self):
builder = self._setup_builder()
main_window_view = MainWindowView(builder, self)
main_window_controller = MainWindowController(
self.main_window_controller = MainWindowController(
main_window_view, builder)
self._setup_container(main_window_view)
self._setup_view(main_window_view)
builder.get_object("chat_menu_button").hide() # TODO: Make default
self.current_controller = main_window_controller
def _setup_add_contact_container(self):
self._setup_container(AddContactView())
def _setup_add_contact_view(self):
self._setup_view(AddContactView())
def _setup_builder(self):
builder = Gtk.Builder.new()
......
......@@ -21,7 +21,7 @@ def test_startup_container_at_init(mocker, startup_container, window_actions,
window = Window()
startup_container.assert_called_once_with(window)
window.current_container.show_all.assert_called_once()
window._current_view.show_all.assert_called_once()
def test_window_actions_at_init(mocker, startup_container, window_actions,
......@@ -35,13 +35,13 @@ def test_window_add_at_init(mocker, startup_container, window_actions,
window_add, window_resize):
window = Window()
window_add.assert_called_once_with(window.current_container)
window_add.assert_called_once_with(window._current_view)
def test_show_main_container(main_window_container, mocker,
startup_container, window_actions,
window_add, window_resize):
Window().show_main_container()
Window().show_main_window_view()
main_window_container.assert_called_once()
......@@ -51,9 +51,9 @@ def test_show_main_shown(main_window_container, mocker,
window_add, window_resize):
window = Window()
window.show_main_container()
window.show_main_window_view()
window.current_container.show_all.assert_called_once()
window._current_view.show_all.assert_called_once()
def test_show_main_add(main_window_container, mocker,
......@@ -62,9 +62,9 @@ def test_show_main_add(main_window_container, mocker,
window = Window()
window_add = mocker.patch(MODULE % "Window.add")
window.show_main_container()
window.show_main_window_view()
window_add.assert_called_once_with(window.current_container)
window_add.assert_called_once_with(window._current_view)
def test_show_main_destroy_old(main_window_container, mocker,
......@@ -72,9 +72,9 @@ def test_show_main_destroy_old(main_window_container, mocker,
window_add, window_resize):
window = Window()
current_container_mock = mocker.MagicMock()
window.current_container = current_container_mock
window._current_view = current_container_mock
window.show_main_container()
window.show_main_window_view()
current_container_mock.destroy.assert_called_once()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment