Can't make a popup menu popup from a GtkStatusIcon



I'm using GtkStatusIcon, GtkMenu, and GtkCheckMenuItem to create a status icon with a popup menu. The code appears to be working in that a small rectangular empty box pops up in exactly the right place under the status icon, but I can't get any content in the menu. I've tried adding extra menu items which makes no difference. Am I missing something? The relevant code is below:

   // Create a menu

   GtkWidget *menu = gtk_menu_new();
GtkWidget *item = gtk_check_menu_item_new_with_label("Don't show this again");
   gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);

g_signal_connect(item, "activate", G_CALLBACK(menu_item_activate), NULL);

   // Create a status icon

   GtkStatusIcon *icon = gtk_status_icon_new_from_icon_name("application");
   gtk_status_icon_set_tooltip_text(icon,
                  "Keyboard auto repeat temporarily disabled");

   g_signal_connect(icon, "popup-menu",
            G_CALLBACK(icon_popup_menu), menu);

   // Show the status icon

   gtk_status_icon_set_visible(icon, TRUE);
...
// Icon popup menu

int icon_popup_menu(GtkStatusIcon *icon, uint button, uint time, GtkMenu *menu)
{
   gtk_menu_popup(menu, NULL, NULL,
          gtk_status_icon_position_menu,
          icon, button, time);
}

Bill



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]