[gnomemm] libglademm: derived widgets



> From: Martin Cole [mailto:mjc sci utah edu] 
> Hi,
> 
> I am not sure but it looks like this is the right list for libglademm 
> questions?
> 
> I would like to tell libglademm to create my derived widget types 
> instead of constructing the standard widgets for various widget types 
> that are parsed in the input xml file.
> 
> for example if
> 
> <child>
>    <widget class="GtkScale" id="myscale">
> 
> I would like to somehow have my class that derives from GtkScale 
> created.  Is this possible? If so could you point me to the interface?

I thought that I had posted about this before, but I can't seem to find
anything in the recent archives. This is something that people often want to
do with libglademm, and I think we need to add some libglademm API for it.

I think we need something like this:

MyDialog* pDialog = 0; //MyDialog derives from Gtk::Dialog.
refXml->get_widget_derived("DialogBasic", pDialog);


And Glade::Xml::get_widget_derived() would look something like this, with a
few extra checks and g_warning()s such as we have already (implemented in
get_widget_checked):

template<class T_Widget>
T_Widget* get_widget_derived(const Glib::ustring& name, T_Widget* &widget)
{
  GObject* cobject = glade_xml_get_widget(name.c_str(), gobj());
  if(!cobject)
    return 0; //TODO: Use g_warning().
  else
  {
    return new T_Widget(cobject);
  }
}


If people want this to happen then they should test that code out in their
own applications. If it works then we can add it to libglademm.

Murray Cumming
murrayc usa net
www.murrayc.com 



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