Howto attach a popup menu to a menubar (gtk2)



All,

  I have a menubar (working fine) and I want to attach a popup menu to that
widget to "show/hide" a toolbar below it. I cannot figure out how to attach
the popup to the 'menubar' itself generically.

    GtkWidget *evbox;           /* popup menu container */
    GtkWidget *pmenu;           /* the menu */
    GtkWidget *pshowtbMI;       /* the menu item */

  I've tried to attach the popup to the 'menubar' as a container with the
following code:

    evbox = gtk_event_box_new();
    gtk_container_add (GTK_CONTAINER(menubar), evbox);
    pmenu = gtk_menu_new();
    pshowtbMI = gtk_check_menu_item_new_with_label ("Show Toolbar");
    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(pshowtbMI), TRUE);
    gtk_menu_shell_append (GTK_MENU_SHELL(pmenu), pshowtbMI);
    g_signal_connect_swapped (G_OBJECT(evbox), "button-press-event",
        G_CALLBACK(show_popup), pmenu);
    g_signal_connect (G_OBJECT(pshowtbMI), "activate",
        G_CALLBACK(menu_showtb_activate), app);

  The show_popup is a generic event-handler that responds to the right-mouse
button (working fine).

  What can I do to provide a popup that will respond when I rt-click on a
blank part of the menubar?

-- 
David C. Rankin, J.D.,P.E.


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