From e19e0153ac7c2f5587f414144e1ba762262b89f5 Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 5 Mar 2021 19:29:40 +0300 Subject: [PATCH] Add '--version' flag (#1014) --- main/src/ui/application.vala | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala index 29b61357..17d67e9e 100644 --- a/main/src/ui/application.vala +++ b/main/src/ui/application.vala @@ -15,6 +15,12 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { public Plugins.Registry plugin_registry { get; set; default = new Plugins.Registry(); } public SearchPathGenerator? search_path_generator { get; set; } + internal static bool print_version = false; + private const OptionEntry[] options = { + { "version", 0, 0, OptionArg.NONE, ref print_version, "Display version number", null }, + { null } + }; + public Application() throws Error { Object(application_id: "im.dino.Dino", flags: ApplicationFlags.HANDLES_OPEN); init(); @@ -26,8 +32,14 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider, STYLE_PROVIDER_PRIORITY_APPLICATION); create_actions(); + add_main_option_entries(options); startup.connect(() => { + if (print_version) { + print(@"Dino $(Dino.VERSION)\n"); + Process.exit(0); + } + NotificationEvents notification_events = stream_interactor.get_module(NotificationEvents.IDENTITY); notification_events.register_notification_provider(new GNotificationsNotifier(stream_interactor)); FreeDesktopNotifier? free_desktop_notifier = FreeDesktopNotifier.try_create(stream_interactor);