diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2021-10-05 10:57:19 +0200 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2021-10-05 10:57:19 +0200 |
commit | a4dba878ffa79c044b16eeb9172fcdc8818925f4 (patch) | |
tree | 7bdbeb3cd175a04836984fb0675b4c85acec3c3e /glib | |
parent | f042c043a776e72ab95f4efa626ce942b5fc1c19 (diff) | |
download | glibmm-a4dba878ffa79c044b16eeb9172fcdc8818925f4.tar.gz |
Glib, Gio: Add some methods for glibmm 2.70
* configure.ac:
* meson.build: Require glib-2.0 >= 2.69.1.
* glib/src/binding.[ccg|hg]: Add dup_source(), dup_target(),
Deprecate get_source(), get_target().
* glib/src/spawn.[ccg|hg]: Change parameter name, exit_status to wait_status.
* glib/src/timezone.[ccg|hg]: Add operator bool(), create_identifier().
Deprecate create().
* gio/src/fileinfo.hg: Add get/set_access_date(), get/set_creation_date().
* gio/src/notification.hg: Add set_category().
* gio/src/tlscertificate.hg: Add property/get_not_valid_before(),
property/get_not_valid_after(), property/get_subject_name(),
property/get_issuer_name().
* gio/src/tlsconnection.hg: Add enum Gio::TlsProtocolVersion,
property/get_protocol_version(), property/get_ciphersuite_name().
* tools/m4/convert_gio.m4: Add conversion for enum TlsProtocolVersion.
Diffstat (limited to 'glib')
-rw-r--r-- | glib/src/binding.ccg | 32 | ||||
-rw-r--r-- | glib/src/binding.hg | 81 | ||||
-rw-r--r-- | glib/src/spawn.ccg | 12 | ||||
-rw-r--r-- | glib/src/spawn.hg | 24 | ||||
-rw-r--r-- | glib/src/timezone.ccg | 10 | ||||
-rw-r--r-- | glib/src/timezone.hg | 19 |
6 files changed, 58 insertions, 120 deletions
diff --git a/glib/src/binding.ccg b/glib/src/binding.ccg index a1b40e91..ff753380 100644 --- a/glib/src/binding.ccg +++ b/glib/src/binding.ccg @@ -117,38 +117,16 @@ Binding::bind_property_value(const PropertyProxy_Base& source_property, return Glib::make_refptr_for_instance<Binding>(new Binding(binding)); } -// We hand-code get_source() and get_target(). -// g_binding_get_source() and g_binding_get_target() are deprecated in glib 2.68. -// We can't use the replacements g_binding_dup_source() and g_binding_dup_target(), -// which are new in glib 2.68. This version of glibmm does not require glib 2.68. -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -Glib::ObjectBase* Binding::get_source() -{ - return Glib::wrap_auto(g_binding_get_source(gobj())); -} - -const Glib::ObjectBase* Binding::get_source() const -{ - return const_cast<Binding*>(this)->get_source(); -} - -Glib::ObjectBase* Binding::get_target() -{ - return Glib::wrap_auto(g_binding_get_target(gobj())); -} - -const Glib::ObjectBase* Binding::get_target() const -{ - return const_cast<Binding*>(this)->get_target(); -} - void Binding::unbind() { // Call g_binding_unbind() only once. It always calls g_object_unref(). - if (g_binding_get_source(gobj())) + GObject* source = g_binding_dup_source(gobj()); + if (source) + { g_binding_unbind(gobj()); + g_object_unref(source); + } } -G_GNUC_END_IGNORE_DEPRECATIONS } // namespace Glib diff --git a/glib/src/binding.hg b/glib/src/binding.hg index dbd64480..54af2d0c 100644 --- a/glib/src/binding.hg +++ b/glib/src/binding.hg @@ -93,8 +93,9 @@ namespace Glib * The binding between the two properties is broken whenever either one of the * Glib::ObjectBase instances it refers to is deleted or when unbind() is called. * If a RefPtr<Binding> remains after the binding has been broken, get_source() - * and get_target() return a <tt>nullptr</tt>. It's not necessary to keep a - * RefPtr<Binding> in order to keep the binding alive. + * and get_target() return a <tt>nullptr</tt>, and dup_source() and dup_target() + * return an empty RefPtr. It's not necessary to keep a RefPtr<Binding> + * in order to keep the binding alive. * * @newin{2,44} */ @@ -381,68 +382,30 @@ public: slot_transform_from.empty() ? SlotTransform() : TransformProp<T_target, T_source>(slot_transform_from)); } - // We hand-code get_source() and get_target(). - // g_binding_get_source() and g_binding_get_target() are deprecated in glib 2.68. - // We can't use the replacements g_binding_dup_source() and g_binding_dup_target(), - // which are new in glib 2.68. This version of glibmm does not require glib 2.68. - //#m4 _CONVERSION(`GObject*',`Glib::ObjectBase*',`Glib::wrap_auto($3)') - //_WRAP_METHOD(Glib::ObjectBase* get_source(), g_binding_get_source, newin "2,44") - //_WRAP_METHOD(const Glib::ObjectBase* get_source() const, g_binding_get_source, constversion, newin "2,44") - _IGNORE(g_binding_get_source) + #m4 _CONVERSION(`GObject*',`Glib::ObjectBase*',`Glib::wrap_auto($3)') + _WRAP_METHOD(Glib::ObjectBase* get_source(), g_binding_get_source, + newin "2,44", deprecated "Use dup_source() instead.") + _WRAP_METHOD(const Glib::ObjectBase* get_source() const, g_binding_get_source, + constversion, newin "2,44", deprecated "Use dup_source() instead.") - /** Retrieves the Glib::ObjectBase instance used as the source of the binding. - * - * A %Glib::Binding can outlive the source Glib::ObjectBase as the binding does not hold a - * strong reference to the source. If the source is destroyed before the - * binding then this function will return a <tt>nullptr</tt>. - * - * @newin{2,44} - * - * @return The source Glib::ObjectBase. - */ - Glib::ObjectBase* get_source(); - - /** Retrieves the Glib::ObjectBase instance used as the source of the binding. - * - * A %Glib::Binding can outlive the source Glib::ObjectBase as the binding does not hold a - * strong reference to the source. If the source is destroyed before the - * binding then this function will return a <tt>nullptr</tt>. - * - * @newin{2,44} - * - * @return The source Glib::ObjectBase. - */ - const Glib::ObjectBase* get_source() const; + // Don't use Glib::RefPtr<Glib::Object> Glib::wrap(GObject* object, bool take_copy). + // The object may be an interface object, e.g. Gio::Action. Such an object can't be + // cast to Glib::Object. https://gitlab.gnome.org/GNOME/glibmm/-/issues/93 +#m4 _CONVERSION(`GObject*',`Glib::RefPtr<Glib::ObjectBase>',`Glib::make_refptr_for_instance<Glib::ObjectBase>(Glib::wrap_auto($3))') + _WRAP_METHOD(Glib::RefPtr<Glib::Object> dup_source(), g_binding_dup_source, newin "2,70") + _WRAP_METHOD(Glib::RefPtr<const Glib::Object> dup_source() const, g_binding_dup_source, + constversion, newin "2,70") _WRAP_METHOD(Glib::ustring get_source_property() const, g_binding_get_source_property, newin "2,44") - //_WRAP_METHOD(Glib::ObjectBase* get_target(), g_binding_get_target, newin "2,44") - //_WRAP_METHOD(const Glib::ObjectBase* get_target() const, g_binding_get_target, constversion, newin "2,44") - _IGNORE(g_binding_get_target) + _WRAP_METHOD(Glib::ObjectBase* get_target(), g_binding_get_target, + newin "2,44", deprecated "Use dup_target() instead.") + _WRAP_METHOD(const Glib::ObjectBase* get_target() const, g_binding_get_target, + constversion, newin "2,44", deprecated "Use dup_target() instead.") - /** Retrieves the Glib::ObjectBase instance used as the target of the binding. - * - * A %Glib::Binding can outlive the target Glib::ObjectBase as the binding does not hold a - * strong reference to the target. If the target is destroyed before the - * binding then this function will return a <tt>nullptr</tt>. - * - * @newin{2,44} - * - * @return The target Glib::ObjectBase. - */ - Glib::ObjectBase* get_target(); - - /** Retrieves the Glib::ObjectBase instance used as the target of the binding. - * - * A %Glib::Binding can outlive the target Glib::ObjectBase as the binding does not hold a - * strong reference to the target. If the target is destroyed before the - * binding then this function will return a <tt>nullptr</tt>. - * - * @newin{2,44} - * - * @return The target Glib::ObjectBase. - */ - const Glib::ObjectBase* get_target() const; + _WRAP_METHOD(Glib::RefPtr<Glib::Object> dup_target(), g_binding_dup_target, newin "2,70") + _WRAP_METHOD(Glib::RefPtr<const Glib::Object> dup_target() const, g_binding_dup_target, + constversion, newin "2,70") _WRAP_METHOD(Glib::ustring get_target_property() const, g_binding_get_target_property, newin "2,44") _WRAP_METHOD(Flags get_flags() const, g_binding_get_flags, newin "2,44") diff --git a/glib/src/spawn.ccg b/glib/src/spawn.ccg index 84752443..22b8895c 100644 --- a/glib/src/spawn.ccg +++ b/glib/src/spawn.ccg @@ -138,7 +138,7 @@ void spawn_sync(const std::string& working_directory, const std::vector<std::string>& argv, const std::vector<std::string>& envp, SpawnFlags flags, const SlotSpawnChildSetup& child_setup, std::string* standard_output, std::string* standard_error, - int* exit_status) + int* wait_status) { const bool setup_slot = !child_setup.empty(); auto child_setup_ = child_setup; @@ -150,7 +150,7 @@ spawn_sync(const std::string& working_directory, const std::vector<std::string>& const_cast<char**>(Glib::ArrayHandler<std::string>::vector_to_array(envp).data()), static_cast<GSpawnFlags>(unsigned(flags)), (setup_slot) ? &child_setup_callback : nullptr, (setup_slot) ? &child_setup_ : nullptr, (standard_output) ? &pch_buf_standard_output : nullptr, - (standard_error) ? &pch_buf_standard_error : nullptr, exit_status, &gerror); + (standard_error) ? &pch_buf_standard_error : nullptr, wait_status, &gerror); auto buf_standard_output = make_unique_ptr_gfree(pch_buf_standard_output); auto buf_standard_error = make_unique_ptr_gfree(pch_buf_standard_error); @@ -164,7 +164,7 @@ spawn_sync(const std::string& working_directory, const std::vector<std::string>& void spawn_sync(const std::string& working_directory, const std::vector<std::string>& argv, SpawnFlags flags, const SlotSpawnChildSetup& child_setup, std::string* standard_output, - std::string* standard_error, int* exit_status) + std::string* standard_error, int* wait_status) { const bool setup_slot = !child_setup.empty(); auto child_setup_ = child_setup; @@ -176,7 +176,7 @@ spawn_sync(const std::string& working_directory, const std::vector<std::string>& g_spawn_sync(Glib::c_str_or_nullptr(working_directory), const_cast<char**>(Glib::ArrayHandler<std::string>::vector_to_array(argv).data()), nullptr, static_cast<GSpawnFlags>(unsigned(flags)), (setup_slot) ? &child_setup_callback : nullptr, (setup_slot) ? &child_setup_ : nullptr, (standard_output) ? &pch_buf_standard_output : nullptr, - (standard_error) ? &pch_buf_standard_error : nullptr, exit_status, &gerror); + (standard_error) ? &pch_buf_standard_error : nullptr, wait_status, &gerror); auto buf_standard_output = make_unique_ptr_gfree(pch_buf_standard_output); auto buf_standard_error = make_unique_ptr_gfree(pch_buf_standard_error); @@ -199,7 +199,7 @@ spawn_command_line_async(const std::string& command_line) void spawn_command_line_sync(const std::string& command_line, std::string* standard_output, - std::string* standard_error, int* exit_status) + std::string* standard_error, int* wait_status) { char* pch_buf_standard_output = nullptr; char* pch_buf_standard_error = nullptr; @@ -207,7 +207,7 @@ spawn_command_line_sync(const std::string& command_line, std::string* standard_o g_spawn_command_line_sync(command_line.c_str(), (standard_output) ? &pch_buf_standard_output : nullptr, - (standard_error) ? &pch_buf_standard_error : nullptr, exit_status, &gerror); + (standard_error) ? &pch_buf_standard_error : nullptr, wait_status, &gerror); auto buf_standard_output = make_unique_ptr_gfree(pch_buf_standard_output); auto buf_standard_error = make_unique_ptr_gfree(pch_buf_standard_error); diff --git a/glib/src/spawn.hg b/glib/src/spawn.hg index c13ab808..c20ad9a8 100644 --- a/glib/src/spawn.hg +++ b/glib/src/spawn.hg @@ -283,13 +283,13 @@ void spawn_async(const std::string& working_directory, * if those parameters are non-nullptr. Note that you must set the * SpawnFlags::STDOUT_TO_DEV_NULL and SpawnFlags::STDERR_TO_DEV_NULL flags when * passing nullptr for @a standard_output and @a standard_error. - * If @a exit_status is non-nullptr, the exit status of the child is stored + * If @a wait_status is non-nullptr, the wait status of the child is stored * there as it would be returned by waitpid(); standard UNIX macros such - * as WIFEXITED() and WEXITSTATUS() must be used to evaluate the exit status. - * Note that this function calls waitpid() even if @a exit_status is nullptr, and + * as WIFEXITED() and WEXITSTATUS() must be used to evaluate the wait status. + * Note that this function calls waitpid() even if @a wait_status is nullptr, and * does not accept the SpawnFlags::DO_NOT_REAP_CHILD flag. * If an error occurs, no data is returned in @a standard_output, - * @a standard_error, or @a exit_status. + * @a standard_error, or @a wait_status. * * This function calls spawn_async_with_pipes() internally; see that * function for full details on the other parameters and details on @@ -302,7 +302,7 @@ void spawn_async(const std::string& working_directory, * @param child_setup Slot to run in the child just before exec(), or an empty slot. * @param standard_output Return location for file descriptor to read child's stdout, or nullptr. * @param standard_error Return location for file descriptor to read child's stderr, or nullptr. - * @param exit_status Return location for child exit status, as returned by waitpid(), or nullptr + * @param wait_status Return location for child wait status, as returned by waitpid(), or nullptr * * @throws SpawnError Errors are reported even if they occur in the child (for example if the * executable in argv[0] is not found). Typically @@ -318,7 +318,7 @@ void spawn_sync(const std::string& working_directory, const SlotSpawnChildSetup& child_setup = {}, std::string* standard_output = nullptr, std::string* standard_error = nullptr, - int* exit_status = nullptr); + int* wait_status = nullptr); /** Like the main spawn_sync() method, but inheriting the parent's environment. * @@ -328,7 +328,7 @@ void spawn_sync(const std::string& working_directory, * @param child_setup Slot to run in the child just before exec(), or an empty slot. * @param standard_output Return location for file descriptor to read child's stdout, or nullptr. * @param standard_error Return location for file descriptor to read child's stderr, or nullptr. - * @param exit_status Return location for child exit status, as returned by waitpid(), or nullptr + * @param wait_status Return location for child wait status, as returned by waitpid(), or nullptr * * @throws SpawnError Errors are reported even if they occur in the child (for example if the * executable in argv[0] is not found). Typically @@ -343,7 +343,7 @@ void spawn_sync(const std::string& working_directory, const SlotSpawnChildSetup& child_setup = {}, std::string* standard_output = nullptr, std::string* standard_error = nullptr, - int* exit_status = nullptr); + int* wait_status = nullptr); /** A simple version of spawn_async() that parses a command line with * shell_parse_argv() and passes it to spawn_async(). It runs a @@ -373,9 +373,9 @@ void spawn_command_line_async(const std::string& command_line); * implications, so consider using spawn_sync() directly if * appropriate. * - * If @a exit_status is non-nullptr, the exit status of the child is stored there as + * If @a wait_status is non-nullptr, the wait status of the child is stored there as * it would be returned by waitpid(); standard UNIX macros such as WIFEXITED() - * and WEXITSTATUS() must be used to evaluate the exit status. + * and WEXITSTATUS() must be used to evaluate the wait status. * * On Windows, please note the implications of shell_parse_argv() * parsing @a command_line. Parsing is done according to Unix shell rules, not @@ -390,7 +390,7 @@ void spawn_command_line_async(const std::string& command_line); * @param command_line A command line. * @param standard_output Return location for child output. * @param standard_error Return location for child errors. - * @param exit_status Return location for child exit status, as returned by waitpid(). + * @param wait_status Return location for child wait status, as returned by waitpid(). * * @throws SpawnError Errors are reported even if they occur in the child (for example if the * executable in argv[0] is not found). Typically @@ -402,7 +402,7 @@ GLIBMM_API void spawn_command_line_sync(const std::string& command_line, std::string* standard_output = nullptr, std::string* standard_error = nullptr, - int* exit_status = nullptr); + int* wait_status = nullptr); /** On some platforms, notably WIN32, the Pid type represents a resource * which must be closed to prevent resource leaking. close_pid() diff --git a/glib/src/timezone.ccg b/glib/src/timezone.ccg index b2af6cb5..0a6db6b9 100644 --- a/glib/src/timezone.ccg +++ b/glib/src/timezone.ccg @@ -19,15 +19,9 @@ namespace Glib { -// We hand-code create(const Glib::ustring& identifier). -// g_time_zone_new() is deprecated in glib 2.68. -// We can't use the replacement g_time_zone_new_identifier(), -// which is new in glib 2.68. This version of glibmm does not require glib 2.68. -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -TimeZone TimeZone::create(const Glib::ustring& identifier) +TimeZone::operator bool() const { - return Glib::wrap(g_time_zone_new(identifier.c_str())); + return gobject_ != nullptr; } -G_GNUC_END_IGNORE_DEPRECATIONS } // namespace Glib diff --git a/glib/src/timezone.hg b/glib/src/timezone.hg index 8d28c4e4..bba1051d 100644 --- a/glib/src/timezone.hg +++ b/glib/src/timezone.hg @@ -61,17 +61,20 @@ class GLIBMM_API TimeZone _IGNORE(g_time_zone_ref, g_time_zone_unref) public: - // We hand-code create(const Glib::ustring& identifier). - // g_time_zone_new() is deprecated in glib 2.68. - // We can't use the replacement g_time_zone_new_identifier(), - // which is new in glib 2.68. This version of glibmm does not require glib 2.68. - //_WRAP_METHOD(static TimeZone create(const Glib::ustring& identifier), g_time_zone_new_identifier) - _WRAP_METHOD_DOCS_ONLY(g_time_zone_new) - static TimeZone create(const Glib::ustring& identifier); - + _WRAP_METHOD(static TimeZone create(const Glib::ustring& identifier), + g_time_zone_new, deprecated "Use create_identifier() instead.") + _WRAP_METHOD(static TimeZone create_identifier(const Glib::ustring& identifier), + g_time_zone_new_identifier, newin "2,70") _WRAP_METHOD(static TimeZone create_local(), g_time_zone_new_local) _WRAP_METHOD(static TimeZone create_utc(), g_time_zone_new_utc) + /** Returns true if the %TimeZone object is valid. + * This will return false, for instance, if create_identifier() + * has been called with an @a identifier that cannot be parsed or loaded. + * @newin{2,70} + */ + explicit operator bool() const; + _WRAP_METHOD(int find_interval(TimeType type, gint64 time) const, g_time_zone_find_interval) _WRAP_METHOD(int adjust_time(TimeType type, gint64& time) const, g_time_zone_adjust_time) _WRAP_METHOD(Glib::ustring get_abbreviation(int interval) const, g_time_zone_get_abbreviation) |