mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
Update dependencies, use new clone syntax
This commit is contained in:
parent
c70abf9594
commit
36b2f1097e
12 changed files with 603 additions and 490 deletions
727
Cargo.lock
generated
727
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -4,15 +4,15 @@ version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
adw = { package = "libadwaita", version = "0.6", features = ["v1_5"] }
|
adw = { package = "libadwaita", version = "0.7", features = ["v1_5"] }
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
diesel = { version = "2.2", features = ["chrono", "sqlite"] }
|
diesel = { version = "2.2", features = ["chrono", "sqlite"] }
|
||||||
diesel_migrations = "2.2"
|
diesel_migrations = "2.2"
|
||||||
fragile = "2"
|
fragile = "2"
|
||||||
gettext-rs = { version = "0.7", features = ["gettext-system"] }
|
gettext-rs = { version = "0.7", features = ["gettext-system"] }
|
||||||
gstreamer-play = "0.22"
|
gstreamer-play = "0.23"
|
||||||
gtk = { package = "gtk4", version = "0.8", features = ["v4_12", "blueprint"] }
|
gtk = { package = "gtk4", version = "0.9", features = ["v4_12", "blueprint"] }
|
||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
mpris-player = "0.6"
|
mpris-player = "0.6"
|
||||||
|
|
|
||||||
|
|
@ -28,24 +28,37 @@ mod imp {
|
||||||
self.parent_constructed();
|
self.parent_constructed();
|
||||||
|
|
||||||
let obj = self.obj();
|
let obj = self.obj();
|
||||||
obj.connect_parent_notify(clone!(@weak obj => move |_: &super::MusicusActivatableRow| {
|
obj.connect_parent_notify(clone!(
|
||||||
|
#[weak]
|
||||||
|
obj,
|
||||||
|
move |_: &super::MusicusActivatableRow| {
|
||||||
let previous_parent = obj.imp().previous_parent.borrow_mut().take();
|
let previous_parent = obj.imp().previous_parent.borrow_mut().take();
|
||||||
let previous_signal_handler_id = obj.imp().previous_signal_handler_id.borrow_mut().take();
|
let previous_signal_handler_id =
|
||||||
if let (Some(previous_parent), Some(previous_signal_handler_id)) = (previous_parent, previous_signal_handler_id) {
|
obj.imp().previous_signal_handler_id.borrow_mut().take();
|
||||||
|
if let (Some(previous_parent), Some(previous_signal_handler_id)) =
|
||||||
|
(previous_parent, previous_signal_handler_id)
|
||||||
|
{
|
||||||
previous_parent.disconnect(previous_signal_handler_id);
|
previous_parent.disconnect(previous_signal_handler_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(parent) = obj.parent().and_downcast::<gtk::ListBox>() {
|
if let Some(parent) = obj.parent().and_downcast::<gtk::ListBox>() {
|
||||||
let signal_handler_id = parent.connect_row_activated(clone!(@weak obj => move |_: >k::ListBox, row: >k::ListBoxRow| {
|
let signal_handler_id = parent.connect_row_activated(clone!(
|
||||||
|
#[weak]
|
||||||
|
obj,
|
||||||
|
move |_: >k::ListBox, row: >k::ListBoxRow| {
|
||||||
if *row == obj {
|
if *row == obj {
|
||||||
obj.activate();
|
obj.activate();
|
||||||
}
|
}
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
|
|
||||||
obj.imp().previous_parent.replace(Some(parent));
|
obj.imp().previous_parent.replace(Some(parent));
|
||||||
obj.imp().previous_signal_handler_id.replace(Some(signal_handler_id));
|
obj.imp()
|
||||||
|
.previous_signal_handler_id
|
||||||
|
.replace(Some(signal_handler_id));
|
||||||
}
|
}
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn signals() -> &'static [Signal] {
|
fn signals() -> &'static [Signal] {
|
||||||
|
|
|
||||||
|
|
@ -88,9 +88,13 @@ mod imp {
|
||||||
persons_popover.connect_create(move |_| {
|
persons_popover.connect_create(move |_| {
|
||||||
let editor = MusicusPersonEditor::new(&obj.navigation(), &obj.library(), None);
|
let editor = MusicusPersonEditor::new(&obj.navigation(), &obj.library(), None);
|
||||||
|
|
||||||
editor.connect_created(clone!(@weak obj => move |_, person| {
|
editor.connect_created(clone!(
|
||||||
|
#[weak]
|
||||||
|
obj,
|
||||||
|
move |_, person| {
|
||||||
obj.add_composer(person);
|
obj.add_composer(person);
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
|
|
||||||
obj.navigation().push(&editor);
|
obj.navigation().push(&editor);
|
||||||
});
|
});
|
||||||
|
|
@ -114,12 +118,21 @@ mod imp {
|
||||||
.css_classes(["flat"])
|
.css_classes(["flat"])
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
remove_button.connect_clicked(
|
remove_button.connect_clicked(clone!(
|
||||||
clone!(@weak obj, @weak row, @strong instrument => move |_| {
|
#[weak]
|
||||||
|
obj,
|
||||||
|
#[weak]
|
||||||
|
row,
|
||||||
|
#[strong]
|
||||||
|
instrument,
|
||||||
|
move |_| {
|
||||||
obj.imp().instrument_list.remove(&row);
|
obj.imp().instrument_list.remove(&row);
|
||||||
obj.imp().instruments.borrow_mut().retain(|i| *i != instrument);
|
obj.imp()
|
||||||
}),
|
.instruments
|
||||||
);
|
.borrow_mut()
|
||||||
|
.retain(|i| *i != instrument);
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
row.add_suffix(&remove_button);
|
row.add_suffix(&remove_button);
|
||||||
|
|
||||||
|
|
@ -184,12 +197,18 @@ impl MusicusWorkEditor {
|
||||||
.css_classes(["flat"])
|
.css_classes(["flat"])
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
remove_button.connect_clicked(
|
remove_button.connect_clicked(clone!(
|
||||||
clone!(@weak self as obj, @weak row, @strong part => move |_| {
|
#[weak(rename_to = this)]
|
||||||
obj.imp().part_list.remove(&row);
|
self,
|
||||||
obj.imp().parts.borrow_mut().retain(|p| *p != part);
|
#[weak]
|
||||||
}),
|
row,
|
||||||
);
|
#[strong]
|
||||||
|
part,
|
||||||
|
move |_| {
|
||||||
|
this.imp().part_list.remove(&row);
|
||||||
|
this.imp().parts.borrow_mut().retain(|p| *p != part);
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
row.add_suffix(&remove_button);
|
row.add_suffix(&remove_button);
|
||||||
|
|
||||||
|
|
@ -210,12 +229,16 @@ impl MusicusWorkEditor {
|
||||||
fn add_composer(&self, person: Person) {
|
fn add_composer(&self, person: Person) {
|
||||||
let role = self.library().composer_default_role().unwrap();
|
let role = self.library().composer_default_role().unwrap();
|
||||||
let composer = Composer { person, role };
|
let composer = Composer { person, role };
|
||||||
let row = MusicusWorkEditorComposerRow::new(&self.library(), composer);
|
let row = MusicusWorkEditorComposerRow::new(&self.navigation(), &self.library(), composer);
|
||||||
|
|
||||||
row.connect_remove(clone!(@weak self as obj => move |row| {
|
row.connect_remove(clone!(
|
||||||
obj.imp().composer_list.remove(row);
|
#[weak(rename_to = this)]
|
||||||
obj.imp().composer_rows.borrow_mut().retain(|c| c != row);
|
self,
|
||||||
}));
|
move |row| {
|
||||||
|
this.imp().composer_list.remove(row);
|
||||||
|
this.imp().composer_rows.borrow_mut().retain(|c| c != row);
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
self.imp()
|
self.imp()
|
||||||
.composer_list
|
.composer_list
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
use crate::{
|
use std::cell::{OnceCell, RefCell};
|
||||||
db::models::{Composer, Role},
|
|
||||||
editor::role_selector_popover::MusicusRoleSelectorPopover,
|
|
||||||
library::MusicusLibrary,
|
|
||||||
};
|
|
||||||
|
|
||||||
use adw::{prelude::*, subclass::prelude::*};
|
use adw::{prelude::*, subclass::prelude::*};
|
||||||
use gtk::glib::{self, subclass::Signal, Properties};
|
use gtk::glib::{self, clone, subclass::Signal, Properties};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use std::cell::{OnceCell, RefCell};
|
use crate::{
|
||||||
|
db::models::{Composer, Role},
|
||||||
|
editor::{role_editor::MusicusRoleEditor, role_selector_popover::MusicusRoleSelectorPopover},
|
||||||
|
library::MusicusLibrary,
|
||||||
|
};
|
||||||
|
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
@ -17,6 +17,9 @@ mod imp {
|
||||||
#[properties(wrapper_type = super::MusicusWorkEditorComposerRow)]
|
#[properties(wrapper_type = super::MusicusWorkEditorComposerRow)]
|
||||||
#[template(file = "data/ui/work_editor_composer_row.blp")]
|
#[template(file = "data/ui/work_editor_composer_row.blp")]
|
||||||
pub struct MusicusWorkEditorComposerRow {
|
pub struct MusicusWorkEditorComposerRow {
|
||||||
|
#[property(get, construct_only)]
|
||||||
|
pub navigation: OnceCell<adw::NavigationView>,
|
||||||
|
|
||||||
#[property(get, construct_only)]
|
#[property(get, construct_only)]
|
||||||
pub library: OnceCell<MusicusLibrary>,
|
pub library: OnceCell<MusicusLibrary>,
|
||||||
|
|
||||||
|
|
@ -67,6 +70,24 @@ mod imp {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let obj = self.obj().to_owned();
|
||||||
|
role_popover.connect_create(move |_| {
|
||||||
|
let editor = MusicusRoleEditor::new(&obj.navigation(), &obj.library(), None);
|
||||||
|
|
||||||
|
editor.connect_created(clone!(
|
||||||
|
#[weak]
|
||||||
|
obj,
|
||||||
|
move |_, role| {
|
||||||
|
if let Some(composer) = &mut *obj.imp().composer.borrow_mut() {
|
||||||
|
obj.imp().role_label.set_label(&role.to_string());
|
||||||
|
composer.role = role;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
obj.navigation().push(&editor);
|
||||||
|
});
|
||||||
|
|
||||||
self.role_box.append(&role_popover);
|
self.role_box.append(&role_popover);
|
||||||
self.role_popover.set(role_popover).unwrap();
|
self.role_popover.set(role_popover).unwrap();
|
||||||
}
|
}
|
||||||
|
|
@ -85,8 +106,15 @@ glib::wrapper! {
|
||||||
|
|
||||||
#[gtk::template_callbacks]
|
#[gtk::template_callbacks]
|
||||||
impl MusicusWorkEditorComposerRow {
|
impl MusicusWorkEditorComposerRow {
|
||||||
pub fn new(library: &MusicusLibrary, composer: Composer) -> Self {
|
pub fn new(
|
||||||
let obj: Self = glib::Object::builder().property("library", library).build();
|
navigation: &adw::NavigationView,
|
||||||
|
library: &MusicusLibrary,
|
||||||
|
composer: Composer,
|
||||||
|
) -> Self {
|
||||||
|
let obj: Self = glib::Object::builder()
|
||||||
|
.property("navigation", navigation)
|
||||||
|
.property("library", library)
|
||||||
|
.build();
|
||||||
obj.set_composer(composer);
|
obj.set_composer(composer);
|
||||||
obj
|
obj
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::cell::{OnceCell, RefCell};
|
||||||
use adw::subclass::{navigation_page::NavigationPageImpl, prelude::*};
|
use adw::subclass::{navigation_page::NavigationPageImpl, prelude::*};
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio,
|
gio,
|
||||||
glib::{self, clone, Properties},
|
glib::{self, Properties},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -97,10 +97,10 @@ mod imp {
|
||||||
|
|
||||||
self.search_entry.set_key_capture_widget(&*self.obj());
|
self.search_entry.set_key_capture_widget(&*self.obj());
|
||||||
|
|
||||||
self.search_entry
|
let obj = self.obj().to_owned();
|
||||||
.connect_query_changed(clone!(@weak self as _self => move |entry| {
|
self.search_entry.connect_query_changed(move |entry| {
|
||||||
_self.obj().query(&entry.query());
|
obj.query(&entry.query());
|
||||||
}));
|
});
|
||||||
|
|
||||||
self.player
|
self.player
|
||||||
.get()
|
.get()
|
||||||
|
|
@ -333,8 +333,11 @@ impl MusicusHomePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
for recording in &results.recordings {
|
for recording in &results.recordings {
|
||||||
imp.recordings_flow_box
|
imp.recordings_flow_box.append(&MusicusRecordingTile::new(
|
||||||
.append(&MusicusRecordingTile::new(recording));
|
&self.navigation(),
|
||||||
|
&self.library(),
|
||||||
|
recording,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
for album in &results.albums {
|
for album in &results.albums {
|
||||||
|
|
|
||||||
|
|
@ -137,12 +137,36 @@ mod imp {
|
||||||
mpris.set_can_set_fullscreen(false);
|
mpris.set_can_set_fullscreen(false);
|
||||||
|
|
||||||
let obj = self.obj();
|
let obj = self.obj();
|
||||||
mpris.connect_raise(clone!(@weak obj => move || obj.emit_by_name::<()>("raise", &[])));
|
mpris.connect_raise(clone!(
|
||||||
mpris.connect_play(clone!(@weak obj => move || obj.play()));
|
#[weak]
|
||||||
mpris.connect_pause(clone!(@weak obj => move || obj.pause()));
|
obj,
|
||||||
mpris.connect_play_pause(clone!(@weak obj => move || obj.play_pause()));
|
move || obj.emit_by_name::<()>("raise", &[])
|
||||||
mpris.connect_previous(clone!(@weak obj => move || obj.previous()));
|
));
|
||||||
mpris.connect_next(clone!(@weak obj => move || obj.next()));
|
mpris.connect_play(clone!(
|
||||||
|
#[weak]
|
||||||
|
obj,
|
||||||
|
move || obj.play()
|
||||||
|
));
|
||||||
|
mpris.connect_pause(clone!(
|
||||||
|
#[weak]
|
||||||
|
obj,
|
||||||
|
move || obj.pause()
|
||||||
|
));
|
||||||
|
mpris.connect_play_pause(clone!(
|
||||||
|
#[weak]
|
||||||
|
obj,
|
||||||
|
move || obj.play_pause()
|
||||||
|
));
|
||||||
|
mpris.connect_previous(clone!(
|
||||||
|
#[weak]
|
||||||
|
obj,
|
||||||
|
move || obj.previous()
|
||||||
|
));
|
||||||
|
mpris.connect_next(clone!(
|
||||||
|
#[weak]
|
||||||
|
obj,
|
||||||
|
move || obj.next()
|
||||||
|
));
|
||||||
|
|
||||||
self.mpris.set(mpris).expect("mpris should not be set");
|
self.mpris.set(mpris).expect("mpris should not be set");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,7 @@ mod imp {
|
||||||
.set_label(&format_time(current_time_ms));
|
.set_label(&format_time(current_time_ms));
|
||||||
|
|
||||||
self.remaining_time_label.set_label(&format_time(
|
self.remaining_time_label.set_label(&format_time(
|
||||||
player
|
player.duration_ms().saturating_sub(current_time_ms),
|
||||||
.duration_ms().saturating_sub(current_time_ms),
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -121,24 +120,38 @@ mod imp {
|
||||||
.sync_create()
|
.sync_create()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let obj = self.obj().clone();
|
let obj = self.obj();
|
||||||
|
|
||||||
player.connect_current_index_notify(
|
player.connect_current_index_notify(clone!(
|
||||||
clone!(@weak obj => move |_| obj.imp().update_item()),
|
#[weak]
|
||||||
);
|
obj,
|
||||||
player.playlist().connect_items_changed(
|
move |_| obj.imp().update_item()
|
||||||
clone!(@weak obj => move |_, _, _, _| obj.imp().update_item()),
|
));
|
||||||
);
|
player.playlist().connect_items_changed(clone!(
|
||||||
|
#[weak]
|
||||||
|
obj,
|
||||||
|
move |_, _, _, _| obj.imp().update_item()
|
||||||
|
));
|
||||||
|
|
||||||
player
|
player.connect_position_ms_notify(clone!(
|
||||||
.connect_position_ms_notify(clone!(@weak obj => move |_| obj.imp().update_time()));
|
#[weak]
|
||||||
player
|
obj,
|
||||||
.connect_duration_ms_notify(clone!(@weak obj => move |_| obj.imp().update_time()));
|
move |_| obj.imp().update_time()
|
||||||
|
));
|
||||||
|
player.connect_duration_ms_notify(clone!(
|
||||||
|
#[weak]
|
||||||
|
obj,
|
||||||
|
move |_| obj.imp().update_time()
|
||||||
|
));
|
||||||
|
|
||||||
let seeking_controller = gtk::EventControllerLegacy::new();
|
let seeking_controller = gtk::EventControllerLegacy::new();
|
||||||
|
|
||||||
seeking_controller.connect_event(
|
seeking_controller.connect_event(clone!(
|
||||||
clone!(@weak obj => @default-return glib::Propagation::Proceed, move |_, event| {
|
#[weak]
|
||||||
|
obj,
|
||||||
|
#[upgrade_or]
|
||||||
|
glib::Propagation::Proceed,
|
||||||
|
move |_, event| {
|
||||||
if let Some(event) = event.downcast_ref::<gdk::ButtonEvent>() {
|
if let Some(event) = event.downcast_ref::<gdk::ButtonEvent>() {
|
||||||
let imp = obj.imp();
|
let imp = obj.imp();
|
||||||
if event.button() == gdk::BUTTON_PRIMARY {
|
if event.button() == gdk::BUTTON_PRIMARY {
|
||||||
|
|
@ -148,23 +161,27 @@ mod imp {
|
||||||
}
|
}
|
||||||
gdk::EventType::ButtonRelease => {
|
gdk::EventType::ButtonRelease => {
|
||||||
let player = obj.player();
|
let player = obj.player();
|
||||||
player.seek_to((imp.slider.value() * player.duration_ms() as f64) as u64);
|
player.seek_to(
|
||||||
|
(imp.slider.value() * player.duration_ms() as f64) as u64,
|
||||||
|
);
|
||||||
imp.seeking.set(false);
|
imp.seeking.set(false);
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glib::Propagation::Proceed
|
glib::Propagation::Proceed
|
||||||
}),
|
}
|
||||||
);
|
));
|
||||||
|
|
||||||
self.slider.add_controller(seeking_controller);
|
self.slider.add_controller(seeking_controller);
|
||||||
|
|
||||||
self.slider
|
self.slider.connect_value_changed(clone!(
|
||||||
.connect_value_changed(clone!(@weak obj => move |_| obj.imp().update_time()));
|
#[weak]
|
||||||
|
obj,
|
||||||
|
move |_| obj.imp().update_time()
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,9 @@ impl MusicusPlaylistPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scroll_to_current(&self) {
|
pub fn scroll_to_current(&self) {
|
||||||
self.imp().playlist.scroll_to(self.player().current_index(), ListScrollFlags::NONE, None);
|
self.imp()
|
||||||
|
.playlist
|
||||||
|
.scroll_to(self.player().current_index(), ListScrollFlags::NONE, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,10 @@ impl Program {
|
||||||
.property("description", &*data.description.borrow())
|
.property("description", &*data.description.borrow())
|
||||||
.property("design", data.design.get())
|
.property("design", data.design.get())
|
||||||
.property("prefer-recently-added", data.prefer_recently_added.get())
|
.property("prefer-recently-added", data.prefer_recently_added.get())
|
||||||
.property("prefer-least-recently-played", data.prefer_least_recently_played.get())
|
.property(
|
||||||
|
"prefer-least-recently-played",
|
||||||
|
data.prefer_least_recently_played.get(),
|
||||||
|
)
|
||||||
.property("play-full-recordings", data.play_full_recordings.get())
|
.property("play-full-recordings", data.play_full_recordings.get())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,10 @@ mod imp {
|
||||||
gesture.set_state(gtk::EventSequenceState::Claimed);
|
gesture.set_state(gtk::EventSequenceState::Claimed);
|
||||||
});
|
});
|
||||||
|
|
||||||
controller.connect_released(clone!(@weak self as _self => move |_, _, _, _| {
|
let obj = self.obj().to_owned();
|
||||||
_self.obj().reset();
|
controller.connect_released(move |_, _, _, _| {
|
||||||
}));
|
obj.reset();
|
||||||
|
});
|
||||||
|
|
||||||
self.clear_icon.add_controller(controller);
|
self.clear_icon.add_controller(controller);
|
||||||
}
|
}
|
||||||
|
|
@ -120,19 +121,29 @@ impl MusicusSearchEntry {
|
||||||
pub fn set_key_capture_widget(&self, widget: &impl IsA<gtk::Widget>) {
|
pub fn set_key_capture_widget(&self, widget: &impl IsA<gtk::Widget>) {
|
||||||
let controller = gtk::EventControllerKey::new();
|
let controller = gtk::EventControllerKey::new();
|
||||||
|
|
||||||
controller.connect_key_pressed(clone!(@weak self as _self => @default-return glib::Propagation::Proceed, move |controller, _, _, _| {
|
controller.connect_key_pressed(clone!(
|
||||||
match controller.forward(&_self.imp().text.get()) {
|
#[weak(rename_to = this)]
|
||||||
|
self,
|
||||||
|
#[upgrade_or]
|
||||||
|
glib::Propagation::Proceed,
|
||||||
|
move |controller, _, _, _| {
|
||||||
|
match controller.forward(&this.imp().text.get()) {
|
||||||
true => {
|
true => {
|
||||||
_self.grab_focus();
|
this.grab_focus();
|
||||||
glib::Propagation::Stop
|
glib::Propagation::Stop
|
||||||
},
|
}
|
||||||
false => glib::Propagation::Proceed,
|
false => glib::Propagation::Proceed,
|
||||||
}
|
}
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
|
|
||||||
controller.connect_key_released(clone!(@weak self as _self => move |controller, _, _, _| {
|
controller.connect_key_released(clone!(
|
||||||
controller.forward(&_self.imp().text.get());
|
#[weak(rename_to = this)]
|
||||||
}));
|
self,
|
||||||
|
move |controller, _, _, _| {
|
||||||
|
controller.forward(&this.imp().text.get());
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
widget.add_controller(controller);
|
widget.add_controller(controller);
|
||||||
}
|
}
|
||||||
|
|
@ -157,8 +168,11 @@ impl MusicusSearchEntry {
|
||||||
|
|
||||||
let tag = MusicusSearchTag::new(tag);
|
let tag = MusicusSearchTag::new(tag);
|
||||||
|
|
||||||
tag.connect_remove(clone!(@weak self as self_ => move |tag| {
|
tag.connect_remove(clone!(
|
||||||
let imp = self_.imp();
|
#[weak(rename_to = this)]
|
||||||
|
self,
|
||||||
|
move |tag| {
|
||||||
|
let imp = this.imp();
|
||||||
|
|
||||||
imp.tags_box.remove(tag);
|
imp.tags_box.remove(tag);
|
||||||
|
|
||||||
|
|
@ -166,8 +180,9 @@ impl MusicusSearchEntry {
|
||||||
imp.tags.borrow_mut().retain(|t| t.tag() != tag.tag());
|
imp.tags.borrow_mut().retain(|t| t.tag() != tag.tag());
|
||||||
}
|
}
|
||||||
|
|
||||||
self_.emit_by_name::<()>("query-changed", &[]);
|
this.emit_by_name::<()>("query-changed", &[]);
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
|
|
||||||
imp.tags_box.append(&tag);
|
imp.tags_box.append(&tag);
|
||||||
imp.tags.borrow_mut().push(tag);
|
imp.tags.borrow_mut().push(tag);
|
||||||
|
|
@ -208,7 +223,7 @@ impl MusicusSearchEntry {
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
fn backspace(&self, text: >k::Text) {
|
fn backspace(&self, text: >k::Text) {
|
||||||
if text.cursor_position() == 0 {
|
if text.position() == 0 {
|
||||||
let changed = if let Some(tag) = self.imp().tags.borrow_mut().pop() {
|
let changed = if let Some(tag) = self.imp().tags.borrow_mut().pop() {
|
||||||
self.imp().tags_box.remove(&tag);
|
self.imp().tags_box.remove(&tag);
|
||||||
true
|
true
|
||||||
|
|
|
||||||
|
|
@ -67,21 +67,31 @@ mod imp {
|
||||||
self.stack.add_named(&playlist_page, Some("playlist"));
|
self.stack.add_named(&playlist_page, Some("playlist"));
|
||||||
|
|
||||||
let stack = self.stack.get();
|
let stack = self.stack.get();
|
||||||
playlist_page.connect_close(clone!(@weak player_bar, @weak stack => move |_| {
|
playlist_page.connect_close(clone!(
|
||||||
|
#[weak]
|
||||||
|
player_bar,
|
||||||
|
#[weak]
|
||||||
|
stack,
|
||||||
|
move |_| {
|
||||||
stack.set_visible_child_name("navigation");
|
stack.set_visible_child_name("navigation");
|
||||||
player_bar.playlist_hidden();
|
player_bar.playlist_hidden();
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
|
|
||||||
player_bar.connect_show_playlist(
|
player_bar.connect_show_playlist(clone!(
|
||||||
clone!(@weak playlist_page, @weak stack => move |_, show| {
|
#[weak]
|
||||||
|
playlist_page,
|
||||||
|
#[weak]
|
||||||
|
stack,
|
||||||
|
move |_, show| {
|
||||||
if show {
|
if show {
|
||||||
playlist_page.scroll_to_current();
|
playlist_page.scroll_to_current();
|
||||||
stack.set_visible_child_name("playlist");
|
stack.set_visible_child_name("playlist");
|
||||||
} else {
|
} else {
|
||||||
stack.set_visible_child_name("navigation");
|
stack.set_visible_child_name("navigation");
|
||||||
};
|
};
|
||||||
}),
|
}
|
||||||
);
|
));
|
||||||
|
|
||||||
self.player
|
self.player
|
||||||
.bind_property("active", &self.player_bar_revealer.get(), "reveal-child")
|
.bind_property("active", &self.player_bar_revealer.get(), "reveal-child")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue