Add StatusArea widget
A palceholder, for now.
This commit is contained in:
parent
121c759904
commit
843fba67b1
3 changed files with 59 additions and 0 deletions
56
src/status_area.rs
Normal file
56
src/status_area.rs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
use cascade::cascade;
|
||||
use gtk4::{
|
||||
glib,
|
||||
prelude::*,
|
||||
subclass::prelude::*,
|
||||
};
|
||||
|
||||
use crate::deref_cell::DerefCell;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct StatusAreaInner {
|
||||
box_: DerefCell<gtk4::Box>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for StatusAreaInner {
|
||||
const NAME: &'static str = "S76StatusArea";
|
||||
type ParentType = gtk4::Widget;
|
||||
type Type = StatusArea;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
klass.set_layout_manager_type::<gtk4::BinLayout>();
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for StatusAreaInner {
|
||||
fn constructed(&self, obj: &StatusArea) {
|
||||
let box_ = cascade! {
|
||||
gtk4::Box::new(gtk4::Orientation::Horizontal, 0);
|
||||
..set_parent(obj);
|
||||
};
|
||||
|
||||
self.box_.set(box_);
|
||||
}
|
||||
|
||||
fn dispose(&self, _obj: &StatusArea) {
|
||||
self.box_.unparent();
|
||||
}
|
||||
}
|
||||
|
||||
impl WidgetImpl for StatusAreaInner {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct StatusArea(ObjectSubclass<StatusAreaInner>)
|
||||
@extends gtk4::Widget;
|
||||
}
|
||||
|
||||
impl StatusArea {
|
||||
pub fn new() -> Self {
|
||||
glib::Object::new(&[]).unwrap()
|
||||
}
|
||||
|
||||
fn inner(&self) -> &StatusAreaInner {
|
||||
StatusAreaInner::from_instance(self)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue