summaryrefslogtreecommitdiff
path: root/libs/libglademm/libglademm
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2005-11-11 04:30:28 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2005-11-11 04:30:28 +0000
commitc9f039a92457221e9e76e06c7ee4e4a34dc72d05 (patch)
tree9db27e5c85c4f2467436c6ad2a2b7dc0a6f2c154 /libs/libglademm/libglademm
parentf34ef3c93a0985aa6fd95c5d92ea6b9c648587f3 (diff)
added libglademm
git-svn-id: svn://localhost/trunk/ardour2@78 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/libglademm/libglademm')
-rw-r--r--libs/libglademm/libglademm/init.cc34
-rw-r--r--libs/libglademm/libglademm/init.h38
-rw-r--r--libs/libglademm/libglademm/private/xml_p.h50
-rw-r--r--libs/libglademm/libglademm/variablesmap.cc199
-rw-r--r--libs/libglademm/libglademm/variablesmap.h96
-rw-r--r--libs/libglademm/libglademm/wrap_init.cc50
-rw-r--r--libs/libglademm/libglademm/wrap_init.h37
-rw-r--r--libs/libglademm/libglademm/xml.cc343
-rw-r--r--libs/libglademm/libglademm/xml.h348
9 files changed, 1195 insertions, 0 deletions
diff --git a/libs/libglademm/libglademm/init.cc b/libs/libglademm/libglademm/init.cc
new file mode 100644
index 0000000000..5e394a8a40
--- /dev/null
+++ b/libs/libglademm/libglademm/init.cc
@@ -0,0 +1,34 @@
+// -*- c++ -*-
+/* $Id$ */
+
+/* init.cc
+ *
+ * Copyright 2001 Free Software Foundation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <libglademm/init.h>
+#include <libglademm/wrap_init.h>
+
+namespace Gnome
+{
+
+namespace Glade
+{
+
+
+} //namespace Glade
+} //namespace Gnome
diff --git a/libs/libglademm/libglademm/init.h b/libs/libglademm/libglademm/init.h
new file mode 100644
index 0000000000..8924769150
--- /dev/null
+++ b/libs/libglademm/libglademm/init.h
@@ -0,0 +1,38 @@
+// -*- c++ -*-
+#ifndef _LIBGLADEMM_INIT_H
+#define _LIBGLADEMM_INIT_H
+/* $Id$ */
+
+/* init.h
+ *
+ * Copyright 2001 Free Software Foundation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+namespace Gnome
+{
+
+namespace Glade
+{
+
+
+
+} /* namespace Glade */
+} //namespace Gnome
+
+#endif //_LIBGLADEMM_INIT_H
+
diff --git a/libs/libglademm/libglademm/private/xml_p.h b/libs/libglademm/libglademm/private/xml_p.h
new file mode 100644
index 0000000000..e69f6798cc
--- /dev/null
+++ b/libs/libglademm/libglademm/private/xml_p.h
@@ -0,0 +1,50 @@
+// -*- c++ -*-
+// Generated by gtkmmproc -- DO NOT MODIFY!
+#ifndef _LIBGLADEMM_XML_P_H
+#define _LIBGLADEMM_XML_P_H
+#include <glibmm/private/object_p.h>
+
+#include <glibmm/class.h>
+
+namespace Gnome
+{
+
+namespace Glade
+{
+
+class Xml_Class : public Glib::Class
+{
+public:
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+ typedef Xml CppObjectType;
+ typedef GladeXML BaseObjectType;
+ typedef GladeXMLClass BaseClassType;
+ typedef Glib::Object_Class CppClassParent;
+ typedef GObjectClass BaseClassParent;
+
+ friend class Xml;
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+ const Glib::Class& init();
+
+ static void class_init_function(void* g_class, void* class_data);
+
+ static Glib::ObjectBase* wrap_new(GObject*);
+
+protected:
+
+ //Callbacks (default signal handlers):
+ //These will call the *_impl member methods, which will then call the existing default signal callbacks, if any.
+ //You could prevent the original default signal handlers being called by overriding the *_impl method.
+
+ //Callbacks (virtual functions):
+ static GType lookup_type_vfunc_callback(GladeXML* self, const char* classname);
+ };
+
+
+} // namespace Glade
+
+} // namespace Gnome
+
+#endif /* _LIBGLADEMM_XML_P_H */
+
diff --git a/libs/libglademm/libglademm/variablesmap.cc b/libs/libglademm/libglademm/variablesmap.cc
new file mode 100644
index 0000000000..57d9785bc3
--- /dev/null
+++ b/libs/libglademm/libglademm/variablesmap.cc
@@ -0,0 +1,199 @@
+/* variablesmap.cc
+ *
+ * Copyright (C) 2002 The libglademm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <libglademm/variablesmap.h>
+#include <gtkmm/togglebutton.h>
+#include <gtkmm/entry.h>
+#include <gtkmm/calendar.h>
+#include <gtkmm/scale.h>
+#include <gtkmm/comboboxentry.h>
+
+namespace Gnome
+{
+
+namespace Glade
+{
+
+VariablesMap::VariablesMap(const Glib::RefPtr<Glade::Xml>& glade)
+: m_refGlade(glade)
+{
+}
+
+VariablesMap::~VariablesMap()
+{
+}
+
+
+void VariablesMap::connect_widget(const Glib::ustring& widget_name, bool& variable)
+{
+ Gtk::ToggleButton* pToggleButton = 0;
+ m_refGlade->get_widget(widget_name, pToggleButton); //Glade::Xml will complain if it is not a ToggleButton.
+ if(pToggleButton)
+ {
+ m_mapWidgetsToVariables[pToggleButton] = (void*)(&variable);
+ }
+}
+
+void VariablesMap::connect_widget(const Glib::ustring& widget_name, Glib::ustring& variable)
+{
+ Gtk::Widget* pWidget = 0;
+ m_refGlade->get_widget(widget_name, pWidget);
+
+ Gtk::Entry* pEntry = dynamic_cast<Gtk::Entry*>(pWidget); //it mange both Gtk::entry and Gtk::SpinButton
+ Gtk::ComboBoxEntry* pComboBoxEntry = dynamic_cast<Gtk::ComboBoxEntry*>(pWidget);
+ if(pEntry)
+ {
+ m_mapWidgetsToVariables[pEntry] = (void*)(&variable);
+ }
+ if(pComboBoxEntry)
+ {
+ m_mapWidgetsToVariables[pComboBoxEntry] = (void*)(&variable);
+ }
+}
+
+void VariablesMap::connect_widget(const Glib::ustring& widget_name, double& variable)
+{
+ Gtk::Widget* pWidget = 0;
+ m_refGlade->get_widget(widget_name, pWidget);
+
+ Gtk::Scale* pScale = dynamic_cast<Gtk::Scale*>(pWidget);
+ if(pScale)
+ {
+ m_mapWidgetsToVariables[pScale] = (void*)(&variable);
+ }
+}
+
+void VariablesMap::connect_widget(const Glib::ustring& widget_name, Glib::Date& variable)
+{
+ Gtk::Widget* pWidget = 0;
+ m_refGlade->get_widget(widget_name, pWidget);
+
+ Gtk::Calendar* pCalendar = dynamic_cast<Gtk::Calendar*>(pWidget);
+ if(pCalendar)
+ {
+ m_mapWidgetsToVariables[pCalendar] = (void*)(&variable);
+ }
+}
+
+void VariablesMap::transfer_widgets_to_variables()
+{
+ if(validate_widgets()) //If the widgets' data is correct. Useful to override.
+ {
+ for(type_mapWidgetsToVariables::iterator iter = m_mapWidgetsToVariables.begin(); iter != m_mapWidgetsToVariables.end(); ++iter)
+ {
+ transfer_one_widget(iter->first, true); //true = to_variable.
+ }
+ }
+}
+
+void VariablesMap::transfer_variables_to_widgets()
+{
+ for(type_mapWidgetsToVariables::iterator iter = m_mapWidgetsToVariables.begin(); iter != m_mapWidgetsToVariables.end(); ++iter)
+ {
+ transfer_one_widget(iter->first, false); //false = to_widget.
+ }
+}
+
+
+void VariablesMap::transfer_one_widget(Gtk::Widget* pWidget, bool to_variable)
+{
+ //Find the widget in the map:
+ type_mapWidgetsToVariables::iterator iterFind = m_mapWidgetsToVariables.find(pWidget);
+ if(iterFind != m_mapWidgetsToVariables.end())
+ {
+ //Get the variable for the widget:
+ void* pVariable = iterFind->second;
+ if(pVariable)
+ {
+ //Cast the variable appropriately and set it appropriately:
+ Gtk::Entry* pEntry = dynamic_cast<Gtk::Entry*>(pWidget);
+ Gtk::ComboBoxEntry* pComboBoxEntry = dynamic_cast<Gtk::ComboBoxEntry*>(pWidget);
+
+ Gtk::ToggleButton* pToggleButton = dynamic_cast<Gtk::ToggleButton*>(pWidget); //CheckButtons and RadioButtons.
+ Gtk::Scale* pScale = dynamic_cast<Gtk::Scale*>(pWidget);
+ Gtk::Calendar* pCalendar = dynamic_cast<Gtk::Calendar*>(pWidget);
+
+ if(pEntry)
+ {
+ Glib::ustring* pVar = (Glib::ustring*)(pVariable);
+
+ if(to_variable)
+ (*pVar) = pEntry->get_text();
+ else
+ pEntry->set_text(*pVar);
+ }
+ if(pComboBoxEntry)
+ {
+ Glib::ustring* pVar = (Glib::ustring*)(pVariable);
+ Gtk::Entry* pIEntry = dynamic_cast<Gtk::Entry*>(pComboBoxEntry->get_child());
+
+ if(to_variable){
+ if(pIEntry)
+ (*pVar) = pIEntry->get_text();
+ } else {
+ if(pIEntry)
+ pIEntry->set_text(*pVar);
+ }
+ }
+ if(pToggleButton)
+ {
+ bool* pVar = (bool*)(pVariable);
+
+ if(to_variable)
+ (*pVar) = pToggleButton->get_active();
+ else
+ pToggleButton->set_active(*pVar);
+ }
+ if(pScale)
+ {
+ double* pVar = (double*)(pVariable);
+
+ if(to_variable)
+ (*pVar) = pScale->get_value();
+ else
+ pScale->set_value(*pVar);
+ }
+ if(pCalendar)
+ {
+ Glib::Date* pVar = (Glib::Date*)(pVariable);
+
+ if(to_variable){
+ guint year,month,day;
+ pCalendar->get_date(year,month,day);
+ (*pVar) = Glib::Date(day,(Glib::Date::Month)month,year);
+ } else {
+ pCalendar->select_day(pVar->get_day());
+ pCalendar->select_month(pVar->get_month(), pVar->get_year());
+ }
+ }
+ }
+ }
+}
+
+bool VariablesMap::validate_widgets()
+{
+ //Override to add validation.
+ //TODO: We could add some automatic data-range and text-length validation.
+ return true;
+}
+
+
+
+} /* namespace Glade */
+} /* namespace Gnome */
diff --git a/libs/libglademm/libglademm/variablesmap.h b/libs/libglademm/libglademm/variablesmap.h
new file mode 100644
index 0000000000..af8bbcdbb9
--- /dev/null
+++ b/libs/libglademm/libglademm/variablesmap.h
@@ -0,0 +1,96 @@
+/* variablesmap.h
+ *
+ * Copyright (C) 2002 The libglademm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _LIBGLADEMM_VARIABLESMAP_H
+#define _LIBGLADEMM_VARIABLESMAP_H
+
+#include <libglademm/xml.h>
+#include <map>
+
+namespace Gnome
+{
+
+namespace Glade
+{
+
+/** Associates named Glade widgets with member variables.
+ * Use connect_widget() to link the widgets with variables that will contain their data.
+ * Then use transfer_widgets_to_variables() and transfer_variables_to_widgets() to get or set all of the variables at once.
+ *
+ * This is meant to be a bit like MFC's "Dialog Data Exchange and Validation".
+ *
+ * The association of widget and member varables follow this mapping:
+ *
+ * Gtk::Entry --> Glib::ustring
+ * Gtk::SpinBox --> Glib::ustring
+ * Gtk::ComboBoxEntry --> Glib::ustring
+ * Gtk::Scale --> double
+ * Gtk::Calendar --> Glib::Date
+ * Gtk::CheckBox --> bool
+ * Gtk::RadioButton --> bool
+ *
+ */
+class VariablesMap
+{
+public:
+ explicit VariablesMap(const Glib::RefPtr<Glade::Xml>& glade);
+ virtual ~VariablesMap();
+
+ ///For ToggleButton (CheckBox and RadioButton)
+ virtual void connect_widget(const Glib::ustring& widget_name, bool& variable);
+
+ ///For Entry, ComboBoxEntry and SpinBox
+ virtual void connect_widget(const Glib::ustring& widget_name, Glib::ustring& variable);
+
+ ///For Scale (HScale and VScale)
+ virtual void connect_widget(const Glib::ustring& widget_name, double& variable);
+
+ ///For Calendar
+ virtual void connect_widget(const Glib::ustring& widget_name, Glib::Date& variable);
+
+ ///Transfer data from the widget to the variable.
+ virtual void transfer_widgets_to_variables();
+
+ ///Transfer data from the variable to the widget.
+ virtual void transfer_variables_to_widgets();
+
+protected:
+
+ /** Override this to validate the data that the user enters into the widgets.
+ * The return value indicates whether the widgets' data is valid.
+ */
+ virtual bool validate_widgets();
+
+ virtual void transfer_one_widget(Gtk::Widget* pWidget, bool to_variable);
+
+ typedef std::map<Gtk::Widget*, void*> type_mapWidgetsToVariables;
+ type_mapWidgetsToVariables m_mapWidgetsToVariables;
+
+ Glib::RefPtr<Glade::Xml> m_refGlade;
+};
+
+} /* namespace Glade */
+} /* namespace Gnome */
+
+
+
+
+#endif /* _LIBGLADEMM_VARIABLESMAP_H */
+
+
diff --git a/libs/libglademm/libglademm/wrap_init.cc b/libs/libglademm/libglademm/wrap_init.cc
new file mode 100644
index 0000000000..ff78f96a4f
--- /dev/null
+++ b/libs/libglademm/libglademm/wrap_init.cc
@@ -0,0 +1,50 @@
+
+#include <glib.h>
+
+// Disable the 'const' function attribute of the get_type() functions.
+// GCC would optimize them out because we don't use the return value.
+#undef G_GNUC_CONST
+#define G_GNUC_CONST /* empty */
+
+#include <libglademm/wrap_init.h>
+#include <glibmm/error.h>
+#include <glibmm/object.h>
+
+// #include the widget headers so that we can call the get_type() static methods:
+
+#include "xml.h"
+
+extern "C"
+{
+
+//Declarations of the *_get_type() functions:
+
+GType glade_xml_get_type(void);
+
+//Declarations of the *_error_quark() functions:
+
+} // extern "C"
+
+
+//Declarations of the *_Class::wrap_new() methods, instead of including all the private headers:
+
+namespace Gnome { namespace Glade { class Xml_Class { public: static Glib::ObjectBase* wrap_new(GObject*); }; } }
+
+namespace Gnome { namespace Glade {
+
+void wrap_init()
+{
+ // Register Error domains:
+
+// Map gtypes to gtkmm wrapper-creation functions:
+ Glib::wrap_register(glade_xml_get_type(), &Gnome::Glade::Xml_Class::wrap_new);
+
+ // Register the gtkmm gtypes:
+ Gnome::Glade::Xml::get_type();
+
+} // wrap_init()
+
+} //Glade
+} //Gnome
+
+
diff --git a/libs/libglademm/libglademm/wrap_init.h b/libs/libglademm/libglademm/wrap_init.h
new file mode 100644
index 0000000000..59dcf4ae07
--- /dev/null
+++ b/libs/libglademm/libglademm/wrap_init.h
@@ -0,0 +1,37 @@
+#ifndef _LIBGLADEMM_WRAP_INIT_H
+#define _LIBGLADEMM_WRAP_INIT_H
+
+/* wrap_init.h
+ *
+ * Copyright (C) 1998-2001 The libglademm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+// wrap_init.cc is generated by tools/generate_wrap_init.pl
+
+namespace Gnome
+{
+
+namespace UI
+{
+
+void wrap_init();
+
+} /* namespace UI */
+
+} /* namespace Gnome */
+
+#endif // _LIBGLADEMM_WRAP_INIT_H
diff --git a/libs/libglademm/libglademm/xml.cc b/libs/libglademm/libglademm/xml.cc
new file mode 100644
index 0000000000..5b672bc582
--- /dev/null
+++ b/libs/libglademm/libglademm/xml.cc
@@ -0,0 +1,343 @@
+// Generated by gtkmmproc -- DO NOT MODIFY!
+
+#include <libglademm/xml.h>
+#include <libglademm/private/xml_p.h>
+
+/* $Id$ */
+
+/* Copyright (C) 2002 The libglademm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <glade/glade-xml.h>
+#include <gtkmm/button.h>
+#include <gtkmm/menuitem.h>
+
+namespace Gnome
+{
+
+namespace Glade
+{
+
+XmlError::XmlError(const Glib::ustring& message)
+:
+ message_ (message)
+{}
+
+XmlError::~XmlError() throw()
+{}
+
+XmlError::XmlError(const XmlError& other)
+:
+ Glib::Exception (other),
+ message_ (other.message_)
+{}
+
+XmlError& XmlError::operator=(const XmlError& other)
+{
+ message_ = other.message_;
+ return *this;
+}
+
+Glib::ustring XmlError::what() const
+{
+ return message_;
+}
+
+
+Xml::Xml(const std::string& filename, const Glib::ustring& root, const Glib::ustring& domain)
+:
+ Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
+ Glib::Object(Glib::ConstructParams(xml_class_.init(), (char*) 0))
+{
+ if(!glade_xml_construct(gobj(), filename.c_str(), root.empty() ? 0 : root.c_str(),
+ domain.empty() ? 0 : domain.c_str()))
+ {
+ throw XmlError("Failed to load glade file `" + Glib::filename_to_utf8(filename) + '\'');
+ }
+}
+
+// TODO: we need glade_xml_construct_from_buffer()
+Xml::Xml(const char* buffer, int size, const Glib::ustring& root, const Glib::ustring& domain)
+:
+ Glib::ObjectBase(0),
+ Glib::Object((GObject*) glade_xml_new_from_buffer(
+ buffer, size, root.empty() ? 0 : root.c_str(), domain.empty() ? 0 : domain.c_str()))
+{
+ if(!gobj())
+ throw XmlError("Failed to read glade input buffer");
+}
+
+// static
+Glib::RefPtr<Xml> Xml::create(const std::string& filename,
+ const Glib::ustring& root, const Glib::ustring& domain)
+{
+ return Glib::RefPtr<Xml>(new Xml(filename, root, domain));
+}
+
+// static
+Glib::RefPtr<Xml> Xml::create_from_buffer(const char* buffer, int size,
+ const Glib::ustring& root, const Glib::ustring& domain)
+{
+ return Glib::RefPtr<Xml>(new Xml(buffer, size, root, domain));
+}
+
+void Xml::reparent_widget(const Glib::ustring& name, Gtk::Container& container)
+{
+ Gtk::Widget* pWidget = 0;
+ get_widget(name, pWidget);
+
+ g_return_if_fail(pWidget != 0);
+
+ pWidget->reparent(container);
+}
+
+Gtk::Widget* Xml::get_widget_checked(const Glib::ustring& name, GType type)
+{
+ // Get the widget from the glade file.
+ Gtk::Widget *const pWidget = get_widget(name);
+
+ if(!pWidget)
+ {
+ g_critical("widget `%s' not found in glade file `%s'", name.c_str(), gobj()->filename);
+ return 0;
+ }
+
+ // Check if it has the correct type.
+ if(!g_type_is_a(G_OBJECT_TYPE(pWidget->gobj()), type))
+ {
+ g_critical("widget `%s' (in glade file `%s') is of type `%s' but `%s' was expected",
+ name.c_str(), gobj()->filename, G_OBJECT_TYPE_NAME(pWidget->gobj()), g_type_name(type));
+ return 0;
+ }
+
+ return pWidget;
+}
+
+GtkWidget* Xml::get_cwidget(const Glib::ustring& name)
+{
+ GtkWidget* pCWidget = glade_xml_get_widget(gobj(), name.c_str());
+ if(!pCWidget)
+ g_critical("Glade::Xml::get_cwidget(): glade_xml_get_widget() failed.");
+
+ return pCWidget;
+}
+
+// Custom coded so that we can custom-code the vfunc in the Xml class.
+// This is marginally better than modifying gtkmmproc to allow this.
+//
+GType Xml_Class::lookup_type_vfunc_callback(GladeXML* self, const char* classname)
+{
+ CppObjectType *const obj = dynamic_cast<CppObjectType*>(
+ Glib::ObjectBase::_get_current_wrapper((GObject*) self));
+
+ if(obj)
+ {
+ try
+ {
+ return obj->lookup_type_vfunc(Glib::convert_const_gchar_ptr_to_ustring(classname));
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ }
+ else
+ {
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class.
+ );
+
+ if(base && base->lookup_type)
+ return (*base->lookup_type)(self, classname);
+ }
+
+ return 0;
+}
+
+GType Xml::lookup_type_vfunc(const Glib::ustring& classname)
+{
+ // See if there is a gtkmm version of the gclass:
+ Glib::ustring classname_prefixed ("gtkmm__"); // gtkmm uses a prefix
+ classname_prefixed += classname;
+
+ GType gtype = g_type_from_name(classname_prefixed.c_str());
+
+ if(gtype == G_TYPE_INVALID) // if it's not a registered typename
+ {
+ // There's no gtkmm derived type, so just use the normal one.
+ gtype = g_type_from_name(classname.c_str());
+ }
+
+ return gtype;
+}
+
+void Xml::connect_clicked(const Glib::ustring& widget_name, const sigc::slot<void>& slot_ )
+{
+ Gtk::Widget* pWidget = 0;
+ get_widget(widget_name, pWidget);
+
+ Gtk::Button* pButton = dynamic_cast<Gtk::Button*>(pWidget);
+ Gtk::MenuItem* pMenuItem = dynamic_cast<Gtk::MenuItem*>(pWidget);
+
+ if(pButton)
+ pButton->signal_clicked().connect( slot_);
+
+ if(pMenuItem)
+ pMenuItem->signal_activate().connect( slot_ );
+}
+
+} // namespace Glade
+} // namespace Gnome
+
+
+namespace
+{
+} // anonymous namespace
+
+
+namespace Glib
+{
+
+Glib::RefPtr<Gnome::Glade::Xml> wrap(GladeXML* object, bool take_copy)
+{
+ return Glib::RefPtr<Gnome::Glade::Xml>( dynamic_cast<Gnome::Glade::Xml*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
+ //We use dynamic_cast<> in case of multiple inheritance.
+}
+
+} /* namespace Glib */
+
+
+namespace Gnome
+{
+
+namespace Glade
+{
+
+
+/* The *_Class implementation: */
+
+const Glib::Class& Xml_Class::init()
+{
+ if(!gtype_) // create the GType if necessary
+ {
+ // Glib::Class has to know the class init function to clone custom types.
+ class_init_func_ = &Xml_Class::class_init_function;
+
+ // This is actually just optimized away, apparently with no harm.
+ // Make sure that the parent type has been created.
+ //CppClassParent::CppObjectType::get_type();
+
+ // Create the wrapper type, with the same class/instance size as the base type.
+ register_derived_type(glade_xml_get_type());
+
+ // Add derived versions of interfaces, if the C type implements any interfaces:
+ }
+
+ return *this;
+}
+
+void Xml_Class::class_init_function(void* g_class, void* class_data)
+{
+ BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
+ CppClassParent::class_init_function(klass, class_data);
+
+ klass->lookup_type = &lookup_type_vfunc_callback;
+ }
+
+
+Glib::ObjectBase* Xml_Class::wrap_new(GObject* object)
+{
+ return new Xml((GladeXML*)object);
+}
+
+
+/* The implementation: */
+
+GladeXML* Xml::gobj_copy()
+{
+ reference();
+ return gobj();
+}
+
+Xml::Xml(const Glib::ConstructParams& construct_params)
+:
+ Glib::Object(construct_params)
+{}
+
+Xml::Xml(GladeXML* castitem)
+:
+ Glib::Object((GObject*)(castitem))
+{}
+
+Xml::~Xml()
+{}
+
+
+Xml::CppClassType Xml::xml_class_; // initialize static member
+
+GType Xml::get_type()
+{
+ return xml_class_.init().get_type();
+}
+
+GType Xml::get_base_type()
+{
+ return glade_xml_get_type();
+}
+
+
+std::string Xml::get_filename() const
+{
+ return Glib::convert_const_gchar_ptr_to_stdstring(gobj()->filename);
+}
+
+Gtk::Widget* Xml::get_widget(const Glib::ustring& name)
+{
+ return Glib::wrap(glade_xml_get_widget(gobj(), name.c_str()));
+}
+
+Glib::ListHandle<Gtk::Widget*> Xml::get_widget_prefix(const Glib::ustring& name)
+{
+ return Glib::ListHandle<Gtk::Widget*>(glade_xml_get_widget_prefix(gobj(), name.c_str()), Glib::OWNERSHIP_SHALLOW);
+}
+
+std::string Xml::relative_file(const std::string& filename) const
+{
+ return Glib::convert_return_gchar_ptr_to_stdstring(glade_xml_relative_file(const_cast<GladeXML*>(gobj()), filename.c_str()));
+}
+
+Glib::ustring Xml::get_widget_name(Gtk::Widget& widget)
+{
+ return Glib::convert_const_gchar_ptr_to_ustring(glade_get_widget_name((widget).gobj()));
+}
+
+Glib::RefPtr<Xml> Xml::get_widget_tree(Gtk::Widget& widget)
+{
+
+ Glib::RefPtr<Xml> retvalue = Glib::wrap(glade_get_widget_tree((widget).gobj()));
+
+ if(retvalue)
+ retvalue->reference(); //The function does not do a ref for us.
+ return retvalue;
+}
+
+
+} // namespace Glade
+
+} // namespace Gnome
+
+
diff --git a/libs/libglademm/libglademm/xml.h b/libs/libglademm/libglademm/xml.h
new file mode 100644
index 0000000000..b0e5c440f7
--- /dev/null
+++ b/libs/libglademm/libglademm/xml.h
@@ -0,0 +1,348 @@
+// -*- c++ -*-
+// Generated by gtkmmproc -- DO NOT MODIFY!
+#ifndef _LIBGLADEMM_XML_H
+#define _LIBGLADEMM_XML_H
+
+#include <glibmm.h>
+
+/* $Id$ */
+
+/* Copyright (C) 2002 The libglademm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gtkmm/container.h>
+
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+typedef struct _GladeXML GladeXML;
+typedef struct _GladeXMLClass GladeXMLClass;
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+
+namespace Gnome
+{
+
+namespace Glade
+{ class Xml_Class; } // namespace Glade
+
+} // namespace Gnome
+namespace Gnome
+{
+
+namespace Glade
+{
+
+class XmlError : public Glib::Exception
+{
+public:
+ explicit XmlError(const Glib::ustring& message);
+ virtual ~XmlError() throw();
+
+ XmlError(const XmlError& other);
+ XmlError& operator=(const XmlError& other);
+
+ virtual Glib::ustring what() const;
+
+private:
+ Glib::ustring message_;
+};
+
+
+class Xml : public Glib::Object
+{
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+public:
+ typedef Xml CppObjectType;
+ typedef Xml_Class CppClassType;
+ typedef GladeXML BaseObjectType;
+ typedef GladeXMLClass BaseClassType;
+
+private: friend class Xml_Class;
+ static CppClassType xml_class_;
+
+private:
+ // noncopyable
+ Xml(const Xml&);
+ Xml& operator=(const Xml&);
+
+protected:
+ explicit Xml(const Glib::ConstructParams& construct_params);
+ explicit Xml(GladeXML* castitem);
+
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+public:
+ virtual ~Xml();
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+ static GType get_type() G_GNUC_CONST;
+ static GType get_base_type() G_GNUC_CONST;
+#endif
+
+ ///Provides access to the underlying C GObject.
+ GladeXML* gobj() { return reinterpret_cast<GladeXML*>(gobject_); }
+
+ ///Provides access to the underlying C GObject.
+ const GladeXML* gobj() const { return reinterpret_cast<GladeXML*>(gobject_); }
+
+ ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
+ GladeXML* gobj_copy();
+
+private:
+
+
+ //Ignore private glade_xml functions.
+
+protected:
+ /** Loads a glade XML file.
+ * @throw XmlError
+ */
+ Xml(const std::string& filename, const Glib::ustring& root, const Glib::ustring& domain);
+
+ /** Reads glade XML data from memory.
+ * @throw XmlError
+ */
+ Xml(const char* buffer, int size, const Glib::ustring& root, const Glib::ustring& domain);
+
+ Gtk::Widget* get_widget_checked(const Glib::ustring& name, GType type);
+ GtkWidget* get_cwidget(const Glib::ustring& name);
+
+public:
+ typedef Gnome::Glade::XmlError Error;
+
+ /** Loads a glade XML file.
+ * @throw XmlError
+ */
+ static Glib::RefPtr<Xml> create(const std::string& filename,
+ const Glib::ustring& root = Glib::ustring(),
+ const Glib::ustring& domain = Glib::ustring());
+
+ /** Reads glade XML data from memory.
+ * @throw XmlError
+ */
+ static Glib::RefPtr<Xml> create_from_buffer(const char* buffer, int size,
+ const Glib::ustring& root = Glib::ustring(),
+ const Glib::ustring& domain = Glib::ustring());
+
+ std::string get_filename() const;
+
+//void glade_xml_signal_connect (GladeXML *self,
+// const char *handlername,
+// GCallback func);
+//void glade_xml_signal_connect_data (GladeXML *self,
+// const char *handlername,
+// GCallback func,
+// gpointer user_data);
+//
+//void glade_xml_signal_autoconnect (GladeXML *self);
+//
+//
+//typedef void (*GladeXMLConnectFunc) (const gchar *handler_name,
+// GObject *object,
+// const gchar *signal_name,
+// const gchar *signal_data,
+// GObject *connect_object,
+// gboolean after,
+// gpointer user_data);
+//
+//
+//void glade_xml_signal_connect_full (GladeXML *self,
+// const gchar *handler_name,
+// GladeXMLConnectFunc func,
+// gpointer user_data);
+//
+//void glade_xml_signal_autoconnect_full (GladeXML *self,
+// GladeXMLConnectFunc func,
+// gpointer user_data);
+//
+//
+ /** Get a widget from the glade file.
+ * For instance:
+ * @code
+ * Gtk::Table* pTable = dynamic_cast<Gtk::Table*>(refXml->get_widget("mytable"));
+ * @endcode
+ * @param name The name of the widget.
+ * @return A pointer to the widget, or <tt>0</tt> on failure.
+ */
+
+ Gtk::Widget* get_widget(const Glib::ustring& name);
+
+ /** This is for convenience.
+ * It allows for a shorter syntax with less repetition. For instance:
+ * @code
+ * Gtk::Table* pTable = 0;
+ * refXml->get_widget("mytable", pTable);
+ * @endcode
+ * This method prints a warning message to the console if the widget
+ * doesn't exist or has the wrong type, so you don't need to check that
+ * manually.
+ * @param name The name of the widget.
+ * @retval widget A pointer to the widget, or <tt>0</tt> on failure.
+ * @return The value of @a widget.
+ */
+ template <class T_Widget> inline
+ T_Widget* get_widget(const Glib::ustring& name, T_Widget*& widget)
+ {
+ // The dynamic_cast<> should never fail if get_widget_checked() succeeded.
+ widget = dynamic_cast<T_Widget*>(this->get_widget_checked(name, T_Widget::get_base_type()));
+
+ if(!widget)
+ g_critical("Gnome::Glade::Xml::get_widget(): dynamic_cast<> failed.");
+
+ return widget;
+ }
+
+ /** This provides a pointer to a widget whose details are specified in the Glade file, but which is implemented
+ * by your own derived class. Your class must have a constructor like so:
+ * @code
+ * DerivedDialog::DerivedDialog(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade)
+ * : Gtk::Dialog(cobject) //Calls the base class constructor
+ * @endcode
+ *
+ * For instance:
+ * @code
+ * Gtk::DerivedBox* pBox = 0;
+ * refXml->get_widget_derived("mybox", pBox);
+ * @endcode
+ *
+ * @param name The name of the widget.
+ * @retval widget A pointer to the widget, or <tt>0</tt> on failure.
+ * @return The value of @a widget.
+ */
+ template <class T_Widget> inline
+ T_Widget* get_widget_derived(const Glib::ustring& name, T_Widget*& widget)
+ {
+ // initialize input parameter
+ widget = 0;
+
+ // Get the widget from the glade file.
+ typedef typename T_Widget::BaseObjectType cwidget_type;
+ cwidget_type* pCWidget = (cwidget_type*)get_cwidget(name);
+
+ //The error was already reported by get_cwidget().
+ if(!pCWidget)
+ return 0;
+
+ //Check whether there is already a C++ wrapper instance associated with this C instance:
+ Glib::ObjectBase* pObjectBase = ObjectBase::_get_current_wrapper((GObject*)pCWidget);
+
+ //If there is already a C++ instance, then return it again:
+ if(pObjectBase)
+ {
+ widget = dynamic_cast<T_Widget*>( Glib::wrap((GtkWidget*)pCWidget) );
+ //Newer, more spec-complaint, versions of g++ not resolve a specific wrap() function in a template.
+
+ //The dynamic cast checks that it is of the correct type.
+ //Somebody might be trying to call get_widget_derived() after already calling get_widget(),
+ //or after already calling get_widget_derived() with a different derived C++ type.
+ if(!widget)
+ g_critical("Gnome::Glade::Xml::get_widget_derived(): dynamic_cast<> failed. An existing C++ instance, of a different type, seems to exist.");
+ }
+ else
+ {
+ //Create a new C++ instance to wrap the existing C instance:
+
+ //Set the output variable. We needed to do this because we can not template the return type.
+ Glib::RefPtr<Gnome::Glade::Xml> refThis(this);
+ refThis->reference(); //take a copy.
+ widget = new T_Widget(pCWidget, refThis);
+ }
+
+ //We return it as well (we need the parameter as well, because C++ can not just template the return type.)
+ return widget;
+ }
+
+
+ Glib::ListHandle<Gtk::Widget*> get_widget_prefix(const Glib::ustring& name);
+
+ ///Take the widget from the glade-generated container and put it in another container.
+ void reparent_widget(const Glib::ustring& name, Gtk::Container& container);
+
+
+ std::string relative_file(const std::string& filename) const;
+
+
+ static Glib::ustring get_widget_name(Gtk::Widget& widget);
+
+ static Glib::RefPtr<Xml> get_widget_tree(Gtk::Widget& widget);
+
+
+ /** Connect a Gtk::Button's clicked signal or a Gtk::MenuItem's activated signal to a slot.
+ *
+ * For instance:
+ * @code
+ * refXml->connect_button("button", sigc::mem_fun(*this, &ExampleWindow::on_button_clicked) );
+ * @endcode
+ *
+ * @param name The name of the widget.
+ * @param pslot The slot to connect to.
+ */
+ void connect_clicked(const Glib::ustring& name, const sigc::slot<void>& slot_);
+
+
+///* interface for changing the custom widget handling */
+//typedef GtkWidget *(* GladeXMLCustomWidgetHandler) (GladeXML *xml,
+// gchar *func_name,
+// gchar *name,
+// gchar *string1,
+// gchar *string2,
+// gint int1,
+// gint int2,
+// gpointer user_data);
+
+//void glade_set_custom_handler(GladeXMLCustomWidgetHandler handler,
+// gpointer user_data);
+
+
+protected:
+
+
+ virtual GType lookup_type_vfunc(const Glib::ustring& classname);
+
+
+public:
+
+public:
+ //C++ methods used to invoke GTK+ virtual functions:
+
+protected:
+ //GTK+ Virtual Functions (override these to change behaviour):
+
+ //Default Signal Handlers::
+
+
+};
+
+} // namespace Glade
+} // namespace Gnome
+
+
+namespace Glib
+{
+ /** @relates Gnome::Glade::Xml
+ * @param object The C instance
+ * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
+ * @result A C++ instance that wraps this C instance.
+ */
+ Glib::RefPtr<Gnome::Glade::Xml> wrap(GladeXML* object, bool take_copy = false);
+}
+
+
+#endif /* _LIBGLADEMM_XML_H */
+