summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjellahlstedt@gmail.com>2022-12-02 19:09:50 +0100
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2022-12-02 19:09:50 +0100
commita31a114cd2185bb725d75e456d04f03ac8fe7036 (patch)
treece3646c90f2d9de444ab79f94662d975c2e602c3
parentaf1d77ee1593a640184e9646ca6af54951a821de (diff)
downloadglibmm-a31a114cd2185bb725d75e456d04f03ac8fe7036.tar.gz
Add Gio::BytesIcon
* gio/giomm.h: * gio/giomm/meson.build: * gio/src/filelist.am: Add BytesIcon. * glib/src/bytes.[ccg|hg]: Add Glib::Value specialization. Required by _WRAP_PROPERTY in bytesicon.hg. * tools/extra_defs_gen/generate_defs_gio.cc: Add G_TYPE_BYTES_ICON. * gio/src/gio_signals.defs: Add BytesIcon property. * gio/src/bytesicon.[ccg|hg]: New files. Fixes #107
-rw-r--r--gio/giomm.h1
-rw-r--r--gio/giomm/meson.build1
-rw-r--r--gio/src/bytesicon.ccg17
-rw-r--r--gio/src/bytesicon.hg64
-rw-r--r--gio/src/filelist.am1
-rw-r--r--gio/src/gio_signals.defs11
-rw-r--r--glib/src/bytes.ccg15
-rw-r--r--glib/src/bytes.hg16
-rw-r--r--tools/extra_defs_gen/generate_defs_gio.cc1
9 files changed, 127 insertions, 0 deletions
diff --git a/gio/giomm.h b/gio/giomm.h
index fe33c51e..6778a914 100644
--- a/gio/giomm.h
+++ b/gio/giomm.h
@@ -33,6 +33,7 @@
#include <giomm/asyncresult.h>
#include <giomm/bufferedinputstream.h>
#include <giomm/bufferedoutputstream.h>
+#include <giomm/bytesicon.h>
#include <giomm/cancellable.h>
#include <giomm/charsetconverter.h>
#include <giomm/contenttype.h>
diff --git a/gio/giomm/meson.build b/gio/giomm/meson.build
index faaeb9b5..1fb44702 100644
--- a/gio/giomm/meson.build
+++ b/gio/giomm/meson.build
@@ -38,6 +38,7 @@ giomm_any_hg_ccg_basenames = [
'asyncresult',
'bufferedinputstream',
'bufferedoutputstream',
+ 'bytesicon',
'cancellable',
'charsetconverter',
'converter',
diff --git a/gio/src/bytesicon.ccg b/gio/src/bytesicon.ccg
new file mode 100644
index 00000000..bb44fe1e
--- /dev/null
+++ b/gio/src/bytesicon.ccg
@@ -0,0 +1,17 @@
+/* Copyright (C) 2022 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gio/gio.h>
diff --git a/gio/src/bytesicon.hg b/gio/src/bytesicon.hg
new file mode 100644
index 00000000..0c8f61e9
--- /dev/null
+++ b/gio/src/bytesicon.hg
@@ -0,0 +1,64 @@
+/* Copyright (C) 2022 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glibmm/object.h>
+#include <giomm/icon.h>
+#include <giomm/loadableicon.h>
+#include <glibmm/bytes.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gio
+{
+
+/** An icon stored in memory as a Glib::Bytes.
+ *
+ * %Gio::BytesIcon specifies an image held in memory in a common format
+ * (usually png) to be used as icon.
+ *
+ * @see Icon, LoadableIcon, Glib::Bytes
+ * @newin{2,76}
+ */
+class GIOMM_API BytesIcon : public Glib::Object, public Icon, public LoadableIcon
+{
+ _CLASS_GOBJECT(BytesIcon, GBytesIcon, G_BYTES_ICON, Glib::Object, GObject, , , GIOMM_API)
+ _IMPLEMENTS_INTERFACE(Icon)
+ _IMPLEMENTS_INTERFACE(LoadableIcon)
+
+protected:
+ _WRAP_CTOR(BytesIcon(const Glib::RefPtr<const Glib::Bytes>& bytes), g_bytes_icon_new)
+
+public:
+ /** Creates a new icon for a Glib::Bytes.
+ *
+ * This cannot fail, but loading and interpreting the bytes may fail later on
+ * (for example, if Gio::LoadableIcon::load() is called) if the image is invalid.
+ *
+ * @newin{2,76}
+ *
+ * @param bytes A Glib::Bytes.
+ * @return A Icon for the given @a bytes.
+ */
+ _WRAP_CREATE(const Glib::RefPtr<const Glib::Bytes>& bytes)
+
+ _WRAP_METHOD(Glib::RefPtr<const Glib::Bytes> get_bytes() const,
+ g_bytes_icon_get_bytes, refreturn, newin "2,76")
+
+ _WRAP_PROPERTY("bytes", Glib::RefPtr<Glib::Bytes>, newin "2,76")
+};
+
+} // namespace Gio
diff --git a/gio/src/filelist.am b/gio/src/filelist.am
index 8f0f297f..12929523 100644
--- a/gio/src/filelist.am
+++ b/gio/src/filelist.am
@@ -23,6 +23,7 @@ giomm_files_any_hg = \
asyncresult.hg \
bufferedinputstream.hg \
bufferedoutputstream.hg \
+ bytesicon.hg \
cancellable.hg \
charsetconverter.hg \
converter.hg \
diff --git a/gio/src/gio_signals.defs b/gio/src/gio_signals.defs
index 514afbec..8c020567 100644
--- a/gio/src/gio_signals.defs
+++ b/gio/src/gio_signals.defs
@@ -278,6 +278,17 @@
(default-value "FALSE")
)
+;; From GBytesIcon
+
+(define-property bytes
+ (of-object "GBytesIcon")
+ (prop-type "GParamBoxed")
+ (docs "The bytes containing the icon")
+ (readable #t)
+ (writable #t)
+ (construct-only #t)
+)
+
;; From GCharsetConverter
(define-property from-charset
diff --git a/glib/src/bytes.ccg b/glib/src/bytes.ccg
index bc43f2d9..2dafaaff 100644
--- a/glib/src/bytes.ccg
+++ b/glib/src/bytes.ccg
@@ -24,4 +24,19 @@ Bytes::create(gconstpointer data, gsize size)
return Glib::wrap(bytes);
}
+GType Value<RefPtr<Glib::Bytes> >::value_type()
+{
+ return g_bytes_get_type();
+}
+
+void Value<RefPtr<Glib::Bytes> >::set(const CppType& data)
+{
+ set_boxed(Glib::unwrap(data));
+}
+
+Value<RefPtr<Glib::Bytes>>::CppType Value<RefPtr<Glib::Bytes>>::get() const
+{
+ return Glib::wrap(static_cast<CType>(get_boxed()), true);
+}
+
} // namespace Glib
diff --git a/glib/src/bytes.hg b/glib/src/bytes.hg
index db0a23f7..e01c89c1 100644
--- a/glib/src/bytes.hg
+++ b/glib/src/bytes.hg
@@ -20,6 +20,7 @@ _DEFS(glibmm,glib)
#include <glibmm/refptr.h>
#include <glibmm/ustring.h>
#include <glibmm/error.h>
+#include <glibmm/value.h>
#include <glib.h>
#ifndef DOXYGEN_SHOULD_SKIP_THIS
@@ -66,4 +67,19 @@ public:
_WRAP_METHOD(static gint compare(gconstpointer bytes1, gconstpointer bytes2), g_bytes_compare)
};
+// This is needed so Glib::RefPtr<Glib::Bytes> can be used with
+// Glib::Value and _WRAP_PROPERTY in Gio::BytesIcon.
+template <>
+class GLIBMM_API Value<Glib::RefPtr<Glib::Bytes>> : public ValueBase_Boxed
+{
+public:
+ using CppType = Glib::RefPtr<Glib::Bytes>;
+ using CType = GBytes*;
+
+ static GType value_type();
+
+ void set(const CppType& data);
+ CppType get() const;
+};
+
} // namespace Glib
diff --git a/tools/extra_defs_gen/generate_defs_gio.cc b/tools/extra_defs_gen/generate_defs_gio.cc
index 36ad4fca..f04ec8a9 100644
--- a/tools/extra_defs_gen/generate_defs_gio.cc
+++ b/tools/extra_defs_gen/generate_defs_gio.cc
@@ -48,6 +48,7 @@ main(int, char**)
<< get_defs(G_TYPE_ACTION_GROUP) << get_defs(G_TYPE_APPLICATION)
<< get_defs(G_TYPE_APP_INFO_MONITOR) << get_defs(G_TYPE_CANCELLABLE)
<< get_defs(G_TYPE_BUFFERED_INPUT_STREAM) << get_defs(G_TYPE_BUFFERED_OUTPUT_STREAM)
+ << get_defs(G_TYPE_BYTES_ICON)
<< get_defs(G_TYPE_CHARSET_CONVERTER) << get_defs(G_TYPE_CONVERTER_INPUT_STREAM)
<< get_defs(G_TYPE_CONVERTER_OUTPUT_STREAM) << get_defs(G_TYPE_DATA_INPUT_STREAM)
<< get_defs(G_TYPE_DATA_OUTPUT_STREAM) << get_defs(G_TYPE_DRIVE)