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
|
|
@ -2,6 +2,7 @@ use gtk4::{gdk, glib, prelude::*};
|
|||
|
||||
mod deref_cell;
|
||||
mod mpris;
|
||||
mod status_area;
|
||||
mod time_button;
|
||||
mod window;
|
||||
mod x;
|
||||
|
|
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ use cascade::cascade;
|
|||
use glib::clone;
|
||||
use gtk4::{gdk, glib, prelude::*};
|
||||
|
||||
use crate::status_area::StatusArea;
|
||||
use crate::time_button::TimeButton;
|
||||
use crate::x;
|
||||
|
||||
|
|
@ -14,6 +15,7 @@ pub fn window(monitor: gdk::Monitor) -> gtk4::Window {
|
|||
..append(>k4::Button::with_label("Applications"));
|
||||
}));
|
||||
..set_center_widget(Some(&TimeButton::new()));
|
||||
..set_end_widget(Some(&StatusArea::new()));
|
||||
};
|
||||
|
||||
let window = cascade! {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue