Re: How to create Gnome-3 style application menu?



There's a working example at https://github.com/GNOME/gtkmm-documentation/tree/master/examples/book/application/app_and_win_menus.

On 08/02/2015 02:01 PM, Gerardo Ballabio wrote:
Hello all,

I'm trying to learn how to build a gtkmm application that conforms to Gnome 3 style guidelines.

In particular I want to create a custom application menu (the menu that pops up when you click the application name in the Gnome 3 top bar). As far as I can see, the gtkmm tutorial (chapter 12) only shows how to create a Gnome 2-style menubar.

Reading the gtkmm 3 API reference I figured I should use Gtk::Application::set_app_menu() and wrote the attached sample file, but it doesn't seem to work: when I run it, it shows the fallback application menu that gets generated when no menu has been set, that is, with a single "Quit" entry (see attached screenshot).

I'm running my test program in Gnome 3 in Debian 8 (gtkmm version 3.14.0), so application menus should definitely be supported. Indeed app->prefers_app_menu() returns true, and Gnome programs such as Web do show their application menus.

Can you please help me find what I'm doing wrong?

The documentation says set_app_menu() should be called after the application has been registered and that "Application::signal_startup() is a good place [to do that]". Indeed I tried to call set_app_menu() in the main function before running app->run(window), but then I get this error message:

(menus:1997): Gtk-CRITICAL **: gtk_application_set_app_menu: assertion 'g_application_get_is_registered (G_APPLICATION (application))' failed

So I connected a callback to app->signal_startup() and called it from there (I considered also subclassing Gtk::Application, but because it has no public constructor and gets instantiated via a static create() method, I don't think I can or should do that). Then I get no error, but no menu either.

I guess the Gio::Menu instance that I'm building may not be adequate, but in the documentation I couldn't find any guidance on how to build it. The procedure described in the tutorial to build menus doesn't create a Gio::Menu and doesn't seem applicable here (or is it?).

Any help will be much appreciated. (A working example would be VERY much appreciated.)

Thanks
 Gerardo



_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list

--
We're not giving up. We're waiting for a better opportunity to win.
    -- Lois McMaster Bujold


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