Just when I finally am making some progress with learning gtkmm and libglademm, along comes gtk-builder. Since gtk-builder is the future, I would like to start learning that before I get too far down the libglademm road.
So far I don't find much help on learning gtk-builder. The only tutorial I could find is http://www.micahcarrick.com/05-30-2008/gtk-builder-libglade-faq.html which covers C but I don't know how to do that in C++. If I could just get started with a simple hello world example, I could probably make some progress with gtk-builder. Using the gtkmm documentation, I have made guess-work changes to a simple libglademm example I have. It compiles and runs but does not display as I expect. It only shows a small window. In the hello.cpp I have commented the libglademm items and replaced them with what I think are the appropriate gtk-builder items. Can anyone please tell me what I am doing wrong? Damon Register ----------------- hello.xml ---------------------------------------- <?xml version="1.0"?> <!--*- mode: xml -*--> <interface> <object class="GtkWindow" id="hello_main_window"> <child> <object class="GtkLayout" id="layout1"> <property name="width_request">450</property> <property name="height_request">450</property> <property name="visible">True</property> <property name="width">450</property> <property name="height">450</property> <child> <object class="GtkButton" id="button2"> <property name="width_request">100</property> <property name="height_request">25</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="label" translatable="yes">quit</property> </object> <packing> <property name="x">21</property> <property name="y">403</property> </packing> </child> </object> </child> </object> </interface> -------------------------- hello.cpp --------------------------- #include <iomanip> #include <sstream> #include <iostream> #include <locale.h> #include <sigc++/retype_return.h> #include <gtkmm.h> class hello : public Gtk::Window { public: hello(); virtual ~hello(); protected: // The widgets that are manipulated. Gtk::Button* quit_button; // Glade interface description. //Glib::RefPtr<Gnome::Glade::Xml> xml_interface; Glib::RefPtr<Gtk::Builder> xml_interface; }; using namespace std; hello::hello() { int k; double heading; std::cout << "hello()" << std::endl; set_title("gtk-builder demo"); set_resizable(false); // Get the Glade user interface and add it to this window. //xml_interface = Gnome::Glade::Xml::create("hello.glade", "layout1"); xml_interface = Gtk::Builder::create_from_file("hello.xml"); Gtk::Layout *main_vbox; xml_interface->get_widget("layout1", main_vbox); //add(*main_vbox); // if this line is uncommented I get a runtime warning about // layout1 already being inside a window xml_interface->get_widget("button2", quit_button); // Set up signal handers for buttons. quit_button->signal_clicked().connect ( sigc::mem_fun(*this, &hello::hide) ); } hello::~hello() { std::cout << "~hello()" << std::endl; } int main (int argc, char *argv[]) { Gtk::Main kit(argc, argv); hello window; kit.run(window); return 0; } _______________________________________________ gtkmm-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtkmm-list
