feat: get rid of deprecated libadwaita functions calls

This commit is contained in:
Observer KRypt0n_ 2024-03-24 10:10:14 +02:00
parent a1d1950ce8
commit 9914072c77
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
6 changed files with 496 additions and 484 deletions

View file

@ -71,82 +71,85 @@ impl SimpleAsyncComponent for EnvironmentPage {
type Output = EnhancementsAppMsg; type Output = EnhancementsAppMsg;
view! { view! {
gtk::Box { adw::NavigationPage {
set_orientation: gtk::Orientation::Vertical, #[wrap(Some)]
set_child = &gtk::Box {
set_orientation: gtk::Orientation::Vertical,
adw::HeaderBar { adw::HeaderBar {
#[wrap(Some)] #[wrap(Some)]
set_title_widget = &adw::WindowTitle { set_title_widget = &adw::WindowTitle {
set_title: &tr!("environment") set_title: &tr!("environment")
}, },
pack_start = &gtk::Button { pack_start = &gtk::Button {
set_icon_name: "go-previous-symbolic", set_icon_name: "go-previous-symbolic",
connect_clicked[sender] => move |_| { connect_clicked[sender] => move |_| {
sender.output(EnhancementsAppMsg::OpenMainPage).unwrap(); 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);
}
} }
} }
}, },
add = &adw::PreferencesGroup { adw::PreferencesPage {
set_title: &tr!("new-variable"), set_title: &tr!("environment"),
set_icon_name: Some("document-properties-symbolic"),
#[wrap(Some)] add = &adw::PreferencesGroup {
set_header_suffix = &gtk::Button { set_title: &tr!("game-command"),
add_css_class: "flat", 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 { connect_changed => |entry| {
set_icon_name: "list-add-symbolic", if let Ok(mut config) = Config::get() {
set_label: &tr!("add") 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 = &gtk::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] #[local_ref]
name_entry -> adw::EntryRow { add = variables -> adw::PreferencesGroup {}
set_title: &tr!("name") }
},
#[local_ref]
value_entry -> adw::EntryRow {
set_title: &tr!("value")
}
},
#[local_ref]
add = variables -> adw::PreferencesGroup {}
} }
} }
} }

View file

@ -105,48 +105,51 @@ impl SimpleAsyncComponent for GamePage {
type Output = EnhancementsAppMsg; type Output = EnhancementsAppMsg;
view! { view! {
gtk::Box { adw::NavigationPage {
set_orientation: gtk::Orientation::Vertical, #[wrap(Some)]
set_child = &gtk::Box {
set_orientation: gtk::Orientation::Vertical,
adw::HeaderBar { adw::HeaderBar {
#[wrap(Some)] #[wrap(Some)]
set_title_widget = &adw::WindowTitle { set_title_widget = &adw::WindowTitle {
set_title: &tr!("game") set_title: &tr!("game")
}, },
pack_start = &gtk::Button { pack_start = &gtk::Button {
set_icon_name: "go-previous-symbolic", set_icon_name: "go-previous-symbolic",
connect_clicked[sender] => move |_| { connect_clicked[sender] => move |_| {
sender.output(EnhancementsAppMsg::OpenMainPage).unwrap(); 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 = &gtk::Button {
set_icon_name: "list-add-symbolic",
add_css_class: "flat",
set_valign: gtk::Align::Center,
connect_clicked => GamePageMsg::AddSession
} }
} }
}, },
#[local_ref] adw::PreferencesPage {
add = sessions -> adw::PreferencesGroup {}, 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 = &gtk::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 {},
}
} }
} }
} }

View file

@ -627,13 +627,13 @@ impl SimpleAsyncComponent for EnhancementsApp {
}, },
#[local_ref] #[local_ref]
game_page -> gtk::Box {}, game_page -> adw::NavigationPage,
#[local_ref] #[local_ref]
sandbox_page -> gtk::Box {}, sandbox_page -> adw::NavigationPage,
#[local_ref] #[local_ref]
environment_page -> gtk::Box {} environment_page -> adw::NavigationPage,
} }
async fn init( async fn init(
@ -769,28 +769,28 @@ impl SimpleAsyncComponent for EnhancementsApp {
PREFERENCES_WINDOW.as_ref() PREFERENCES_WINDOW.as_ref()
.unwrap_unchecked() .unwrap_unchecked()
.widget() .widget()
.close_subpage(); .pop_subpage();
} }
EnhancementsAppMsg::OpenGameSettingsPage => unsafe { EnhancementsAppMsg::OpenGameSettingsPage => unsafe {
PREFERENCES_WINDOW.as_ref() PREFERENCES_WINDOW.as_ref()
.unwrap_unchecked() .unwrap_unchecked()
.widget() .widget()
.present_subpage(self.game_page.widget()); .push_subpage(self.game_page.widget());
} }
EnhancementsAppMsg::OpenSandboxSettingsPage => unsafe { EnhancementsAppMsg::OpenSandboxSettingsPage => unsafe {
PREFERENCES_WINDOW.as_ref() PREFERENCES_WINDOW.as_ref()
.unwrap_unchecked() .unwrap_unchecked()
.widget() .widget()
.present_subpage(self.sandbox_page.widget()); .push_subpage(self.sandbox_page.widget());
} }
EnhancementsAppMsg::OpenEnvironmentSettingsPage => unsafe { EnhancementsAppMsg::OpenEnvironmentSettingsPage => unsafe {
PREFERENCES_WINDOW.as_ref() PREFERENCES_WINDOW.as_ref()
.unwrap_unchecked() .unwrap_unchecked()
.widget() .widget()
.present_subpage(self.environment_page.widget()); .push_subpage(self.environment_page.widget());
} }
EnhancementsAppMsg::Toast { title, description } => { EnhancementsAppMsg::Toast { title, description } => {

View file

@ -98,226 +98,229 @@ impl SimpleAsyncComponent for SandboxPage {
type Output = EnhancementsAppMsg; type Output = EnhancementsAppMsg;
view! { view! {
gtk::Box { adw::NavigationPage {
set_orientation: gtk::Orientation::Vertical, #[wrap(Some)]
set_child = &gtk::Box {
adw::HeaderBar { set_orientation: gtk::Orientation::Vertical,
#[wrap(Some)]
set_title_widget = &adw::WindowTitle {
set_title: &tr!("sandbox")
},
pack_start = &gtk::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 = &gtk::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 = &gtk::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 = &gtk::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 = &gtk::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::HeaderBar {
#[wrap(Some)] #[wrap(Some)]
set_header_suffix = &gtk::Button { set_title_widget = &adw::WindowTitle {
add_css_class: "flat", set_title: &tr!("sandbox")
},
set_valign: gtk::Align::Center, pack_start = &gtk::Button {
set_icon_name: "go-previous-symbolic",
adw::ButtonContent { connect_clicked[sender] => move |_| {
set_icon_name: "list-add-symbolic", sender.output(EnhancementsAppMsg::OpenMainPage).unwrap();
set_label: &tr!("add") }
}
},
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 = &gtk::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 = &gtk::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 = &gtk::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] add = &adw::PreferencesGroup {
shared_path_from_entry -> adw::EntryRow { set_title: &tr!("private-directories"),
set_title: &tr!("original-path") set_description: Some(&tr!("private-directories-description")),
},
#[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] #[local_ref]
add_suffix = read_only_switch -> gtk::Switch { private_path_entry -> adw::EntryRow {
set_valign: gtk::Align::Center set_title: &tr!("path"),
add_suffix = &gtk::Button {
set_icon_name: "list-add-symbolic",
add_css_class: "flat",
set_valign: gtk::Align::Center,
connect_clicked => SandboxPageMsg::AddPrivate
}
} }
} },
},
#[local_ref] #[local_ref]
add = shared_paths -> adw::PreferencesGroup {}, add = private_paths -> adw::PreferencesGroup {},
add = &adw::PreferencesGroup { add = &adw::PreferencesGroup {
set_title: &tr!("symlinks"), set_title: &tr!("shared-directories"),
set_description: Some(&tr!("symlinks-description")), set_description: Some(&tr!("shared-directories-description")),
#[wrap(Some)] #[wrap(Some)]
set_header_suffix = &gtk::Button { set_header_suffix = &gtk::Button {
add_css_class: "flat", add_css_class: "flat",
set_valign: gtk::Align::Center, set_valign: gtk::Align::Center,
adw::ButtonContent { adw::ButtonContent {
set_icon_name: "list-add-symbolic", set_icon_name: "list-add-symbolic",
set_label: &tr!("add") 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] #[local_ref]
symlink_path_from_entry -> adw::EntryRow { add = shared_paths -> adw::PreferencesGroup {},
set_title: &tr!("original-path")
add = &adw::PreferencesGroup {
set_title: &tr!("symlinks"),
set_description: Some(&tr!("symlinks-description")),
#[wrap(Some)]
set_header_suffix = &gtk::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] #[local_ref]
symlink_path_to_entry -> adw::EntryRow { add = symlink_paths -> adw::PreferencesGroup {}
set_title: &tr!("new-path") }
}
},
#[local_ref]
add = symlink_paths -> adw::PreferencesGroup {}
} }
} }
} }

View file

@ -49,193 +49,196 @@ impl SimpleAsyncComponent for ComponentsPage {
type Output = GeneralAppMsg; type Output = GeneralAppMsg;
view! { view! {
gtk::Box { adw::NavigationPage {
set_orientation: gtk::Orientation::Vertical, #[wrap(Some)]
set_child = &gtk::Box {
set_orientation: gtk::Orientation::Vertical,
adw::HeaderBar { adw::HeaderBar {
#[wrap(Some)] #[wrap(Some)]
set_title_widget = &adw::WindowTitle { set_title_widget = &adw::WindowTitle {
set_title: &tr!("components") set_title: &tr!("components")
},
pack_start = &gtk::Button {
set_icon_name: "go-previous-symbolic",
connect_clicked[sender] => move |_| {
sender.output(GeneralAppMsg::OpenMainPage).unwrap();
}
}
}, },
pack_start = &gtk::Button { adw::PreferencesPage {
set_icon_name: "go-previous-symbolic", add = &adw::PreferencesGroup {
set_title: &tr!("wine-version"),
connect_clicked[sender] => move |_| { adw::ComboRow {
sender.output(GeneralAppMsg::OpenMainPage).unwrap(); set_title: &tr!("selected-version"),
}
#[watch]
#[block_signal(wine_selected_notify)]
set_model: Some(&gtk::StringList::new(&model.downloaded_wine_versions.iter().map(|(version, _)| version.title.as_str()).collect::<Vec<&str>>())),
#[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 = &gtk::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 = &gtk::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 = &gtk::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 = &gtk::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(&gtk::StringList::new(&model.downloaded_dxvk_versions.iter().map(|version| version.name.as_str()).collect::<Vec<&str>>())),
#[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 = &gtk::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 = &gtk::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(&gtk::StringList::new(&model.downloaded_wine_versions.iter().map(|(version, _)| version.title.as_str()).collect::<Vec<&str>>())),
#[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 = &gtk::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 = &gtk::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 = &gtk::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 = &gtk::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(&gtk::StringList::new(&model.downloaded_dxvk_versions.iter().map(|version| version.name.as_str()).collect::<Vec<&str>>())),
#[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 = &gtk::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 = &gtk::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(),
},
} }
} }
} }

View file

@ -528,7 +528,7 @@ impl SimpleAsyncComponent for GeneralApp {
}, },
#[local_ref] #[local_ref]
components_page -> gtk::Box {} components_page -> adw::NavigationPage,
} }
async fn init( async fn init(
@ -664,14 +664,14 @@ impl SimpleAsyncComponent for GeneralApp {
PREFERENCES_WINDOW.as_ref() PREFERENCES_WINDOW.as_ref()
.unwrap_unchecked() .unwrap_unchecked()
.widget() .widget()
.close_subpage(); .pop_subpage();
} }
GeneralAppMsg::OpenComponentsPage => unsafe { GeneralAppMsg::OpenComponentsPage => unsafe {
PREFERENCES_WINDOW.as_ref() PREFERENCES_WINDOW.as_ref()
.unwrap_unchecked() .unwrap_unchecked()
.widget() .widget()
.present_subpage(self.components_page.widget()); .push_subpage(self.components_page.widget());
} }
#[allow(unused_must_use)] #[allow(unused_must_use)]