mirror of
https://gitlab.freedesktop.org/pipewire/helvum.git
synced 2025-12-20 08:50:03 +01:00
ui: Add "About" window to display version, authors, license, etc.
This adds a new adw::AboutWindow containing information about version, authors, license, links etc. It is opened via a new menu button in the toolbar, which opens a menu containing an "About Helvum" button. The version and authors are pulled from the Cargo.toml file.
This commit is contained in:
parent
e92c77f2b1
commit
bc006fe393
4 changed files with 72 additions and 16 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "helvum"
|
name = "helvum"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
authors = ["Tom A. Wagner <tom.a.wagner@protonmail.com>"]
|
authors = ["Tom Wagner <tom.a.wagner@protonmail.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.70"
|
rust-version = "1.70"
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
|
|
@ -15,7 +15,7 @@ categories = ["gui", "multimedia"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
pipewire = "0.7.1"
|
pipewire = "0.7.1"
|
||||||
adw = { version = "0.5", package = "libadwaita" }
|
adw = { version = "0.5", package = "libadwaita", features = ["v1_2"] }
|
||||||
glib = { version = "0.18", features = ["log"] }
|
glib = { version = "0.18", features = ["log"] }
|
||||||
|
|
||||||
log = "0.4.11"
|
log = "0.4.11"
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ gnome = import('gnome')
|
||||||
|
|
||||||
base_id = 'org.pipewire.Helvum'
|
base_id = 'org.pipewire.Helvum'
|
||||||
|
|
||||||
dependency('glib-2.0', version: '>= 2.66')
|
dependency('glib-2.0', version: '>= 2.66')
|
||||||
dependency('gtk4', version: '>= 4.4.0')
|
dependency('gtk4', version: '>= 4.4.0')
|
||||||
dependency('libadwaita-1')
|
dependency('libadwaita-1', version: '>= 1.2')
|
||||||
dependency('libpipewire-0.3')
|
dependency('libpipewire-0.3')
|
||||||
|
|
||||||
desktop_file_validate = find_program('desktop-file-validate', required: false)
|
desktop_file_validate = find_program('desktop-file-validate', required: false)
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,9 @@ use pipewire::channel::Sender;
|
||||||
use crate::{graph_manager::GraphManager, ui, GtkMessage, PipewireMessage};
|
use crate::{graph_manager::GraphManager, ui, GtkMessage, PipewireMessage};
|
||||||
|
|
||||||
static STYLE: &str = include_str!("style.css");
|
static STYLE: &str = include_str!("style.css");
|
||||||
|
static APP_ID: &str = "org.pipewire.Helvum";
|
||||||
|
static VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
static AUTHORS: &str = env!("CARGO_PKG_AUTHORS");
|
||||||
|
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
@ -81,10 +84,50 @@ mod imp {
|
||||||
&provider,
|
&provider,
|
||||||
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
self.setup_actions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl GtkApplicationImpl for Application {}
|
impl GtkApplicationImpl for Application {}
|
||||||
impl AdwApplicationImpl for Application {}
|
impl AdwApplicationImpl for Application {}
|
||||||
|
|
||||||
|
impl Application {
|
||||||
|
fn setup_actions(&self) {
|
||||||
|
let obj = &*self.obj();
|
||||||
|
|
||||||
|
// Add <Control-Q> shortcut for quitting the application.
|
||||||
|
let quit = gtk::gio::SimpleAction::new("quit", None);
|
||||||
|
quit.connect_activate(clone!(@weak obj => move |_, _| {
|
||||||
|
obj.quit();
|
||||||
|
}));
|
||||||
|
obj.set_accels_for_action("app.quit", &["<Control>Q"]);
|
||||||
|
obj.add_action(&quit);
|
||||||
|
|
||||||
|
let action_about = gio::ActionEntry::builder("about")
|
||||||
|
.activate(|obj: &super::Application, _, _| {
|
||||||
|
obj.imp().show_about_dialog();
|
||||||
|
})
|
||||||
|
.build();
|
||||||
|
obj.add_action_entries([action_about]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn show_about_dialog(&self) {
|
||||||
|
let authors: Vec<&str> = AUTHORS.split(':').collect();
|
||||||
|
|
||||||
|
let about_window = adw::AboutWindow::builder()
|
||||||
|
.application_icon(APP_ID)
|
||||||
|
.application_name("Helvum")
|
||||||
|
.developer_name("Tom Wagner")
|
||||||
|
.developers(authors)
|
||||||
|
.version(VERSION)
|
||||||
|
.website("https://gitlab.freedesktop.org/pipewire/helvum")
|
||||||
|
.issue_url("https://gitlab.freedesktop.org/pipewire/helvum/-/issues")
|
||||||
|
.license_type(gtk::License::Gpl30Only)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
about_window.present();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glib::wrapper! {
|
glib::wrapper! {
|
||||||
|
|
@ -101,7 +144,7 @@ impl Application {
|
||||||
pw_sender: Sender<GtkMessage>,
|
pw_sender: Sender<GtkMessage>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let app: Application = glib::Object::builder()
|
let app: Application = glib::Object::builder()
|
||||||
.property("application-id", "org.pipewire.Helvum")
|
.property("application-id", APP_ID)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let imp = app.imp();
|
let imp = app.imp();
|
||||||
|
|
@ -114,14 +157,6 @@ impl Application {
|
||||||
))
|
))
|
||||||
.expect("Should be able to set graph manager");
|
.expect("Should be able to set graph manager");
|
||||||
|
|
||||||
// Add <Control-Q> shortcut for quitting the application.
|
|
||||||
let quit = gtk::gio::SimpleAction::new("quit", None);
|
|
||||||
quit.connect_activate(clone!(@weak app => move |_, _| {
|
|
||||||
app.quit();
|
|
||||||
}));
|
|
||||||
app.set_accels_for_action("app.quit", &["<Control>Q"]);
|
|
||||||
app.add_action(&quit);
|
|
||||||
|
|
||||||
app
|
app
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,14 @@
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk" version="4.0"/>
|
<requires lib="gtk" version="4.0"/>
|
||||||
<requires lib="Adw" version="1.0"/>
|
<requires lib="Adw" version="1.0"/>
|
||||||
|
<menu id="primary_menu">
|
||||||
|
<section>
|
||||||
|
<item>
|
||||||
|
<attribute name="label">_About Helvum</attribute>
|
||||||
|
<attribute name="action">app.about</attribute>
|
||||||
|
</item>
|
||||||
|
</section>
|
||||||
|
</menu>
|
||||||
<template class="HelvumWindow" parent="AdwApplicationWindow">
|
<template class="HelvumWindow" parent="AdwApplicationWindow">
|
||||||
<property name="default-width">1280</property>
|
<property name="default-width">1280</property>
|
||||||
<property name="default-height">720</property>
|
<property name="default-height">720</property>
|
||||||
|
|
@ -12,8 +20,21 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwHeaderBar" id="header_bar">
|
<object class="AdwHeaderBar" id="header_bar">
|
||||||
<child type="end">
|
<child type="end">
|
||||||
<object class="HelvumZoomEntry">
|
<object class="GtkBox">
|
||||||
<property name="zoomed-widget">graph</property>
|
<style>
|
||||||
|
<class name="toolbar"></class>
|
||||||
|
</style>
|
||||||
|
<child>
|
||||||
|
<object class="HelvumZoomEntry">
|
||||||
|
<property name="zoomed-widget">graph</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkMenuButton">
|
||||||
|
<property name="icon-name">open-menu-symbolic</property>
|
||||||
|
<property name="menu-model">primary_menu</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue