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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -93,12 +93,9 @@
<property name="height-request">200</property>
<property name="vexpand">true</property>
<child>
<object class="AdwClamp">
<object class="AdwClamp" id="clamp">
<property name="maximum-size">500</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-end">6</property>
<property name="margin-top">12</property>
@ -106,8 +103,6 @@
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</child>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -26,6 +26,7 @@ impl Screen<Option<Instrument>, Instrument> for InstrumentEditor {
let list = gtk::ListBoxBuilder::new()
.selection_mode(gtk::SelectionMode::None)
.css_classes(vec![String::from("boxed-list")])
.build();
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()
.selection_mode(gtk::SelectionMode::None)
.css_classes(vec![String::from("boxed-list")])
.build();
let person_row = ButtonRow::new("Person", "Select");
@ -46,6 +47,7 @@ impl Screen<Option<Performance>, Performance> for PerformanceEditor {
let role_list = gtk::ListBoxBuilder::new()
.selection_mode(gtk::SelectionMode::None)
.css_classes(vec![String::from("boxed-list")])
.build();
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()
.selection_mode(gtk::SelectionMode::None)
.css_classes(vec![String::from("boxed-list")])
.build();
let first_name = EntryRow::new(&gettext("First name"));

View file

@ -141,6 +141,8 @@ impl MediumPreview {
let list = gtk::ListBoxBuilder::new()
.selection_mode(gtk::SelectionMode::None)
.margin_bottom(12)
.css_classes(vec![String::from("boxed-list")])
.build();
let header = adw::ActionRowBuilder::new()
@ -152,10 +154,7 @@ impl MediumPreview {
list.append(&header);
if let Some(list) = &last_list {
let frame = gtk::FrameBuilder::new().margin_bottom(12).build();
frame.set_child(Some(list));
self.medium_box.append(&frame);
self.medium_box.append(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::Button, back_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();
parts_list.set_selection_mode(gtk::SelectionMode::None);
parts_list.set_vexpand(false);
parts_list.show();
parts_frame.set_child(Some(&parts_list));
let parts_list = gtk::ListBoxBuilder::new()
.selection_mode(gtk::SelectionMode::None)
.css_classes(vec![String::from("boxed-list")])
.build();
clamp.set_child(Some(&parts_list));
let this = Rc::new(Self {
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::Button, back_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();
track_list.set_selection_mode(gtk::SelectionMode::None);
track_list.set_vexpand(false);
track_list.show();
tracks_frame.set_child(Some(&track_list));
let track_list = gtk::ListBoxBuilder::new()
.selection_mode(gtk::SelectionMode::None)
.css_classes(vec![String::from("boxed-list")])
.build();
clamp.set_child(Some(&track_list));
let this = Rc::new(Self {
handle,

View file

@ -48,7 +48,7 @@ impl Screen<(), ()> for MainScreen {
widget.insert_action_group("widget", Some(&actions));
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();
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::rc::Rc;
/// Elements for visually representing the playlist.
/// A playable track within the playlist.
#[derive(Clone)]
enum ListItem {
/// A playable track.
Track {
struct ListItem {
/// Index within the playlist.
index: usize,
@ -20,10 +18,6 @@ enum ListItem {
/// Whether this is the currently played track.
playing: bool,
},
/// A separator shown between recordings.
Separator,
}
pub struct PlayerScreen {
@ -52,6 +46,7 @@ impl Screen<(), ()> for PlayerScreen {
get_widget!(builder, gtk::Box, widget);
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, subtitle_label);
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::Image, play_image);
get_widget!(builder, gtk::Image, pause_image);
get_widget!(builder, gtk::Frame, frame);
let list = List::new();
frame.set_child(Some(&list.widget));
content.append(&list.widget);
let event_controller = gtk::EventControllerLegacy::new();
position_scale.add_controller(&event_controller);
@ -209,22 +203,9 @@ impl Screen<(), ()> for PlayerScreen {
this.list
.set_make_widget_cb(clone!(@weak this => @default-panic, move |index| {
let widget = match this.items.borrow()[index] {
ListItem::Track {index, first, playing} => {
let track = &this.playlist.borrow()[index];
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
let item = &this.items.borrow()[index];
let track = &this.playlist.borrow()[item.index];
TrackRow::new(track, item.first, item.playing).get_widget()
}));
this.list
@ -232,9 +213,7 @@ impl Screen<(), ()> for PlayerScreen {
.connect_row_activated(clone!(@weak this => move |_, row| {
let list_index = row.index();
let list_item = this.items.borrow()[list_index as usize].clone();
if let ListItem::Track {index, ..} = list_item {
this.handle.backend.pl().set_track(index).unwrap();
};
this.handle.backend.pl().set_track(list_item.index).unwrap();
}));
player.send_data();
@ -249,33 +228,22 @@ impl PlayerScreen {
let playlist = self.playlist.borrow();
let current_track = self.current_track.get();
let mut first = true;
let mut items = Vec::new();
let mut last_recording_id = "";
for (index, track) in playlist.iter().enumerate() {
let first_track = if track.recording.id != last_recording_id {
last_recording_id = &track.recording.id;
if !first {
items.push(ListItem::Separator);
} else {
first = false;
}
true
} else {
false
};
let item = ListItem::Track {
items.push(ListItem {
index,
first: first_track,
playing: index == current_track,
};
items.push(item);
});
}
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::SearchEntry, search_entry);
get_widget!(builder, gtk::Stack, stack);
get_widget!(builder, gtk::Frame, frame);
get_widget!(builder, adw::Clamp, clamp);
let list = List::new();
frame.set_child(Some(&list.widget));
clamp.set_child(Some(&list.widget));
let this = Rc::new(Self {
widget,

View file

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

View file

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