Note that there are some explanatory texts on larger screens.

plurals
  1. POgetting Error in gtkmm code
    primarykey
    data
    text
    <p>The error is very unusual for me.. No file name.. Not a correct line number Error is : building menus failed: Error on line 1 char 19: Odd character '’', expected an open quote mark after the equals sign when giving value for attribute 'action' of</p> <p>File: examplewindow.h</p> <pre><code>#ifndef GTKMM_EXAMPLEWINDOW_H #define GTKMM_EXAMPLEWINDOW_H #include &lt;gtkmm.h&gt; class ExampleWindow : public Gtk::Window { public: ExampleWindow(); virtual ~ExampleWindow(); protected: //Signal handlers: virtual void on_menu_file_new_generic(); virtual void on_menu_file_quit(); virtual void on_menu_others(); virtual void on_menu_choices_one(); virtual void on_menu_choices_two(); //Child widgets: Gtk::VBox m_Box; Glib::RefPtr&lt;Gtk::UIManager&gt; m_refUIManager; Glib::RefPtr&lt;Gtk::ActionGroup&gt; m_refActionGroup; Glib::RefPtr&lt;Gtk::RadioAction&gt; m_refChoiceOne, m_refChoiceTwo; }; #endif //GTKMM_EXAMPLEWINDOW_H </code></pre> <p>File: main.cc</p> <pre><code>#include &lt;gtkmm/main.h&gt; #include "examplewindow.h" int main(int argc, char *argv[]) { Gtk::Main kit(argc, argv); ExampleWindow window; //Shows the window and returns when it is closed. Gtk::Main::run(window); return 0; } </code></pre> <p>File: examplewindow.cc</p> <pre><code>#include "examplewindow.h" #include &lt;gtkmm/stock.h&gt; #include &lt;iostream&gt; ExampleWindow::ExampleWindow() { set_title("main menu example"); set_default_size(200, 200); add(m_Box); // put a MenuBar at the top of the box and other stuff below it. //Create actions for menus and toolbars: m_refActionGroup = Gtk::ActionGroup::create(); //File|New sub menu: m_refActionGroup-&gt;add(Gtk::Action::create("FileNewStandard", G tk::Stock::NEW, "_New", "Create a new file"), sigc::mem_fun(*this, &amp;ExampleWindow::on_menu_file_new_generic)); m_refActionGroup-&gt;add(Gtk::Action::create("FileNewFoo", Gtk::Stock::NEW, "New Foo", "Create a new foo"), sigc::mem_fun(*this, &amp;ExampleWindow::on_menu_file_new_generic)); m_refActionGroup-&gt;add(Gtk::Action::create("FileNewGoo", Gtk::Stock::NEW, "_New Goo", "Create a new goo"), sigc::mem_fun(*this, &amp;ExampleWindow::on_menu_file_new_generic)); //File menu: m_refActionGroup-&gt;add(Gtk::Action::create("FileMenu", "File")); //Sub-menu. m_refActionGroup-&gt;add(Gtk::Action::create("FileNew", Gtk::Stock::NEW)); m_refActionGroup-&gt;add(Gtk::Action::create("FileQuit", Gtk::Stock::QUIT), sigc::mem_fun(*this, &amp;ExampleWindow::on_menu_file_quit)); //Edit menu: m_refActionGroup-&gt;add(Gtk::Action::create("EditMenu", "Edit")); m_refActionGroup-&gt;add(Gtk::Action::create("EditCopy", Gtk::Stock::COPY), sigc::mem_fun(*this, &amp;ExampleWindow::on_menu_others)); m_refActionGroup-&gt;add(Gtk::Action::create("EditPaste", Gtk::Stock::PASTE), sigc::mem_fun(*this, &amp;ExampleWindow::on_menu_others)); m_refActionGroup-&gt;add(Gtk::Action::create("EditSomething", "Something"), Gtk::AccelKey("&lt;control&gt;&lt;alt&gt;S"), sigc::mem_fun(*this, &amp;ExampleWindow::on_menu_others)); //Choices menu, to demonstrate Radio items m_refActionGroup-&gt;add( Gtk::Action::create("ChoicesMenu", "Choices") ); Gtk::RadioAction::Group group_userlevel; m_refChoiceOne = Gtk::RadioAction::create(group_userlevel, "ChoiceOne", "One"); m_refActionGroup-&gt;add(m_refChoiceOne, sigc::mem_fun(*this, &amp;ExampleWindow::on_menu_choices_one) ); m_refChoiceTwo = Gtk::RadioAction::create(group_userlevel, "ChoiceTwo", "Two"); m_refActionGroup-&gt;add(m_refChoiceTwo, sigc::mem_fun(*this, &amp;ExampleWindow::on_menu_choices_two) ); //Help menu: m_refActionGroup-&gt;add( Gtk::Action::create("HelpMenu", "Help") ); m_refActionGroup-&gt;add( Gtk::Action::create("HelpAbout", Gtk::Stock::HELP), sigc::mem_fun(*this, &amp;ExampleWindow::on_menu_others) ); m_refUIManager = Gtk::UIManager::create(); m_refUIManager-&gt;insert_action_group(m_refActionGroup); add_accel_group(m_refUIManager-&gt;get_accel_group()); //Layout the actions in a menubar and toolbar: Glib::ustring ui_info = "&lt;ui&gt;" " &lt;menubar name=’MenuBar’&gt;" " &lt;menu action=’FileMenu’&gt;" " &lt;menu action=’FileNew’&gt;" " &lt;menuitem action=’FileNewStandard’/&gt;" " &lt;menuitem action=’FileNewFoo’/&gt;" " &lt;menuitem action=’FileNewGoo’/&gt;" " &lt;/menu&gt;" " &lt;separator/&gt;" " &lt;menuitem action=’FileQuit’/&gt;" " &lt;/menu&gt;" " &lt;menu action=’EditMenu’&gt;" " &lt;menuitem action=’EditCopy’/&gt;" " &lt;menuitem action=’EditPaste’/&gt;" " &lt;menuitem action=’EditSomething’/&gt;" " &lt;/menu&gt;" " &lt;menu action=’ChoicesMenu’&gt;" " &lt;menuitem action=’ChoiceOne’/&gt;" " &lt;menuitem action=’ChoiceTwo’/&gt;" " &lt;/menu&gt;" " &lt;menu action=’HelpMenu’&gt;" " &lt;menuitem action=’HelpAbout’/&gt;" " &lt;/menu&gt;" " &lt;/menubar&gt;" " &lt;toolbar name=’ToolBar’&gt;" " &lt;toolitem action=’FileNewStandard’/&gt;" " &lt;toolitem action=’FileQuit’/&gt;" " &lt;/toolbar&gt;" "&lt;/ui&gt;"; #ifdef GLIBMM_EXCEPTIONS_ENABLED try { m_refUIManager-&gt;add_ui_from_string(ui_info); } catch(const Glib::Error&amp; ex) { std::cerr &lt;&lt; "building menus failed: " &lt;&lt; ex.what(); } #else std::auto_ptr&lt;Glib::Error&gt; ex; m_refUIManager-&gt;add_ui_from_string(ui_info, ex); if(ex.get()) { std::cerr &lt;&lt; "building menus failed: " &lt;&lt; ex-&gt;what(); } #endif //GLIBMM_EXCEPTIONS_ENABLED //Get the menubar and toolbar widgets, and add them to a container widget: Gtk::Widget* pMenubar = m_refUIManager-&gt;get_widget("/MenuBar"); if(pMenubar) m_Box.pack_start(*pMenubar, Gtk::PACK_SHRINK); Gtk::Widget* pToolbar = m_refUIManager-&gt;get_widget("/ToolBar") ; if(pToolbar) m_Box.pack_start(*pToolbar, Gtk::PACK_SHRINK); show_all_children(); } ExampleWindow::~ExampleWindow() { } void ExampleWindow::on_menu_file_quit() { hide(); //Closes the main window to stop the Gtk::Main::run(). } void ExampleWindow::on_menu_file_new_generic() { std::cout &lt;&lt; "A File|New menu item was selected." &lt;&lt; std::endl; } void ExampleWindow::on_menu_others() { std::cout &lt;&lt; "A menu item was selected." &lt;&lt; std::endl; } void ExampleWindow::on_menu_choices_one() { Glib::ustring message; if(m_refChoiceOne-&gt;get_active()) message = "Choice 1 was selected."; else message = "Choice 1 was deselected"; std::cout &lt;&lt; message &lt;&lt; std::endl; } void ExampleWindow::on_menu_choices_two() { Glib::ustring message; if(m_refChoiceTwo-&gt;get_active()) message = "Choice 2 was selected."; else message = "Choice 2 was deselected"; std::cout &lt;&lt; message &lt;&lt; std::endl; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload