Add CSS support and tweak styles a bit
This commit is contained in:
parent
c656ea5311
commit
b09a392351
2 changed files with 14 additions and 2 deletions
4
css/style.css
Normal file
4
css/style.css
Normal file
|
@ -0,0 +1,4 @@
|
|||
.sample-list-view row {
|
||||
margin: 2px 5px;
|
||||
border-radius: 7px;
|
||||
}
|
12
src/main.rs
12
src/main.rs
|
@ -1,4 +1,5 @@
|
|||
use diesel::prelude::*;
|
||||
use gtk::gdk::Display;
|
||||
use gtk::glib::BoxedAnyObject;
|
||||
use gtk::prelude::*;
|
||||
use relm4::{factory::FactoryVecDeque, prelude::*};
|
||||
|
@ -53,12 +54,11 @@ impl SimpleComponent for AppModel {
|
|||
},
|
||||
gtk::Box {
|
||||
set_orientation: gtk::Orientation::Vertical,
|
||||
set_spacing: 5,
|
||||
set_margin_all: 5,
|
||||
set_hexpand: true,
|
||||
|
||||
gtk::ScrolledWindow {
|
||||
set_vexpand: true,
|
||||
set_css_classes: &["sample-list-view"],
|
||||
gtk::ColumnView {
|
||||
set_model: Some(&model.samples),
|
||||
append_column = >k::ColumnViewColumn {
|
||||
|
@ -84,6 +84,7 @@ impl SimpleComponent for AppModel {
|
|||
|
||||
gtk::Box {
|
||||
set_height_request: 100,
|
||||
set_margin_all: 5,
|
||||
gtk::Label {
|
||||
#[watch]
|
||||
set_label: "Sample playback",
|
||||
|
@ -178,8 +179,15 @@ impl SimpleComponent for AppModel {
|
|||
}
|
||||
}
|
||||
|
||||
fn load_css() {
|
||||
let provider = gtk::CssProvider::new();
|
||||
provider.load_from_data(include_str!("../css/style.css"));
|
||||
gtk::style_context_add_provider_for_display(&Display::default().expect("Could not connect to a display."), &provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let app = RelmApp::new("relm.test.simple_manual");
|
||||
relm4::main_application().connect_startup(|_| load_css());
|
||||
relm4_icons::initialize_icons();
|
||||
app.run::<AppModel>(());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue