Re: About GtkBuilder, GMenu, and GAction (was Re: Deprecation of GtkImageMenuItem)



hi;

you can set an id attribute on any section, and then retrieve the
GMenu associated with that section, at which point you can add any
further item there, e.g.:

  <section>
    <attribute name="id">view-placeholder</attribute>
    <item>
      ...
    </item>
  </section>

then use the GMenuModel API to iterate over the menu until you hit the
section with the "view-placeholder" id attribute. at that point, you
can use the GMenu API to add items at that section. gedit has some
simple code that handles their extension mechanism for menus:

https://git.gnome.org/browse/gedit/tree/gedit/gedit-app.c#n1613

and a class that handles appending/prepending/removing menus by using
a "merge-id" attribute on the GMenuItem added by an extension.

ciao,
 Emmanuele.

On 23 October 2014 10:58, Jean Brefort <jean brefort normalesup org> wrote:
Le jeudi 23 octobre 2014 à 10:31 +0100, Emmanuele Bassi a écrit :
another recommendation is to *not* use GtkMenu and friends directly,
but to use GtkBuilder, GAction, and GMenu — follow the "How Do I"
document here: https://developer.gnome.org/GMenu/ — to describe your
menus with XML, which also lets you specify icons for specific menu
items.

Hi Emmanuele,

I read that documentation, but I'm unsure about how I might use
placeholders with this (not so) new API, as I could do when using
GtkUIManager. Is it possible? or not?

Best regards,
Jean




-- 
http://www.bassi.io
[ ] ebassi [ gmail com]


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