diff options
author | Marcin Kolny <marcin.kolny@gmail.com> | 2016-03-21 20:23:11 +0100 |
---|---|---|
committer | Marcin Kolny <marcin.kolny@gmail.com> | 2016-04-01 20:22:34 +0200 |
commit | e17b42eae4d336e0da0ca5bee2613711116cea5f (patch) | |
tree | 300f5b5d721896b28b6e6d55245961e2918494ee /glib | |
parent | 48f03ef26ff57a96b305c06cfa0b19fd873cb971 (diff) | |
download | glibmm-e17b42eae4d336e0da0ca5bee2613711116cea5f.tar.gz |
Glib::Property: allow to set property nick, blurb and flags.
* .gitignore: add paramflags generated files to ignore list.
* glib/glibmm.h: add paramflags header to include list.
* glib/glibmm/property.{cc|}h: add constructors allowing set nick,
blurb. Add getters for this values.
and flags of property.
* glib/glibmm/value.{cc|h}:
* glib/src/filelist.am: add paramflags to a build.
* glib/src/enums.{ccg|hg}: add GParamFlags enum wrapper.
* glib/glibmm/value_basictypes.{cc|h}.m4: add
overloaded create_param_spec() for setting additional property
parameters.
This patch fixes bug #755256
Diffstat (limited to 'glib')
-rw-r--r-- | glib/glibmm.h | 1 | ||||
-rw-r--r-- | glib/glibmm/property.cc | 14 | ||||
-rw-r--r-- | glib/glibmm/property.h | 284 | ||||
-rw-r--r-- | glib/glibmm/value.cc | 63 | ||||
-rw-r--r-- | glib/glibmm/value.h | 15 | ||||
-rw-r--r-- | glib/src/enums.ccg | 16 | ||||
-rw-r--r-- | glib/src/enums.hg | 26 | ||||
-rw-r--r-- | glib/src/filelist.am | 1 | ||||
-rw-r--r-- | glib/src/value_basictypes.cc.m4 | 12 | ||||
-rw-r--r-- | glib/src/value_basictypes.h.m4 | 2 |
10 files changed, 413 insertions, 21 deletions
diff --git a/glib/glibmm.h b/glib/glibmm.h index 00334162..80b27b50 100644 --- a/glib/glibmm.h +++ b/glib/glibmm.h @@ -106,6 +106,7 @@ #include <glibmm/date.h> #include <glibmm/datetime.h> #include <glibmm/dispatcher.h> +#include <glibmm/enums.h> #include <glibmm/error.h> #include <glibmm/exception.h> #include <glibmm/exceptionhandler.h> diff --git a/glib/glibmm/property.cc b/glib/glibmm/property.cc index 70859000..45d90b3f 100644 --- a/glib/glibmm/property.cc +++ b/glib/glibmm/property.cc @@ -297,6 +297,20 @@ PropertyBase::get_name() const return Glib::ustring(get_name_internal()); } +Glib::ustring +PropertyBase::get_nick() const +{ + return Glib::convert_const_gchar_ptr_to_ustring( + g_param_spec_get_nick(param_spec_)); +} + +Glib::ustring +PropertyBase::get_blurb() const +{ + return Glib::convert_const_gchar_ptr_to_ustring( + g_param_spec_get_blurb(param_spec_)); +} + void PropertyBase::notify() { diff --git a/glib/glibmm/property.h b/glib/glibmm/property.h index 10769896..454be13d 100644 --- a/glib/glibmm/property.h +++ b/glib/glibmm/property.h @@ -61,6 +61,14 @@ public: */ Glib::ustring get_name() const; + /** Returns the nickname of the property. + */ + Glib::ustring get_nick() const; + + /** Returns the short description of the property. + */ + Glib::ustring get_blurb() const; + /** Notifies the object containing the property that the property has changed. * This emits the "notify" signal, passing the property name. */ @@ -122,10 +130,11 @@ private: * * The default value and the minimum and maximum bounds (depending on the type of the property). * * Flags, defining, among other things, whether the property can be read or written. * - * This Property class currently supports only the name and default value. The - * minimum and maximum bounds are set to the full range of the value. The nick - * and the explanation are set to empty. The flags are set to indicate that the - * property can be both read from and written to. + * This Property class currently supports the name, nick name, description default value and flags. + * The minimum and maximum bounds are set to the full range of the value. + * Because of internal implementation, flags shouldn't be set to values: Glib::PARAM_STATIC_NAME, + * Glib::PARAM_STATIC_NICK, Glib::PARAM_STATIC_BLURB, Glib::PARAM_CONSTRUCT and + * Glib::PARAM_CONSTRUCT_ONLY. * * The class information must be installed into the GObject system once per * property, but this is handled automatically. @@ -184,6 +193,20 @@ public: */ Property(Glib::Object& object, const Glib::ustring& name, const PropertyType& default_value); + /** Constructs a property of the @a object with the specified @a name, @a nick, @a blurb and + * @a flags. + * For each instance of the object, the same property must be constructed with the same name. + */ + Property(Glib::Object& object, const Glib::ustring& name, const Glib::ustring& nick, + const Glib::ustring& blurb, Glib::ParamFlags flags); + + /** Constructs a property of the @a object with the specified @a name, @a default_value, @a nick, + * @a blurb and @a flags. + * For each instance of the object, the same property must be constructed with the same name. + */ + Property(Glib::Object& object, const Glib::ustring& name, const PropertyType& default_value, + const Glib::ustring& nick, const Glib::ustring& blurb, Glib::ParamFlags flags); + /** Sets the value of the property to @a data. * The object containing the property will be notified about the change. */ @@ -207,27 +230,143 @@ public: inline Glib::PropertyProxy<T> get_proxy(); }; +/** See Property. + * This property can be read, but not written, so there is no set_value() method. + */ +template <class T> +class Property_ReadOnly : public PropertyBase +{ +public: + typedef T PropertyType; + typedef Glib::Value<T> ValueType; + + /** Constructs a property of the @a object with the specified @a name. + * For each instance of the object, the same property must be constructed with the same name. + */ + Property_ReadOnly(Glib::Object& object, const Glib::ustring& name); + + /** Constructs a property of the @a object with the specified @a name and @a default_value. + * For each instance of the object, the same property must be constructed with the same name. + */ + Property_ReadOnly(Glib::Object& object, const Glib::ustring& name, const PropertyType& default_value); + + /** Constructs a property of the @a object with the specified @a name, @a nick, @a blurb and + * @a flags. + * For each instance of the object, the same property must be constructed with the same name. + */ + Property_ReadOnly(Glib::Object& object, const Glib::ustring& name, const Glib::ustring& nick, + const Glib::ustring& blurb, Glib::ParamFlags flags); + + /** Constructs a property of the @a object with the specified @a name, @a default_value, @a nick, + * @a blurb and @a flags. + * For each instance of the object, the same property must be constructed with the same name. + */ + Property_ReadOnly(Glib::Object& object, const Glib::ustring& name, const PropertyType& default_value, + const Glib::ustring& nick, const Glib::ustring& blurb, Glib::ParamFlags flags); + + /** Returns the value of the property. + */ + inline PropertyType get_value() const; + + /** Returns the value of the property. + */ + inline operator PropertyType() const; + + /** Returns a proxy object that can be used to manipulate this property. + */ + inline Glib::PropertyProxy_ReadOnly<T> get_proxy(); +}; + +/** See Property. + * This property can be written, but not read, so there is no get_value() method. + */ +template <class T> +class Property_WriteOnly : public PropertyBase +{ +public: + typedef T PropertyType; + typedef Glib::Value<T> ValueType; + + /** Constructs a property of the @a object with the specified @a name. + * For each instance of the object, the same property must be constructed with the same name. + */ + Property_WriteOnly(Glib::Object& object, const Glib::ustring& name); + + /** Constructs a property of the @a object with the specified @a name and @a default_value. + * For each instance of the object, the same property must be constructed with the same name. + */ + Property_WriteOnly(Glib::Object& object, const Glib::ustring& name, const PropertyType& default_value); + + /** Constructs a property of the @a object with the specified @a name, @a nick, @a blurb and + * @a flags. + * For each instance of the object, the same property must be constructed with the same name. + */ + Property_WriteOnly(Glib::Object& object, const Glib::ustring& name, const Glib::ustring& nick, + const Glib::ustring& blurb, Glib::ParamFlags flags); + + /** Constructs a property of the @a object with the specified @a name, @a default_value, @a nick, + * @a blurb and @a flags. + * For each instance of the object, the same property must be constructed with the same name. + */ + Property_WriteOnly(Glib::Object& object, const Glib::ustring& name, const PropertyType& default_value, + const Glib::ustring& nick, const Glib::ustring& blurb, Glib::ParamFlags flags); + + /** Sets the value of the property to @a data. + * The object containing the property will be notified about the change. + */ + inline void set_value(const PropertyType& data); + + /** Sets the value of the property to @a data. + * The object containing the property will be notified about the change. + */ + inline Property_WriteOnly<T>& operator=(const PropertyType& data); + + /** Returns a proxy object that can be used to manipulate this property. + */ + inline Glib::PropertyProxy_WriteOnly<T> get_proxy(); +}; + #ifndef DOXYGEN_SHOULD_SKIP_THIS /**** Glib::Property<T> ****************************************************/ template <class T> Property<T>::Property(Glib::Object& object, const Glib::ustring& name) -: PropertyBase(object, ValueType::value_type()) +: Property(object, name, Glib::ustring(), Glib::ustring(), Glib::PARAM_READWRITE) { - if (!lookup_property(name)) - install_property(static_cast<ValueType&>(value_).create_param_spec(name)); } template <class T> Property<T>::Property(Glib::Object& object, const Glib::ustring& name, const typename Property<T>::PropertyType& default_value) +: Property(object, name, default_value, Glib::ustring(), + Glib::ustring(), Glib::PARAM_READWRITE) +{ +} + +template <class T> +Property<T>::Property(Glib::Object& object, const Glib::ustring& name, + const Glib::ustring& nick, const Glib::ustring& blurb, Glib::ParamFlags flags) : PropertyBase(object, ValueType::value_type()) { + flags |= Glib::PARAM_READWRITE; + + if (!lookup_property(name)) + install_property(static_cast<ValueType&>(value_).create_param_spec(name, nick, blurb, flags)); +} + +template <class T> +Property<T>::Property(Glib::Object& object, const Glib::ustring& name, const PropertyType& default_value, + const Glib::ustring& nick, const Glib::ustring& blurb, Glib::ParamFlags flags) +: + PropertyBase(object, ValueType::value_type()) +{ + flags |= Glib::PARAM_READWRITE; + static_cast<ValueType&>(value_).set(default_value); if (!lookup_property(name)) - install_property(static_cast<ValueType&>(value_).create_param_spec(name)); + install_property(static_cast<ValueType&>(value_).create_param_spec(name, nick, blurb, flags)); } template <class T> @@ -267,8 +406,137 @@ Property<T>::get_proxy() return Glib::PropertyProxy<T>(object_, get_name_internal()); } +/**** Glib::Property_ReadOnly<T> ****************************************************/ + +template <class T> +Property_ReadOnly<T>::Property_ReadOnly(Glib::Object& object, const Glib::ustring& name) +: Property_ReadOnly(object, name, Glib::ustring(), Glib::ustring(), Glib::PARAM_READABLE) +{ +} + +template <class T> +Property_ReadOnly<T>::Property_ReadOnly(Glib::Object& object, const Glib::ustring& name, + const typename Property_ReadOnly<T>::PropertyType& default_value) +: Property_ReadOnly(object, name, default_value, Glib::ustring(), Glib::ustring(), + Glib::PARAM_READABLE) +{ +} + +template <class T> +Property_ReadOnly<T>::Property_ReadOnly(Glib::Object& object, const Glib::ustring& name, + const Glib::ustring& nick, const Glib::ustring& blurb, Glib::ParamFlags flags) +: PropertyBase(object, ValueType::value_type()) +{ + flags |= Glib::PARAM_READABLE; + flags &= ~Glib::PARAM_WRITABLE; + + if (!lookup_property(name)) + install_property(static_cast<ValueType&>(value_).create_param_spec(name, nick, blurb, flags)); +} + +template <class T> +Property_ReadOnly<T>::Property_ReadOnly(Glib::Object& object, const Glib::ustring& name, const PropertyType& default_value, + const Glib::ustring& nick, const Glib::ustring& blurb, Glib::ParamFlags flags) +: PropertyBase(object, ValueType::value_type()) +{ + flags |= Glib::PARAM_READABLE; + flags &= ~Glib::PARAM_WRITABLE; + + static_cast<ValueType&>(value_).set(default_value); + + if (!lookup_property(name)) + install_property(static_cast<ValueType&>(value_).create_param_spec(name, nick, blurb, flags)); +} + +template <class T> +inline typename Property_ReadOnly<T>::PropertyType +Property_ReadOnly<T>::get_value() const +{ + return static_cast<const ValueType&>(value_).get(); +} + +template <class T> +inline Property_ReadOnly<T>::operator T() const +{ + return static_cast<const ValueType&>(value_).get(); +} + +template <class T> +inline Glib::PropertyProxy_ReadOnly<T> +Property_ReadOnly<T>::get_proxy() +{ + return Glib::PropertyProxy_ReadOnly<T>(object_, get_name_internal()); +} #endif /* DOXYGEN_SHOULD_SKIP_THIS */ +/**** Glib::Property_WriteOnly<T> ****************************************************/ + +template <class T> +Property_WriteOnly<T>::Property_WriteOnly(Glib::Object& object, const Glib::ustring& name) +: Property_WriteOnly(object, name, Glib::ustring(), + Glib::ustring(), Glib::PARAM_WRITABLE) +{ +} + +template <class T> +Property_WriteOnly<T>::Property_WriteOnly(Glib::Object& object, const Glib::ustring& name, + const typename Property_WriteOnly<T>::PropertyType& default_value) +: Property_WriteOnly(object, name, default_value, Glib::ustring(), + Glib::ustring(), Glib::PARAM_WRITABLE) +{ +} + +template <class T> +Property_WriteOnly<T>::Property_WriteOnly(Glib::Object& object, const Glib::ustring& name, + const Glib::ustring& nick, const Glib::ustring& blurb, Glib::ParamFlags flags) +: PropertyBase(object, ValueType::value_type()) +{ + flags |= Glib::PARAM_WRITABLE; + flags &= ~Glib::PARAM_READABLE; + + if (!lookup_property(name)) + install_property(static_cast<ValueType&>(value_).create_param_spec(name, nick, blurb, flags)); + +} + +template <class T> +Property_WriteOnly<T>::Property_WriteOnly(Glib::Object& object, const Glib::ustring& name, const PropertyType& default_value, + const Glib::ustring& nick, const Glib::ustring& blurb, Glib::ParamFlags flags) +: PropertyBase(object, ValueType::value_type()) +{ + flags |= Glib::PARAM_WRITABLE; + flags &= ~Glib::PARAM_READABLE; + + static_cast<ValueType&>(value_).set(default_value); + + if (!lookup_property(name)) + install_property(static_cast<ValueType&>(value_).create_param_spec(name, nick, blurb, flags)); +} + +template <class T> +inline void +Property_WriteOnly<T>::set_value(const typename Property_WriteOnly<T>::PropertyType& data) +{ + static_cast<ValueType&>(value_).set(data); + this->notify(); +} + +template <class T> +inline Property_WriteOnly<T>& +Property_WriteOnly<T>::operator=(const typename Property_WriteOnly<T>::PropertyType& data) +{ + static_cast<ValueType&>(value_).set(data); + this->notify(); + return *this; +} + +template <class T> +inline Glib::PropertyProxy_WriteOnly<T> +Property_WriteOnly<T>::get_proxy() +{ + return Glib::PropertyProxy_WriteOnly<T>(object_, get_name_internal()); +} + } // namespace Glib #endif /* _GLIBMM_PROPERTY_H */ diff --git a/glib/glibmm/value.cc b/glib/glibmm/value.cc index 62d59473..ef68fcef 100644 --- a/glib/glibmm/value.cc +++ b/glib/glibmm/value.cc @@ -100,8 +100,16 @@ ValueBase_Boxed::get_boxed() const GParamSpec* ValueBase_Boxed::create_param_spec(const Glib::ustring& name) const { - return g_param_spec_boxed(name.c_str(), nullptr, nullptr, G_VALUE_TYPE(&gobject_), - GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE)); + return create_param_spec(name, Glib::ustring(), Glib::ustring(), + static_cast<Glib::ParamFlags>(G_PARAM_READABLE | G_PARAM_WRITABLE)); +} + +GParamSpec* ValueBase_Boxed::create_param_spec(const Glib::ustring& name, + const Glib::ustring& nick, const Glib::ustring& blurb, Glib::ParamFlags flags) const +{ + return g_param_spec_boxed( + name.c_str(), c_str_or_nullptr(nick), c_str_or_nullptr(blurb), + G_VALUE_TYPE(&gobject_), static_cast<GParamFlags>(flags)); } /**** Glib::ValueBase_Object ***********************************************/ @@ -136,6 +144,14 @@ ValueBase_Object::get_object_copy() const GParamSpec* ValueBase_Object::create_param_spec(const Glib::ustring& name) const { + return create_param_spec(name, Glib::ustring(), Glib::ustring(), + static_cast<Glib::ParamFlags>(G_PARAM_READABLE | G_PARAM_WRITABLE)); +} + +GParamSpec* +ValueBase_Object::create_param_spec(const Glib::ustring& name, + const Glib::ustring& nick, const Glib::ustring& blurb, Glib::ParamFlags flags) const +{ // Glib::Value_Pointer<> derives from Glib::ValueBase_Object, because // we don't know beforehand whether a certain type is derived from // Glib::Object or not. To keep create_param_spec() out of the template @@ -143,15 +159,16 @@ ValueBase_Object::create_param_spec(const Glib::ustring& name) const if (G_VALUE_HOLDS_OBJECT(&gobject_)) { - return g_param_spec_object(name.c_str(), nullptr, nullptr, G_VALUE_TYPE(&gobject_), - GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE)); + return g_param_spec_object(name.c_str(), c_str_or_nullptr(nick), c_str_or_nullptr(blurb), + G_VALUE_TYPE(&gobject_), static_cast<GParamFlags>(flags)); } else { g_return_val_if_fail(G_VALUE_HOLDS_POINTER(&gobject_), nullptr); return g_param_spec_pointer( - name.c_str(), nullptr, nullptr, GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE)); + name.c_str(), c_str_or_nullptr(nick), c_str_or_nullptr(blurb), + static_cast<GParamFlags>(flags)); } } @@ -179,8 +196,17 @@ ValueBase_Enum::get_enum() const GParamSpec* ValueBase_Enum::create_param_spec(const Glib::ustring& name) const { - return g_param_spec_enum(name.c_str(), nullptr, nullptr, G_VALUE_TYPE(&gobject_), - g_value_get_enum(&gobject_), GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE)); + return create_param_spec(name, Glib::ustring(), Glib::ustring(), + static_cast<Glib::ParamFlags>(G_PARAM_READABLE | G_PARAM_WRITABLE)); +} + +GParamSpec* +ValueBase_Enum::create_param_spec(const Glib::ustring& name, + const Glib::ustring& nick, const Glib::ustring& blurb, Glib::ParamFlags flags) const +{ + return g_param_spec_enum( + name.c_str(), c_str_or_nullptr(nick), c_str_or_nullptr(blurb), G_VALUE_TYPE(&gobject_), + g_value_get_enum(&gobject_), static_cast<GParamFlags>(flags)); } /**** Glib::ValueBase_Flags ************************************************/ @@ -207,8 +233,15 @@ ValueBase_Flags::get_flags() const GParamSpec* ValueBase_Flags::create_param_spec(const Glib::ustring& name) const { - return g_param_spec_flags(name.c_str(), nullptr, nullptr, G_VALUE_TYPE(&gobject_), - g_value_get_flags(&gobject_), GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE)); + return create_param_spec(name, Glib::ustring(), Glib::ustring(), + static_cast<Glib::ParamFlags>(G_PARAM_READABLE | G_PARAM_WRITABLE)); +} + +GParamSpec* ValueBase_Flags::create_param_spec(const Glib::ustring& name, + const Glib::ustring& nick, const Glib::ustring& blurb, Glib::ParamFlags flags) const +{ + return g_param_spec_flags(name.c_str(), c_str_or_nullptr(nick), c_str_or_nullptr(blurb), + G_VALUE_TYPE(&gobject_), g_value_get_flags(&gobject_), static_cast<GParamFlags>(flags)); } /**** Glib::ValueBase_String ***********************************************/ @@ -238,8 +271,16 @@ ValueBase_String::get_cstring() const GParamSpec* ValueBase_String::create_param_spec(const Glib::ustring& name) const { - return g_param_spec_string(name.c_str(), nullptr, nullptr, get_cstring(), - GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE)); + return create_param_spec(name, Glib::ustring(), Glib::ustring(), + static_cast<Glib::ParamFlags>(G_PARAM_READABLE | G_PARAM_WRITABLE)); +} + +GParamSpec* +ValueBase_String::create_param_spec(const Glib::ustring& name, + const Glib::ustring& nick, const Glib::ustring& blurb, Glib::ParamFlags flags) const +{ + return g_param_spec_string(name.c_str(), c_str_or_nullptr(nick), c_str_or_nullptr(blurb), + get_cstring(), static_cast<GParamFlags>(flags)); } /**** Glib::Value<std::string> *********************************************/ diff --git a/glib/glibmm/value.h b/glib/glibmm/value.h index c7f61af0..80c885a0 100644 --- a/glib/glibmm/value.h +++ b/glib/glibmm/value.h @@ -21,6 +21,7 @@ #include <glibmmconfig.h> #include <glibmm/refptr.h> #include <glibmm/ustring.h> +#include <glibmm/enums.h> #include <glib-object.h> namespace Glib @@ -103,6 +104,8 @@ public: #ifndef DOXYGEN_SHOULD_SKIP_THIS GParamSpec* create_param_spec(const Glib::ustring& name) const; + GParamSpec* create_param_spec(const Glib::ustring& name, const Glib::ustring& nick, + const Glib::ustring& blurb, Glib::ParamFlags flags) const; #endif protected: @@ -120,6 +123,9 @@ public: #ifndef DOXYGEN_SHOULD_SKIP_THIS GParamSpec* create_param_spec(const Glib::ustring& name) const; + GParamSpec* create_param_spec(const Glib::ustring& name, const Glib::ustring& nick, + const Glib::ustring& blurb, Glib::ParamFlags flags) const; + #endif protected: @@ -139,6 +145,9 @@ public: #ifndef DOXYGEN_SHOULD_SKIP_THIS GParamSpec* create_param_spec(const Glib::ustring& name) const; + GParamSpec* create_param_spec(const Glib::ustring& name, const Glib::ustring& nick, + const Glib::ustring& blurb, Glib::ParamFlags flags) const; + #endif protected: @@ -157,6 +166,9 @@ public: #ifndef DOXYGEN_SHOULD_SKIP_THIS GParamSpec* create_param_spec(const Glib::ustring& name) const; + GParamSpec* create_param_spec(const Glib::ustring& name, const Glib::ustring& nick, + const Glib::ustring& blurb, Glib::ParamFlags flags) const; + #endif protected: @@ -175,6 +187,9 @@ public: #ifndef DOXYGEN_SHOULD_SKIP_THIS GParamSpec* create_param_spec(const Glib::ustring& name) const; + GParamSpec* create_param_spec(const Glib::ustring& name, const Glib::ustring& nick, + const Glib::ustring& blurb, Glib::ParamFlags flags) const; + #endif protected: diff --git a/glib/src/enums.ccg b/glib/src/enums.ccg new file mode 100644 index 00000000..f3c6be66 --- /dev/null +++ b/glib/src/enums.ccg @@ -0,0 +1,16 @@ +/* Copyright (C) 2016 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, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ diff --git a/glib/src/enums.hg b/glib/src/enums.hg new file mode 100644 index 00000000..290ee4b8 --- /dev/null +++ b/glib/src/enums.hg @@ -0,0 +1,26 @@ +/* Copyright (C) 2016 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, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +_DEFS(glibmm,glib) + +#include <glib.h> + +namespace Glib +{ +_WRAP_ENUM(ParamFlags, GParamFlags, NO_GTYPE) +} //namespace Glib + diff --git a/glib/src/filelist.am b/glib/src/filelist.am index f76c8bd2..6b52c61a 100644 --- a/glib/src/filelist.am +++ b/glib/src/filelist.am @@ -22,6 +22,7 @@ glibmm_files_any_hg = \ convert.hg \ date.hg \ datetime.hg \ + enums.hg \ fileutils.hg \ iochannel.hg \ keyfile.hg \ diff --git a/glib/src/value_basictypes.cc.m4 b/glib/src/value_basictypes.cc.m4 index fd5f775e..ec37c61e 100644 --- a/glib/src/value_basictypes.cc.m4 +++ b/glib/src/value_basictypes.cc.m4 @@ -47,10 +47,18 @@ $1 Value<$1>::get() const GParamSpec* Value<$1>::create_param_spec(const Glib::ustring& name) const { + return create_param_spec(name, Glib::ustring(), Glib::ustring(), + Glib::PARAM_READWRITE); +} + +GParamSpec* Value<$1>::create_param_spec(const Glib::ustring& name, const Glib::ustring& nick, + const Glib::ustring& blurb, Glib::ParamFlags flags) const +{ return g_param_spec_[]ifelse($2,schar,char,$2)( - name.c_str(), nullptr, nullptr,ifelse($2,pointer,,[ + name.c_str(), nick.empty() ? nullptr : nick.c_str(), + blurb.empty() ? nullptr : blurb.c_str(), ifelse($2,pointer,,[ ifelse($3,,,[$3, $4, ])[]g_value_get_$2(&gobject_),]) - GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE)); + static_cast<GParamFlags>(flags)); } ]) diff --git a/glib/src/value_basictypes.h.m4 b/glib/src/value_basictypes.h.m4 index 06320cfa..91a3a4bf 100644 --- a/glib/src/value_basictypes.h.m4 +++ b/glib/src/value_basictypes.h.m4 @@ -43,6 +43,8 @@ public: #ifndef DOXYGEN_SHOULD_SKIP_THIS GParamSpec* create_param_spec(const Glib::ustring& name) const; + GParamSpec* create_param_spec(const Glib::ustring& name, const Glib::ustring& nick, + const Glib::ustring& blurb, Glib::ParamFlags flags) const; #endif }; ]) |