Add switch to enable cards
This commit is contained in:
@@ -3,7 +3,8 @@ use std::cell::RefCell;
|
||||
use glib::subclass::InitializingObject;
|
||||
use glib::Properties;
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk::{glib, prelude::*, Button, CompositeTemplate, Label, Image};
|
||||
use gtk::{glib, prelude::*, Button, CompositeTemplate, Image, Label, Switch};
|
||||
|
||||
|
||||
#[derive(CompositeTemplate, Properties, Default)]
|
||||
#[properties(wrapper_type = super::CardEntry)]
|
||||
@@ -14,17 +15,25 @@ pub struct CardEntry {
|
||||
#[template_child]
|
||||
pub hieroglyph_label: TemplateChild<Label>,
|
||||
#[template_child]
|
||||
pub reading_label: TemplateChild<Label>,
|
||||
#[template_child]
|
||||
pub translation_label: TemplateChild<Label>,
|
||||
#[template_child]
|
||||
pub edit_button: TemplateChild<Button>,
|
||||
#[template_child]
|
||||
pub delete_button: TemplateChild<Button>,
|
||||
#[template_child]
|
||||
pub is_learning_switch: TemplateChild<Switch>,
|
||||
#[property(get, set)]
|
||||
pub imagepath: RefCell<String>,
|
||||
#[property(get, set)]
|
||||
hieroglyph: RefCell<String>,
|
||||
pub hieroglyph: RefCell<String>,
|
||||
#[property(get, set)]
|
||||
translation: RefCell<String>,
|
||||
pub reading: RefCell<String>,
|
||||
#[property(get, set)]
|
||||
pub translation: RefCell<String>,
|
||||
#[property(get, set)]
|
||||
pub islearning: RefCell<bool>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
@@ -53,6 +62,12 @@ impl ObjectImpl for CardEntry {
|
||||
.sync_create()
|
||||
.build();
|
||||
|
||||
let reading_label_binding: &Label = self.reading_label.as_ref();
|
||||
self.obj()
|
||||
.bind_property("reading", reading_label_binding, "label")
|
||||
.sync_create()
|
||||
.build();
|
||||
|
||||
let translation_label_binding: &Label = self.translation_label.as_ref();
|
||||
self.obj()
|
||||
.bind_property("translation", translation_label_binding, "label")
|
||||
|
||||
Reference in New Issue
Block a user