diff --git a/src/ui/app.rs b/src/ui/app.rs index c687e34..a5694ee 100644 --- a/src/ui/app.rs +++ b/src/ui/app.rs @@ -102,6 +102,8 @@ pub struct App { wivrn_conf_editor: Option>, skip_depcheck: bool, configure_wivrn_action: gtk::gio::SimpleAction, + build_profile_action: gtk::gio::SimpleAction, + clean_build_profile_action: gtk::gio::SimpleAction, openxr_prober_worker: Option, xrservice_ready: bool, vkinfo: Option, @@ -1180,6 +1182,8 @@ impl AsyncComponent for App { self.monado_gui_worker = None; } Msg::ProfilesEnabledChanged(enabled) => { + self.build_profile_action.set_enabled(enabled); + self.clean_build_profile_action.set_enabled(enabled); self.config.profiles_enabled = enabled; self.config.save(); sender.input(Msg::ProfileSelected(self.get_selected_profile())); @@ -1219,28 +1223,6 @@ impl AsyncComponent for App { let mut actions = RelmActionGroup::::new(); - stateless_action!( - actions, - BuildProfileAction, - clone!( - #[strong] - sender, - move |_| { - sender.input_sender().emit(Msg::BuildProfile(false)); - } - ) - ); - stateless_action!( - actions, - BuildProfileCleanAction, - clone!( - #[strong] - sender, - move |_| { - sender.input_sender().emit(Msg::BuildProfile(true)); - } - ) - ); stateless_action!( actions, QuitAction, @@ -1333,6 +1315,29 @@ impl AsyncComponent for App { ret.set_enabled(false); ret }; + let build_profile_action = { + let action = RelmAction::::new_stateless(clone!( + #[strong] + sender, + move |_| { sender.input(Msg::BuildProfile(false)) } + )); + let ret = action.gio_action().clone(); + actions.add_action(action); + ret.set_enabled(config.profiles_enabled); + ret + }; + let clean_build_profile_action = { + let action = RelmAction::::new_stateless(clone!( + #[strong] + sender, + move |_| { sender.input(Msg::BuildProfile(true)) } + )); + let ret = action.gio_action().clone(); + actions.add_action(action); + ret.set_enabled(config.profiles_enabled); + ret + }; + let selected_profile = if config.profiles_enabled { config.get_selected_profile(&profiles) } else { @@ -1421,6 +1426,8 @@ impl AsyncComponent for App { wivrn_conf_editor: None, skip_depcheck: false, configure_wivrn_action, + build_profile_action, + clean_build_profile_action, openxr_prober_worker: None, xrservice_ready: false, inhibit_fail_notif: None, diff --git a/src/ui/debug_view.rs b/src/ui/debug_view.rs index 4b20e39..cd93c77 100644 --- a/src/ui/debug_view.rs +++ b/src/ui/debug_view.rs @@ -14,6 +14,7 @@ use crate::{ ui::{ SENDER_IO_ERR_MSG, alert::alert, + app::{BuildProfileAction, BuildProfileCleanAction}, profile_editor::{ProfileEditor, ProfileEditorInit, ProfileEditorMsg, ProfileEditorOutMsg}, util::limit_dropdown_width, }, @@ -143,6 +144,8 @@ impl AsyncComponent for DebugView { debug_menu: { section! { custom: "profile_id_widget", + "_Build profile" => BuildProfileAction, + "C_lean build profile" => BuildProfileCleanAction, }, section! { "Open _Data Folder" => DebugOpenDataAction, @@ -347,6 +350,7 @@ impl AsyncComponent for DebugView { self.set_profile(prof.clone()); self.profile_id_widget .set_label(&format!("Profile id: {}", self.profile.uuid)); + self.profile_id_widget.set_visible(!prof.is_system_profile); self.profile_delete_action.set_enabled(prof.editable); self.profile_export_action.set_enabled(prof.editable); } @@ -364,20 +368,22 @@ impl AsyncComponent for DebugView { } Self::Input::UpdateProfiles(profiles, config) => { self.set_profiles(profiles); - // why send another message to set the dropdown selection? - // set_* from tracker likely updates the view obj in the next - // draw, so selecting here will result in nothing cause the - // dropdown is effectively empty - sender.input(Self::Input::SetSelectedProfile({ - match self - .profiles - .iter() - .position(|p| p.uuid == config.selected_profile_uuid) - { - Some(idx) => idx as u32, - None => 0, - } - })); + if (config.profiles_enabled) { + // why send another message to set the dropdown selection? + // set_* from tracker likely updates the view obj in the next + // draw, so selecting here will result in nothing cause the + // dropdown is effectively empty + sender.input(Self::Input::SetSelectedProfile({ + match self + .profiles + .iter() + .position(|p| p.uuid == config.selected_profile_uuid) + { + Some(idx) => idx as u32, + None => 0, + } + })); + } } Self::Input::SetSelectedProfile(index) => { if let Some(dd) = self.profiles_dropdown.as_ref() { @@ -533,6 +539,7 @@ impl AsyncComponent for DebugView { } Self::Input::ProfilesEnabledChanged(enabled) => { self.set_profiles_enabled(enabled); + self.profile_id_widget.set_visible(enabled); sender .output(Self::Output::ProfilesEnabledChanged(enabled)) .expect(SENDER_IO_ERR_MSG); @@ -752,6 +759,7 @@ impl AsyncComponent for DebugView { .css_classes(["flat", "dim-label", "caption"]) .label(format!("Profile id: {}", init.profile.uuid)) .tooltip_text("Copy") + .visible(init.profiles_enabled) .build(), profile: init.profile, profiles: Vec::new(), diff --git a/src/ui/main_view.rs b/src/ui/main_view.rs index 9423090..7bf81b0 100644 --- a/src/ui/main_view.rs +++ b/src/ui/main_view.rs @@ -1,9 +1,6 @@ use super::{ SENDER_IO_ERR_MSG, - app::{ - AboutAction, BuildProfileAction, BuildProfileCleanAction, ConfigureWivrnAction, - DebugViewToggleAction, PluginStoreAction, - }, + app::{AboutAction, ConfigureWivrnAction, DebugViewToggleAction, PluginStoreAction}, devices_box::{DevicesBox, DevicesBoxMsg}, install_wivrn_box::{InstallWivrnBox, InstallWivrnBoxInit, InstallWivrnBoxMsg}, openhmd_calibration_box::{OpenHmdCalibrationBox, OpenHmdCalibrationBoxMsg}, @@ -98,8 +95,6 @@ impl AsyncComponent for MainView { // value inside action is ignored "_Preferences" => PreferencesAction, "_Developer mode" => DebugViewToggleAction, - "_Build profile" => BuildProfileAction, - "C_lean build profile" => BuildProfileCleanAction, "Configure _WiVRn" => ConfigureWivrnAction, }, section! {