fix is_learning switch
This commit is contained in:
parent
6a6ecd79d4
commit
78b2a1a272
|
@ -15,8 +15,7 @@ use gtk::glib::{clone, closure_local, Object};
|
|||
use gtk::prelude::WidgetExt;
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk::{
|
||||
gio, glib, Button, CompositeTemplate, ListView, NoSelection, ScrolledWindow, SearchEntry,
|
||||
Window,
|
||||
gio, glib, Button, CompositeTemplate, ListView, NoSelection, ScrolledWindow, SearchEntry, Switch, Window
|
||||
};
|
||||
use gtk::{prelude::*, FileDialog};
|
||||
use gtk::{ListItem, SignalListItemFactory};
|
||||
|
@ -125,6 +124,13 @@ impl MemoryCardsEditScene {
|
|||
.and_downcast::<CardEntry>()
|
||||
.unwrap();
|
||||
|
||||
card_object_to_display.get_is_learning_switch_widget().connect_closure("state-set", false, closure_local!(@strong card_object as card => move |s: &Switch, is_enabled: bool| {
|
||||
let connection = Connection::open(get_db_path()).unwrap();
|
||||
let is_learning = is_enabled;
|
||||
let hieroglyph = card.hieroglyph();
|
||||
connection.execute("UPDATE cards SET is_learning = ?1 WHERE hieroglyph = ?2", (&is_learning, &hieroglyph)).unwrap();
|
||||
glib::Propagation::Proceed
|
||||
}));
|
||||
card_object_to_display.get_delete_button_widget().connect_closure("clicked", false, closure_local!(@strong card_object as card, @strong self_binding => move |_b: &Button| {
|
||||
let connection = Connection::open(get_db_path()).unwrap();
|
||||
let imagepath = &card.imagepath();
|
||||
|
|
|
@ -53,6 +53,10 @@ impl CardEntry {
|
|||
self.imp().edit_button.as_ref()
|
||||
}
|
||||
|
||||
pub fn get_is_learning_switch_widget(&self) -> &Switch {
|
||||
self.imp().is_learning_switch.as_ref()
|
||||
}
|
||||
|
||||
pub fn update_file_for_image(&self) {
|
||||
let image_binding: &Image = self.imp().image.as_ref();
|
||||
let path: &str = &*self.imp().imagepath.borrow().clone().to_string();
|
||||
|
|
Loading…
Reference in New Issue