mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-04-18 18:48:33 +02:00
65 lines
1.5 KiB
Rust
65 lines
1.5 KiB
Rust
use std::cell::{Cell, RefCell};
|
|
|
|
use glib::subclass::InitializingObject;
|
|
use gtk::{CompositeTemplate, FlowBox, glib, Image, Label, ListBoxRow};
|
|
use gtk::subclass::prelude::*;
|
|
|
|
use crate::components::window::handleSidebarClick::HANDLE_HOME;
|
|
use crate::components::window::sidebarEntry;
|
|
|
|
#[derive(Default)]
|
|
pub enum Categories {
|
|
Connectivity,
|
|
Audio,
|
|
Peripherals,
|
|
#[default]
|
|
Misc,
|
|
}
|
|
|
|
#[allow(non_snake_case)]
|
|
#[derive(CompositeTemplate, Default)]
|
|
#[template(resource = "/org/Xetibo/ReSet/resetSidebarEntry.ui")]
|
|
pub struct SidebarEntry {
|
|
#[template_child]
|
|
pub resetSidebarLabel: TemplateChild<Label>,
|
|
#[template_child]
|
|
pub resetSidebarImage: TemplateChild<Image>,
|
|
pub category: Cell<Categories>,
|
|
pub isSubcategory: Cell<bool>,
|
|
pub onClickEvent: RefCell<SidebarAction>,
|
|
pub name : RefCell<String>,
|
|
}
|
|
|
|
#[allow(non_snake_case)]
|
|
pub struct SidebarAction {
|
|
pub onClickEvent: fn(FlowBox),
|
|
}
|
|
|
|
impl Default for SidebarAction {
|
|
fn default() -> Self {
|
|
Self {
|
|
onClickEvent: HANDLE_HOME
|
|
}
|
|
}
|
|
}
|
|
|
|
#[glib::object_subclass]
|
|
impl ObjectSubclass for SidebarEntry {
|
|
const NAME: &'static str = "resetSidebarEntry";
|
|
type Type = sidebarEntry::SidebarEntry;
|
|
type ParentType = ListBoxRow;
|
|
|
|
fn class_init(klass: &mut Self::Class) {
|
|
klass.bind_template();
|
|
}
|
|
|
|
fn instance_init(obj: &InitializingObject<Self>) {
|
|
obj.init_template();
|
|
}
|
|
}
|
|
|
|
impl ObjectImpl for SidebarEntry {}
|
|
|
|
impl ListBoxRowImpl for SidebarEntry {}
|
|
|
|
impl WidgetImpl for SidebarEntry {} |