0

Hello am trying to write a program using gtkmm and ran into some problem, the was following the online tutorial on the gnome website. Although my program compiles and executes the menu bar is not being displayed, also shortcut key doesn’t work.

But I get a warning on the terminal Gtk-WARNING **: File: missing action File

Any pointers will helpful. Thank you

And this is the code for creating menu

mActionGroup = Gtk::ActionGroup::create();
mActionGroup->add(Gtk::Action::create("File", "_File"));
mActionGroup->add(
    Gtk::Action::create( "Open", Gtk::Stock::OPEN, "_Open", "Open a file" ),
    Gtk::AccelKey( "<control>o" ),
    sigc::mem_fun( *this, &myWindow::onFileOpen ) );

std::string menuInfo =
    std::string("<ui>")+
    "  <menubar name='MenuBar'>"+
    "    <menu action='File'>"+
    "      <menuitem action='Open'/>"+
    "    </menu>"+
    "  </menubar>"+
    "</ui>";
mUIManager = Gtk::UIManager::create();
add_accel_group(mUIManager->get_accel_group());
try
{
    mUIManager->add_ui_from_string( menuInfo );
}
catch( const Glib::Error &ex )
{
    ERROR( "Could not create menu" << ex.what() )
}
Gtk::Widget *pMenu = mUIManager->get_widget( "/MenuBar" );

mBox.pack_start( *pMenu, Gtk::PACK_SHRINK );
show_all_children();

this is the Gtkmm package installed libgtkmm-3.0-dev:amd64 and I compile using pkg-config --libs gtkmm-3.0 this gives these libraries

-lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lgtk-3 -lglibmm-2.4     
-lcairomm-1.0 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject 
-lpango-1.0 -lcairo -lsigc-2.0 -lgobject-2.0 -lglib-2.0  

EDIT:

not sure how to check my gtkmm version but i searched the package name and got this marked as superseded [https://launchpad.net/ubuntu/saucy/amd64/libgtkmm-3.0-dev/3.6.0-0ubuntu1] so i think the version is 3.6

tejas
  • 1,795
  • 1
  • 16
  • 34
  • 1
    GtkUIManager has been recently deprecated in favor of GtkBuilder. If the GTK version you use allows it, I'd recommend using GtkBuilder. – liberforce Dec 16 '13 at 13:00
  • Yes I found this online [https://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/menus/main_menu/examplewindow.cc] and tried to follow the example there but in my version of gtkmm `Gio::SimpleActionGroup::add_action` has only 1 parameter but there in the example required two. – tejas Dec 16 '13 at 17:23
  • Which version of GTKmm are you using ? – liberforce Dec 17 '13 at 09:54
  • Updated details in the question. – tejas Dec 19 '13 at 05:58
  • I'm not sure you're answering my question. You give me the version of the development package, which may be different from the real version of library used, as versioning of the packages just follows the ABI changes. Same for the `pkg-config` output. On my Mageia machine, the package is called `lib64gtkmm3.0_1-3.6.0-3.mga3`. The version hence is 3.6.0, not 3.0. – liberforce Dec 19 '13 at 09:09

0 Answers0