[gnomemm] libglademm: reparenting to a Gnome::UI::App class



In the variablesmap example, there is an example of deriving a class from Gtk::Window and
reparenting the vbox from example.glade.  Here's the class definition from
examplewindow.h and an excerpt from the constructor (that is the focus of this email)
from examplewindow.c:

class ExampleWindow : public Gtk::Window
{

public:
  ExampleWindow();
  virtual ~ExampleWindow();

protected:
  //Signal handlers:
  virtual void on_button_clicked();

  Glib::RefPtr<Gnome::Glade::Xml> m_refGlade;
  Gnome::Glade::VariablesMap* m_pVariablesMap;

  //Variables:
  Glib::ustring m_strEntry;
  bool m_bCheckBox;
};

ExampleWindow::ExampleWindow()
: m_bCheckBox(0)
{
  // Sets the border width of the window.
  set_border_width(10);

  //Get Glade UI:
  m_refGlade = Gnome::Glade::Xml::create("example.glade");
  m_refGlade->reparent_widget("vbox", *this);
...
  show_all_children();
}

as you can see, the constructor reparents the widget that is the child of the GtkWindow
in the glade file.  This does not work with gnome application.  Here are some excerpts
from a project I'm working on:


class gcdb : public Gnome::UI::App
{
private:
	Glib::RefPtr<Gnome::Glade::Xml> refXml;
public:
	gcdb();
	virtual ~gcdb();

	// member methods
	void init_dock();
	void init_appbar();

	// member variables
	Gnome::UI::About *gbcdAbout;
	Gtk::MenuItem *help_about;
};

gcdb::gcdb() :
	Gnome::UI::App("GCDB", "GCDB")
{
	refXml = Gnome::Glade::Xml::create("gcdburn.glade");
	refXml->reparent_widget("bonobodock1", *this);
	refXml->reparent_widget("appbar1", *this);
...
        show_all_children();
}

this example, although seemingly logical, will compile, but when run, it gives these
errors:
(gcdburn:8507): Gtk-WARNING **: Attempting to add a widget with type BonoboDock
to a gtkmm__GnomeApp, but as a GtkBin subclass a gtkmm__GnomeApp can only contain one
widget at a time; it already contains a widget of type GtkVBox
 
(gcdburn:8507): Gtk-WARNING **: Attempting to add a widget with type gtkmm__GnomeAppBar
to a gtkmm__GnomeApp, but as a GtkBin subclass a gtkmm__GnomeApp can only contain one
widget at a time; it already contains a widget of type GtkVBox

but I've found a solution which is kind of elusive.  Instead of reparenting the children
of the GnomeApp (the appbar and bonobodock) from the glade file to the Gnome::UI::App
(*this), you need to reparent them to dynamic_cast<Gtk::Container&>(*get_child()).  To
me, that just doesn't make sense.  Is this something that's wrong in libglademm, or am I
missing something?  Or is this supposed to be a feature?  Thanks in advance.

-Bryan

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



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