Switch to libadwaita

This commit is contained in:
justine 2024-08-20 17:42:13 +02:00
parent 06b091c87f
commit 838e093190
3 changed files with 36 additions and 4 deletions

32
Cargo.lock generated
View File

@ -398,6 +398,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"gtk4",
"libadwaita",
]
[[package]]
@ -410,6 +411,37 @@ dependencies = [
"hashbrown",
]
[[package]]
name = "libadwaita"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ff9c222b5c783729de45185f07b2fec2d43a7f9c63961e777d3667e20443878"
dependencies = [
"gdk4",
"gio",
"glib",
"gtk4",
"libadwaita-sys",
"libc",
"pango",
]
[[package]]
name = "libadwaita-sys"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c44d8bdbad31d6639e1f20cc9c1424f1a8e02d751fc28d44659bf743fb9eca6"
dependencies = [
"gdk4-sys",
"gio-sys",
"glib-sys",
"gobject-sys",
"gtk4-sys",
"libc",
"pango-sys",
"system-deps",
]
[[package]]
name = "libc"
version = "0.2.158"

View File

@ -4,5 +4,6 @@ version = "0.1.0"
edition = "2021"
[dependencies]
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_5"] }
anyhow = "1.0.86"
gtk = { version = "0.9.0", package = "gtk4", features = ["v4_14"] }

View File

@ -1,4 +1,5 @@
use crate::glib::clone;
use adw;
use gtk::prelude::*;
use gtk::{self, glib, Application, ApplicationWindow, Button, Image};
use std::cell::Cell;
@ -11,7 +12,7 @@ const APP_ID: &str = "org.gtk_rs.GObjectMemoryManagement1";
fn main() -> glib::ExitCode {
// Create a new application
let app = Application::builder().application_id(APP_ID).build();
let app = adw::Application::builder().application_id(APP_ID).build();
// Connect to "activate" signal of `app`
app.connect_activate(build_ui);
@ -45,7 +46,7 @@ fn get_pictures_in_folder(folder: String) -> anyhow::Result<Vec<String>> {
Ok(myvec)
}
fn build_ui(application: &Application) {
fn build_ui(application: &adw::Application) {
// Create a vertical container
let mut vbox = gtk::Box::new(gtk::Orientation::Vertical, 0);
@ -98,7 +99,6 @@ fn build_ui(application: &Application) {
curr_pic.set(new_index);
image.set_from_file(Some(shared_pics[curr_pic.get()].clone()));
dbg!(new_index.clone());
println!("haaa");
}
));
@ -113,7 +113,6 @@ fn build_ui(application: &Application) {
curr_pic.set(new_index);
image.set_from_file(Some(shared_pics[curr_pic.get()].clone()));
dbg!(new_index.clone());
println!("haaa");
}
));