mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:47:44 +00:00
WindowServer: Allow updating the name of a menu
This commit is contained in:
parent
952f6bbb2a
commit
cf730403ea
5 changed files with 29 additions and 0 deletions
|
@ -96,6 +96,27 @@ void ConnectionFromClient::create_menu(i32 menu_id, DeprecatedString const& name
|
||||||
m_menus.set(menu_id, move(menu));
|
m_menus.set(menu_id, move(menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConnectionFromClient::set_menu_name(i32 menu_id, DeprecatedString const& name)
|
||||||
|
{
|
||||||
|
auto it = m_menus.find(menu_id);
|
||||||
|
if (it == m_menus.end()) {
|
||||||
|
did_misbehave("DestroyMenu: Bad menu ID");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto& menu = *it->value;
|
||||||
|
menu.set_name(name);
|
||||||
|
for (auto& it : m_windows) {
|
||||||
|
auto& window = *it.value;
|
||||||
|
window.menubar().for_each_menu([&](Menu& other_menu) {
|
||||||
|
if (&menu == &other_menu) {
|
||||||
|
window.invalidate_menubar();
|
||||||
|
return IterationDecision::Break;
|
||||||
|
}
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ConnectionFromClient::destroy_menu(i32 menu_id)
|
void ConnectionFromClient::destroy_menu(i32 menu_id)
|
||||||
{
|
{
|
||||||
auto it = m_menus.find(menu_id);
|
auto it = m_menus.find(menu_id);
|
||||||
|
|
|
@ -94,6 +94,7 @@ private:
|
||||||
void destroy_window(Window&, Vector<i32>& destroyed_window_ids);
|
void destroy_window(Window&, Vector<i32>& destroyed_window_ids);
|
||||||
|
|
||||||
virtual void create_menu(i32, DeprecatedString const&) override;
|
virtual void create_menu(i32, DeprecatedString const&) override;
|
||||||
|
virtual void set_menu_name(i32, DeprecatedString const&) override;
|
||||||
virtual void destroy_menu(i32) override;
|
virtual void destroy_menu(i32) override;
|
||||||
virtual void add_menu(i32, i32) override;
|
virtual void add_menu(i32, i32) override;
|
||||||
virtual void add_menu_item(i32, i32, i32, DeprecatedString const&, bool, bool, bool, bool, bool, DeprecatedString const&, Gfx::ShareableBitmap const&, bool) override;
|
virtual void add_menu_item(i32, i32, i32, DeprecatedString const&, bool, bool, bool, bool, bool, DeprecatedString const&, Gfx::ShareableBitmap const&, bool) override;
|
||||||
|
|
|
@ -752,6 +752,11 @@ void Menu::set_hovered_index(int index, bool make_input)
|
||||||
redraw(*old_hovered_item);
|
redraw(*old_hovered_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Menu::set_name(DeprecatedString name)
|
||||||
|
{
|
||||||
|
m_name = move(name);
|
||||||
|
}
|
||||||
|
|
||||||
bool Menu::is_open() const
|
bool Menu::is_open() const
|
||||||
{
|
{
|
||||||
return MenuManager::the().is_open(*this);
|
return MenuManager::the().is_open(*this);
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
void add_item(NonnullOwnPtr<MenuItem>);
|
void add_item(NonnullOwnPtr<MenuItem>);
|
||||||
|
|
||||||
DeprecatedString const& name() const { return m_name; }
|
DeprecatedString const& name() const { return m_name; }
|
||||||
|
void set_name(DeprecatedString);
|
||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
IterationDecision for_each_item(Callback callback)
|
IterationDecision for_each_item(Callback callback)
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
endpoint WindowServer
|
endpoint WindowServer
|
||||||
{
|
{
|
||||||
create_menu(i32 menu_id, [UTF8] DeprecatedString name) =|
|
create_menu(i32 menu_id, [UTF8] DeprecatedString name) =|
|
||||||
|
set_menu_name(i32 menu_id, DeprecatedString name) =|
|
||||||
destroy_menu(i32 menu_id) =|
|
destroy_menu(i32 menu_id) =|
|
||||||
|
|
||||||
add_menu(i32 window_id, i32 menu_id) =|
|
add_menu(i32 window_id, i32 menu_id) =|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue