From 5ebd30a163a5560a85b29914bebc3a41a0dc3537 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Sun, 6 Sep 2020 23:44:03 -0700 Subject: [PATCH] Imported Upstream version 2.39.93 --- MSVC_Net2005/giomm/giomm.vcproj | 2 + MSVC_Net2008/giomm/giomm.vcproj | 2 + MSVC_Net2010/giomm/giomm.vcxproj | 2 + MSVC_Net2010/giomm/giomm.vcxproj.filters | 2 + NEWS | 31 +++++++ configure.ac | 4 +- gio/src/actiongroup.hg | 2 + gio/src/application.ccg | 2 + gio/src/application.hg | 18 +++- gio/src/applicationcommandline.hg | 5 + gio/src/gio_docs.xml | 61 +++++++----- gio/src/gio_signals.defs | 106 +++++++++++++++++++++ gio/src/settings.ccg | 18 ++++ gio/src/settings.hg | 63 +++++++++++++ gio/src/socket.hg | 3 + gio/src/tlsfiledatabase.hg | 5 - gio/src/tlsinteraction.hg | 13 +++ glib/glibmm.h | 1 + glib/src/filelist.am | 1 + glib/src/glib_docs.xml | 21 +++-- glib/src/glib_extra_objects.defs | 6 ++ glib/src/keyfile.hg | 2 + glib/src/optioncontext.hg | 2 +- glib/src/variant.ccg | 15 +-- glib/src/variant.hg | 3 + glib/src/variantdict.ccg | 39 ++++++++ glib/src/variantdict.hg | 144 +++++++++++++++++++++++++++++ tools/defs_gen/h2def.py | 4 +- tools/extra_defs_gen/generate_defs_gio.cc | 5 + tools/extra_defs_gen/generate_defs_glib.cc | 13 ++- tools/m4/convert_gio.m4 | 20 ++-- tools/m4/convert_glib.m4 | 17 +++- 32 files changed, 559 insertions(+), 73 deletions(-) create mode 100644 glib/src/variantdict.ccg create mode 100644 glib/src/variantdict.hg diff --git a/MSVC_Net2005/giomm/giomm.vcproj b/MSVC_Net2005/giomm/giomm.vcproj index 2a2d373..36928af 100644 --- a/MSVC_Net2005/giomm/giomm.vcproj +++ b/MSVC_Net2005/giomm/giomm.vcproj @@ -265,6 +265,7 @@ + @@ -387,6 +388,7 @@ + diff --git a/MSVC_Net2008/giomm/giomm.vcproj b/MSVC_Net2008/giomm/giomm.vcproj index bf613c5..ab48741 100644 --- a/MSVC_Net2008/giomm/giomm.vcproj +++ b/MSVC_Net2008/giomm/giomm.vcproj @@ -274,6 +274,7 @@ + @@ -396,6 +397,7 @@ + diff --git a/MSVC_Net2010/giomm/giomm.vcxproj b/MSVC_Net2010/giomm/giomm.vcxproj index f22cc39..d4056a0 100644 --- a/MSVC_Net2010/giomm/giomm.vcxproj +++ b/MSVC_Net2010/giomm/giomm.vcxproj @@ -259,6 +259,7 @@ + @@ -377,6 +378,7 @@ + diff --git a/MSVC_Net2010/giomm/giomm.vcxproj.filters b/MSVC_Net2010/giomm/giomm.vcxproj.filters index 09bb3f0..2e5971c 100644 --- a/MSVC_Net2010/giomm/giomm.vcxproj.filters +++ b/MSVC_Net2010/giomm/giomm.vcxproj.filters @@ -92,6 +92,7 @@ Source Files Source Files Source Files + Source Files Source Files Source Files Source Files @@ -209,6 +210,7 @@ Header Files Header Files Header Files + Header Files Header Files Header Files Header Files diff --git a/NEWS b/NEWS index 5491520..1fd61e3 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,34 @@ +2.39.93 (unstable): + +Glib: +* Keyfile: Add save_to_file(). + (Murray Cumming) +* Add VariantDict. + (Murray Cumming) +* Variant: Remove the now-unnecessary local g_variant_parse_error_quark(). + (Murray Cumming) Bug #727554 (Antoine Jacoutot) + +Gio: +* Application: Add the handle-local-options signal. +* ApplicationCommandline: Add get_options_dict(). +* Settings: Add get_user_value() and get_default_value(). + (Murray Cumming) +* Socket: Add get/set_option(). + (Murray Cumming) +* TlsInteraction: Add invoke_request_certificate(), + request_certificate(), request_certificate_async() and + request_certificate_finish(). + (Murray Cumming) + +Build: +* h2def.py: + - Handle *_DEPRECATED_IN_* and AVAILABLE_IN_* with 0 digits. + - Also strip *_DEPRECATE_IN_*_FOR () without a space. + (Murray Cumming) +* Visual Studio Projects: Update giomm Projects. + (Chun-wei Fan) + + 2.39.92 (unstable): Gio: diff --git a/configure.ac b/configure.ac index eefddba..3c4f214 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ ## You should have received a copy of the GNU Lesser General Public License ## along with this library. If not, see . -AC_INIT([glibmm], [2.39.92], +AC_INIT([glibmm], [2.39.93], [http://bugzilla.gnome.org/enter_bug.cgi?product=glibmm], [glibmm], [http://www.gtkmm.org/]) AC_PREREQ([2.59]) @@ -60,7 +60,7 @@ AS_IF([test "x$enable_static" = xyes], AC_DEFINE([GIOMM_STATIC_LIB], [1], [Define if giomm is built as a static library]) ]) -glibreq='2.0 >= 2.39.92' +glibreq='2.0 >= 2.40.0' GLIBMM_MODULES="sigc++-2.0 >= 2.2.10 glib-$glibreq gobject-$glibreq gmodule-$glibreq" GIOMM_MODULES="$GLIBMM_MODULES gio-$glibreq" diff --git a/gio/src/actiongroup.hg b/gio/src/actiongroup.hg index 434b7fa..54411cf 100644 --- a/gio/src/actiongroup.hg +++ b/gio/src/actiongroup.hg @@ -173,6 +173,8 @@ void ActionGroup::get_action_state(const Glib::ustring& action_name, T_Value& va g_variant_type_equal(g_action_group_get_action_state_type(const_cast(gobj()), action_name.c_str()), type_glib_variant::variant_type().gobj())); const Glib::VariantBase variantBase = get_action_state_variant(action_name); + + //TODO: Add a bool return instead of letting a std::bad_cast from the cast_dynamic() be thrown up to the caller? const type_glib_variant variantDerived = variantBase.cast_dynamic(variantBase); value = variantDerived.get(); } diff --git a/gio/src/application.ccg b/gio/src/application.ccg index 8175d9e..0ca8245 100644 --- a/gio/src/application.ccg +++ b/gio/src/application.ccg @@ -208,6 +208,7 @@ void Application::open(const Glib::RefPtr& file, const Glib::ustring& open(files, hint); } +/* void Application::add_main_option_entry(Glib::OptionEntry& entry) { //Create a temporary array, just so we can give the correct thing to g_application_add_main_option_entries(): @@ -217,5 +218,6 @@ void Application::add_main_option_entry(Glib::OptionEntry& entry) g_application_add_main_option_entries(gobj(), array); } +*/ } // namespace Gio diff --git a/gio/src/application.hg b/gio/src/application.hg index 327736a..06011b2 100644 --- a/gio/src/application.hg +++ b/gio/src/application.hg @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -131,15 +132,16 @@ public: _WRAP_METHOD(void set_action_group(const Glib::RefPtr& action_group), g_application_set_action_group) + //TODO: We need to be able to add a group, not just some entries, + //so we can do pre and post parsing. See https://bugzilla.gnome.org/show_bug.cgi?id=727602 + // //TODO: Custom write the documentation for this method? - _WRAP_METHOD_DOCS_ONLY(g_application_add_main_option_entries) - void add_main_option_entry(Glib::OptionEntry& entry); - _IGNORE(g_application_add_main_option_entries) + //_WRAP_METHOD_DOCS_ONLY(g_application_add_main_option_entries) + //void add_main_option_entry(Glib::OptionEntry& entry); + //_IGNORE(g_application_add_main_option_entries) _WRAP_METHOD(void add_option_group(Glib::OptionGroup& group), g_application_add_option_group) - - _WRAP_METHOD(bool is_registered() const, g_application_get_is_registered) _WRAP_METHOD(bool is_remote() const, g_application_get_is_remote) @@ -230,6 +232,12 @@ public: #m4 _CONVERSION(`GApplicationCommandLine*', `const Glib::RefPtr&',`Glib::wrap($3, true)') _WRAP_SIGNAL(int command_line(const Glib::RefPtr& command_line), "command-line") + //TODO: Remove no_default_handler when we can break ABI + //TODO: Avoid the use of the Variants in the VariantDict? + //TODO: Should options definitely be non-const? Confirm that the handler is meant to modify it. +#m4 _CONVERSION(`GVariantDict*',`const Glib::RefPtr&',`Glib::wrap($3, true)') + _WRAP_SIGNAL(int handle_local_options(const Glib::RefPtr& options), "handle-local-options", no_default_handler) + protected: virtual void on_open(const type_vec_files& files, const Glib::ustring& hint); diff --git a/gio/src/applicationcommandline.hg b/gio/src/applicationcommandline.hg index 3404613..1e064e7 100644 --- a/gio/src/applicationcommandline.hg +++ b/gio/src/applicationcommandline.hg @@ -19,6 +19,7 @@ #include #include #include +#include _DEFS(giomm,gio) _PINCLUDE(glibmm/private/object_p.h) @@ -65,6 +66,10 @@ public: _WRAP_METHOD(char** get_arguments(int& argc) const, g_application_command_line_get_arguments) + //TODO: Wrap the GVariantDict*. See also Application's handle-local-options signal. + _WRAP_METHOD(Glib::RefPtr get_options_dict(), g_application_command_line_get_options_dict, refreturn) + _WRAP_METHOD(Glib::RefPtr get_options_dict() const, g_application_command_line_get_options_dict, refreturn, constversion) + _WRAP_METHOD(Glib::RefPtr get_stdin(), g_application_command_line_get_stdin, refreturn) _WRAP_METHOD(Glib::RefPtr get_stdin() const, g_application_command_line_get_stdin, refreturn, constversion) diff --git a/gio/src/gio_docs.xml b/gio/src/gio_docs.xml index 27e4ce7..a9e39fe 100644 --- a/gio/src/gio_docs.xml +++ b/gio/src/gio_docs.xml @@ -3644,11 +3644,25 @@ previewed in a file manager. Returned as the value of the key Error codes returned by GIO functions. +Note that this domain may be extended in future GLib releases. In +general, new error codes either only apply to new APIs, or else +replace #G_IO_ERROR_FAILED in cases that were not explicitly +distinguished before. You should therefore avoid writing code like +|[<!-- language="C" --> +if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FAILED)) +{ +// Assume that this is EPRINTERONFIRE +... +} +]| +but should instead treat all unrecognized error codes the same as +#G_IO_ERROR_FAILED. - Generic error condition for when any operation fails. + Generic error condition for when an operation fails +and no more specific #GIOErrorEnum value is defined. @@ -3708,7 +3722,7 @@ Error codes returned by GIO functions. - Operation not supported for the current backend. + Operation (or one of its parameters) not supported @@ -41648,7 +41662,7 @@ in the following two cases (such as `/path/to/my icon.png`) without escaping if the #GFile for @icon is a native file. If the file is not native, the returned string is the result of g_file_get_uri() -(such as `sftp://path/to/my\%20icon.png`). +(such as `sftp://path/to/my%20icon.png`). - If @icon is a #GThemedIcon with exactly one name, the encoding is simply the name (such as `network-server`). @@ -43127,7 +43141,10 @@ ignore. -Converts errno.h error codes into GIO error codes. +Converts errno.h error codes into GIO error codes. The fallback +value %G_IO_ERROR_FAILED is returned for error codes not currently +handled (but note that future GLib releases may return a more +specific value instead). @@ -43143,9 +43160,15 @@ Converts errno.h error codes into GIO error codes. -Converts some common error codes into GIO error codes. The -fallback value G_IO_ERROR_FAILED is returned for error codes not -handled. +Converts some common error codes (as returned from GetLastError() +or WSAGetLastError()) into GIO error codes. The fallback value +%G_IO_ERROR_FAILED is returned for error codes not currently +handled (but note that future GLib releases may return a more +specific value instead). + +You can use g_win32_error_message() to get a localized string +corresponding to @error_code. (But note that unlike g_strerror(), +g_win32_error_message() returns a string that must be freed.) Since: 2.26 @@ -47565,8 +47588,8 @@ Adds a button to @notification that activates @action when clicked. @action must be an application-wide action (it must start with "app."). If @target_format is given, it is used to collect remaining -positional parameters into a GVariant instance, similar to -g_variant_new(). @action will be activated with that GVariant as its +positional parameters into a #GVariant instance, similar to +g_variant_new(). @action will be activated with that #GVariant as its parameter. Since: 2.40 @@ -47586,11 +47609,11 @@ Since: 2.40 - a GVariant format string, or %NULL + a #GVariant format string, or %NULL - positional parameters, as determined by @format_string + positional parameters, as determined by @target_format @@ -47622,7 +47645,7 @@ Since: 2.40 - a GVariant to use as @action's parameter, or %NULL + a #GVariant to use as @action's parameter, or %NULL @@ -47709,8 +47732,8 @@ activated when the notification is clicked on. It must be an application-wide action (it must start with "app."). If @target_format is given, it is used to collect remaining -positional parameters into a GVariant instance, similar to -g_variant_new(). @action will be activated with that GVariant as its +positional parameters into a #GVariant instance, similar to +g_variant_new(). @action will be activated with that #GVariant as its parameter. When no default action is set, the application that the notification @@ -47729,11 +47752,11 @@ Since: 2.40 - a GVariant format string, or %NULL + a #GVariant format string, or %NULL - positional parameters, as determined by @format_string + positional parameters, as determined by @target_format @@ -47746,10 +47769,6 @@ Sets the default action of @notification to @action. This action is activated when the notification is clicked on. It must be an application-wide action (start with "app."). -If @target_format is given, it is used to collect remaining -positional parameters into a GVariant instance, similar to -g_variant_new(). - If @target is non-%NULL, @action will be activated with @target as its parameter. @@ -47769,7 +47788,7 @@ Since: 2.40 - a GVariant to use as @action's parameter, or %NULL + a #GVariant to use as @action's parameter, or %NULL diff --git a/gio/src/gio_signals.defs b/gio/src/gio_signals.defs index 9f7acc9..ea5828a 100644 --- a/gio/src/gio_signals.defs +++ b/gio/src/gio_signals.defs @@ -190,6 +190,14 @@ (construct-only #f) ) +;; From GAppInfoMonitor + +(define-signal changed + (of-object "GAppInfoMonitor") + (return-type "void") + (when "first") +) + ;; From GCancellable (define-signal cancelled @@ -758,6 +766,73 @@ (construct-only #f) ) +;; From GNotification + +;; From GPropertyAction + +(define-property name + (of-object "GPropertyAction") + (prop-type "GParamString") + (docs "The name used to invoke the action") + (readable #t) + (writable #t) + (construct-only #t) +) + +(define-property parameter-type + (of-object "GPropertyAction") + (prop-type "GParamBoxed") + (docs "The type of GVariant passed to activate()") + (readable #t) + (writable #f) + (construct-only #f) +) + +(define-property enabled + (of-object "GPropertyAction") + (prop-type "GParamBoolean") + (docs "If the action can be activated") + (readable #t) + (writable #f) + (construct-only #f) +) + +(define-property state-type + (of-object "GPropertyAction") + (prop-type "GParamBoxed") + (docs "The type of the state kept by the action") + (readable #t) + (writable #f) + (construct-only #f) +) + +(define-property state + (of-object "GPropertyAction") + (prop-type "GParamVariant") + (docs "The state the action is in") + (readable #t) + (writable #f) + (construct-only #f) +) + +(define-property object + (of-object "GPropertyAction") + (prop-type "GParamObject") + (docs "The object with the property to wrap") + (readable #f) + (writable #t) + (construct-only #t) +) + +(define-property property-name + (of-object "GPropertyAction") + (prop-type "GParamString") + (docs "The name of the property to wrap") + (readable #f) + (writable #t) + (construct-only #t) +) + ;; From GProxy ;; From GProxyAddress @@ -1038,6 +1113,37 @@ (construct-only #f) ) +;; From GSubprocess + +(define-property flags + (of-object "GSubprocess") + (prop-type "GParamFlags") + (docs "Subprocess flags") + (readable #f) + (writable #t) + (construct-only #t) +) + +(define-property argv + (of-object "GSubprocess") + (prop-type "GParamBoxed") + (docs "Argument vector") + (readable #f) + (writable #t) + (construct-only #t) +) + +;; From GSubprocessLauncher + +(define-property flags + (of-object "GSubprocessLauncher") + (prop-type "GParamFlags") + (docs "GSubprocessFlags for launched processes") + (readable #f) + (writable #t) + (construct-only #t) +) + ;; From GThemedIcon (define-property name diff --git a/gio/src/settings.ccg b/gio/src/settings.ccg index a32ad94..ca92f15 100644 --- a/gio/src/settings.ccg +++ b/gio/src/settings.ccg @@ -31,6 +31,24 @@ void Settings::get_value(const Glib::ustring& key, Glib::VariantBase& value) con value.init(g_value, false /* don't take a reference */); } +bool Settings::get_user_value(const Glib::ustring& key, Glib::VariantBase& value) const +{ + GVariant* const g_value = g_settings_get_user_value(const_cast(gobj()), key.c_str()); + if(!g_value) + return false; + + value.init(g_value, false /* don't take a reference */); + return true; +} + +void Settings::get_default_value(const Glib::ustring& key, Glib::VariantBase& value) const +{ + GVariant* const g_value = g_settings_get_default_value(const_cast(gobj()), key.c_str()); + if(!g_value) + return; + + value.init(g_value, false /* don't take a reference */); +} void Settings::bind(const Glib::ustring& key, const Glib::PropertyProxy_Base& property_proxy, SettingsBindFlags flags) diff --git a/gio/src/settings.hg b/gio/src/settings.hg index 74554fa..4e45cee 100644 --- a/gio/src/settings.hg +++ b/gio/src/settings.hg @@ -51,8 +51,10 @@ public: //TODO: Requires SettingsBackend: _WRAP_CREATE(const Glib::ustring& schema, const Glib::RefPtr& backend) //TODO: Requires SettingsBackend: _WRAP_CREATE(const Glib::ustring& schema, const Glib::RefPtr& backend, const Glib::ustring& path) + //TODO: Rename these to get/set_*_value_variant() and add templated get/set_*_value() methods as elsewhere? _WRAP_METHOD(bool set_value(const Glib::ustring& key, const Glib::VariantBase& value), g_settings_set_value) + /** Gets the value that is stored in the settings for a @a key. * * It is a programmer error to give a @a key that isn't contained in the @@ -66,6 +68,67 @@ public: void get_value(const Glib::ustring& key, Glib::VariantBase& value) const; _IGNORE(g_settings_get_value) + //TODO: We've added a bool return to handle the NULL return value case, + //but maybe other get_value() methods can return NULLs too. + + /** Checks the "user value" of a @a key, if there is one. + * + * The user value of a key is the last value that was set by the user. + * + * After calling reset() this function should always return + * false (assuming something is not wrong with the system + * configuration). + * + * It is possible that get_value() will return a different + * value than this method. This can happen in the case that the user + * set a value for a key that was subsequently locked down by the system + * administrator -- this method will return the user's old value. + * + * This method may be useful for adding a "reset" option to a UI or + * for providing indication that a particular value has been changed. + * + * It is a programmer error to give a @a key that isn't contained in the + * schema for the settings. + * + * @param key The key to get the user value for. + * @param value A Variant of the expected type. + * @result true if a user value was found. + * + * @newin{2,40} + */ + bool get_user_value(const Glib::ustring& key, Glib::VariantBase& value) const; + _IGNORE(g_settings_get_user_value) + + /** Gets the "default value" of a key. + * + * This is the value that would be read if reset() were to be + * called on the key. + * + * Note that this may be a different value than returned by + * get_default_value() if the system administrator + * has provided a default value. + * + * Comparing the return values of get_default_value() and + * value() is not sufficient for determining if a value + * has been set because the user may have explicitly set the value to + * something that happens to be equal to the default. The difference + * here is that if the default changes in the future, the user's key + * will still be set. + * + * This method may be useful for adding an indication to a UI of what + * the default value was before the user set it. + * + * It is a programmer error to give a @a key that isn't contained in the + * schema for the settings. + * + * @param key The key to get the default value for. + * @param value A Variant of the expected type. + * + * @newin{2,40} + */ + void get_default_value(const Glib::ustring& key, Glib::VariantBase& value) const; + _IGNORE(g_settings_get_default_value) + _WRAP_METHOD(int get_int(const Glib::ustring& key) const, g_settings_get_int) _WRAP_METHOD(void set_int(const Glib::ustring& key, int value), g_settings_set_int) _WRAP_METHOD(guint get_uint(const Glib::ustring& key) const, g_settings_get_uint) diff --git a/gio/src/socket.hg b/gio/src/socket.hg index bcaa9d3..f0bce7b 100644 --- a/gio/src/socket.hg +++ b/gio/src/socket.hg @@ -268,6 +268,9 @@ public: _WRAP_METHOD_DOCS_ONLY(g_socket_send_with_blocking) gssize send_with_blocking(gchar* buffer, gsize size, bool blocking, const Glib::RefPtr& cancellable = Glib::RefPtr()); + _WRAP_METHOD(bool get_option(int level, int optname, int& value) const, g_socket_get_option, errthrow) + _WRAP_METHOD(bool set_option(int level, int optname, int value), g_socket_set_option, errthrow) + _WRAP_METHOD(guint get_ttl() const, g_socket_get_ttl) _WRAP_METHOD(void set_ttl(guint ttl), g_socket_set_ttl) diff --git a/gio/src/tlsfiledatabase.hg b/gio/src/tlsfiledatabase.hg index 516e211..08650c5 100644 --- a/gio/src/tlsfiledatabase.hg +++ b/gio/src/tlsfiledatabase.hg @@ -44,11 +44,6 @@ class TlsFileDatabase _CLASS_INTERFACE(TlsFileDatabase, GTlsFileDatabase, G_TLS_FILE_DATABASE, GTlsFileDatabaseInterface) public: - //TODO: Should this create() method be in TlsDatabase since the _new() - //function returns a GTlsDatabase? - // No, it's normal for a G* C API to return a base type, but we correct that in C++. - // For instance, many GTK+ _new() functions return GtkWidget*. murrayc. - //TODO: It is not possible to use _WRAP_CTOR()/WRAP_CREATE() here because this //class is an interface. // So, should we make it possible to use them? murrayc. diff --git a/gio/src/tlsinteraction.hg b/gio/src/tlsinteraction.hg index 37ad491..37abbbc 100644 --- a/gio/src/tlsinteraction.hg +++ b/gio/src/tlsinteraction.hg @@ -17,6 +17,7 @@ #include #include +#include _DEFS(giomm,gio) _PINCLUDE(glibmm/private/object_p.h) @@ -26,6 +27,7 @@ namespace Gio { _WRAP_ENUM(TlsInteractionResult, GTlsInteractionResult) +_WRAP_ENUM(TlsCertificateRequestFlags, GTlsCertificateRequestFlags) class Cancellable; class TlsPassword; @@ -65,6 +67,17 @@ public: _WRAP_METHOD(TlsInteractionResult ask_password_finish(const Glib::RefPtr& result), g_tls_interaction_ask_password_finish, errthrow) _WRAP_METHOD(TlsInteractionResult invoke_ask_password(const Glib::RefPtr& password, const Glib::RefPtr& cancellable{?}), g_tls_interaction_invoke_ask_password, errthrow) + + + _WRAP_METHOD(TlsInteractionResult invoke_request_certificate(const Glib::RefPtr& connection, TlsCertificateRequestFlags flags, const Glib::RefPtr& cancellable{?}), g_tls_interaction_invoke_request_certificate, errthrow) + + _WRAP_METHOD(TlsInteractionResult request_certificate(const Glib::RefPtr& connection, TlsCertificateRequestFlags flags, const Glib::RefPtr& cancellable{?}), g_tls_interaction_request_certificate, errthrow) + + _WRAP_METHOD(void request_certificate_async(const Glib::RefPtr& connection, TlsCertificateRequestFlags flags, const SlotAsyncReady& slot{callback?}, const Glib::RefPtr& cancellable{.?}), g_tls_interaction_request_certificate_async, slot_name slot, slot_callback SignalProxy_async_callback) + + _WRAP_METHOD(TlsInteractionResult request_certificate_finish(const Glib::RefPtr& result), g_tls_interaction_request_certificate_finish, errthrow) + + #m4 _CONVERSION(`GTlsPassword*',`const Glib::RefPtr&',`Glib::wrap($3, true)') _WRAP_VFUNC(TlsInteractionResult ask_password(const Glib::RefPtr& password, const Glib::RefPtr& cancellable), "ask_password", errthrow) _WRAP_VFUNC(void ask_password_async(const Glib::RefPtr& password, const SlotAsyncReady& slot{callback}, const Glib::RefPtr& cancellable{.}), "ask_password_async", slot_name slot, slot_callback SignalProxy_async_callback) diff --git a/glib/glibmm.h b/glib/glibmm.h index 9438ee9..296db7b 100644 --- a/glib/glibmm.h +++ b/glib/glibmm.h @@ -142,6 +142,7 @@ #include #include #include +#include #include #include #include diff --git a/glib/src/filelist.am b/glib/src/filelist.am index 0c5ef5d..8db8500 100644 --- a/glib/src/filelist.am +++ b/glib/src/filelist.am @@ -42,6 +42,7 @@ glibmm_files_hg = \ uriutils.hg \ valuearray.hg \ variant.hg \ + variantdict.hg \ variantiter.hg \ varianttype.hg diff --git a/glib/src/glib_docs.xml b/glib/src/glib_docs.xml index f7dbd12..c40583a 100644 --- a/glib/src/glib_docs.xml +++ b/glib/src/glib_docs.xml @@ -13600,7 +13600,7 @@ The following format specifiers are supported: - \%C: the century number (year/100) as a 2-digit integer (00-99) - \%d: the day of the month as a decimal number (range 01 to 31) - \%e: the day of the month as a decimal number (range 1 to 31) -- \%F: equivalent to `\%Y-\%m-\%d` (the ISO 8601 date format) +- \%F: equivalent to `%Y-%m-%d` (the ISO 8601 date format) - \%g: the last two digits of the ISO 8601 week-based year as a decimal number (00-99). This works well with \%V and \%u. - \%G: the ISO 8601 week-based year as a decimal number. This works @@ -15456,6 +15456,13 @@ Returns %TRUE if @error matches @domain and @code, %FALSE otherwise. In particular, when @error is %NULL, %FALSE will be returned. +If @domain contains a `FAILED` (or otherwise generic) error code, +you should generally not check for it explicitly, but should +instead treat any not-explicitly-recognized error code as being +equilalent to the `FAILED` code. This way, if the domain is +extended in the future to provide a more specific error code for +a certain case, your code will still work. + @@ -57365,12 +57372,12 @@ Since: 2.32 -Translate a Win32 error code (as returned by GetLastError()) into -the corresponding message. The message is either language neutral, -or in the thread's language, or the user's language, the system's -language, or US English (see docs for FormatMessage()). The -returned string is in UTF-8. It should be deallocated with -g_free(). +Translate a Win32 error code (as returned by GetLastError() or +WSAGetLastError()) into the corresponding message. The message is +either language neutral, or in the thread's language, or the user's +language, the system's language, or US English (see docs for +FormatMessage()). The returned string is in UTF-8. It should be +deallocated with g_free(). diff --git a/glib/src/glib_extra_objects.defs b/glib/src/glib_extra_objects.defs index 1774ec4..d190f3c 100644 --- a/glib/src/glib_extra_objects.defs +++ b/glib/src/glib_extra_objects.defs @@ -73,6 +73,12 @@ (gtype-id "G_TYPE_VARIANT") ) +(define-object VariantDict + (in-module "GLib") + (c-name "GVariantDict") + (gtype-id "G_TYPE_VARIANT_DICT") +) + (define-object VariantType (in-module "GLib") (c-name "GVariantType") diff --git a/glib/src/keyfile.hg b/glib/src/keyfile.hg index a572e4d..b1560e9 100644 --- a/glib/src/keyfile.hg +++ b/glib/src/keyfile.hg @@ -166,6 +166,8 @@ _DEPRECATE_IFDEF_END Glib::ustring to_data(); _IGNORE(g_key_file_to_data) + _WRAP_METHOD(bool save_to_file(const std::string& filename), g_key_file_save_to_file, errthrow) + _WRAP_METHOD(Glib::ustring get_start_group() const, g_key_file_get_start_group) /** Gets a list of all groups in the KeyFile diff --git a/glib/src/optioncontext.hg b/glib/src/optioncontext.hg index b159ff2..60c3549 100644 --- a/glib/src/optioncontext.hg +++ b/glib/src/optioncontext.hg @@ -108,7 +108,7 @@ public: #m4 _CONVERSION(`char**&',`gchar***',`&($3)') _WRAP_METHOD(bool parse(int& argc, char**& argv), g_option_context_parse, errthrow) - //TODO: Document ths as useful (only?) with the result from g_win32_get_command_line? + //TODO: Document this as useful (only?) with the result from g_win32_get_command_line? //goption.c has example code that suggests always using this, and ifdefing for G_OS_WIN32, with a g_strdupv for the non-win32 case. //Presumably we cannot hide that ifdeffing from application code because the argument-removal would be invisible to the caller. //So can we hide it for people who don't care about arguments being removed from argv? diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg index bfdff9f..a7c5352 100644 --- a/glib/src/variant.ccg +++ b/glib/src/variant.ccg @@ -20,19 +20,6 @@ #include #include -extern "C" -{ - -//This is hack to workaround this problem in glib: -// https://bugzilla.gnome.org/show_bug.cgi?id=708212 -//We really should not define a g_* symbol outside of glib: -GQuark g_variant_parse_error_quark() -{ - return g_variant_parser_get_error_quark(); -} - -} //extern C - namespace Glib { @@ -58,7 +45,7 @@ void VariantBase::get_normal_form(VariantBase& result) const GVariant* const g_value = g_variant_get_normal_form(const_cast(gobj())); - //The C function never returns NULL, according to its docuemenation, + //The C function never returns NULL, according to its documenation, //so we don't need a bool return value. result.init(g_value); // g_value is already referenced. } diff --git a/glib/src/variant.hg b/glib/src/variant.hg index 1ab266e..0cb1a82 100644 --- a/glib/src/variant.hg +++ b/glib/src/variant.hg @@ -210,6 +210,8 @@ public: template static V_CastTo cast_dynamic(const VariantBase& v) throw(std::bad_cast); + _IGNORE(g_variant_dict_new) + private: /** Relational operators are deleted to prevent invalid conversion * to const void*. @@ -454,6 +456,7 @@ public: //TODO: Documentation void get(VariantBase& variant) const; + //TODO: Deprecate this in favour of get(VariantBase&)? _WRAP_METHOD(VariantBase get() const, g_variant_get_variant) }; diff --git a/glib/src/variantdict.ccg b/glib/src/variantdict.ccg new file mode 100644 index 0000000..ddc061d --- /dev/null +++ b/glib/src/variantdict.ccg @@ -0,0 +1,39 @@ +/* + * Copyright 2014 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +namespace Glib +{ + +bool VariantDict::lookup_value_variant(const Glib::ustring& key, const VariantType& expected_type, VariantBase& value) const +{ + GVariant* const g_value = + g_variant_dict_lookup_value(const_cast(gobj()), + key.c_str(), + expected_type.gobj()); + if(!g_value) + return false; + + value.init(g_value); // g_value is already referenced. + return true; +} + +} //namespace Glib + + diff --git a/glib/src/variantdict.hg b/glib/src/variantdict.hg new file mode 100644 index 0000000..876591f --- /dev/null +++ b/glib/src/variantdict.hg @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2014 The glibmm 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +_DEFS(glibmm,glib) + +namespace Glib +{ + +/** VariantDict is a mutable interface to Variant dictionaries. + * + * It can be used for doing a sequence of dictionary lookups in an + * efficient way on an existing Variant dictionary or it can be used + * to construct new dictionaries with a hashtable-like interface. It + * can also be used for taking existing dictionaries and modifying them + * in order to create new ones. + * + * newin{2,40} + */ +class VariantDict +{ + //GVariantDict is registered as a boxed type, but it has ref/unref functions instead of copy/free, + //so we use it via RefPtr. + _CLASS_OPAQUE_REFCOUNTED(VariantDict, GVariantDict, NONE, g_variant_dict_ref, g_variant_dict_unref) + _IGNORE(g_variant_dict_ref, g_variant_dict_unref, g_variant_dict_init) + +public: + _WRAP_METHOD(static Glib::RefPtr create(const VariantBase& from_asv{?}), g_variant_dict_new) + + +//TODO: Add a method overload that does not take expected_type (which can be null), +//just returning a VariantBase that should be cast_dynamic()ed? + + /** Looks up a value in the VariantDict. See also lookup_value(). + * + * If the @a key is not found the false is returned. + * + * The @a expected_type string specifies what type of value is expected. + * If the value associated with @a key has a different type then false is + * returned. + * + * If the key is found and the value has the correct type, it is + * returned in the @a value output variable. + */ + bool lookup_value_variant(const Glib::ustring& key, const VariantType& expected_type, VariantBase& value) const; + _IGNORE(g_variant_dict_lookup_value) + + /** Looks up a value in the VariantDict. + * + * If the @a key is not found the false is returned. + * + * If the value associated with @a key has a different type than expected then false is + * returned. + * + * If the key is found and the value has the correct type, it is + * returned in the @a value output variable. + */ + template + bool lookup_value(const Glib::ustring& key, T_Value& value) const; + _IGNORE(g_variant_dict_lookup) + + + _WRAP_METHOD(bool contains(const Glib::ustring& key) const, g_variant_dict_contains) + + _IGNORE(g_variant_dict_insert) + + + _WRAP_METHOD(void insert_value_variant(const Glib::ustring& key, const VariantBase& value), g_variant_dict_insert_value) + + /** Inserts (or replaces) a key in a VariantDict. + * + * @param key The key to insert a value for. + * @param value The value to insert. + */ + template + void insert_value(const Glib::ustring& key, const T_Value& value); + + + _WRAP_METHOD(bool remove(const Glib::ustring& key), g_variant_dict_remove) + + _WRAP_METHOD(void clear(), g_variant_dict_clear) + + _IGNORE(g_variant_dict_end) +}; + +template +void VariantDict::insert_value(const Glib::ustring& key, const T_Value& value) +{ + typedef Glib::Variant type_glib_variant; + + //TODO: Can we do any check like this here, before glib does? + //g_return_val_if_fail( + // g_variant_type_equal(g_action_get_parameter_type(const_cast(gobj())), type_glib_variant::variant_type().gobj()), + // Glib::ustring()); + return insert_value_variant(key, type_glib_variant::create(value)); +} + +template +bool VariantDict::lookup_value(const Glib::ustring& key, T_Value& value) const +{ + value = T_Value(); //Make sure that it is initialized. + + typedef Glib::Variant type_glib_variant; + + //TODO: Can we do any check like this here, before glib does? + //g_variant_type_equal(g_action_group_get_action_state_type(const_cast(gobj()), action_name.c_str()), type_glib_variant::variant_type().gobj())); + + Glib::VariantBase variantBase; + const bool result = lookup_value_variant(key, type_glib_variant::variant_type(), variantBase); + if(!result) + return result; + + try + { + const type_glib_variant variantDerived = variantBase.cast_dynamic(variantBase); + value = variantDerived.get(); + } + catch(const std::bad_cast& ex) + { + return false; + } + + return result; +} + +} //namespace Glib + + diff --git a/tools/defs_gen/h2def.py b/tools/defs_gen/h2def.py index 3ffbd7c..82651fe 100755 --- a/tools/defs_gen/h2def.py +++ b/tools/defs_gen/h2def.py @@ -305,7 +305,7 @@ def clean_func(buf): buf = pat.sub('', buf) #strip *_DEPRECATED_IN_*_FOR (*): - pat = re.compile(r"""[A-Z]+_DEPRECATED_IN_[1-9]_([1-9]*)_FOR \(\S*\)\S*""", re.MULTILINE) + pat = re.compile(r"""[A-Z]+_DEPRECATED_IN_[0-9]_([0-9]*)_FOR\s*\(\S*\)\S*""", re.MULTILINE) buf = pat.sub('', buf) #strip *_DEPRECATED* @@ -313,7 +313,7 @@ def clean_func(buf): buf = pat.sub('', buf) #strip *_AVAILABLE_IN_* - pat = re.compile(r"""[A-Z]+_AVAILABLE_IN_[1-9]_[1-9]\S*""", re.MULTILINE) + pat = re.compile(r"""[A-Z]+_AVAILABLE_IN_[0-9]_[0-9]\S*""", re.MULTILINE) buf = pat.sub('', buf) #strip *_AVAILABLE_IN_ALL diff --git a/tools/extra_defs_gen/generate_defs_gio.cc b/tools/extra_defs_gen/generate_defs_gio.cc index 6d202bb..df76459 100644 --- a/tools/extra_defs_gen/generate_defs_gio.cc +++ b/tools/extra_defs_gen/generate_defs_gio.cc @@ -42,6 +42,7 @@ int main(int, char**) << get_defs(G_TYPE_ACTION) << 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) @@ -80,6 +81,8 @@ int main(int, char**) << get_defs(G_TYPE_MENU_MODEL) << get_defs(G_TYPE_MOUNT) << get_defs(G_TYPE_MOUNT_OPERATION) + << get_defs(G_TYPE_NOTIFICATION) + << get_defs(G_TYPE_PROPERTY_ACTION) << get_defs(G_TYPE_PROXY) << get_defs(G_TYPE_PROXY_ADDRESS) << get_defs(G_TYPE_PROXY_ADDRESS_ENUMERATOR) @@ -89,6 +92,8 @@ int main(int, char**) << get_defs(G_TYPE_SETTINGS_BACKEND) << get_defs(G_TYPE_SIMPLE_ASYNC_RESULT) << get_defs(G_TYPE_SIMPLE_ACTION) + << get_defs(G_TYPE_SUBPROCESS) + << get_defs(G_TYPE_SUBPROCESS_LAUNCHER) << get_defs(G_TYPE_THEMED_ICON) //TODO: This causes a g_warning: diff --git a/tools/extra_defs_gen/generate_defs_glib.cc b/tools/extra_defs_gen/generate_defs_glib.cc index 01176b7..2ead0a0 100644 --- a/tools/extra_defs_gen/generate_defs_glib.cc +++ b/tools/extra_defs_gen/generate_defs_glib.cc @@ -27,10 +27,21 @@ int main() // g_type_init() is deprecated as of 2.36. // g_type_init(); - std::cout << get_defs( G_TYPE_DATE ) + std::cout << get_defs( G_TYPE_BYTES ) + << get_defs( G_TYPE_CHECKSUM ) + << get_defs( G_TYPE_DATE ) + << get_defs( G_TYPE_DATE_TIME ) << get_defs( G_TYPE_IO_CHANNEL ) + << get_defs( G_TYPE_KEY_FILE ) + << get_defs( G_TYPE_MAIN_CONTEXT ) + << get_defs( G_TYPE_MAIN_LOOP ) + << get_defs( G_TYPE_MATCH_INFO ) << get_defs( G_TYPE_REGEX ) + << get_defs( G_TYPE_SOURCE ) + << get_defs( G_TYPE_THREAD ) << get_defs( G_TYPE_VARIANT ) + << get_defs( G_TYPE_VARIANT_BUILDER ) + << get_defs( G_TYPE_VARIANT_DICT ) << std::endl; return 0; diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4 index a6f04a3..58d2a65 100644 --- a/tools/m4/convert_gio.m4 +++ b/tools/m4/convert_gio.m4 @@ -42,6 +42,7 @@ _CONV_ENUM(G,SocketMsgFlags) _CONV_ENUM(G,SocketProtocol) _CONV_ENUM(G,SocketType) _CONV_ENUM(G,TlsCertificateFlags) +_CONV_ENUM(G,TlsCertificateRequestFlags) _CONV_ENUM(G,TlsDatabaseVerifyFlags) _CONV_ENUM(G,TlsDatabaseLookupFlags) _CONV_ENUM(G,TlsInteractionResult) @@ -287,30 +288,23 @@ _CONVERSION(`GTlsCertificate*', `Glib::RefPtr', `Glib::wrap($3)' _CONVERSION(`const Glib::RefPtr&', `GTlsCertificate*', `const_cast(Glib::unwrap($3))') _CONVERSION(`const Glib::RefPtr&',`GTlsCertificate*',`Glib::unwrap($3)') +#TlsConnection: +_CONVERSION(`const Glib::RefPtr&',`GTlsConnection*',`Glib::unwrap($3)') + #TlsDatabase _CONVERSION(`GTlsDatabase*',`Glib::RefPtr',`Glib::wrap($3)') -_CONVERSION(`const Glib::RefPtr&',`GTlsDatabase*',`Glib::unwrap($3)') +_CONVERSION(`const Glib::RefPtr&',`GTlsDatabase*',__CONVERT_REFPTR_TO_P) #TlsInteraction _CONVERSION(`const Glib::RefPtr&',`GTlsInteraction*',`Glib::unwrap($3)') _CONVERSION(`GTlsInteraction*',`Glib::RefPtr',`Glib::wrap($3)') #TlsPassword -_CONVERSION(`const Glib::RefPtr&',`GTlsPassword*',`Glib::unwrap($3)') +_CONVERSION(`const Glib::RefPtr&',`GTlsPassword*',__CONVERT_REFPTR_TO_P) #UnixFDList _CONVERSION(`GUnixFDList*',`Glib::RefPtr',`Glib::wrap($3)') -_CONVERSION(`const Glib::RefPtr&',`GUnixFDList*',`Glib::unwrap($3)') - -#Variant -_CONVERSION(`GVariant*',`Glib::VariantBase',`Glib::wrap($3, false)') -_CONVERSION(`GVariant*',`Glib::VariantContainerBase',`Glib::VariantContainerBase($3, false)') -_CONVERSION(`const Glib::VariantBase&',`GVariant*',`const_cast(($3).gobj())') -_CONVERSION(`const Glib::VariantContainerBase&',`GVariant*',`const_cast(($3).gobj())') - -#VariantType -_CONVERSION(`const GVariantType*',`Glib::VariantType',`Glib::wrap(const_cast($3), true)') -_CONVERSION(`const Glib::VariantType&',`const GVariantType*',`$3.gobj()') +_CONVERSION(`const Glib::RefPtr&',`GUnixFDList*',__CONVERT_REFPTR_TO_P) #Volume _CONVERSION(`GVolume*',`Glib::RefPtr',`Glib::wrap($3)') diff --git a/tools/m4/convert_glib.m4 b/tools/m4/convert_glib.m4 index 3dd4e8d..f7e768c 100644 --- a/tools/m4/convert_glib.m4 +++ b/tools/m4/convert_glib.m4 @@ -154,10 +154,23 @@ _CONVERSION(`const Glib::ValueBase&',`GValue*',`const_cast(($3).gobj()) _CONVERSION(`GValue*', `Glib::ValueBase&', `*reinterpret_cast($3)') _CONVERSION(`const GValue*', `const Glib::ValueBase&', `*reinterpret_cast($3)') -dnl VariantContainerBase +#Variant +_CONVERSION(`GVariant*',`Glib::VariantBase',`Glib::wrap($3, false)') +_CONVERSION(`GVariant*',`Glib::VariantContainerBase',`Glib::VariantContainerBase($3, false)') +_CONVERSION(`const VariantBase&',`GVariant*',`const_cast(($3).gobj())') +_CONVERSION(`const Glib::VariantBase&',`GVariant*',`const_cast(($3).gobj())') +_CONVERSION(`const Glib::VariantContainerBase&',`GVariant*',`const_cast(($3).gobj())') + +# VariantContainerBase _CONVERSION(`const VariantContainerBase&',`GVariant*',`const_cast(($3).gobj())') -dnl VariantType +#VariantDict +_CONVERSION(`GVariantDict*',`Glib::RefPtr',`Glib::wrap($3)') +_CONVERSION(`GVariantDict*',`Glib::RefPtr',`Glib::wrap($3)') +_CONVERSION(`GVariantDict*',`Glib::RefPtr',`Glib::wrap($3)') + +#VariantType +_CONVERSION(`const GVariantType*',`Glib::VariantType',`Glib::wrap(const_cast($3), true)') _CONVERSION(`const VariantType&',`const GVariantType*',`($3).gobj()') _CONVERSION(`const Glib::VariantType&',`const GVariantType*',`($3).gobj()') _CONVERSION(`GVariantType*',`VariantType',`Glib::wrap($3)') -- 2.7.4