Re: [gtk-list] Problems with gtk_item_factory_popup()



On Sun, 10 Jan 1999, Jonas Almfeldt wrote:

> Does anyone know what I am doing wrong when get the following error
> message:
> 
> GtkCRITICAL **: file gtkitemfactory.c: line 1384
> (Gtk_item_factory_popup_with_data):
> assertion 'GTK_IS_MENU (ifactory->widget)' failed.
> 
> The code that generates this error message:
> 
> GtkItemFactory *factory;
> GtkMenuPath *menu_path;
> 
> static GtkItemFactoryEntry mbox_popup_items[] =
> {
>   { "/Properties", NULL, NULL, 0, "" }
> };
> 
> static int n_mbox_items = sizeof(mbox_popup_items) /
> sizeof(mbox_popup_items[0]);
> 
> 
> 
> factory = (GtkItemFactory *) gtk_item_factory_new(GTK_TYPE_MENU_BAR,
                                                    ^^^^^^^^^^^^^^^^^
>                                                             "<Main>",
> NULL);
>           gtk_item_factory_create_items(GTK_ITEM_FACTORY(factory),
>                                         n_mbox_items,
>                                         mbox_popup_items,
>                                         &mbox);
> 
>           gtk_item_factory_popup(GTK_ITEM_FACTORY(factory),
>                                  event->x,
>                                  event->y,
>                                  event->button,
>                                  event->time);

you can't popup a menubar factory, either create a factory with
gtk_item_factory_new (GTK_TYPE_MENU, ..) or don't pop it up and
do something like

window =
  gtk_widget_new (GTK_TYPE_WINDOW,
                  "child", gtk_widget_new (GTK_TYPE_VBOX,
                                           "visible", TRUE,
                                           "child",
                                           GTK_ITEM_FACTORY (factory)->widget,
                                           NULL),
                  "visible", TRUE,
                  NULL);
gtk_widget_show (GTK_ITEM_FACTORY (factory)->widget);

> 
> Thanks in advance.
> 

---
ciaoTJ



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