glibmm r659 - in trunk: . gio/src



Author: jjongsma
Date: Sat Apr 26 04:12:55 2008
New Revision: 659
URL: http://svn.gnome.org/viewvc/glibmm?rev=659&view=rev

Log:
* gio/src/mount.hg: Add a TypeTraits implementation for
Glib::RefPtr<Gio::Mount> so that we can wrap implementor types that don't
have a wrapper (e.g. GHalMount in gvfs).  Fixes bug #529533


Modified:
   trunk/ChangeLog
   trunk/gio/src/mount.hg

Modified: trunk/gio/src/mount.hg
==============================================================================
--- trunk/gio/src/mount.hg	(original)
+++ trunk/gio/src/mount.hg	Sat Apr 26 04:12:55 2008
@@ -181,3 +181,43 @@
 
 } // namespace Gio
 
+namespace Glib
+{
+
+//Pre-declare this so we can use it in TypeTrait:
+Glib::RefPtr<Gio::Mount> wrap(GMount* 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::Mount> >
+{
+  typedef Glib::RefPtr<Gio::Mount> CppType;
+  typedef GMount* CType;
+  typedef GMount* 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



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