[gtkmm] Gtk::TextBuffer: Wrap the copy-target-list and paste-target-list props



commit a1c6de68ff1a776ef1ff60f8d5c5d3f98902893d
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Fri Jan 9 19:12:27 2015 +0100

    Gtk::TextBuffer: Wrap the copy-target-list and paste-target-list props
    
    * gtk/src/targetlist.[ccg|hg]: Add a Glib::Value<Glib::RefPtr<Gtk::TargetList>>
    template specialization. This is needed because properties are stored
    in GValue objects, and GtkTargetList is refcounted boxed type.
    * gtk/src/textbuffer.hg: Wrap the copy-target-list and paste-target-list
    properties.

 gtk/src/targetlist.ccg |   19 +++++++++++++++++++
 gtk/src/targetlist.hg  |   20 +++++++++++++++++++-
 gtk/src/textbuffer.hg  |    4 ++--
 3 files changed, 40 insertions(+), 3 deletions(-)
---
diff --git a/gtk/src/targetlist.ccg b/gtk/src/targetlist.ccg
index 974c2f8..e31148e 100644
--- a/gtk/src/targetlist.ccg
+++ b/gtk/src/targetlist.ccg
@@ -33,3 +33,22 @@ void TargetList::add(const std::vector<TargetEntry>& targets)
 
 } // namespace Gtk
 
+namespace Glib
+{
+
+GType Value<RefPtr<Gtk::TargetList> >::value_type()
+{
+  return gtk_target_list_get_type();
+}
+
+void Value<RefPtr<Gtk::TargetList> >::set(const CppType& data)
+{
+  set_boxed(Glib::unwrap(data));
+}
+
+Value<RefPtr<Gtk::TargetList> >::CppType Value<RefPtr<Gtk::TargetList> >::get() const
+{
+  return Glib::wrap(static_cast<CType>(get_boxed()), true);
+}
+
+} // namespace Glib
diff --git a/gtk/src/targetlist.hg b/gtk/src/targetlist.hg
index 4e6b711..480af83 100644
--- a/gtk/src/targetlist.hg
+++ b/gtk/src/targetlist.hg
@@ -50,7 +50,7 @@ public:
   _WRAP_METHOD(void add_image_targets(guint info, bool writable), gtk_target_list_add_image_targets)
   _WRAP_METHOD(void add_uri_targets(guint info), gtk_target_list_add_uri_targets)
 
-/** TODO:
+/* TODO:
 void           gtk_target_list_add_table (GtkTargetList        *list,
                                           const GtkTargetEntry *targets,
                                           guint                 ntargets);
@@ -62,3 +62,21 @@ void           gtk_target_list_add_table (GtkTargetList        *list,
 
 } // namespace Gtk
 
+namespace Glib
+{
+// This is needed so Glib::RefPtr<Gtk::TargetList> can be used with
+// Glib::Value and _WRAP_PROPERTY in TextBuffer.
+template <>
+class Value< Glib::RefPtr<Gtk::TargetList> > : public ValueBase_Boxed
+{
+public:
+  typedef Glib::RefPtr<Gtk::TargetList> CppType;
+  typedef GtkTargetList* CType;
+
+  static GType value_type();
+
+  void set(const CppType& data);
+  CppType get() const;
+};
+
+} // namespace Glib
diff --git a/gtk/src/textbuffer.hg b/gtk/src/textbuffer.hg
index e67ed71..3060e6a 100644
--- a/gtk/src/textbuffer.hg
+++ b/gtk/src/textbuffer.hg
@@ -576,8 +576,8 @@ _CONVERSION(`const char*',`const Glib::ustring&',`Glib::ustring(p1, p1 + p2)')
   _WRAP_PROPERTY("text", Glib::ustring)
   _WRAP_PROPERTY("has-selection", bool)
   _WRAP_PROPERTY("cursor-position", int)
-  //TODO: Check the ref-counting/conversion for these: _WRAP_PROPERTY("copy-target-list", Glib::ListHandle< 
Glib::RefPtr<TargetList> >)
-  //TODO: _WRAP_PROPERTY("paste-target-list", Glib::ListHandle< Glib::RefPtr<TargetList> >)
+  _WRAP_PROPERTY("copy-target-list", Glib::RefPtr<TargetList>)
+  _WRAP_PROPERTY("paste-target-list", Glib::RefPtr<TargetList>)
 };
 
 } // namespace Gtk


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