Re: GMenuModel has landed
- From: Ryan Lortie <desrt desrt ca>
- To: Jannis Pohlmann <jannis xfce org>
- Cc: gtk-devel-list gnome org
- Subject: Re: GMenuModel has landed
- Date: Fri, 09 Dec 2011 09:56:46 -0500
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]