Menu not on screen



We are building a menubar using a GtkItemFactory, however, when we
attempt to provide bindings that activate the menus (ALt-f for the
File menu, etc) invoking Alt-f causes a pop-up menu at the mouse
pointer (with the correct items, and they work properly) and the
following errors on the terminal.

Gdk-CRITICAL **: file gdkwindow.c: line 1479 (gdk_window_get_origin): assertion `window != NULL' failed.

Gtk-WARNING **: Menu not on screen

The menus work fine if you just click on them

As best as I can tell, this error is happening because the menu's
parent-window is NULL, but I'm not sure why this is happening.

I've pasted the relevant chunk of code below.

thanks

-kevin

GtkWidget* create_menubar(gint i, GtkWidget *main_window, GtkWidget *vbox) 
{
  GtkWidget      *menubar;
  GtkItemFactory *item_factory;
  GtkAccelGroup *accel_group;

  GtkItemFactoryEntry menu_items[] = {
    { "/_File",         NULL,         NULL, 0, "<Branch>" },
    { "/File/_Save",   "<control>S", on_save_program, 0, NULL },
    { "/File/_Reload", "<control>R", on_reload_program, 0, NULL },
    { "/File/Clear",   NULL, on_clear_program, 0, NULL },
    { "/File/Insert S_keleton", NULL, on_insert_skeleton, 0, NULL},
    { "/_Edit", NULL, NULL, 0, "<Branch>" },
    { "/Edit/_Copy",   "<control>C", on_edit_copy, 0, NULL },
    { "/Edit/_Cut",    "<control>X", on_edit_cut, 0, NULL },
    { "/Edit/_Paste",  "<control>V", on_edit_paste, 0, NULL },
    { "/Edit/_Undo",   "<control>Z", on_edit_undo, 0, NULL },
    { "/_Language", NULL, NULL, 0, "<Branch>" },
    { "/Language/C", NULL, on_language_activate, LANG_C, "<RadioItem>"},
    { "/Language/C++", NULL, on_language_activate, LANG_CC, "/Language/C"},
    { "/Language/Java", NULL, on_language_activate, LANG_JAVA, "/Language/C"},
    { "/_Help", NULL, NULL, 0, "<LastBranch>" },
  };

  gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);

  accel_group = gtk_accel_group_new ();

  item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", 
                                      accel_group);

  gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, 
                                 notebook);
  
  /* Attach the new accelerator group to the window. */
  gtk_window_add_accel_group (GTK_WINDOW (main_window), accel_group);

  /* clip some stuff to set certain menu items as "checked" */
 
  /* Finally, return the actual menu bar created by the item factory. */ 
  menubar = gtk_item_factory_get_widget (item_factory, "<main>");
  
  /* make the menubar look purty */
  gtk_menu_bar_set_shadow_type(GTK_MENU_BAR(menubar), GTK_SHADOW_ETCHED_IN);

  /* attach menubar to the main window */
  gtk_widget_ref (menubar);
  gtk_object_set_data_full (GTK_OBJECT (main_window), "menubar", menubar,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0);

  return menubar;
}

-- 
the purpose of a windowing system is to put some amusing fluff around
your one almighty emacs window.
Mark Kromer in <36FC3101 37FB9797 mynode com>




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