Hi Steve,

On 26 November 2011 08:27, Steve . <iteratio...@gmail.com> wrote:
> I've got a GtkItemFactoryEntry popup menu, the menu pops up from a button
> press event using gtk_menu_popup.

I found the best solution was to make my own menus and use quarks set
on them to link them to their context. I build the menus in my
class_init like this:

  pane = rowview_popup_menu = popup_build( _( "Row menu" ) );
  popup_add_but( pane, _( "_Edit" ), POPUP_FUNC( rowview_edit_cb ) );
  menu_add_sep( pane );
  popup_add_but( pane, GTK_STOCK_DELETE, POPUP_FUNC( rowview_remove_cb ) );

When you build a widget that needs one of these right-click menus you
link the widget to the menu with (rview is any client data, but in
this case is the underlying model):

     popup_attach( widget, rowview_popup_menu, rview );

and callbacks look like this:

     static void
     rowview_edit_cb( GtkWidget *menu, GtkWidget *button, Rowview *rview )
     {
        do_stuff( rview );
     }

Source here, along with some other stuff. It's only 100 lines or so.

  https://github.com/jcupitt/nip2/blob/master/src/gtkutil.c

John
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to