#include <libayatana-appindicator/app-indicator.h>
int main(int argc, char** argv) {
gtk_init(&argc, &argv);
// createa app indicator and assign it a menu
AppIndicator* indicator = app_indicator_new("tray-icon", "icon.ico", APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
app_indicator_set_status(indicator, APP_INDICATOR_STATUS_ACTIVE);
GtkWidget* menu = gtk_menu_new();
app_indicator_set_menu(indicator, GTK_MENU(menu));
// create a menu item that has a submenu
GtkWidget* submenu = gtk_menu_new();
GtkWidget* submenu_item = gtk_menu_item_new_with_label("submenu");
gtk_menu_item_set_submenu(GTK_MENU_ITEM(submenu_item), submenu);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), submenu_item);
gtk_widget_show(submenu_item);
// create a menu item that is part of the submenu and that should self-destruct when clicked
GtkWidget* item = gtk_menu_item_new_with_label("item");
g_signal_connect(item, "activate", G_CALLBACK(gtk_widget_destroy), NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item);
gtk_widget_show(item);
g_main_loop_run(g_main_loop_new(NULL, FALSE));
}
As expected, this creates an app indicator whose menu has a sub-menu which contains a simple label menu item. When that label menu item is clicked, it is destroyed and automatically removed from its parent GtkMenu. This works fine on Gnome, and the label menu item does indeed not appear in the sub-menu anymore. But on KDE, the label menu item is still being rendered as part of the sub-menu.
Furthermore, when hovering the sub-menu with the cursor, the following warning is issued
(untitled:21248): LIBDBUSMENU-GLIB-WARNING **: 16:51:50.209: About to Show called on an item wihtout submenus. We're ignoring it.
which indicates that the label item menu was indeed removed from the sub-menu, it's just that it is still getting rendered.
I'm not entirely sure if this bug is caused by libayatana-appindicator, libdbusmenu or by KDE itself.
Consider the following example
As expected, this creates an app indicator whose menu has a sub-menu which contains a simple label menu item. When that label menu item is clicked, it is destroyed and automatically removed from its parent
GtkMenu
. This works fine on Gnome, and the label menu item does indeed not appear in the sub-menu anymore. But on KDE, the label menu item is still being rendered as part of the sub-menu. Furthermore, when hovering the sub-menu with the cursor, the following warning is issuedwhich indicates that the label item menu was indeed removed from the sub-menu, it's just that it is still getting rendered.
I'm not entirely sure if this bug is caused by
libayatana-appindicator
,libdbusmenu
or by KDE itself.