Skip to content

Use libcosmic about widget #658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 21 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ edition = "2021"
license = "GPL-3.0-only"
rust-version = "1.71"

[build-dependencies]
vergen = { version = "8", features = ["git", "gitcl"] }

[dependencies]
chrono = { version = "0.4", features = ["unstable-locales"] }
dirs = "5.0.1"
Expand Down Expand Up @@ -67,7 +64,7 @@ features = ["multi-window", "tokio", "winit"]

[features]
default = ["bzip2", "desktop", "gvfs", "liblzma", "notify", "wgpu"]
desktop = ["libcosmic/desktop", "dep:xdg"]
desktop = ["libcosmic/desktop", "libcosmic/about", "dep:xdg"]
gvfs = ["dep:gio", "dep:glib"]
jemalloc = ["dep:tikv-jemallocator"]
notify = ["dep:notify-rust"]
Expand Down
17 changes: 0 additions & 17 deletions build.rs

This file was deleted.

3 changes: 2 additions & 1 deletion i18n/en/cosmic_files.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ execute = Execute
# Context Pages

## About
git-description = Git commit {$hash} on {$date}
repository = Repository
support = Support

## Add Network Drive
add-network-drive = Add network drive
Expand Down
49 changes: 16 additions & 33 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use cosmic::{
dnd_destination::DragId,
menu::{action::MenuAction, key_bind::KeyBind},
segmented_button::{self, Entity},
about::About,
},
Application, ApplicationExt, Element,
};
Expand Down Expand Up @@ -503,6 +504,7 @@ impl PartialEq for WatcherWrapper {
/// The [`App`] stores application-specific state.
pub struct App {
core: Core,
about: About,
nav_bar_context_id: segmented_button::Entity,
nav_model: segmented_button::SingleSelectModel,
tab_model: segmented_button::Model<segmented_button::SingleSelect>,
Expand Down Expand Up @@ -1075,38 +1077,6 @@ impl App {
Task::none()
}

fn about(&self) -> Element<Message> {
let cosmic_theme::Spacing { space_xxs, .. } = theme::active().cosmic().spacing;
let repository = "https://github.com/pop-os/cosmic-files";
let hash = env!("VERGEN_GIT_SHA");
let short_hash: String = hash.chars().take(7).collect();
let date = env!("VERGEN_GIT_COMMIT_DATE");
widget::column::with_children(vec![
widget::svg(widget::svg::Handle::from_memory(
&include_bytes!(
"../res/icons/hicolor/128x128/apps/com.system76.CosmicFiles.svg"
)[..],
))
.into(),
widget::text::title3(fl!("cosmic-files")).into(),
widget::button::link(repository)
.on_press(Message::LaunchUrl(repository.to_string()))
.padding(0)
.into(),
widget::button::link(fl!(
"git-description",
hash = short_hash.as_str(),
date = date
))
.on_press(Message::LaunchUrl(format!("{}/commits/{}", repository, hash)))
.padding(0)
.into(),
])
.align_x(Alignment::Center)
.spacing(space_xxs)
.into()
}

fn network_drive(&self) -> Element<Message> {
let cosmic_theme::Spacing {
space_xxs, space_m, ..
Expand Down Expand Up @@ -1429,8 +1399,21 @@ impl Application for App {

let window_id_opt = core.main_window_id();

let about = About::default()
.name(fl!("cosmic-files"))
.icon(Self::APP_ID)
.version(env!("CARGO_PKG_VERSION"))
.author("System76")
.license("GPL-3.0-only")
.developers([("Jeremy Soller", "[email protected]")])
.links([
(fl!("repository"), "https://github.com/pop-os/cosmic-files"),
(fl!("support"), "https://github.com/pop-os/cosmic-files/issues"),
]);

let mut app = App {
core,
about,
nav_bar_context_id: segmented_button::Entity::null(),
nav_model: segmented_button::ModelBuilder::default().build(),
tab_model: segmented_button::ModelBuilder::default().build(),
Expand Down Expand Up @@ -3308,7 +3291,7 @@ impl Application for App {
}

Some(match &self.context_page {
ContextPage::About => self.about(),
ContextPage::About => widget::about(&self.about, Message::LaunchUrl),
ContextPage::EditHistory => self.edit_history(),
ContextPage::NetworkDrive => self.network_drive(),
ContextPage::Preview(entity_opt, kind) => self.preview(entity_opt, kind, true),
Expand Down