Add switch to enable cards

This commit is contained in:
2024-04-18 14:14:19 +03:00
parent d0d2aaeb60
commit 9fa5524c9d
13 changed files with 139 additions and 50 deletions

View File

@@ -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")