Commit 8e368723 authored by Nico's avatar Nico
Browse files

Actually start using MainWindowController

parent e2b7dad3
......@@ -2,8 +2,32 @@
# SPDX-License-Identifier: AGPL-3.0-only
# License-Filename: LICENSE.md
from briar_gtk.controllers.main_menu import MainMenuController
from briar_gtk.controllers.private_chat import PrivateChatController
from briar_gtk.controllers.sidebar import SidebarController
from briar_gtk.define import APP
from briar_gtk.views.main_menu import MainMenuView
from briar_gtk.views.private_chat import PrivateChatView
from briar_gtk.views.sidebar import SidebarView
class MainWindowController():
def __init__(self):
pass
def __init__(self, main_window_view, builder):
self._main_window_view = main_window_view
self._builder = builder
self._setup_children()
def _setup_children(self):
self._sidebar_view = SidebarView(self._builder)
self._sidebar_controller = SidebarController(
self._sidebar_view, APP().api)
self._private_chat_view = PrivateChatView(self._builder)
self._private_chat_controller = PrivateChatController(
self._private_chat_view, APP().api)
self._main_menu_view = MainMenuView()
self._main_menu_controller = MainMenuController(
self._main_menu_view, APP().api)
......@@ -5,8 +5,6 @@
# Initial version based on GNOME Fractal
# https://gitlab.gnome.org/GNOME/fractal/-/tags/4.2.2
import os
from gettext import gettext as _
from gi.repository import Gio, GLib, Gtk
......@@ -17,7 +15,7 @@ from briar_gtk.containers.private_chat import PrivateChatContainer
from briar_gtk.controllers.main_menu import MainMenuController
from briar_gtk.controllers.private_chat import PrivateChatController
from briar_gtk.controllers.sidebar import SidebarController
from briar_gtk.define import APP, NOTIFICATION_CONTACT_ADDED, RESOURCES_DIR
from briar_gtk.define import APP, NOTIFICATION_CONTACT_ADDED
from briar_gtk.define import NOTIFICATION_PRIVATE_MESSAGE
from briar_gtk.views.main_menu import MainMenuView
from briar_gtk.views.private_chat import PrivateChatView
......@@ -29,42 +27,17 @@ from briar_gtk.widgets.edit_dialog import EditDialog
class MainWindowView(Gtk.Overlay):
MAIN_MENU_UI = "main_menu.ui"
CHAT_MENU_UI = "chat_menu.ui"
MAIN_WINDOW_UI = "main_window.ui"
_current_contact_id = 0
_current_private_chat_widget = None
def __init__(self):
def __init__(self, builder):
super().__init__()
self._builder = Gtk.Builder()
self._add_from_resource(self.MAIN_MENU_UI)
self._add_from_resource(self.CHAT_MENU_UI)
self._add_from_resource(self.MAIN_WINDOW_UI)
self._builder.connect_signals(self)
self._sidebar_view = SidebarView(self._builder)
self._sidebar_controller = SidebarController(
self._sidebar_view, APP().api)
self._private_chat_view = PrivateChatView(self._builder)
self._private_chat_controller = PrivateChatController(
self._private_chat_view, APP().api)
self._main_menu_view = MainMenuView()
self._main_menu_controller = MainMenuController(
self._main_menu_view, APP().api)
self._builder = builder
self._signals = list()
self._setup_view()
self._load_content()
def _add_from_resource(self, ui_filename):
self._builder.add_from_resource(
os.path.join(RESOURCES_DIR, ui_filename)
)
@property
def main_window_leaflet(self):
return self._builder.get_object("main_window_leaflet")
......
......@@ -19,6 +19,7 @@ class SidebarView():
self._clear_contact_list()
for contact in contact_list:
print(contact)
contact_row = ContactRowWidget(contact)
contacts_list_box = self._builder.get_object("contacts_list_box")
contacts_list_box.add(contact_row)
......
......@@ -2,16 +2,19 @@
# SPDX-License-Identifier: AGPL-3.0-only
# License-Filename: LICENSE.md
import os
from gettext import gettext as _
from gi.repository import Gio, Gtk
from briar_gtk.actions.window import WindowActions
from briar_gtk.containers.add_contact import AddContactContainer
from briar_gtk.controllers.main_window import MainWindowController
from briar_gtk.views.main_window import MainWindowView
from briar_gtk.containers.startup import StartupContainer
from briar_gtk.define import APP, APPLICATION_ID, APPLICATION_NAME
from briar_gtk.define import NOTIFICATION_CONTACT_ADDED
from briar_gtk.define import NOTIFICATION_PRIVATE_MESSAGE
from briar_gtk.define import NOTIFICATION_PRIVATE_MESSAGE, RESOURCES_DIR
class Window(Gtk.ApplicationWindow):
......@@ -99,7 +102,25 @@ class Window(Gtk.ApplicationWindow):
self._setup_container(StartupContainer(self))
def _setup_main_container(self):
self._setup_container(MainWindowView())
builder = self._setup_builder()
main_window_view = MainWindowView(builder)
main_window_controller = MainWindowController(
main_window_view, builder)
self._setup_container(main_window_view)
def _setup_add_contact_container(self):
self._setup_container(AddContactContainer())
def _setup_builder(self):
builder = Gtk.Builder.new()
builder.add_from_resource(
os.path.join(RESOURCES_DIR, "main_menu.ui")
)
builder.add_from_resource(
os.path.join(RESOURCES_DIR, "chat_menu.ui")
)
builder.add_from_resource(
os.path.join(RESOURCES_DIR, "main_window.ui")
)
builder.connect_signals(self)
return builder
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