mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
delegate action registration to widget
This commit is contained in:
parent
532ed65ed8
commit
157227cbfe
2 changed files with 28 additions and 18 deletions
|
|
@ -3,7 +3,10 @@ mod database;
|
|||
use database::Database;
|
||||
|
||||
use adw::ApplicationWindow;
|
||||
use gtk::{prelude::GtkWindowExt, Box};
|
||||
use gtk::{
|
||||
gio::SimpleAction,
|
||||
prelude::{ActionMapExt, GtkWindowExt, IsA},
|
||||
};
|
||||
use sqlite::Transaction;
|
||||
|
||||
// Default options
|
||||
|
|
@ -17,7 +20,7 @@ pub struct Widget {
|
|||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new(content: &Box) -> Self {
|
||||
pub fn new(content: &impl IsA<gtk::Widget>, actions: &[SimpleAction]) -> Self {
|
||||
// Init GTK
|
||||
let gobject = ApplicationWindow::builder()
|
||||
.content(content)
|
||||
|
|
@ -26,6 +29,11 @@ impl Widget {
|
|||
.maximized(MAXIMIZED)
|
||||
.build();
|
||||
|
||||
// Register actions
|
||||
for action in actions {
|
||||
gobject.add_action(action);
|
||||
}
|
||||
|
||||
// Return new struct
|
||||
Self { gobject }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue