mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-02 22:29:01 +00:00
feat: homepage and author in plugin details
This commit is contained in:
parent
b24c8e4c0b
commit
879637115c
2 changed files with 59 additions and 12 deletions
|
@ -16,6 +16,7 @@ use std::path::PathBuf;
|
||||||
pub struct Plugin {
|
pub struct Plugin {
|
||||||
pub appid: String,
|
pub appid: String,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
pub author: Option<String>,
|
||||||
pub icon_url: Option<String>,
|
pub icon_url: Option<String>,
|
||||||
pub version: Option<String>,
|
pub version: Option<String>,
|
||||||
pub short_description: Option<String>,
|
pub short_description: Option<String>,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use super::Plugin;
|
||||||
use crate::{downloader::cache_file, ui::SENDER_IO_ERR_MSG};
|
use crate::{downloader::cache_file, ui::SENDER_IO_ERR_MSG};
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
use relm4::prelude::*;
|
use relm4::prelude::*;
|
||||||
use tracing::warn;
|
use tracing::{error, warn};
|
||||||
|
|
||||||
#[tracker::track]
|
#[tracker::track]
|
||||||
pub struct StoreDetail {
|
pub struct StoreDetail {
|
||||||
|
@ -25,6 +25,7 @@ pub enum StoreDetailMsg {
|
||||||
Install,
|
Install,
|
||||||
Remove,
|
Remove,
|
||||||
SetEnabled(bool),
|
SetEnabled(bool),
|
||||||
|
OpenHomepage,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -91,18 +92,42 @@ impl AsyncComponent for StoreDetail {
|
||||||
set_margin_end: 12,
|
set_margin_end: 12,
|
||||||
set_pixel_size: 96,
|
set_pixel_size: 96,
|
||||||
},
|
},
|
||||||
gtk::Label {
|
gtk::Box {
|
||||||
add_css_class: "title-2",
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
set_hexpand: true,
|
set_hexpand: true,
|
||||||
set_xalign: 0.0,
|
set_valign: gtk::Align::Center,
|
||||||
#[track = "model.changed(Self::plugin())"]
|
set_spacing: 6,
|
||||||
set_text: model
|
gtk::Label {
|
||||||
.plugin
|
add_css_class: "title-2",
|
||||||
.as_ref()
|
set_xalign: 0.0,
|
||||||
.map(|p| p.name.as_str())
|
#[track = "model.changed(Self::plugin())"]
|
||||||
.unwrap_or_default(),
|
set_text: model
|
||||||
set_ellipsize: gtk::pango::EllipsizeMode::None,
|
.plugin
|
||||||
set_wrap: true,
|
.as_ref()
|
||||||
|
.map(|p| p.name.as_str())
|
||||||
|
.unwrap_or_default(),
|
||||||
|
set_ellipsize: gtk::pango::EllipsizeMode::None,
|
||||||
|
set_wrap: true,
|
||||||
|
},
|
||||||
|
gtk::Label {
|
||||||
|
add_css_class: "dim-label",
|
||||||
|
set_xalign: 0.0,
|
||||||
|
#[track = "model.changed(Self::plugin())"]
|
||||||
|
set_visible: model
|
||||||
|
.plugin
|
||||||
|
.as_ref()
|
||||||
|
.is_some_and(|p| p.author.is_some()),
|
||||||
|
#[track = "model.changed(Self::plugin())"]
|
||||||
|
set_text: model
|
||||||
|
.plugin
|
||||||
|
.as_ref()
|
||||||
|
.and_then(
|
||||||
|
|p| p.author.as_deref()
|
||||||
|
)
|
||||||
|
.unwrap_or_default(),
|
||||||
|
set_ellipsize: gtk::pango::EllipsizeMode::None,
|
||||||
|
set_wrap: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
gtk::Box {
|
gtk::Box {
|
||||||
set_orientation: gtk::Orientation::Vertical,
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
@ -161,6 +186,15 @@ impl AsyncComponent for StoreDetail {
|
||||||
gtk::glib::Propagation::Proceed
|
gtk::glib::Propagation::Proceed
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
gtk::Button {
|
||||||
|
#[track = "model.changed(Self::plugin())"]
|
||||||
|
set_visible: model.plugin.as_ref()
|
||||||
|
.is_some_and(|p| p.homepage_url.is_some()),
|
||||||
|
set_label: "Homepage",
|
||||||
|
connect_clicked[sender] => move |_| {
|
||||||
|
sender.input(Self::Input::OpenHomepage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -211,6 +245,18 @@ impl AsyncComponent for StoreDetail {
|
||||||
self.reset();
|
self.reset();
|
||||||
|
|
||||||
match message {
|
match message {
|
||||||
|
Self::Input::OpenHomepage => {
|
||||||
|
if let Some(plugin) = self.plugin.as_ref() {
|
||||||
|
if let Some(homepage) = plugin.homepage_url.as_ref() {
|
||||||
|
if let Err(e) = gtk::gio::AppInfo::launch_default_for_uri(
|
||||||
|
homepage,
|
||||||
|
gtk::gio::AppLaunchContext::NONE,
|
||||||
|
) {
|
||||||
|
error!("opening uri {homepage}: {e}");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Self::Input::SetPlugin(p, enabled, needs_update) => {
|
Self::Input::SetPlugin(p, enabled, needs_update) => {
|
||||||
self.set_plugin(Some(p));
|
self.set_plugin(Some(p));
|
||||||
self.set_enabled(enabled);
|
self.set_enabled(enabled);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue