context menus on toolbar buttons & conversion to bonobo




John Sullivan writes:
 > I'm trying to convert Nautilus to using BonoboUIHandler for its menus &
 > toolbars, so we can use menu/toolbar merging. I'm a novice at bonobo, so
 > maybe some of my questions will be novice ones. I'm going to ask several
 > questions in separate messages to keep different topics separate.
 > 
 > Nautilus connects to the button_press_event signal of a toolbar button in
 > order to put up a context menu in some cases. I don't know how to do this if
 > I convert the toolbar to be BonoboUIHander objects, because I don't know how
 > to get directly at the button widget. Is this possible with bonobo?

Two answers:

    First, you may not need to access the button widget directly in
this case.  If you don't, then you should just specify a callback when 
you create the toolbar button.  Your callback will be invoked when
someone clicks on the buttonn.  You can popup your menu then.

    If, in fact, you do need direct access to the widget, then you can
make the button be a control and remotely embed it.  From the embedded
component's perspective, this looks like:


        button = gtk_button_new ( ... );
        control = bonobo_control_new (button);

        bonobo_ui_handler_toolbar_new_control (
            uih, "/Path/to_button", position, 
            bonobo_object_corba_objref (BONOBO_OBJECT (control)));


Ta da.

Nat



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