r21293 - gnucash/trunk/src/optional/gtkmm - Add Glibmm C++ wrappers of GObject objects to the optional gtkmm module.

Christian Stimming cstim at code.gnucash.org
Thu Sep 22 06:50:12 EDT 2011


Author: cstim
Date: 2011-09-22 06:50:12 -0400 (Thu, 22 Sep 2011)
New Revision: 21293
Trac: http://svn.gnucash.org/trac/changeset/21293

Added:
   gnucash/trunk/src/optional/gtkmm/gncmm/
   gnucash/trunk/src/optional/gtkmm/gncmm/Account.cpp
   gnucash/trunk/src/optional/gtkmm/gncmm/Account.hpp
   gnucash/trunk/src/optional/gtkmm/gncmm/Book.cpp
   gnucash/trunk/src/optional/gtkmm/gncmm/Book.hpp
   gnucash/trunk/src/optional/gtkmm/gncmm/Commodity.cpp
   gnucash/trunk/src/optional/gtkmm/gncmm/Commodity.hpp
   gnucash/trunk/src/optional/gtkmm/gncmm/Numeric.cpp
   gnucash/trunk/src/optional/gtkmm/gncmm/Numeric.hpp
   gnucash/trunk/src/optional/gtkmm/gncmm/private/
   gnucash/trunk/src/optional/gtkmm/gncmm/private/Account_p.hpp
   gnucash/trunk/src/optional/gtkmm/gncmm/private/Book_p.hpp
   gnucash/trunk/src/optional/gtkmm/gncmm/private/Commodity_p.hpp
   gnucash/trunk/src/optional/gtkmm/gncmm/wrap_init.cpp
   gnucash/trunk/src/optional/gtkmm/gncmm/wrap_init.hpp
Modified:
   gnucash/trunk/src/optional/gtkmm/Makefile.am
   gnucash/trunk/src/optional/gtkmm/gncmod-gtkmm.cpp
Log:
Add Glibmm C++ wrappers of GObject objects to the optional gtkmm module.

Modified: gnucash/trunk/src/optional/gtkmm/Makefile.am
===================================================================
--- gnucash/trunk/src/optional/gtkmm/Makefile.am	2011-09-22 09:29:08 UTC (rev 21292)
+++ gnucash/trunk/src/optional/gtkmm/Makefile.am	2011-09-22 10:50:12 UTC (rev 21293)
@@ -3,10 +3,23 @@
 pkglib_LTLIBRARIES = libgncmod-gtkmm.la
 
 libgncmod_gtkmm_la_SOURCES = \
+  gncmm/Account.cpp \
+  gncmm/Book.cpp \
+  gncmm/Commodity.cpp \
+  gncmm/Numeric.cpp \
+  gncmm/wrap_init.cpp \
   gnc-plugin-gtkmm.cpp \
   gncmod-gtkmm.cpp
 
 noinst_HEADERS = \
+  gncmm/Account.hpp \
+  gncmm/Book.hpp \
+  gncmm/Commodity.hpp \
+  gncmm/private/Account_p.hpp \
+  gncmm/private/Book_p.hpp \
+  gncmm/private/Commodity_p.hpp \
+  gncmm/Numeric.hpp \
+  gncmm/wrap_init.hpp \
   gnc-plugin-gtkmm.hpp
 
 libgncmod_gtkmm_la_LDFLAGS = -avoid-version
@@ -27,6 +40,9 @@
 AM_CPPFLAGS = \
   -I${top_srcdir}/src \
   -I${top_srcdir}/src/libqof/qof \
+  -I${top_srcdir}/src/gnc-module \
+  -I${top_srcdir}/src/core-utils \
+  -I${top_srcdir}/src/engine \
   ${GTKMM_CFLAGS} \
   ${GNOME_CFLAGS} \
   ${GLADE_CFLAGS} \

Added: gnucash/trunk/src/optional/gtkmm/gncmm/Account.cpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmm/Account.cpp	                        (rev 0)
+++ gnucash/trunk/src/optional/gtkmm/gncmm/Account.cpp	2011-09-22 10:50:12 UTC (rev 21293)
@@ -0,0 +1,136 @@
+/*
+ * Account.cpp
+ * Copyright (C) 2011 Christian Stimming
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#include "config.h"
+#include "Account.hpp"
+#include "private/Account_p.hpp"
+#include "Commodity.hpp"
+
+namespace Glib
+{
+
+Glib::RefPtr<gnc::Account> wrap(::Account* object, bool take_copy)
+{
+    return Glib::RefPtr<gnc::Account>( dynamic_cast<gnc::Account*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
+    //We use dynamic_cast<> in case of multiple inheritance.
+}
+
+} /* namespace Glib */
+
+
+namespace gnc
+{
+
+
+/* The *_Class implementation: */
+
+const Glib::Class& Account_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_ = &Account_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(gnc_account_get_type());
+
+        // Add derived versions of interfaces, if the C type implements any interfaces:
+
+    }
+
+    return *this;
+}
+
+
+void Account_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);
+}
+
+
+Glib::ObjectBase* Account_Class::wrap_new(GObject* object)
+{
+    return new Account((::Account*)object);
+}
+
+
+/* The implementation: */
+
+::Account* Account::gobj_copy()
+{
+    reference();
+    return gobj();
+}
+
+Account::Account(const Glib::ConstructParams& construct_params)
+    : Glib::Object(construct_params)
+{
+
+}
+
+Account::Account(::Account* castitem)
+    : Glib::Object((GObject*)(castitem))
+{}
+
+
+Account::~Account()
+{}
+
+
+Account::CppClassType Account::account_class_; // initialize static member
+
+GType Account::get_type()
+{
+    return account_class_.init().get_type();
+}
+
+
+GType Account::get_base_type()
+{
+    return gnc_account_get_type();
+}
+
+
+
+Glib::RefPtr<Commodity> Account::getCommodity() const
+{
+    return Glib::wrap(xaccAccountGetCommodity(gobj()));
+}
+Glib::RefPtr<Account> Account::get_parent() const
+{
+    return Glib::wrap(gnc_account_get_parent(gobj()));
+}
+Glib::RefPtr<Account> Account::get_root()
+{
+    return Glib::wrap(gnc_account_get_root(gobj()));
+}
+Glib::RefPtr<Account> Account::nth_child (gint num) const
+{
+    return Glib::wrap(gnc_account_nth_child(gobj(), num));
+}
+
+} // END namespace gnc


Property changes on: gnucash/trunk/src/optional/gtkmm/gncmm/Account.cpp
___________________________________________________________________
Added: svn:eol-style
   + LF

Added: gnucash/trunk/src/optional/gtkmm/gncmm/Account.hpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmm/Account.hpp	                        (rev 0)
+++ gnucash/trunk/src/optional/gtkmm/gncmm/Account.hpp	2011-09-22 10:50:12 UTC (rev 21293)
@@ -0,0 +1,207 @@
+/*
+ * Account.hpp
+ * Copyright (C) 2011 Christian Stimming
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef GNC_ACCOUNT_HPP
+#define GNC_ACCOUNT_HPP
+
+// gnucash includes
+extern "C"
+{
+#include "qof.h"
+#include "engine/Account.h"
+}
+
+#include <glibmm/object.h>
+#include <glibmm/ustring.h>
+
+#include "Numeric.hpp"
+
+namespace gnc
+{
+class Account_Class;
+} // END namespace gnc
+
+namespace gnc
+{
+class Account;
+class Commodity;
+
+/** Wrapper around a gnucash ::Account pointer with C++ methods for
+ * easier setter and getter access.
+ */
+class Account : public Glib::Object
+{
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+    typedef Account CppObjectType;
+    typedef Account_Class CppClassType;
+    typedef ::Account BaseObjectType;
+    typedef ::AccountClass BaseClassType;
+
+private:
+    friend class Account_Class;
+    static CppClassType account_class_;
+
+private:
+    // noncopyable
+    Account(const Account&);
+    Account& operator=(const Account&);
+
+protected:
+    explicit Account(const Glib::ConstructParams& construct_params);
+    explicit Account(::Account* castitem);
+
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+public:
+    virtual ~Account();
+#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.
+    ::Account*       gobj()
+    {
+        return reinterpret_cast< ::Account*>(gobject_);
+    }
+
+    ///Provides access to the underlying C GObject.
+    const ::Account* gobj() const
+    {
+        return reinterpret_cast< ::Account*>(gobject_);
+    }
+
+    ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
+    ::Account* gobj_copy();
+
+private:
+public:
+
+
+    // actual implementation follows here
+
+    Glib::ustring getName() const
+    {
+        return (xaccAccountGetName(gobj()));
+    }
+    Glib::ustring getFullName() const
+    {
+        return gchar_to_ustring(gnc_account_get_full_name (gobj()));
+    }
+    Glib::ustring getCode() const
+    {
+        return (xaccAccountGetCode(gobj()));
+    }
+    Glib::ustring getDescription() const
+    {
+        return (xaccAccountGetDescription(gobj()));
+    }
+    Glib::RefPtr<Commodity> getCommodity() const;
+    int getCommoditySCU() const
+    {
+        return xaccAccountGetCommoditySCU(gobj());
+    }
+
+    ::SplitList* getSplitList() const
+    {
+        return xaccAccountGetSplitList(gobj());
+    }
+
+    /** @name Account tree traversal */
+    //@{
+
+    Glib::RefPtr<Account> get_parent() const;
+    Glib::RefPtr<Account> get_root();
+    bool is_root() const
+    {
+        return gnc_account_is_root(gobj());
+    }
+    gint n_children() const
+    {
+        return gnc_account_n_children(gobj());
+    }
+    GList *get_children() const
+    {
+        return gnc_account_get_children(gobj());
+    }
+    GList *get_descendants () const
+    {
+        return gnc_account_get_descendants (gobj());
+    }
+    Glib::RefPtr<Account> nth_child (gint num) const;
+
+
+    /** Return the index of this account in the children's list of its
+     * parent account.
+     */
+    gint child_index () const
+    {
+        Glib::RefPtr<Account> parent(get_parent());
+        if (parent && parent->gobj())
+            return gnc_account_child_index(parent->gobj(), gobj());
+        else
+            return 0;
+    }
+
+    gint get_current_depth () const
+    {
+        return gnc_account_get_current_depth(gobj());
+    }
+    gint get_tree_depth () const
+    {
+        return gnc_account_get_tree_depth(gobj());
+    }
+    //@}
+
+
+#if 0
+    static AccountQList fromGList(GList* glist)
+    {
+        AccountQList result;
+        GList* list = glist;
+        while (list)
+        {
+            result.append(reinterpret_cast< ::Account*>(list->data));
+            list = g_list_next(list);
+        }
+        return result;
+    }
+#endif
+
+};
+
+} // END namespace gnc
+
+namespace Glib
+{
+/** A Glib::wrap() method for this object.
+ *
+ * @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.
+ *
+ * @relates Gio::FileInfo
+ */
+Glib::RefPtr<gnc::Account> wrap(::Account* object, bool take_copy = false);
+}
+
+#endif


Property changes on: gnucash/trunk/src/optional/gtkmm/gncmm/Account.hpp
___________________________________________________________________
Added: svn:eol-style
   + LF

Added: gnucash/trunk/src/optional/gtkmm/gncmm/Book.cpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmm/Book.cpp	                        (rev 0)
+++ gnucash/trunk/src/optional/gtkmm/gncmm/Book.cpp	2011-09-22 10:50:12 UTC (rev 21293)
@@ -0,0 +1,124 @@
+/*
+ * Book.cpp
+ * Copyright (C) 2011 Christian Stimming
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#include "config.h"
+#include "Book.hpp"
+#include "private/Book_p.hpp"
+//#include "Account.hpp"
+
+namespace Glib
+{
+
+Glib::RefPtr<gnc::Book> wrap(QofBook* object, bool take_copy)
+{
+    return Glib::RefPtr<gnc::Book>( dynamic_cast<gnc::Book*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
+    //We use dynamic_cast<> in case of multiple inheritance.
+}
+
+} /* namespace Glib */
+
+
+namespace gnc
+{
+
+
+/* The *_Class implementation: */
+
+const Glib::Class& Book_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_ = &Book_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(qof_book_get_type());
+
+        // Add derived versions of interfaces, if the C type implements any interfaces:
+
+    }
+
+    return *this;
+}
+
+
+void Book_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);
+}
+
+
+Glib::ObjectBase* Book_Class::wrap_new(GObject* object)
+{
+    return new Book((QofBook*)object);
+}
+
+
+/* The implementation: */
+
+QofBook* Book::gobj_copy()
+{
+    reference();
+    return gobj();
+}
+
+Book::Book(const Glib::ConstructParams& construct_params)
+    : Glib::Object(construct_params)
+{
+
+}
+
+Book::Book(QofBook* castitem)
+    : Glib::Object((GObject*)(castitem))
+{}
+
+
+Book::~Book()
+{}
+
+
+Book::CppClassType Book::book_class_; // initialize static member
+
+GType Book::get_type()
+{
+    return book_class_.init().get_type();
+}
+
+
+GType Book::get_base_type()
+{
+    return qof_book_get_type();
+}
+
+
+
+// Account Book::get_root_account()
+// {
+//     return Account(gnc_book_get_root_account (get()));
+// }
+
+} // END namespace gnc


Property changes on: gnucash/trunk/src/optional/gtkmm/gncmm/Book.cpp
___________________________________________________________________
Added: svn:eol-style
   + LF

Added: gnucash/trunk/src/optional/gtkmm/gncmm/Book.hpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmm/Book.hpp	                        (rev 0)
+++ gnucash/trunk/src/optional/gtkmm/gncmm/Book.hpp	2011-09-22 10:50:12 UTC (rev 21293)
@@ -0,0 +1,115 @@
+/*
+ * Book.hpp
+ * Copyright (C) 2011 Christian Stimming
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef GNC_BOOK_HPP
+#define GNC_BOOK_HPP
+
+// gnucash includes
+extern "C"
+{
+#include "qof.h"
+#include "engine/gnc-hooks.h"
+#include "engine/Account.h"
+}
+
+#include <glibmm/object.h>
+
+namespace gnc
+{
+class Book_Class;
+} // END namespace gnc
+
+namespace gnc
+{
+class Account;
+
+/** Wrapper around a gnucash ::QofBook pointer with C++ methods for
+ * easier setter and getter access.
+ */
+class Book : public Glib::Object
+{
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+    typedef Book CppObjectType;
+    typedef Book_Class CppClassType;
+    typedef ::QofBook BaseObjectType;
+    typedef ::QofBookClass BaseClassType;
+
+private:
+    friend class Book_Class;
+    static CppClassType book_class_;
+
+private:
+    // noncopyable
+    Book(const Book&);
+    Book& operator=(const Book&);
+
+protected:
+    explicit Book(const Glib::ConstructParams& construct_params);
+    explicit Book(QofBook* castitem);
+
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+public:
+    virtual ~Book();
+#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.
+    QofBook*       gobj()
+    {
+        return reinterpret_cast<QofBook*>(gobject_);
+    }
+
+    ///Provides access to the underlying C GObject.
+    const QofBook* gobj() const
+    {
+        return reinterpret_cast<QofBook*>(gobject_);
+    }
+
+    ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
+    QofBook* gobj_copy();
+
+private:
+public:
+
+
+    Glib::RefPtr<Account> get_root_account();
+};
+
+} // END namespace gnc
+
+namespace Glib
+{
+/** A Glib::wrap() method for this object.
+ *
+ * @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.
+ *
+ * @relates Gio::FileInfo
+ */
+Glib::RefPtr<gnc::Book> wrap(::QofBook* object, bool take_copy = false);
+}
+
+#endif


Property changes on: gnucash/trunk/src/optional/gtkmm/gncmm/Book.hpp
___________________________________________________________________
Added: svn:eol-style
   + LF

Added: gnucash/trunk/src/optional/gtkmm/gncmm/Commodity.cpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmm/Commodity.cpp	                        (rev 0)
+++ gnucash/trunk/src/optional/gtkmm/gncmm/Commodity.cpp	2011-09-22 10:50:12 UTC (rev 21293)
@@ -0,0 +1,118 @@
+/*
+ * Commodity.cpp
+ * Copyright (C) 2011 Christian Stimming
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#include "Commodity.hpp"
+#include "private/Commodity_p.hpp"
+
+
+namespace Glib
+{
+
+Glib::RefPtr<gnc::Commodity> wrap(gnc_commodity* object, bool take_copy)
+{
+    return Glib::RefPtr<gnc::Commodity>( dynamic_cast<gnc::Commodity*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
+    //We use dynamic_cast<> in case of multiple inheritance.
+}
+
+} /* namespace Glib */
+
+
+namespace gnc
+{
+
+
+/* The *_Class implementation: */
+
+const Glib::Class& Commodity_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_ = &Commodity_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(gnc_commodity_get_type());
+
+        // Add derived versions of interfaces, if the C type implements any interfaces:
+
+    }
+
+    return *this;
+}
+
+
+void Commodity_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);
+}
+
+
+Glib::ObjectBase* Commodity_Class::wrap_new(GObject* object)
+{
+    return new Commodity((gnc_commodity*)object);
+}
+
+
+/* The implementation: */
+
+gnc_commodity* Commodity::gobj_copy()
+{
+    reference();
+    return gobj();
+}
+
+Commodity::Commodity(const Glib::ConstructParams& construct_params)
+    : Glib::Object(construct_params)
+{
+
+}
+
+Commodity::Commodity(gnc_commodity* castitem)
+    : Glib::Object((GObject*)(castitem))
+{}
+
+
+Commodity::~Commodity()
+{}
+
+
+Commodity::CppClassType Commodity::commodity_class_; // initialize static member
+
+GType Commodity::get_type()
+{
+    return commodity_class_.init().get_type();
+}
+
+
+GType Commodity::get_base_type()
+{
+    return gnc_commodity_get_type();
+}
+
+
+
+} // END namespace gnc


Property changes on: gnucash/trunk/src/optional/gtkmm/gncmm/Commodity.cpp
___________________________________________________________________
Added: svn:eol-style
   + LF

Added: gnucash/trunk/src/optional/gtkmm/gncmm/Commodity.hpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmm/Commodity.hpp	                        (rev 0)
+++ gnucash/trunk/src/optional/gtkmm/gncmm/Commodity.hpp	2011-09-22 10:50:12 UTC (rev 21293)
@@ -0,0 +1,157 @@
+/*
+ * Commodity.hpp
+ * Copyright (C) 2011 Christian Stimming
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef GNC_COMMODITY_HPP
+#define GNC_COMMODITY_HPP
+
+// gnucash includes
+#include "config.h"
+extern "C"
+{
+#include "qof.h"
+#include "engine/gnc-commodity.h"
+}
+
+#include <glibmm/object.h>
+#include <glibmm/ustring.h>
+
+namespace gnc
+{
+class Commodity_Class;
+} // END namespace gnc
+
+namespace gnc
+{
+
+/** Wrapper around a gnucash \ref gnc_commodity object */
+class Commodity : public Glib::Object
+{
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+    typedef Commodity CppObjectType;
+    typedef Commodity_Class CppClassType;
+    typedef ::gnc_commodity BaseObjectType;
+    typedef ::gnc_commodityClass BaseClassType;
+
+private:
+    friend class Commodity_Class;
+    static CppClassType commodity_class_;
+
+private:
+    // noncopyable
+    Commodity(const Commodity&);
+    Commodity& operator=(const Commodity&);
+
+protected:
+    explicit Commodity(const Glib::ConstructParams& construct_params);
+    explicit Commodity(gnc_commodity* castitem);
+
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+public:
+    virtual ~Commodity();
+#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.
+    gnc_commodity*       gobj()
+    {
+        return reinterpret_cast<gnc_commodity*>(gobject_);
+    }
+
+    ///Provides access to the underlying C GObject.
+    const gnc_commodity* gobj() const
+    {
+        return reinterpret_cast<gnc_commodity*>(gobject_);
+    }
+
+    ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
+    gnc_commodity* gobj_copy();
+
+private:
+public:
+
+    Glib::ustring get_mnemonic() const
+    {
+        return gnc_commodity_get_mnemonic(gobj());
+    }
+    Glib::ustring get_namespace() const
+    {
+        return gnc_commodity_get_namespace(gobj());
+    }
+    Glib::ustring get_fullname() const
+    {
+        return gnc_commodity_get_fullname(gobj());
+    }
+    Glib::ustring get_printname() const
+    {
+        return gnc_commodity_get_printname(gobj());
+    }
+
+    int get_fraction() const
+    {
+        return gnc_commodity_get_fraction(gobj());
+    }
+    bool get_quote_flag() const
+    {
+        return gnc_commodity_get_quote_flag(gobj());
+    }
+
+    bool is_currency() const
+    {
+        return gnc_commodity_is_currency(gobj());
+    }
+
+    bool equal(const Commodity& other) const
+    {
+        return gnc_commodity_equal(gobj(), other.gobj());
+    }
+};
+
+inline bool operator==(const Commodity& a, const Commodity& b)
+{
+    return a.equal(b);
+}
+
+inline bool operator!=(const Commodity& a, const Commodity& b)
+{
+    return !(a == b);
+}
+
+} // END namespace gnc
+
+namespace Glib
+{
+/** A Glib::wrap() method for this object.
+ *
+ * @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.
+ *
+ * @relates Gio::FileInfo
+ */
+Glib::RefPtr<gnc::Commodity> wrap(gnc_commodity* object, bool take_copy = false);
+}
+
+
+#endif


Property changes on: gnucash/trunk/src/optional/gtkmm/gncmm/Commodity.hpp
___________________________________________________________________
Added: svn:eol-style
   + LF

Added: gnucash/trunk/src/optional/gtkmm/gncmm/Numeric.cpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmm/Numeric.cpp	                        (rev 0)
+++ gnucash/trunk/src/optional/gtkmm/gncmm/Numeric.cpp	2011-09-22 10:50:12 UTC (rev 21293)
@@ -0,0 +1,72 @@
+/*
+ * Numeric.cpp
+ * Copyright (C) 2011 Christian Stimming
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#include "Numeric.hpp"
+
+extern "C"
+{
+#include "app-utils/gnc-exp-parser.h"
+}
+
+namespace gnc
+{
+
+// These are in the cpp file to avoid circular dependency between the
+// headers
+
+// PrintAmountInfo::PrintAmountInfo(const Account& account, bool use_symbol)
+//         : base_class(gnc_account_print_info(account.get(), use_symbol))
+// {}
+// PrintAmountInfo::PrintAmountInfo(const Split& split, bool use_symbol)
+//         : base_class(gnc_split_amount_print_info(split.get(), use_symbol))
+// {}
+
+Glib::ustring Numeric::printAmount(const PrintAmountInfo& info) const
+{
+    char buf[256];
+    if (!xaccSPrintAmount (buf, *this, info))
+        buf[0] = '\0';
+    return Glib::ustring(buf);
+}
+
+Glib::ustring Numeric::parse(const Glib::ustring& str)
+{
+    Glib::ustring errorString;
+
+    const char* input = str.c_str();
+    char *error_loc;
+    Numeric result;
+    gboolean p = gnc_exp_parser_parse(input, &result, &error_loc);
+    if (p)
+    {
+        *this = result;
+    }
+    else
+    {
+        errorString = Glib::ustring(gnc_exp_parser_error_string());
+    }
+
+    return errorString;
+}
+
+
+} // END namespace gnc


Property changes on: gnucash/trunk/src/optional/gtkmm/gncmm/Numeric.cpp
___________________________________________________________________
Added: svn:eol-style
   + LF

Added: gnucash/trunk/src/optional/gtkmm/gncmm/Numeric.hpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmm/Numeric.hpp	                        (rev 0)
+++ gnucash/trunk/src/optional/gtkmm/gncmm/Numeric.hpp	2011-09-22 10:50:12 UTC (rev 21293)
@@ -0,0 +1,324 @@
+/*
+ * Numeric.hpp
+ * Copyright (C) 2011 Christian Stimming
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef GNC_NUMERIC_HPP
+#define GNC_NUMERIC_HPP
+
+// gnucash includes
+#include "config.h"
+extern "C"
+{
+#include "qof.h"
+#include "gnc-date.h"
+#include "app-utils/gnc-ui-util.h"
+#include "app-utils/gnc-ui-balances.h"
+}
+
+#include <glibmm/ustring.h>
+
+#if GLIB_HAVE_DATETIME
+// Glib::DateTime is new in glibmm-2.29 but very useful
+# include <glibmm/datetime.h>
+#endif
+
+namespace gnc
+{
+
+class Account;
+class Split;
+
+/** Conversion of a newly allocated gchar* to QString, which will
+ * correctly g_free() the newly allocated gchar* as well.
+ *
+ * If a gchar* does not have to be freed again, the standard
+ * conversion constructor Glib::ustring(const gchar*) is sufficient
+ * (as it expects its input in UTF-8) and we do not need to define an
+ * extra function for that.
+ */
+inline Glib::ustring gchar_to_ustring(gchar* tmp_string)
+{
+    if (!tmp_string)
+        return Glib::ustring();
+    Glib::ustring result(tmp_string); // implies source string in UTF-8
+    g_free(tmp_string);
+    return result;
+}
+
+#if GLIB_HAVE_DATETIME
+// Glib::DateTime is new in glibmm-2.29 but very useful
+inline Glib::DateTime toQDateTime(const ::Timespec& timespec)
+{
+    Glib::DateTime result = Glib::DateTime::create_now_utc(timespec.tv_sec);
+    result.add_seconds(timespec.tv_nsec * 1e-9);
+    return result;
+}
+inline ::Timespec toTimespec(const Glib::DateTime& gdt)
+{
+    ::Timespec result;
+    result.tv_sec = qdt.to_unix;
+    result.tv_nsec = qdt.get_microseconds() * 1000;
+    return result;
+}
+#endif
+
+
+/** Wrapper around a gnucash ::GNCPrintAmountInfo structure with C++
+ * methods for easier setter and getter access.
+ *
+ * Since this class is a derived class of the original gnucash struct,
+ * it keeps the data by-value and its member variables will always
+ * exist as long as this object exists.
+ */
+class PrintAmountInfo : public ::GNCPrintAmountInfo
+{
+public:
+    typedef ::GNCPrintAmountInfo base_class;
+
+    PrintAmountInfo(const base_class& other)
+        : base_class(other)
+    {}
+    PrintAmountInfo(bool use_symbol)
+        : base_class(gnc_default_print_info(use_symbol))
+    {}
+
+    /* If the boolean set to true, then prefix 3 letter ISO 4217
+       currency code to the amount. */
+    PrintAmountInfo(const Account& account, bool use_symbol);
+    PrintAmountInfo(const Split& split, bool use_symbol);
+
+    static PrintAmountInfo share_places(int decplaces)
+    {
+        return gnc_share_print_info_places(decplaces);
+    }
+    static PrintAmountInfo default_share()
+    {
+        return gnc_default_share_print_info();
+    }
+    static PrintAmountInfo default_price()
+    {
+        return gnc_default_price_print_info();
+    }
+    static PrintAmountInfo integral()
+    {
+        return gnc_integral_print_info();
+    }
+};
+
+
+/** Wrapper around a gnucash ::gnc_numeric structure with C++ methods
+ * for easier setter and getter access.
+ *
+ * Since this class is a derived class of the original gnucash struct,
+ * it keeps the data by-value and its member variables will always
+ * exist as long as this object exists.
+ */
+class Numeric : public ::gnc_numeric
+{
+public:
+    typedef ::gnc_numeric base_class;
+
+    /// Constructor for value zero
+    Numeric()
+    {
+        base_class::num = 0;
+        base_class::denom = 1;
+    }
+
+    /// Constructor with given nominator and denominator
+    Numeric(gint64 num, gint64 denom)
+    {
+        base_class::num = num;
+        base_class::denom = denom;
+    }
+
+    /// Copy constructor
+    Numeric(const base_class& other) : base_class(other) {}
+
+    /// Constructor for value zero
+    static Numeric zero()
+    {
+        return Numeric(0, 1);
+    }
+
+    /// Constructor for value one
+    static Numeric one()
+    {
+        return Numeric(1, 1);
+    }
+
+    /// Conversion from a double value, with the given target
+    /// denominator and the specified rounding method "how".
+    Numeric(double in, gint64 denom, gint how)
+    {
+        *this = double_to_gnc_numeric(in, denom, how);
+    }
+
+    /// Watch out: This conversion never seems to work!
+    static bool string_to_numeric(const Glib::ustring& str, Numeric& n)
+    {
+        return string_to_gnc_numeric(str.c_str(), &n);
+    }
+
+    /// Constructor for representing any of the given
+    /// GNCNumericErrorCode values
+    Numeric(GNCNumericErrorCode error_code)
+    {
+        *this = gnc_numeric_error(error_code);
+    }
+
+    /// Returns the numerator
+    gint64 num() const
+    {
+        return base_class::num;
+    }
+    /// Returns the denominator
+    gint64 denom() const
+    {
+        return base_class::denom;
+    }
+    /// Conversion to double
+    gdouble to_double() const
+    {
+        return gnc_numeric_to_double(*this);
+    }
+
+    /// Conversion to string, but only as a fractional representation
+    /// i.e. "123/456". Use printAmount() for user-visible values
+    /// instead.
+    Glib::ustring to_string() const
+    {
+        return gchar_to_ustring(gnc_numeric_to_string(*this));
+    }
+
+    GNCNumericErrorCode check() const
+    {
+        return gnc_numeric_check(*this);
+    }
+    gint compare(const Numeric& b) const
+    {
+        return gnc_numeric_compare(*this, b);
+    }
+    bool zero_p() const
+    {
+        return gnc_numeric_zero_p(*this);
+    }
+    bool negative_p() const
+    {
+        return gnc_numeric_negative_p(*this);
+    }
+    bool positive_p() const
+    {
+        return gnc_numeric_positive_p(*this);
+    }
+    bool eq(const Numeric& b) const
+    {
+        return gnc_numeric_eq(*this, b);
+    }
+    bool equal(const Numeric& b) const
+    {
+        return gnc_numeric_equal(*this, b);
+    }
+    bool same(const Numeric& b, gint64 denom, gint how) const
+    {
+        return gnc_numeric_same(*this, b, denom, how);
+    }
+
+    Numeric add(const Numeric& b, gint64 denom, gint how) const
+    {
+        return gnc_numeric_add(*this, b, denom, how);
+    }
+    Numeric sub(const Numeric& b, gint64 denom, gint how) const
+    {
+        return gnc_numeric_sub(*this, b, denom, how);
+    }
+    Numeric mul(const Numeric& b, gint64 denom, gint how) const
+    {
+        return gnc_numeric_mul(*this, b, denom, how);
+    }
+    Numeric div(const Numeric& b, gint64 denom, gint how) const
+    {
+        return gnc_numeric_div(*this, b, denom, how);
+    }
+    Numeric neg() const
+    {
+        return gnc_numeric_neg(*this);
+    }
+    Numeric abs() const
+    {
+        return gnc_numeric_abs(*this);
+    }
+
+    Numeric add_fixed(const Numeric& b) const
+    {
+        return gnc_numeric_add_fixed(*this, b);
+    }
+    Numeric sub_fixed(const Numeric& b) const
+    {
+        return gnc_numeric_sub_fixed(*this, b);
+    }
+
+    Numeric reduce() const
+    {
+        return gnc_numeric_reduce(*this);
+    }
+
+    Glib::ustring printAmount(const PrintAmountInfo& info) const;
+
+    /** Parses the given string by the expression parser. On success,
+     * the value is written into this object and an empty string is
+     * returned. On error, this object is unchanged and a string with
+     * the error message is returned. */
+    Glib::ustring parse(const Glib::ustring& str);
+};
+
+inline bool operator==(const Numeric& a, const Numeric& b)
+{
+    return a.equal(b);
+}
+
+inline bool operator!=(const Numeric& a, const Numeric& b)
+{
+    return !(a == b);
+}
+
+/// Returns the negative value of a
+inline Numeric operator-(const Numeric& a)
+{
+    return a.neg();
+}
+
+/// Returns a + b
+inline Numeric operator+(const Numeric& a, const Numeric& b)
+{
+    return a.add_fixed(b);
+}
+
+/// Returns a - b
+inline Numeric operator-(const Numeric& a, const Numeric& b)
+{
+    return a.sub_fixed(b);
+}
+
+} // END namespace gnc
+
+
+#endif


Property changes on: gnucash/trunk/src/optional/gtkmm/gncmm/Numeric.hpp
___________________________________________________________________
Added: svn:eol-style
   + LF

Added: gnucash/trunk/src/optional/gtkmm/gncmm/private/Account_p.hpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmm/private/Account_p.hpp	                        (rev 0)
+++ gnucash/trunk/src/optional/gtkmm/gncmm/private/Account_p.hpp	2011-09-22 10:50:12 UTC (rev 21293)
@@ -0,0 +1,48 @@
+// -*- c++ -*-
+// Generated by gtkmmproc -- DO NOT MODIFY!
+#ifndef _GNCMM_PRIVATE_ACCOUNT_P_HPP
+#define _GNCMM_PRIVATE_ACCOUNT_P_HPP
+
+
+#include <glibmm/private/object_p.h>
+
+#include <glibmm/class.h>
+
+namespace gnc
+{
+
+class Account_Class : public Glib::Class
+{
+public:
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+    typedef Account CppObjectType;
+    typedef ::Account BaseObjectType;
+    typedef ::AccountClass BaseClassType;
+    typedef Glib::Object_Class CppClassParent;
+    typedef GObjectClass BaseClassParent;
+
+    friend class Account;
+#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):
+};
+
+
+} // namespace gnc
+
+
+#endif /* _GNCMM_PRIVATE_ACCOUNT_P_HPP */
+


Property changes on: gnucash/trunk/src/optional/gtkmm/gncmm/private/Account_p.hpp
___________________________________________________________________
Added: svn:eol-style
   + LF

Added: gnucash/trunk/src/optional/gtkmm/gncmm/private/Book_p.hpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmm/private/Book_p.hpp	                        (rev 0)
+++ gnucash/trunk/src/optional/gtkmm/gncmm/private/Book_p.hpp	2011-09-22 10:50:12 UTC (rev 21293)
@@ -0,0 +1,48 @@
+// -*- c++ -*-
+// Generated by gtkmmproc -- DO NOT MODIFY!
+#ifndef _GNCMM_PRIVATE_BOOK_P_HPP
+#define _GNCMM_PRIVATE_BOOK_P_HPP
+
+
+#include <glibmm/private/object_p.h>
+
+#include <glibmm/class.h>
+
+namespace gnc
+{
+
+class Book_Class : public Glib::Class
+{
+public:
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+    typedef Book CppObjectType;
+    typedef QofBook BaseObjectType;
+    typedef QofBookClass BaseClassType;
+    typedef Glib::Object_Class CppClassParent;
+    typedef GObjectClass BaseClassParent;
+
+    friend class Book;
+#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):
+};
+
+
+} // namespace gnc
+
+
+#endif /* _GNCMM_PRIVATE_BOOK_P_HPP */
+


Property changes on: gnucash/trunk/src/optional/gtkmm/gncmm/private/Book_p.hpp
___________________________________________________________________
Added: svn:eol-style
   + LF

Added: gnucash/trunk/src/optional/gtkmm/gncmm/private/Commodity_p.hpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmm/private/Commodity_p.hpp	                        (rev 0)
+++ gnucash/trunk/src/optional/gtkmm/gncmm/private/Commodity_p.hpp	2011-09-22 10:50:12 UTC (rev 21293)
@@ -0,0 +1,48 @@
+// -*- c++ -*-
+// Generated by gtkmmproc -- DO NOT MODIFY!
+#ifndef _GNCMM_GNC_COMMODITY_P_H
+#define _GNCMM_GNC_COMMODITY_P_H
+
+
+#include <glibmm/private/object_p.h>
+
+#include <glibmm/class.h>
+
+namespace gnc
+{
+
+class Commodity_Class : public Glib::Class
+{
+public:
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+    typedef Commodity CppObjectType;
+    typedef gnc_commodity BaseObjectType;
+    typedef gnc_commodityClass BaseClassType;
+    typedef Glib::Object_Class CppClassParent;
+    typedef GObjectClass BaseClassParent;
+
+    friend class Commodity;
+#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):
+};
+
+
+} // namespace gnc
+
+
+#endif /* _GNCMM_GNC_COMMODITY_P_H */
+


Property changes on: gnucash/trunk/src/optional/gtkmm/gncmm/private/Commodity_p.hpp
___________________________________________________________________
Added: svn:eol-style
   + LF

Added: gnucash/trunk/src/optional/gtkmm/gncmm/wrap_init.cpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmm/wrap_init.cpp	                        (rev 0)
+++ gnucash/trunk/src/optional/gtkmm/gncmm/wrap_init.cpp	2011-09-22 10:50:12 UTC (rev 21293)
@@ -0,0 +1,51 @@
+
+#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 <giomm/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 "config.h"
+#include "Account.hpp"
+#include "Book.hpp"
+#include "Commodity.hpp"
+
+extern "C"
+{
+
+//Declarations of the *_get_type() functions:
+
+    GType gnc_account_get_type(void);
+    GType qof_book_get_type(void);
+    GType gnc_commodity_get_type(void);
+} // extern "C"
+
+//Declarations of the *_Class::wrap_new() methods, instead of including all the private headers:
+
+namespace gnc {  class Account_Class { public: static Glib::ObjectBase* wrap_new(GObject*); };  }
+namespace gnc {  class Book_Class { public: static Glib::ObjectBase* wrap_new(GObject*); };  }
+namespace gnc {  class Commodity_Class { public: static Glib::ObjectBase* wrap_new(GObject*); };  }
+
+namespace gnc
+{
+void wrap_init()
+{
+// Map gtypes to gtkmm wrapper-creation functions:
+    Glib::wrap_register(gnc_account_get_type(), &gnc::Account_Class::wrap_new);
+    Glib::wrap_register(qof_book_get_type(), &gnc::Book_Class::wrap_new);
+    Glib::wrap_register(gnc_commodity_get_type(), &gnc::Commodity_Class::wrap_new);
+
+    // Register our gtkmm gtypes:
+    gnc::Account::get_type();
+    gnc::Book::get_type();
+    gnc::Commodity::get_type();
+} // wrap_init()
+} // END namespace gnc
+


Property changes on: gnucash/trunk/src/optional/gtkmm/gncmm/wrap_init.cpp
___________________________________________________________________
Added: svn:eol-style
   + LF

Added: gnucash/trunk/src/optional/gtkmm/gncmm/wrap_init.hpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmm/wrap_init.hpp	                        (rev 0)
+++ gnucash/trunk/src/optional/gtkmm/gncmm/wrap_init.hpp	2011-09-22 10:50:12 UTC (rev 21293)
@@ -0,0 +1,32 @@
+// -*- c++ -*-
+#ifndef _GNCMM_WRAP_INIT_H
+#define _GNCMM_WRAP_INIT_H
+
+#include <glibmm.h>
+
+/* wrap_init.h
+ *
+ * Copyright (C) 2007 The gtkmm development team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+namespace gnc
+{
+void wrap_init () ;
+}
+
+#endif //_GNCMM_WRAP_INIT_H
+


Property changes on: gnucash/trunk/src/optional/gtkmm/gncmm/wrap_init.hpp
___________________________________________________________________
Added: svn:eol-style
   + LF

Modified: gnucash/trunk/src/optional/gtkmm/gncmod-gtkmm.cpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmod-gtkmm.cpp	2011-09-22 09:29:08 UTC (rev 21292)
+++ gnucash/trunk/src/optional/gtkmm/gncmod-gtkmm.cpp	2011-09-22 10:50:12 UTC (rev 21293)
@@ -49,6 +49,7 @@
 #include <gtkmm.h>
 
 // And our own plugin
+#include "gncmm/wrap_init.hpp"
 #include "gnc-plugin-gtkmm.hpp"
 
 extern "C" {
@@ -80,6 +81,9 @@
         // is sufficient; we don't actually need a Gtk::Main object.
         Gtk::Main::init_gtkmm_internals();
 
+        // Register our own gncmm wrapper classes at glib type system
+        gnc::wrap_init();
+
         // Register our plugin, adding menu items with callbacks
         gncmm::gnc_plugin_gtkmm_create_plugin();
 



More information about the gnucash-changes mailing list