Skip to content

Commit 3b693d4

Browse files
committed
Prefer stored title over GTK label in SetIcon
Updated MenuItem::SetIcon to use the stored title if available when preserving the label text, falling back to the GTK widget label only if the title is not set. This ensures consistency when the title is managed internally.
1 parent 6439cea commit 3b693d4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/platform/linux/menu_linux.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,15 @@ void MenuItem::SetIcon(std::shared_ptr<Image> image) {
276276
return;
277277
}
278278

279-
// Get current label text to preserve it
280-
const char* label_text = gtk_menu_item_get_label(GTK_MENU_ITEM(pimpl_->gtk_menu_item_));
281-
std::string current_label = label_text ? label_text : "";
279+
// Get current label text to preserve it - prefer stored title over GTK widget
280+
std::string current_label;
281+
if (pimpl_->title_.has_value()) {
282+
current_label = pimpl_->title_.value();
283+
} else {
284+
// Fallback to GTK widget if title not set
285+
const char* label_text = gtk_menu_item_get_label(GTK_MENU_ITEM(pimpl_->gtk_menu_item_));
286+
current_label = label_text ? label_text : "";
287+
}
282288

283289
// Remove existing child widget
284290
GtkWidget* existing_child = gtk_bin_get_child(GTK_BIN(pimpl_->gtk_menu_item_));

0 commit comments

Comments
 (0)