mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
Add new works list
This commit is contained in:
parent
3aceac3d34
commit
96188929d4
2 changed files with 156 additions and 1 deletions
100
res/ui/window.ui
100
res/ui/window.ui
|
|
@ -270,9 +270,107 @@
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="shadow_type">none</property>
|
<property name="shadow_type">none</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkListBox" id="list">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<property name="border_width">18</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="spacing">18</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="work_box">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="spacing">12</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="label" translatable="yes">Works</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="size" value="12288" />
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkFrame">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="shadow_type">in</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkListBox" id="work_list">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="recording_box">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="spacing">12</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="label" translatable="yes">Recordings</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="size" value="12288" />
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkFrame">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="shadow_type">in</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkListBox" id="recording_list">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="height-request">200</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,18 @@ pub struct Window {
|
||||||
db: Rc<Database>,
|
db: Rc<Database>,
|
||||||
leaflet: libhandy::Leaflet,
|
leaflet: libhandy::Leaflet,
|
||||||
persons: RefCell<Vec<Person>>,
|
persons: RefCell<Vec<Person>>,
|
||||||
|
works: RefCell<Vec<WorkDescription>>,
|
||||||
|
recordings: RefCell<Vec<RecordingDescription>>,
|
||||||
sidebar_box: gtk::Box,
|
sidebar_box: gtk::Box,
|
||||||
person_search_entry: gtk::SearchEntry,
|
person_search_entry: gtk::SearchEntry,
|
||||||
person_list: gtk::ListBox,
|
person_list: gtk::ListBox,
|
||||||
stack: gtk::Stack,
|
stack: gtk::Stack,
|
||||||
header: libhandy::HeaderBar,
|
header: libhandy::HeaderBar,
|
||||||
header_menu_button: gtk::MenuButton,
|
header_menu_button: gtk::MenuButton,
|
||||||
|
work_box: gtk::Box,
|
||||||
|
work_list: gtk::ListBox,
|
||||||
|
recording_box: gtk::Box,
|
||||||
|
recording_list: gtk::ListBox,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
|
|
@ -35,6 +41,10 @@ impl Window {
|
||||||
get_widget!(builder, gtk::Stack, stack);
|
get_widget!(builder, gtk::Stack, stack);
|
||||||
get_widget!(builder, libhandy::HeaderBar, header);
|
get_widget!(builder, libhandy::HeaderBar, header);
|
||||||
get_widget!(builder, gtk::MenuButton, header_menu_button);
|
get_widget!(builder, gtk::MenuButton, header_menu_button);
|
||||||
|
get_widget!(builder, gtk::Box, work_box);
|
||||||
|
get_widget!(builder, gtk::ListBox, work_list);
|
||||||
|
get_widget!(builder, gtk::Box, recording_box);
|
||||||
|
get_widget!(builder, gtk::ListBox, recording_list);
|
||||||
|
|
||||||
let db = Rc::new(Database::new("test.sqlite"));
|
let db = Rc::new(Database::new("test.sqlite"));
|
||||||
let persons = db.get_persons();
|
let persons = db.get_persons();
|
||||||
|
|
@ -44,12 +54,18 @@ impl Window {
|
||||||
db: db,
|
db: db,
|
||||||
leaflet: leaflet,
|
leaflet: leaflet,
|
||||||
persons: RefCell::new(persons),
|
persons: RefCell::new(persons),
|
||||||
|
works: RefCell::new(Vec::new()),
|
||||||
|
recordings: RefCell::new(Vec::new()),
|
||||||
sidebar_box: sidebar_box,
|
sidebar_box: sidebar_box,
|
||||||
person_list: person_list,
|
person_list: person_list,
|
||||||
person_search_entry: person_search_entry,
|
person_search_entry: person_search_entry,
|
||||||
stack: stack,
|
stack: stack,
|
||||||
header: header,
|
header: header,
|
||||||
header_menu_button: header_menu_button,
|
header_menu_button: header_menu_button,
|
||||||
|
work_box: work_box,
|
||||||
|
work_list: work_list,
|
||||||
|
recording_box: recording_box,
|
||||||
|
recording_list: recording_list,
|
||||||
});
|
});
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|
@ -202,10 +218,51 @@ impl Window {
|
||||||
|
|
||||||
self.header_menu_button.set_menu_model(Some(&menu));
|
self.header_menu_button.set_menu_model(Some(&menu));
|
||||||
|
|
||||||
|
self.works.replace(self.db.get_work_descriptions(person.id));
|
||||||
|
self.show_works();
|
||||||
|
|
||||||
|
self.show_recordings();
|
||||||
|
|
||||||
self.stack.set_visible_child_name("person_screen");
|
self.stack.set_visible_child_name("person_screen");
|
||||||
self.leaflet.set_visible_child(&self.stack);
|
self.leaflet.set_visible_child(&self.stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn show_works(&self) {
|
||||||
|
for child in self.work_list.get_children() {
|
||||||
|
self.work_list.remove(&child);
|
||||||
|
}
|
||||||
|
|
||||||
|
let works = self.works.borrow();
|
||||||
|
|
||||||
|
if works.is_empty() {
|
||||||
|
self.work_box.hide();
|
||||||
|
} else {
|
||||||
|
self.work_box.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (index, work) in works.iter().enumerate() {
|
||||||
|
let label = gtk::Label::new(Some(&work.title));
|
||||||
|
label.set_halign(gtk::Align::Start);
|
||||||
|
let row = SelectorRow::new(index.try_into().unwrap(), &label);
|
||||||
|
row.show_all();
|
||||||
|
self.work_list.insert(&row, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn show_recordings(&self) {
|
||||||
|
for child in self.recording_list.get_children() {
|
||||||
|
self.recording_list.remove(&child);
|
||||||
|
}
|
||||||
|
|
||||||
|
let recordings = self.recordings.borrow();
|
||||||
|
|
||||||
|
if recordings.is_empty() {
|
||||||
|
self.recording_box.hide();
|
||||||
|
} else {
|
||||||
|
self.recording_box.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn back(&self) {
|
fn back(&self) {
|
||||||
self.stack.set_visible_child_name("empty_screen");
|
self.stack.set_visible_child_name("empty_screen");
|
||||||
self.leaflet.set_visible_child(&self.sidebar_box);
|
self.leaflet.set_visible_child(&self.sidebar_box);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue