From 29afa414377caad4ec8cfa4a3b8cb9fbd0107a52 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 4 Jun 2024 19:36:22 +0200 Subject: [PATCH] Implement xmpp: URI passing from the CLI When receiving such an argument, open a new Tab. This partially reverts commit 690e7113abfe32788651f1c348ab813c2b6e7c59. --- src/main.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 52bb18b..a5e80a4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -76,9 +76,26 @@ fn main() { let app = adw::Application::builder() .application_id("fr.linkmauve.XmppClient") + .flags(gio::ApplicationFlags::HANDLES_COMMAND_LINE) .build(); - app.connect_activate(move |app| { + app.connect_command_line(move |app, command_line| { + let args = command_line.arguments(); + let mut iter = args.iter(); + iter.next().unwrap(); + let win = app.active_window().unwrap(); + let win: &window::MainWindow = win.downcast_ref().unwrap(); + for arg in iter { + let arg = arg.to_str().unwrap().to_owned(); + if let Some(jid) = arg.strip_prefix("xmpp:") { + let tab = Tab::new(jid, jid); + win.tabs_store().append(&tab); + } + } + 0 + }); + + app.connect_startup(move |app| { let win = window::MainWindow::new(app); let action_close = gio::ActionEntry::builder("close")