libcosmic/examples/dock/dock_item/imp.rs

47 lines
1.2 KiB
Rust
Raw Normal View History

2022-01-03 21:33:26 -05:00
use glib::subclass::Signal;
2021-12-30 16:54:35 -05:00
use gtk4::glib;
2022-01-03 21:33:26 -05:00
use gtk4::prelude::*;
2021-12-30 16:54:35 -05:00
use gtk4::subclass::prelude::*;
2022-01-03 21:33:26 -05:00
use once_cell::sync::Lazy;
2021-12-30 17:53:06 -05:00
use std::cell::RefCell;
use std::rc::Rc;
use crate::dock_popover::DockPopover;
2021-12-30 17:53:06 -05:00
#[derive(Debug, Default)]
2021-12-15 11:37:28 -05:00
pub struct DockItem {
2021-12-30 17:53:06 -05:00
pub image: Rc<RefCell<gtk4::Image>>,
pub dots: Rc<RefCell<gtk4::Label>>,
2022-01-03 21:33:26 -05:00
pub item_box: Rc<RefCell<gtk4::Box>>,
pub popover: Rc<RefCell<gtk4::Popover>>,
pub popover_menu: Rc<RefCell<DockPopover>>,
}
#[glib::object_subclass]
2021-12-15 11:37:28 -05:00
impl ObjectSubclass for DockItem {
const NAME: &'static str = "DockItem";
type Type = super::DockItem;
2021-12-30 22:23:17 -05:00
type ParentType = gtk4::Button;
}
2022-01-03 21:33:26 -05:00
impl ObjectImpl for DockItem {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
vec![Signal::builder(
// Signal name
"popover-closed",
// Types of the values which will be sent to the signal handler
&[],
// Type of the value the signal handler sends back
<()>::static_type().into(),
)
.build()]
});
SIGNALS.as_ref()
}
}
2021-12-15 11:37:28 -05:00
impl WidgetImpl for DockItem {}
2021-12-30 22:23:17 -05:00
impl ButtonImpl for DockItem {}