1
0

Open links

This commit is contained in:
2025-02-12 19:01:22 +02:00
parent 61d91247e7
commit f162127cb8
5 changed files with 68 additions and 10 deletions

View File

@ -2075,6 +2075,25 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "is-docker"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3"
dependencies = [
"once_cell",
]
[[package]]
name = "is-wsl"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5"
dependencies = [
"is-docker",
"once_cell",
]
[[package]]
name = "itoa"
version = "1.0.14"
@ -2717,6 +2736,17 @@ version = "1.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
[[package]]
name = "open"
version = "5.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2483562e62ea94312f3576a7aca397306df7990b8d89033e18766744377ef95"
dependencies = [
"is-wsl",
"libc",
"pathdiff",
]
[[package]]
name = "orbclient"
version = "0.3.48"
@ -2874,6 +2904,12 @@ version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "pathdiff"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3"
[[package]]
name = "pem-rfc7468"
version = "0.7.0"
@ -3256,6 +3292,7 @@ version = "0.1.0"
dependencies = [
"data",
"iced",
"open",
"service",
"strum",
]

View File

@ -9,6 +9,7 @@ service = { path = "service" }
iced = { version = "0.13.1", features = ["tokio", "lazy"] }
strum = { version = "0.27.0", features = ["derive"] }
open = "5.3.2"
[workspace]
resolver = "2"

View File

@ -34,9 +34,11 @@ struct Repository {
>,
}
#[derive(Default)]
enum Screen {
Search,
// Statistics,
#[default]
Authentication,
}
@ -76,8 +78,7 @@ impl Repository {
Self {
main_id,
scale_factor: 1.4,
screen: Screen::Search,
screen: Screen::default(),
authenticated: None,
@ -112,7 +113,7 @@ impl Repository {
return task.map(Message::Authentecation);
}
authentication::Event::Authenticated(authenticated) => {
log!("authenticated as {:#?}", authenticated);
log!("authenticated as {:#?}", *authenticated);
self.authenticated = Some(authenticated);
self.screen = Screen::Search;
}
@ -126,13 +127,21 @@ impl Repository {
return task.map(Message::Search);
}
search::Event::OpenPackage(id) => {
log!("opening package {id}")
log!("opening package {id}");
}
search::Event::OpenBase(id) => {
log!("opening package base {id}")
log!("opening package base {id}");
}
search::Event::OpenURL(url) => {
log!("opening url {url}")
log!("opening url {url}");
match open::that(url.as_ref()) {
Ok(()) => {
log!("opened url {url}");
}
Err(e) => {
log!("can't open url \"{url}\": {e}");
}
}
}
}
}
@ -155,7 +164,10 @@ impl Repository {
fn title(&self, _: window::Id) -> String {
// "Repository".into()
self.authentication.title()
match self.screen {
Screen::Search => self.search.title(),
Screen::Authentication => self.authentication.title(),
}
}
fn subscription(&self) -> Subscription<Message> {

View File

@ -158,7 +158,15 @@ impl Table {
entry
.url
.as_ref()
.map_or("-".into(), |s| url(&"link", Message::URLPressed(s.clone()))),
.map_or("-".into(), |s|
tip(
url(&"link", Message::URLPressed(s.clone())),
s.clone(),
tip::Position::Bottom,
),
),
);
table[4].push(text(entry.description.to_string()).into());
table[5].push(text(entry.updated_at.to_string()).into());

View File

@ -36,12 +36,12 @@ pub mod tip {
/// Tooltip with some styling applied
pub fn tip<'a, Message: 'a>(
content: impl Into<Element<'a, Message>>,
tip: &'a str,
tip: impl ToString,
position: tip::Position,
) -> Element<'a, Message> {
tooltip(
content,
container(text(tip).size(14))
container(text(tip.to_string()).size(14))
.padding(5)
.style(container::dark),
position,