Moved to libadwaita 1.2

This commit is contained in:
Observer KRypt0n_ 2022-09-24 16:52:31 +02:00
parent 6fd220e633
commit 5d26f84659
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
32 changed files with 81 additions and 126 deletions

11
Cargo.lock generated
View file

@ -1130,10 +1130,12 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libadwaita" name = "libadwaita"
version = "0.1.1" version = "0.2.0-alpha.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2ae453d28e3b91f03749f02b1531e8cfe315a1d0762b77a61797d2ab80bb87d" checksum = "73815fa30ca62d1db2713fe87cfd1cea41cad076ccdece6bb8328032db152f47"
dependencies = [ dependencies = [
"bitflags",
"futures-channel",
"gdk-pixbuf", "gdk-pixbuf",
"gdk4", "gdk4",
"gio", "gio",
@ -1147,9 +1149,9 @@ dependencies = [
[[package]] [[package]]
name = "libadwaita-sys" name = "libadwaita-sys"
version = "0.1.0" version = "0.2.0-alpha.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f18b6ac4cadd252a89f5cba0a5a4e99836131795d6fad37b859ac79e8cb7d2c8" checksum = "b91960ec236b6fecdace0491ae1e4aac938d1c6adffd5939f811f3ed6592a59e"
dependencies = [ dependencies = [
"gdk4-sys", "gdk4-sys",
"gio-sys", "gio-sys",
@ -1157,6 +1159,7 @@ dependencies = [
"gobject-sys", "gobject-sys",
"gtk4-sys", "gtk4-sys",
"libc", "libc",
"pango-sys",
"system-deps", "system-deps",
] ]

View file

@ -13,11 +13,11 @@ lto = true
opt-level = 3 opt-level = 3
[build-dependencies] [build-dependencies]
gtk4 = "0.4" gtk = { package = "gtk4", version = "0.4", features = ["v4_8"] }
[dependencies] [dependencies]
gtk4 = "0.4" gtk = { package = "gtk4", version = "0.4", features = ["v4_8"] }
libadwaita = "0.1" adw = { package = "libadwaita", version = "0.2.0-alpha.3", features = ["v1_2"] }
rfd = { version = "0.10", features = ["xdg-portal"], default-features = false } rfd = { version = "0.10", features = ["xdg-portal"], default-features = false }
anime-game-core = { path = "anime-game-core", features = ["all", "static", "genshin"] } anime-game-core = { path = "anime-game-core", features = ["all", "static", "genshin"] }

View file

@ -108,11 +108,12 @@ Adw.ApplicationWindow window {
}; };
} }
Gtk.AboutDialog about { Adw.AboutWindow about {
program-name: "An Anime Game Launcher"; application-name: "An Anime Game Launcher";
application-icon: "moe.launcher.an-anime-game-launcher-gtk";
logo: "resource:///org/app/assets/images/icon.png";
website: "https://github.com/an-anime-team/an-anime-game-launcher-gtk"; website: "https://github.com/an-anime-team/an-anime-game-launcher-gtk";
issue-url: "https://github.com/an-anime-team/an-anime-game-launcher-gtk/issues";
modal: true; modal: true;
transient-for: window; transient-for: window;

View file

@ -11,73 +11,49 @@ Adw.PreferencesWindow window {
Adw.PreferencesGroup { Adw.PreferencesGroup {
title: "Game resolution"; title: "Game resolution";
Adw.ActionRow { Adw.EntryRow game_width {
title: "Width"; title: "Width";
Gtk.Entry game_width {
placeholder-text: "0";
valign: center;
input-purpose: digits; input-purpose: digits;
} }
}
Adw.ActionRow { Adw.EntryRow game_height {
title: "Height"; title: "Height";
Gtk.Entry game_height {
placeholder-text: "0";
valign: center;
input-purpose: digits; input-purpose: digits;
} }
} }
}
Adw.PreferencesGroup { Adw.PreferencesGroup {
title: "Gamescope resolution"; title: "Gamescope resolution";
Adw.ActionRow { Adw.EntryRow gamescope_width {
title: "Width"; title: "Width";
Gtk.Entry gamescope_width {
placeholder-text: "0";
valign: center;
input-purpose: digits; input-purpose: digits;
} }
}
Adw.ActionRow { Adw.EntryRow gamescope_height {
title: "Height"; title: "Height";
Gtk.Entry gamescope_height {
placeholder-text: "0";
valign: center;
input-purpose: digits; input-purpose: digits;
} }
} }
}
Adw.PreferencesGroup { Adw.PreferencesGroup {
title: "Other settings"; title: "Other settings";
Adw.ActionRow { Adw.EntryRow framerate_limit {
title: "Framerate limit"; title: "Framerate limit";
Gtk.Entry framerate_limit {
placeholder-text: "0";
valign: center;
input-purpose: digits; input-purpose: digits;
} }
}
Adw.ActionRow { Adw.EntryRow framerate_unfocused_limit {
title: "Unfocused framerate limit"; title: "Unfocused framerate limit";
Gtk.Entry framerate_unfocused_limit {
placeholder-text: "0";
valign: center;
input-purpose: digits; input-purpose: digits;
} }
}
Adw.ActionRow { Adw.ActionRow {
title: "Integer scaling"; title: "Integer scaling";

View file

@ -77,7 +77,7 @@ fn main() {
blp_process_dir(String::new()); blp_process_dir(String::new());
if let Ok(_) = read_to_string("assets/resources.xml") { if let Ok(_) = read_to_string("assets/resources.xml") {
gtk4::gio::compile_resources( gtk::gio::compile_resources(
"assets", "assets",
"assets/resources.xml", "assets/resources.xml",
".assets.gresource", ".assets.gresource",

View file

@ -1,5 +1,3 @@
use gtk4 as gtk;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum Fps { pub enum Fps {
/// 90 /// 90

View file

@ -1,5 +1,3 @@
use gtk4 as gtk;
use std::collections::HashMap; use std::collections::HashMap;
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};

View file

@ -1,5 +1,3 @@
use gtk4 as gtk;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum Resolution { pub enum Resolution {
// qHD; 960x540 // qHD; 960x540

View file

@ -1,5 +1,4 @@
use gtk4::{self as gtk, prelude::*}; use gtk::prelude::*;
use libadwaita as adw;
use gtk::{CssProvider, StyleContext, STYLE_PROVIDER_PRIORITY_APPLICATION}; use gtk::{CssProvider, StyleContext, STYLE_PROVIDER_PRIORITY_APPLICATION};
use gtk::gdk::Display; use gtk::gdk::Display;
@ -19,8 +18,7 @@ pub const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
pub const APP_DEBUG: bool = cfg!(debug_assertions); pub const APP_DEBUG: bool = cfg!(debug_assertions);
fn main() { fn main() {
gtk::init().expect("GTK initialization failed"); adw::init().expect("Libadwaita initialization failed");
adw::init();
// Register and include resources // Register and include resources
gtk::gio::resources_register_include!(".assets.gresource") gtk::gio::resources_register_include!(".assets.gresource")

View file

@ -1,4 +1,4 @@
use libadwaita::{self as adw, prelude::*}; use adw::prelude::*;
use crate::lib::dxvk::Group; use crate::lib::dxvk::Group;
use super::dxvk_row::DxvkRow; use super::dxvk_row::DxvkRow;

View file

@ -1,5 +1,5 @@
use gtk4::{self as gtk, prelude::*}; use gtk::prelude::*;
use libadwaita::{self as adw, prelude::*}; use adw::prelude::*;
use crate::lib::dxvk::Version; use crate::lib::dxvk::Version;
use crate::ui::traits::download_component::*; use crate::ui::traits::download_component::*;

View file

@ -1,5 +1,4 @@
use gtk4::{self as gtk, prelude::*}; use gtk::prelude::*;
use libadwaita as adw;
use gtk::glib; use gtk::glib;

View file

@ -1,5 +1,5 @@
use gtk4::{self as gtk, prelude::*}; use gtk::prelude::*;
use libadwaita::{self as adw, prelude::*}; use adw::prelude::*;
use std::path::PathBuf; use std::path::PathBuf;

View file

@ -1,4 +1,4 @@
use libadwaita::{self as adw, prelude::*}; use adw::prelude::*;
use crate::lib::wine::Group; use crate::lib::wine::Group;
use super::wine_row::WineRow; use super::wine_row::WineRow;

View file

@ -1,5 +1,5 @@
use gtk4::{self as gtk, prelude::*}; use gtk::prelude::*;
use libadwaita::{self as adw, prelude::*}; use adw::prelude::*;
use crate::lib::wine::Version; use crate::lib::wine::Version;
use crate::ui::traits::download_component::*; use crate::ui::traits::download_component::*;

View file

@ -1,5 +1,4 @@
use gtk4 as gtk; use adw::prelude::*;
use libadwaita::{self as adw, prelude::*};
use gtk::glib; use gtk::glib;
use gtk::glib::clone; use gtk::glib::clone;

View file

@ -1,5 +1,3 @@
use gtk4 as gtk;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use crate::ui::*; use crate::ui::*;

View file

@ -1,5 +1,4 @@
use gtk4 as gtk; use adw::prelude::*;
use libadwaita::{self as adw, prelude::*};
use crate::lib::wine::{Version as WineVersion, List as WineList}; use crate::lib::wine::{Version as WineVersion, List as WineList};
use crate::lib::dxvk::{Version as DxvkVersion, List as DxvkList}; use crate::lib::dxvk::{Version as DxvkVersion, List as DxvkList};

View file

@ -1,5 +1,3 @@
use gtk4 as gtk;
use crate::ui::*; use crate::ui::*;
#[derive(Clone)] #[derive(Clone)]

View file

@ -1,5 +1,4 @@
use gtk4::{self as gtk, prelude::*}; use gtk::prelude::*;
use libadwaita as adw;
use gtk::glib; use gtk::glib;
use gtk::glib::clone; use gtk::glib::clone;

View file

@ -1,5 +1,3 @@
use gtk4 as gtk;
use crate::ui::*; use crate::ui::*;
#[derive(Clone)] #[derive(Clone)]

View file

@ -1,5 +1,5 @@
use gtk4 as gtk; use gtk::prelude::*;
use libadwaita::{self as adw, prelude::*}; use adw::prelude::*;
use anime_game_core::genshin::voice_data::prelude::*; use anime_game_core::genshin::voice_data::prelude::*;

View file

@ -1,5 +1,3 @@
use gtk4 as gtk;
use crate::ui::*; use crate::ui::*;
#[derive(Clone)] #[derive(Clone)]

View file

@ -1,8 +1,7 @@
use gtk4::{self as gtk, prelude::*}; use gtk::prelude::*;
use libadwaita as adw;
use gtk4::glib; use gtk::glib;
use gtk4::glib::clone; use gtk::glib::clone;
use std::rc::Rc; use std::rc::Rc;
use std::cell::Cell; use std::cell::Cell;
@ -42,7 +41,7 @@ pub struct AppWidgets {
pub toast_overlay: adw::ToastOverlay, pub toast_overlay: adw::ToastOverlay,
pub menu: gtk::MenuButton, pub menu: gtk::MenuButton,
pub about: gtk::AboutDialog, pub about: adw::AboutWindow,
pub leaflet: adw::Leaflet, pub leaflet: adw::Leaflet,
pub status_page: adw::StatusPage, pub status_page: adw::StatusPage,
@ -100,31 +99,31 @@ impl AppWidgets {
// Set default About Dialog values // Set default About Dialog values
if crate::APP_DEBUG { if crate::APP_DEBUG {
result.about.set_version(Some(format!("{} (development)", crate::APP_VERSION).as_str())); result.about.set_version(&format!("{}-dev", crate::APP_VERSION));
} }
else { else {
result.about.set_version(Some(crate::APP_VERSION)); result.about.set_version(crate::APP_VERSION);
} }
result.about.set_license_type(gtk::License::Gpl30); result.about.set_license_type(gtk::License::Gpl30);
result.about.set_authors(&[ result.about.set_developers(&[
"Nikita Podvirnyy https://github.com/krypt0nn" "Nikita Podvirnyy https://github.com/krypt0nn"
]); ]);
result.about.add_credit_section("Logo", &[ result.about.add_credit_section(Some("Logo"), &[
"@nightany https://pinterest.com/pin/356206651788051017" "@nightany https://pinterest.com/pin/356206651788051017"
]); ]);
result.about.add_credit_section("An Anime Team", &[ result.about.add_credit_section(Some("An Anime Team"), &[
"@Marie https://github.com/Mar0xy", "@Marie https://github.com/Mar0xy",
"@lane https://github.com/laurinneff" "@lane https://github.com/laurinneff"
]); ]);
let curl_info = anime_game_core::curl_sys::Version::get(); let curl_info = anime_game_core::curl_sys::Version::get();
result.about.set_system_information(Some(&[ result.about.set_debug_info(&[
format!("Anime Game core library version: {}", anime_game_core::VERSION), format!("Anime Game core library version: {}", anime_game_core::VERSION),
format!("Curl version: {}", curl_info.version()), format!("Curl version: {}", curl_info.version()),
format!("SSL version: {}", curl_info.ssl_version().unwrap_or("?")), format!("SSL version: {}", curl_info.ssl_version().unwrap_or("?")),
@ -133,7 +132,7 @@ impl AppWidgets {
format!("Libadwaita version: {}.{}.{}", adw::major_version(), adw::minor_version(), adw::micro_version()), format!("Libadwaita version: {}.{}.{}", adw::major_version(), adw::minor_version(), adw::micro_version()),
format!("Pango version: {}", gtk::pango::version_string().unwrap_or("?".into())), format!("Pango version: {}", gtk::pango::version_string().unwrap_or("?".into())),
format!("Cairo version: {}", gtk::cairo::version_string()), format!("Cairo version: {}", gtk::cairo::version_string()),
].join("\n"))); ].join("\n"));
// Add preferences page to the leaflet // Add preferences page to the leaflet
result.leaflet.append(&result.preferences_stack.preferences).set_name(Some("preferences_page")); result.leaflet.append(&result.preferences_stack.preferences).set_name(Some("preferences_page"));

View file

@ -1,5 +1,4 @@
use gtk4::{self as gtk, prelude::*}; use gtk::prelude::*;
use libadwaita as adw;
pub mod first_run; pub mod first_run;
pub mod main; pub mod main;

View file

@ -1,5 +1,5 @@
use gtk4 as gtk; use gtk::prelude::*;
use libadwaita::{self as adw, prelude::*}; use adw::prelude::*;
use gtk::glib; use gtk::glib;
use gtk::glib::clone; use gtk::glib::clone;

View file

@ -1,8 +1,8 @@
use gtk4 as gtk; use gtk::prelude::*;
use libadwaita::{self as adw, prelude::*}; use adw::prelude::*;
use gtk4::glib; use gtk::glib;
use gtk4::glib::clone; use gtk::glib::clone;
use std::collections::HashMap; use std::collections::HashMap;
use std::rc::Rc; use std::rc::Rc;

View file

@ -1,5 +1,4 @@
use gtk4 as gtk; use gtk::prelude::*;
use libadwaita::{self as adw, prelude::*};
use gtk::glib; use gtk::glib;
@ -17,14 +16,14 @@ use crate::ui::*;
pub struct AppWidgets { pub struct AppWidgets {
pub window: adw::PreferencesWindow, pub window: adw::PreferencesWindow,
pub game_width: gtk::Entry, pub game_width: adw::EntryRow,
pub game_height: gtk::Entry, pub game_height: adw::EntryRow,
pub gamescope_width: gtk::Entry, pub gamescope_width: adw::EntryRow,
pub gamescope_height: gtk::Entry, pub gamescope_height: adw::EntryRow,
pub framerate_limit: gtk::Entry, pub framerate_limit: adw::EntryRow,
pub framerate_unfocused_limit: gtk::Entry, pub framerate_unfocused_limit: adw::EntryRow,
pub integer_scaling: gtk::Switch, pub integer_scaling: gtk::Switch,
pub fsr: gtk::Switch, pub fsr: gtk::Switch,
pub nis: gtk::Switch, pub nis: gtk::Switch,
@ -227,7 +226,7 @@ impl App {
status_page.set_description(Some("Loading gamescope...")); status_page.set_description(Some("Loading gamescope..."));
fn set_text(widget: &gtk::Entry, value: u64) { fn set_text(widget: &adw::EntryRow, value: u64) {
widget.set_text(&if value == 0 { String::new() } else { value.to_string() }); widget.set_text(&if value == 0 { String::new() } else { value.to_string() });
} }

View file

@ -1,5 +1,5 @@
use gtk4::{self as gtk, prelude::*}; use gtk::prelude::*;
use libadwaita::{self as adw, prelude::*}; use adw::prelude::*;
use gtk::glib; use gtk::glib;
use gtk::glib::clone; use gtk::glib::clone;

View file

@ -1,5 +1,4 @@
use gtk4::{self as gtk, prelude::*}; use gtk::prelude::*;
use libadwaita as adw;
use gtk::glib; use gtk::glib;

View file

@ -1,4 +1,4 @@
use gtk4::{self as gtk, prelude::*}; use gtk::prelude::*;
use gtk::glib; use gtk::glib;

View file

@ -1,5 +1,4 @@
use gtk4::{self as gtk, prelude::*}; use gtk::prelude::*;
use libadwaita as adw;
use crate::ui::add_action; use crate::ui::add_action;