2021-12-29 17:31:01 -05:00
|
|
|
use std::cell::RefCell;
|
|
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
2021-12-29 22:32:10 -05:00
|
|
|
use glib::SignalHandlerId;
|
2021-12-30 16:54:35 -05:00
|
|
|
use gtk4::subclass::prelude::*;
|
2021-12-27 17:59:49 -05:00
|
|
|
use gtk4::DragSource;
|
2021-12-16 09:38:20 -05:00
|
|
|
use gtk4::DropTarget;
|
2021-12-14 16:36:28 -05:00
|
|
|
use gtk4::EventControllerMotion;
|
2021-12-30 19:01:59 -05:00
|
|
|
use gtk4::ListView;
|
2021-12-14 16:36:28 -05:00
|
|
|
use gtk4::Revealer;
|
2021-12-30 16:54:35 -05:00
|
|
|
use gtk4::{gio, glib};
|
2021-12-30 15:35:10 -05:00
|
|
|
use gtk4::{Box, GestureClick};
|
2021-12-14 11:53:18 -05:00
|
|
|
use once_cell::sync::OnceCell;
|
|
|
|
|
|
|
|
|
|
// Object holding the state
|
2021-12-30 19:01:59 -05:00
|
|
|
#[derive(Default)]
|
2021-12-14 11:53:18 -05:00
|
|
|
pub struct Window {
|
2021-12-30 19:01:59 -05:00
|
|
|
pub saved_app_list_view: OnceCell<ListView>,
|
|
|
|
|
pub active_app_list_view: OnceCell<ListView>,
|
|
|
|
|
pub revealer: OnceCell<Revealer>,
|
|
|
|
|
pub cursor_handle: OnceCell<Box>,
|
2021-12-15 14:03:23 -05:00
|
|
|
pub saved_app_model: OnceCell<gio::ListStore>,
|
2021-12-21 13:01:32 -05:00
|
|
|
pub active_app_model: OnceCell<gio::ListStore>,
|
2021-12-30 15:35:10 -05:00
|
|
|
pub cursor_motion_controller: OnceCell<EventControllerMotion>,
|
|
|
|
|
pub saved_click_controller: Rc<OnceCell<GestureClick>>,
|
|
|
|
|
pub active_click_controller: Rc<OnceCell<GestureClick>>,
|
2021-12-16 09:38:20 -05:00
|
|
|
pub drop_controller: OnceCell<DropTarget>,
|
2021-12-27 17:59:49 -05:00
|
|
|
pub saved_drag_source: Rc<OnceCell<DragSource>>,
|
2021-12-30 15:35:10 -05:00
|
|
|
pub active_drag_source: Rc<OnceCell<DragSource>>,
|
2021-12-27 20:19:59 -05:00
|
|
|
pub saved_drag_end_signal: Rc<RefCell<Option<SignalHandlerId>>>,
|
|
|
|
|
pub active_drag_end_signal: Rc<RefCell<Option<SignalHandlerId>>>,
|
|
|
|
|
pub saved_drag_cancel_signal: Rc<RefCell<Option<SignalHandlerId>>>,
|
|
|
|
|
pub active_drag_cancel_signal: Rc<RefCell<Option<SignalHandlerId>>>,
|
2021-12-30 15:35:10 -05:00
|
|
|
pub window_drop_controller: Rc<OnceCell<DropTarget>>,
|
2021-12-14 11:53:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The central trait for subclassing a GObject
|
|
|
|
|
#[glib::object_subclass]
|
|
|
|
|
impl ObjectSubclass for Window {
|
|
|
|
|
// `NAME` needs to match `class` attribute of template
|
2021-12-30 22:23:17 -05:00
|
|
|
const NAME: &'static str = "DockWindow";
|
2021-12-14 11:53:18 -05:00
|
|
|
type Type = super::Window;
|
2021-12-30 16:54:35 -05:00
|
|
|
type ParentType = gtk4::ApplicationWindow;
|
2021-12-14 11:53:18 -05:00
|
|
|
}
|
2021-12-29 17:31:01 -05:00
|
|
|
|
2021-12-14 11:53:18 -05:00
|
|
|
// Trait shared by all GObjects
|
2021-12-30 19:01:59 -05:00
|
|
|
impl ObjectImpl for Window {}
|
2021-12-29 17:31:01 -05:00
|
|
|
|
2021-12-14 11:53:18 -05:00
|
|
|
// Trait shared by all widgets
|
|
|
|
|
impl WidgetImpl for Window {}
|
|
|
|
|
|
|
|
|
|
// Trait shared by all windows
|
|
|
|
|
impl WindowImpl for Window {}
|
|
|
|
|
|
|
|
|
|
// Trait shared by all application
|
|
|
|
|
impl ApplicationWindowImpl for Window {}
|