summaryrefslogtreecommitdiff
path: root/glib/glibmm
Commit message (Collapse)AuthorAgeFilesLines
...
* Glib: Adding static check for template parameterPavlo Solntsev2019-11-171-0/+10
| | | | | To meet requirements for the passed type, compile type check for the passed type was added.
* fix ustring::insert(iterator, In, In)Thomas Holder2019-11-141-1/+2
|
* Glib::ustring_Iterator: Explicitly declare copy assignmentKjell Ahlstedt2019-11-031-0/+1
| | | | | | | | | | | This disables a warning from g++ 9.2 (abbreviated here): In member function ‘bool Glib::ustring::validate(Glib::ustring::iterator&)’: error: implicitly-declared ..... is deprecated [-Werror=deprecated-copy] 1206 | first_invalid = iterator(string_.begin() + (valid_end - pdata)); note: because ..... has user-provided ..... 972 | inline ustring_Iterator<T>::ustring_Iterator( const ustring_Iterator<std::string::iterator>& other)
* Glib: Replace BasicStringView with non-template StringViewKjell Ahlstedt2019-10-231-16/+20
| | | | | | | | A call to path_get_dirname(StdStringView filename) with a Glib::ustring fails if StdStringView does not have a constructor that takes a const Glib::ustring&. StdStringView and UStringView are now aliases of StringView, whose names show which data type is preferred. See issue #34
* Glib: Add BasicStringView, StdStringView, UStringViewKjell Ahlstedt2019-10-231-0/+47
| | | | | | and use them in build_filename() and other functions in miscutils.hg. Fixes #34
* Glib::MainContext: Add push/pop/get_thread_default()Kjell Ahlstedt2019-10-072-4/+92
| | | | See issue #56
* Glib::ustring documentation: Minor fixKjell Ahlstedt2019-09-181-2/+2
|
* Remove Glib::TimeValKjell Ahlstedt2019-08-133-380/+0
| | | | | | | | | | | | | | | | | | GTimeVal has been deprecated in glib. Remove its wrapping in glibmm. * examples/dbus/server_without_bus.cc: * examples/dbus/session_bus_service.cc: Replace TimeVal by DateTime. * gio/src/fileinfo.[ccg|hg]: Remove [set_]modification_time(). Add set/get_modification_date_time(). * glib/glibmm.h: * glib/glibmm/filelist.am: Remove timeval. * glib/glibmm/timeval.[cc|h]: Removed files. * glib/src/date.[ccg|hg]: Remove set_time(const GTimeVal& timeval). * glib/src/datetime.[ccg|hg]: Remove create_now_local/utc(const TimeVal& tv) and to_timeval(). Add create_from_iso8601(), format_iso8601() and operator bool(). * tools/m4/convert_glib.m4: * tools/m4/convert_gio.m4: Remove conversions for GTimeVal.
* Glib::ustring docs: ustring can't always replace std::stringKjell Ahlstedt2019-07-121-10/+20
| | | | Fixes #47
* Glib::init(), Gio::init(): Improve the documentationKjell Ahlstedt2019-07-091-4/+6
| | | | See issue #49
* Glib::Property: Update for compatibility with Gtk::BuilderKjell Ahlstedt2019-06-272-32/+96
| | | | | | | | | When an object is created by GtkBuilder, the GObject-derived C object is created and its properties set before there is a C++ wrapper to store the property values in. Glib::custom_set_property_callback() stores property values in a data structure reached via a GQuark in the object. PropertyBase::lookup_property() copies those property values to the PropertyBase objects when the C++ wrapper is created.
* ustring: Add overloads for const char* fmt . . .Daniel Boles2019-06-211-1/+44
| | | | | | | | | | | | | | | | . . . in the hope that doing so can help compilers catch some mistakes that users might make. However, point out they shouldn't rely on that. We only provide this overload in case it catches such users in the act of making a mistake, but they should still be careful when writing code. details: (1) This means we can implement sprintf(ustring const&) in terms of ustring(char const*) instead of repeating ourselves. (2) I provide a 2nd overload of the zero-args case just for symmetry, and to avoid creating another ustring for the argument just to copy it on return (if not that I expect this to be performance-critical) https://gitlab.gnome.org/GNOME/glibmm/issues/21#note_537941
* ustring: Be extra clear about "count/types/order"Daniel Boles2019-06-211-2/+2
| | | | | | Say the same thing both in the main blurb and the argument documentation – and say "count" instead of "number" just so it's extra clear what I mean (and because "size" didn't seem clear enough in that sense).
* ustring: Don't say "message string" for sprintf()Daniel Boles2019-06-211-1/+1
| | | | | | | | I just copied that from compose() and am not sure of its precise intended meaning, but in case it conveys 'a string suitable for showing a message, i.e. a translatable string', let's not give that incorrect impression, since placeholders can't be reordered by translators. See also https://gitlab.gnome.org/GNOME/glibmm/issues/21#note_533829 et al.
* ustring: Fix warning/errors if sprintf("fmt only")Daniel Boles2019-06-211-1/+24
| | | | | | | | | | | | | | | | | | | | | | If no args to be substituted are given, there is nothing to do, so the fmt string is returned as-is without substitution. This is an obvious case of mismatched format/args that we can check. Not doing so causes warnings/errors with common compiler options, as it is a security risk. For instance, -Wformat-security causes GCC to complain thusly: > format not a string literal and no format arguments Not passing arguments but passing a variable string that might contain placeholders and thus instruct the compiler to try grabbing random unrelated things off the stacks is obviously not something we want to do – nor do we want to do it any *other* time, but this is the one case we can obviously catch ourselves, rather than hoping any compiler does. The argument for not just static_assert()ing that sizeof...(args) >= 1 is that this might conceivably be used in generic code where doing the former would be annoying, and it's easy enough to make that work anyway. https://gitlab.gnome.org/GNOME/glibmm/issues/21#note_537551
* ustring: Add sprintf(), wrapping g_strdup_printf()Daniel Boles2019-06-201-0/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | Add another way to produce formatted ustrings, this time using printf syntax, by forwarding arguments to g_strdup_printf() and then copying the result into the returned ustring. This includes a private ustring::sprintify() function that by default just forward its argument but can be overloaded to do something else. In this commit, that is overloaded for ustring and std::string so that their .c_str() is passed to printf instead, avoiding the ugliness of users always having to write .c_str() in their own lists of arguments. Note that the same lack of type safety as plagues printf() and all its variants (in both C and GLib) applies here: the arguments are just forwarded on, so if you include too few or the wrong types for the placeholders you specify, you invoke undefined behaviour just as in C. For reasons like that, C++'s preference of streams over stdio, and the hope that we'll eventually get an actual nice string-formatting solution in the C++ Standard, I don't go out of my way to shout about this in the documentation. Users who really want sprintf() will find it, without us having to shout too loudly about it and risk being seen as recommending it more than anything else. It's here for those who know they need it. https://gitlab.gnome.org/GNOME/glibmm/issues/21
* Property: Add const get_proxy() returning ReadOnlyDaniel Boles2019-06-111-0/+12
| | | | | | | | We could only get_proxy() if non-const and with a read/write Proxy. This resolves that so that we can get a read-only proxy from a const Property (without having to construct manually from the instance/name as before). Close https://gitlab.gnome.org/GNOME/glibmm/issues/44
* Property: Getting Proxy from ReadOnly is const tooDaniel Boles2019-06-111-2/+2
| | | | | Thereʼs no need for this to require a non-const Property_ReadOnly as the Proxy by definition canʼt modify it, so make it const like other methods
* Property: Clarify “manipulate” → read and/or writeDaniel Boles2019-06-111-3/+3
|
* Fix callback races in glibmm when source is destructedDainis Jonitis2019-04-181-7/+23
| | | | | | | | | | | It is normal situation when glib main loop iterates sources on one thread where it checks whether source is still active and its callback functions can be called and glibmm Source being destroyed on other thread. Glibmm should check once again that callback_data and callback_funcs fields are still valid and GSource was not marked as inactive while its callback handlers are called. Fixes #41
* Use convert_return_gchar_ptr_to_*() in a couple of ustring methodsMartin Ejdestig2019-04-181-10/+5
| | | | | | | | | | | | | | | | First attempt at fixing memory leak in make_valid() (see previous commit) used make_unique_ptr_gfree() directly because of looking at these methods. Better to use the helper function. This actually fixes undefined behavior for normalize() since g_utf8_normalize() is documented to return NULL if string is not a valid UTF-8 string. The constructor for std::string, which ustring uses for storage, that takes a pointer is documented to have undefined behavior if pointer is NULL. The utility function checks for NULL and uses the default constructor in that case. (Have not looked at implementation of Glib functions, and it may be that all std::string implementations Glibmm is used with handles this case, but good to avoid undefined behavior regardless, I think.)
* Fix memory leak in Glib::ustring::make_valid()Martin Ejdestig2019-04-181-1/+1
|
* gmmproc: _WRAP_PROPERTY: Check the data typeKjell Ahlstedt2019-01-311-0/+35
| | | | | | | | | | | | * glib/glibmm/value_custom.h: Add template class Glib::Traits::ValueCompatibleWithWrapProperty<> that checks if the template parameter names a type that can be used with _WRAP_PROPERTY and _WRAP_CHILD_PROPERTY. * tools/m4/property.m4: * tools/pm/Output.pm: * tools/pm/WrapParser.pm: _WRAP_PROPERTY and _WRAP_CHILD_PROPERTY generate a static_assert() that checks if the data type is acceptable. The generation of the static_assert() can be suppressed with the new no_type_check parameter.
* gmmproc: Add _IS_REFCOUNTED_BOXEDTYPEKjell Ahlstedt2019-01-301-0/+21
| | | | | | | | * glib/glibmm/value.h: Add Value_RefPtrBoxed<>. * tools/m4/class_opaque_refcounted.m4: Add _IS_REFCOUNTED_BOXEDTYPE, which can be used together with _CLASS_OPAQUE_REFCOUNTED. It generates a *_get_type() function and a Glib::Value specialization. A Glib::Value specialization is required, if the C++ class is used in _WRAP_PROPERTY.
* Glib::Value: Add Value<std::vector<string>> specializationsKjell Ahlstedt2019-01-272-0/+70
| | | | | | Add Value<std::vector<std::string>> and Value<std::vector<Glib::ustring>>. One of them is needed in _WRAP_PROPERTY("names", std::vector<Glib::ustring>) in Gio::ThemedIcon and in _WRAP_PROPERTYs in gtkmm.
* Glib::Value: Add ValueBase_VariantKjell Ahlstedt2019-01-202-1/+49
| | | | | Nice to have as a base class for Value<VariantBase> and possibly for future Glib::Value specializations.
* Glib::Value: Remove obsolete create_param_spec() overloadKjell Ahlstedt2019-01-182-44/+0
| | | | | Glib::Property uses the create_param_spec() method with 4 parameters. Remove the one with only a 'name' parameter.
* Glib: Add some Glib::Value<> specializationsKjell Ahlstedt2019-01-184-1/+58
| | | | | | | | | | | | | | | | * glib/glibmm/error.[cc|h]: Add operator bool(). Add Glib::Value<Glib::Error> which is needed in _WRAP_PROPERTY() in Gtk::MediaStream. * glib/glibmm/objectbase.[cc|h]: Add get_base_type(), which is necessary for one of the existing Value<> specializations to apply. ObjectBase is used in _WRAP_PROPERTY() in Glib::Binding. * glib/src/variant.[ccg|hg]: Add Glib::Value<VariantBase> which is needed in _WRAP_PROPERTY() in Gio:Action. * glib/src/varianttype.[ccg|hg]: Add Glib::Value<VariantType> which is needed in _WRAP_PROPERTY() in Gio:Action. All data types that occur in _WRAP_PROPERTY() must have correct Glib::Value<> specializations. In most cases missing Value<> specializations are noticed only during execution of code that calls an affected property_*() method.
* stringutils: Don't use @retval here eitherDaniel Boles2018-12-171-1/+1
| | | | | as pointed out by Kjell: https://gitlab.gnome.org/GNOME/gtkmm/merge_requests/9#note_389406
* extraclassinit: Fix typo in comment in doc exampleDaniel Boles2018-12-091-1/+1
|
* ustring: Remove useless alternative Stringify ctorDaniel Boles2018-10-141-3/+0
| | | | | This can never be called, because we explicitly specialise Stringify for const char*, so that specialisation will always be used instead of this.
* ustring: Avoid un(necessary|clear) ptr @ StringifyDaniel Boles2018-10-141-6/+6
| | | | | | | | | | | | Rather than storing a pointer in the temporary Stringify objects, we can instead store a reference, which is clearer about it being non-optional and makes for nicer syntax. Then we return that and use operator& when forwarding it to compose_private() in the std::initializer_list, since containers can't hold references, so we do need a pointer there. Unless: We could perhaps go a step further and make that an initializer_list of std::reference_wrapper, avoiding pointers altogether while probably not incurring overhead as it is a simple wrapper, but that's one for later.
* ustring: Make 1 Stringify member const like othersDaniel Boles2018-10-141-1/+1
| | | | | This was the only specialisation of Stringify in which the member string_ was not already const. Make it so.
* ustring: Use C++17 fold expr. instead of recursionDaniel Boles2018-10-141-24/+1
| | | | | | Instead of having to manually recurse in order to stream every element in the parameter pack, use the new fold expressions, by streaming a binary left fold of operator, - to do the same thing in far fewer lines.
* Fix reference documentation generationChun-wei Fan2018-09-101-1/+1
| | | | | | | | | * docs/Makefile.am: Include the filelist.gmake.am files if applicable * glib/glibmm/filelist.gmake.am: * gio/src/filelist.gmake.am: * gio/giomm/filelist.gmake.am: Include filelist.am relative from $(top_srcdir) as we are including the filelist.gmake.am's from docs/ as well.
* glibmm, giomm: Split out GNU automake items from filelist.amChun-wei Fan2018-09-073-2/+6
| | | | | | This enables the filelist.am files to be shared with the NMake Makefiles, so that any addition/removal to the sources can be reflected in the Visual Studio build files as well.
* Avoid compiler warnings from function pointer conversionsKjell Ahlstedt2018-08-312-13/+16
| | | | | | | | | | | | | | gcc8 -Wextra prints a warning when a single reinterpret_cast is used for conversion between different types of function pointers. The previous fix with a union in Glib::bitwise_equivalent_cast<>() is not standard C++. Rename the function to Glib::function_pointer_cast<>(), and use two reinterpret_casts as recommended in gcc's documentation. * glib/src/optiongroup.ccg: Use a reinterpret_cast to convert from a function pointer to void*. That's possible now. It's "conditionally supported", starting with C++11. See https://github.com/libsigcplusplus/libsigcplusplus/issues/8
* Avoid compiler warnings from function pointer conversionsKjell Ahlstedt2018-07-172-3/+23
| | | | | | | | | | | | gcc8 -Wextra prints a warning when reinterpret_cast is used for conversion between different types of function pointers. Avoid that by adding Glib::bitwise_equivalent_cast<>() with a union with members of the two types of function pointers. * glib/src/optiongroup.ccg: Use Glib::bitwise_equivalent_cast<>() to convert from a function pointer to void*. See https://github.com/libsigcplusplus/libsigcplusplus/issues/1
* Revert "Avoid compiler warnings from function pointer conversions"Kjell Ahlstedt2018-07-171-21/+5
| | | | | | This reverts commit fa85bd1161d5d914095d1a3f9b620da294c9af79. This can be done in a better way by keeping the union in a template function.
* Avoid compiler warnings from function pointer conversionsKjell Ahlstedt2018-07-131-5/+21
| | | | | | | | gcc8 -Wextra prints a warning when reinterpret_cast is used for conversion between different types of function pointers. Avoid that by instead using a union with members of the two types of function pointers. See https://github.com/libsigcplusplus/libsigcplusplus/issues/1
* Glib::ExtraClassInit docs: Don't mention Gtk::WidgetCustomDrawKjell Ahlstedt2018-05-241-5/+4
| | | | | Gtk::WidgetCustomDraw has been removed. Don't mention it in the class documentation of Glib::ExtraClassInit.
* ustring: Fix wchar conversion on macOS with libc++Clemens Lang2018-04-261-3/+3
| | | | | | | | | | | | | | libc++ internally represents std::wstrings in UCS-4 just like libstdc++, but does not set the __STDC_ISO_10646__ define. This caused the code to fall back to calling iconv with the WCHAR_T source character set, which does not correctly convert these strings and leads to errors, for example in inkscape on startup. See https://trac.macports.org/ticket/56214 for an instance of such a problem. Re-use the UCS4 to UTF8 conversion code when libc++ is detected, which solves this. Bug 795338
* Update some @newin commandsKjell Ahlstedt2018-04-264-6/+6
| | | | | | API which is new in the future ABI-breaking release is newin{2,58}, but this might change again in the future. glibmm-2.58 is still just a preliminary name of this ABI. Bug 789330
* Glib::TimeoutSource: Use monotonic time consistentlyKjell Ahlstedt2018-01-252-37/+18
| | | | | | * glib/glibmm/main.[cc|h]: Change type of TimeoutSource::expiration_ from Glib::TimeVal to gint64. Use Source::get_time() consistently. Bug 792524
* Glib::Source: Remove get_current_time() from main.hKjell Ahlstedt2017-11-172-14/+0
| | | | | get_current_time() is a deprecated function that was removed from main.cc by commit 45cc8f8f8cb093a9e8aa8747af93c57941e1b32a
* Glib::ObjectBase: Don't mention GtkObject in commentsKjell Ahlstedt2017-10-102-8/+10
| | | | | Don't mention GtkObject or gtk_object_destroy() in comments. They were removed from gtk+ in gtk+3.
* ustring: Avoid warning due to type confusionDaniel Boles2017-09-051-2/+3
| | | | | | | | | | | | | | | | | | error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits] if (index >= 0 && index < ilist.size()) digit_value() - N is an int, but ilist.size() is an std::size_t. There’s rarely a nice way to handle such situations, but here we have an OK one: As ilist.size() is static_assert()ed in compose() to be in range of int, we can safely convert to int for use as the bound. For clarity, convert to a new int, rather than comparing to static_cast<int>(ilist.size()). Using an int is clearer than e.g. relying on std::size_t underflowing to its max if digit_value() returns < 0 and hence not being < ilist.size(). https://bugzilla.gnome.org/show_bug.cgi?id=784211
* Glib::IOCondition: Add an IO_ prefix to the enumerator namesKjell Ahlstedt2017-09-051-4/+4
| | | | | | | IN and OUT can be preprocessor macros. IO_ is added to the enumerator names. E.g. Glib::IOCondition::IN is replaced by Glib::IOCondition::IO_IN. These enumerator names will be the same as before we used enum class. Bug 786717
* ustring: Replace 8×format() with 1 variadic templateDaniel Boles2017-09-031-153/+29
| | | | | | | | | as per the previous commit for Glib::ustring. Now, users can pass format() as many arguments as their compiler or stack will allow, rather than being limited to a maximum of 8. https://bugzilla.gnome.org/show_bug.cgi?id=784211
* ustring: Replace 9×compose() with 1 variadic templateDaniel Boles2017-09-031-189/+21
| | | | | | No more gratuitous repetition, hooray for modern C++! https://bugzilla.gnome.org/show_bug.cgi?id=784211