diff --git a/data/ui/album_editor.blp b/data/ui/editor/album.blp
similarity index 100%
rename from data/ui/album_editor.blp
rename to data/ui/editor/album.blp
diff --git a/data/ui/ensemble_editor.blp b/data/ui/editor/ensemble.blp
similarity index 100%
rename from data/ui/ensemble_editor.blp
rename to data/ui/editor/ensemble.blp
diff --git a/data/ui/instrument_editor.blp b/data/ui/editor/instrument.blp
similarity index 100%
rename from data/ui/instrument_editor.blp
rename to data/ui/editor/instrument.blp
diff --git a/data/ui/person_editor.blp b/data/ui/editor/person.blp
similarity index 100%
rename from data/ui/person_editor.blp
rename to data/ui/editor/person.blp
diff --git a/data/ui/recording_editor.blp b/data/ui/editor/recording.blp
similarity index 100%
rename from data/ui/recording_editor.blp
rename to data/ui/editor/recording.blp
diff --git a/data/ui/recording_editor_ensemble_row.blp b/data/ui/editor/recording/ensemble_row.blp
similarity index 100%
rename from data/ui/recording_editor_ensemble_row.blp
rename to data/ui/editor/recording/ensemble_row.blp
diff --git a/data/ui/recording_editor_performer_row.blp b/data/ui/editor/recording/performer_row.blp
similarity index 100%
rename from data/ui/recording_editor_performer_row.blp
rename to data/ui/editor/recording/performer_row.blp
diff --git a/data/ui/role_editor.blp b/data/ui/editor/role.blp
similarity index 100%
rename from data/ui/role_editor.blp
rename to data/ui/editor/role.blp
diff --git a/data/ui/tracks_editor.blp b/data/ui/editor/tracks.blp
similarity index 100%
rename from data/ui/tracks_editor.blp
rename to data/ui/editor/tracks.blp
diff --git a/data/ui/tracks_editor_parts_popover.blp b/data/ui/editor/tracks/parts_popover.blp
similarity index 100%
rename from data/ui/tracks_editor_parts_popover.blp
rename to data/ui/editor/tracks/parts_popover.blp
diff --git a/data/ui/tracks_editor_track_row.blp b/data/ui/editor/tracks/track_row.blp
similarity index 100%
rename from data/ui/tracks_editor_track_row.blp
rename to data/ui/editor/tracks/track_row.blp
diff --git a/data/ui/translation_editor.blp b/data/ui/editor/translation.blp
similarity index 100%
rename from data/ui/translation_editor.blp
rename to data/ui/editor/translation.blp
diff --git a/data/ui/translation_entry.blp b/data/ui/editor/translation_entry.blp
similarity index 100%
rename from data/ui/translation_entry.blp
rename to data/ui/editor/translation_entry.blp
diff --git a/data/ui/work_editor.blp b/data/ui/editor/work.blp
similarity index 100%
rename from data/ui/work_editor.blp
rename to data/ui/editor/work.blp
diff --git a/data/ui/work_editor_composer_row.blp b/data/ui/editor/work/composer_row.blp
similarity index 100%
rename from data/ui/work_editor_composer_row.blp
rename to data/ui/editor/work/composer_row.blp
diff --git a/data/ui/work_editor_part_row.blp b/data/ui/editor/work/part_row.blp
similarity index 100%
rename from data/ui/work_editor_part_row.blp
rename to data/ui/editor/work/part_row.blp
diff --git a/data/ui/ensemble_selector_popover.blp b/data/ui/selector/ensemble.blp
similarity index 100%
rename from data/ui/ensemble_selector_popover.blp
rename to data/ui/selector/ensemble.blp
diff --git a/data/ui/instrument_selector_popover.blp b/data/ui/selector/instrument.blp
similarity index 100%
rename from data/ui/instrument_selector_popover.blp
rename to data/ui/selector/instrument.blp
diff --git a/data/ui/performer_role_selector_popover.blp b/data/ui/selector/performer_role.blp
similarity index 100%
rename from data/ui/performer_role_selector_popover.blp
rename to data/ui/selector/performer_role.blp
diff --git a/data/ui/person_selector_popover.blp b/data/ui/selector/person.blp
similarity index 100%
rename from data/ui/person_selector_popover.blp
rename to data/ui/selector/person.blp
diff --git a/data/ui/recording_selector_popover.blp b/data/ui/selector/recording.blp
similarity index 100%
rename from data/ui/recording_selector_popover.blp
rename to data/ui/selector/recording.blp
diff --git a/data/ui/role_selector_popover.blp b/data/ui/selector/role.blp
similarity index 100%
rename from data/ui/role_selector_popover.blp
rename to data/ui/selector/role.blp
diff --git a/data/ui/work_selector_popover.blp b/data/ui/selector/work.blp
similarity index 100%
rename from data/ui/work_selector_popover.blp
rename to data/ui/selector/work.blp
diff --git a/src/editor/activatable_row.rs b/src/activatable_row.rs
similarity index 87%
rename from src/editor/activatable_row.rs
rename to src/activatable_row.rs
index 63751d2..9e3da5b 100644
--- a/src/editor/activatable_row.rs
+++ b/src/activatable_row.rs
@@ -1,3 +1,5 @@
+use std::cell::RefCell;
+
use gtk::{
glib::{self, clone, subclass::Signal},
prelude::*,
@@ -5,25 +7,23 @@ use gtk::{
};
use once_cell::sync::Lazy;
-use std::cell::RefCell;
-
mod imp {
use super::*;
#[derive(Default)]
- pub struct MusicusActivatableRow {
+ pub struct ActivatableRow {
pub previous_parent: RefCell>,
pub previous_signal_handler_id: RefCell >,
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusActivatableRow {
+ impl ObjectSubclass for ActivatableRow {
const NAME: &'static str = "MusicusActivatableRow";
- type Type = super::MusicusActivatableRow;
+ type Type = super::ActivatableRow;
type ParentType = gtk::ListBoxRow;
}
- impl ObjectImpl for MusicusActivatableRow {
+ impl ObjectImpl for ActivatableRow {
fn constructed(&self) {
self.parent_constructed();
@@ -31,7 +31,7 @@ mod imp {
obj.connect_parent_notify(clone!(
#[weak]
obj,
- move |_: &super::MusicusActivatableRow| {
+ move |_: &super::ActivatableRow| {
let previous_parent = obj.imp().previous_parent.borrow_mut().take();
let previous_signal_handler_id =
obj.imp().previous_signal_handler_id.borrow_mut().take();
@@ -69,9 +69,9 @@ mod imp {
}
}
- impl WidgetImpl for MusicusActivatableRow {}
+ impl WidgetImpl for ActivatableRow {}
- impl ListBoxRowImpl for MusicusActivatableRow {
+ impl ListBoxRowImpl for ActivatableRow {
fn activate(&self) {
self.obj().emit_by_name::<()>("activated", &[]);
}
@@ -81,11 +81,11 @@ mod imp {
glib::wrapper! {
/// A simple helper widget for connecting a signal handler to a single [`gtk::ListBoxRow`] for
/// handling activation.
- pub struct MusicusActivatableRow(ObjectSubclass)
+ pub struct ActivatableRow(ObjectSubclass)
@extends gtk::Widget, gtk::ListBoxRow;
}
-impl MusicusActivatableRow {
+impl ActivatableRow {
pub fn new(child: &W) -> Self
where
W: IsA,
diff --git a/src/album_tile.rs b/src/album_tile.rs
index 4ddda14..73667cb 100644
--- a/src/album_tile.rs
+++ b/src/album_tile.rs
@@ -1,6 +1,7 @@
-use gtk::{glib, subclass::prelude::*};
use std::cell::OnceCell;
+use gtk::{glib, subclass::prelude::*};
+
use crate::db::models::Album;
mod imp {
@@ -8,7 +9,7 @@ mod imp {
#[derive(Debug, Default, gtk::CompositeTemplate)]
#[template(file = "data/ui/album_tile.blp")]
- pub struct MusicusAlbumTile {
+ pub struct AlbumTile {
pub album: OnceCell,
#[template_child]
@@ -16,9 +17,9 @@ mod imp {
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusAlbumTile {
+ impl ObjectSubclass for AlbumTile {
const NAME: &'static str = "MusicusAlbumTile";
- type Type = super::MusicusAlbumTile;
+ type Type = super::AlbumTile;
type ParentType = gtk::FlowBoxChild;
fn class_init(klass: &mut Self::Class) {
@@ -30,17 +31,17 @@ mod imp {
}
}
- impl ObjectImpl for MusicusAlbumTile {}
- impl WidgetImpl for MusicusAlbumTile {}
- impl FlowBoxChildImpl for MusicusAlbumTile {}
+ impl ObjectImpl for AlbumTile {}
+ impl WidgetImpl for AlbumTile {}
+ impl FlowBoxChildImpl for AlbumTile {}
}
glib::wrapper! {
- pub struct MusicusAlbumTile(ObjectSubclass)
+ pub struct AlbumTile(ObjectSubclass)
@extends gtk::Widget, gtk::FlowBoxChild;
}
-impl MusicusAlbumTile {
+impl AlbumTile {
pub fn new(album: &Album) -> Self {
let obj: Self = glib::Object::new();
diff --git a/src/application.rs b/src/application.rs
index ced6ddc..94c7704 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -2,22 +2,22 @@ use adw::{prelude::*, subclass::prelude::*};
use gettextrs::gettext;
use gtk::{gio, glib};
-use crate::{config, MusicusWindow};
+use crate::{config, Window};
mod imp {
use super::*;
#[derive(Debug, Default)]
- pub struct MusicusApplication {}
+ pub struct Application {}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusApplication {
+ impl ObjectSubclass for Application {
const NAME: &'static str = "MusicusApplication";
- type Type = super::MusicusApplication;
+ type Type = super::Application;
type ParentType = adw::Application;
}
- impl ObjectImpl for MusicusApplication {
+ impl ObjectImpl for Application {
fn constructed(&self) {
self.parent_constructed();
let obj = self.obj();
@@ -26,14 +26,14 @@ mod imp {
}
}
- impl ApplicationImpl for MusicusApplication {
+ impl ApplicationImpl for Application {
fn activate(&self) {
let application = self.obj();
let window = if let Some(window) = application.active_window() {
window
} else {
- let window = MusicusWindow::new(&*application);
+ let window = Window::new(&*application);
window.upcast()
};
@@ -41,17 +41,17 @@ mod imp {
}
}
- impl GtkApplicationImpl for MusicusApplication {}
- impl AdwApplicationImpl for MusicusApplication {}
+ impl GtkApplicationImpl for Application {}
+ impl AdwApplicationImpl for Application {}
}
glib::wrapper! {
- pub struct MusicusApplication(ObjectSubclass)
+ pub struct Application(ObjectSubclass)
@extends gio::Application, gtk::Application, adw::Application,
@implements gio::ActionGroup, gio::ActionMap;
}
-impl MusicusApplication {
+impl Application {
pub fn new() -> Self {
glib::Object::builder()
.property("application-id", config::APP_ID)
diff --git a/src/db/models.rs b/src/db/models.rs
index 46b5053..cf78dd7 100644
--- a/src/db/models.rs
+++ b/src/db/models.rs
@@ -6,12 +6,11 @@ use std::fmt::Display;
use anyhow::Result;
use diesel::prelude::*;
use gtk::glib::{self, Boxed};
-
-use super::{schema::*, tables, TranslatedString};
-
// Re-exports for tables that don't need additional information.
pub use tables::{Instrument, Person, Role};
+use super::{schema::*, tables, TranslatedString};
+
#[derive(Boxed, Clone, Debug)]
#[boxed_type(name = "MusicusWork")]
pub struct Work {
diff --git a/src/db/tables.rs b/src/db/tables.rs
index a9d6477..b631cdd 100644
--- a/src/db/tables.rs
+++ b/src/db/tables.rs
@@ -2,8 +2,7 @@
//! tables in the database schema.
use chrono::NaiveDateTime;
-use diesel::prelude::*;
-use diesel::sqlite::Sqlite;
+use diesel::{prelude::*, sqlite::Sqlite};
use gtk::glib::{self, Boxed};
use super::{schema::*, TranslatedString};
diff --git a/src/editor/album_editor.rs b/src/editor/album.rs
similarity index 88%
rename from src/editor/album_editor.rs
rename to src/editor/album.rs
index 27fc898..10bc244 100644
--- a/src/editor/album_editor.rs
+++ b/src/editor/album.rs
@@ -1,34 +1,28 @@
-use crate::{
- db::models::{Album, Recording},
- editor::{
- recording_editor::MusicusRecordingEditor,
- recording_selector_popover::RecordingSelectorPopover,
- translation_editor::MusicusTranslationEditor,
- },
- library::MusicusLibrary,
-};
+use std::cell::{OnceCell, RefCell};
use adw::{prelude::*, subclass::prelude::*};
use gettextrs::gettext;
-use gtk::glib::{
- clone, Properties,
- {self, subclass::Signal},
-};
+use gtk::glib::{self, clone, subclass::Signal, Properties};
use once_cell::sync::Lazy;
-use std::cell::{OnceCell, RefCell};
+use crate::{
+ db::models::{Album, Recording},
+ editor::{recording::RecordingEditor, translation::TranslationEditor},
+ library::Library,
+ selector::recording::RecordingSelectorPopover,
+};
mod imp {
use super::*;
#[derive(Debug, Default, gtk::CompositeTemplate, Properties)]
#[properties(wrapper_type = super::AlbumEditor)]
- #[template(file = "data/ui/album_editor.blp")]
+ #[template(file = "data/ui/editor/album.blp")]
pub struct AlbumEditor {
#[property(get, construct_only)]
pub navigation: OnceCell,
#[property(get, construct_only)]
- pub library: OnceCell,
+ pub library: OnceCell,
pub album_id: OnceCell,
pub recordings: RefCell>,
@@ -36,7 +30,7 @@ mod imp {
pub recordings_popover: OnceCell,
#[template_child]
- pub name_editor: TemplateChild,
+ pub name_editor: TemplateChild,
#[template_child]
pub recordings_list: TemplateChild,
#[template_child]
@@ -52,7 +46,7 @@ mod imp {
type ParentType = adw::NavigationPage;
fn class_init(klass: &mut Self::Class) {
- MusicusTranslationEditor::static_type();
+ TranslationEditor::static_type();
klass.bind_template();
klass.bind_template_instance_callbacks();
}
@@ -86,7 +80,7 @@ mod imp {
let obj = self.obj().clone();
recordings_popover.connect_create(move |_| {
- let editor = MusicusRecordingEditor::new(&obj.navigation(), &obj.library(), None);
+ let editor = RecordingEditor::new(&obj.navigation(), &obj.library(), None);
editor.connect_created(clone!(
#[weak]
@@ -115,11 +109,7 @@ glib::wrapper! {
#[gtk::template_callbacks]
impl AlbumEditor {
- pub fn new(
- navigation: &adw::NavigationView,
- library: &MusicusLibrary,
- album: Option<&Album>,
- ) -> Self {
+ pub fn new(navigation: &adw::NavigationView, library: &Library, album: Option<&Album>) -> Self {
let obj: Self = glib::Object::builder()
.property("navigation", navigation)
.property("library", library)
diff --git a/src/editor/ensemble_editor.rs b/src/editor/ensemble.rs
similarity index 77%
rename from src/editor/ensemble_editor.rs
rename to src/editor/ensemble.rs
index e74db5e..d7ce46f 100644
--- a/src/editor/ensemble_editor.rs
+++ b/src/editor/ensemble.rs
@@ -5,36 +5,33 @@ use gettextrs::gettext;
use gtk::glib::{self, subclass::Signal};
use once_cell::sync::Lazy;
-use crate::{
- db::models::Ensemble, editor::translation_editor::MusicusTranslationEditor,
- library::MusicusLibrary,
-};
+use crate::{db::models::Ensemble, editor::translation::TranslationEditor, library::Library};
mod imp {
use super::*;
#[derive(Debug, Default, gtk::CompositeTemplate)]
- #[template(file = "data/ui/ensemble_editor.blp")]
- pub struct MusicusEnsembleEditor {
+ #[template(file = "data/ui/editor/ensemble.blp")]
+ pub struct EnsembleEditor {
pub navigation: OnceCell,
- pub library: OnceCell,
+ pub library: OnceCell,
pub ensemble_id: OnceCell,
#[template_child]
- pub name_editor: TemplateChild,
+ pub name_editor: TemplateChild,
#[template_child]
pub save_row: TemplateChild,
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusEnsembleEditor {
+ impl ObjectSubclass for EnsembleEditor {
const NAME: &'static str = "MusicusEnsembleEditor";
- type Type = super::MusicusEnsembleEditor;
+ type Type = super::EnsembleEditor;
type ParentType = adw::NavigationPage;
fn class_init(klass: &mut Self::Class) {
- MusicusTranslationEditor::static_type();
+ TranslationEditor::static_type();
klass.bind_template();
klass.bind_template_instance_callbacks();
}
@@ -44,7 +41,7 @@ mod imp {
}
}
- impl ObjectImpl for MusicusEnsembleEditor {
+ impl ObjectImpl for EnsembleEditor {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy> = Lazy::new(|| {
vec![Signal::builder("created")
@@ -56,20 +53,20 @@ mod imp {
}
}
- impl WidgetImpl for MusicusEnsembleEditor {}
- impl NavigationPageImpl for MusicusEnsembleEditor {}
+ impl WidgetImpl for EnsembleEditor {}
+ impl NavigationPageImpl for EnsembleEditor {}
}
glib::wrapper! {
- pub struct MusicusEnsembleEditor(ObjectSubclass)
+ pub struct EnsembleEditor(ObjectSubclass)
@extends gtk::Widget, adw::NavigationPage;
}
#[gtk::template_callbacks]
-impl MusicusEnsembleEditor {
+impl EnsembleEditor {
pub fn new(
navigation: &adw::NavigationView,
- library: &MusicusLibrary,
+ library: &Library,
ensemble: Option<&Ensemble>,
) -> Self {
let obj: Self = glib::Object::new();
diff --git a/src/editor/instrument_editor.rs b/src/editor/instrument.rs
similarity index 77%
rename from src/editor/instrument_editor.rs
rename to src/editor/instrument.rs
index 4163bf0..3f0c561 100644
--- a/src/editor/instrument_editor.rs
+++ b/src/editor/instrument.rs
@@ -5,36 +5,33 @@ use gettextrs::gettext;
use gtk::glib::{self, subclass::Signal};
use once_cell::sync::Lazy;
-use crate::{
- db::models::Instrument, editor::translation_editor::MusicusTranslationEditor,
- library::MusicusLibrary,
-};
+use crate::{db::models::Instrument, editor::translation::TranslationEditor, library::Library};
mod imp {
use super::*;
#[derive(Debug, Default, gtk::CompositeTemplate)]
- #[template(file = "data/ui/instrument_editor.blp")]
- pub struct MusicusInstrumentEditor {
+ #[template(file = "data/ui/editor/instrument.blp")]
+ pub struct InstrumentEditor {
pub navigation: OnceCell,
- pub library: OnceCell,
+ pub library: OnceCell,
pub instrument_id: OnceCell,
#[template_child]
- pub name_editor: TemplateChild,
+ pub name_editor: TemplateChild,
#[template_child]
pub save_row: TemplateChild,
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusInstrumentEditor {
+ impl ObjectSubclass for InstrumentEditor {
const NAME: &'static str = "MusicusInstrumentEditor";
- type Type = super::MusicusInstrumentEditor;
+ type Type = super::InstrumentEditor;
type ParentType = adw::NavigationPage;
fn class_init(klass: &mut Self::Class) {
- MusicusTranslationEditor::static_type();
+ TranslationEditor::static_type();
klass.bind_template();
klass.bind_template_instance_callbacks();
}
@@ -44,7 +41,7 @@ mod imp {
}
}
- impl ObjectImpl for MusicusInstrumentEditor {
+ impl ObjectImpl for InstrumentEditor {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy> = Lazy::new(|| {
vec![Signal::builder("created")
@@ -56,20 +53,20 @@ mod imp {
}
}
- impl WidgetImpl for MusicusInstrumentEditor {}
- impl NavigationPageImpl for MusicusInstrumentEditor {}
+ impl WidgetImpl for InstrumentEditor {}
+ impl NavigationPageImpl for InstrumentEditor {}
}
glib::wrapper! {
- pub struct MusicusInstrumentEditor(ObjectSubclass)
+ pub struct InstrumentEditor(ObjectSubclass)
@extends gtk::Widget, adw::NavigationPage;
}
#[gtk::template_callbacks]
-impl MusicusInstrumentEditor {
+impl InstrumentEditor {
pub fn new(
navigation: &adw::NavigationView,
- library: &MusicusLibrary,
+ library: &Library,
instrument: Option<&Instrument>,
) -> Self {
let obj: Self = glib::Object::new();
diff --git a/src/editor/mod.rs b/src/editor/mod.rs
index 258ecb8..ff21b6a 100644
--- a/src/editor/mod.rs
+++ b/src/editor/mod.rs
@@ -1,24 +1,10 @@
-pub mod activatable_row;
-pub mod album_editor;
-pub mod ensemble_editor;
-pub mod ensemble_selector_popover;
-pub mod instrument_editor;
-pub mod instrument_selector_popover;
-pub mod performer_role_selector_popover;
-pub mod person_editor;
-pub mod person_selector_popover;
-pub mod recording_editor;
-pub mod recording_editor_ensemble_row;
-pub mod recording_editor_performer_row;
-pub mod recording_selector_popover;
-pub mod role_editor;
-pub mod role_selector_popover;
-pub mod tracks_editor;
-pub mod tracks_editor_parts_popover;
-pub mod tracks_editor_track_row;
-pub mod translation_editor;
+pub mod album;
+pub mod ensemble;
+pub mod instrument;
+pub mod person;
+pub mod recording;
+pub mod role;
+pub mod tracks;
+pub mod translation;
pub mod translation_entry;
-pub mod work_editor;
-pub mod work_editor_composer_row;
-pub mod work_editor_part_row;
-pub mod work_selector_popover;
+pub mod work;
diff --git a/src/editor/person_editor.rs b/src/editor/person.rs
similarity index 77%
rename from src/editor/person_editor.rs
rename to src/editor/person.rs
index 487c857..fbedb04 100644
--- a/src/editor/person_editor.rs
+++ b/src/editor/person.rs
@@ -5,36 +5,33 @@ use gettextrs::gettext;
use gtk::glib::{self, subclass::Signal};
use once_cell::sync::Lazy;
-use crate::{
- db::models::Person, editor::translation_editor::MusicusTranslationEditor,
- library::MusicusLibrary,
-};
+use crate::{db::models::Person, editor::translation::TranslationEditor, library::Library};
mod imp {
use super::*;
#[derive(Debug, Default, gtk::CompositeTemplate)]
- #[template(file = "data/ui/person_editor.blp")]
- pub struct MusicusPersonEditor {
+ #[template(file = "data/ui/editor/person.blp")]
+ pub struct PersonEditor {
pub navigation: OnceCell,
- pub library: OnceCell,
+ pub library: OnceCell,
pub person_id: OnceCell,
#[template_child]
- pub name_editor: TemplateChild,
+ pub name_editor: TemplateChild,
#[template_child]
pub save_row: TemplateChild,
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusPersonEditor {
+ impl ObjectSubclass for PersonEditor {
const NAME: &'static str = "MusicusPersonEditor";
- type Type = super::MusicusPersonEditor;
+ type Type = super::PersonEditor;
type ParentType = adw::NavigationPage;
fn class_init(klass: &mut Self::Class) {
- MusicusTranslationEditor::static_type();
+ TranslationEditor::static_type();
klass.bind_template();
klass.bind_template_instance_callbacks();
}
@@ -44,7 +41,7 @@ mod imp {
}
}
- impl ObjectImpl for MusicusPersonEditor {
+ impl ObjectImpl for PersonEditor {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy> = Lazy::new(|| {
vec![Signal::builder("created")
@@ -56,20 +53,20 @@ mod imp {
}
}
- impl WidgetImpl for MusicusPersonEditor {}
- impl NavigationPageImpl for MusicusPersonEditor {}
+ impl WidgetImpl for PersonEditor {}
+ impl NavigationPageImpl for PersonEditor {}
}
glib::wrapper! {
- pub struct MusicusPersonEditor(ObjectSubclass)
+ pub struct PersonEditor(ObjectSubclass)
@extends gtk::Widget, adw::NavigationPage;
}
#[gtk::template_callbacks]
-impl MusicusPersonEditor {
+impl PersonEditor {
pub fn new(
navigation: &adw::NavigationView,
- library: &MusicusLibrary,
+ library: &Library,
person: Option<&Person>,
) -> Self {
let obj: Self = glib::Object::new();
diff --git a/src/editor/recording_editor.rs b/src/editor/recording.rs
similarity index 80%
rename from src/editor/recording_editor.rs
rename to src/editor/recording.rs
index e3f9fd0..1065ae9 100644
--- a/src/editor/recording_editor.rs
+++ b/src/editor/recording.rs
@@ -1,47 +1,46 @@
+mod ensemble_row;
+mod performer_row;
+
use std::cell::{OnceCell, RefCell};
use adw::{prelude::*, subclass::prelude::*};
+use ensemble_row::RecordingEditorEnsembleRow;
use gettextrs::gettext;
use gtk::glib::{self, clone, subclass::Signal, Properties};
use once_cell::sync::Lazy;
+use performer_row::RecordingEditorPerformerRow;
use crate::{
db::models::{Ensemble, EnsemblePerformer, Performer, Person, Recording, Work},
- editor::{
- ensemble_editor::MusicusEnsembleEditor,
- ensemble_selector_popover::MusicusEnsembleSelectorPopover,
- person_editor::MusicusPersonEditor, person_selector_popover::MusicusPersonSelectorPopover,
- recording_editor_ensemble_row::MusicusRecordingEditorEnsembleRow,
- recording_editor_performer_row::MusicusRecordingEditorPerformerRow,
- work_selector_popover::MusicusWorkSelectorPopover,
+ editor::{ensemble::EnsembleEditor, person::PersonEditor, work::WorkEditor},
+ library::Library,
+ selector::{
+ ensemble::EnsembleSelectorPopover, person::PersonSelectorPopover, work::WorkSelectorPopover,
},
- library::MusicusLibrary,
};
mod imp {
- use crate::editor::work_editor::MusicusWorkEditor;
-
use super::*;
#[derive(Debug, Default, gtk::CompositeTemplate, Properties)]
- #[properties(wrapper_type = super::MusicusRecordingEditor)]
- #[template(file = "data/ui/recording_editor.blp")]
- pub struct MusicusRecordingEditor {
+ #[properties(wrapper_type = super::RecordingEditor)]
+ #[template(file = "data/ui/editor/recording.blp")]
+ pub struct RecordingEditor {
#[property(get, construct_only)]
pub navigation: OnceCell,
#[property(get, construct_only)]
- pub library: OnceCell,
+ pub library: OnceCell,
pub recording_id: OnceCell,
pub work: RefCell>,
- pub performer_rows: RefCell>,
- pub ensemble_rows: RefCell>,
+ pub performer_rows: RefCell>,
+ pub ensemble_rows: RefCell>,
- pub work_selector_popover: OnceCell,
- pub persons_popover: OnceCell,
- pub ensembles_popover: OnceCell,
+ pub work_selector_popover: OnceCell,
+ pub persons_popover: OnceCell,
+ pub ensembles_popover: OnceCell,
#[template_child]
pub work_row: TemplateChild,
@@ -62,9 +61,9 @@ mod imp {
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusRecordingEditor {
+ impl ObjectSubclass for RecordingEditor {
const NAME: &'static str = "MusicusRecordingEditor";
- type Type = super::MusicusRecordingEditor;
+ type Type = super::RecordingEditor;
type ParentType = adw::NavigationPage;
fn class_init(klass: &mut Self::Class) {
@@ -78,7 +77,7 @@ mod imp {
}
#[glib::derived_properties]
- impl ObjectImpl for MusicusRecordingEditor {
+ impl ObjectImpl for RecordingEditor {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy> = Lazy::new(|| {
vec![Signal::builder("created")
@@ -92,8 +91,7 @@ mod imp {
fn constructed(&self) {
self.parent_constructed();
- let work_selector_popover =
- MusicusWorkSelectorPopover::new(self.library.get().unwrap());
+ let work_selector_popover = WorkSelectorPopover::new(self.library.get().unwrap());
let obj = self.obj().clone();
work_selector_popover.connect_selected(move |_, work| {
@@ -102,7 +100,7 @@ mod imp {
let obj = self.obj().clone();
work_selector_popover.connect_create(move |_| {
- let editor = MusicusWorkEditor::new(&obj.navigation(), &obj.library(), None, false);
+ let editor = WorkEditor::new(&obj.navigation(), &obj.library(), None, false);
editor.connect_created(clone!(
#[weak]
@@ -120,7 +118,7 @@ mod imp {
.set(work_selector_popover)
.unwrap();
- let persons_popover = MusicusPersonSelectorPopover::new(self.library.get().unwrap());
+ let persons_popover = PersonSelectorPopover::new(self.library.get().unwrap());
let obj = self.obj().clone();
persons_popover.connect_person_selected(move |_, person| {
@@ -129,7 +127,7 @@ mod imp {
let obj = self.obj().clone();
persons_popover.connect_create(move |_| {
- let editor = MusicusPersonEditor::new(&obj.navigation(), &obj.library(), None);
+ let editor = PersonEditor::new(&obj.navigation(), &obj.library(), None);
editor.connect_created(clone!(
#[weak]
@@ -145,8 +143,7 @@ mod imp {
self.select_person_box.append(&persons_popover);
self.persons_popover.set(persons_popover).unwrap();
- let ensembles_popover =
- MusicusEnsembleSelectorPopover::new(self.library.get().unwrap());
+ let ensembles_popover = EnsembleSelectorPopover::new(self.library.get().unwrap());
let obj = self.obj().clone();
ensembles_popover.connect_ensemble_selected(move |_, ensemble| {
@@ -155,7 +152,7 @@ mod imp {
let obj = self.obj().clone();
ensembles_popover.connect_create(move |_| {
- let editor = MusicusEnsembleEditor::new(&obj.navigation(), &obj.library(), None);
+ let editor = EnsembleEditor::new(&obj.navigation(), &obj.library(), None);
editor.connect_created(clone!(
#[weak]
@@ -173,20 +170,20 @@ mod imp {
}
}
- impl WidgetImpl for MusicusRecordingEditor {}
- impl NavigationPageImpl for MusicusRecordingEditor {}
+ impl WidgetImpl for RecordingEditor {}
+ impl NavigationPageImpl for RecordingEditor {}
}
glib::wrapper! {
- pub struct MusicusRecordingEditor(ObjectSubclass)
+ pub struct RecordingEditor(ObjectSubclass)
@extends gtk::Widget, adw::NavigationPage;
}
#[gtk::template_callbacks]
-impl MusicusRecordingEditor {
+impl RecordingEditor {
pub fn new(
navigation: &adw::NavigationView,
- library: &MusicusLibrary,
+ library: &Library,
recording: Option<&Recording>,
) -> Self {
let obj: Self = glib::Object::builder()
@@ -267,8 +264,7 @@ impl MusicusRecordingEditor {
}
fn add_performer_row(&self, performer: Performer) {
- let row =
- MusicusRecordingEditorPerformerRow::new(&self.navigation(), &self.library(), performer);
+ let row = RecordingEditorPerformerRow::new(&self.navigation(), &self.library(), performer);
row.connect_remove(clone!(
#[weak(rename_to = this)]
@@ -296,7 +292,7 @@ impl MusicusRecordingEditor {
}
fn add_ensemble_row(&self, ensemble_performer: EnsemblePerformer) {
- let row = MusicusRecordingEditorEnsembleRow::new(
+ let row = RecordingEditorEnsembleRow::new(
&self.navigation(),
&self.library(),
ensemble_performer,
diff --git a/src/editor/recording_editor_ensemble_row.rs b/src/editor/recording/ensemble_row.rs
similarity index 74%
rename from src/editor/recording_editor_ensemble_row.rs
rename to src/editor/recording/ensemble_row.rs
index aed9b07..22f3b86 100644
--- a/src/editor/recording_editor_ensemble_row.rs
+++ b/src/editor/recording/ensemble_row.rs
@@ -5,26 +5,25 @@ use gtk::glib::{self, clone, subclass::Signal, Properties};
use once_cell::sync::Lazy;
use crate::{
- db::models::EnsemblePerformer,
- editor::{role_editor::MusicusRoleEditor, role_selector_popover::MusicusRoleSelectorPopover},
- library::MusicusLibrary,
+ db::models::EnsemblePerformer, editor::role::RoleEditor, library::Library,
+ selector::role::RoleSelectorPopover,
};
mod imp {
use super::*;
#[derive(Properties, Debug, Default, gtk::CompositeTemplate)]
- #[properties(wrapper_type = super::MusicusRecordingEditorEnsembleRow)]
- #[template(file = "data/ui/recording_editor_ensemble_row.blp")]
- pub struct MusicusRecordingEditorEnsembleRow {
+ #[properties(wrapper_type = super::RecordingEditorEnsembleRow)]
+ #[template(file = "data/ui/editor/recording/ensemble_row.blp")]
+ pub struct RecordingEditorEnsembleRow {
#[property(get, construct_only)]
pub navigation: OnceCell,
#[property(get, construct_only)]
- pub library: OnceCell,
+ pub library: OnceCell,
pub ensemble: RefCell>,
- pub role_popover: OnceCell,
+ pub role_popover: OnceCell,
#[template_child]
pub role_label: TemplateChild,
@@ -33,9 +32,9 @@ mod imp {
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusRecordingEditorEnsembleRow {
+ impl ObjectSubclass for RecordingEditorEnsembleRow {
const NAME: &'static str = "MusicusRecordingEditorEnsembleRow";
- type Type = super::MusicusRecordingEditorEnsembleRow;
+ type Type = super::RecordingEditorEnsembleRow;
type ParentType = adw::ActionRow;
fn class_init(klass: &mut Self::Class) {
@@ -49,7 +48,7 @@ mod imp {
}
#[glib::derived_properties]
- impl ObjectImpl for MusicusRecordingEditorEnsembleRow {
+ impl ObjectImpl for RecordingEditorEnsembleRow {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy> =
Lazy::new(|| vec![Signal::builder("remove").build()]);
@@ -60,7 +59,7 @@ mod imp {
fn constructed(&self) {
self.parent_constructed();
- let role_popover = MusicusRoleSelectorPopover::new(self.library.get().unwrap());
+ let role_popover = RoleSelectorPopover::new(self.library.get().unwrap());
let obj = self.obj().to_owned();
role_popover.connect_role_selected(move |_, role| {
@@ -72,7 +71,7 @@ mod imp {
let obj = self.obj().to_owned();
role_popover.connect_create(move |_| {
- let editor = MusicusRoleEditor::new(&obj.navigation(), &obj.library(), None);
+ let editor = RoleEditor::new(&obj.navigation(), &obj.library(), None);
editor.connect_created(clone!(
#[weak]
@@ -93,22 +92,22 @@ mod imp {
}
}
- impl WidgetImpl for MusicusRecordingEditorEnsembleRow {}
- impl ListBoxRowImpl for MusicusRecordingEditorEnsembleRow {}
- impl PreferencesRowImpl for MusicusRecordingEditorEnsembleRow {}
- impl ActionRowImpl for MusicusRecordingEditorEnsembleRow {}
+ impl WidgetImpl for RecordingEditorEnsembleRow {}
+ impl ListBoxRowImpl for RecordingEditorEnsembleRow {}
+ impl PreferencesRowImpl for RecordingEditorEnsembleRow {}
+ impl ActionRowImpl for RecordingEditorEnsembleRow {}
}
glib::wrapper! {
- pub struct MusicusRecordingEditorEnsembleRow(ObjectSubclass)
+ pub struct RecordingEditorEnsembleRow(ObjectSubclass)
@extends gtk::Widget, gtk::ListBoxRow, adw::PreferencesRow, adw::ActionRow;
}
#[gtk::template_callbacks]
-impl MusicusRecordingEditorEnsembleRow {
+impl RecordingEditorEnsembleRow {
pub fn new(
navigation: &adw::NavigationView,
- library: &MusicusLibrary,
+ library: &Library,
ensemble: EnsemblePerformer,
) -> Self {
let obj: Self = glib::Object::builder()
diff --git a/src/editor/recording_editor_performer_row.rs b/src/editor/recording/performer_row.rs
similarity index 74%
rename from src/editor/recording_editor_performer_row.rs
rename to src/editor/recording/performer_row.rs
index d25b249..0596df3 100644
--- a/src/editor/recording_editor_performer_row.rs
+++ b/src/editor/recording/performer_row.rs
@@ -5,31 +5,26 @@ use gtk::glib::{self, clone, subclass::Signal, Properties};
use once_cell::sync::Lazy;
use crate::{
- db::models::Performer,
- editor::{
- performer_role_selector_popover::MusicusPerformerRoleSelectorPopover,
- role_editor::MusicusRoleEditor,
- },
- library::MusicusLibrary,
+ db::models::Performer, editor::role::RoleEditor, library::Library,
+ selector::performer_role::PerformerRoleSelectorPopover,
};
mod imp {
- use crate::editor::instrument_editor::MusicusInstrumentEditor;
-
use super::*;
+ use crate::editor::instrument::InstrumentEditor;
#[derive(Properties, Debug, Default, gtk::CompositeTemplate)]
- #[properties(wrapper_type = super::MusicusRecordingEditorPerformerRow)]
- #[template(file = "data/ui/recording_editor_performer_row.blp")]
- pub struct MusicusRecordingEditorPerformerRow {
+ #[properties(wrapper_type = super::RecordingEditorPerformerRow)]
+ #[template(file = "data/ui/editor/recording/performer_row.blp")]
+ pub struct RecordingEditorPerformerRow {
#[property(get, construct_only)]
pub navigation: OnceCell,
#[property(get, construct_only)]
- pub library: OnceCell,
+ pub library: OnceCell,
pub performer: RefCell>,
- pub role_popover: OnceCell,
+ pub role_popover: OnceCell,
#[template_child]
pub role_label: TemplateChild,
@@ -38,9 +33,9 @@ mod imp {
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusRecordingEditorPerformerRow {
+ impl ObjectSubclass for RecordingEditorPerformerRow {
const NAME: &'static str = "MusicusRecordingEditorPerformerRow";
- type Type = super::MusicusRecordingEditorPerformerRow;
+ type Type = super::RecordingEditorPerformerRow;
type ParentType = adw::ActionRow;
fn class_init(klass: &mut Self::Class) {
@@ -54,7 +49,7 @@ mod imp {
}
#[glib::derived_properties]
- impl ObjectImpl for MusicusRecordingEditorPerformerRow {
+ impl ObjectImpl for RecordingEditorPerformerRow {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy> =
Lazy::new(|| vec![Signal::builder("remove").build()]);
@@ -65,8 +60,7 @@ mod imp {
fn constructed(&self) {
self.parent_constructed();
- let role_popover =
- MusicusPerformerRoleSelectorPopover::new(self.library.get().unwrap());
+ let role_popover = PerformerRoleSelectorPopover::new(self.library.get().unwrap());
let obj = self.obj().to_owned();
role_popover.connect_selected(move |_, role, instrument| {
@@ -85,7 +79,7 @@ mod imp {
let obj = self.obj().to_owned();
role_popover.connect_create_role(move |_| {
- let editor = MusicusRoleEditor::new(&obj.navigation(), &obj.library(), None);
+ let editor = RoleEditor::new(&obj.navigation(), &obj.library(), None);
editor.connect_created(clone!(
#[weak]
@@ -104,7 +98,7 @@ mod imp {
let obj = self.obj().to_owned();
role_popover.connect_create_instrument(move |_| {
- let editor = MusicusInstrumentEditor::new(&obj.navigation(), &obj.library(), None);
+ let editor = InstrumentEditor::new(&obj.navigation(), &obj.library(), None);
editor.connect_created(clone!(
#[weak]
@@ -126,24 +120,20 @@ mod imp {
}
}
- impl WidgetImpl for MusicusRecordingEditorPerformerRow {}
- impl ListBoxRowImpl for MusicusRecordingEditorPerformerRow {}
- impl PreferencesRowImpl for MusicusRecordingEditorPerformerRow {}
- impl ActionRowImpl for MusicusRecordingEditorPerformerRow {}
+ impl WidgetImpl for RecordingEditorPerformerRow {}
+ impl ListBoxRowImpl for RecordingEditorPerformerRow {}
+ impl PreferencesRowImpl for RecordingEditorPerformerRow {}
+ impl ActionRowImpl for RecordingEditorPerformerRow {}
}
glib::wrapper! {
- pub struct MusicusRecordingEditorPerformerRow(ObjectSubclass)
+ pub struct RecordingEditorPerformerRow(ObjectSubclass)
@extends gtk::Widget, gtk::ListBoxRow, adw::PreferencesRow, adw::ActionRow;
}
#[gtk::template_callbacks]
-impl MusicusRecordingEditorPerformerRow {
- pub fn new(
- navigation: &adw::NavigationView,
- library: &MusicusLibrary,
- performer: Performer,
- ) -> Self {
+impl RecordingEditorPerformerRow {
+ pub fn new(navigation: &adw::NavigationView, library: &Library, performer: Performer) -> Self {
let obj: Self = glib::Object::builder()
.property("navigation", navigation)
.property("library", library)
diff --git a/src/editor/role_editor.rs b/src/editor/role.rs
similarity index 74%
rename from src/editor/role_editor.rs
rename to src/editor/role.rs
index 6197635..0269ed8 100644
--- a/src/editor/role_editor.rs
+++ b/src/editor/role.rs
@@ -5,34 +5,32 @@ use gettextrs::gettext;
use gtk::glib::{self, subclass::Signal};
use once_cell::sync::Lazy;
-use crate::{
- db::models::Role, editor::translation_editor::MusicusTranslationEditor, library::MusicusLibrary,
-};
+use crate::{db::models::Role, editor::translation::TranslationEditor, library::Library};
mod imp {
use super::*;
#[derive(Debug, Default, gtk::CompositeTemplate)]
- #[template(file = "data/ui/role_editor.blp")]
- pub struct MusicusRoleEditor {
+ #[template(file = "data/ui/editor/role.blp")]
+ pub struct RoleEditor {
pub navigation: OnceCell,
- pub library: OnceCell,
+ pub library: OnceCell,
pub role_id: OnceCell,
#[template_child]
- pub name_editor: TemplateChild,
+ pub name_editor: TemplateChild,
#[template_child]
pub save_row: TemplateChild,
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusRoleEditor {
+ impl ObjectSubclass for RoleEditor {
const NAME: &'static str = "MusicusRoleEditor";
- type Type = super::MusicusRoleEditor;
+ type Type = super::RoleEditor;
type ParentType = adw::NavigationPage;
fn class_init(klass: &mut Self::Class) {
- MusicusTranslationEditor::static_type();
+ TranslationEditor::static_type();
klass.bind_template();
klass.bind_template_instance_callbacks();
}
@@ -42,7 +40,7 @@ mod imp {
}
}
- impl ObjectImpl for MusicusRoleEditor {
+ impl ObjectImpl for RoleEditor {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy> = Lazy::new(|| {
vec![Signal::builder("created")
@@ -54,22 +52,18 @@ mod imp {
}
}
- impl WidgetImpl for MusicusRoleEditor {}
- impl NavigationPageImpl for MusicusRoleEditor {}
+ impl WidgetImpl for RoleEditor {}
+ impl NavigationPageImpl for RoleEditor {}
}
glib::wrapper! {
- pub struct MusicusRoleEditor(ObjectSubclass)
+ pub struct RoleEditor(ObjectSubclass)
@extends gtk::Widget, adw::NavigationPage;
}
#[gtk::template_callbacks]
-impl MusicusRoleEditor {
- pub fn new(
- navigation: &adw::NavigationView,
- library: &MusicusLibrary,
- role: Option<&Role>,
- ) -> Self {
+impl RoleEditor {
+ pub fn new(navigation: &adw::NavigationView, library: &Library, role: Option<&Role>) -> Self {
let obj: Self = glib::Object::new();
obj.imp().navigation.set(navigation.to_owned()).unwrap();
diff --git a/src/editor/tracks_editor.rs b/src/editor/tracks.rs
similarity index 94%
rename from src/editor/tracks_editor.rs
rename to src/editor/tracks.rs
index 0debd40..832f3e2 100644
--- a/src/editor/tracks_editor.rs
+++ b/src/editor/tracks.rs
@@ -1,12 +1,9 @@
-use super::tracks_editor_track_row::{TrackLocation, TracksEditorTrackData};
-use crate::{
- db::models::{Recording, Track, Work},
- editor::{
- recording_editor::MusicusRecordingEditor,
- recording_selector_popover::RecordingSelectorPopover,
- tracks_editor_track_row::TracksEditorTrackRow,
- },
- library::MusicusLibrary,
+mod parts_popover;
+mod track_row;
+
+use std::{
+ cell::{OnceCell, RefCell},
+ path::PathBuf,
};
use adw::{prelude::*, subclass::prelude::*};
@@ -16,10 +13,13 @@ use gtk::{
glib::{self, clone, subclass::Signal, Properties},
};
use once_cell::sync::Lazy;
+use track_row::{TrackLocation, TracksEditorTrackData, TracksEditorTrackRow};
-use std::{
- cell::{OnceCell, RefCell},
- path::PathBuf,
+use crate::{
+ db::models::{Recording, Track, Work},
+ editor::recording::RecordingEditor,
+ library::Library,
+ selector::recording::RecordingSelectorPopover,
};
mod imp {
@@ -27,12 +27,12 @@ mod imp {
#[derive(Debug, Default, gtk::CompositeTemplate, Properties)]
#[properties(wrapper_type = super::TracksEditor)]
- #[template(file = "data/ui/tracks_editor.blp")]
+ #[template(file = "data/ui/editor/tracks.blp")]
pub struct TracksEditor {
#[property(get, construct_only)]
pub navigation: OnceCell,
#[property(get, construct_only)]
- pub library: OnceCell,
+ pub library: OnceCell,
pub recording: RefCell>,
pub recordings_popover: OnceCell,
@@ -91,11 +91,8 @@ mod imp {
let obj = self.obj().clone();
recordings_popover.connect_create(move |_| {
- let editor = MusicusRecordingEditor::new(
- obj.imp().navigation.get().unwrap(),
- &obj.library(),
- None,
- );
+ let editor =
+ RecordingEditor::new(obj.imp().navigation.get().unwrap(), &obj.library(), None);
editor.connect_created(clone!(
#[weak]
@@ -135,7 +132,7 @@ glib::wrapper! {
impl TracksEditor {
pub fn new(
navigation: &adw::NavigationView,
- library: &MusicusLibrary,
+ library: &Library,
recording: Option,
) -> Self {
let obj: Self = glib::Object::builder()
diff --git a/src/editor/tracks_editor_parts_popover.rs b/src/editor/tracks/parts_popover.rs
similarity index 86%
rename from src/editor/tracks_editor_parts_popover.rs
rename to src/editor/tracks/parts_popover.rs
index 2f6fddd..0a42b1c 100644
--- a/src/editor/tracks_editor_parts_popover.rs
+++ b/src/editor/tracks/parts_popover.rs
@@ -1,5 +1,4 @@
-use super::activatable_row::MusicusActivatableRow;
-use crate::db::models::Work;
+use std::cell::{OnceCell, RefCell};
use gtk::{
glib::{self, subclass::Signal},
@@ -8,13 +7,13 @@ use gtk::{
};
use once_cell::sync::Lazy;
-use std::cell::{OnceCell, RefCell};
+use crate::{activatable_row::ActivatableRow, db::models::Work};
mod imp {
use super::*;
#[derive(Debug, Default, gtk::CompositeTemplate)]
- #[template(file = "data/ui/tracks_editor_parts_popover.blp")]
+ #[template(file = "data/ui/editor/tracks/parts_popover.blp")]
pub struct TracksEditorPartsPopover {
pub parts: OnceCell>,
pub parts_filtered: RefCell>,
@@ -47,14 +46,13 @@ mod imp {
fn constructed(&self) {
self.parent_constructed();
- self.obj()
- .connect_visible_notify(|obj: &super::TracksEditorPartsPopover| {
- if obj.is_visible() {
- obj.imp().search_entry.set_text("");
- obj.imp().search_entry.grab_focus();
- obj.imp().scrolled_window.vadjustment().set_value(0.0);
- }
- });
+ self.obj().connect_visible_notify(|obj| {
+ if obj.is_visible() {
+ obj.imp().search_entry.set_text("");
+ obj.imp().search_entry.grab_focus();
+ obj.imp().scrolled_window.vadjustment().set_value(0.0);
+ }
+ });
}
fn signals() -> &'static [Signal] {
@@ -143,7 +141,7 @@ impl TracksEditorPartsPopover {
imp.list_box.remove_all();
for part in &parts_filtered {
- let row = MusicusActivatableRow::new(
+ let row = ActivatableRow::new(
>k::Label::builder()
.label(part.to_string())
.halign(gtk::Align::Start)
@@ -154,7 +152,7 @@ impl TracksEditorPartsPopover {
let part = part.clone();
let obj = self.clone();
- row.connect_activated(move |_: &MusicusActivatableRow| {
+ row.connect_activated(move |_: &ActivatableRow| {
obj.select(part.clone());
});
diff --git a/src/editor/tracks_editor_track_row.rs b/src/editor/tracks/track_row.rs
similarity index 95%
rename from src/editor/tracks_editor_track_row.rs
rename to src/editor/tracks/track_row.rs
index 60125b1..8579d07 100644
--- a/src/editor/tracks_editor_track_row.rs
+++ b/src/editor/tracks/track_row.rs
@@ -1,7 +1,6 @@
-use crate::{
- db::models::{Recording, Track, Work},
- editor::tracks_editor_parts_popover::TracksEditorPartsPopover,
- library::MusicusLibrary,
+use std::{
+ cell::{OnceCell, RefCell},
+ path::PathBuf,
};
use adw::{prelude::*, subclass::prelude::*};
@@ -10,9 +9,10 @@ use gettextrs::gettext;
use gtk::glib::{self, clone, subclass::Signal, Properties};
use once_cell::sync::Lazy;
-use std::{
- cell::{OnceCell, RefCell},
- path::PathBuf,
+use super::parts_popover::TracksEditorPartsPopover;
+use crate::{
+ db::models::{Recording, Track, Work},
+ library::Library,
};
mod imp {
@@ -20,12 +20,12 @@ mod imp {
#[derive(Properties, Debug, Default, gtk::CompositeTemplate)]
#[properties(wrapper_type = super::TracksEditorTrackRow)]
- #[template(file = "data/ui/tracks_editor_track_row.blp")]
+ #[template(file = "data/ui/editor/tracks/track_row.blp")]
pub struct TracksEditorTrackRow {
#[property(get, construct_only)]
pub navigation: OnceCell,
#[property(get, construct_only)]
- pub library: OnceCell,
+ pub library: OnceCell,
pub recording: OnceCell,
pub track_data: RefCell,
@@ -79,7 +79,7 @@ glib::wrapper! {
impl TracksEditorTrackRow {
pub fn new(
navigation: &adw::NavigationView,
- library: &MusicusLibrary,
+ library: &Library,
recording: Recording,
track_data: TracksEditorTrackData,
) -> Self {
diff --git a/src/editor/translation_editor.rs b/src/editor/translation.rs
similarity index 75%
rename from src/editor/translation_editor.rs
rename to src/editor/translation.rs
index 4911c45..65fb0a5 100644
--- a/src/editor/translation_editor.rs
+++ b/src/editor/translation.rs
@@ -1,31 +1,28 @@
-use std::cell::RefCell;
-use std::collections::HashMap;
+use std::{cell::RefCell, collections::HashMap};
use adw::{prelude::*, subclass::prelude::*};
use gtk::glib;
-use crate::db::TranslatedString;
-use crate::editor::translation_entry::MusicusTranslationEntry;
-use crate::util;
+use crate::{db::TranslatedString, editor::translation_entry::TranslationEntry, util};
mod imp {
use super::*;
#[derive(Debug, Default, gtk::CompositeTemplate)]
- #[template(file = "data/ui/translation_editor.blp")]
- pub struct MusicusTranslationEditor {
+ #[template(file = "data/ui/editor/translation.blp")]
+ pub struct TranslationEditor {
#[template_child]
pub list_box: TemplateChild,
#[template_child]
pub entry_row: TemplateChild,
- pub translation_entries: RefCell>,
+ pub translation_entries: RefCell>,
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusTranslationEditor {
+ impl ObjectSubclass for TranslationEditor {
const NAME: &'static str = "MusicusTranslationEditor";
- type Type = super::MusicusTranslationEditor;
+ type Type = super::TranslationEditor;
type ParentType = adw::Bin;
fn class_init(klass: &mut Self::Class) {
@@ -38,23 +35,23 @@ mod imp {
}
}
- impl ObjectImpl for MusicusTranslationEditor {
+ impl ObjectImpl for TranslationEditor {
fn constructed(&self) {
self.parent_constructed();
}
}
- impl WidgetImpl for MusicusTranslationEditor {}
- impl BinImpl for MusicusTranslationEditor {}
+ impl WidgetImpl for TranslationEditor {}
+ impl BinImpl for TranslationEditor {}
}
glib::wrapper! {
- pub struct MusicusTranslationEditor(ObjectSubclass)
+ pub struct TranslationEditor(ObjectSubclass)
@extends gtk::Widget, adw::PreferencesGroup;
}
#[gtk::template_callbacks]
-impl MusicusTranslationEditor {
+impl TranslationEditor {
pub fn new() -> Self {
glib::Object::new()
}
@@ -89,7 +86,7 @@ impl MusicusTranslationEditor {
}
fn add_entry(&self, lang: &str, translation: &str) {
- let entry = MusicusTranslationEntry::new(lang, translation);
+ let entry = TranslationEntry::new(lang, translation);
let obj = self.clone();
entry.connect_remove(move |entry| {
diff --git a/src/editor/translation_entry.rs b/src/editor/translation_entry.rs
index f2741a6..a5a1a46 100644
--- a/src/editor/translation_entry.rs
+++ b/src/editor/translation_entry.rs
@@ -6,8 +6,8 @@ mod imp {
use super::*;
#[derive(Debug, Default, gtk::CompositeTemplate)]
- #[template(file = "data/ui/translation_entry.blp")]
- pub struct MusicusTranslationEntry {
+ #[template(file = "data/ui/editor/translation_entry.blp")]
+ pub struct TranslationEntry {
#[template_child]
pub lang_popover: TemplateChild,
#[template_child]
@@ -15,9 +15,9 @@ mod imp {
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusTranslationEntry {
+ impl ObjectSubclass for TranslationEntry {
const NAME: &'static str = "MusicusTranslationEntry";
- type Type = super::MusicusTranslationEntry;
+ type Type = super::TranslationEntry;
type ParentType = adw::EntryRow;
fn class_init(klass: &mut Self::Class) {
@@ -30,7 +30,7 @@ mod imp {
}
}
- impl ObjectImpl for MusicusTranslationEntry {
+ impl ObjectImpl for TranslationEntry {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy> =
Lazy::new(|| vec![Signal::builder("remove").build()]);
@@ -43,21 +43,21 @@ mod imp {
}
}
- impl WidgetImpl for MusicusTranslationEntry {}
- impl ListBoxRowImpl for MusicusTranslationEntry {}
- impl PreferencesRowImpl for MusicusTranslationEntry {}
- impl EntryRowImpl for MusicusTranslationEntry {}
- impl EditableImpl for MusicusTranslationEntry {}
+ impl WidgetImpl for TranslationEntry {}
+ impl ListBoxRowImpl for TranslationEntry {}
+ impl PreferencesRowImpl for TranslationEntry {}
+ impl EntryRowImpl for TranslationEntry {}
+ impl EditableImpl for TranslationEntry {}
}
glib::wrapper! {
- pub struct MusicusTranslationEntry(ObjectSubclass)
+ pub struct TranslationEntry(ObjectSubclass)
@extends gtk::Widget, gtk::ListBoxRow, adw::PreferencesRow, adw::EntryRow,
@implements gtk::Editable;
}
#[gtk::template_callbacks]
-impl MusicusTranslationEntry {
+impl TranslationEntry {
pub fn new(lang: &str, translation: &str) -> Self {
let obj: Self = glib::Object::new();
obj.set_text(translation);
diff --git a/src/editor/work_editor.rs b/src/editor/work.rs
similarity index 81%
rename from src/editor/work_editor.rs
rename to src/editor/work.rs
index 102ea4b..3876c61 100644
--- a/src/editor/work_editor.rs
+++ b/src/editor/work.rs
@@ -1,41 +1,37 @@
+mod composer_row;
+mod part_row;
+
+use std::cell::{Cell, OnceCell, RefCell};
+
+use adw::{prelude::*, subclass::prelude::*};
+use composer_row::WorkEditorComposerRow;
+use gettextrs::gettext;
+use gtk::glib::{self, clone, subclass::Signal, Properties};
+use once_cell::sync::Lazy;
+use part_row::WorkEditorPartRow;
+
use crate::{
db::{
self,
models::{Composer, Instrument, Person, Work},
},
- editor::{
- instrument_editor::MusicusInstrumentEditor,
- instrument_selector_popover::MusicusInstrumentSelectorPopover,
- person_editor::MusicusPersonEditor, person_selector_popover::MusicusPersonSelectorPopover,
- translation_editor::MusicusTranslationEditor,
- work_editor_composer_row::MusicusWorkEditorComposerRow,
- work_editor_part_row::MusicusWorkEditorPartRow,
- },
- library::MusicusLibrary,
+ editor::{instrument::InstrumentEditor, person::PersonEditor, translation::TranslationEditor},
+ library::Library,
+ selector::{instrument::InstrumentSelectorPopover, person::PersonSelectorPopover},
};
-use adw::{prelude::*, subclass::prelude::*};
-use gettextrs::gettext;
-use gtk::glib::{
- clone, Properties,
- {self, subclass::Signal},
-};
-use once_cell::sync::Lazy;
-
-use std::cell::{Cell, OnceCell, RefCell};
-
mod imp {
use super::*;
#[derive(Debug, Default, gtk::CompositeTemplate, Properties)]
- #[properties(wrapper_type = super::MusicusWorkEditor)]
- #[template(file = "data/ui/work_editor.blp")]
- pub struct MusicusWorkEditor {
+ #[properties(wrapper_type = super::WorkEditor)]
+ #[template(file = "data/ui/editor/work.blp")]
+ pub struct WorkEditor {
#[property(get, construct_only)]
pub navigation: OnceCell,
#[property(get, construct_only)]
- pub library: OnceCell,
+ pub library: OnceCell,
pub work_id: OnceCell,
pub is_part_editor: Cell,
@@ -43,16 +39,16 @@ mod imp {
// Holding a reference to each composer row is the simplest way to enumerate all
// results when finishing the process of editing the work. The composer rows
// handle all state related to the composer.
- pub composer_rows: RefCell>,
- pub part_rows: RefCell>,
+ pub composer_rows: RefCell>,
+ pub part_rows: RefCell>,
pub instruments: RefCell>,
- pub persons_popover: OnceCell,
- pub instruments_popover: OnceCell,
+ pub persons_popover: OnceCell,
+ pub instruments_popover: OnceCell,
#[template_child]
- pub name_editor: TemplateChild,
+ pub name_editor: TemplateChild,
#[template_child]
pub composer_list: TemplateChild,
#[template_child]
@@ -68,13 +64,13 @@ mod imp {
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusWorkEditor {
+ impl ObjectSubclass for WorkEditor {
const NAME: &'static str = "MusicusWorkEditor";
- type Type = super::MusicusWorkEditor;
+ type Type = super::WorkEditor;
type ParentType = adw::NavigationPage;
fn class_init(klass: &mut Self::Class) {
- MusicusTranslationEditor::static_type();
+ TranslationEditor::static_type();
klass.bind_template();
klass.bind_template_instance_callbacks();
}
@@ -85,7 +81,7 @@ mod imp {
}
#[glib::derived_properties]
- impl ObjectImpl for MusicusWorkEditor {
+ impl ObjectImpl for WorkEditor {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy> = Lazy::new(|| {
vec![Signal::builder("created")
@@ -99,7 +95,7 @@ mod imp {
fn constructed(&self) {
self.parent_constructed();
- let persons_popover = MusicusPersonSelectorPopover::new(self.library.get().unwrap());
+ let persons_popover = PersonSelectorPopover::new(self.library.get().unwrap());
let obj = self.obj().clone();
persons_popover.connect_person_selected(move |_, person| {
@@ -108,7 +104,7 @@ mod imp {
let obj = self.obj().clone();
persons_popover.connect_create(move |_| {
- let editor = MusicusPersonEditor::new(&obj.navigation(), &obj.library(), None);
+ let editor = PersonEditor::new(&obj.navigation(), &obj.library(), None);
editor.connect_created(clone!(
#[weak]
@@ -124,8 +120,7 @@ mod imp {
self.select_person_box.append(&persons_popover);
self.persons_popover.set(persons_popover).unwrap();
- let instruments_popover =
- MusicusInstrumentSelectorPopover::new(self.library.get().unwrap());
+ let instruments_popover = InstrumentSelectorPopover::new(self.library.get().unwrap());
let obj = self.obj().clone();
instruments_popover.connect_instrument_selected(move |_, instrument| {
@@ -134,7 +129,7 @@ mod imp {
let obj = self.obj().clone();
instruments_popover.connect_create(move |_| {
- let editor = MusicusInstrumentEditor::new(&obj.navigation(), &obj.library(), None);
+ let editor = InstrumentEditor::new(&obj.navigation(), &obj.library(), None);
editor.connect_created(clone!(
#[weak]
@@ -152,20 +147,20 @@ mod imp {
}
}
- impl WidgetImpl for MusicusWorkEditor {}
- impl NavigationPageImpl for MusicusWorkEditor {}
+ impl WidgetImpl for WorkEditor {}
+ impl NavigationPageImpl for WorkEditor {}
}
glib::wrapper! {
- pub struct MusicusWorkEditor(ObjectSubclass)
+ pub struct WorkEditor(ObjectSubclass)
@extends gtk::Widget, adw::NavigationPage;
}
#[gtk::template_callbacks]
-impl MusicusWorkEditor {
+impl WorkEditor {
pub fn new(
navigation: &adw::NavigationView,
- library: &MusicusLibrary,
+ library: &Library,
work: Option<&Work>,
is_part_editor: bool,
) -> Self {
@@ -218,7 +213,7 @@ impl MusicusWorkEditor {
#[template_callback]
fn add_part(&self) {
- let editor = MusicusWorkEditor::new(&self.navigation(), &self.library(), None, true);
+ let editor = WorkEditor::new(&self.navigation(), &self.library(), None, true);
editor.connect_created(clone!(
#[weak(rename_to = this)]
@@ -243,7 +238,7 @@ impl MusicusWorkEditor {
}
fn add_part_row(&self, part: Work) {
- let row = MusicusWorkEditorPartRow::new(&self.navigation(), &self.library(), part);
+ let row = WorkEditorPartRow::new(&self.navigation(), &self.library(), part);
row.connect_remove(clone!(
#[weak(rename_to = this)]
@@ -262,7 +257,7 @@ impl MusicusWorkEditor {
}
fn add_composer_row(&self, composer: Composer) {
- let row = MusicusWorkEditorComposerRow::new(&self.navigation(), &self.library(), composer);
+ let row = WorkEditorComposerRow::new(&self.navigation(), &self.library(), composer);
row.connect_remove(clone!(
#[weak(rename_to = this)]
diff --git a/src/editor/work_editor_composer_row.rs b/src/editor/work/composer_row.rs
similarity index 73%
rename from src/editor/work_editor_composer_row.rs
rename to src/editor/work/composer_row.rs
index d3fef1a..cd05ca9 100644
--- a/src/editor/work_editor_composer_row.rs
+++ b/src/editor/work/composer_row.rs
@@ -5,26 +5,25 @@ use gtk::glib::{self, clone, subclass::Signal, Properties};
use once_cell::sync::Lazy;
use crate::{
- db::models::Composer,
- editor::{role_editor::MusicusRoleEditor, role_selector_popover::MusicusRoleSelectorPopover},
- library::MusicusLibrary,
+ db::models::Composer, editor::role::RoleEditor, library::Library,
+ selector::role::RoleSelectorPopover,
};
mod imp {
use super::*;
#[derive(Properties, Debug, Default, gtk::CompositeTemplate)]
- #[properties(wrapper_type = super::MusicusWorkEditorComposerRow)]
- #[template(file = "data/ui/work_editor_composer_row.blp")]
- pub struct MusicusWorkEditorComposerRow {
+ #[properties(wrapper_type = super::WorkEditorComposerRow)]
+ #[template(file = "data/ui/editor/work/composer_row.blp")]
+ pub struct WorkEditorComposerRow {
#[property(get, construct_only)]
pub navigation: OnceCell,
#[property(get, construct_only)]
- pub library: OnceCell,
+ pub library: OnceCell,
pub composer: RefCell>,
- pub role_popover: OnceCell,
+ pub role_popover: OnceCell,
#[template_child]
pub role_label: TemplateChild,
@@ -33,9 +32,9 @@ mod imp {
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusWorkEditorComposerRow {
+ impl ObjectSubclass for WorkEditorComposerRow {
const NAME: &'static str = "MusicusWorkEditorComposerRow";
- type Type = super::MusicusWorkEditorComposerRow;
+ type Type = super::WorkEditorComposerRow;
type ParentType = adw::ActionRow;
fn class_init(klass: &mut Self::Class) {
@@ -49,7 +48,7 @@ mod imp {
}
#[glib::derived_properties]
- impl ObjectImpl for MusicusWorkEditorComposerRow {
+ impl ObjectImpl for WorkEditorComposerRow {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy> =
Lazy::new(|| vec![Signal::builder("remove").build()]);
@@ -60,7 +59,7 @@ mod imp {
fn constructed(&self) {
self.parent_constructed();
- let role_popover = MusicusRoleSelectorPopover::new(self.library.get().unwrap());
+ let role_popover = RoleSelectorPopover::new(self.library.get().unwrap());
let obj = self.obj().to_owned();
role_popover.connect_role_selected(move |_, role| {
@@ -72,7 +71,7 @@ mod imp {
let obj = self.obj().to_owned();
role_popover.connect_create(move |_| {
- let editor = MusicusRoleEditor::new(&obj.navigation(), &obj.library(), None);
+ let editor = RoleEditor::new(&obj.navigation(), &obj.library(), None);
editor.connect_created(clone!(
#[weak]
@@ -93,24 +92,20 @@ mod imp {
}
}
- impl WidgetImpl for MusicusWorkEditorComposerRow {}
- impl ListBoxRowImpl for MusicusWorkEditorComposerRow {}
- impl PreferencesRowImpl for MusicusWorkEditorComposerRow {}
- impl ActionRowImpl for MusicusWorkEditorComposerRow {}
+ impl WidgetImpl for WorkEditorComposerRow {}
+ impl ListBoxRowImpl for WorkEditorComposerRow {}
+ impl PreferencesRowImpl for WorkEditorComposerRow {}
+ impl ActionRowImpl for WorkEditorComposerRow {}
}
glib::wrapper! {
- pub struct MusicusWorkEditorComposerRow(ObjectSubclass)
+ pub struct WorkEditorComposerRow(ObjectSubclass)
@extends gtk::Widget, gtk::ListBoxRow, adw::PreferencesRow, adw::ActionRow;
}
#[gtk::template_callbacks]
-impl MusicusWorkEditorComposerRow {
- pub fn new(
- navigation: &adw::NavigationView,
- library: &MusicusLibrary,
- composer: Composer,
- ) -> Self {
+impl WorkEditorComposerRow {
+ pub fn new(navigation: &adw::NavigationView, library: &Library, composer: Composer) -> Self {
let obj: Self = glib::Object::builder()
.property("navigation", navigation)
.property("library", library)
diff --git a/src/editor/work_editor_part_row.rs b/src/editor/work/part_row.rs
similarity index 74%
rename from src/editor/work_editor_part_row.rs
rename to src/editor/work/part_row.rs
index 21ddf2e..6c51c5d 100644
--- a/src/editor/work_editor_part_row.rs
+++ b/src/editor/work/part_row.rs
@@ -1,32 +1,32 @@
-use crate::{db::models::Work, editor::work_editor::MusicusWorkEditor, library::MusicusLibrary};
+use std::cell::{OnceCell, RefCell};
use adw::{prelude::*, subclass::prelude::*};
use gtk::glib::{self, clone, subclass::Signal, Properties};
use once_cell::sync::Lazy;
-use std::cell::{OnceCell, RefCell};
+use crate::{db::models::Work, editor::work::WorkEditor, library::Library};
mod imp {
use super::*;
#[derive(Properties, Debug, Default, gtk::CompositeTemplate)]
- #[properties(wrapper_type = super::MusicusWorkEditorPartRow)]
- #[template(file = "data/ui/work_editor_part_row.blp")]
- pub struct MusicusWorkEditorPartRow {
+ #[properties(wrapper_type = super::WorkEditorPartRow)]
+ #[template(file = "data/ui/editor/work/part_row.blp")]
+ pub struct WorkEditorPartRow {
#[property(get, construct_only)]
pub navigation: OnceCell,
#[property(get, construct_only)]
- pub library: OnceCell,
+ pub library: OnceCell,
pub part: RefCell>,
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusWorkEditorPartRow {
+ impl ObjectSubclass for WorkEditorPartRow {
const NAME: &'static str = "MusicusWorkEditorPartRow";
- type Type = super::MusicusWorkEditorPartRow;
+ type Type = super::WorkEditorPartRow;
type ParentType = adw::ActionRow;
fn class_init(klass: &mut Self::Class) {
@@ -40,7 +40,7 @@ mod imp {
}
#[glib::derived_properties]
- impl ObjectImpl for MusicusWorkEditorPartRow {
+ impl ObjectImpl for WorkEditorPartRow {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy> =
Lazy::new(|| vec![Signal::builder("remove").build()]);
@@ -49,20 +49,20 @@ mod imp {
}
}
- impl WidgetImpl for MusicusWorkEditorPartRow {}
- impl ListBoxRowImpl for MusicusWorkEditorPartRow {}
- impl PreferencesRowImpl for MusicusWorkEditorPartRow {}
- impl ActionRowImpl for MusicusWorkEditorPartRow {}
+ impl WidgetImpl for WorkEditorPartRow {}
+ impl ListBoxRowImpl for WorkEditorPartRow {}
+ impl PreferencesRowImpl for WorkEditorPartRow {}
+ impl ActionRowImpl for WorkEditorPartRow {}
}
glib::wrapper! {
- pub struct MusicusWorkEditorPartRow(ObjectSubclass)
+ pub struct WorkEditorPartRow(ObjectSubclass)
@extends gtk::Widget, gtk::ListBoxRow, adw::PreferencesRow, adw::ActionRow;
}
#[gtk::template_callbacks]
-impl MusicusWorkEditorPartRow {
- pub fn new(navigation: &adw::NavigationView, library: &MusicusLibrary, part: Work) -> Self {
+impl WorkEditorPartRow {
+ pub fn new(navigation: &adw::NavigationView, library: &Library, part: Work) -> Self {
let obj: Self = glib::Object::builder()
.property("navigation", navigation)
.property("library", library)
@@ -104,7 +104,7 @@ impl MusicusWorkEditorPartRow {
#[template_callback]
fn edit(&self) {
- let editor = MusicusWorkEditor::new(
+ let editor = WorkEditor::new(
&self.navigation(),
&self.library(),
self.imp().part.borrow().as_ref(),
diff --git a/src/home_page.rs b/src/home_page.rs
index f4d5172..226cf7c 100644
--- a/src/home_page.rs
+++ b/src/home_page.rs
@@ -8,38 +8,35 @@ use gtk::{
};
use crate::{
- album_tile::MusicusAlbumTile,
+ album_tile::AlbumTile,
config,
db::models::*,
- editor::{
- ensemble_editor::MusicusEnsembleEditor, person_editor::MusicusPersonEditor,
- work_editor::MusicusWorkEditor,
- },
- library::{LibraryQuery, MusicusLibrary},
- player::MusicusPlayer,
+ editor::{ensemble::EnsembleEditor, person::PersonEditor, work::WorkEditor},
+ library::{Library, LibraryQuery},
+ player::Player,
program::Program,
- program_tile::MusicusProgramTile,
- recording_tile::MusicusRecordingTile,
- search_entry::MusicusSearchEntry,
+ program_tile::ProgramTile,
+ recording_tile::RecordingTile,
+ search_entry::SearchEntry,
search_tag::Tag,
- tag_tile::MusicusTagTile,
+ tag_tile::TagTile,
};
mod imp {
use super::*;
#[derive(Properties, Debug, Default, gtk::CompositeTemplate)]
- #[properties(wrapper_type = super::MusicusHomePage)]
+ #[properties(wrapper_type = super::HomePage)]
#[template(file = "data/ui/home_page.blp")]
- pub struct MusicusHomePage {
+ pub struct HomePage {
#[property(get, construct_only)]
pub navigation: OnceCell,
#[property(get, construct_only)]
- pub library: OnceCell,
+ pub library: OnceCell,
#[property(get, construct_only)]
- pub player: OnceCell,
+ pub player: OnceCell,
pub programs: RefCell>,
pub composers: RefCell>,
@@ -50,7 +47,7 @@ mod imp {
pub albums: RefCell>,
#[template_child]
- pub search_entry: TemplateChild,
+ pub search_entry: TemplateChild,
#[template_child]
pub stack: TemplateChild,
#[template_child]
@@ -78,9 +75,9 @@ mod imp {
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusHomePage {
+ impl ObjectSubclass for HomePage {
const NAME: &'static str = "MusicusHomePage";
- type Type = super::MusicusHomePage;
+ type Type = super::HomePage;
type ParentType = adw::NavigationPage;
fn class_init(klass: &mut Self::Class) {
@@ -94,7 +91,7 @@ mod imp {
}
#[glib::derived_properties]
- impl ObjectImpl for MusicusHomePage {
+ impl ObjectImpl for HomePage {
fn constructed(&self) {
self.parent_constructed();
@@ -128,7 +125,7 @@ mod imp {
for program in &programs {
self.programs_flow_box
- .append(&MusicusProgramTile::new(program.to_owned()));
+ .append(&ProgramTile::new(program.to_owned()));
}
self.programs.replace(programs);
@@ -137,22 +134,18 @@ mod imp {
}
}
- impl WidgetImpl for MusicusHomePage {}
- impl NavigationPageImpl for MusicusHomePage {}
+ impl WidgetImpl for HomePage {}
+ impl NavigationPageImpl for HomePage {}
}
glib::wrapper! {
- pub struct MusicusHomePage(ObjectSubclass)
+ pub struct HomePage(ObjectSubclass)
@extends gtk::Widget, adw::NavigationPage;
}
#[gtk::template_callbacks]
-impl MusicusHomePage {
- pub fn new(
- navigation: &adw::NavigationView,
- library: &MusicusLibrary,
- player: &MusicusPlayer,
- ) -> Self {
+impl HomePage {
+ pub fn new(navigation: &adw::NavigationView, library: &Library, player: &Player) -> Self {
glib::Object::builder()
.property("navigation", navigation)
.property("library", library)
@@ -170,20 +163,20 @@ impl MusicusHomePage {
if let Some(tag) = self.imp().search_entry.tags().first() {
match tag {
Tag::Composer(person) | Tag::Performer(person) => {
- self.navigation().push(&MusicusPersonEditor::new(
+ self.navigation().push(&PersonEditor::new(
&self.navigation(),
&self.library(),
Some(person),
));
}
Tag::Ensemble(ensemble) => {
- self.navigation().push(&MusicusEnsembleEditor::new(
+ self.navigation().push(&EnsembleEditor::new(
&self.navigation(),
&self.library(),
Some(ensemble),
));
}
- Tag::Work(work) => self.navigation().push(&MusicusWorkEditor::new(
+ Tag::Work(work) => self.navigation().push(&WorkEditor::new(
&self.navigation(),
&self.library(),
Some(work),
@@ -202,7 +195,7 @@ impl MusicusHomePage {
}
#[template_callback]
- fn select(&self, search_entry: &MusicusSearchEntry) {
+ fn select(&self, search_entry: &SearchEntry) {
let imp = self.imp();
if imp.programs_flow_box.is_visible() {
@@ -240,28 +233,25 @@ impl MusicusHomePage {
#[template_callback]
fn program_selected(&self, tile: >k::FlowBoxChild, _: >k::FlowBox) {
self.player()
- .set_program(tile.downcast_ref::().unwrap().program());
+ .set_program(tile.downcast_ref::().unwrap().program());
}
#[template_callback]
fn tile_selected(&self, tile: >k::FlowBoxChild, _: >k::FlowBox) {
self.imp()
.search_entry
- .add_tag(tile.downcast_ref::().unwrap().tag().clone())
+ .add_tag(tile.downcast_ref::().unwrap().tag().clone())
}
#[template_callback]
fn recording_selected(&self, tile: >k::FlowBoxChild, _: >k::FlowBox) {
- self.player().play_recording(
- tile.downcast_ref::()
- .unwrap()
- .recording(),
- );
+ self.player()
+ .play_recording(tile.downcast_ref::().unwrap().recording());
}
#[template_callback]
fn album_selected(&self, tile: >k::FlowBoxChild, _: >k::FlowBox) {
- self.show_album(tile.downcast_ref::().unwrap().album());
+ self.show_album(tile.downcast_ref::().unwrap().album());
}
fn show_album(&self, _album: &Album) {
@@ -331,26 +321,26 @@ impl MusicusHomePage {
for composer in &results.composers {
imp.composers_flow_box
- .append(&MusicusTagTile::new(Tag::Composer(composer.clone())));
+ .append(&TagTile::new(Tag::Composer(composer.clone())));
}
for performer in &results.performers {
imp.performers_flow_box
- .append(&MusicusTagTile::new(Tag::Performer(performer.clone())));
+ .append(&TagTile::new(Tag::Performer(performer.clone())));
}
for ensemble in &results.ensembles {
imp.ensembles_flow_box
- .append(&MusicusTagTile::new(Tag::Ensemble(ensemble.clone())));
+ .append(&TagTile::new(Tag::Ensemble(ensemble.clone())));
}
for work in &results.works {
imp.works_flow_box
- .append(&MusicusTagTile::new(Tag::Work(work.clone())));
+ .append(&TagTile::new(Tag::Work(work.clone())));
}
for recording in &results.recordings {
- imp.recordings_flow_box.append(&MusicusRecordingTile::new(
+ imp.recordings_flow_box.append(&RecordingTile::new(
&self.navigation(),
&self.library(),
recording,
@@ -358,7 +348,7 @@ impl MusicusHomePage {
}
for album in &results.albums {
- imp.albums_flow_box.append(&MusicusAlbumTile::new(album));
+ imp.albums_flow_box.append(&AlbumTile::new(album));
}
imp.composers.replace(results.composers);
diff --git a/src/library.rs b/src/library.rs
index db310a1..20682a2 100644
--- a/src/library.rs
+++ b/src/library.rs
@@ -1,6 +1,8 @@
-use crate::{
- db::{self, models::*, schema::*, tables, TranslatedString},
- program::Program,
+use std::{
+ cell::{OnceCell, RefCell},
+ ffi::OsString,
+ fs,
+ path::{Path, PathBuf},
};
use adw::{
@@ -13,11 +15,9 @@ use chrono::prelude::*;
use diesel::{dsl::exists, prelude::*, QueryDsl, SqliteConnection};
use once_cell::sync::Lazy;
-use std::{
- cell::{OnceCell, RefCell},
- ffi::OsString,
- fs,
- path::{Path, PathBuf},
+use crate::{
+ db::{self, models::*, schema::*, tables, TranslatedString},
+ program::Program,
};
diesel::define_sql_function! {
@@ -29,21 +29,21 @@ mod imp {
use super::*;
#[derive(Properties, Default)]
- #[properties(wrapper_type = super::MusicusLibrary)]
- pub struct MusicusLibrary {
+ #[properties(wrapper_type = super::Library)]
+ pub struct Library {
#[property(get, construct_only)]
pub folder: OnceCell,
pub connection: RefCell>,
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusLibrary {
+ impl ObjectSubclass for Library {
const NAME: &'static str = "MusicusLibrary";
- type Type = super::MusicusLibrary;
+ type Type = super::Library;
}
#[glib::derived_properties]
- impl ObjectImpl for MusicusLibrary {
+ impl ObjectImpl for Library {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy> =
Lazy::new(|| vec![Signal::builder("changed").build()]);
@@ -62,10 +62,10 @@ mod imp {
}
glib::wrapper! {
- pub struct MusicusLibrary(ObjectSubclass);
+ pub struct Library(ObjectSubclass);
}
-impl MusicusLibrary {
+impl Library {
pub fn new(path: impl AsRef) -> Self {
glib::Object::builder()
.property("folder", path.as_ref().to_str().unwrap())
diff --git a/src/library_manager/albums_page.rs b/src/library_manager/albums_page.rs
index 7fe74e8..2bb1bd1 100644
--- a/src/library_manager/albums_page.rs
+++ b/src/library_manager/albums_page.rs
@@ -1,10 +1,10 @@
-use crate::{db::models::Album, editor::album_editor::AlbumEditor, library::MusicusLibrary};
+use std::cell::{OnceCell, RefCell};
use adw::{prelude::*, subclass::prelude::*};
use gettextrs::gettext;
use gtk::glib::{self, clone};
-use std::cell::{OnceCell, RefCell};
+use crate::{db::models::Album, editor::album::AlbumEditor, library::Library};
mod imp {
use super::*;
@@ -13,7 +13,7 @@ mod imp {
#[template(file = "data/ui/library_manager_albums_page.blp")]
pub struct AlbumsPage {
pub navigation: OnceCell,
- pub library: OnceCell,
+ pub library: OnceCell,
pub albums: RefCell>,
pub albums_filtered: RefCell>,
@@ -57,7 +57,7 @@ glib::wrapper! {
#[gtk::template_callbacks]
impl AlbumsPage {
- pub fn new(navigation: &adw::NavigationView, library: &MusicusLibrary) -> Self {
+ pub fn new(navigation: &adw::NavigationView, library: &Library) -> Self {
let obj: Self = glib::Object::new();
let imp = obj.imp();
diff --git a/src/library_manager/mod.rs b/src/library_manager/mod.rs
index 6107c49..5ec5c04 100644
--- a/src/library_manager/mod.rs
+++ b/src/library_manager/mod.rs
@@ -1,12 +1,9 @@
pub mod albums_page;
-use crate::{
- db::{
- models::{Album, Ensemble, Instrument, Person, Recording, Role, Track, Work},
- tables::Medium,
- },
- library::MusicusLibrary,
- window::MusicusWindow,
+use std::{
+ cell::{OnceCell, RefCell},
+ ffi::OsStr,
+ path::Path,
};
use adw::{prelude::*, subclass::prelude::*};
@@ -14,10 +11,13 @@ use albums_page::AlbumsPage;
use gettextrs::gettext;
use gtk::glib;
-use std::{
- cell::{OnceCell, RefCell},
- ffi::OsStr,
- path::Path,
+use crate::{
+ db::{
+ models::{Album, Ensemble, Instrument, Person, Recording, Role, Track, Work},
+ tables::Medium,
+ },
+ library::Library,
+ window::Window,
};
mod imp {
@@ -27,7 +27,7 @@ mod imp {
#[template(file = "data/ui/library_manager.blp")]
pub struct LibraryManager {
pub navigation: OnceCell,
- pub library: OnceCell,
+ pub library: OnceCell,
pub persons: RefCell>,
pub roles: RefCell>,
@@ -95,7 +95,7 @@ glib::wrapper! {
#[gtk::template_callbacks]
impl LibraryManager {
- pub fn new(navigation: &adw::NavigationView, library: &MusicusLibrary) -> Self {
+ pub fn new(navigation: &adw::NavigationView, library: &Library) -> Self {
let obj: Self = glib::Object::new();
let imp = obj.imp();
@@ -116,7 +116,7 @@ impl LibraryManager {
let window = root
.as_ref()
.and_then(|r| r.downcast_ref::())
- .and_then(|w| w.downcast_ref::())
+ .and_then(|w| w.downcast_ref::())
.unwrap();
match dialog.select_folder_future(Some(window)).await {
diff --git a/src/main.rs b/src/main.rs
index e019fae..f6ea0d5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,4 @@
+mod activatable_row;
mod album_tile;
mod application;
mod config;
@@ -16,16 +17,18 @@ mod program_tile;
mod recording_tile;
mod search_entry;
mod search_tag;
+mod selector;
mod tag_tile;
mod util;
mod welcome_page;
mod window;
-use self::{application::MusicusApplication, window::MusicusWindow};
use gettextrs::LocaleCategory;
use gstreamer_play::gst;
use gtk::{gio, glib, prelude::*};
+use self::{application::Application, window::Window};
+
fn main() -> glib::ExitCode {
tracing_subscriber::fmt::init();
gtk::init().expect("Failed to initialize GTK!");
@@ -48,5 +51,5 @@ fn main() -> glib::ExitCode {
.expect("Could not load resources"),
);
- MusicusApplication::new().run()
+ Application::new().run()
}
diff --git a/src/player.rs b/src/player.rs
index ad28f86..02c8931 100644
--- a/src/player.rs
+++ b/src/player.rs
@@ -16,7 +16,7 @@ use once_cell::sync::Lazy;
use crate::{
config,
db::models::{Recording, Track},
- library::MusicusLibrary,
+ library::Library,
playlist_item::PlaylistItem,
program::Program,
};
@@ -25,10 +25,10 @@ mod imp {
use super::*;
#[derive(Properties, Debug, Default)]
- #[properties(wrapper_type = super::MusicusPlayer)]
- pub struct MusicusPlayer {
+ #[properties(wrapper_type = super::Player)]
+ pub struct Player {
#[property(get, set)]
- pub library: RefCell>,
+ pub library: RefCell >,
#[property(get, set)]
pub active: Cell,
#[property(get, set)]
@@ -49,7 +49,7 @@ mod imp {
pub mpris: OnceCell,
}
- impl MusicusPlayer {
+ impl Player {
pub fn set_program(&self, program: &Program) {
self.program.replace(Some(program.to_owned()));
@@ -114,13 +114,13 @@ mod imp {
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusPlayer {
+ impl ObjectSubclass for Player {
const NAME: &'static str = "MusicusPlayer";
- type Type = super::MusicusPlayer;
+ type Type = super::Player;
}
#[glib::derived_properties]
- impl ObjectImpl for MusicusPlayer {
+ impl ObjectImpl for Player {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy> =
Lazy::new(|| vec![Signal::builder("raise").build()]);
@@ -180,10 +180,10 @@ mod imp {
}
glib::wrapper! {
- pub struct MusicusPlayer(ObjectSubclass);
+ pub struct Player(ObjectSubclass);
}
-impl MusicusPlayer {
+impl Player {
pub fn new() -> Self {
glib::Object::builder()
.property("active", false)
@@ -436,7 +436,7 @@ impl MusicusPlayer {
}
}
-impl Default for MusicusPlayer {
+impl Default for Player {
fn default() -> Self {
Self::new()
}
diff --git a/src/player_bar.rs b/src/player_bar.rs
index 8b35b53..162fe54 100644
--- a/src/player_bar.rs
+++ b/src/player_bar.rs
@@ -1,4 +1,5 @@
-use crate::player::MusicusPlayer;
+use std::cell::{Cell, OnceCell};
+
use gtk::{
gdk,
glib::{self, clone, subclass::Signal, Properties},
@@ -6,7 +7,8 @@ use gtk::{
subclass::prelude::*,
};
use once_cell::sync::Lazy;
-use std::cell::{Cell, OnceCell};
+
+use crate::player::Player;
mod imp {
use super::*;
@@ -16,7 +18,7 @@ mod imp {
#[template(file = "data/ui/player_bar.blp")]
pub struct PlayerBar {
#[property(get, construct_only)]
- pub player: OnceCell,
+ pub player: OnceCell,
pub seeking: Cell,
@@ -196,7 +198,7 @@ glib::wrapper! {
#[gtk::template_callbacks]
impl PlayerBar {
- pub fn new(player: &MusicusPlayer) -> Self {
+ pub fn new(player: &Player) -> Self {
glib::Object::builder().property("player", player).build()
}
diff --git a/src/playlist_item.rs b/src/playlist_item.rs
index 9cd43e7..f55ae98 100644
--- a/src/playlist_item.rs
+++ b/src/playlist_item.rs
@@ -1,9 +1,10 @@
-use gtk::{glib, glib::Properties, prelude::*, subclass::prelude::*};
use std::{
cell::{Cell, OnceCell},
path::{Path, PathBuf},
};
+use gtk::{glib, glib::Properties, prelude::*, subclass::prelude::*};
+
mod imp {
use super::*;
diff --git a/src/playlist_page.rs b/src/playlist_page.rs
index 758cc93..db52f4e 100644
--- a/src/playlist_page.rs
+++ b/src/playlist_page.rs
@@ -1,29 +1,35 @@
-use crate::{player::MusicusPlayer, playlist_tile::PlaylistTile};
-use adw::subclass::prelude::*;
-use gtk::{glib, glib::subclass::Signal, glib::Properties, prelude::*, ListScrollFlags};
-use once_cell::sync::Lazy;
use std::cell::OnceCell;
+use adw::subclass::prelude::*;
+use gtk::{
+ glib,
+ glib::{subclass::Signal, Properties},
+ prelude::*,
+ ListScrollFlags,
+};
+use once_cell::sync::Lazy;
+
+use crate::{player::Player, playlist_tile::PlaylistTile};
+
mod imp {
+ use super::*;
use crate::playlist_item::PlaylistItem;
- use super::*;
-
#[derive(Properties, Debug, Default, gtk::CompositeTemplate)]
- #[properties(wrapper_type = super::MusicusPlaylistPage)]
+ #[properties(wrapper_type = super::PlaylistPage)]
#[template(file = "data/ui/playlist_page.blp")]
- pub struct MusicusPlaylistPage {
+ pub struct PlaylistPage {
#[property(get, construct_only)]
- pub player: OnceCell,
+ pub player: OnceCell,
#[template_child]
pub playlist: TemplateChild,
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusPlaylistPage {
+ impl ObjectSubclass for PlaylistPage {
const NAME: &'static str = "MusicusPlaylistPage";
- type Type = super::MusicusPlaylistPage;
+ type Type = super::PlaylistPage;
type ParentType = adw::Bin;
fn class_init(klass: &mut Self::Class) {
@@ -37,7 +43,7 @@ mod imp {
}
#[glib::derived_properties]
- impl ObjectImpl for MusicusPlaylistPage {
+ impl ObjectImpl for PlaylistPage {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy> =
Lazy::new(|| vec![Signal::builder("close").build()]);
@@ -76,18 +82,18 @@ mod imp {
}
}
- impl WidgetImpl for MusicusPlaylistPage {}
- impl BinImpl for MusicusPlaylistPage {}
+ impl WidgetImpl for PlaylistPage {}
+ impl BinImpl for PlaylistPage {}
}
glib::wrapper! {
- pub struct MusicusPlaylistPage(ObjectSubclass)
+ pub struct PlaylistPage(ObjectSubclass)
@extends gtk::Widget, adw::Bin;
}
#[gtk::template_callbacks]
-impl MusicusPlaylistPage {
- pub fn new(player: &MusicusPlayer) -> Self {
+impl PlaylistPage {
+ pub fn new(player: &Player) -> Self {
glib::Object::builder().property("player", player).build()
}
diff --git a/src/playlist_tile.rs b/src/playlist_tile.rs
index a210197..3e9ae5f 100644
--- a/src/playlist_tile.rs
+++ b/src/playlist_tile.rs
@@ -1,7 +1,9 @@
-use crate::playlist_item::PlaylistItem;
-use gtk::{glib, prelude::*, subclass::prelude::*};
use std::cell::RefCell;
+use gtk::{glib, prelude::*, subclass::prelude::*};
+
+use crate::playlist_item::PlaylistItem;
+
mod imp {
use super::*;
diff --git a/src/program_tile.rs b/src/program_tile.rs
index 9ed502b..9e5c034 100644
--- a/src/program_tile.rs
+++ b/src/program_tile.rs
@@ -12,9 +12,9 @@ mod imp {
use super::*;
#[derive(Properties, Debug, Default, gtk::CompositeTemplate)]
- #[properties(wrapper_type = super::MusicusProgramTile)]
+ #[properties(wrapper_type = super::ProgramTile)]
#[template(file = "data/ui/program_tile.blp")]
- pub struct MusicusProgramTile {
+ pub struct ProgramTile {
#[property(get, construct_only)]
pub program: OnceCell,
@@ -27,9 +27,9 @@ mod imp {
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusProgramTile {
+ impl ObjectSubclass for ProgramTile {
const NAME: &'static str = "MusicusProgramTile";
- type Type = super::MusicusProgramTile;
+ type Type = super::ProgramTile;
type ParentType = gtk::FlowBoxChild;
fn class_init(klass: &mut Self::Class) {
@@ -42,18 +42,18 @@ mod imp {
}
#[glib::derived_properties]
- impl ObjectImpl for MusicusProgramTile {}
+ impl ObjectImpl for ProgramTile {}
- impl WidgetImpl for MusicusProgramTile {}
- impl FlowBoxChildImpl for MusicusProgramTile {}
+ impl WidgetImpl for ProgramTile {}
+ impl FlowBoxChildImpl for ProgramTile {}
}
glib::wrapper! {
- pub struct MusicusProgramTile(ObjectSubclass)
+ pub struct ProgramTile(ObjectSubclass)
@extends gtk::Widget, gtk::FlowBoxChild;
}
-impl MusicusProgramTile {
+impl ProgramTile {
pub fn new(program: Program) -> Self {
let obj: Self = glib::Object::builder()
.property("program", &program)
diff --git a/src/recording_tile.rs b/src/recording_tile.rs
index 65e9c0a..28f240d 100644
--- a/src/recording_tile.rs
+++ b/src/recording_tile.rs
@@ -1,20 +1,17 @@
-use crate::{
- db::models::Recording, editor::recording_editor::MusicusRecordingEditor,
- library::MusicusLibrary,
-};
+use std::cell::OnceCell;
use gettextrs::gettext;
use gtk::{gio, glib, prelude::*, subclass::prelude::*};
-use std::cell::OnceCell;
+
+use crate::{db::models::Recording, editor::recording::RecordingEditor, library::Library};
mod imp {
- use crate::editor::tracks_editor::TracksEditor;
-
use super::*;
+ use crate::editor::tracks::TracksEditor;
#[derive(Debug, Default, gtk::CompositeTemplate)]
#[template(file = "data/ui/recording_tile.blp")]
- pub struct MusicusRecordingTile {
+ pub struct RecordingTile {
#[template_child]
pub composer_label: TemplateChild,
#[template_child]
@@ -23,14 +20,14 @@ mod imp {
pub performances_label: TemplateChild,
pub navigation: OnceCell,
- pub library: OnceCell,
+ pub library: OnceCell,
pub recording: OnceCell,
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusRecordingTile {
+ impl ObjectSubclass for RecordingTile {
const NAME: &'static str = "MusicusRecordingTile";
- type Type = super::MusicusRecordingTile;
+ type Type = super::RecordingTile;
type ParentType = gtk::FlowBoxChild;
fn class_init(klass: &mut Self::Class) {
@@ -42,7 +39,7 @@ mod imp {
}
}
- impl ObjectImpl for MusicusRecordingTile {
+ impl ObjectImpl for RecordingTile {
fn constructed(&self) {
self.parent_constructed();
@@ -53,7 +50,7 @@ mod imp {
.navigation
.get()
.unwrap()
- .push(&MusicusRecordingEditor::new(
+ .push(&RecordingEditor::new(
obj.imp().navigation.get().unwrap(),
obj.imp().library.get().unwrap(),
Some(&obj.imp().recording.get().unwrap()),
@@ -78,21 +75,17 @@ mod imp {
}
}
- impl WidgetImpl for MusicusRecordingTile {}
- impl FlowBoxChildImpl for MusicusRecordingTile {}
+ impl WidgetImpl for RecordingTile {}
+ impl FlowBoxChildImpl for RecordingTile {}
}
glib::wrapper! {
- pub struct MusicusRecordingTile(ObjectSubclass)
+ pub struct RecordingTile(ObjectSubclass)
@extends gtk::Widget, gtk::FlowBoxChild;
}
-impl MusicusRecordingTile {
- pub fn new(
- navigation: &adw::NavigationView,
- library: &MusicusLibrary,
- recording: &Recording,
- ) -> Self {
+impl RecordingTile {
+ pub fn new(navigation: &adw::NavigationView, library: &Library, recording: &Recording) -> Self {
let obj: Self = glib::Object::new();
let imp = obj.imp();
diff --git a/src/search_entry.rs b/src/search_entry.rs
index a7796eb..28adf3f 100644
--- a/src/search_entry.rs
+++ b/src/search_entry.rs
@@ -1,21 +1,23 @@
-use crate::{
- library::LibraryQuery,
- search_tag::{MusicusSearchTag, Tag},
-};
+use std::{cell::RefCell, time::Duration};
+
use adw::{prelude::*, subclass::prelude::*};
use gtk::{
gdk, gio,
glib::{self, clone, subclass::Signal, Propagation},
};
use once_cell::sync::Lazy;
-use std::{cell::RefCell, time::Duration};
+
+use crate::{
+ library::LibraryQuery,
+ search_tag::{SearchTag, Tag},
+};
mod imp {
use super::*;
#[derive(Debug, Default, gtk::CompositeTemplate)]
#[template(file = "data/ui/search_entry.blp")]
- pub struct MusicusSearchEntry {
+ pub struct SearchEntry {
#[template_child]
pub tags_box: TemplateChild,
#[template_child]
@@ -23,14 +25,14 @@ mod imp {
#[template_child]
pub clear_icon: TemplateChild,
- pub tags: RefCell>,
+ pub tags: RefCell>,
pub query_changed: RefCell>,
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusSearchEntry {
+ impl ObjectSubclass for SearchEntry {
const NAME: &'static str = "MusicusSearchEntry";
- type Type = super::MusicusSearchEntry;
+ type Type = super::SearchEntry;
type ParentType = gtk::Box;
fn class_init(klass: &mut Self::Class) {
@@ -45,8 +47,8 @@ mod imp {
gdk::ModifierType::empty(),
))
.action(>k::CallbackAction::new(|widget, _| match widget
- .downcast_ref::(
- ) {
+ .downcast_ref::()
+ {
Some(obj) => {
obj.reset();
Propagation::Stop
@@ -62,7 +64,7 @@ mod imp {
}
}
- impl ObjectImpl for MusicusSearchEntry {
+ impl ObjectImpl for SearchEntry {
fn constructed(&self) {
let controller = gtk::GestureClick::new();
@@ -90,22 +92,22 @@ mod imp {
}
}
- impl WidgetImpl for MusicusSearchEntry {
+ impl WidgetImpl for SearchEntry {
fn grab_focus(&self) -> bool {
self.text.grab_focus_without_selecting()
}
}
- impl BoxImpl for MusicusSearchEntry {}
+ impl BoxImpl for SearchEntry {}
}
glib::wrapper! {
- pub struct MusicusSearchEntry(ObjectSubclass)
+ pub struct SearchEntry(ObjectSubclass)
@extends gtk::Widget;
}
#[gtk::template_callbacks]
-impl MusicusSearchEntry {
+impl SearchEntry {
pub fn new() -> Self {
glib::Object::new()
}
@@ -166,7 +168,7 @@ impl MusicusSearchEntry {
imp.clear_icon.set_visible(true);
imp.text.set_text("");
- let tag = MusicusSearchTag::new(tag);
+ let tag = SearchTag::new(tag);
tag.connect_remove(clone!(
#[weak(rename_to = this)]
diff --git a/src/search_tag.rs b/src/search_tag.rs
index 2c78916..064c399 100644
--- a/src/search_tag.rs
+++ b/src/search_tag.rs
@@ -1,6 +1,7 @@
+use std::cell::OnceCell;
+
use adw::{glib, glib::subclass::Signal, prelude::*, subclass::prelude::*};
use once_cell::sync::Lazy;
-use std::cell::OnceCell;
use crate::db::models::{Ensemble, Person, Work};
@@ -9,16 +10,16 @@ mod imp {
#[derive(Debug, Default, gtk::CompositeTemplate)]
#[template(file = "data/ui/search_tag.blp")]
- pub struct MusicusSearchTag {
+ pub struct SearchTag {
#[template_child]
pub label: TemplateChild,
pub tag: OnceCell,
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusSearchTag {
+ impl ObjectSubclass for SearchTag {
const NAME: &'static str = "MusicusSearchTag";
- type Type = super::MusicusSearchTag;
+ type Type = super::SearchTag;
type ParentType = gtk::Box;
fn class_init(klass: &mut Self::Class) {
@@ -31,7 +32,7 @@ mod imp {
}
}
- impl ObjectImpl for MusicusSearchTag {
+ impl ObjectImpl for SearchTag {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy> =
Lazy::new(|| vec![Signal::builder("remove").build()]);
@@ -40,19 +41,19 @@ mod imp {
}
}
- impl WidgetImpl for MusicusSearchTag {}
- impl BoxImpl for MusicusSearchTag {}
+ impl WidgetImpl for SearchTag {}
+ impl BoxImpl for SearchTag {}
}
glib::wrapper! {
- pub struct MusicusSearchTag(ObjectSubclass)
+ pub struct SearchTag(ObjectSubclass)
@extends gtk::Widget;
}
#[gtk::template_callbacks]
-impl MusicusSearchTag {
+impl SearchTag {
pub fn new(tag: Tag) -> Self {
- let obj: MusicusSearchTag = glib::Object::new();
+ let obj: SearchTag = glib::Object::new();
obj.imp().label.set_label(match &tag {
Tag::Composer(person) => person.name.get(),
diff --git a/src/editor/ensemble_selector_popover.rs b/src/selector/ensemble.rs
similarity index 75%
rename from src/editor/ensemble_selector_popover.rs
rename to src/selector/ensemble.rs
index e13fc39..63f203b 100644
--- a/src/editor/ensemble_selector_popover.rs
+++ b/src/selector/ensemble.rs
@@ -1,4 +1,4 @@
-use crate::{db::models::Ensemble, library::MusicusLibrary};
+use std::cell::{OnceCell, RefCell};
use gettextrs::gettext;
use gtk::{
@@ -8,19 +8,17 @@ use gtk::{
};
use once_cell::sync::Lazy;
-use std::cell::{OnceCell, RefCell};
-
-use super::activatable_row::MusicusActivatableRow;
+use crate::{activatable_row::ActivatableRow, db::models::Ensemble, library::Library};
mod imp {
use super::*;
#[derive(Debug, Default, gtk::CompositeTemplate, Properties)]
- #[properties(wrapper_type = super::MusicusEnsembleSelectorPopover)]
- #[template(file = "data/ui/ensemble_selector_popover.blp")]
- pub struct MusicusEnsembleSelectorPopover {
+ #[properties(wrapper_type = super::EnsembleSelectorPopover)]
+ #[template(file = "data/ui/selector/ensemble.blp")]
+ pub struct EnsembleSelectorPopover {
#[property(get, construct_only)]
- pub library: OnceCell,
+ pub library: OnceCell,
pub ensembles: RefCell>,
@@ -33,9 +31,9 @@ mod imp {
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusEnsembleSelectorPopover {
+ impl ObjectSubclass for EnsembleSelectorPopover {
const NAME: &'static str = "MusicusEnsembleSelectorPopover";
- type Type = super::MusicusEnsembleSelectorPopover;
+ type Type = super::EnsembleSelectorPopover;
type ParentType = gtk::Popover;
fn class_init(klass: &mut Self::Class) {
@@ -49,18 +47,17 @@ mod imp {
}
#[glib::derived_properties]
- impl ObjectImpl for MusicusEnsembleSelectorPopover {
+ impl ObjectImpl for EnsembleSelectorPopover {
fn constructed(&self) {
self.parent_constructed();
- self.obj()
- .connect_visible_notify(|obj: &super::MusicusEnsembleSelectorPopover| {
- if obj.is_visible() {
- obj.imp().search_entry.set_text("");
- obj.imp().search_entry.grab_focus();
- obj.imp().scrolled_window.vadjustment().set_value(0.0);
- }
- });
+ self.obj().connect_visible_notify(|obj| {
+ if obj.is_visible() {
+ obj.imp().search_entry.set_text("");
+ obj.imp().search_entry.grab_focus();
+ obj.imp().scrolled_window.vadjustment().set_value(0.0);
+ }
+ });
self.obj().search("");
}
@@ -79,7 +76,7 @@ mod imp {
}
}
- impl WidgetImpl for MusicusEnsembleSelectorPopover {
+ impl WidgetImpl for EnsembleSelectorPopover {
// TODO: Fix focus.
fn focus(&self, direction_type: gtk::DirectionType) -> bool {
if direction_type == gtk::DirectionType::Down {
@@ -90,17 +87,17 @@ mod imp {
}
}
- impl PopoverImpl for MusicusEnsembleSelectorPopover {}
+ impl PopoverImpl for EnsembleSelectorPopover {}
}
glib::wrapper! {
- pub struct MusicusEnsembleSelectorPopover(ObjectSubclass)
+ pub struct EnsembleSelectorPopover(ObjectSubclass)
@extends gtk::Widget, gtk::Popover;
}
#[gtk::template_callbacks]
-impl MusicusEnsembleSelectorPopover {
- pub fn new(library: &MusicusLibrary) -> Self {
+impl EnsembleSelectorPopover {
+ pub fn new(library: &Library) -> Self {
glib::Object::builder().property("library", library).build()
}
@@ -151,7 +148,7 @@ impl MusicusEnsembleSelectorPopover {
imp.list_box.remove_all();
for ensemble in &ensembles {
- let row = MusicusActivatableRow::new(
+ let row = ActivatableRow::new(
>k::Label::builder()
.label(ensemble.to_string())
.halign(gtk::Align::Start)
@@ -162,7 +159,7 @@ impl MusicusEnsembleSelectorPopover {
let ensemble = ensemble.clone();
let obj = self.clone();
- row.connect_activated(move |_: &MusicusActivatableRow| {
+ row.connect_activated(move |_: &ActivatableRow| {
obj.select(ensemble.clone());
});
@@ -178,9 +175,9 @@ impl MusicusEnsembleSelectorPopover {
.build(),
);
- let create_row = MusicusActivatableRow::new(&create_box);
+ let create_row = ActivatableRow::new(&create_box);
let obj = self.clone();
- create_row.connect_activated(move |_: &MusicusActivatableRow| {
+ create_row.connect_activated(move |_: &ActivatableRow| {
obj.create();
});
diff --git a/src/editor/instrument_selector_popover.rs b/src/selector/instrument.rs
similarity index 76%
rename from src/editor/instrument_selector_popover.rs
rename to src/selector/instrument.rs
index 6edbbde..7117a80 100644
--- a/src/editor/instrument_selector_popover.rs
+++ b/src/selector/instrument.rs
@@ -1,4 +1,4 @@
-use crate::{db::models::Instrument, library::MusicusLibrary};
+use std::cell::{OnceCell, RefCell};
use gettextrs::gettext;
use gtk::{
@@ -8,19 +8,17 @@ use gtk::{
};
use once_cell::sync::Lazy;
-use std::cell::{OnceCell, RefCell};
-
-use super::activatable_row::MusicusActivatableRow;
+use crate::{activatable_row::ActivatableRow, db::models::Instrument, library::Library};
mod imp {
use super::*;
#[derive(Debug, Default, gtk::CompositeTemplate, Properties)]
- #[properties(wrapper_type = super::MusicusInstrumentSelectorPopover)]
- #[template(file = "data/ui/instrument_selector_popover.blp")]
- pub struct MusicusInstrumentSelectorPopover {
+ #[properties(wrapper_type = super::InstrumentSelectorPopover)]
+ #[template(file = "data/ui/selector/instrument.blp")]
+ pub struct InstrumentSelectorPopover {
#[property(get, construct_only)]
- pub library: OnceCell,
+ pub library: OnceCell,
pub instruments: RefCell>,
@@ -33,9 +31,9 @@ mod imp {
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusInstrumentSelectorPopover {
+ impl ObjectSubclass for InstrumentSelectorPopover {
const NAME: &'static str = "MusicusInstrumentSelectorPopover";
- type Type = super::MusicusInstrumentSelectorPopover;
+ type Type = super::InstrumentSelectorPopover;
type ParentType = gtk::Popover;
fn class_init(klass: &mut Self::Class) {
@@ -49,18 +47,17 @@ mod imp {
}
#[glib::derived_properties]
- impl ObjectImpl for MusicusInstrumentSelectorPopover {
+ impl ObjectImpl for InstrumentSelectorPopover {
fn constructed(&self) {
self.parent_constructed();
- self.obj()
- .connect_visible_notify(|obj: &super::MusicusInstrumentSelectorPopover| {
- if obj.is_visible() {
- obj.imp().search_entry.set_text("");
- obj.imp().search_entry.grab_focus();
- obj.imp().scrolled_window.vadjustment().set_value(0.0);
- }
- });
+ self.obj().connect_visible_notify(|obj| {
+ if obj.is_visible() {
+ obj.imp().search_entry.set_text("");
+ obj.imp().search_entry.grab_focus();
+ obj.imp().scrolled_window.vadjustment().set_value(0.0);
+ }
+ });
self.obj().search("");
}
@@ -79,7 +76,7 @@ mod imp {
}
}
- impl WidgetImpl for MusicusInstrumentSelectorPopover {
+ impl WidgetImpl for InstrumentSelectorPopover {
// TODO: Fix focus.
fn focus(&self, direction_type: gtk::DirectionType) -> bool {
if direction_type == gtk::DirectionType::Down {
@@ -90,17 +87,17 @@ mod imp {
}
}
- impl PopoverImpl for MusicusInstrumentSelectorPopover {}
+ impl PopoverImpl for InstrumentSelectorPopover {}
}
glib::wrapper! {
- pub struct MusicusInstrumentSelectorPopover(ObjectSubclass)
+ pub struct InstrumentSelectorPopover(ObjectSubclass)
@extends gtk::Widget, gtk::Popover;
}
#[gtk::template_callbacks]
-impl MusicusInstrumentSelectorPopover {
- pub fn new(library: &MusicusLibrary) -> Self {
+impl InstrumentSelectorPopover {
+ pub fn new(library: &Library) -> Self {
glib::Object::builder().property("library", library).build()
}
@@ -156,7 +153,7 @@ impl MusicusInstrumentSelectorPopover {
imp.list_box.remove_all();
for instrument in &instruments {
- let row = MusicusActivatableRow::new(
+ let row = ActivatableRow::new(
>k::Label::builder()
.label(instrument.to_string())
.halign(gtk::Align::Start)
@@ -167,7 +164,7 @@ impl MusicusInstrumentSelectorPopover {
let instrument = instrument.clone();
let obj = self.clone();
- row.connect_activated(move |_: &MusicusActivatableRow| {
+ row.connect_activated(move |_: &ActivatableRow| {
obj.select(instrument.clone());
});
@@ -183,9 +180,9 @@ impl MusicusInstrumentSelectorPopover {
.build(),
);
- let create_row = MusicusActivatableRow::new(&create_box);
+ let create_row = ActivatableRow::new(&create_box);
let obj = self.clone();
- create_row.connect_activated(move |_: &MusicusActivatableRow| {
+ create_row.connect_activated(move |_: &ActivatableRow| {
obj.create();
});
diff --git a/src/selector/mod.rs b/src/selector/mod.rs
new file mode 100644
index 0000000..2ccddb5
--- /dev/null
+++ b/src/selector/mod.rs
@@ -0,0 +1,7 @@
+pub mod ensemble;
+pub mod instrument;
+pub mod performer_role;
+pub mod person;
+pub mod recording;
+pub mod role;
+pub mod work;
diff --git a/src/editor/performer_role_selector_popover.rs b/src/selector/performer_role.rs
similarity index 83%
rename from src/editor/performer_role_selector_popover.rs
rename to src/selector/performer_role.rs
index ce1a7cb..02a4488 100644
--- a/src/editor/performer_role_selector_popover.rs
+++ b/src/selector/performer_role.rs
@@ -1,7 +1,4 @@
-use crate::{
- db::models::{Instrument, Role},
- library::MusicusLibrary,
-};
+use std::cell::{OnceCell, RefCell};
use gettextrs::gettext;
use gtk::{
@@ -12,19 +9,21 @@ use gtk::{
};
use once_cell::sync::Lazy;
-use std::cell::{OnceCell, RefCell};
-
-use super::activatable_row::MusicusActivatableRow;
+use crate::{
+ activatable_row::ActivatableRow,
+ db::models::{Instrument, Role},
+ library::Library,
+};
mod imp {
use super::*;
#[derive(Debug, Default, gtk::CompositeTemplate, Properties)]
- #[properties(wrapper_type = super::MusicusPerformerRoleSelectorPopover)]
- #[template(file = "data/ui/performer_role_selector_popover.blp")]
- pub struct MusicusPerformerRoleSelectorPopover {
+ #[properties(wrapper_type = super::PerformerRoleSelectorPopover)]
+ #[template(file = "data/ui/selector/performer_role.blp")]
+ pub struct PerformerRoleSelectorPopover {
#[property(get, construct_only)]
- pub library: OnceCell,
+ pub library: OnceCell,
pub roles: RefCell>,
pub instruments: RefCell>,
@@ -50,9 +49,9 @@ mod imp {
}
#[glib::object_subclass]
- impl ObjectSubclass for MusicusPerformerRoleSelectorPopover {
+ impl ObjectSubclass for PerformerRoleSelectorPopover {
const NAME: &'static str = "MusicusPerformerRoleSelectorPopover";
- type Type = super::MusicusPerformerRoleSelectorPopover;
+ type Type = super::PerformerRoleSelectorPopover;
type ParentType = gtk::Popover;
fn class_init(klass: &mut Self::Class) {
@@ -66,20 +65,18 @@ mod imp {
}
#[glib::derived_properties]
- impl ObjectImpl for MusicusPerformerRoleSelectorPopover {
+ impl ObjectImpl for PerformerRoleSelectorPopover {
fn constructed(&self) {
self.parent_constructed();
- self.obj().connect_visible_notify(
- |obj: &super::MusicusPerformerRoleSelectorPopover| {
- if obj.is_visible() {
- obj.imp().stack.set_visible_child(&*obj.imp().role_view);
- obj.imp().role_search_entry.set_text("");
- obj.imp().role_search_entry.grab_focus();
- obj.imp().role_scrolled_window.vadjustment().set_value(0.0);
- }
- },
- );
+ self.obj().connect_visible_notify(|obj| {
+ if obj.is_visible() {
+ obj.imp().stack.set_visible_child(&*obj.imp().role_view);
+ obj.imp().role_search_entry.set_text("");
+ obj.imp().role_search_entry.grab_focus();
+ obj.imp().role_scrolled_window.vadjustment().set_value(0.0);
+ }
+ });
self.obj().search_roles("");
}
@@ -99,7 +96,7 @@ mod imp {
}
}
- impl WidgetImpl for MusicusPerformerRoleSelectorPopover {
+ impl WidgetImpl for PerformerRoleSelectorPopover {
// TODO: Fix focus.
fn focus(&self, direction_type: gtk::DirectionType) -> bool {
if direction_type == gtk::DirectionType::Down {
@@ -114,17 +111,17 @@ mod imp {
}
}
- impl PopoverImpl for MusicusPerformerRoleSelectorPopover {}
+ impl PopoverImpl for PerformerRoleSelectorPopover {}
}
glib::wrapper! {
- pub struct MusicusPerformerRoleSelectorPopover(ObjectSubclass)
+ pub struct PerformerRoleSelectorPopover(ObjectSubclass)
@extends gtk::Widget, gtk::Popover;
}
#[gtk::template_callbacks]
-impl MusicusPerformerRoleSelectorPopover {
- pub fn new(library: &MusicusLibrary) -> Self {
+impl PerformerRoleSelectorPopover {
+ pub fn new(library: &Library) -> Self {
glib::Object::builder().property("library", library).build()
}
@@ -204,7 +201,7 @@ impl MusicusPerformerRoleSelectorPopover {
imp.role_list.remove_all();
for role in &roles {
- let row = MusicusActivatableRow::new(
+ let row = ActivatableRow::new(
>k::Label::builder()
.label(role.to_string())
.halign(gtk::Align::Start)
@@ -216,7 +213,7 @@ impl MusicusPerformerRoleSelectorPopover {
let role = role.clone();
let obj = self.clone();
- row.connect_activated(move |_: &MusicusActivatableRow| {
+ row.connect_activated(move |_: &ActivatableRow| {
obj.select_role(role.clone());
});
@@ -232,9 +229,9 @@ impl MusicusPerformerRoleSelectorPopover {
.build(),
);
- let create_row = MusicusActivatableRow::new(&create_box);
+ let create_row = ActivatableRow::new(&create_box);
let obj = self.clone();
- create_row.connect_activated(move |_: &MusicusActivatableRow| {
+ create_row.connect_activated(move |_: &ActivatableRow| {
obj.create_role();
});
@@ -256,7 +253,7 @@ impl MusicusPerformerRoleSelectorPopover {
imp.instrument_list.remove_all();
for instrument in &instruments {
- let row = MusicusActivatableRow::new(
+ let row = ActivatableRow::new(
>k::Label::builder()
.label(instrument.to_string())
.halign(gtk::Align::Start)
@@ -268,7 +265,7 @@ impl MusicusPerformerRoleSelectorPopover {
let instrument = instrument.clone();
let obj = self.clone();
- row.connect_activated(move |_: &MusicusActivatableRow| {
+ row.connect_activated(move |_: &ActivatableRow| {
obj.select_instrument(instrument.clone());
});
@@ -284,9 +281,9 @@ impl MusicusPerformerRoleSelectorPopover {
.build(),
);
- let create_row = MusicusActivatableRow::new(&create_box);
+ let create_row = ActivatableRow::new(&create_box);
let obj = self.clone();
- create_row.connect_activated(move |_: &MusicusActivatableRow| {
+ create_row.connect_activated(move |_: &ActivatableRow| {
obj.create_instrument();
});
diff --git a/src/editor/person_selector_popover.rs b/src/selector/person.rs
similarity index 76%
rename from src/editor/person_selector_popover.rs
rename to src/selector/person.rs
index e7ee69b..aaf8fa2 100644
--- a/src/editor/person_selector_popover.rs
+++ b/src/selector/person.rs
@@ -1,4 +1,4 @@
-use crate::{db::models::Person, library::MusicusLibrary};
+use std::cell::{OnceCell, RefCell};
use gettextrs::gettext;
use gtk::{
@@ -8,19 +8,17 @@ use gtk::{
};
use once_cell::sync::Lazy;
-use std::cell::{OnceCell, RefCell};
-
-use super::activatable_row::MusicusActivatableRow;
+use crate::{activatable_row::ActivatableRow, db::models::Person, library::Library};
mod imp {
use super::*;
#[derive(Debug, Default, gtk::CompositeTemplate, Properties)]
- #[properties(wrapper_type = super::MusicusPersonSelectorPopover)]
- #[template(file = "data/ui/person_selector_popover.blp")]
- pub struct MusicusPersonSelectorPopover {
+ #[properties(wrapper_type = super::PersonSelectorPopover)]
+ #[template(file = "data/ui/selector/person.blp")]
+ pub struct PersonSelectorPopover {
#[property(get, construct_only)]
- pub library: OnceCell