mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Make tiles selectable by mouse
This commit is contained in:
parent
2143d6333b
commit
16d1408194
3 changed files with 33 additions and 1 deletions
|
|
@ -57,6 +57,7 @@ template $MusicusHomePage : Adw.NavigationPage {
|
||||||
row-spacing: 12;
|
row-spacing: 12;
|
||||||
homogeneous: true;
|
homogeneous: true;
|
||||||
selection-mode: none;
|
selection-mode: none;
|
||||||
|
child-activated => $tile_selected() swapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk.Label {
|
Gtk.Label {
|
||||||
|
|
@ -73,6 +74,7 @@ template $MusicusHomePage : Adw.NavigationPage {
|
||||||
row-spacing: 12;
|
row-spacing: 12;
|
||||||
homogeneous: true;
|
homogeneous: true;
|
||||||
selection-mode: none;
|
selection-mode: none;
|
||||||
|
child-activated => $tile_selected() swapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk.Label {
|
Gtk.Label {
|
||||||
|
|
@ -89,6 +91,7 @@ template $MusicusHomePage : Adw.NavigationPage {
|
||||||
row-spacing: 12;
|
row-spacing: 12;
|
||||||
homogeneous: true;
|
homogeneous: true;
|
||||||
selection-mode: none;
|
selection-mode: none;
|
||||||
|
child-activated => $tile_selected() swapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk.Label {
|
Gtk.Label {
|
||||||
|
|
@ -105,6 +108,7 @@ template $MusicusHomePage : Adw.NavigationPage {
|
||||||
row-spacing: 12;
|
row-spacing: 12;
|
||||||
homogeneous: true;
|
homogeneous: true;
|
||||||
selection-mode: none;
|
selection-mode: none;
|
||||||
|
child-activated => $tile_selected() swapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk.Label {
|
Gtk.Label {
|
||||||
|
|
@ -121,6 +125,7 @@ template $MusicusHomePage : Adw.NavigationPage {
|
||||||
row-spacing: 12;
|
row-spacing: 12;
|
||||||
homogeneous: true;
|
homogeneous: true;
|
||||||
selection-mode: none;
|
selection-mode: none;
|
||||||
|
child-activated => $recording_selected() swapped;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,12 +118,13 @@ impl MusicusHomePage {
|
||||||
fn select(&self, search_entry: &MusicusSearchEntry) {
|
fn select(&self, search_entry: &MusicusSearchEntry) {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
|
|
||||||
let (composer, performer, ensemble, work) = {
|
let (composer, performer, ensemble, work, recording) = {
|
||||||
(
|
(
|
||||||
imp.composers.borrow().first().cloned(),
|
imp.composers.borrow().first().cloned(),
|
||||||
imp.performers.borrow().first().cloned(),
|
imp.performers.borrow().first().cloned(),
|
||||||
imp.ensembles.borrow().first().cloned(),
|
imp.ensembles.borrow().first().cloned(),
|
||||||
imp.works.borrow().first().cloned(),
|
imp.works.borrow().first().cloned(),
|
||||||
|
imp.recordings.borrow().first().cloned(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -135,9 +136,31 @@ impl MusicusHomePage {
|
||||||
search_entry.add_tag(Tag::Ensemble(ensemble));
|
search_entry.add_tag(Tag::Ensemble(ensemble));
|
||||||
} else if let Some(work) = work {
|
} else if let Some(work) = work {
|
||||||
search_entry.add_tag(Tag::Work(work));
|
search_entry.add_tag(Tag::Work(work));
|
||||||
|
} else if let Some(recording) = recording {
|
||||||
|
self.play_recording(&recording);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[template_callback]
|
||||||
|
fn tile_selected(&self, tile: >k::FlowBoxChild, _: >k::FlowBox) {
|
||||||
|
self.imp()
|
||||||
|
.search_entry
|
||||||
|
.add_tag(tile.downcast_ref::<MusicusTagTile>().unwrap().tag().clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[template_callback]
|
||||||
|
fn recording_selected(&self, tile: >k::FlowBoxChild, _: >k::FlowBox) {
|
||||||
|
self.play_recording(
|
||||||
|
tile.downcast_ref::<MusicusRecordingTile>()
|
||||||
|
.unwrap()
|
||||||
|
.recording(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn play_recording(&self, recording: &Recording) {
|
||||||
|
log::info!("Play recording: {:?}", recording)
|
||||||
|
}
|
||||||
|
|
||||||
fn query(&self, query: &LibraryQuery) {
|
fn query(&self, query: &LibraryQuery) {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
let results = self.library().query(query);
|
let results = self.library().query(query);
|
||||||
|
|
|
||||||
|
|
@ -64,4 +64,8 @@ impl MusicusTagTile {
|
||||||
|
|
||||||
obj
|
obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn tag(&self) -> &Tag {
|
||||||
|
self.imp().tag.get().unwrap()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue