mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Search for matching mediums online or locally
This commit is contained in:
parent
606ee563e9
commit
2f281d7d11
2 changed files with 32 additions and 7 deletions
|
|
@ -32,14 +32,25 @@
|
|||
<property name="margin-bottom">6</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="halign">start</property>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-top">12</property>
|
||||
<property name="margin-bottom">6</property>
|
||||
<property name="label" translatable="yes">Matching metadata</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
</attributes>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="hexpand">true</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Matching metadata</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
</attributes>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="server_check_button">
|
||||
<property name="label" translatable="yes">Use the Musicus server</property>
|
||||
<property name="active">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use gtk::prelude::*;
|
|||
use gtk_macros::get_widget;
|
||||
use libadwaita::prelude::*;
|
||||
use log::debug;
|
||||
use musicus_backend::Error;
|
||||
use musicus_backend::db::Medium;
|
||||
use musicus_backend::import::ImportSession;
|
||||
use std::rc::Rc;
|
||||
|
|
@ -17,6 +18,7 @@ pub struct ImportScreen {
|
|||
handle: NavigationHandle<()>,
|
||||
session: Arc<ImportSession>,
|
||||
widget: gtk::Box,
|
||||
server_check_button: gtk::CheckButton,
|
||||
matching_stack: gtk::Stack,
|
||||
error_row: libadwaita::ActionRow,
|
||||
matching_list: gtk::ListBox,
|
||||
|
|
@ -29,7 +31,13 @@ impl ImportScreen {
|
|||
|
||||
let this = self;
|
||||
spawn!(@clone this, async move {
|
||||
match this.handle.backend.db().get_mediums_by_source_id(this.session.source_id()).await {
|
||||
let mediums: Result<Vec<Medium>, Error> = if this.server_check_button.get_active() {
|
||||
this.handle.backend.cl().get_mediums_by_discid(this.session.source_id()).await.map_err(|err| err.into())
|
||||
} else {
|
||||
this.handle.backend.db().get_mediums_by_source_id(this.session.source_id()).await.map_err(|err| err.into())
|
||||
};
|
||||
|
||||
match mediums {
|
||||
Ok(mediums) => {
|
||||
if !mediums.is_empty() {
|
||||
this.show_matches(mediums);
|
||||
|
|
@ -99,6 +107,7 @@ impl Screen<Arc<ImportSession>, ()> for ImportScreen {
|
|||
get_widget!(builder, gtk::Stack, matching_stack);
|
||||
get_widget!(builder, gtk::Button, try_again_button);
|
||||
get_widget!(builder, libadwaita::ActionRow, error_row);
|
||||
get_widget!(builder, gtk::CheckButton, server_check_button);
|
||||
get_widget!(builder, gtk::ListBox, matching_list);
|
||||
get_widget!(builder, gtk::Button, select_button);
|
||||
get_widget!(builder, gtk::Button, add_button);
|
||||
|
|
@ -107,6 +116,7 @@ impl Screen<Arc<ImportSession>, ()> for ImportScreen {
|
|||
handle,
|
||||
session,
|
||||
widget,
|
||||
server_check_button,
|
||||
matching_stack,
|
||||
error_row,
|
||||
matching_list,
|
||||
|
|
@ -118,6 +128,10 @@ impl Screen<Arc<ImportSession>, ()> for ImportScreen {
|
|||
this.handle.pop(None);
|
||||
}));
|
||||
|
||||
this.server_check_button.connect_toggled(clone!(@weak this => move |_| {
|
||||
this.load_matches();
|
||||
}));
|
||||
|
||||
try_again_button.connect_clicked(clone!(@weak this => move |_| {
|
||||
this.load_matches();
|
||||
}));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue