mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 03:47:23 +01:00
Remove unused SearchTag
This commit is contained in:
parent
45338c1bf9
commit
66af523d5a
8 changed files with 33 additions and 139 deletions
|
|
@ -14,17 +14,6 @@
|
||||||
padding-bottom: 3px;
|
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 {
|
.tile {
|
||||||
min-height: 50px;
|
min-height: 50px;
|
||||||
min-width: 200px;
|
min-width: 200px;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -29,7 +29,10 @@ impl Library {
|
||||||
&self,
|
&self,
|
||||||
path: impl AsRef<Path>,
|
path: impl AsRef<Path>,
|
||||||
) -> Result<async_channel::Receiver<ProcessMsg>> {
|
) -> Result<async_channel::Receiver<ProcessMsg>> {
|
||||||
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 path = path.as_ref().to_owned();
|
||||||
let library_folder = PathBuf::from(&self.folder());
|
let library_folder = PathBuf::from(&self.folder());
|
||||||
let this_connection = self.imp().connection.get().unwrap().clone();
|
let this_connection = self.imp().connection.get().unwrap().clone();
|
||||||
|
|
@ -52,7 +55,10 @@ impl Library {
|
||||||
&self,
|
&self,
|
||||||
path: impl AsRef<Path>,
|
path: impl AsRef<Path>,
|
||||||
) -> Result<async_channel::Receiver<ProcessMsg>> {
|
) -> Result<async_channel::Receiver<ProcessMsg>> {
|
||||||
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 connection = &mut *self.imp().connection.get().unwrap().lock().unwrap();
|
||||||
|
|
||||||
let path = path.as_ref().to_owned();
|
let path = path.as_ref().to_owned();
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,13 @@ impl LibraryManager {
|
||||||
}
|
}
|
||||||
Ok(path) => {
|
Ok(path) => {
|
||||||
if let Some(path) = path.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) => {
|
Ok(receiver) => {
|
||||||
let process = Process::new(
|
let process = Process::new(
|
||||||
&formatx!(
|
&formatx!(
|
||||||
|
|
@ -186,7 +192,13 @@ impl LibraryManager {
|
||||||
}
|
}
|
||||||
Ok(path) => {
|
Ok(path) => {
|
||||||
if let Some(path) = path.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) => {
|
Ok(receiver) => {
|
||||||
let process = Process::new(
|
let process = Process::new(
|
||||||
&formatx!(
|
&formatx!(
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ mod program;
|
||||||
mod program_tile;
|
mod program_tile;
|
||||||
mod recording_tile;
|
mod recording_tile;
|
||||||
mod search_page;
|
mod search_page;
|
||||||
mod search_tag;
|
|
||||||
mod selector;
|
mod selector;
|
||||||
mod slider_row;
|
mod slider_row;
|
||||||
mod tag_tile;
|
mod tag_tile;
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,7 @@ use crate::{
|
||||||
program::Program,
|
program::Program,
|
||||||
program_tile::ProgramTile,
|
program_tile::ProgramTile,
|
||||||
recording_tile::RecordingTile,
|
recording_tile::RecordingTile,
|
||||||
search_tag::Tag,
|
tag_tile::{Tag, TagTile},
|
||||||
tag_tile::TagTile,
|
|
||||||
util,
|
util,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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<gtk::Label>,
|
|
||||||
pub tag: OnceCell<Tag>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[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<Self>) {
|
|
||||||
obj.init_template();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ObjectImpl for SearchTag {
|
|
||||||
fn signals() -> &'static [Signal] {
|
|
||||||
static SIGNALS: Lazy<Vec<Signal>> =
|
|
||||||
Lazy::new(|| vec![Signal::builder("remove").build()]);
|
|
||||||
|
|
||||||
SIGNALS.as_ref()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WidgetImpl for SearchTag {}
|
|
||||||
impl BoxImpl for SearchTag {}
|
|
||||||
}
|
|
||||||
|
|
||||||
glib::wrapper! {
|
|
||||||
pub struct SearchTag(ObjectSubclass<imp::SearchTag>)
|
|
||||||
@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<F: Fn(&Self) + 'static>(&self, f: F) -> glib::SignalHandlerId {
|
|
||||||
self.connect_local("remove", true, move |values| {
|
|
||||||
let obj = values[0].get::<Self>().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),
|
|
||||||
}
|
|
||||||
|
|
@ -2,7 +2,7 @@ use std::cell::OnceCell;
|
||||||
|
|
||||||
use gtk::{glib, prelude::*, subclass::prelude::*};
|
use gtk::{glib, prelude::*, subclass::prelude::*};
|
||||||
|
|
||||||
use crate::search_tag::Tag;
|
use crate::db::models::{Ensemble, Instrument, Person, Work};
|
||||||
|
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
@ -78,3 +78,12 @@ impl TagTile {
|
||||||
self.imp().tag.get().unwrap()
|
self.imp().tag.get().unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub enum Tag {
|
||||||
|
Composer(Person),
|
||||||
|
Performer(Person),
|
||||||
|
Ensemble(Ensemble),
|
||||||
|
Instrument(Instrument),
|
||||||
|
Work(Work),
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue