Skip to content

Commit

Permalink
Make it so only a single guide can be opened
Browse files Browse the repository at this point in the history
  • Loading branch information
kra-mo committed Jan 27, 2024
1 parent 686a981 commit f7d2dac
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions hyperplane/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
class HypApplication(Adw.Application):
"""The main application singleton class."""

guide: Optional[HypGuide] = None

def __init__(self) -> None:
super().__init__(
application_id=shared.APP_ID,
Expand Down Expand Up @@ -163,10 +165,12 @@ def do_activate(
"is-maximized", win, "maximized", Gio.SettingsBindFlags.SET
)

if not self.guide:
self.guide = HypGuide()

if shared.state_schema.get_boolean("first-run"):
shared.state_schema.set_boolean("first-run", False)
guide = HypGuide()
guide.present(win)
self.guide.present(win)

win.present()

Expand Down Expand Up @@ -205,9 +209,8 @@ def create_action(
self.set_accels_for_action(f"app.{name}", shortcuts)

def __guide(self, *_args: Any) -> None:
guide = HypGuide()

guide.present(self.get_active_window())
self.guide.carousel.scroll_to(self.guide.page_1, False)
self.guide.present(self.get_active_window())

def __about(self, *_args: Any) -> None:
about = Adw.AboutDialog.new_from_appdata(
Expand Down

0 comments on commit f7d2dac

Please sign in to comment.