-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
3,775 additions
and
508 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fallback_language = "en" | ||
|
||
[fluent] | ||
assets_dir = "./i18n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
allow = Allow | ||
cancel = Cancel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
use cosmic::{app, iced::window}; | ||
|
||
use crate::{access, screenshot, subscription}; | ||
|
||
pub(crate) fn run() -> cosmic::iced::Result { | ||
let settings = cosmic::app::Settings::default().no_main_window(true); | ||
cosmic::app::run::<CosmicPortal>(settings, ()) | ||
} | ||
|
||
#[derive(Default, Clone)] | ||
// run iced app with no main surface | ||
pub struct CosmicPortal { | ||
pub core: app::Core, | ||
pub access_args: Option<access::AccessDialogArgs>, | ||
pub access_choices: Vec<(Option<usize>, Vec<String>)>, | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
pub enum Msg { | ||
Access(access::Msg), | ||
Portal(subscription::Event), | ||
} | ||
|
||
impl cosmic::Application for CosmicPortal { | ||
type Executor = cosmic::executor::Default; | ||
|
||
type Flags = (); | ||
|
||
type Message = Msg; | ||
|
||
const APP_ID: &'static str = "org.freedesktop.portal.desktop.cosmic"; | ||
|
||
fn core(&self) -> &app::Core { | ||
&self.core | ||
} | ||
|
||
fn core_mut(&mut self) -> &mut app::Core { | ||
&mut self.core | ||
} | ||
|
||
fn init( | ||
core: app::Core, | ||
_flags: Self::Flags, | ||
) -> (Self, cosmic::iced::Command<app::Message<Self::Message>>) { | ||
( | ||
Self { | ||
core, | ||
..Default::default() | ||
}, | ||
cosmic::iced::Command::none(), | ||
) | ||
} | ||
|
||
fn view(&self) -> cosmic::prelude::Element<Self::Message> { | ||
unimplemented!() | ||
} | ||
|
||
fn view_window(&self, id: window::Id) -> cosmic::prelude::Element<Self::Message> { | ||
if id == *access::ACCESS_ID { | ||
access::view(self).map(Msg::Access) | ||
} else if id == *screenshot::SCREENSHOT_ID { | ||
screenshot::view(self) | ||
} else { | ||
panic!("Unknown window id {:?}", id); | ||
} | ||
} | ||
|
||
fn update( | ||
&mut self, | ||
message: Self::Message, | ||
) -> cosmic::iced::Command<app::Message<Self::Message>> { | ||
match message { | ||
Msg::Access(m) => access::update_msg(self, m).map(cosmic::app::Message::App), | ||
Msg::Portal(e) => match e { | ||
subscription::Event::Access(args) => { | ||
access::update_args(self, args).map(cosmic::app::Message::App) | ||
} | ||
}, | ||
} | ||
} | ||
|
||
fn subscription(&self) -> cosmic::iced_futures::Subscription<Self::Message> { | ||
subscription::portal_subscription().map(|e| Msg::Portal(e)) | ||
} | ||
} |
Oops, something went wrong.