mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-30 22:54:35 +03:00
WindowServer: Allow updating the name of a menu
This commit is contained in:
parent
952f6bbb2a
commit
cf730403ea
Notes:
sideshowbarker
2024-07-16 22:17:36 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/cf730403ea Pull-request: https://github.com/SerenityOS/serenity/pull/18054 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/linusg
@ -96,6 +96,27 @@ void ConnectionFromClient::create_menu(i32 menu_id, DeprecatedString const& name
|
||||
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)
|
||||
{
|
||||
auto it = m_menus.find(menu_id);
|
||||
|
@ -94,6 +94,7 @@ private:
|
||||
void destroy_window(Window&, Vector<i32>& destroyed_window_ids);
|
||||
|
||||
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 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;
|
||||
|
@ -752,6 +752,11 @@ void Menu::set_hovered_index(int index, bool make_input)
|
||||
redraw(*old_hovered_item);
|
||||
}
|
||||
|
||||
void Menu::set_name(DeprecatedString name)
|
||||
{
|
||||
m_name = move(name);
|
||||
}
|
||||
|
||||
bool Menu::is_open() const
|
||||
{
|
||||
return MenuManager::the().is_open(*this);
|
||||
|
@ -59,6 +59,7 @@ public:
|
||||
void add_item(NonnullOwnPtr<MenuItem>);
|
||||
|
||||
DeprecatedString const& name() const { return m_name; }
|
||||
void set_name(DeprecatedString);
|
||||
|
||||
template<typename Callback>
|
||||
IterationDecision for_each_item(Callback callback)
|
||||
|
@ -5,6 +5,7 @@
|
||||
endpoint WindowServer
|
||||
{
|
||||
create_menu(i32 menu_id, [UTF8] DeprecatedString name) =|
|
||||
set_menu_name(i32 menu_id, DeprecatedString name) =|
|
||||
destroy_menu(i32 menu_id) =|
|
||||
|
||||
add_menu(i32 window_id, i32 menu_id) =|
|
||||
|
Loading…
Reference in New Issue
Block a user