about: Add basic debug information
This commit is contained in:
parent
fc2d5da527
commit
e1ee9c14ee
4 changed files with 80 additions and 23 deletions
|
|
@ -6,6 +6,7 @@ data/gtk/window.ui
|
||||||
data/org.gnome.Loupe.desktop.in.in
|
data/org.gnome.Loupe.desktop.in.in
|
||||||
data/org.gnome.Loupe.metainfo.xml.in.in
|
data/org.gnome.Loupe.metainfo.xml.in.in
|
||||||
data/resources/gtk/help-overlay.ui
|
data/resources/gtk/help-overlay.ui
|
||||||
|
src/about.rs
|
||||||
src/application.rs
|
src/application.rs
|
||||||
src/decoder/formats/glycin_proxy.rs
|
src/decoder/formats/glycin_proxy.rs
|
||||||
src/decoder/formats/mod.rs
|
src/decoder/formats/mod.rs
|
||||||
|
|
|
||||||
71
src/about.rs
Normal file
71
src/about.rs
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
// Copyright (c) 2023 Sophie Herold
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
use gettextrs::gettext;
|
||||||
|
|
||||||
|
use crate::config;
|
||||||
|
|
||||||
|
pub async fn window() -> adw::AboutWindow {
|
||||||
|
// Builders are a pattern that allow you to create
|
||||||
|
// an object and set all relevant properties very
|
||||||
|
// easily in a way that's idiomatic to Rust.
|
||||||
|
adw::AboutWindow::builder()
|
||||||
|
.application_name(gettext("Loupe"))
|
||||||
|
.application_icon(config::APP_ID)
|
||||||
|
.version(config::VERSION)
|
||||||
|
.developer_name(gettext("The Loupe Team"))
|
||||||
|
.website("https://gitlab.gnome.org/GNOME/Incubator/loupe")
|
||||||
|
.issue_url("https://gitlab.gnome.org/GNOME/Incubator/loupe/-/issues/new")
|
||||||
|
.developers([
|
||||||
|
"Christopher Davis <christopherdavis@gnome.org>",
|
||||||
|
"Sophie Herold <sophieherold@gnome.org>",
|
||||||
|
])
|
||||||
|
.designers(["Allan Day", "Jakub Steiner", "Tobias Bernard"])
|
||||||
|
// Translators: Replace "translator-credits" with your names, one name per line
|
||||||
|
.translator_credits(gettext("translator-credits"))
|
||||||
|
.copyright(gettext("Copyright © 2020–2023 Christopher Davis et al."))
|
||||||
|
.license_type(gtk::License::Gpl30)
|
||||||
|
.debug_info(debug_info().await)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn etc() -> std::path::PathBuf {
|
||||||
|
if ashpd::is_sandboxed().await {
|
||||||
|
std::path::PathBuf::from("/run/host/etc")
|
||||||
|
} else {
|
||||||
|
std::path::PathBuf::from("/etc")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn os_release() -> String {
|
||||||
|
let os_release = etc().await.join("os-release");
|
||||||
|
std::fs::read_to_string(os_release).unwrap_or_default()
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn debug_info() -> String {
|
||||||
|
[
|
||||||
|
format!("- Version: {}", config::VERSION),
|
||||||
|
format!("- App ID: {}", config::APP_ID),
|
||||||
|
format!(
|
||||||
|
"- Sandboxed: {} {}",
|
||||||
|
ashpd::is_sandboxed().await,
|
||||||
|
std::env::var("container").unwrap_or_default()
|
||||||
|
),
|
||||||
|
format!("\n##### OS Information\n```\n{}\n```", os_release().await),
|
||||||
|
]
|
||||||
|
.join("\n")
|
||||||
|
}
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
use crate::about;
|
||||||
use crate::deps::*;
|
use crate::deps::*;
|
||||||
use crate::util::gettext::*;
|
|
||||||
use crate::util::spawn;
|
use crate::util::spawn;
|
||||||
|
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
|
|
@ -112,7 +112,10 @@ impl LpApplication {
|
||||||
// add them with add_action_entries().
|
// add them with add_action_entries().
|
||||||
let actions = [
|
let actions = [
|
||||||
gio::ActionEntryBuilder::new("about")
|
gio::ActionEntryBuilder::new("about")
|
||||||
.activate(|app: &Self, _, _| app.show_about())
|
.activate(|app: &Self, _, _| {
|
||||||
|
let app = app.clone();
|
||||||
|
spawn(async move { app.show_about().await });
|
||||||
|
})
|
||||||
.build(),
|
.build(),
|
||||||
gio::ActionEntryBuilder::new("help")
|
gio::ActionEntryBuilder::new("help")
|
||||||
.activate(|app: &Self, _, _| app.show_help())
|
.activate(|app: &Self, _, _| app.show_help())
|
||||||
|
|
@ -185,27 +188,8 @@ impl LpApplication {
|
||||||
self.set_accels_for_action("window.close", &["<Ctrl>W"]);
|
self.set_accels_for_action("window.close", &["<Ctrl>W"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn show_about(&self) {
|
pub async fn show_about(&self) {
|
||||||
// Builders are a pattern that allow you to create
|
let about = about::window().await;
|
||||||
// an object and set all relevant properties very
|
|
||||||
// easily in a way that's idiomatic to Rust.
|
|
||||||
let about = adw::AboutWindow::builder()
|
|
||||||
.application_name(gettext("Loupe"))
|
|
||||||
.application_icon(config::APP_ID)
|
|
||||||
.version(config::VERSION)
|
|
||||||
.developer_name(gettext("The Loupe Team"))
|
|
||||||
.website("https://gitlab.gnome.org/GNOME/Incubator/loupe")
|
|
||||||
.issue_url("https://gitlab.gnome.org/GNOME/Incubator/loupe/-/issues/new")
|
|
||||||
.developers([
|
|
||||||
"Christopher Davis <christopherdavis@gnome.org>",
|
|
||||||
"Sophie Herold <sophieherold@gnome.org>",
|
|
||||||
])
|
|
||||||
.designers(["Allan Day", "Jakub Steiner", "Tobias Bernard"])
|
|
||||||
// Translators: Replace "translator-credits" with your names, one name per line
|
|
||||||
.translator_credits(gettext("translator-credits"))
|
|
||||||
.copyright(gettext("Copyright © 2020–2023 Christopher Davis et al."))
|
|
||||||
.license_type(gtk::License::Gpl30)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
if let Some(window) = self.active_window() {
|
if let Some(window) = self.active_window() {
|
||||||
about.set_transient_for(Some(&window));
|
about.set_transient_for(Some(&window));
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ Simplified widget arrangement including the most important widgets.
|
||||||
use gettextrs::*;
|
use gettextrs::*;
|
||||||
use gtk::gio::{self, prelude::*};
|
use gtk::gio::{self, prelude::*};
|
||||||
|
|
||||||
|
mod about;
|
||||||
mod application;
|
mod application;
|
||||||
mod config;
|
mod config;
|
||||||
mod decoder;
|
mod decoder;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue