Skip to content

Commit

Permalink
tweak state
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvladus committed May 20, 2024
1 parent 5cc5049 commit ed4affc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 21 deletions.
18 changes: 5 additions & 13 deletions errands/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@
from errands.lib.gsettings import GSettings
from errands.lib.logging import Log
from errands.lib.notifications import ErrandsNotificationsDaemon
from errands.lib.plugins import PluginsLoader

# from errands.lib.plugins import PluginsLoader
from errands.lib.utils import threaded
from errands.state import State
from errands.widgets.shared.task_toolbar import ErrandsAttachmentsWindow
from errands.widgets.shared.task_toolbar import DateTimeWindow
from errands.widgets.shared.task_toolbar import NotesWindow
from errands.widgets.window import Window


class ErrandsApplication(Adw.Application):
plugins_loader: PluginsLoader = None
# plugins_loader: PluginsLoader = None

def __init__(self) -> None:
super().__init__(
Expand Down Expand Up @@ -152,14 +150,8 @@ def do_startup(self) -> None:
# Plugins
# self.plugins_loader = PluginsLoader(self)

# Notes window
State.notes_window = NotesWindow()

# Date and time window
State.datetime_window = DateTimeWindow()

# Attachments window
State.attachments_window = ErrandsAttachmentsWindow()
# Initialize State
State.init()

# Main window
State.main_window = Window(application=State.application)
Expand Down
20 changes: 16 additions & 4 deletions errands/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from errands.lib.notifications import ErrandsNotificationsDaemon
from errands.widgets.loading_page import ErrandsLoadingPage
from errands.widgets.shared.task_toolbar import (
DateTimeWindow,
ErrandsDateTimeWindow,
ErrandsAttachmentsWindow,
NotesWindow,
ErrandsNotesWindow,
)
from errands.widgets.sidebar import Sidebar
from errands.widgets.tags.tags import Tags
Expand Down Expand Up @@ -62,14 +62,26 @@ class State:
trash_sidebar_row: TrashSidebarRow | None = None

# Notes window
notes_window: NotesWindow | None = None
notes_window: ErrandsNotesWindow | None = None

# Date and time window
datetime_window: DateTimeWindow | None = None
datetime_window: ErrandsDateTimeWindow | None = None

# Attachments window
attachments_window: ErrandsAttachmentsWindow | None = None

@classmethod
def init(cls) -> None:
from errands.widgets.shared.task_toolbar import (
ErrandsNotesWindow,
ErrandsDateTimeWindow,
ErrandsAttachmentsWindow,
)

cls.notes_window = ErrandsNotesWindow()
cls.datetime_window = ErrandsDateTimeWindow()
cls.attachments_window = ErrandsAttachmentsWindow()

@classmethod
def get_task_list(cls, uid: str) -> TaskList:
return [lst for lst in cls.get_task_lists() if lst.list_uid == uid][0]
Expand Down
4 changes: 2 additions & 2 deletions errands/widgets/shared/task_toolbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
from errands.widgets.shared.task_toolbar.attachments_window import (
ErrandsAttachmentsWindow,
)
from errands.widgets.shared.task_toolbar.datetime_window import DateTimeWindow
from errands.widgets.shared.task_toolbar.notes_window import NotesWindow
from errands.widgets.shared.task_toolbar.datetime_window import ErrandsDateTimeWindow
from errands.widgets.shared.task_toolbar.notes_window import ErrandsNotesWindow
2 changes: 1 addition & 1 deletion errands/widgets/shared/task_toolbar/datetime_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from errands.widgets.today.today_task import TodayTask


class DateTimeWindow(Adw.Dialog):
class ErrandsDateTimeWindow(Adw.Dialog):
def __init__(self):
super().__init__()
self.__build_ui()
Expand Down
2 changes: 1 addition & 1 deletion errands/widgets/shared/task_toolbar/notes_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from errands.widgets.task import Task


class NotesWindow(Adw.Dialog):
class ErrandsNotesWindow(Adw.Dialog):
def __init__(self):
super().__init__()
self.__build_ui()
Expand Down

0 comments on commit ed4affc

Please sign in to comment.