menuitems + glade + accelerator keys



Hallo *,

Some weeks ago I asked a question about my problem with not functional
menu shortcuts. Now I had the time to write a little test program. Using
the mouse to select File|Open or pressing Alt + F and then O outputs
"Hello" but pressing Ctrl+O does not! Has anyone an idea why?

Thank you!

Tobias


main.cpp:

#include <gtkmm.h>
#include <libglademm.h>
#include <iostream>

class CMyWindow : public Gtk::Window
{
  public:
    CMyWindow() : Gtk::Window()
    {
      Glib::RefPtr<Gnome::Glade::Xml> refXMLInterface =
Gnome::Glade::Xml::create("windowMain.glade");
      refXMLInterface->reparent_widget("vboxMain", *this);
      refXMLInterface->get_widget("menuitemFileOpen", m_pwMenuItemOpen);
      m_pwMenuItemOpen->signal_activate().connect(sigc::mem_fun(*this,
&CMyWindow::on_MainMenuOpen_activate));
      show_all_children();
    }
  protected:
    Gtk::MenuItem *m_pwMenuItemOpen;
    void on_MainMenuOpen_activate()
    {
      std::cout << "hello\n";
    }
};

int main(int argc, char **argv)
{
  Gtk::Main m(argc, argv);

  CMyWindow oMyWindow;
  Gtk::Main::run(oMyWindow);

  return 0;
}



windowMain.glade:

<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd";>

<glade-interface>

<widget class="GtkWindow" id="windowMain">
  <property name="width_request">400</property>
  <property name="height_request">400</property>
  <property name="title" translatable="yes">Base GTK</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="resizable">True</property>
  <property name="destroy_with_parent">False</property>
  <property name="decorated">True</property>
  <property name="skip_taskbar_hint">False</property>
  <property name="skip_pager_hint">False</property>
  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
  <property name="focus_on_map">True</property>
  <accessibility>
    <atkproperty name="AtkObject::accessible_name"
translatable="yes">windowMain</atkproperty>
  </accessibility>

  <child>
    <widget class="GtkVBox" id="vboxMain">
      <property name="visible">True</property>
      <property name="homogeneous">False</property>
      <property name="spacing">0</property>

      <child>
	<widget class="GtkMenuBar" id="menubar">
	  <property name="visible">True</property>

	  <child>
	    <widget class="GtkMenuItem" id="menuitemFile">
	      <property name="visible">True</property>
	      <property name="label" translatable="yes">_File</property>
	      <property name="use_underline">True</property>

	      <child>
		<widget class="GtkMenu" id="menuitemFile_menu">

		  <child>
		    <widget class="GtkImageMenuItem" id="menuitemFileOpen">
		      <property name="visible">True</property>
		      <property name="label" translatable="yes">_Open</property>
		      <property name="use_underline">True</property>
		      <signal name="activate" handler="on_menuitemFileOpen_activate"/>
		      <accelerator key="O" modifiers="GDK_CONTROL_MASK"
signal="activate"/>

		      <child internal-child="image">
			<widget class="GtkImage" id="image1">
			  <property name="visible">True</property>
			  <property name="stock">gtk-open</property>
			  <property name="icon_size">1</property>
			  <property name="xalign">0.5</property>
			  <property name="yalign">0.5</property>
			  <property name="xpad">0</property>
			  <property name="ypad">0</property>
			</widget>
		      </child>
		    </widget>
		  </child>
		</widget>
	      </child>
	    </widget>
	  </child>
	</widget>
	<packing>
	  <property name="padding">0</property>
	  <property name="expand">False</property>
	  <property name="fill">False</property>
	</packing>
      </child>

      <child>
	<placeholder/>
      </child>
    </widget>
  </child>
</widget>

</glade-interface>




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