Find the answer to your Linux question:
Results 1 to 2 of 2
I have this experimental little app that is supposed to pop up a menu on SIGUSR1: Code: GtkWidget *create_menu(void) { GtkWidget *menu1, *menuitem1; menu1 = gtk_menu_new (); menuitem1 = gtk_image_menu_item_new_with_mnemonic ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Enthusiast
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    521

    gtk_menu_popup() only works the first time?


    I have this experimental little app that is supposed to pop up a menu on SIGUSR1:
    Code:
    GtkWidget *create_menu(void) {
        GtkWidget *menu1, *menuitem1;
        menu1 = gtk_menu_new ();
    
        menuitem1 = gtk_image_menu_item_new_with_mnemonic ("Menu Item _1");
        gtk_menu_shell_append (GTK_MENU_SHELL (menu1), menuitem1);
        menuitem1 = gtk_image_menu_item_new_with_mnemonic ("Menu Item _2");
        gtk_menu_shell_append (GTK_MENU_SHELL (menu1), menuitem1);
    
        gtk_widget_show_all (menu1);
        gtk_menu_popup (GTK_MENU (menu1), NULL, NULL, NULL, NULL, 0,
            gtk_get_current_event_time ());
    
        return menu1;
    }
    It works properly when first called. The silly little menu pops up under the mouse. Click an entry or hit ESCAPE and it goes away. Perfect.

    I send a SIGUSR1 to the app, it catches it, prints a little confirmation that it did indeed catch it, then calls gtk_widget_show_all(menu1) and gtk_menu_popup(menu1, ...), and nothing. The menu doesn't reappear. First I thought the widgets were being destroyed, but then I'd surely get a segfault on the gtk_widget_show_all().

    Any notion why this would be?

  2. #2
    Linux Enthusiast
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    521
    I figured it out. To sum up:

    gtk_menus and all their automagic get confused by spurious events.

    The gory details are here:

    View topic - gtk_menu_popup() only works once, then fails silently?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •