From 2020e56c8166c6b09a64776d4899e6679c30062c Mon Sep 17 00:00:00 2001 From: Avery Date: Sat, 18 Nov 2023 17:31:20 -0500 Subject: [PATCH] Use app icon for windows and about --- data/icons/meson.build | 10 ++++++++++ data/meson.build | 1 + delfin/.gitignore | 2 ++ delfin/meson.build | 15 +++++++++++++++ delfin/src/app.rs | 2 ++ delfin/src/borgar/about.rs | 3 ++- delfin/src/lib.rs | 1 + delfin/src/main.rs | 11 +++++------ delfin/src/meson_config.rs.in | 2 ++ meson.build | 11 +++++++++++ 10 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 data/icons/meson.build create mode 100644 data/meson.build create mode 100644 delfin/.gitignore create mode 100644 delfin/src/meson_config.rs.in diff --git a/data/icons/meson.build b/data/icons/meson.build new file mode 100644 index 0000000..fdd715d --- /dev/null +++ b/data/icons/meson.build @@ -0,0 +1,10 @@ +install_data( + '@0@.svg'.format(app_id), + install_dir: iconsdir / 'hicolor' / 'scalable' / 'apps' +) + +install_data( + '@0@-symbolic.svg'.format(base_id), + install_dir: iconsdir / 'hicolor' / 'symbolic' / 'apps', + rename: '@0@-symbolic.svg'.format(app_id) +) diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 0000000..feb1c1e --- /dev/null +++ b/data/meson.build @@ -0,0 +1 @@ +subdir('icons') diff --git a/delfin/.gitignore b/delfin/.gitignore new file mode 100644 index 0000000..fa432a7 --- /dev/null +++ b/delfin/.gitignore @@ -0,0 +1,2 @@ +# Gets generated by Meson +src/meson_config.rs diff --git a/delfin/meson.build b/delfin/meson.build index 3f372d0..d46461e 100644 --- a/delfin/meson.build +++ b/delfin/meson.build @@ -1,3 +1,18 @@ +config = configure_file( + input: 'src/meson_config.rs.in', + output: 'meson_config.rs', + configuration: { + 'APP_ID': app_id, + }, +) + +run_command( + 'cp', + meson.project_build_root() / 'delfin' / 'meson_config.rs', + meson.project_source_root() / 'delfin' / 'src' / 'meson_config.rs', + check: true +) + cargo_options = [] rust_target = 'debug' diff --git a/delfin/src/app.rs b/delfin/src/app.rs index d9aac85..10fe05e 100644 --- a/delfin/src/app.rs +++ b/delfin/src/app.rs @@ -14,6 +14,7 @@ use crate::{ library::{Library, LibraryOutput}, locales::tera_tr, media_details::MediaDetails, + meson_config::APP_ID, servers::server_list::{ServerList, ServerListOutput}, tr, utils::{main_window::MAIN_APP_WINDOW_NAME, shift_state::shift_state_controller}, @@ -107,6 +108,7 @@ impl Component for App { root: &Self::Root, sender: relm4::ComponentSender, ) -> relm4::ComponentParts { + gtk::Window::set_default_icon_name(APP_ID); adw::StyleManager::default().set_color_scheme(CONFIG.read().general.theme().into()); // Use development styles when running debug build diff --git a/delfin/src/borgar/about.rs b/delfin/src/borgar/about.rs index feb0b02..e2c90fb 100644 --- a/delfin/src/borgar/about.rs +++ b/delfin/src/borgar/about.rs @@ -1,7 +1,7 @@ use gtk::prelude::*; use relm4::{prelude::*, ComponentParts, SimpleComponent}; -use crate::tr; +use crate::{meson_config::APP_ID, tr}; pub(crate) struct About; @@ -18,6 +18,7 @@ impl SimpleComponent for About { set_visible: true, set_application_name: tr!("app-name"), + set_application_icon: APP_ID, set_developer_name: "Avery ❤️", set_version: "0.0", set_license_type: gtk::License::Agpl30, diff --git a/delfin/src/lib.rs b/delfin/src/lib.rs index 4205e51..7311696 100644 --- a/delfin/src/lib.rs +++ b/delfin/src/lib.rs @@ -7,6 +7,7 @@ pub mod jellyfin_api; pub mod library; pub mod locales; pub mod media_details; +pub mod meson_config; pub mod preferences; pub mod servers; pub mod utils; diff --git a/delfin/src/main.rs b/delfin/src/main.rs index 1c29eee..8743397 100644 --- a/delfin/src/main.rs +++ b/delfin/src/main.rs @@ -1,4 +1,7 @@ -use delfin::app::{App, APP_BROKER}; +use delfin::{ + app::{App, APP_BROKER}, + meson_config::APP_ID, +}; use relm4::RelmApp; fn main() { @@ -9,11 +12,7 @@ fn main() { video_player_gst::init_gst(); } - let app = if cfg!(debug_assertions) { - RelmApp::new("cafe.avery.Delfin.Devel") - } else { - RelmApp::new("cafe.avery.Delfin") - }; + let app = RelmApp::new(APP_ID); relm4_icons::initialize_icons(); load_css(); diff --git a/delfin/src/meson_config.rs.in b/delfin/src/meson_config.rs.in new file mode 100644 index 0000000..4c65a28 --- /dev/null +++ b/delfin/src/meson_config.rs.in @@ -0,0 +1,2 @@ +// Generated by Meson from meson_config.rs.in - do not modify +pub const APP_ID: &str = "@APP_ID@"; diff --git a/meson.build b/meson.build index ade2f05..d9a2745 100644 --- a/meson.build +++ b/meson.build @@ -6,6 +6,8 @@ project( subproject_dir: 'video_player_mpv', ) +gnome = import('gnome') + base_id = 'cafe.avery.Delfin' cargo = find_program('cargo', required: true) @@ -28,5 +30,14 @@ if get_option('flatpak') ) endif +prefix = get_option('prefix') +datadir = prefix / get_option('datadir') +iconsdir = datadir / 'icons' + subproject('sys') subdir('delfin') +subdir('data') + +gnome.post_install( + gtk_update_icon_cache: true, +)