Added game voiceover selection ui

This commit is contained in:
Observer KRypt0n_ 2022-07-02 18:03:32 +02:00
parent 178c45ae48
commit 9d5c0cc9ee
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
6 changed files with 49 additions and 14 deletions

View file

@ -17,3 +17,4 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
dirs = "4.0.0"
# tokio = { version = "1.19.2", features = ["rt", "rt-multi-thread", "macros"]}

View file

@ -18,6 +18,47 @@ Adw.PreferencesPage general_page {
]
};
}
Adw.ExpanderRow {
title: "Game voiceovers";
subtitle: "Select voice packages used in game";
Adw.ActionRow {
title: "English";
Gtk.Button {
icon-name: "document-save-symbolic";
valign: center;
}
}
Adw.ActionRow {
title: "Japanese";
Gtk.Button {
icon-name: "user-trash-symbolic";
valign: center;
}
}
Adw.ActionRow {
title: "Korean";
Gtk.Button {
icon-name: "document-save-symbolic";
valign: center;
}
}
Adw.ActionRow {
title: "Chinese";
Gtk.Button {
icon-name: "document-save-symbolic";
valign: center;
}
}
}
}
Adw.PreferencesGroup {

View file

@ -6,6 +6,7 @@ pub mod lib;
use ui::*;
// #[tokio::main]
fn main() {
gtk::init().expect("GTK initialization failed");
adw::init();
@ -23,9 +24,7 @@ fn main() {
let app_copy = app.clone();
app.open_preferences.connect_clicked(move |_| {
if let Err(err) = app_copy.open_preferences_page() {
app_copy.toast_error("Failed to open settings page", err);
}
app_copy.open_preferences_page();
});
app.window.show();

View file

@ -1,8 +1,6 @@
use gtk4::{self as gtk, prelude::*};
use libadwaita::{self as adw, prelude::*};
use std::io::Error;
use super::get_object;
use super::preferences::PreferencesStack;
use super::ToastError;
@ -93,12 +91,12 @@ impl App {
Ok(result)
}
pub fn open_preferences_page(&self) -> Result<(), Error> {
self.preferences_stack.update()?;
pub fn open_preferences_page(&self) {
self.leaflet.set_visible_child_name("preferences_page");
Ok(())
if let Err(err) = self.preferences_stack.update() {
self.toast_error("Failed to update preferences", err);
}
}
pub fn update_state(&self, state: AppState) {

View file

@ -73,8 +73,6 @@ impl PreferencesStack {
self.status_page.set_visible(false);
self.flap.set_visible(true);
self.toast_error("Aboba amogus", Error::last_os_error());
Ok(())
}
}

View file

@ -1,8 +1,6 @@
use gtk4::{self as gtk, prelude::*};
use libadwaita::{self as adw, prelude::*};
use std::io::Error;
use super::add_action;
pub trait ToastError {
@ -11,7 +9,7 @@ pub trait ToastError {
/// Show toast with `toast` title and `See message` button
///
/// This button will show message dialog with error message
fn toast_error(&self, toast: &str, err: Error) {
fn toast_error<T: ToString + 'static>(&self, toast: &str, err: T) {
let toast = adw::Toast::new(toast);
toast.set_button_label(Some("See message"));