Add title and border to settingbox

Fix padding around window
Add some styling
This commit is contained in:
takotori 2023-11-11 14:34:32 +01:00
parent 179a2b44cc
commit 9f3815476d
12 changed files with 313 additions and 258 deletions

View file

@ -1,19 +1,21 @@
use crate::components::base::settingBoxImpl;
use adw::glib;
use adw::glib::{IsA, Object};
use gtk::prelude::BoxExt;
use glib::subclass::prelude::ObjectSubclassIsExt;
use gtk::prelude::FrameExt;
use gtk::Widget;
glib::wrapper! {
pub struct SettingBox(ObjectSubclass<settingBoxImpl::SettingBox>)
@extends gtk::Box, gtk::Widget,
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
@extends gtk::Frame, gtk::Widget,
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
}
impl SettingBox {
pub fn new(child: &impl IsA<Widget>) -> Self {
pub fn new(child: &impl IsA<Widget>, title: &str) -> Self {
let entry: SettingBox = Object::builder().build();
entry.append(child);
entry.set_child(Some(child));
entry.imp().resetSettingLabel.set_text(title);
entry
}
}

View file

@ -1,17 +1,20 @@
use gtk::{CompositeTemplate, glib};
use gtk::{CompositeTemplate, glib, Label};
use gtk::subclass::prelude::*;
use crate::components::base::settingBox;
#[allow(non_snake_case)]
#[derive(Default, CompositeTemplate)]
#[template(resource = "/org/Xetibo/ReSet/resetSettingBox.ui")]
pub struct SettingBox {}
pub struct SettingBox {
#[template_child]
pub resetSettingLabel: TemplateChild<Label>,
}
#[glib::object_subclass]
impl ObjectSubclass for SettingBox {
const NAME: &'static str = "resetSetting";
const NAME: &'static str = "resetSettingFrame";
type Type = settingBox::SettingBox;
type ParentType = gtk::Box;
type ParentType = gtk::Frame;
fn class_init(klass: &mut Self::Class) {
klass.bind_template();
@ -28,7 +31,7 @@ impl ObjectImpl for SettingBox {
}
}
impl BoxImpl for SettingBox {}
impl FrameImpl for SettingBox {}
impl WidgetImpl for SettingBox {}