mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-12-15 18:11:38 +01:00
Big restructuring
This commit is contained in:
parent
c4c95df8d3
commit
13084ed86d
22 changed files with 638 additions and 595 deletions
64
src/components/window/sidebarEntryImpl.rs
Normal file
64
src/components/window/sidebarEntryImpl.rs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
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,
|
||||
#[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 {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue