Replace most unnecessary frames with CSS classes

This commit is contained in:
Elias Projahn 2022-04-07 12:39:50 +02:00
parent f2d99d2316
commit 3ae5727f39
24 changed files with 328 additions and 376 deletions

View file

@ -47,8 +47,6 @@
</child> </child>
</object> </object>
</child> </child>
<child>
<object class="GtkFrame">
<child> <child>
<object class="GtkStack" id="matching_stack"> <object class="GtkStack" id="matching_stack">
<property name="transition-type">crossfade</property> <property name="transition-type">crossfade</property>
@ -71,6 +69,9 @@
</child> </child>
</object> </object>
</child> </child>
<style>
<class name="boxed-list" />
</style>
</object> </object>
</property> </property>
</object> </object>
@ -94,6 +95,9 @@
</child> </child>
</object> </object>
</child> </child>
<style>
<class name="boxed-list" />
</style>
</object> </object>
</property> </property>
</object> </object>
@ -110,6 +114,9 @@
<property name="title" translatable="yes">No matching metadata found</property> <property name="title" translatable="yes">No matching metadata found</property>
</object> </object>
</child> </child>
<style>
<class name="boxed-list" />
</style>
</object> </object>
</property> </property>
</object> </object>
@ -120,14 +127,15 @@
<property name="child"> <property name="child">
<object class="GtkListBox" id="matching_list"> <object class="GtkListBox" id="matching_list">
<property name="selection-mode">none</property> <property name="selection-mode">none</property>
<style>
<class name="boxed-list" />
</style>
</object> </object>
</property> </property>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
</object>
</child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel">
<property name="halign">start</property> <property name="halign">start</property>
@ -139,8 +147,6 @@
</attributes> </attributes>
</object> </object>
</child> </child>
<child>
<object class="GtkFrame">
<child> <child>
<object class="GtkListBox"> <object class="GtkListBox">
<property name="selection-mode">none</property> <property name="selection-mode">none</property>
@ -170,8 +176,9 @@
</child> </child>
</object> </object>
</child> </child>
</object> <style>
</child> <class name="boxed-list" />
</style>
</object> </object>
</child> </child>
</object> </object>

View file

@ -64,8 +64,6 @@
</attributes> </attributes>
</object> </object>
</child> </child>
<child>
<object class="GtkFrame">
<child> <child>
<object class="GtkListBox"> <object class="GtkListBox">
<property name="selection-mode">none</property> <property name="selection-mode">none</property>
@ -82,8 +80,9 @@
</child> </child>
</object> </object>
</child> </child>
</object> <style>
</child> <class name="boxed-list" />
</style>
</object> </object>
</child> </child>
<child> <child>

View file

@ -43,9 +43,6 @@
<property name="margin-bottom">12</property> <property name="margin-bottom">12</property>
<property name="maximum-size">500</property> <property name="maximum-size">500</property>
<property name="tightening-threshold">300</property> <property name="tightening-threshold">300</property>
<child>
<object class="GtkFrame">
<property name="valign">start</property>
<child> <child>
<object class="GtkListBox"> <object class="GtkListBox">
<property name="selection-mode">none</property> <property name="selection-mode">none</property>
@ -95,8 +92,9 @@
</child> </child>
</object> </object>
</child> </child>
</object> <style>
</child> <class name="boxed-list" />
</style>
</object> </object>
</child> </child>
</object> </object>

View file

@ -44,7 +44,7 @@
<property name="margin-bottom">12</property> <property name="margin-bottom">12</property>
<property name="maximum-size">800</property> <property name="maximum-size">800</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox" id="content">
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<child> <child>
@ -144,10 +144,6 @@
</child> </child>
</object> </object>
</child> </child>
<child>
<object class="GtkFrame" id="frame">
</object>
</child>
</object> </object>
</child> </child>
</object> </object>

View file

@ -68,8 +68,6 @@
</attributes> </attributes>
</object> </object>
</child> </child>
<child>
<object class="GtkFrame">
<child> <child>
<object class="GtkListBox"> <object class="GtkListBox">
<property name="selection-mode">none</property> <property name="selection-mode">none</property>
@ -99,8 +97,9 @@
</child> </child>
</object> </object>
</child> </child>
</object> <style>
</child> <class name="boxed-list" />
</style>
</object> </object>
</child> </child>
<child> <child>

View file

@ -34,8 +34,5 @@
</child> </child>
</object> </object>
</child> </child>
<child>
<object class="GtkFrame" id="frame"/>
</child>
</object> </object>
</interface> </interface>

View file

@ -93,12 +93,9 @@
<property name="height-request">200</property> <property name="height-request">200</property>
<property name="vexpand">true</property> <property name="vexpand">true</property>
<child> <child>
<object class="AdwClamp"> <object class="AdwClamp" id="clamp">
<property name="maximum-size">500</property> <property name="maximum-size">500</property>
<property name="tightening-threshold">300</property> <property name="tightening-threshold">300</property>
<child>
<object class="GtkFrame" id="frame">
<property name="valign">start</property>
<property name="margin-start">6</property> <property name="margin-start">6</property>
<property name="margin-end">6</property> <property name="margin-end">6</property>
<property name="margin-top">12</property> <property name="margin-top">12</property>
@ -106,8 +103,6 @@
</object> </object>
</child> </child>
</object> </object>
</child>
</object>
</property> </property>
</object> </object>
</child> </child>

View file

@ -35,10 +35,7 @@
<object class="GtkScrolledWindow"> <object class="GtkScrolledWindow">
<property name="vexpand">True</property> <property name="vexpand">True</property>
<child> <child>
<object class="AdwClamp"> <object class="AdwClamp" id="clamp">
<child>
<object class="GtkFrame" id="parts_frame">
<property name="valign">start</property>
<property name="margin-top">12</property> <property name="margin-top">12</property>
<property name="margin-start">6</property> <property name="margin-start">6</property>
<property name="margin-end">6</property> <property name="margin-end">6</property>
@ -48,6 +45,4 @@
</object> </object>
</child> </child>
</object> </object>
</child>
</object>
</interface> </interface>

View file

@ -36,10 +36,7 @@
<object class="GtkScrolledWindow"> <object class="GtkScrolledWindow">
<property name="vexpand">True</property> <property name="vexpand">True</property>
<child> <child>
<object class="AdwClamp"> <object class="AdwClamp" id="clamp">
<child>
<object class="GtkFrame" id="tracks_frame">
<property name="valign">start</property>
<property name="margin-top">12</property> <property name="margin-top">12</property>
<property name="margin-start">6</property> <property name="margin-start">6</property>
<property name="margin-end">6</property> <property name="margin-end">6</property>
@ -49,6 +46,4 @@
</object> </object>
</child> </child>
</object> </object>
</child>
</object>
</interface> </interface>

View file

@ -54,8 +54,6 @@
</attributes> </attributes>
</object> </object>
</child> </child>
<child>
<object class="GtkFrame">
<child> <child>
<object class="GtkListBox"> <object class="GtkListBox">
<property name="selection-mode">none</property> <property name="selection-mode">none</property>
@ -72,8 +70,9 @@
</child> </child>
</object> </object>
</child> </child>
</object> <style>
</child> <class name="boxed-list" />
</style>
</object> </object>
</child> </child>
<child> <child>

View file

@ -68,8 +68,6 @@
</attributes> </attributes>
</object> </object>
</child> </child>
<child>
<object class="GtkFrame">
<child> <child>
<object class="GtkListBox"> <object class="GtkListBox">
<property name="selection-mode">none</property> <property name="selection-mode">none</property>
@ -99,8 +97,9 @@
</child> </child>
</object> </object>
</child> </child>
</object> <style>
</child> <class name="boxed-list" />
</style>
</object> </object>
</child> </child>
<child> <child>

View file

@ -47,9 +47,6 @@
<property name="margin-bottom">12</property> <property name="margin-bottom">12</property>
<property name="maximum-size">500</property> <property name="maximum-size">500</property>
<property name="tightening-threshold">300</property> <property name="tightening-threshold">300</property>
<child>
<object class="GtkFrame">
<property name="valign">start</property>
<child> <child>
<object class="GtkListBox"> <object class="GtkListBox">
<property name="selection-mode">none</property> <property name="selection-mode">none</property>
@ -66,8 +63,9 @@
</child> </child>
</object> </object>
</child> </child>
</object> <style>
</child> <class name="boxed-list" />
</style>
</object> </object>
</child> </child>
</object> </object>

View file

@ -26,6 +26,7 @@ impl Screen<Option<Ensemble>, Ensemble> for EnsembleEditor {
let list = gtk::ListBoxBuilder::new() let list = gtk::ListBoxBuilder::new()
.selection_mode(gtk::SelectionMode::None) .selection_mode(gtk::SelectionMode::None)
.css_classes(vec![String::from("boxed-list")])
.build(); .build();
let name = EntryRow::new(&gettext("Name")); let name = EntryRow::new(&gettext("Name"));

View file

@ -26,6 +26,7 @@ impl Screen<Option<Instrument>, Instrument> for InstrumentEditor {
let list = gtk::ListBoxBuilder::new() let list = gtk::ListBoxBuilder::new()
.selection_mode(gtk::SelectionMode::None) .selection_mode(gtk::SelectionMode::None)
.css_classes(vec![String::from("boxed-list")])
.build(); .build();
let name = EntryRow::new(&gettext("Name")); let name = EntryRow::new(&gettext("Name"));

View file

@ -31,6 +31,7 @@ impl Screen<Option<Performance>, Performance> for PerformanceEditor {
let performer_list = gtk::ListBoxBuilder::new() let performer_list = gtk::ListBoxBuilder::new()
.selection_mode(gtk::SelectionMode::None) .selection_mode(gtk::SelectionMode::None)
.css_classes(vec![String::from("boxed-list")])
.build(); .build();
let person_row = ButtonRow::new("Person", "Select"); let person_row = ButtonRow::new("Person", "Select");
@ -46,6 +47,7 @@ impl Screen<Option<Performance>, Performance> for PerformanceEditor {
let role_list = gtk::ListBoxBuilder::new() let role_list = gtk::ListBoxBuilder::new()
.selection_mode(gtk::SelectionMode::None) .selection_mode(gtk::SelectionMode::None)
.css_classes(vec![String::from("boxed-list")])
.build(); .build();
let reset_role_button = gtk::ButtonBuilder::new() let reset_role_button = gtk::ButtonBuilder::new()

View file

@ -27,6 +27,7 @@ impl Screen<Option<Person>, Person> for PersonEditor {
let list = gtk::ListBoxBuilder::new() let list = gtk::ListBoxBuilder::new()
.selection_mode(gtk::SelectionMode::None) .selection_mode(gtk::SelectionMode::None)
.css_classes(vec![String::from("boxed-list")])
.build(); .build();
let first_name = EntryRow::new(&gettext("First name")); let first_name = EntryRow::new(&gettext("First name"));

View file

@ -141,6 +141,8 @@ impl MediumPreview {
let list = gtk::ListBoxBuilder::new() let list = gtk::ListBoxBuilder::new()
.selection_mode(gtk::SelectionMode::None) .selection_mode(gtk::SelectionMode::None)
.margin_bottom(12)
.css_classes(vec![String::from("boxed-list")])
.build(); .build();
let header = adw::ActionRowBuilder::new() let header = adw::ActionRowBuilder::new()
@ -152,10 +154,7 @@ impl MediumPreview {
list.append(&header); list.append(&header);
if let Some(list) = &last_list { if let Some(list) = &last_list {
let frame = gtk::FrameBuilder::new().margin_bottom(12).build(); self.medium_box.append(list);
frame.set_child(Some(list));
self.medium_box.append(&frame);
} }
last_list = Some(list); last_list = Some(list);

View file

@ -27,13 +27,14 @@ impl Screen<(Recording, Vec<usize>), Vec<usize>> for TrackEditor {
get_widget!(builder, gtk::Box, widget); get_widget!(builder, gtk::Box, widget);
get_widget!(builder, gtk::Button, back_button); get_widget!(builder, gtk::Button, back_button);
get_widget!(builder, gtk::Button, select_button); get_widget!(builder, gtk::Button, select_button);
get_widget!(builder, gtk::Frame, parts_frame); get_widget!(builder, adw::Clamp, clamp);
let parts_list = gtk::ListBox::new(); let parts_list = gtk::ListBoxBuilder::new()
parts_list.set_selection_mode(gtk::SelectionMode::None); .selection_mode(gtk::SelectionMode::None)
parts_list.set_vexpand(false); .css_classes(vec![String::from("boxed-list")])
parts_list.show(); .build();
parts_frame.set_child(Some(&parts_list));
clamp.set_child(Some(&parts_list));
let this = Rc::new(Self { let this = Rc::new(Self {
handle, handle,

View file

@ -27,13 +27,14 @@ impl Screen<Arc<ImportSession>, Vec<usize>> for TrackSelector {
get_widget!(builder, gtk::Box, widget); get_widget!(builder, gtk::Box, widget);
get_widget!(builder, gtk::Button, back_button); get_widget!(builder, gtk::Button, back_button);
get_widget!(builder, gtk::Button, select_button); get_widget!(builder, gtk::Button, select_button);
get_widget!(builder, gtk::Frame, tracks_frame); get_widget!(builder, adw::Clamp, clamp);
let track_list = gtk::ListBox::new(); let track_list = gtk::ListBoxBuilder::new()
track_list.set_selection_mode(gtk::SelectionMode::None); .selection_mode(gtk::SelectionMode::None)
track_list.set_vexpand(false); .css_classes(vec![String::from("boxed-list")])
track_list.show(); .build();
tracks_frame.set_child(Some(&track_list));
clamp.set_child(Some(&track_list));
let this = Rc::new(Self { let this = Rc::new(Self {
handle, handle,

View file

@ -48,7 +48,7 @@ impl Screen<(), ()> for MainScreen {
widget.insert_action_group("widget", Some(&actions)); widget.insert_action_group("widget", Some(&actions));
let poe_list = List::new(); let poe_list = List::new();
poe_list.widget.add_css_class("navigation-sidebar"); poe_list.widget.set_css_classes(&["navigation-sidebar"]);
poe_list.enable_selection(); poe_list.enable_selection();
let navigator = Navigator::new(Rc::clone(&handle.backend), &handle.window, &empty_screen); let navigator = Navigator::new(Rc::clone(&handle.backend), &handle.window, &empty_screen);

View file

@ -7,11 +7,9 @@ use musicus_backend::db::Track;
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};
use std::rc::Rc; use std::rc::Rc;
/// Elements for visually representing the playlist. /// A playable track within the playlist.
#[derive(Clone)] #[derive(Clone)]
enum ListItem { struct ListItem {
/// A playable track.
Track {
/// Index within the playlist. /// Index within the playlist.
index: usize, index: usize,
@ -20,10 +18,6 @@ enum ListItem {
/// Whether this is the currently played track. /// Whether this is the currently played track.
playing: bool, playing: bool,
},
/// A separator shown between recordings.
Separator,
} }
pub struct PlayerScreen { pub struct PlayerScreen {
@ -52,6 +46,7 @@ impl Screen<(), ()> for PlayerScreen {
get_widget!(builder, gtk::Box, widget); get_widget!(builder, gtk::Box, widget);
get_widget!(builder, gtk::Button, back_button); get_widget!(builder, gtk::Button, back_button);
get_widget!(builder, gtk::Box, content);
get_widget!(builder, gtk::Label, title_label); get_widget!(builder, gtk::Label, title_label);
get_widget!(builder, gtk::Label, subtitle_label); get_widget!(builder, gtk::Label, subtitle_label);
get_widget!(builder, gtk::Button, previous_button); get_widget!(builder, gtk::Button, previous_button);
@ -64,10 +59,9 @@ impl Screen<(), ()> for PlayerScreen {
get_widget!(builder, gtk::Label, duration_label); get_widget!(builder, gtk::Label, duration_label);
get_widget!(builder, gtk::Image, play_image); get_widget!(builder, gtk::Image, play_image);
get_widget!(builder, gtk::Image, pause_image); get_widget!(builder, gtk::Image, pause_image);
get_widget!(builder, gtk::Frame, frame);
let list = List::new(); let list = List::new();
frame.set_child(Some(&list.widget)); content.append(&list.widget);
let event_controller = gtk::EventControllerLegacy::new(); let event_controller = gtk::EventControllerLegacy::new();
position_scale.add_controller(&event_controller); position_scale.add_controller(&event_controller);
@ -209,22 +203,9 @@ impl Screen<(), ()> for PlayerScreen {
this.list this.list
.set_make_widget_cb(clone!(@weak this => @default-panic, move |index| { .set_make_widget_cb(clone!(@weak this => @default-panic, move |index| {
let widget = match this.items.borrow()[index] { let item = &this.items.borrow()[index];
ListItem::Track {index, first, playing} => { let track = &this.playlist.borrow()[item.index];
let track = &this.playlist.borrow()[index]; TrackRow::new(track, item.first, item.playing).get_widget()
TrackRow::new(track, first, playing).get_widget()
}
ListItem::Separator => {
gtk::ListBoxRowBuilder::new()
.selectable(false)
.activatable(false)
.child(&gtk::Separator::new(gtk::Orientation::Horizontal))
.build()
.upcast()
}
};
widget
})); }));
this.list this.list
@ -232,9 +213,7 @@ impl Screen<(), ()> for PlayerScreen {
.connect_row_activated(clone!(@weak this => move |_, row| { .connect_row_activated(clone!(@weak this => move |_, row| {
let list_index = row.index(); let list_index = row.index();
let list_item = this.items.borrow()[list_index as usize].clone(); let list_item = this.items.borrow()[list_index as usize].clone();
if let ListItem::Track {index, ..} = list_item { this.handle.backend.pl().set_track(list_item.index).unwrap();
this.handle.backend.pl().set_track(index).unwrap();
};
})); }));
player.send_data(); player.send_data();
@ -249,33 +228,22 @@ impl PlayerScreen {
let playlist = self.playlist.borrow(); let playlist = self.playlist.borrow();
let current_track = self.current_track.get(); let current_track = self.current_track.get();
let mut first = true;
let mut items = Vec::new(); let mut items = Vec::new();
let mut last_recording_id = ""; let mut last_recording_id = "";
for (index, track) in playlist.iter().enumerate() { for (index, track) in playlist.iter().enumerate() {
let first_track = if track.recording.id != last_recording_id { let first_track = if track.recording.id != last_recording_id {
last_recording_id = &track.recording.id; last_recording_id = &track.recording.id;
if !first {
items.push(ListItem::Separator);
} else {
first = false;
}
true true
} else { } else {
false false
}; };
let item = ListItem::Track { items.push(ListItem {
index, index,
first: first_track, first: first_track,
playing: index == current_track, playing: index == current_track,
}; });
items.push(item);
} }
let length = items.len(); let length = items.len();

View file

@ -34,10 +34,10 @@ impl<T> Selector<T> {
get_widget!(builder, gtk::Button, add_button); get_widget!(builder, gtk::Button, add_button);
get_widget!(builder, gtk::SearchEntry, search_entry); get_widget!(builder, gtk::SearchEntry, search_entry);
get_widget!(builder, gtk::Stack, stack); get_widget!(builder, gtk::Stack, stack);
get_widget!(builder, gtk::Frame, frame); get_widget!(builder, adw::Clamp, clamp);
let list = List::new(); let list = List::new();
frame.set_child(Some(&list.widget)); clamp.set_child(Some(&list.widget));
let this = Rc::new(Self { let this = Rc::new(Self {
widget, widget,

View file

@ -27,8 +27,10 @@ impl List {
// let factory = gtk::SignalListItemFactory::new(); // let factory = gtk::SignalListItemFactory::new();
// let widget = gtk::ListView::new(Some(&selection), Some(&factory)); // let widget = gtk::ListView::new(Some(&selection), Some(&factory));
let widget = gtk::ListBox::new(); let widget = gtk::ListBoxBuilder::new()
widget.set_selection_mode(gtk::SelectionMode::None); .selection_mode(gtk::SelectionMode::None)
.css_classes(vec![String::from("boxed-list")])
.build();
let this = Rc::new(Self { let this = Rc::new(Self {
widget, widget,

View file

@ -24,10 +24,9 @@ impl Section {
get_widget!(builder, gtk::Box, title_box); get_widget!(builder, gtk::Box, title_box);
get_widget!(builder, gtk::Label, title_label); get_widget!(builder, gtk::Label, title_label);
get_widget!(builder, gtk::Label, subtitle_label); get_widget!(builder, gtk::Label, subtitle_label);
get_widget!(builder, gtk::Frame, frame);
title_label.set_label(title); title_label.set_label(title);
frame.set_child(Some(&content.get_widget())); widget.append(&content.get_widget());
Self { Self {
widget, widget,