Why I cannot get Gtk::Action object from Glade file by Gtk::Builder?



Hi,

I used Glade to build an interface, and found that I cannot get the Gtk::Action object from Gtk::Builder by get_widget().

I minimize the problem to the following program:
===========
#include <gtkmm.h>

const char* glade_content = ""
"<?xml version=\"1.0\"?>"
"<interface>"
"  <requires lib=\"gtk+\" version=\"2.16\"/>"
"  <!-- interface-naming-policy project-wide -->"
"  <object class=\"GtkAction\" id=\"action1\"/>"
"</interface>";

int main(int argc, char* argv[])
{
    Gtk::Main kit(argc, argv);
    Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create_from_string(glade_content);
    Gtk::Action* action = "">    builder->get_widget("action1", action);
    return 0;
}
===========

The code compiled ok, and it generate following error during the execution:

===========
(action:5162): gtkmm-CRITICAL **: gtkmm: object `action1' (type=`gtkmm__GtkAction') (in GtkBuilder file) is not a widget type.

(action:5162): gtkmm-CRITICAL **: gtkmm: Gtk::Buidler: widget `action1' was not found in the GtkBuilder file, or the specified part of it.

** (action:5162): CRITICAL **: Gtk::Builder::get_widget(): dynamic_cast<> failed.
===========

It said, the action1 is not a widget type, however, Gtk::Action is inherited from Gtk::Widget if I remember it correctly. So, why I cannot get the Gtk::Action object from the glade file?

--
Regards

Tao Wang


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