[gtkmm] gdkmm: PixbufFormat: Wrap as a boxed-type.



commit 592279e8a9c7c4d1de497d517f5a88ec9fca9a27
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Oct 26 09:58:07 2010 +0200

    gdkmm: PixbufFormat: Wrap as a boxed-type.
    
    	* gdk/src/pixbufformat.[hg|ccg]: Wrap this as a boxed-type, now that it is.
    	This means we can remove some hand-coded code.
    	* gdk/src/pixbug.hg: Move PixbufFormatTraits to pixbufformat.hg.

 ChangeLog                |    8 ++++++++
 gdk/src/pixbuf.hg        |   14 --------------
 gdk/src/pixbufformat.ccg |   29 +----------------------------
 gdk/src/pixbufformat.hg  |   37 +++++++++++++++++--------------------
 4 files changed, 26 insertions(+), 62 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index be0cb48..9935af5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-10-26  Murray Cumming  <murrayc murrayc com>
+
+	gdkmm: PixbufFormat: Wrap as a boxed-type.
+
+	* gdk/src/pixbufformat.[hg|ccg]: Wrap this as a boxed-type, now that it is.
+	This means we can remove some hand-coded code.
+	* gdk/src/pixbug.hg: Move PixbufFormatTraits to pixbufformat.hg.
+
 2010-10-25  Murray Cumming  <murrayc murrayc com>>
 
 	Add RGBA class and widget methods.(Fixing the build with latest GTK+)
diff --git a/gdk/src/pixbuf.hg b/gdk/src/pixbuf.hg
index c3de934..70acdda 100644
--- a/gdk/src/pixbuf.hg
+++ b/gdk/src/pixbuf.hg
@@ -43,20 +43,6 @@ _WRAP_ENUM(PixbufRotation, GdkPixbufRotation)
  */
 _WRAP_GERROR(PixbufError,GdkPixbufError,GDK_PIXBUF_ERROR)
 
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-struct PixbufFormatTraits
-{
-  typedef PixbufFormat  CppType;
-  typedef const GdkPixbufFormat*      CType;
-  typedef GdkPixbufFormat*            CTypeNonConst;
-
-  static CType   to_c_type      (const CppType& obj) { return obj.gobj();     }
-  static CType   to_c_type      (CType          ptr) { return ptr;                   }
-  static CppType to_cpp_type    (CType          ptr) { return PixbufFormat(ptr); /* Does not take ownership */ }
-  static void    release_c_type (CType          /* ptr */) { /* Doesn't happen */ }
-};
-#endif //DOXYGEN_SHOULD_SKIP_THIS
-
 class Pixbuf : public Glib::Object
 {
   _CLASS_GOBJECT(Pixbuf, GdkPixbuf, GDK_PIXBUF, Glib::Object, GObject)
diff --git a/gdk/src/pixbufformat.ccg b/gdk/src/pixbufformat.ccg
index 2f46d6f..f0deee2 100644
--- a/gdk/src/pixbufformat.ccg
+++ b/gdk/src/pixbufformat.ccg
@@ -18,41 +18,14 @@
  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <glibmm/utility.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
 namespace Gdk
 {
 
 PixbufFormat::PixbufFormat()
-: gobject_ (0)
-{}
-
-PixbufFormat::PixbufFormat(const GdkPixbufFormat* gobject)
-: gobject_ (gobject)
-{}
-
-PixbufFormat::~PixbufFormat()
-{
-  //We don't free anything because we did not take ownership of the underlying C instance
-  //(because we can't.)
-}
-
-PixbufFormat::PixbufFormat(const PixbufFormat& src)
-: gobject_(src.gobject_)
-{
-}
-
-PixbufFormat& PixbufFormat::operator=(const PixbufFormat& src)
+: gobject_(0) //because only a gdk-pixbuf backend can create them.
 {
-  gobject_ = src.gobject_;
-  return *this;
 }
 
-
-
-
-
-
 } // namespace Gdk
-
diff --git a/gdk/src/pixbufformat.hg b/gdk/src/pixbufformat.hg
index c460056..fd0c524 100644
--- a/gdk/src/pixbufformat.hg
+++ b/gdk/src/pixbufformat.hg
@@ -21,45 +21,42 @@ _DEFS(gdkmm,gdk)
 
 #include <gdkmmconfig.h>
 
-
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-extern "C" { typedef struct _GdkPixbufFormat GdkPixbufFormat; }
-#endif
-
 namespace Gdk
 {
 
 class PixbufFormat
 {
-  _CLASS_GENERIC(PixbufFormat, GdkPixbufFormat)
+  _CLASS_BOXEDTYPE(PixbufFormat, GdkPixbufFormat, NONE, gdk_pixbuf_format_copy, gdk_pixbuf_format_free)
+  _IGNORE(gdk_pixbuf_format_copy, gdk_pixbuf_format_free)
 
 public:
+  _CUSTOM_DEFAULT_CTOR
   PixbufFormat();
-  explicit PixbufFormat(const GdkPixbufFormat* gobject);
-  virtual ~PixbufFormat();
-
-  PixbufFormat(const PixbufFormat& src);
-  PixbufFormat& operator=(const PixbufFormat& src);
 
   _WRAP_METHOD(Glib::ustring get_name() const, gdk_pixbuf_format_get_name)
   _WRAP_METHOD(Glib::ustring get_description() const, gdk_pixbuf_format_get_description)
   _WRAP_METHOD(Glib::StringArrayHandle get_mime_types() const, gdk_pixbuf_format_get_mime_types)
   _WRAP_METHOD(Glib::StringArrayHandle get_extensions() const, gdk_pixbuf_format_get_extensions)
   _WRAP_METHOD(bool is_writable() const, gdk_pixbuf_format_is_writable)
-  
+
   _WRAP_METHOD(bool is_scalable() const, gdk_pixbuf_format_is_scalable)
   _WRAP_METHOD(bool is_disabled() const, gdk_pixbuf_format_is_disabled)
   _WRAP_METHOD(void set_disabled(bool disabled = true), gdk_pixbuf_format_set_disabled)
   _WRAP_METHOD(Glib::ustring get_license() const, gdk_pixbuf_format_get_license)
+};
 
-  /// Provides access to the underlying C GObject.
-  GdkPixbufFormat*       gobj()       { return const_cast<GdkPixbufFormat*>(gobject_); }
-  /// Provides access to the underlying C GObject.
-  const GdkPixbufFormat* gobj() const { return gobject_; }
-
-protected:
-  const GdkPixbufFormat* gobject_;
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+struct PixbufFormatTraits
+{
+  typedef PixbufFormat  CppType;
+  typedef const GdkPixbufFormat*      CType;
+  typedef GdkPixbufFormat*            CTypeNonConst;
+
+  static CType   to_c_type      (const CppType& obj) { return obj.gobj();     }
+  static CType   to_c_type      (CType          ptr) { return ptr;                   }
+  static CppType to_cpp_type    (CType          ptr) { return PixbufFormat(const_cast<GdkPixbufFormat*>(ptr), true); }
+  static void    release_c_type (CType          /* ptr */) { /* Doesn't happen */ }
 };
+#endif //DOXYGEN_SHOULD_SKIP_THIS
 
 } // namespace Gdk
-



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