Skip to content

Commit

Permalink
Make it so only one preferences dialog can be open
Browse files Browse the repository at this point in the history
  • Loading branch information
kra-mo committed Apr 5, 2024
1 parent dfec323 commit 94d8fb7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hyperplane/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ def __about(self, *_args: Any) -> None:
about.present(self.get_active_window())

def __preferences(self, *_args: Any) -> None:
if HypPreferencesDialog.is_open:
return

prefs = HypPreferencesDialog()
prefs.present(self.get_active_window())

Expand Down
9 changes: 9 additions & 0 deletions hyperplane/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@ class HypPreferencesDialog(Adw.PreferencesDialog):
folders_switch_row = Gtk.Template.Child()
single_click_open_switch_row = Gtk.Template.Child()

is_open = False

def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)

# Make it so only one dialog can be open at a time
self.__class__.is_open = True
self.connect("closed", lambda *_: self.set_is_open(False))

shared.schema.bind(
"folders-before-files",
self.folders_switch_row,
Expand All @@ -52,3 +58,6 @@ def __init__(self, **kwargs) -> None:
self.folders_switch_row.connect(
"notify::active", lambda *_: shared.postmaster.emit("sort-changed")
)

def set_is_open(self, is_open: bool) -> None:
self.__class__.is_open = is_open

0 comments on commit 94d8fb7

Please sign in to comment.