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'>
      <item label='_New' action=''/>
      <item label='_Open' action=''/>
      <item label='_Save' action=''/>
      <item label='_Print' action='win.print'/>
    <section id='recent-documents'/>
      <item label='_Close' action='win.close'/>
      <item label='_Quit' action='app.quit'/>


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.


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