[gnomemm] Missing Stock Menu Item Accelerators



Hello,

I have sent this request to the glademm-list before, so apologies if you
receive the message for the second time.

I have built a window using Glade2/libglademm2. There are several
accelerators attached to menu items, and in Glade2 they are correctly
showing up in the menu (e.g. File/"Quit Ctrl+Q").

But when I load the window in my program, the accelerators will not work
and they are not showing up in the menu as well.

This happens only with the stock menu items. The accelerators of
non-stock items work fine.

I have tried the glademm example from libglademm/examples/menus/, but
the same problem happens there either.

Glade 2.0.1
libglade 2.0.1
libglademm 2.1.2

The complete code (from the example, but using sigc-1.2) is appended
below.

Any ideas?

Thanks,
-Samuel



*********************************************************************
* example.cc
*********************************************************************
#include <libglademm/xml.h>
#include <gtkmm.h>
#include <iostream>

Gtk::Dialog* pDialog = 0;

void on_button_clicked()
{
  if(pDialog)
    pDialog->hide(); //hide() will cause main::run() to end.
}

//This could be a member method (you might use get_widget_derived) instead,
//but I'm trying to keep this example simple. murrayc.
void on_menu_item_activated()
{
  std::cout << "menu item activated" << std::endl;
}

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

  //Load the Glade file and instiate its widgets:
  Glib::RefPtr<Gnome::Glade::Xml> refXml;
  try
  {
    refXml = Gnome::Glade::Xml::create("example.glade");
  }
  catch(const Gnome::Glade::XmlError& ex)
  {
    std::cerr << ex.what() << std::endl;
    return 1;
  }

  //Get the Glade-instantiated Dialog:
  
  refXml->get_widget("DialogBasic", pDialog);
  if (pDialog) {
    //Get the Glade-instantiated Button, and connect a signal handler:
    Gtk::Button* pButton = 0;
    refXml->get_widget("quit_button", pButton);
    if(pButton)
      pButton->signal_clicked().connect(SigC::slot(&on_button_clicked));
    
    //Connect signal handlers for the menu items:
    Gtk::MenuItem* pMenuItem = 0;
    refXml->get_widget("menu_file_new", pMenuItem);
    if(pMenuItem)
      pMenuItem->signal_activate().connect(SigC::slot(&on_menu_item_activated));

    refXml->get_widget("menu_file_save", pMenuItem);
    if(pMenuItem)
      pMenuItem->signal_activate().connect(SigC::slot(&on_menu_item_activated));

    refXml->get_widget("menu_file_quit", pMenuItem);
    if(pMenuItem)
      pMenuItem->signal_activate().connect(SigC::slot(&on_button_clicked));

    kit.run(*pDialog);
  }

  return 0;
}

*********************************************************************
* example.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="GtkDialog" id="DialogBasic">
  <property name="height_request">200</property>
  <property name="title" translatable="yes">libglademm example</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="has_separator">True</property>
 
  <child internal-child="vbox">
    <widget class="GtkVBox" id="dialog-vbox2">
      <property name="visible">True</property>
      <property name="homogeneous">False</property>
      <property name="spacing">0</property>
 
      <child internal-child="action_area">
        <widget class="GtkHButtonBox" id="dialog-action_area2">
          <property name="visible">True</property>
          <property name="layout_style">GTK_BUTTONBOX_END</property>
 
          <child>
            <widget class="GtkButton" id="quit_button">
              <property name="visible">True</property>
              <property name="can_default">True</property>
              <property name="can_focus">True</property>
              <property name="label">gtk-quit</property>
              <property name="use_stock">True</property>
              <property name="relief">GTK_RELIEF_NORMAL</property>
              <property name="response_id">0</property>
            </widget>
          </child>
        </widget>
        <packing>
          <property name="padding">0</property>
          <property name="expand">False</property>
          <property name="fill">True</property>
          <property name="pack_type">GTK_PACK_END</property>
        </packing>
      </child>
 
      <child>
        <widget class="GtkMenuBar" id="menubar1">
          <property name="visible">True</property>
 
          <child>
            <widget class="GtkMenuItem" id="menuitem1">
              <property name="visible">True</property>
              <property name="label" translatable="yes">_File</property>
              <property name="use_underline">True</property>
 
              <child>
                <widget class="GtkMenu" id="menuitem1_menu">
 
                  <child>
                    <widget class="GtkImageMenuItem" id="menu_file_new">
                      <property name="visible">True</property>
                      <property name="label">gtk-new</property>
                      <property name="use_stock">True</property>
                    </widget>
                  </child>
 
                  <child>
                    <widget class="GtkImageMenuItem" id="menu_file_open">
                      <property name="visible">True</property>
                      <property name="label">gtk-open</property>
                      <property name="use_stock">True</property>
                    </widget>
                  </child>
 
                  <child>
                    <widget class="GtkImageMenuItem" id="menu_file_save">
                      <property name="visible">True</property>
                      <property name="label">gtk-save</property>
                      <property name="use_stock">True</property>
                    </widget>
                  </child>
 
                  <child>
                    <widget class="GtkImageMenuItem" id="menu_file_saveas">
                      <property name="visible">True</property>
                      <property name="label">gtk-save-as</property>
                      <property name="use_stock">True</property>
                    </widget>
                  </child>
 
                  <child>
                    <widget class="GtkMenuItem" id="separatormenuitem1">
                      <property name="visible">True</property>
                    </widget>
                  </child>
 
                  <child>
                    <widget class="GtkImageMenuItem" id="menu_file_quit">
                      <property name="visible">True</property>
                      <property name="label">gtk-quit</property>
                      <property name="use_stock">True</property>
                    </widget>
                  </child>
                </widget>
              </child>
            </widget>
          </child>
 
          <child>
            <widget class="GtkMenuItem" id="menuitem4">
              <property name="visible">True</property>
              <property name="label" translatable="yes">_Help</property>
              <property name="use_underline">True</property>
 
              <child>
                <widget class="GtkMenu" id="menuitem4_menu">
 
                  <child>
                    <widget class="GtkMenuItem" id="menu_file_about">
                      <property name="visible">True</property>
                      <property name="label" translatable="yes">_About</property>
                      <property name="use_underline">True</property>
                    </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>
        <widget class="GtkLabel" id="label1">
          <property name="visible">True</property>
          <property name="label" translatable="yes">This is a libglademm example.
The File/New, File/Save, and File/Quit menu items are connected to signal handlers.</property>
          <property name="use_underline">False</property>
          <property name="use_markup">False</property>
          <property name="justify">GTK_JUSTIFY_LEFT</property>
          <property name="wrap">False</property>
          <property name="selectable">False</property>
          <property name="xalign">0.5</property>
          <property name="yalign">0.5</property>
          <property name="xpad">0</property>
          <property name="ypad">0</property>
        </widget>
        <packing>
          <property name="padding">0</property>
          <property name="expand">True</property>
          <property name="fill">False</property>
        </packing>
      </child>
    </widget>
  </child>
</widget>
 
</glade-interface>




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