diff options
author | Jonathon Jongsma <jjongsma@src.gnome.org> | 2008-04-26 04:12:58 +0000 |
---|---|---|
committer | Jonathon Jongsma <jjongsma@src.gnome.org> | 2008-04-26 04:12:58 +0000 |
commit | 97a96cc288e8b96c7c991c745285689ea0c1bb99 (patch) | |
tree | b09360244d73e42d4a6d6793c513ec36f91f0989 | |
parent | 7fec29a14e2f9637f35b560e1f206dccecf33684 (diff) | |
download | glibmm-97a96cc288e8b96c7c991c745285689ea0c1bb99.tar.gz |
Add TypeTraits implementations for Drive and Volume similar to the one added for Mount.
svn path=/trunk/; revision=660
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | gio/src/drive.hg | 40 | ||||
-rw-r--r-- | gio/src/volume.hg | 41 |
3 files changed, 87 insertions, 0 deletions
@@ -1,3 +1,9 @@ +2008-04-25 Jonathon Jongsma <jjongsma@gnome.org> + + * gio/src/drive.hg: + * gio/src/volume.hg: add TypeTraits implementations for Drive and Volume + similar to the one added for Mount. + 2008-04-23 Jonathon Jongsma <jjongsma@gnome.org> * gio/src/mount.hg: Add a TypeTraits implementation for diff --git a/gio/src/drive.hg b/gio/src/drive.hg index 813e415f..7d875dac 100644 --- a/gio/src/drive.hg +++ b/gio/src/drive.hg @@ -119,3 +119,43 @@ public: } // namespace Gio +namespace Glib +{ + +//Pre-declare this so we can use it in TypeTrait: +Glib::RefPtr<Gio::Drive> wrap(GDrive* object, bool take_copy); + +namespace Container_Helpers +{ + +/** This specialization of TypeTraits exists + * because the default use of Glib::wrap(GObject*), + * instead of a specific Glib::wrap(GSomeInterface*), + * would not return a wrapper for an interface. + */ +template <> +struct TypeTraits< Glib::RefPtr<Gio::Drive> > +{ + typedef Glib::RefPtr<Gio::Drive> CppType; + typedef GDrive* CType; + typedef GDrive* CTypeNonConst; + + static CType to_c_type (const CppType& item) + { return Glib::unwrap (item); } + + static CppType to_cpp_type (const CType& item) + { + //Use a specific Glib::wrap() function, + //because CType has the specific type (not just GObject): + return Glib::wrap(item, true /* take_copy */); + } + + static void release_c_type (CType item) + { + GLIBMM_DEBUG_UNREFERENCE(0, item); + g_object_unref(item); + } +}; + +} // Container_Helpers +} // Glib diff --git a/gio/src/volume.hg b/gio/src/volume.hg index 4d43180a..26dee39c 100644 --- a/gio/src/volume.hg +++ b/gio/src/volume.hg @@ -181,3 +181,44 @@ public: }; } // namespace Gio + +namespace Glib +{ + +//Pre-declare this so we can use it in TypeTrait: +Glib::RefPtr<Gio::Volume> wrap(GVolume* object, bool take_copy); + +namespace Container_Helpers +{ + +/** This specialization of TypeTraits exists + * because the default use of Glib::wrap(GObject*), + * instead of a specific Glib::wrap(GSomeInterface*), + * would not return a wrapper for an interface. + */ +template <> +struct TypeTraits< Glib::RefPtr<Gio::Volume> > +{ + typedef Glib::RefPtr<Gio::Volume> CppType; + typedef GVolume* CType; + typedef GVolume* CTypeNonConst; + + static CType to_c_type (const CppType& item) + { return Glib::unwrap (item); } + + static CppType to_cpp_type (const CType& item) + { + //Use a specific Glib::wrap() function, + //because CType has the specific type (not just GObject): + return Glib::wrap(item, true /* take_copy */); + } + + static void release_c_type (CType item) + { + GLIBMM_DEBUG_UNREFERENCE(0, item); + g_object_unref(item); + } +}; + +} // Container_Helpers +} // Glib |