Re: GMenuModel has landed



hi Jannis,

On Fri, 2011-12-09 at 15:34 +0100, Jannis Pohlmann wrote:
> I guess this is unrelated but I have a question regarding extensions as
> well. Will there be functionality similar to GtkUIManager-based merging
> with placeholders in the GTK part of GMenu? 
> 
> We use this heavily in Thunar to allow plugins to specify items for
> file/folder context menus (and also for the window's "File" menu).

The way this works is with questions.

Take this as an example that I've tossed around a lot:

<menu id='menubar'>
  <submenu label='_File'>
    <section>
      <item label='_New' action='app.new'/>
      <item label='_Open' action='app.open'/>
      <item label='_Save' action='win.save'/>
      <item label='_Print' action='win.print'/>
    </section>
    <section id='recent-documents'/>
    <section>
      <item label='_Close' action='win.close'/>
      <item label='_Quit' action='app.quit'/>
    </section>
  </submenu>

  ...
</menu>

Then you can feed that XML into a GtkBuilder.

Later, you can do this:

GMenu *menu = G_MENU (gtk_builder_get_object (builder, "recent-documents"));

and begin appending items to that menu.

Note that Gtk automatically introduces separators between the sections
at the toplevel (but not sections nested within sections).

In a similar form, you could introduce empty 'plugin area' sections into
your menus (or even the menubar -- but no separators there, of course)
that the plugins could insert their items into, in section form.

Cheers



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