[gtkmm/gtkmm-3-22] Add a specialization for Glib::Value<Cairo::RefPtr<Cairo::Surface>>
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm/gtkmm-3-22] Add a specialization for Glib::Value<Cairo::RefPtr<Cairo::Surface>>
- Date: Fri, 13 Oct 2017 14:53:53 +0000 (UTC)
commit a26c327b3d57be5650c4dc9d9e5be46db1b8af51
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Fri Oct 13 16:50:57 2017 +0200
Add a specialization for Glib::Value<Cairo::RefPtr<Cairo::Surface>>
* gtk/src/cellrendererpixbuf.hg: Add a specialization for
Glib::Value<Cairo::RefPtr<Cairo::Surface>>. A specialization for
Glib::Value<Cairo::RefPtr<T>> can't be put in glibmm, because glibmm does
not depend on cairomm. It can't be put in cairomm, because cairomm does
not depend on glibmm. It's needed for property_surface(). Bug 788513
gtk/src/cellrendererpixbuf.hg | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/gtk/src/cellrendererpixbuf.hg b/gtk/src/cellrendererpixbuf.hg
index e2cf5e4..e0b414b 100644
--- a/gtk/src/cellrendererpixbuf.hg
+++ b/gtk/src/cellrendererpixbuf.hg
@@ -17,10 +17,44 @@
*/
#include <gtkmm/cellrenderer.h>
+#include <glibmm/value.h>
#include <giomm/icon.h>
_DEFS(gtkmm,gtk)
_PINCLUDE(gtkmm/private/cellrenderer_p.h)
+extern "C"
+{
+GType cairo_gobject_surface_get_type();
+}
+
+namespace Glib
+{
+//TODO: If we decide to allow adding ABI to gtkmm-3, make this specialization
+// more like the one in gtkmm-4, gdk/gdkmm/value_cairo.h.
+/** Specialization of Glib::Value<> for Cairo::RefPtr<Cairo::Surface>.
+ * Needed for Gtk::CellRendererPixbuf::property_surface().
+ */
+template <>
+class Value<::Cairo::RefPtr<::Cairo::Surface>> : public ValueBase_Boxed
+{
+public:
+ using T = ::Cairo::Surface;
+ using CppType = ::Cairo::RefPtr<T>;
+ using CType = T::cobject;
+
+ static GType value_type() { return cairo_gobject_surface_get_type(); }
+
+ void set(const CppType& data) { set_boxed(data->cobj()); }
+
+ CppType get() const
+ {
+ CType* CObj = static_cast<CType*>(get_boxed());
+ T* CppObj = new T(CObj, false); // false == take reference
+ return CppType(CppObj);
+ }
+};
+
+} // namespace Glib
namespace Gtk
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]