From 9914072c774b0a6912d548b26752f9f8649b72c9 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 24 Mar 2024 10:10:14 +0200 Subject: [PATCH] feat: get rid of deprecated libadwaita functions calls --- .../preferences/enhancements/environment.rs | 125 +++--- src/ui/preferences/enhancements/game.rs | 73 ++-- src/ui/preferences/enhancements/mod.rs | 14 +- src/ui/preferences/enhancements/sandbox.rs | 395 +++++++++--------- src/ui/preferences/general/components.rs | 367 ++++++++-------- src/ui/preferences/general/mod.rs | 6 +- 6 files changed, 496 insertions(+), 484 deletions(-) diff --git a/src/ui/preferences/enhancements/environment.rs b/src/ui/preferences/enhancements/environment.rs index 93bfad9..73e61ee 100644 --- a/src/ui/preferences/enhancements/environment.rs +++ b/src/ui/preferences/enhancements/environment.rs @@ -71,82 +71,85 @@ impl SimpleAsyncComponent for EnvironmentPage { type Output = EnhancementsAppMsg; view! { - gtk::Box { - set_orientation: gtk::Orientation::Vertical, + adw::NavigationPage { + #[wrap(Some)] + set_child = >k::Box { + set_orientation: gtk::Orientation::Vertical, - adw::HeaderBar { - #[wrap(Some)] - set_title_widget = &adw::WindowTitle { - set_title: &tr!("environment") - }, + adw::HeaderBar { + #[wrap(Some)] + set_title_widget = &adw::WindowTitle { + set_title: &tr!("environment") + }, - pack_start = >k::Button { - set_icon_name: "go-previous-symbolic", + pack_start = >k::Button { + set_icon_name: "go-previous-symbolic", - connect_clicked[sender] => move |_| { - sender.output(EnhancementsAppMsg::OpenMainPage).unwrap(); - } - } - }, - - adw::PreferencesPage { - set_title: &tr!("environment"), - set_icon_name: Some("document-properties-symbolic"), - - add = &adw::PreferencesGroup { - set_title: &tr!("game-command"), - set_description: Some(&tr!("game-command-description")), - - adw::EntryRow { - set_title: "%command%", - set_text: CONFIG.game.command.as_ref().unwrap_or(&String::new()).trim(), - - connect_changed => |entry| { - if let Ok(mut config) = Config::get() { - let command = entry.text().trim().to_string(); - - config.game.command = if command.is_empty() { - None - } else { - Some(command) - }; - - Config::update(config); - } + connect_clicked[sender] => move |_| { + sender.output(EnhancementsAppMsg::OpenMainPage).unwrap(); } } }, - add = &adw::PreferencesGroup { - set_title: &tr!("new-variable"), + adw::PreferencesPage { + set_title: &tr!("environment"), + set_icon_name: Some("document-properties-symbolic"), - #[wrap(Some)] - set_header_suffix = >k::Button { - add_css_class: "flat", + add = &adw::PreferencesGroup { + set_title: &tr!("game-command"), + set_description: Some(&tr!("game-command-description")), - set_valign: gtk::Align::Center, + adw::EntryRow { + set_title: "%command%", + set_text: CONFIG.game.command.as_ref().unwrap_or(&String::new()).trim(), - adw::ButtonContent { - set_icon_name: "list-add-symbolic", - set_label: &tr!("add") + connect_changed => |entry| { + if let Ok(mut config) = Config::get() { + let command = entry.text().trim().to_string(); + + config.game.command = if command.is_empty() { + None + } else { + Some(command) + }; + + Config::update(config); + } + } + } + }, + + add = &adw::PreferencesGroup { + set_title: &tr!("new-variable"), + + #[wrap(Some)] + set_header_suffix = >k::Button { + add_css_class: "flat", + + set_valign: gtk::Align::Center, + + adw::ButtonContent { + set_icon_name: "list-add-symbolic", + set_label: &tr!("add") + }, + + connect_clicked => EnvironmentPageMsg::Add }, - connect_clicked => EnvironmentPageMsg::Add + #[local_ref] + name_entry -> adw::EntryRow { + set_title: &tr!("name") + }, + + #[local_ref] + value_entry -> adw::EntryRow { + set_title: &tr!("value") + } }, #[local_ref] - name_entry -> adw::EntryRow { - set_title: &tr!("name") - }, - - #[local_ref] - value_entry -> adw::EntryRow { - set_title: &tr!("value") - } - }, - - #[local_ref] - add = variables -> adw::PreferencesGroup {} + add = variables -> adw::PreferencesGroup {} + } } } } diff --git a/src/ui/preferences/enhancements/game.rs b/src/ui/preferences/enhancements/game.rs index 081c655..bd9e085 100644 --- a/src/ui/preferences/enhancements/game.rs +++ b/src/ui/preferences/enhancements/game.rs @@ -105,48 +105,51 @@ impl SimpleAsyncComponent for GamePage { type Output = EnhancementsAppMsg; view! { - gtk::Box { - set_orientation: gtk::Orientation::Vertical, + adw::NavigationPage { + #[wrap(Some)] + set_child = >k::Box { + set_orientation: gtk::Orientation::Vertical, - adw::HeaderBar { - #[wrap(Some)] - set_title_widget = &adw::WindowTitle { - set_title: &tr!("game") - }, + adw::HeaderBar { + #[wrap(Some)] + set_title_widget = &adw::WindowTitle { + set_title: &tr!("game") + }, - pack_start = >k::Button { - set_icon_name: "go-previous-symbolic", + pack_start = >k::Button { + set_icon_name: "go-previous-symbolic", - connect_clicked[sender] => move |_| { - sender.output(EnhancementsAppMsg::OpenMainPage).unwrap(); - } - } - }, - - adw::PreferencesPage { - set_title: &tr!("game"), - set_icon_name: Some("applications-games-symbolic"), - - add = &adw::PreferencesGroup { - set_title: &tr!("game-sessions"), - - #[local_ref] - session_name_entry -> adw::EntryRow { - set_title: &tr!("name"), - - add_suffix = >k::Button { - set_icon_name: "list-add-symbolic", - add_css_class: "flat", - - set_valign: gtk::Align::Center, - - connect_clicked => GamePageMsg::AddSession + connect_clicked[sender] => move |_| { + sender.output(EnhancementsAppMsg::OpenMainPage).unwrap(); } } }, - #[local_ref] - add = sessions -> adw::PreferencesGroup {}, + adw::PreferencesPage { + set_title: &tr!("game"), + set_icon_name: Some("applications-games-symbolic"), + + add = &adw::PreferencesGroup { + set_title: &tr!("game-sessions"), + + #[local_ref] + session_name_entry -> adw::EntryRow { + set_title: &tr!("name"), + + add_suffix = >k::Button { + set_icon_name: "list-add-symbolic", + add_css_class: "flat", + + set_valign: gtk::Align::Center, + + connect_clicked => GamePageMsg::AddSession + } + } + }, + + #[local_ref] + add = sessions -> adw::PreferencesGroup {}, + } } } } diff --git a/src/ui/preferences/enhancements/mod.rs b/src/ui/preferences/enhancements/mod.rs index 7a097d3..44ef8bf 100644 --- a/src/ui/preferences/enhancements/mod.rs +++ b/src/ui/preferences/enhancements/mod.rs @@ -627,13 +627,13 @@ impl SimpleAsyncComponent for EnhancementsApp { }, #[local_ref] - game_page -> gtk::Box {}, + game_page -> adw::NavigationPage, #[local_ref] - sandbox_page -> gtk::Box {}, + sandbox_page -> adw::NavigationPage, #[local_ref] - environment_page -> gtk::Box {} + environment_page -> adw::NavigationPage, } async fn init( @@ -769,28 +769,28 @@ impl SimpleAsyncComponent for EnhancementsApp { PREFERENCES_WINDOW.as_ref() .unwrap_unchecked() .widget() - .close_subpage(); + .pop_subpage(); } EnhancementsAppMsg::OpenGameSettingsPage => unsafe { PREFERENCES_WINDOW.as_ref() .unwrap_unchecked() .widget() - .present_subpage(self.game_page.widget()); + .push_subpage(self.game_page.widget()); } EnhancementsAppMsg::OpenSandboxSettingsPage => unsafe { PREFERENCES_WINDOW.as_ref() .unwrap_unchecked() .widget() - .present_subpage(self.sandbox_page.widget()); + .push_subpage(self.sandbox_page.widget()); } EnhancementsAppMsg::OpenEnvironmentSettingsPage => unsafe { PREFERENCES_WINDOW.as_ref() .unwrap_unchecked() .widget() - .present_subpage(self.environment_page.widget()); + .push_subpage(self.environment_page.widget()); } EnhancementsAppMsg::Toast { title, description } => { diff --git a/src/ui/preferences/enhancements/sandbox.rs b/src/ui/preferences/enhancements/sandbox.rs index 60eab07..8abb937 100644 --- a/src/ui/preferences/enhancements/sandbox.rs +++ b/src/ui/preferences/enhancements/sandbox.rs @@ -98,226 +98,229 @@ impl SimpleAsyncComponent for SandboxPage { type Output = EnhancementsAppMsg; view! { - gtk::Box { - set_orientation: gtk::Orientation::Vertical, - - adw::HeaderBar { - #[wrap(Some)] - set_title_widget = &adw::WindowTitle { - set_title: &tr!("sandbox") - }, - - pack_start = >k::Button { - set_icon_name: "go-previous-symbolic", - - connect_clicked[sender] => move |_| { - sender.output(EnhancementsAppMsg::OpenMainPage).unwrap(); - } - } - }, - - adw::PreferencesPage { - set_title: &tr!("sandbox"), - set_icon_name: Some("folder-symbolic"), - - set_sensitive: is_available("bwrap"), - - add = &adw::PreferencesGroup { - set_title: &tr!("sandbox"), - set_description: Some(&tr!("sandbox-description")), - - adw::ActionRow { - set_title: &tr!("enable-sandboxing"), - set_subtitle: &tr!("enable-sandboxing-description"), - - add_suffix = >k::Switch { - set_valign: gtk::Align::Center, - - set_state: CONFIG.sandbox.enabled, - - connect_state_notify => |switch| { - if is_ready() { - if let Ok(mut config) = Config::get() { - config.sandbox.enabled = switch.state(); - - Config::update(config); - } - } - } - } - }, - - adw::ActionRow { - set_title: &tr!("hide-home-directory"), - set_subtitle: &tr!("hide-home-directory-description"), - - add_suffix = >k::Switch { - set_valign: gtk::Align::Center, - - set_state: CONFIG.sandbox.isolate_home, - - connect_state_notify => |switch| { - if is_ready() { - if let Ok(mut config) = Config::get() { - config.sandbox.isolate_home = switch.state(); - - Config::update(config); - } - } - } - } - }, - - adw::EntryRow { - set_title: &tr!("hostname"), - set_text: CONFIG.sandbox.hostname.as_ref().unwrap_or(&String::new()).trim(), - - connect_changed => |entry| { - if let Ok(mut config) = Config::get() { - let command = entry.text().trim().to_string(); - - config.sandbox.hostname = if command.is_empty() { - None - } else { - Some(command) - }; - - Config::update(config); - } - } - }, - - adw::EntryRow { - set_title: &tr!("additional-arguments"), - set_text: CONFIG.sandbox.args.as_ref().unwrap_or(&String::new()).trim(), - - connect_changed => |entry| { - if let Ok(mut config) = Config::get() { - let command = entry.text().trim().to_string(); - - config.sandbox.args = if command.is_empty() { - None - } else { - Some(command) - }; - - Config::update(config); - } - }, - - add_suffix = >k::Button { - set_icon_name: "dialog-information-symbolic", - add_css_class: "flat", - - set_valign: gtk::Align::Center, - - connect_clicked[sender] => move |_| { - if let Err(err) = open::that("https://man.archlinux.org/man/bwrap.1") { - sender.output(EnhancementsAppMsg::Toast { - title: tr!("documentation-url-open-failed"), - description: Some(err.to_string()) - }).unwrap(); - } - } - } - } - }, - - add = &adw::PreferencesGroup { - set_title: &tr!("private-directories"), - set_description: Some(&tr!("private-directories-description")), - - #[local_ref] - private_path_entry -> adw::EntryRow { - set_title: &tr!("path"), - - add_suffix = >k::Button { - set_icon_name: "list-add-symbolic", - add_css_class: "flat", - - set_valign: gtk::Align::Center, - - connect_clicked => SandboxPageMsg::AddPrivate - } - } - }, - - #[local_ref] - add = private_paths -> adw::PreferencesGroup {}, - - add = &adw::PreferencesGroup { - set_title: &tr!("shared-directories"), - set_description: Some(&tr!("shared-directories-description")), + adw::NavigationPage { + #[wrap(Some)] + set_child = >k::Box { + set_orientation: gtk::Orientation::Vertical, + adw::HeaderBar { #[wrap(Some)] - set_header_suffix = >k::Button { - add_css_class: "flat", + set_title_widget = &adw::WindowTitle { + set_title: &tr!("sandbox") + }, - set_valign: gtk::Align::Center, + pack_start = >k::Button { + set_icon_name: "go-previous-symbolic", - adw::ButtonContent { - set_icon_name: "list-add-symbolic", - set_label: &tr!("add") + connect_clicked[sender] => move |_| { + sender.output(EnhancementsAppMsg::OpenMainPage).unwrap(); + } + } + }, + + adw::PreferencesPage { + set_title: &tr!("sandbox"), + set_icon_name: Some("folder-symbolic"), + + set_sensitive: is_available("bwrap"), + + add = &adw::PreferencesGroup { + set_title: &tr!("sandbox"), + set_description: Some(&tr!("sandbox-description")), + + adw::ActionRow { + set_title: &tr!("enable-sandboxing"), + set_subtitle: &tr!("enable-sandboxing-description"), + + add_suffix = >k::Switch { + set_valign: gtk::Align::Center, + + set_state: CONFIG.sandbox.enabled, + + connect_state_notify => |switch| { + if is_ready() { + if let Ok(mut config) = Config::get() { + config.sandbox.enabled = switch.state(); + + Config::update(config); + } + } + } + } }, - connect_clicked => SandboxPageMsg::AddShared + adw::ActionRow { + set_title: &tr!("hide-home-directory"), + set_subtitle: &tr!("hide-home-directory-description"), + + add_suffix = >k::Switch { + set_valign: gtk::Align::Center, + + set_state: CONFIG.sandbox.isolate_home, + + connect_state_notify => |switch| { + if is_ready() { + if let Ok(mut config) = Config::get() { + config.sandbox.isolate_home = switch.state(); + + Config::update(config); + } + } + } + } + }, + + adw::EntryRow { + set_title: &tr!("hostname"), + set_text: CONFIG.sandbox.hostname.as_ref().unwrap_or(&String::new()).trim(), + + connect_changed => |entry| { + if let Ok(mut config) = Config::get() { + let command = entry.text().trim().to_string(); + + config.sandbox.hostname = if command.is_empty() { + None + } else { + Some(command) + }; + + Config::update(config); + } + } + }, + + adw::EntryRow { + set_title: &tr!("additional-arguments"), + set_text: CONFIG.sandbox.args.as_ref().unwrap_or(&String::new()).trim(), + + connect_changed => |entry| { + if let Ok(mut config) = Config::get() { + let command = entry.text().trim().to_string(); + + config.sandbox.args = if command.is_empty() { + None + } else { + Some(command) + }; + + Config::update(config); + } + }, + + add_suffix = >k::Button { + set_icon_name: "dialog-information-symbolic", + add_css_class: "flat", + + set_valign: gtk::Align::Center, + + connect_clicked[sender] => move |_| { + if let Err(err) = open::that("https://man.archlinux.org/man/bwrap.1") { + sender.output(EnhancementsAppMsg::Toast { + title: tr!("documentation-url-open-failed"), + description: Some(err.to_string()) + }).unwrap(); + } + } + } + } }, - #[local_ref] - shared_path_from_entry -> adw::EntryRow { - set_title: &tr!("original-path") - }, - - #[local_ref] - shared_path_to_entry -> adw::EntryRow { - set_title: &tr!("new-path") - }, - - adw::ActionRow { - set_title: &tr!("read-only"), - set_subtitle: &tr!("read-only-description"), + add = &adw::PreferencesGroup { + set_title: &tr!("private-directories"), + set_description: Some(&tr!("private-directories-description")), #[local_ref] - add_suffix = read_only_switch -> gtk::Switch { - set_valign: gtk::Align::Center + private_path_entry -> adw::EntryRow { + set_title: &tr!("path"), + + add_suffix = >k::Button { + set_icon_name: "list-add-symbolic", + add_css_class: "flat", + + set_valign: gtk::Align::Center, + + connect_clicked => SandboxPageMsg::AddPrivate + } } - } - }, + }, - #[local_ref] - add = shared_paths -> adw::PreferencesGroup {}, + #[local_ref] + add = private_paths -> adw::PreferencesGroup {}, - add = &adw::PreferencesGroup { - set_title: &tr!("symlinks"), - set_description: Some(&tr!("symlinks-description")), + add = &adw::PreferencesGroup { + set_title: &tr!("shared-directories"), + set_description: Some(&tr!("shared-directories-description")), - #[wrap(Some)] - set_header_suffix = >k::Button { - add_css_class: "flat", + #[wrap(Some)] + set_header_suffix = >k::Button { + add_css_class: "flat", - set_valign: gtk::Align::Center, + set_valign: gtk::Align::Center, - adw::ButtonContent { - set_icon_name: "list-add-symbolic", - set_label: &tr!("add") + adw::ButtonContent { + set_icon_name: "list-add-symbolic", + set_label: &tr!("add") + }, + + connect_clicked => SandboxPageMsg::AddShared }, - connect_clicked => SandboxPageMsg::AddSymlink + #[local_ref] + shared_path_from_entry -> adw::EntryRow { + set_title: &tr!("original-path") + }, + + #[local_ref] + shared_path_to_entry -> adw::EntryRow { + set_title: &tr!("new-path") + }, + + adw::ActionRow { + set_title: &tr!("read-only"), + set_subtitle: &tr!("read-only-description"), + + #[local_ref] + add_suffix = read_only_switch -> gtk::Switch { + set_valign: gtk::Align::Center + } + } }, #[local_ref] - symlink_path_from_entry -> adw::EntryRow { - set_title: &tr!("original-path") + add = shared_paths -> adw::PreferencesGroup {}, + + add = &adw::PreferencesGroup { + set_title: &tr!("symlinks"), + set_description: Some(&tr!("symlinks-description")), + + #[wrap(Some)] + set_header_suffix = >k::Button { + add_css_class: "flat", + + set_valign: gtk::Align::Center, + + adw::ButtonContent { + set_icon_name: "list-add-symbolic", + set_label: &tr!("add") + }, + + connect_clicked => SandboxPageMsg::AddSymlink + }, + + #[local_ref] + symlink_path_from_entry -> adw::EntryRow { + set_title: &tr!("original-path") + }, + + #[local_ref] + symlink_path_to_entry -> adw::EntryRow { + set_title: &tr!("new-path") + } }, #[local_ref] - symlink_path_to_entry -> adw::EntryRow { - set_title: &tr!("new-path") - } - }, - - #[local_ref] - add = symlink_paths -> adw::PreferencesGroup {} + add = symlink_paths -> adw::PreferencesGroup {} + } } } } diff --git a/src/ui/preferences/general/components.rs b/src/ui/preferences/general/components.rs index cc51737..20b7433 100644 --- a/src/ui/preferences/general/components.rs +++ b/src/ui/preferences/general/components.rs @@ -49,193 +49,196 @@ impl SimpleAsyncComponent for ComponentsPage { type Output = GeneralAppMsg; view! { - gtk::Box { - set_orientation: gtk::Orientation::Vertical, + adw::NavigationPage { + #[wrap(Some)] + set_child = >k::Box { + set_orientation: gtk::Orientation::Vertical, - adw::HeaderBar { - #[wrap(Some)] - set_title_widget = &adw::WindowTitle { - set_title: &tr!("components") + adw::HeaderBar { + #[wrap(Some)] + set_title_widget = &adw::WindowTitle { + set_title: &tr!("components") + }, + + pack_start = >k::Button { + set_icon_name: "go-previous-symbolic", + + connect_clicked[sender] => move |_| { + sender.output(GeneralAppMsg::OpenMainPage).unwrap(); + } + } }, - pack_start = >k::Button { - set_icon_name: "go-previous-symbolic", + adw::PreferencesPage { + add = &adw::PreferencesGroup { + set_title: &tr!("wine-version"), - connect_clicked[sender] => move |_| { - sender.output(GeneralAppMsg::OpenMainPage).unwrap(); - } + adw::ComboRow { + set_title: &tr!("selected-version"), + + #[watch] + #[block_signal(wine_selected_notify)] + set_model: Some(>k::StringList::new(&model.downloaded_wine_versions.iter().map(|(version, _)| version.title.as_str()).collect::>())), + + #[watch] + #[block_signal(wine_selected_notify)] + set_selected: model.selected_wine_version, + + #[watch] + set_activatable: !model.selecting_wine_version, + + connect_selected_notify[sender] => move |row| { + if is_ready() { + sender.input(ComponentsPageMsg::SelectWine(row.selected() as usize)); + } + } @wine_selected_notify, + + add_suffix = >k::Spinner { + set_spinning: true, + + #[watch] + set_visible: model.selecting_wine_version + } + }, + + adw::ActionRow { + set_title: &tr!("recommended-only"), + set_subtitle: &tr!("wine-recommended-description"), + + add_suffix = >k::Switch { + set_valign: gtk::Align::Center, + + #[block_signal(wine_recommended_notify)] + set_state: true, + + connect_state_notify[sender] => move |switch| { + if is_ready() { + sender.input(ComponentsPageMsg::WineRecommendedOnly(switch.state())); + } + } @wine_recommended_notify + } + } + }, + + add = &adw::PreferencesGroup { + add = model.wine_components.widget(), + }, + + add = &adw::PreferencesGroup { + set_title: &tr!("wine-options"), + + adw::ActionRow { + set_title: &tr!("wine-use-shared-libraries"), + set_subtitle: &tr!("wine-use-shared-libraries-description"), + + add_suffix = >k::Switch { + set_valign: gtk::Align::Center, + + #[block_signal(wine_shared_libraries_notify)] + set_state: CONFIG.game.wine.shared_libraries.wine, + + connect_state_notify => |switch| { + if is_ready() { + if let Ok(mut config) = Config::get() { + config.game.wine.shared_libraries.wine = switch.state(); + + Config::update(config); + } + } + } @wine_shared_libraries_notify + } + }, + + adw::ActionRow { + set_title: &tr!("gstreamer-use-shared-libraries"), + set_subtitle: &tr!("gstreamer-use-shared-libraries-description"), + + add_suffix = >k::Switch { + set_valign: gtk::Align::Center, + + #[block_signal(gstreamer_shared_libraries_notify)] + set_state: CONFIG.game.wine.shared_libraries.gstreamer, + + connect_state_notify => |switch| { + if is_ready() { + if let Ok(mut config) = Config::get() { + config.game.wine.shared_libraries.gstreamer = switch.state(); + + Config::update(config); + } + } + } @gstreamer_shared_libraries_notify + } + } + }, + + add = &adw::PreferencesGroup { + set_title: &tr!("dxvk-version"), + + #[watch] + set_description: Some(&if !model.allow_dxvk_selection { + tr!("dxvk-selection-disabled") + } else { + String::new() + }), + + #[watch] + set_sensitive: model.allow_dxvk_selection, + + adw::ComboRow { + set_title: &tr!("selected-version"), + + #[watch] + #[block_signal(dxvk_selected_notify)] + set_model: Some(>k::StringList::new(&model.downloaded_dxvk_versions.iter().map(|version| version.name.as_str()).collect::>())), + + #[watch] + #[block_signal(dxvk_selected_notify)] + set_selected: model.selected_dxvk_version, + + #[watch] + set_activatable: !model.selecting_dxvk_version, + + connect_selected_notify[sender] => move |row| { + if is_ready() { + sender.input(ComponentsPageMsg::SelectDxvk(row.selected() as usize)); + } + } @dxvk_selected_notify, + + add_suffix = >k::Spinner { + set_spinning: true, + + #[watch] + set_visible: model.selecting_dxvk_version + } + }, + + adw::ActionRow { + set_title: &tr!("recommended-only"), + set_subtitle: &tr!("dxvk-recommended-description"), + + add_suffix = >k::Switch { + set_valign: gtk::Align::Center, + + #[block_signal(dxvk_recommended_notify)] + set_state: true, + + connect_state_notify[sender] => move |switch| { + if is_ready() { + sender.input(ComponentsPageMsg::DxvkRecommendedOnly(switch.state())); + } + } @dxvk_recommended_notify + } + } + }, + + add = &adw::PreferencesGroup { + #[watch] + set_sensitive: model.allow_dxvk_selection, + + add = model.dxvk_components.widget(), + }, } - }, - - adw::PreferencesPage { - add = &adw::PreferencesGroup { - set_title: &tr!("wine-version"), - - adw::ComboRow { - set_title: &tr!("selected-version"), - - #[watch] - #[block_signal(wine_selected_notify)] - set_model: Some(>k::StringList::new(&model.downloaded_wine_versions.iter().map(|(version, _)| version.title.as_str()).collect::>())), - - #[watch] - #[block_signal(wine_selected_notify)] - set_selected: model.selected_wine_version, - - #[watch] - set_activatable: !model.selecting_wine_version, - - connect_selected_notify[sender] => move |row| { - if is_ready() { - sender.input(ComponentsPageMsg::SelectWine(row.selected() as usize)); - } - } @wine_selected_notify, - - add_suffix = >k::Spinner { - set_spinning: true, - - #[watch] - set_visible: model.selecting_wine_version - } - }, - - adw::ActionRow { - set_title: &tr!("recommended-only"), - set_subtitle: &tr!("wine-recommended-description"), - - add_suffix = >k::Switch { - set_valign: gtk::Align::Center, - - #[block_signal(wine_recommended_notify)] - set_state: true, - - connect_state_notify[sender] => move |switch| { - if is_ready() { - sender.input(ComponentsPageMsg::WineRecommendedOnly(switch.state())); - } - } @wine_recommended_notify - } - } - }, - - add = &adw::PreferencesGroup { - add = model.wine_components.widget(), - }, - - add = &adw::PreferencesGroup { - set_title: &tr!("wine-options"), - - adw::ActionRow { - set_title: &tr!("wine-use-shared-libraries"), - set_subtitle: &tr!("wine-use-shared-libraries-description"), - - add_suffix = >k::Switch { - set_valign: gtk::Align::Center, - - #[block_signal(wine_shared_libraries_notify)] - set_state: CONFIG.game.wine.shared_libraries.wine, - - connect_state_notify => |switch| { - if is_ready() { - if let Ok(mut config) = Config::get() { - config.game.wine.shared_libraries.wine = switch.state(); - - Config::update(config); - } - } - } @wine_shared_libraries_notify - } - }, - - adw::ActionRow { - set_title: &tr!("gstreamer-use-shared-libraries"), - set_subtitle: &tr!("gstreamer-use-shared-libraries-description"), - - add_suffix = >k::Switch { - set_valign: gtk::Align::Center, - - #[block_signal(gstreamer_shared_libraries_notify)] - set_state: CONFIG.game.wine.shared_libraries.gstreamer, - - connect_state_notify => |switch| { - if is_ready() { - if let Ok(mut config) = Config::get() { - config.game.wine.shared_libraries.gstreamer = switch.state(); - - Config::update(config); - } - } - } @gstreamer_shared_libraries_notify - } - } - }, - - add = &adw::PreferencesGroup { - set_title: &tr!("dxvk-version"), - - #[watch] - set_description: Some(&if !model.allow_dxvk_selection { - tr!("dxvk-selection-disabled") - } else { - String::new() - }), - - #[watch] - set_sensitive: model.allow_dxvk_selection, - - adw::ComboRow { - set_title: &tr!("selected-version"), - - #[watch] - #[block_signal(dxvk_selected_notify)] - set_model: Some(>k::StringList::new(&model.downloaded_dxvk_versions.iter().map(|version| version.name.as_str()).collect::>())), - - #[watch] - #[block_signal(dxvk_selected_notify)] - set_selected: model.selected_dxvk_version, - - #[watch] - set_activatable: !model.selecting_dxvk_version, - - connect_selected_notify[sender] => move |row| { - if is_ready() { - sender.input(ComponentsPageMsg::SelectDxvk(row.selected() as usize)); - } - } @dxvk_selected_notify, - - add_suffix = >k::Spinner { - set_spinning: true, - - #[watch] - set_visible: model.selecting_dxvk_version - } - }, - - adw::ActionRow { - set_title: &tr!("recommended-only"), - set_subtitle: &tr!("dxvk-recommended-description"), - - add_suffix = >k::Switch { - set_valign: gtk::Align::Center, - - #[block_signal(dxvk_recommended_notify)] - set_state: true, - - connect_state_notify[sender] => move |switch| { - if is_ready() { - sender.input(ComponentsPageMsg::DxvkRecommendedOnly(switch.state())); - } - } @dxvk_recommended_notify - } - } - }, - - add = &adw::PreferencesGroup { - #[watch] - set_sensitive: model.allow_dxvk_selection, - - add = model.dxvk_components.widget(), - }, } } } diff --git a/src/ui/preferences/general/mod.rs b/src/ui/preferences/general/mod.rs index 1300115..1a2eeb7 100644 --- a/src/ui/preferences/general/mod.rs +++ b/src/ui/preferences/general/mod.rs @@ -528,7 +528,7 @@ impl SimpleAsyncComponent for GeneralApp { }, #[local_ref] - components_page -> gtk::Box {} + components_page -> adw::NavigationPage, } async fn init( @@ -664,14 +664,14 @@ impl SimpleAsyncComponent for GeneralApp { PREFERENCES_WINDOW.as_ref() .unwrap_unchecked() .widget() - .close_subpage(); + .pop_subpage(); } GeneralAppMsg::OpenComponentsPage => unsafe { PREFERENCES_WINDOW.as_ref() .unwrap_unchecked() .widget() - .present_subpage(self.components_page.widget()); + .push_subpage(self.components_page.widget()); } #[allow(unused_must_use)]