From b21a0258d7e200c46a5db91569f9c3822f3db0a5 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Sun, 6 Sep 2020 23:43:28 -0700 Subject: [PATCH] Imported Upstream version 2.39.4 --- NEWS | 28 +++++++ configure.ac | 4 +- gio/giomm.h | 1 + gio/src/action.hg | 57 +++++++++++++-- gio/src/actionmap.hg | 1 - gio/src/application.hg | 5 ++ gio/src/cancellable.hg | 3 - gio/src/dbusconnection.hg | 1 + gio/src/dbusmessage.hg | 8 +- gio/src/dbusproxy.hg | 1 + gio/src/file.hg | 21 +++--- gio/src/fileattributeinfo.hg | 8 +- gio/src/fileinfo.hg | 2 +- gio/src/filelist.am | 1 + gio/src/gio_methods.defs | 10 +-- gio/src/inputstream.hg | 1 + gio/src/memoryinputstream.ccg | 49 ++++++++++++- gio/src/memoryinputstream.hg | 26 +++++-- gio/src/menuitem.hg | 8 +- gio/src/menumodel.hg | 4 +- gio/src/mount.hg | 1 + gio/src/notification.ccg | 31 ++++++++ gio/src/notification.hg | 133 ++++++++++++++++++++++++++++++++++ gio/src/outputstream.hg | 1 + gio/src/settings.hg | 2 +- gio/src/simpleaction.hg | 5 +- gio/src/socketconnection.hg | 3 +- gio/src/threadedsocketservice.hg | 4 +- glib/glibmm/base64.h | 2 +- glib/glibmm/refptr.h | 2 +- glib/src/bytes.hg | 3 +- glib/src/module.hg | 5 +- glib/src/optioncontext.hg | 58 ++++++++++++++- glib/src/optionentry.hg | 1 + glib/src/optiongroup.ccg | 3 +- glib/src/optiongroup.hg | 45 ++++++++++++ glib/src/variant.hg | 7 +- tests/Makefile.am | 4 + tests/giomm_memoryinputstream/main.cc | 95 ++++++++++++++++++++++++ tools/m4/convert_gio.m4 | 4 + tools/m4/initialize_glib.m4 | 3 + tools/pm/DocsParser.pm | 6 +- 42 files changed, 584 insertions(+), 73 deletions(-) create mode 100644 gio/src/notification.ccg create mode 100644 gio/src/notification.hg create mode 100644 tests/giomm_memoryinputstream/main.cc diff --git a/NEWS b/NEWS index 31a543f..c5843a1 100644 --- a/NEWS +++ b/NEWS @@ -1,10 +1,38 @@ 2.39.3 (unstable): +Gio +* Action: + - Add parse_detailed_name() and parse_detailed_name_variant(). + (Kjell Ahlstedt) + - Fix activate(const Glib::Variant& value). + (Kjell Ahlstedt) Bug #722896 +* MenuModel: Add signal_items_changed() + (Kjell Ahlstedt) +* MemoryInputStream: Add add_data() taking a sigc::slot, + with a test. + (Kjell Ahlstedt) Bug #609946 (Daniel Elstner) +* MenuModel: Add signal_items_changed() + (Kjell Ahlstedt) +* Add Notification. + (Kjell Ahlstedt) Bug #722896. + +Documentation: +* Fix some doxygen warnings. + (Kjell Ahlstedt) +* Don't change NULL to 0 in docs, when it's part of a longer name. + (Kjell Ahlstedt) +* OptionContext: Add API documentation based on the C docs. + (Murray Cumming) + + +2.39.3 (unstable): + * Documentation improvements. (Kjell Ahlstedt) * Fix a test on IPv6 systems. (Adam Sampson) + 2.38.1 (stable): Build: diff --git a/configure.ac b/configure.ac index 312003c..baee4ca 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.3], +AC_INIT([glibmm], [2.39.4], [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.38.0' +glibreq='2.0 >= 2.39.4' GLIBMM_MODULES="sigc++-2.0 >= 2.2.10 glib-$glibreq gobject-$glibreq gmodule-$glibreq" GIOMM_MODULES="$GLIBMM_MODULES gio-$glibreq" diff --git a/gio/giomm.h b/gio/giomm.h index 2ce4935..5f31f09 100644 --- a/gio/giomm.h +++ b/gio/giomm.h @@ -101,6 +101,7 @@ #include #include #include +#include #include #include #include diff --git a/gio/src/action.hg b/gio/src/action.hg index b981e25..932ab8c 100644 --- a/gio/src/action.hg +++ b/gio/src/action.hg @@ -164,7 +164,7 @@ public: //This is just here to maintain API compatibility, //by stopping the compiler from calling the - //regular change_state() with a Variant, + //regular activate() with a Variant, //if the application code previously called activate(VariantBase). template void activate(const Glib::Variant& parameter); @@ -175,8 +175,21 @@ public: _WRAP_METHOD(static bool name_is_valid(const Glib::ustring& action_name), g_action_name_is_valid ) - //TODO: _WRAP_METHOD(static bool parse_detailed_name(const Glib::ustring& detailed_name, gchar** action_name, GVariant** target_value), g_action_parse_detailed_name, errthrow) + /** Parses a detailed action name into its separate name and target components. + * + * Detailed action names can have three formats. See parse_detailed_name_variant(). + * + * @newin{2,40} + * @param detailed_name A detailed action name. + * @param[out] action_name The action name. + * @param[out] target_value The target value. + * @throw Glib::VariantParseError if @a detailed_name has an invalid format or a target of an unexpected type. + */ + template + static void parse_detailed_name(const Glib::ustring& detailed_name, Glib::ustring& action_name, T_Value& target_value); + _WRAP_METHOD(static void parse_detailed_name_variant(const Glib::ustring& detailed_name, + Glib::ustring& action_name{>>}, Glib::VariantBase& target_value{>>}), g_action_parse_detailed_name, errthrow) /** Formats a detailed action name from the action's action_name and @a target_value. * @@ -191,9 +204,9 @@ public: * @result A detailed format string. */ template - Glib::ustring print_detailed_name(const T_Value& value); + Glib::ustring print_detailed_name(const T_Value& target_value); - _WRAP_METHOD(static Glib::ustring print_detailed_name_variant(const Glib::ustring& action_name, const Glib::VariantBase& parameter), g_action_print_detailed_name) + _WRAP_METHOD(static Glib::ustring print_detailed_name_variant(const Glib::ustring& action_name, const Glib::VariantBase& target_value), g_action_print_detailed_name) _WRAP_PROPERTY("enabled", bool) _WRAP_PROPERTY("name", Glib::ustring) @@ -254,15 +267,45 @@ void Action::get_state_hint(T_Value& value) const value = variantDerived.get(); } +#ifndef DOXYGEN_SHOULD_SKIP_THIS +// Doxygen 1.8.4 does not understand that this is the static function previously declared. +template +//static +void Action::parse_detailed_name(const Glib::ustring& detailed_name, Glib::ustring& action_name, T_Value& target_value) +{ + action_name.clear(); //Make sure the output arguments are initialized. + target_value = T_Value(); + + typedef Glib::Variant type_glib_variant; + + Glib::VariantBase target_value_variantBase; + parse_detailed_name_variant(detailed_name, action_name, target_value_variantBase); + + if (!target_value_variantBase) + throw Glib::VariantParseError(Glib::VariantParseError::TYPE_ERROR, + "Detailed action name '" + detailed_name + "' has no target. Expected a target of type " + + type_glib_variant::variant_type().get_string()); + + if (!target_value_variantBase.is_of_type(type_glib_variant::variant_type())) + throw Glib::VariantParseError(Glib::VariantParseError::TYPE_ERROR, + "Detailed action name '" + detailed_name + "' has a target of type " + + target_value_variantBase.get_type_string() + ". Expected " + type_glib_variant::variant_type().get_string()); + + const type_glib_variant target_value_variantDerived = + target_value_variantBase.cast_dynamic(target_value_variantBase); + target_value = target_value_variantDerived.get(); +} +#endif /* DOXYGEN_SHOULD_SKIP_THIS */ + template -Glib::ustring Action::print_detailed_name(const T_Value& parameter) +Glib::ustring Action::print_detailed_name(const T_Value& target_value) { typedef Glib::Variant type_glib_variant; 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 print_detailed_name_variant(get_name(), type_glib_variant::create(parameter)); + return print_detailed_name_variant(get_name(), type_glib_variant::create(target_value)); } template @@ -297,7 +340,7 @@ void Action::activate(const T_Value& parameter) template void Action::activate(const Glib::Variant& value) { - activate(value); + activate_variant(value); } diff --git a/gio/src/actionmap.hg b/gio/src/actionmap.hg index 4400a68..3fb7332 100644 --- a/gio/src/actionmap.hg +++ b/gio/src/actionmap.hg @@ -68,7 +68,6 @@ public: * and adding it to the ActionMap. * * @param name The name of the Action. - * @param slot The callback method to be called when the action is activated. * @return The Action. */ Glib::RefPtr add_action(const Glib::ustring& name); diff --git a/gio/src/application.hg b/gio/src/application.hg index c821150..d8d02ef 100644 --- a/gio/src/application.hg +++ b/gio/src/application.hg @@ -29,6 +29,7 @@ #include #include #include +#include _DEFS(giomm,gio) _PINCLUDE(glibmm/private/object_p.h) @@ -133,6 +134,7 @@ public: //Renamed from register() because that is a C++ keyword. _WRAP_METHOD(bool register_application(const Glib::RefPtr& cancellable{?}), g_application_register, errthrow) + _IGNORE(g_application_impl_register) _WRAP_METHOD(void hold(), g_application_hold) _WRAP_METHOD(void release(), g_application_release) @@ -193,6 +195,9 @@ public: _WRAP_METHOD(void mark_busy(), g_application_mark_busy) _WRAP_METHOD(void unmark_busy(), g_application_unmark_busy) + _WRAP_METHOD(void send_notification(const Glib::ustring& id{?}, const Glib::RefPtr& notification), g_application_send_notification) + _WRAP_METHOD(void withdraw_notification(const Glib::ustring& id), g_application_withdraw_notification) + _WRAP_PROPERTY("action-group", Glib::RefPtr) _WRAP_PROPERTY("application-id", Glib::ustring) _WRAP_PROPERTY("flags", ApplicationFlags) diff --git a/gio/src/cancellable.hg b/gio/src/cancellable.hg index 4ca5df5..2fcd58b 100644 --- a/gio/src/cancellable.hg +++ b/gio/src/cancellable.hg @@ -64,9 +64,6 @@ public: g_cancellable_pop_current) _WRAP_METHOD(void reset(), g_cancellable_reset) - // TODO: is this useful in the C++ API? - //_WRAP_METHOD(void make_pollfd(PollFD* pollfd), g_cancellable_make_pollfd) - /** Convenience function to connect to the Cancellable::signal_cancelled() * signal. Also handles the race condition that may happen * if the cancellable is cancelled right before connecting. diff --git a/gio/src/dbusconnection.hg b/gio/src/dbusconnection.hg index 0f8dc83..065db96 100644 --- a/gio/src/dbusconnection.hg +++ b/gio/src/dbusconnection.hg @@ -785,6 +785,7 @@ public: /** Finishes an operation started with call() (with a UnixFDList). * @param res A AsyncResult obtained from the SlotAsyncReady passed to * call(). + * @param out_fd_list Return location for a UnixFDList. * @result A Variant tuple with return values. * @throw Glib::Error. * @newin{2,34} diff --git a/gio/src/dbusmessage.hg b/gio/src/dbusmessage.hg index 3ca2511..71b9c89 100644 --- a/gio/src/dbusmessage.hg +++ b/gio/src/dbusmessage.hg @@ -65,15 +65,15 @@ public: // See here about whether the parameters should be ustring or std::string: // http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names // They are generally UTF-8 that can only contain the ASCII subset, - // so ustring still seems preferrable to std::string, which generally implies an unknown endoding for us. + // so ustring still seems preferrable to std::string, which generally implies an unknown encoding for us. _WRAP_METHOD(static Glib::RefPtr create_signal(const Glib::ustring& path, const Glib::ustring& interface, const Glib::ustring& signal), g_dbus_message_new_signal) _WRAP_METHOD(static Glib::RefPtr create_method_call(const Glib::ustring& name, const Glib::ustring& path, const Glib::ustring& interface, const Glib::ustring& method), g_dbus_message_new_method_call) _WRAP_METHOD(static Glib::RefPtr create_method_reply(const Glib::RefPtr& method_call_message), g_dbus_message_new_method_reply) _WRAP_METHOD(static Glib::RefPtr create_method_error_literal(const Glib::RefPtr& method_call_message, const Glib::ustring& error_name, const Glib::ustring& error_message), g_dbus_message_new_method_error_literal) - // Ignore variable argument function. - _IGNORE(g_dbus_message_new_method_error) + // Ignore variable argument functions. + _IGNORE(g_dbus_message_new_method_error, g_dbus_message_new_method_error_valist) _WRAP_METHOD(static Glib::RefPtr create_from_blob(const guchar* blob, gsize blob_len, CapabilityFlags capabilities = CAPABILITY_FLAGS_NONE), g_dbus_message_new_from_blob, errthrow) @@ -128,8 +128,6 @@ public: _WRAP_METHOD(guint32 get_num_unix_fds() const, g_dbus_message_get_num_unix_fds) _WRAP_METHOD(void set_num_unix_fds(guint32 value), g_dbus_message_set_num_unix_fds) - //TODO: _WRAP_METHOD(std::vector) get_header_fields() const, g_dbus_message_get_header_fields) - /** Gets a header field on the message. The header is returned in @a value. * @param value Location in which to store the header. * @param header_field The header field type. diff --git a/gio/src/dbusproxy.hg b/gio/src/dbusproxy.hg index 298f9b2..0f79156 100644 --- a/gio/src/dbusproxy.hg +++ b/gio/src/dbusproxy.hg @@ -370,6 +370,7 @@ public: /** Finishes an operation started with call() (with a UnixFDList). * @param res A AsyncResult obtained from the SlotAsyncReady passed to * call(). + * @param out_fd_list Return location for a UnixFDList. * @result A Variant tuple with return values. * @throw Glib::Error. * @newin{2,34} diff --git a/gio/src/file.hg b/gio/src/file.hg index b01d0e8..7df94c3 100644 --- a/gio/src/file.hg +++ b/gio/src/file.hg @@ -220,7 +220,7 @@ public: void read_async(const SlotAsyncReady& slot, int io_priority = Glib::PRIORITY_DEFAULT); _IGNORE(g_file_read_async) - _WRAP_METHOD(Glib::RefPtr read_finish(const Glib::RefPtr& result), + _WRAP_METHOD(Glib::RefPtr read_finish(const Glib::RefPtr& res), g_file_read_finish, errthrow) @@ -410,6 +410,7 @@ public: * name is to longa Gio::Error with FILENAME_TOO_LONG will be thrown. Other errors are possible too, and * depend on what kind of filesystem the file is on. * + * @param cancellable A Cancellable object which can be used to cancel the operation. * @param etag An optional entity tag for the current Glib::File. * @param make_backup true if a backup should be created. * @param flags A set of FileCreateFlags. @@ -717,7 +718,7 @@ public: * be a comma-separated list of attribute or attribute wildcards. The wildcard "*" * means all attributes, and a wildcard like "standard::*" means all attributes in the standard * namespace. An example attribute query be "standard::*,owner::user". - * The standard attributes are available as defines, like #G_FILE_ATTRIBUTE_STANDARD_NAME. + * The standard attributes are available as defines, like G_FILE_ATTRIBUTE_STANDARD_NAME. * * The operation can be cancelled by * triggering the cancellable object from another thread. If the operation @@ -750,7 +751,7 @@ public: * be a comma-separated list of attribute or attribute wildcards. The wildcard "*" * means all attributes, and a wildcard like "standard::*" means all attributes in the standard * namespace. An example attribute query be "standard::*,owner::user". - * The standard attributes are available as defines, like #G_FILE_ATTRIBUTE_STANDARD_NAME. + * The standard attributes are available as defines, like G_FILE_ATTRIBUTE_STANDARD_NAME. * * For symlinks, normally the information about the target of the * symlink is returned, rather than information about the symlink itself. @@ -782,7 +783,7 @@ public: * directory, or symlink. * * @param flags: a set of FileQueryInfoFlags passed to query_info(). - * @results The FileType of the file, or FILE_TYPE_UNKNOWN if the file does not exist. + * @result The FileType of the file, or FILE_TYPE_UNKNOWN if the file does not exist. * * @newin{2,18} */ @@ -1098,7 +1099,7 @@ public: g_file_trash, errthrow) - /** Asynchronously sends @file to the Trash location, if possible. + /** Asynchronously sends the file to the Trash location, if possible. * * @param slot_ready A SlotAsyncReady to call when the request is satisfied * @param cancellable A Cancellable object which can be used to cancel the operation @@ -1107,7 +1108,7 @@ public: */ void trash_async(const SlotAsyncReady& slot_ready, const Glib::RefPtr& cancellable, int io_priority = Glib::PRIORITY_DEFAULT); - /** Asynchronously sends @file to the Trash location, if possible. + /** Asynchronously sends the file to the Trash location, if possible. * * @param slot_ready A SlotAsyncReady to call when the request is satisfied * @param io_priority The I/O priority of the request @@ -1815,7 +1816,7 @@ public: //We ignore the gboolean result, because we throw an exception if it is false. /** Recursively measures the disk usage of the file. * - * This is essentially an analog of the 'du' command, + * This is essentially an analog of the 'du' command, * but it also reports the number of directories and non-directory files * encountered (including things like symbolic links). * @@ -1835,7 +1836,7 @@ public: * If the operation was cancelled, a Gio::Error with CANCELLED will be thrown. * * @param cancellable A Cancellable object which can be used to cancel the operation - * @param progress_callback A SlotFileMeasureProgress to call periodically while scanning. + * @param slot_progress A SlotFileMeasureProgress to call periodically while scanning. * @param disk_usage The number of bytes of disk space used. * @param num_dirs The number of directories encountered. * @param num_files The number of non-directories encountered. @@ -1858,7 +1859,7 @@ public: * @param flags Set of FileMeasureFlags * @param io_priority The I/O priority of the request */ - void measure_disk_usage_async(const SlotAsyncReady& slot_ready, const Glib::RefPtr& cancellable, const SlotFileMeasureProgress& slot, FileMeasureFlags flags = FILE_MEASURE_NONE, int io_priority = Glib::PRIORITY_DEFAULT); + void measure_disk_usage_async(const SlotAsyncReady& slot_ready, const Glib::RefPtr& cancellable, const SlotFileMeasureProgress& slot_progress, FileMeasureFlags flags = FILE_MEASURE_NONE, int io_priority = Glib::PRIORITY_DEFAULT); _IGNORE(g_file_measure_disk_usage_async) _WRAP_METHOD(bool measure_disk_usage_finish(const Glib::RefPtr& result, guint64& disk_usage, guint64& num_dirs, guint64& num_files), g_file_measure_disk_usage_finish, errthrow) @@ -2350,7 +2351,7 @@ public: * @param new_etag A location of a new entity tag * for the document. */ - void replace_contents_finish(const Glib::RefPtr& result, std::string& etag); + void replace_contents_finish(const Glib::RefPtr& result, std::string& new_etag); /** Finishes an asynchronous replace of the given file . See * replace_contents_async(). Sets @a new_etag to the new entity diff --git a/gio/src/fileattributeinfo.hg b/gio/src/fileattributeinfo.hg index 710e153..7d5c92b 100644 --- a/gio/src/fileattributeinfo.hg +++ b/gio/src/fileattributeinfo.hg @@ -26,11 +26,9 @@ _DEFS(giomm,gio) namespace Gio { -//TODO: Fix the need for NO_GTYPE. -//It guesses gfile_attribute_type_get_type() instead of g_file_attribute_type_get_type(). murrayc. -_WRAP_ENUM(FileAttributeType, GFileAttributeType, NO_GTYPE) -_WRAP_ENUM(FileAttributeInfoFlags, GFileAttributeInfoFlags, NO_GTYPE) -_WRAP_ENUM(FileAttributeStatus, GFileAttributeStatus, NO_GTYPE) +_WRAP_ENUM(FileAttributeType, GFileAttributeType) +_WRAP_ENUM(FileAttributeInfoFlags, GFileAttributeInfoFlags) +_WRAP_ENUM(FileAttributeStatus, GFileAttributeStatus) /** Information about a specific attribute - see FileAttributeInfoList. diff --git a/gio/src/fileinfo.hg b/gio/src/fileinfo.hg index d75d849..d10eb68 100644 --- a/gio/src/fileinfo.hg +++ b/gio/src/fileinfo.hg @@ -136,7 +136,7 @@ public: _WRAP_METHOD(bool set_attribute_status(const std::string& attribute, FileAttributeStatus status), g_file_info_set_attribute_status) //TODO: This should take a ustring value instead: https://bugzilla.gnome.org/show_bug.cgi?id=615950#c7 - _WRAP_METHOD(void set_attribute_string(const std::string& attribute, const std::string& value), + _WRAP_METHOD(void set_attribute_string(const std::string& attribute, const std::string& attr_value), g_file_info_set_attribute_string) #m4 _CONVERSION(`const std::vector&',`char**',`const_cast(Glib::ArrayHandler::vector_to_array($3).data())') diff --git a/gio/src/filelist.am b/gio/src/filelist.am index fbc0e33..e2a545f 100644 --- a/gio/src/filelist.am +++ b/gio/src/filelist.am @@ -88,6 +88,7 @@ giomm_files_any_hg = \ mountoperation.hg \ networkaddress.hg \ networkservice.hg \ + notification.hg \ outputstream.hg \ pollableinputstream.hg \ pollableoutputstream.hg \ diff --git a/gio/src/gio_methods.defs b/gio/src/gio_methods.defs index bb4080b..cb4454b 100644 --- a/gio/src/gio_methods.defs +++ b/gio/src/gio_methods.defs @@ -1951,7 +1951,7 @@ (return-type "gchar*") (parameters '("const-gchar*" "action_name") - '("GVariant*" "parameter") + '("GVariant*" "target_value") ) ) @@ -8446,7 +8446,7 @@ (c-name "g_file_replace_contents_bytes_async") (return-type "none") (parameters - '("GBytes*" "bytes") + '("GBytes*" "contents") '("const-char*" "etag") '("gboolean" "make_backup") '("GFileCreateFlags" "flags") @@ -14194,7 +14194,7 @@ (c-name "g_settings_schema_get_key") (return-type "GSettingsSchemaKey*") (parameters - '("const-gchar*" "key") + '("const-gchar*" "name") ) ) @@ -14203,7 +14203,7 @@ (c-name "g_settings_schema_has_key") (return-type "gboolean") (parameters - '("const-gchar*" "key") + '("const-gchar*" "name") ) ) @@ -18823,7 +18823,7 @@ (parameters '("const-gchar*" "thumbnail_path") '("const-gchar*" "file_uri") - '("const-GStatBuf*" "file_stat_buf") + '("const-GLocalFileStat*" "file_stat_buf") ) ) diff --git a/gio/src/inputstream.hg b/gio/src/inputstream.hg index 7065303..64c53c4 100644 --- a/gio/src/inputstream.hg +++ b/gio/src/inputstream.hg @@ -41,6 +41,7 @@ namespace Gio class InputStream : public Glib::Object { _CLASS_GOBJECT(InputStream, GInputStream, G_INPUT_STREAM, Glib::Object, GObject) + _IGNORE(g_input_stream_async_read_is_via_threads) dnl// private method public: _WRAP_METHOD(gssize read(void* buffer, gsize count, const Glib::RefPtr& cancellable{?}), diff --git a/gio/src/memoryinputstream.ccg b/gio/src/memoryinputstream.ccg index 0801e02..0dfd768 100644 --- a/gio/src/memoryinputstream.ccg +++ b/gio/src/memoryinputstream.ccg @@ -19,16 +19,55 @@ #include +namespace +{ + +class SlotWithData +{ +public: + SlotWithData(const Gio::MemoryInputStream::SlotDestroyData& slot, void* data) + : + m_slot(new Gio::MemoryInputStream::SlotDestroyData(slot)), m_data(data) + { } + + ~SlotWithData() { delete m_slot; } + + void operator()() { (*m_slot)(m_data); } + +private: + Gio::MemoryInputStream::SlotDestroyData* m_slot; + void* m_data; +}; + +void destroy_data_callback(void* user_data) +{ + SlotWithData* slot_with_data = static_cast(user_data); + g_return_if_fail(slot_with_data != 0); + + try + { + (*slot_with_data)(); // Invoke callback + } + catch (...) + { + Glib::exception_handlers_invoke(); + } + + delete slot_with_data; +} + +} // anonymous namespace + namespace Gio { +_DEPRECATE_IFDEF_START void MemoryInputStream::add_data(const std::string& data) { char *data_copy = g_strdup (data.c_str ()); g_memory_input_stream_add_data(gobj(), data_copy, -1, g_free); } - void MemoryInputStream::add_data(const void* data, gssize len) { char *data_copy = 0; @@ -41,10 +80,14 @@ void MemoryInputStream::add_data(const void* data, gssize len) g_memory_input_stream_add_data(gobj(), data_copy, len, g_free); } +_DEPRECATE_IFDEF_END -void MemoryInputStream::add_data(const void* data, gssize len, GDestroyNotify destroy) +void MemoryInputStream::add_data(const void* data, gssize len, const SlotDestroyData& destroy_slot) { - g_memory_input_stream_add_data(gobj(), data, len, destroy); + SlotWithData* slot_with_data = new SlotWithData(destroy_slot, const_cast(data)); + GBytes* bytes = g_bytes_new_with_free_func(data, len, &destroy_data_callback, slot_with_data); + g_memory_input_stream_add_bytes(gobj(), bytes); + g_bytes_unref(bytes); // g_memory_input_stream_add_bytes() takes a reference } } // namespace Gio diff --git a/gio/src/memoryinputstream.hg b/gio/src/memoryinputstream.hg index 925303a..eee7161 100644 --- a/gio/src/memoryinputstream.hg +++ b/gio/src/memoryinputstream.hg @@ -46,31 +46,47 @@ protected: public: _WRAP_CREATE() +_DEPRECATE_IFDEF_START /** Appends to data that can be read from the input stream. * * @param data Input data. + * + * @deprecated Use add_data() with SlotDestroyData or GDestroyNotify instead. */ void add_data(const std::string& data); /** Appends to data that can be read from the input stream. * - * Note that the data will copied internally and freed when no longer needed. + * Note that the data will be copied internally and freed when no longer needed. * * @param data Input data. * @param len Length of the data, may be -1 if data is a null-terminated string. * - * @deprecated Use version with destroy notification + * @deprecated Use add_data() with SlotDestroyData or GDestroyNotify instead. */ void add_data(const void* data, gssize len); +_DEPRECATE_IFDEF_END + + _WRAP_METHOD(void add_data(const void* data, gssize len, GDestroyNotify destroy), g_memory_input_stream_add_data) + + /** For example, + * void on_destroy_data(void* data); + * + * @param data The data to free. + * + * @newin{2,40} + */ + typedef sigc::slot SlotDestroyData; /** Appends to data that can be read from the input stream. * * @param data Input data. * @param len Length of the data, may be -1 if data is a null-terminated string. - * @param destroy A function to be called to free the data when it is no - * longer needed + * @param destroy_slot A slot to be called to free the data when it is no longer needed. + * + * @newin{2,40} */ - void add_data(const void* data, gssize len, GDestroyNotify destroy); + void add_data(const void* data, gssize len, const SlotDestroyData& destroy_slot); }; } // namespace Gio diff --git a/gio/src/menuitem.hg b/gio/src/menuitem.hg index 31eeae0..258aba9 100644 --- a/gio/src/menuitem.hg +++ b/gio/src/menuitem.hg @@ -55,7 +55,7 @@ protected: * set_submenu(). * * @param label The section label. - * @param A MenuModel with the items of the submenu. + * @param submenu A MenuModel with the items of the submenu. */ explicit MenuItem(const Glib::ustring& label, const Glib::RefPtr& submenu); @@ -64,7 +64,7 @@ protected: * This is a convenience API around the MenuItem(label, detailed_action) constructor and * set_submenu(). * - * @param A MenuModel with the items of the submenu. + * @param submenu A MenuModel with the items of the submenu. */ explicit MenuItem(const Glib::RefPtr& submenu); _IGNORE(g_menu_item_new_submenu) @@ -126,7 +126,7 @@ GMenuItem * g_menu_item_new_section (const Glib::ustring& label, _DEPRECATE_IFDEF_START /** Unsets the target for the specified @a action. - * @deprecate Use set_action() or unset_target() instead. + * @deprecated Use set_action() or unset_target() instead. */ void set_action_and_target(const Glib::ustring& action); _DEPRECATE_IFDEF_END @@ -148,7 +148,7 @@ _DEPRECATE_IFDEF_END /** Unsets the action and target for the menu item. * See set_action_and_target(). * - * @newin{2,38}. + * @newin{2,38} */ void unset_action_and_target(); diff --git a/gio/src/menumodel.hg b/gio/src/menumodel.hg index 729b9c2..696e8f5 100644 --- a/gio/src/menumodel.hg +++ b/gio/src/menumodel.hg @@ -164,8 +164,8 @@ dnl See the .ccg implementation for how this conversion works. _WRAP_METHOD(void items_changed(int position, int removed, int added), g_menu_model_items_changed) - //TODO: The "items-changed" signal cannot be wrapped because it is not - //included in the *Class declaration of GMenuModel. + // The items-changed signal can't have a default handler in glibmm, because it does not have one in glib. + _WRAP_SIGNAL(void items_changed(int position, int removed, int added), "items-changed", no_default_handler) }; } // namespace Gio diff --git a/gio/src/mount.hg b/gio/src/mount.hg index 8f29973..18c03b0 100644 --- a/gio/src/mount.hg +++ b/gio/src/mount.hg @@ -106,6 +106,7 @@ public: * @param operation A mount operation. * @param slot A callback which will be called when the operation is completed or canceled. * @param cancellable A cancellable object which can be used to cancel the operation. + * @param flags Flags affecting the operation. */ void remount(const Glib::RefPtr& operation, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountMountFlags flags = MOUNT_MOUNT_NONE); diff --git a/gio/src/notification.ccg b/gio/src/notification.ccg new file mode 100644 index 0000000..0578395 --- /dev/null +++ b/gio/src/notification.ccg @@ -0,0 +1,31 @@ +/* Copyright (C) 2014 The giomm 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 . + */ + +#include +#include +#include + +namespace Gio +{ + +Notification::Notification(const Glib::ustring& title) +: _CONSTRUCT() +{ + // The title is compulsory. Don't skip it, if it's empty. + set_title(title); +} + +} // namespace Gio diff --git a/gio/src/notification.hg b/gio/src/notification.hg new file mode 100644 index 0000000..674bd4e --- /dev/null +++ b/gio/src/notification.hg @@ -0,0 +1,133 @@ +/* Copyright (C) 2014 The giomm 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 . + */ + +#include +#include +#include + +_DEFS(giomm,gio) +_PINCLUDE(glibmm/private/object_p.h) + +namespace Gio +{ +class Icon; + +/** User Notifications (pop up messages). + * + * Gio::Notification is a mechanism for creating a notification to be shown + * to the user -- typically as a pop-up notification presented by the + * desktop environment shell. + * + * The key difference between Notification and other similar APIs is + * that, if supported by the desktop environment, notifications sent + * with Notification will persist after the application has exited, + * and even across system reboots. + * + * Since the user may click on a notification while the application is + * not running, applications using Notification should be able to be + * started as a D-Bus service, using Gio::Application. + * + * User interaction with a notification (either the default action, or + * buttons) must be associated with actions on the application (ie: + * "app." actions). It is not possible to route user interaction + * through the notification itself, because the object will not exist if + * the application is autostarted as a result of a notification being + * clicked. + * + * A notification can be sent with Gio::Application::send_notification(). + * + * @newin{2,40} + */ +class Notification : public Glib::Object +{ + _CLASS_GOBJECT(Notification, GNotification, G_NOTIFICATION, Glib::Object, GObject) + +protected: + // Can't use _WRAP_CTOR. GNotification has no properties, but it must have a title. + explicit Notification(const Glib::ustring& title); + _IGNORE(g_notification_new) + +public: + _WRAP_METHOD_DOCS_ONLY(g_notification_new) + _WRAP_CREATE(const Glib::ustring& title) + + _WRAP_METHOD(void set_title(const Glib::ustring& title), g_notification_set_title) + _WRAP_METHOD(void set_body(const Glib::ustring& body), g_notification_set_body) + _WRAP_METHOD(void set_icon(const Glib::RefPtr& icon), g_notification_set_icon) + _WRAP_METHOD(void set_urgent(bool urgent = true), g_notification_set_urgent) + + _WRAP_METHOD(void add_button(const Glib::ustring& label, const Glib::ustring& detailed_action), g_notification_add_button) + + /** Adds a button that activates @a action when clicked. + * @a action must be an application-wide action (it must start with "app."). + * @a action will be activated with @a target as its parameter. + * + * @newin{2,40} + * @param label Label of the button. + * @param action An action name. + * @param target @a action's parameter. + */ + template + void add_button(const Glib::ustring& label, const Glib::ustring& action, const T_Value& target); + + _WRAP_METHOD(void add_button_variant(const Glib::ustring& label, const Glib::ustring& action, const Glib::VariantBase& target), g_notification_add_button_with_target_value) + + _WRAP_METHOD(void set_default_action(const Glib::ustring& detailed_action), g_notification_set_default_action) + + /** Sets the default action to @a action. + * This action is activated when the notification is clicked on. It must be an + * application-wide action (start with "app."). + * @a action will be activated with @a target as its parameter. + * + * When no default action is set, the application that the notification + * was sent on is activated. + * + * @newin{2,40} + * @param action An action name. + * @param target @a action's parameter. + */ + template + void set_default_action(const Glib::ustring& action, const T_Value& target); + + _WRAP_METHOD(void set_default_action_variant(const Glib::ustring& action, const Glib::VariantBase& target), g_notification_set_default_action_and_target_value) + + // Ignore functions with variable-length parameter lists. + _IGNORE(g_notification_add_button_with_target, g_notification_set_default_action_and_target) + // Ignore private methods + _IGNORE(g_notification_get_urgent, g_notification_get_button, g_notification_get_default_action) + _IGNORE(g_notification_get_n_buttons, g_notification_get_button_with_action, g_notification_serialize) + _IGNORE(g_notification_get_icon, g_notification_get_id, g_notification_get_body, g_notification_get_title) + + // There are no properties, signals, vfuncs. +}; + +template +void Notification::add_button(const Glib::ustring& label, const Glib::ustring& action, const T_Value& target) +{ + typedef Glib::Variant type_glib_variant; + + add_button_variant(label, action, type_glib_variant::create(target)); +} + +template +void Notification::set_default_action(const Glib::ustring& action, const T_Value& target) +{ + typedef Glib::Variant type_glib_variant; + + set_default_action_variant(action, type_glib_variant::create(target)); +} + +} // namespace Gio diff --git a/gio/src/outputstream.hg b/gio/src/outputstream.hg index 39b27e4..d13992f 100644 --- a/gio/src/outputstream.hg +++ b/gio/src/outputstream.hg @@ -39,6 +39,7 @@ _WRAP_ENUM(OutputStreamSpliceFlags, GOutputStreamSpliceFlags, NO_GTYPE) class OutputStream : public Glib::Object { _CLASS_GOBJECT(OutputStream, GOutputStream, G_OUTPUT_STREAM, Glib::Object, GObject) + _IGNORE(g_output_stream_async_write_is_via_threads) dnl// private method public: diff --git a/gio/src/settings.hg b/gio/src/settings.hg index ff060f4..74554fa 100644 --- a/gio/src/settings.hg +++ b/gio/src/settings.hg @@ -92,7 +92,7 @@ public: _WRAP_METHOD(Glib::RefPtr get_child(const Glib::ustring& name), g_settings_get_child) _WRAP_METHOD(Glib::RefPtr get_child(const Glib::ustring& name) const, g_settings_get_child, constversion) - _WRAP_METHOD(bool is_writable(const Glib::ustring& key) const, g_settings_is_writable) + _WRAP_METHOD(bool is_writable(const Glib::ustring& name) const, g_settings_is_writable) _WRAP_METHOD(void delay(), g_settings_delay) _WRAP_METHOD(void apply(), g_settings_apply) diff --git a/gio/src/simpleaction.hg b/gio/src/simpleaction.hg index 0a5059a..4765674 100644 --- a/gio/src/simpleaction.hg +++ b/gio/src/simpleaction.hg @@ -50,7 +50,6 @@ protected: * The created action is stateless. * * @param name The name of the action. - * @param state The initial state of the action. */ explicit SimpleAction(const Glib::ustring& name); @@ -120,6 +119,7 @@ public: * * @newin{2,38} * @param name The name of the action. + * @param initial_state The initial state of the action. * @return A new SimpleAction. */ static Glib::RefPtr create_radio_string(const Glib::ustring& name, const Glib::ustring& initial_state); @@ -135,9 +135,10 @@ public: * * @newin{2,38} * @param name The name of the action. + * @param initial_state The initial state of the action. * @return A new SimpleAction. */ - static Glib::RefPtr create_radio_integer(const Glib::ustring& name, gint32 inital_state); + static Glib::RefPtr create_radio_integer(const Glib::ustring& name, gint32 initial_state); _WRAP_METHOD(void set_enabled(bool enabled = true), g_simple_action_set_enabled) diff --git a/gio/src/socketconnection.hg b/gio/src/socketconnection.hg index 2e8b859..f154386 100644 --- a/gio/src/socketconnection.hg +++ b/gio/src/socketconnection.hg @@ -51,7 +51,8 @@ namespace Gio */ class SocketConnection : public Gio::IOStream { - _CLASS_GOBJECT(SocketConnection, GSocketConnection, G_SOCKET_CONNECTION, Gio::IOStream, GIOStream) + _CLASS_GOBJECT(SocketConnection, GSocketConnection, G_SOCKET_CONNECTION, Gio::IOStream, GIOStream) + _IGNORE(g_socket_connection_set_cached_remote_address) dnl// private method public: _WRAP_METHOD(bool connect(const Glib::RefPtr& address, const Glib::RefPtr& cancellable{?}), g_socket_connection_connect, errthrow) diff --git a/gio/src/threadedsocketservice.hg b/gio/src/threadedsocketservice.hg index 82b3565..d14a545 100644 --- a/gio/src/threadedsocketservice.hg +++ b/gio/src/threadedsocketservice.hg @@ -30,7 +30,7 @@ namespace Gio * * A ThreadedSocketService is a simple subclass of SocketService * that handles incoming connections by creating a worker thread and - * dispatching the connection to it by emitting the ::run signal in + * dispatching the connection to it by emitting the run signal in * the new thread. * * The signal handler may perform blocking IO and need not return @@ -41,7 +41,7 @@ namespace Gio * The service automatically stops the SocketService from accepting * new connections when all threads are busy. * - * As with SocketService, you may connect to ThreadedSocketService:run, + * As with SocketService, you may connect to ThreadedSocketService::signal_run(), * or subclass and override the default handler. * * @newin{2,24} diff --git a/glib/glibmm/base64.h b/glib/glibmm/base64.h index 96ad384..d5ec413 100644 --- a/glib/glibmm/base64.h +++ b/glib/glibmm/base64.h @@ -38,7 +38,7 @@ namespace Base64 * line breaking, that is usually used in mail systems. The new line * character will appear for every 72 bytes. * @param source A string to encode. - * @param line_break Enables/disables line breaking. + * @param break_lines Enables/disables line breaking. * @return The string encoded in Base-64. */ std::string encode(const std::string& source, bool break_lines = false); diff --git a/glib/glibmm/refptr.h b/glib/glibmm/refptr.h index 541a1bc..7b11a75 100644 --- a/glib/glibmm/refptr.h +++ b/glib/glibmm/refptr.h @@ -59,7 +59,7 @@ public: /// Destructor - decrements reference count. inline ~RefPtr(); - /// For use only by the ::create() methods. + /// For use only by the \::create() methods. explicit inline RefPtr(T_CppObject* pCppObject); /** Copy constructor diff --git a/glib/src/bytes.hg b/glib/src/bytes.hg index 1c81e61..255c668 100644 --- a/glib/src/bytes.hg +++ b/glib/src/bytes.hg @@ -39,7 +39,7 @@ namespace Glib /** A simple refcounted data type representing an immutable byte sequence * from an unspecified origin. * - * The purpose of a the Bytes class is to keep the memory region that it holds + * The purpose of the Bytes class is to keep the memory region that it holds * alive for as long as anyone holds a reference to the bytes. When * the last reference count is dropped, the memory is released. Multiple * unrelated callers can use byte data in the Bytes object without coordinating @@ -60,6 +60,7 @@ class Bytes public: static Glib::RefPtr create(gconstpointer data, gsize size); + _IGNORE(g_bytes_new_from_bytes, g_bytes_unref_to_data, g_bytes_unref_to_array) _WRAP_METHOD(gconstpointer get_data(gsize& size) const, g_bytes_get_data) _WRAP_METHOD(gsize get_size() const, g_bytes_get_size) diff --git a/glib/src/module.hg b/glib/src/module.hg index afa2bcd..65f7f87 100644 --- a/glib/src/module.hg +++ b/glib/src/module.hg @@ -41,7 +41,7 @@ _WRAP_ENUM(ModuleFlags, GModuleFlags, NO_GTYPE) class Module { _CLASS_GENERIC(Module, GModule) - _IGNORE(g_module_open, g_module_close) + _IGNORE(g_module_open, g_module_open_utf8, g_module_close) public: @@ -106,6 +106,7 @@ public: * @returns The name of the module */ _WRAP_METHOD(std::string get_name() const, g_module_name) + _IGNORE(g_module_name_utf8) /** A portable way to build the filename of a module. The * platform-specific prefix and suffix are added to the filename, if @@ -117,7 +118,7 @@ public: * module is in a standard platform-specific directory, though this * is not recommended since the wrong module may be found. * - * For example, calling g_module_build_path() on a Linux + * For example, calling build_path() on a Linux * system with a directory of /lib and a module_name of * "mylibrary" will return /lib/libmylibrary.so. On a * Windows system, using \\Windows as the directory it will diff --git a/glib/src/optioncontext.hg b/glib/src/optioncontext.hg index bc31f15..b159ff2 100644 --- a/glib/src/optioncontext.hg +++ b/glib/src/optioncontext.hg @@ -34,7 +34,55 @@ namespace Glib */ _WRAP_GERROR(OptionError, GOptionError, G_OPTION_ERROR, NO_GTYPE) -/** An OptionContext defines which options are accepted by the commandline option parser. +/** An OptionContext defines and parses commandline options, using OptionGroup%s and \link OptionEntry option entries \endlink. + * + * It supports short and long commandline options, as shown in the following example: + * + * testtreemodel -r 1 --max-size 20 --rand --display=:1.0 -vb -- file1 file2 + * + * The example demonstrates a number of features of the GOption + * commandline parser + * - Options can be single letters, prefixed by a single dash. + Multiple short options can be grouped behind a single dash. + * - Long options are prefixed by two consecutive dashes. + * - Options can have an extra argument, which can be a number, a string or + * a filename. For long options, the extra argument can be appended with + * an equals sign after the option name, which is useful if the extra + * argument starts with a dash, which would otherwise cause it to be + * interpreted as another option. + * - Non-option arguments are returned to the application as rest arguments. + * - An argument consisting solely of two dashes turns off further parsing, + * any remaining arguments (even those starting with a dash) are returned + * to the application as rest arguments. + * + * The OptionContext groups options in OptionGroups, which makes it easy to + * incorporate options from multiple sources. The intended use for this is + * to let applications collect option groups from the libraries it uses, + * add them to their OptionContext, and parse all options by a single call + * to parse(). See Gtk::Main::add_gtk_option_group(), for an example. + * + * Add options by creating OptionEntry instances and appropriately-typed variables, + * and adding them to an OptionGroup with OptionGroup::add_entry() or + * OptionGroup::add_entry_filename(). The option group should then be added to + * the OptionContext with set_main_group() or add_group(). + * + * You might find it convenient to derive your own class from OptionGroup to + * contain these OptionEntry instances and member variables. + * + * If an option is of type string (see OptionGroup::add_entry()) or filename + * (see OptionGroup::add_entry_filename()), OptionContext takes + * care of converting it to the right encoding. strings are returned in + * UTF-8 encoding and filenames are returned in the GLib filename encoding. + * Note that this only works if setlocale() has been called before + * OptionContext::parse(). + * + * OptionContext can automatically generate nicely formatted help output. Unless it is + * explicitly turned off with set_help_enabled(), this will recognize + * the --help, -?, --help-all and --help-groupname options + * (where groupname is the name of an OptionGroup) and write suitable text to + * stdout. + * + * */ class OptionContext { @@ -47,7 +95,7 @@ public: */ explicit OptionContext(const Glib::ustring& parameter_string = Glib::ustring()); - //Note that, unlike Glib::Wrap(), this would create a second C++ instance for the same C instance, + //Note that, unlike Glib::Wrap(), this would create a second C++ instance for the same C instance,u //so it should be used carefully. For instance you could not access data in a derived class via this second instance. explicit OptionContext(GOptionContext* castitem, bool take_ownership = false); virtual ~OptionContext(); @@ -60,6 +108,12 @@ 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? + //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? + //TODO? _WRAP_METHOD(bool parse(char**& argv), g_option_context_parse_strv, errthrow) + //g_option_context_add_main_entries(), just creates a group internally, adds them to it, and does a set_main_group() //- a group without callbacks seems to do some simple default parsing. _IGNORE(g_option_context_add_main_entries) diff --git a/glib/src/optionentry.hg b/glib/src/optionentry.hg index 852dff2..d77eab7 100644 --- a/glib/src/optionentry.hg +++ b/glib/src/optionentry.hg @@ -73,6 +73,7 @@ public: _MEMBER_SET(short_name, short_name, gchar, gchar) _MEMBER_GET(flags, flags, int, int) + /** Set one or more OptionEntry::Flags. * Do not set FLAG_FILENAME. Character encoding is chosen when the OptionEntry * is added to an OptionGroup. diff --git a/glib/src/optiongroup.ccg b/glib/src/optiongroup.ccg index d2f81ff..4a87564 100644 --- a/glib/src/optiongroup.ccg +++ b/glib/src/optiongroup.ccg @@ -358,7 +358,8 @@ void OptionGroup::add_entry_filename(const OptionEntry& entry, vecstrings& arg) // G_OPTION_ARG_STRING_ARRAY, and G_OPTION_ARG_FILENAME_ARRAY, which in glibmm // are set by OptionGroup::add_entry[_filename]. But when a callback function // is chosen, there is only G_OPTION_ARG_CALLBACK, and the encoding is chosen -// with G_OPTION_FLAG_FILENAME. Other option flags are set by OptionEntry::set_flags(). +// with G_OPTION_FLAG_FILENAME. We do this automatiically in set_c_arg_default(). +// Other option flags are set by OptionEntry::set_flags(). void OptionGroup::add_entry(const OptionEntry& entry, const SlotOptionArgString& slot) { diff --git a/glib/src/optiongroup.hg b/glib/src/optiongroup.hg index 7d330eb..9857208 100644 --- a/glib/src/optiongroup.hg +++ b/glib/src/optiongroup.hg @@ -83,14 +83,59 @@ public: typedef std::vector vecustrings; typedef std::vector vecstrings; + /** Add a boolean option @a entry. + * The @arg parameter will be set to the option's extra argument + * after OptionContext::parse() has returned. + */ void add_entry(const OptionEntry& entry, bool& arg); + + /** Add an integer option @a entry. + * The @arg parameter will be set to the option's extra argument + * after OptionContext::parse() has returned. + */ void add_entry(const OptionEntry& entry, int& arg); + + /** Add a double option @a entry. + * The @arg parameter will be set to the option's extra argument + * after OptionContext::parse() has returned. + */ void add_entry(const OptionEntry& entry, double& arg); + + /** Add a UTF-8 string option @a entry. + * The @arg parameter will be set to the option's extra argument + * after OptionContext::parse() has returned. + * + * As indicated by the Glib::ustring type, the string will be + * UTF-8 encoded. + */ void add_entry(const OptionEntry& entry, Glib::ustring& arg); + + /** Add a filename string option @a entry. + * The @arg parameter will be set to the option's extra argument + * after OptionContext::parse() has returned. + * + * The string will be in glib's filename encoding. + */ void add_entry_filename(const OptionEntry& entry, std::string& arg); + + /** Add an option @a entry that provides a list of UTF-8 strings. + * The @arg parameter will be set to the option's extra argument + * after OptionContext::parse() has returned. + * + * As indicated by the Glib::ustring type, the strings will be + * UTF-8 encoded. + */ void add_entry(const OptionEntry& entry, vecustrings& arg); void add_entry_filename(const OptionEntry& entry, vecstrings& arg); + + /** Add a string option @a entry, but let a callback slot parse the extra argument + * instead of just setting a variable to its value. + */ void add_entry(const OptionEntry& entry, const SlotOptionArgString& slot); + + /** Add a filename option @a entry, but let a callback slot parse the extra argument + * instead of just setting a variable to its value. + */ void add_entry_filename(const OptionEntry& entry, const SlotOptionArgFilename& slot); /** Sets the function which is used to translate user-visible strings, for diff --git a/glib/src/variant.hg b/glib/src/variant.hg index 1f905fc..1ab266e 100644 --- a/glib/src/variant.hg +++ b/glib/src/variant.hg @@ -53,7 +53,7 @@ namespace Glib * Serialised Variant data can also be sent over the network. * * Variant is largely compatible with D-Bus. Almost all types of - * #GVariant instances can be sent over D-Bus. See VariantType for + * Variant instances can be sent over D-Bus. See VariantType for * exceptions. * * There is a Python-inspired text language for describing Variant @@ -61,9 +61,10 @@ namespace Glib * with type inferencing.. */ -//Note: So far we only wrap this because it is thrown by GtkBuilder's functions. +//Note: We wrap this because it is thrown by GtkBuilder's functions. // See https://bugzilla.gnome.org/show_bug.cgi?id=708206 // It would also be thrown by parse() if we wrap g_variant_parse(). +// Now (2014-01-30) it's also thrown by Gio::Action::parse_detailed_name(). /** Exception class for Variant parse errors. */ _WRAP_GERROR(VariantParseError, GVariantParseError, G_VARIANT_PARSE_ERROR, NO_GTYPE) @@ -88,7 +89,7 @@ class VariantBase { _CLASS_OPAQUE_COPYABLE(VariantBase, GVariant, NONE, g_variant_ref_sink, g_variant_unref) _CUSTOM_CTOR_CAST() - _IGNORE(g_variant_ref, g_variant_ref_sink, g_variant_unref, + _IGNORE(g_variant_ref, g_variant_ref_sink, g_variant_take_ref, g_variant_unref, g_variant_get, g_variant_get_va) public: diff --git a/tests/Makefile.am b/tests/Makefile.am index be9c4c6..c2b0458 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -20,6 +20,7 @@ AUTOMAKE_OPTIONS = subdir-objects check_PROGRAMS = \ giomm_ioerror/test \ giomm_ioerror_and_iodbuserror/test \ + giomm_memoryinputstream/test \ giomm_simple/test \ giomm_asyncresult_sourceobject/test \ giomm_tls_client/test \ @@ -65,6 +66,9 @@ giomm_ioerror_test_LDADD = $(giomm_ldadd) giomm_ioerror_and_iodbuserror_test_SOURCES = giomm_ioerror_and_iodbuserror/main.cc giomm_ioerror_and_iodbuserror_test_LDADD = $(giomm_ldadd) +giomm_memoryinputstream_test_SOURCES = giomm_memoryinputstream/main.cc +giomm_memoryinputstream_test_LDADD = $(giomm_ldadd) + giomm_simple_test_SOURCES = giomm_simple/main.cc giomm_simple_test_LDADD = $(giomm_ldadd) diff --git a/tests/giomm_memoryinputstream/main.cc b/tests/giomm_memoryinputstream/main.cc new file mode 100644 index 0000000..813fa4e --- /dev/null +++ b/tests/giomm_memoryinputstream/main.cc @@ -0,0 +1,95 @@ +#include +#include +#include +#include +#include +#include + +namespace +{ +//Use this line if you want debug output: +//std::ostream& ostr = std::cout; + +//This seems nicer and more useful than putting an ifdef around the use of ostr: +std::ostringstream debug; +std::ostream& ostr = debug; + +std::string func1_output; +std::string func2_output; + +void destroy_func1(void* data) +{ + char* cdata = static_cast(data); + func1_output += "Deleting "; + func1_output += cdata; + delete[] cdata; +} + +void destroy_func2(void* data, const Glib::ustring& intro) +{ + char* cdata = static_cast(data); + func2_output += intro + cdata; + delete[] cdata; +} + +} // anonymous namespace + +int main(int, char**) +{ + Glib::init(); + Gio::init(); + + gchar buffer[1000]; + std::memset(buffer, 0, sizeof buffer); + try + { + Glib::RefPtr stream = Gio::MemoryInputStream::create(); + if (!stream) + { + std::cerr << "Could not create a MemoryInputStream." << std::endl; + return EXIT_FAILURE; + } + + // Add data that shall not be deleted by stream. + static const char data1[] = "Data not owned by stream.\n"; + stream->add_data(data1, sizeof data1 - 1, 0); + + // Add data that shall be deleted by destroy_func1(). + char* data2 = new char[7]; + std::strcpy(data2, "data2\n"); + stream->add_data(data2, 6, destroy_func1); + + // Add data that shall be deleted by destroy_func2(). + char* data3 = new char[7]; + std::strcpy(data3, "data3\n"); + stream->add_data(data3, 6, sigc::bind(sigc::ptr_fun(destroy_func2), "Now deleting ")); + + const gsize bytes_read = stream->read(buffer, sizeof buffer - 1); + + if (bytes_read) + ostr << "Memory contents read: " << buffer << std::endl; + else + { + std::cerr << "Gio::InputStream::read() read 0 bytes." << std::endl; + return EXIT_FAILURE; + } + } + catch (const Glib::Exception& ex) + { + std::cerr << "Exception caught: " << ex.what() << std::endl; + return EXIT_FAILURE; + } + + ostr << func1_output << std::endl; + ostr << func2_output << std::endl; + + if (std::strcmp(buffer, "Data not owned by stream.\ndata2\ndata3\n") == 0 && + func1_output == "Deleting data2\n" && + func2_output == "Now deleting data3\n") + return EXIT_SUCCESS; + + std::cerr << "buffer: \"" << buffer << "\"" << std::endl; + std::cerr << "func1_output: \"" << func1_output << "\"" << std::endl; + std::cerr << "func2_output: \"" << func2_output << "\"" << std::endl; + return EXIT_FAILURE; +} diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4 index 0cc55b9..a6f04a3 100644 --- a/tools/m4/convert_gio.m4 +++ b/tools/m4/convert_gio.m4 @@ -237,6 +237,10 @@ _CONVERSION(`PasswordSave',`GPasswordSave',`($2)$3') #MountOperation #_CONVERSION(`GAskPasswordFlags',`AskPasswordFlags',`($2)$3') +# Notification +_CONVERSION(`GNotification*',`Glib::RefPtr',`Glib::wrap($3)') +_CONVERSION(`const Glib::RefPtr&',`GNotification*',__CONVERT_CONST_REFPTR_TO_P) + # OutputStream _CONVERSION(`GOutputStream*',`Glib::RefPtr',`Glib::wrap($3)') _CONVERSION(`const Glib::RefPtr&',`GOutputStream*',__CONVERT_CONST_REFPTR_TO_P) diff --git a/tools/m4/initialize_glib.m4 b/tools/m4/initialize_glib.m4 index 47302cd..5264d98 100644 --- a/tools/m4/initialize_glib.m4 +++ b/tools/m4/initialize_glib.m4 @@ -11,3 +11,6 @@ _INITIALIZATION(`Glib::VariantBase&',`GVariant*',`$3 = Glib::wrap($4)') dnl VariantType _INITIALIZATION(`Glib::VariantType&',`const GVariantType*',`$3 = Glib::wrap(const_cast($4))') + +dnl ustring +_INITIALIZATION(`Glib::ustring&',`gchar*',`$3 = Glib::convert_return_gchar_ptr_to_ustring($4)') diff --git a/tools/pm/DocsParser.pm b/tools/pm/DocsParser.pm index db23b7e..f7c9ea7 100644 --- a/tools/pm/DocsParser.pm +++ b/tools/pm/DocsParser.pm @@ -521,9 +521,9 @@ sub convert_tags_to_doxygen($) # Doxygen is too dumb to handle — s"—" \@htmlonly—\@endhtmlonly "g; - s"\%?FALSE\b"false"g; - s"\%?TRUE\b"true"g; - s"\%?NULL\b"0"g; + s"\%?\bFALSE\b"false"g; + s"\%?\bTRUE\b"true"g; + s"\%?\bNULL\b"0"g; s"#?\bgboolean\b"bool"g; s"#?\bg(int|short|long)\b"$1"g; -- 2.7.4