diff --git a/repos/gems/src/app/sculpt_manager/main.cc b/repos/gems/src/app/sculpt_manager/main.cc index 1bc8c04eb3..d8d6850962 100644 --- a/repos/gems/src/app/sculpt_manager/main.cc +++ b/repos/gems/src/app/sculpt_manager/main.cc @@ -407,6 +407,7 @@ struct Sculpt::Main : Input_event_handler, { _scan_rom.update(); _popup_dialog.depot_users_scan_updated(); + _system_dialog.sanitize_user_selection(); } Attached_rom_dataspace _image_index_rom { _env, "report -> runtime/depot_query/image_index" }; diff --git a/repos/gems/src/app/sculpt_manager/view/depot_users_dialog.h b/repos/gems/src/app/sculpt_manager/view/depot_users_dialog.h index 24d72eb874..50864d6f85 100644 --- a/repos/gems/src/app/sculpt_manager/view/depot_users_dialog.h +++ b/repos/gems/src/app/sculpt_manager/view/depot_users_dialog.h @@ -39,6 +39,8 @@ struct Sculpt::Depot_users_dialog using Url_edit_field = Text_entry_field<50>; + User const _default_user; + Depot_users const &_depot_users; Action &_action; @@ -227,7 +229,8 @@ struct Sculpt::Depot_users_dialog User const &default_user, Action &action) : - _depot_users(depot_users), _action(action), _selected(default_user) + _default_user(default_user), _depot_users(depot_users), + _action(action), _selected(default_user) { } User selected() const @@ -325,6 +328,24 @@ struct Sculpt::Depot_users_dialog } bool one_selected() const { return !_unfolded && _selected.length() > 1; } + + void sanitize_unfold_state() + { + /* + * If the selected depot user does not exist in the depot, show + * list of available users. + */ + bool selected_user_exists = false; + + _depot_users.xml().for_each_sub_node([&] (Xml_node const &user) { + if (_selected == user.attribute_value("name", User())) + selected_user_exists = true; }); + + if (!selected_user_exists) { + _selected = _default_user; + _unfolded = true; + } + } }; #endif /* _VIEW__DEPOT_USERS_DIALOG_H_ */ diff --git a/repos/gems/src/app/sculpt_manager/view/software_update_dialog.h b/repos/gems/src/app/sculpt_manager/view/software_update_dialog.h index 9fa59e4f21..d09afdf1cc 100644 --- a/repos/gems/src/app/sculpt_manager/view/software_update_dialog.h +++ b/repos/gems/src/app/sculpt_manager/view/software_update_dialog.h @@ -356,6 +356,8 @@ struct Sculpt::Software_update_dialog bool keyboard_needed() const { return _users.keyboard_needed(); } void handle_key(Codepoint c) { _users.handle_key(c); } + + void sanitize_user_selection() { _users.sanitize_unfold_state(); } }; #endif /* _VIEW__SOFTWARE_UPDATE_DIALOG_H_ */ diff --git a/repos/gems/src/app/sculpt_manager/view/system_dialog.h b/repos/gems/src/app/sculpt_manager/view/system_dialog.h index 2199c56eee..a202cb39ae 100644 --- a/repos/gems/src/app/sculpt_manager/view/system_dialog.h +++ b/repos/gems/src/app/sculpt_manager/view/system_dialog.h @@ -137,6 +137,8 @@ struct Sculpt::System_dialog : Noncopyable, Dialog bool keyboard_needed() const { return _update_dialog.keyboard_needed(); } void handle_key(Codepoint c) { _update_dialog.handle_key(c); } + + void sanitize_user_selection() { _update_dialog.sanitize_user_selection(); } }; #endif /* _VIEW__SYSTEM_DIALOG_H_ */