[fractal/version] gtk: Implement version command line
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/version] gtk: Implement version command line
- Date: Fri, 12 Jun 2020 07:55:33 +0000 (UTC)
commit e37bb4a354a3563f2586ac1ab42b7c0b1d35bfa4
Author: Daniel GarcĂa Moreno <dani danigm net>
Date: Fri Jun 12 09:54:02 2020 +0200
gtk: Implement version command line
Fix https://gitlab.gnome.org/GNOME/fractal/-/issues/639
fractal-gtk/src/main.rs | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/fractal-gtk/src/main.rs b/fractal-gtk/src/main.rs
index fe7dea09..a8b9a2b7 100644
--- a/fractal-gtk/src/main.rs
+++ b/fractal-gtk/src/main.rs
@@ -58,7 +58,10 @@ fn main() -> Result<(), Box<dyn Error>> {
gst::init()?;
// Create a Application with default flags
- let application = gtk::Application::new(Some(config::APP_ID), gio::ApplicationFlags::empty())?;
+ let application = gtk::Application::new(
+ Some(config::APP_ID),
+ gio::ApplicationFlags::HANDLES_COMMAND_LINE,
+ )?;
application.set_resource_base_path(Some("/org/gnome/Fractal"));
@@ -66,6 +69,20 @@ fn main() -> Result<(), Box<dyn Error>> {
App::on_startup(application);
});
+ application.connect_command_line(|app, command| {
+ for arg in command.get_arguments() {
+ match arg.to_str() {
+ Some("-V") | Some("--version") => {
+ println!("{}", config::VERSION);
+ app.quit();
+ }
+ _ => {}
+ };
+ }
+
+ 0
+ });
+
application.run(&args().collect::<Vec<_>>());
Ok(())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]