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")