diff options
| author | Robert Günzler <r@gnzler.io> | 2026-08-13 17:21:46 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2026-08-13 17:21:46 +0200 |
| commit | 502d94151ed9dcfeeb691a92a4c413be5783ae2d (patch) | |
| tree | 0a547802f5408e8bcd11eca811365f0622519abc /src/mm-application.vala | |
| download | munchmate-master.tar.gz | |
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'src/mm-application.vala')
| -rw-r--r-- | src/mm-application.vala | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/mm-application.vala b/src/mm-application.vala new file mode 100644 index 0000000..193f16b --- /dev/null +++ b/src/mm-application.vala @@ -0,0 +1,50 @@ +namespace MunchMate { + public class Application : Adw.Application { + private Window win; + + private static bool print_version = false; + + private const GLib.OptionEntry[] options = { + { "version", 'V', OptionFlags.NONE, OptionArg.NONE, ref print_version, "Display version number", null }, + { null } // terminator + }; + + private const GLib.ActionEntry[] action_entries = { + { "quit", on_quit_activate }, + }; + + public override int handle_local_options(VariantDict _) { + if (print_version) { + print("%s version %s\n", Config.APP_ID, Config.VERSION); + return 0; + } + return -1; + } + + public override void activate() { + win = new Window(this); + win.present(); + } + + public override void startup() { + base.startup(); + + set_accels_for_action("app.quit", { "q" }); + } + + public Application() { + // why doesnt service binding work in flatpak + Object(application_id: Config.APP_ID, flags: ApplicationFlags.NON_UNIQUE); + + set_resource_base_path("/im/gzr/munchmate/"); + + add_main_option_entries(options); + + add_action_entries(action_entries, this); + } + + void on_quit_activate() { + quit(); + } + } +} |