fix is_learning switch
This commit is contained in:
		@@ -15,8 +15,7 @@ use gtk::glib::{clone, closure_local, Object};
 | 
				
			|||||||
use gtk::prelude::WidgetExt;
 | 
					use gtk::prelude::WidgetExt;
 | 
				
			||||||
use gtk::subclass::prelude::*;
 | 
					use gtk::subclass::prelude::*;
 | 
				
			||||||
use gtk::{
 | 
					use gtk::{
 | 
				
			||||||
    gio, glib, Button, CompositeTemplate, ListView, NoSelection, ScrolledWindow, SearchEntry,
 | 
					    gio, glib, Button, CompositeTemplate, ListView, NoSelection, ScrolledWindow, SearchEntry, Switch, Window
 | 
				
			||||||
    Window,
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use gtk::{prelude::*, FileDialog};
 | 
					use gtk::{prelude::*, FileDialog};
 | 
				
			||||||
use gtk::{ListItem, SignalListItemFactory};
 | 
					use gtk::{ListItem, SignalListItemFactory};
 | 
				
			||||||
@@ -125,6 +124,13 @@ impl MemoryCardsEditScene {
 | 
				
			|||||||
                .and_downcast::<CardEntry>()
 | 
					                .and_downcast::<CardEntry>()
 | 
				
			||||||
                .unwrap();
 | 
					                .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| {
 | 
					            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 connection = Connection::open(get_db_path()).unwrap();
 | 
				
			||||||
                let imagepath = &card.imagepath();
 | 
					                let imagepath = &card.imagepath();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,6 +53,10 @@ impl CardEntry {
 | 
				
			|||||||
        self.imp().edit_button.as_ref()
 | 
					        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) {
 | 
					    pub fn update_file_for_image(&self) {
 | 
				
			||||||
        let image_binding: &Image = self.imp().image.as_ref();
 | 
					        let image_binding: &Image = self.imp().image.as_ref();
 | 
				
			||||||
        let path: &str = &*self.imp().imagepath.borrow().clone().to_string();
 | 
					        let path: &str = &*self.imp().imagepath.borrow().clone().to_string();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user