diff --git a/data/res/style.css b/data/res/style.css index b3ebbf3..4e55c11 100644 --- a/data/res/style.css +++ b/data/res/style.css @@ -14,17 +14,6 @@ padding-bottom: 3px; } -.searchbar .searchtag { - background-color: alpha(currentColor, 0.1); - border-radius: 100px; -} - -.searchbar .searchtag>button { - min-width: 24px; - min-height: 24px; - margin: 0px; -} - .tile { min-height: 50px; min-width: 200px; diff --git a/data/ui/search_tag.blp b/data/ui/search_tag.blp deleted file mode 100644 index be66cf5..0000000 --- a/data/ui/search_tag.blp +++ /dev/null @@ -1,22 +0,0 @@ -using Gtk 4.0; - -template $MusicusSearchTag : Gtk.Box { - styles ["searchtag"] - - margin-start: 6; - margin-end: 6; - - Gtk.Label label { - styles ["caption-heading"] - margin-start: 12; - margin-end: 6; - max-width-chars: 15; - ellipsize: end; - } - - Gtk.Button button { - styles ["flat", "circular"] - icon-name: "window-close-symbolic"; - clicked => $remove() swapped; - } -} \ No newline at end of file diff --git a/src/library/exchange.rs b/src/library/exchange.rs index 5e512ae..3560d9f 100644 --- a/src/library/exchange.rs +++ b/src/library/exchange.rs @@ -29,7 +29,10 @@ impl Library { &self, path: impl AsRef, ) -> Result> { - log::info!("Importing library from ZIP at {}", path.as_ref().to_string_lossy()); + log::info!( + "Importing library from ZIP at {}", + path.as_ref().to_string_lossy() + ); let path = path.as_ref().to_owned(); let library_folder = PathBuf::from(&self.folder()); let this_connection = self.imp().connection.get().unwrap().clone(); @@ -52,7 +55,10 @@ impl Library { &self, path: impl AsRef, ) -> Result> { - log::info!("Exporting library to ZIP at {}", path.as_ref().to_string_lossy()); + log::info!( + "Exporting library to ZIP at {}", + path.as_ref().to_string_lossy() + ); let connection = &mut *self.imp().connection.get().unwrap().lock().unwrap(); let path = path.as_ref().to_owned(); diff --git a/src/library_manager.rs b/src/library_manager.rs index 5c494f3..5d1d987 100644 --- a/src/library_manager.rs +++ b/src/library_manager.rs @@ -128,7 +128,13 @@ impl LibraryManager { } Ok(path) => { if let Some(path) = path.path() { - match self.imp().library.get().unwrap().import_library_from_zip(&path) { + match self + .imp() + .library + .get() + .unwrap() + .import_library_from_zip(&path) + { Ok(receiver) => { let process = Process::new( &formatx!( @@ -186,7 +192,13 @@ impl LibraryManager { } Ok(path) => { if let Some(path) = path.path() { - match self.imp().library.get().unwrap().export_library_to_zip(&path) { + match self + .imp() + .library + .get() + .unwrap() + .export_library_to_zip(&path) + { Ok(receiver) => { let process = Process::new( &formatx!( diff --git a/src/main.rs b/src/main.rs index 35e5a4c..14115fe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,6 @@ mod program; mod program_tile; mod recording_tile; mod search_page; -mod search_tag; mod selector; mod slider_row; mod tag_tile; diff --git a/src/search_page.rs b/src/search_page.rs index b9c6ff7..ce7983b 100644 --- a/src/search_page.rs +++ b/src/search_page.rs @@ -22,8 +22,7 @@ use crate::{ program::Program, program_tile::ProgramTile, recording_tile::RecordingTile, - search_tag::Tag, - tag_tile::TagTile, + tag_tile::{Tag, TagTile}, util, }; diff --git a/src/search_tag.rs b/src/search_tag.rs deleted file mode 100644 index e2cdb8b..0000000 --- a/src/search_tag.rs +++ /dev/null @@ -1,98 +0,0 @@ -use std::cell::OnceCell; - -use adw::{glib, glib::subclass::Signal, prelude::*, subclass::prelude::*}; -use once_cell::sync::Lazy; - -use crate::db::models::{Ensemble, Instrument, Person, Work}; - -mod imp { - use super::*; - - #[derive(Debug, Default, gtk::CompositeTemplate)] - #[template(file = "data/ui/search_tag.blp")] - pub struct SearchTag { - #[template_child] - pub label: TemplateChild, - pub tag: OnceCell, - } - - #[glib::object_subclass] - impl ObjectSubclass for SearchTag { - const NAME: &'static str = "MusicusSearchTag"; - type Type = super::SearchTag; - type ParentType = gtk::Box; - - fn class_init(klass: &mut Self::Class) { - klass.bind_template(); - klass.bind_template_instance_callbacks(); - } - - fn instance_init(obj: &glib::subclass::InitializingObject) { - obj.init_template(); - } - } - - impl ObjectImpl for SearchTag { - fn signals() -> &'static [Signal] { - static SIGNALS: Lazy> = - Lazy::new(|| vec![Signal::builder("remove").build()]); - - SIGNALS.as_ref() - } - } - - impl WidgetImpl for SearchTag {} - impl BoxImpl for SearchTag {} -} - -glib::wrapper! { - pub struct SearchTag(ObjectSubclass) - @extends gtk::Widget; -} - -#[gtk::template_callbacks] -impl SearchTag { - pub fn new(tag: Tag) -> Self { - let obj: SearchTag = glib::Object::new(); - - let label = match &tag { - Tag::Composer(person) => person.name.get(), - Tag::Performer(person) => person.name.get(), - Tag::Ensemble(ensemble) => ensemble.name.get(), - Tag::Instrument(instrument) => instrument.name.get(), - Tag::Work(work) => work.name.get(), - }; - - obj.imp().label.set_label(label); - obj.set_tooltip_text(Some(label)); - obj.imp().tag.set(tag).unwrap(); - - obj - } - - pub fn connect_remove(&self, f: F) -> glib::SignalHandlerId { - self.connect_local("remove", true, move |values| { - let obj = values[0].get::().unwrap(); - f(&obj); - None - }) - } - - pub fn tag(&self) -> &Tag { - self.imp().tag.get().unwrap() - } - - #[template_callback] - fn remove(&self) { - self.emit_by_name::<()>("remove", &[]); - } -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub enum Tag { - Composer(Person), - Performer(Person), - Ensemble(Ensemble), - Instrument(Instrument), - Work(Work), -} diff --git a/src/tag_tile.rs b/src/tag_tile.rs index 2f2f642..7b92ea5 100644 --- a/src/tag_tile.rs +++ b/src/tag_tile.rs @@ -2,7 +2,7 @@ use std::cell::OnceCell; use gtk::{glib, prelude::*, subclass::prelude::*}; -use crate::search_tag::Tag; +use crate::db::models::{Ensemble, Instrument, Person, Work}; mod imp { use super::*; @@ -78,3 +78,12 @@ impl TagTile { self.imp().tag.get().unwrap() } } + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Tag { + Composer(Person), + Performer(Person), + Ensemble(Ensemble), + Instrument(Instrument), + Work(Work), +}