RE: How to create submenus using UIManager



On Sun, 2007-11-04 at 15:27 -0500, Stewart Weiss wrote:

> I have Emmanuele Bassi's recent-uimanager code and I am trying
> to use that as a guide, but it seems absurd to have to go down so
> far as to create GObjects just to do this.

that code showed how to integrate a pre-existing menu item + sub-menu
widget (GtkRecentChooserMenu) with a GtkUIManager; as of GTK+ 2.12 it's
not needed anymore, as GtkRecentAction is available exactly for that
purpose.

if your menu hierarchy is static and you just want to add a menu item
with a sub-menu, then just do:

  <menu>
    <menuitem .../>
    <menu>
      <menuitem .../>
      <menuitem .../>
      ...
    </menu>
    <menuitem .../>
    ...
  </menu>

if, on the other hand, your menu hierarchy is dynamically generated, you
can either use a placeholder and the switch in/out menu items or you can
use a GtkAction subclass that provides a menu item with its own
sub-menu, exactly like I did in my recent-uimanager example.

my preferences go to the object-oriented approach, because it's cleaner
and easier to swap in or out of a project. and creating a new GObject
isn't that much work, compared to hooking into a placeholder.

ciao,
 Emmanuele.

-- 
Emmanuele Bassi,
W: http://www.emmanuelebassi.net
B: http://log.emmanuelebassi.net



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