changed from image to picture

This commit is contained in:
leca 2024-04-05 19:44:46 +03:00
parent 749e38d5e5
commit 8d17e4e474
5 changed files with 9 additions and 8 deletions

View File

@ -10,7 +10,7 @@
<property name="halign">GTK_ALIGN_CENTER</property> <property name="halign">GTK_ALIGN_CENTER</property>
<property name="valign">GTK_ALIGN_CENTER</property> <property name="valign">GTK_ALIGN_CENTER</property>
<child> <child>
<object class="GtkImage" id="image"> <object class="GtkPicture" id="image">
<property name="halign">GTK_ALIGN_CENTER</property> <property name="halign">GTK_ALIGN_CENTER</property>
<property name="valign">GTK_ALIGN_CENTER</property> <property name="valign">GTK_ALIGN_CENTER</property>
<property name="file">/home/leca/Downloads/2648 - SoyBooru.png</property> <property name="file">/home/leca/Downloads/2648 - SoyBooru.png</property>

View File

@ -35,7 +35,7 @@ pub fn init() {
image_hash CHAR(64), image_hash CHAR(64),
hieroglyph VARCHAR(2), hieroglyph VARCHAR(2),
translation VARCHAR(128) translation VARCHAR(128)
)",(),).unwrap(); )",()).unwrap();
} }
pub fn get_program_home_path() -> &'static RwLock<String> { pub fn get_program_home_path() -> &'static RwLock<String> {

View File

@ -8,7 +8,7 @@ use glib::subclass::InitializingObject;
use gtk::glib::object::ObjectExt; use gtk::glib::object::ObjectExt;
use gtk::glib::{clone, closure_local}; use gtk::glib::{clone, closure_local};
use gtk::subclass::prelude::*; use gtk::subclass::prelude::*;
use gtk::{glib, Button, CompositeTemplate, ScrolledWindow, SearchEntry, Window}; use gtk::{gio, glib, Button, CompositeTemplate, ScrolledWindow, SearchEntry, Window};
use gtk::{prelude::*, FileDialog}; use gtk::{prelude::*, FileDialog};
use sha256::try_digest; use sha256::try_digest;
@ -71,7 +71,8 @@ async fn file_choose_dialog<W: IsA<gtk::Window>>(window: Rc<W>) {
let w: &MemoryCardsNewScene = Into::<&Window>::into(window.upcast_ref()) let w: &MemoryCardsNewScene = Into::<&Window>::into(window.upcast_ref())
.downcast_ref() .downcast_ref()
.unwrap(); // Weird casting from &Window as passed in func to &MemoryCardsNewScene .unwrap(); // Weird casting from &Window as passed in func to &MemoryCardsNewScene
w.get_image_widget().set_file(Some(path)); // w.get_image_widget().set_file(Some(path));
w.get_image_widget().set_file(Some(&gio::File::for_path(path)));
let binding = Path::new(path); let binding = Path::new(path);
let hash = try_digest(binding).unwrap(); let hash = try_digest(binding).unwrap();

View File

@ -1,12 +1,12 @@
use glib::subclass::InitializingObject; use glib::subclass::InitializingObject;
use gtk::subclass::prelude::*; use gtk::subclass::prelude::*;
use gtk::{glib, Button, CompositeTemplate, Entry, Image}; use gtk::{glib, Button, CompositeTemplate, Entry, Picture};
#[derive(CompositeTemplate, Default)] #[derive(CompositeTemplate, Default)]
#[template(resource = "/org/foxarmy/learn-hieroglyph/cards/new/ui.xml")] #[template(resource = "/org/foxarmy/learn-hieroglyph/cards/new/ui.xml")]
pub struct MemoryCardsNewScene { pub struct MemoryCardsNewScene {
#[template_child] #[template_child]
pub image: TemplateChild<Image>, pub image: TemplateChild<Picture>,
#[template_child] #[template_child]
pub file_choose_button: TemplateChild<Button>, pub file_choose_button: TemplateChild<Button>,
#[template_child] #[template_child]

View File

@ -2,7 +2,7 @@ mod imp;
use glib::Object; use glib::Object;
use gtk::{ use gtk::{
gio, glib::{self, subclass::types::ObjectSubclassIsExt}, Application, Button, Image, prelude::* gio, glib::{self, subclass::types::ObjectSubclassIsExt}, prelude::*, Application, Button, Picture
}; };
glib::wrapper! { glib::wrapper! {
@ -21,7 +21,7 @@ impl MemoryCardsNewScene {
self.imp().file_choose_button.as_ref() self.imp().file_choose_button.as_ref()
} }
pub fn get_image_widget(&self) -> &Image { pub fn get_image_widget(&self) -> &Picture {
self.imp().image.as_ref() self.imp().image.as_ref()
} }