refactor and clean up app library
This commit is contained in:
parent
4ce3b3cc21
commit
28151177d0
7 changed files with 670 additions and 498 deletions
41
examples/app_library/group_grid/imp.rs
Normal file
41
examples/app_library/group_grid/imp.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
use glib::subclass::Signal;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::{gio, glib, GridView, ScrolledWindow};
|
||||
use gtk4::{prelude::*, CustomFilter};
|
||||
use once_cell::sync::{Lazy, OnceCell};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct GroupGrid {
|
||||
pub group_grid_view: OnceCell<GridView>,
|
||||
pub group_scroll_window: OnceCell<ScrolledWindow>,
|
||||
pub group_model: OnceCell<gio::ListStore>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for GroupGrid {
|
||||
// `NAME` needs to match `class` attribute of template
|
||||
const NAME: &'static str = "GroupGrid";
|
||||
type Type = super::GroupGrid;
|
||||
type ParentType = gtk4::Box;
|
||||
}
|
||||
|
||||
impl ObjectImpl for GroupGrid {
|
||||
fn signals() -> &'static [Signal] {
|
||||
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
|
||||
vec![Signal::builder(
|
||||
// Signal name
|
||||
"group-changed",
|
||||
// Types of the values which will be sent to the signal handler
|
||||
&[CustomFilter::static_type().into()],
|
||||
// Type of the value the signal handler sends back
|
||||
<()>::static_type().into(),
|
||||
)
|
||||
.build()]
|
||||
});
|
||||
SIGNALS.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl WidgetImpl for GroupGrid {}
|
||||
|
||||
impl BoxImpl for GroupGrid {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue