GTKMM MainMenu tutorial



I'm trying to learn Gtk::UIManager, and I can't get the MainMenu example in the tutorial to work.

Software:
    Linux 3.0.0-17 i686
    Ubuntu 11.10

    x@y:~$ g++ --version
    g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1

    x@y:~$ pkg-config gtkmm-3.0 --modversion
    3.2.0

    All software updates current as of this morning (6 Apr 2012)

Tutorial:
    gtkmm-documentation-3.0.3-1

I tried the "Source Code" link for the MainMenu example at file:///usr/share/doc/gtkmm-documentation/tutorial/html/sec-menus-examples.html. It took me to  http://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/menus/main_menu/?h=, which says "Invalid branch:"

By stripping the "/?h=" from the url, I found a list of the three source code modules. I copied them and tried to build:

    x@y:~$ g++ main.cc examplewindow.cc `pkg-config gtkmm-3.0 --cflags --libs` -o mainmenu
    main.cc:18:31: fatal error: gtkmm/application.h: No such file or directory
    compilation terminated.

I changed #include <gtkmm/application.h> in main.cc to #include <gtkmm.h>, and tried again:

    x@y:~/x$ g++ main.cc examplewindow.cc `pkg-config gtkmm-3.0 --cflags --libs` -o mainmenu
    main.cc: In function ‘int main(int, char**)’:
    main.cc:23:16: error: ‘Application’ is not a member of ‘Gtk’
    main.cc:23:16: error: ‘Application’ is not a member of ‘Gtk’
    main.cc:23:32: error: template argument 1 is invalid
    main.cc:23:38: error: invalid type in declaration before ‘=’ token
    main.cc:23:45: error: ‘Gtk::Application’ has not been declared
    main.cc:28:13: error: base operand of ‘->’ is not a pointer

I then replaced the code modules with those displayed in the tutorial itself (at file:///usr/share/doc/gtkmm-documentation/tutorial/html/sec-menus-examples.html), where it says prior to each module "(For use with gtkmm 3, not gtkmm 2)". This version compiled and linked with no errors or warnings (same g++ command as above). Upon execution, the console showed no error or warning messages but the window appeared with only a (properly configured) tool bar -- no menu bar was displayed.

I added code to pack unique Gtk::Labels before and after the get_widget("/MenuBar")/pack_start() calls at lines 108-110. The resulting window contained both labels and the tool bar, but still no menu bar between the labels.

I just now discovered, at file:///usr/share/doc/libgtkmm-3.0-doc/reference/html/index.html, a link to an online version of the tutorial at http://developer.gnome.org/gtkmm-tutorial/stable/, with yet a third version of the MainMenu code. Surely an online copy will be the latest and greatest, and will resolve these difficulties!

Nope. It too compiles and links, but it still fails to show a menu bar.

Am I missing something, or is this example fundamentally flawed?



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