Skip to content

Commit

Permalink
Close #150: add Star on Github menu action
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Maksimov committed Dec 22, 2023
1 parent 0b3c041 commit 4c7932d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions data/ui/welcome_page.blp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ menu primary_menu {
action: "app.about";
}
}

section {
item {
label: _("⭐ Star on GitHub");
action: "app.github_star";
icon: "starred-symbolic";
}
}
}

menu grab_menu {
Expand Down
9 changes: 9 additions & 0 deletions frog/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def do_startup(self, *args, **kwargs):
self.create_action('quit', lambda *_: self.quit(), ['<primary>q', '<primary>w'])
self.create_action('about', self.on_about)
self.create_action('preferences', self.on_preferences, ['<primary>comma'])
self.create_action('github_star', self.on_github_star)

def do_activate(self):
win = self.props.active_window
Expand All @@ -123,6 +124,11 @@ def do_command_line(self, command_line):
def on_preferences(self, _action, _param) -> None:
self.get_active_window().show_preferences()

def on_github_star(self, _action, _param) -> None:
launcher: Gtk.UriLauncher = Gtk.UriLauncher()
launcher.set_uri('https://github.com/TenderOwl/Frog')
launcher.launch(callback=self._on_github_star)

def on_about(self, _action, _param):
about_window = Adw.AboutWindow(
application_name="Frog",
Expand Down Expand Up @@ -224,6 +230,9 @@ def create_action(self, name, callback, shortcuts=None):
if shortcuts:
self.set_accels_for_action(f"app.{name}", shortcuts)

def _on_github_star(self, _, result):
pass


def main(version):
app = FrogApplication(version)
Expand Down

0 comments on commit 4c7932d

Please sign in to comment.