Changed preferences icon, updated main window's menu

This commit is contained in:
Observer KRypt0n_ 2022-08-06 21:28:38 +02:00
parent ac8ed8dfe0
commit 049a9b72a2
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
3 changed files with 60 additions and 8 deletions

View file

@ -74,7 +74,7 @@ Adw.ApplicationWindow window {
}
Gtk.Button open_preferences {
icon-name: "preferences-system-symbolic";
icon-name: "emblem-system-symbolic";
}
}
}
@ -91,9 +91,7 @@ Adw.ApplicationWindow window {
Gtk.ProgressBar progress_bar {
show-text: true;
width-request: 360;
fraction: 0.37;
valign: center;
}
@ -121,6 +119,28 @@ Gtk.AboutDialog about {
}
menu app_menu {
item ("Check for updates")
item ("About", "show-about-dialog.show-about-dialog")
section {
submenu {
label: "Open";
item {
label: "Launcher folder";
action: "open-launcher-folder.open-launcher-folder";
}
item {
label: "Game folder";
action: "open-game-folder.open-game-folder";
}
item {
label: "Config file";
action: "open-config-file.open-config-file";
}
}
}
section {
item ("About", "show-about-dialog.show-about-dialog")
}
}

View file

@ -21,14 +21,14 @@ impl WinePrefix {
let wine = format!("{}/{}/{}", &runners_folder, runner.name, runner.files.wine64);
let wineserver = format!("{}/{}/{}", &runners_folder, runner.name, runner.files.wineserver);
let mut wineboot = Command::new(wine);
let mut wine_command = Command::new(wine);
wineboot.env("WINEARCH", "win64")
wine_command.env("WINEARCH", "win64")
.env("WINESERVER", wineserver)
.env("WINEPREFIX", &self.path)
.arg(command);
Ok(wineboot.output()?)
Ok(wine_command.output()?)
}
pub fn update<T: ToString>(&self, runners_folder: T, runner: super::wine::Version) -> std::io::Result<Output> {

View file

@ -207,6 +207,38 @@ impl App {
/// Add default events and values to the widgets
fn init_events(self) -> Self {
// Add menu actions
add_action(&self.widgets.menu, "open-launcher-folder", clone!(@weak self as this => move || {
if let Some(launcher_dir) = consts::launcher_dir() {
if let Err(err) = Command::new("xdg-open").arg(launcher_dir).spawn() {
this.update(Actions::Toast(Rc::new((
String::from("Failed to open launcher folder"), err
)))).unwrap();
}
}
}));
add_action(&self.widgets.menu, "open-game-folder", clone!(@weak self as this => move || {
if let Ok(config) = config::get() {
if let Err(err) = Command::new("xdg-open").arg(config.game.path).spawn() {
this.update(Actions::Toast(Rc::new((
String::from("Failed to open game folder"), err
)))).unwrap();
}
}
}));
add_action(&self.widgets.menu, "open-config-file", clone!(@weak self as this => move || {
if let Some(config_file) = consts::config_file() {
if let Err(err) = Command::new("xdg-open").arg(config_file).spawn() {
this.update(Actions::Toast(Rc::new((
String::from("Failed to open config file"), err
)))).unwrap();
}
}
}));
// Other actions
add_action(&self.widgets.menu, "show-about-dialog", clone!(@strong self.widgets.about as about => move || {
about.show();
}));