Implement xmpp: URI passing from the CLI
When receiving such an argument, open a new Tab.
This partially reverts commit 690e7113ab
.
This commit is contained in:
parent
5824275f06
commit
29afa41437
19
src/main.rs
19
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")
|
||||
|
|
Loading…
Reference in New Issue
Block a user