refactor remove template for dock window

This commit is contained in:
Ashley Wulber 2021-12-30 19:01:59 -05:00
parent 71273ec430
commit 2b8e462c9d
3 changed files with 124 additions and 181 deletions

View file

@ -1,31 +1,24 @@
use std::cell::RefCell;
use std::rc::Rc;
use glib::subclass::InitializingObject;
use glib::SignalHandlerId;
use gtk4::prelude::*;
use gtk4::subclass::prelude::*;
use gtk4::DragSource;
use gtk4::DropTarget;
use gtk4::EventControllerMotion;
use gtk4::ListView;
use gtk4::Revealer;
use gtk4::{gio, glib};
use gtk4::{Box, GestureClick};
use gtk4::{CompositeTemplate, ListView};
use once_cell::sync::OnceCell;
// Object holding the state
#[derive(CompositeTemplate, Default)]
#[template(file = "window.ui")]
#[derive(Default)]
pub struct Window {
#[template_child]
pub saved_app_list_view: TemplateChild<ListView>,
#[template_child]
pub active_app_list_view: TemplateChild<ListView>,
#[template_child]
pub revealer: TemplateChild<Revealer>,
#[template_child]
pub cursor_handle: TemplateChild<Box>,
pub saved_app_list_view: OnceCell<ListView>,
pub active_app_list_view: OnceCell<ListView>,
pub revealer: OnceCell<Revealer>,
pub cursor_handle: OnceCell<Box>,
pub saved_app_model: OnceCell<gio::ListStore>,
pub active_app_model: OnceCell<gio::ListStore>,
pub cursor_motion_controller: OnceCell<EventControllerMotion>,
@ -48,38 +41,10 @@ impl ObjectSubclass for Window {
const NAME: &'static str = "LauncherWindow";
type Type = super::Window;
type ParentType = gtk4::ApplicationWindow;
fn class_init(klass: &mut Self::Class) {
Self::bind_template(klass);
}
fn instance_init(obj: &InitializingObject<Self>) {
obj.init_template();
}
}
// Trait shared by all GObjects
impl ObjectImpl for Window {
fn constructed(&self, obj: &Self::Type) {
// Call "constructed" on parent
self.parent_constructed(obj);
// Setup
obj.setup_model();
obj.setup_motion_controller();
obj.setup_click_controller();
obj.setup_drop_target();
obj.setup_drag_source();
obj.restore_saved_apps();
obj.setup_callbacks();
// obj.setup_window_callbacks();
// obj.setup_saved_list_callbacks();
// obj.setup_active_list_callbacks();
// obj.setup_drag_callbacks();
obj.setup_click_callbacks();
obj.setup_factory();
}
}
impl ObjectImpl for Window {}
// Trait shared by all widgets
impl WidgetImpl for Window {}