Commit Graph

2760 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
2e8375daa0 gbookmarkfile: Add copy function
GBookmarkFile has everything for being introspectable, but it lacks a
GType, because it can't be copied. So provide a copy function that
deeply copies all the bookmark structures.

Add tests for this.
2022-10-14 16:39:20 +01:00
Christian Hergert
49ae9b490d strfuncs: add g_set_str()
This is like our other suite of g_set_*() based APIs to simplify and
improve correctness of setters for fields, properties, and more.

This implementation specifically handles setting string values that may
point to an offset within the current string by copying before free.

strcmp() is used directly (as opposed to g_strcmp0() due to it being in
gtestutils.h as well as to increase the chance that the compiler will
hoist the implementation.

Fixes #2747
2022-10-14 16:24:41 +01:00
Philip Withnall
05714bf635 docs: Add 2.76 release series documentation pages to the build
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-10-14 16:03:29 +01:00
Xavier Claessens
dcfc9f689e Fix symbol visibility macros on Windows
There is currently no `dllimport` attribute on any of our function,
which prevents MSVC to optimize function calls.

To fix that issue, we need to redeclare all our visibility macros for
each of our libraries, because when compiling e.g. GIO code, we need
dllimport in GLIB headers and dllexport in GIO headers. That means they
cannot use the same GLIB_AVAILABLE_* macro.

Since that's a lot of boilerplate to copy/paste after each version bump,
this MR generate all those macros using a python script.

Also simplify the meson side by using `gnu_symbol_visibility : 'hidden'`
keyword argument instead of passing the cflag manually.

This leaves only API index to add manually into glib-docs.xml when
bumping GLib version. That file cannot be generated because Meson does
not allow passing a buit file to gnome.gtkdoc()'s main_xml kwarg
unfortunately.
2022-10-13 20:53:56 -04:00
Emmanuele Bassi
32edf9c01a Build API docs only with shared libraries
Building the references requires libraries with all their symbols
available. Passing `-Dgtk_doc=true` and `-Ddefault_library=static`
should be considered a configuration error.
2022-09-14 15:03:43 +01:00
Marco Trevisan (Treviño)
ea0617e993 docs: Add --delete option to gio-tool attributes documentation
It was added via !2845 but not documented.
2022-08-05 22:36:06 +02:00
Michael Catanzaro
61a843564d Improve default value of glib_debug option
glib_debug is an auto option. This is clever because it allows us to
guess the best default based on the build type, while also allowing an
easy way to override if the guess is not good. Sadly, the attempt to
guess based on the build type does not work well. For example, it
considers debugoptimized builds to be debug builds, but despite the
name, it is definitely a release build type (except on Windows, which
we'll ignore here). The minsize build type has the exact same problem.
The debug option is true for both build types, but this only controls
whether debuginfo is enabled, not whether debug extras are enabled.

The plain build type has a different problem: debug is off, but the
optimization option is off too, even though plain builds are distro
builds are will almost always use optimization.

I've outlined an argument for why we should make these changes here:
https://blogs.gnome.org/mcatanzaro/2022/07/15/best-practices-for-build-options/

Specifically, Rule 4 shows all the build types and whether they
correspond to release builds or debug builds. Rule 6 argues that we
should provide good defaults for plain builds.
2022-08-03 17:07:13 -05:00
Aleksei Rybalkin
8d5a44dc8f replace pcre1 with pcre2 2022-07-12 11:46:34 +00:00
Matthias Clasen
9d89f75a50 Merge branch 'release-docs' into 'main'
docs: Document the release process

See merge request GNOME/glib!2763
2022-07-08 14:16:47 +00:00
Philip Withnall
8385f52db7 Merge branch 'inline-macros' into 'main'
gmacros: Provide platform-independent G_ALWAYS_INLINE and G_NO_INLINE

See merge request GNOME/glib!2781
2022-07-06 13:40:10 +00:00
Marco Trevisan (Treviño)
15cd0f0461 gmacros: Provide platform-independent G_ALWAYS_INLINE and G_NO_INLINE
We had gcc-only implementations for them while both can be used in all
the supported platforms we have.

So let's just provide generic definitions, while we keep the old ones
for both consistency and retro-compatibility.
2022-07-06 14:57:06 +02:00
Philip Withnall
89b1fe42d7 Merge branch 'testing-docs' into 'main'
docs: Add a testing policy

See merge request GNOME/glib!2748
2022-06-30 10:24:35 +00:00
Emmanuele Bassi
5cf742d42e Merge branch 'ebassi/c99-macro-varargs' into 'main'
Require C99's __VA_ARGS__

Closes #2681

See merge request GNOME/glib!2791
2022-06-30 01:40:55 +00:00
Emmanuele Bassi
fa05ebe27c docs: Mention alternatives for defining enumeration types
We should mention glib-mkenums in the documentation for
G_DEFINE_ENUM_TYPE and G_DEFINE_FLAGS_TYPE.

We should also mention the macros in the documentation for glib-mkenums.

This way, developers can choose the most appropriate tool for their use
case.
2022-06-30 01:46:54 +01:00
Emmanuele Bassi
28edd84e77 docs: Add the new G_DEFINE macros for enumeration types 2022-06-30 01:46:54 +01:00
Emmanuele Bassi
2a12de5b1d Require C99's __VA_ARGS__
We have fallback in places for GNU's variadic arguments in macros, and
for static inline functions with variadic arguments as an fallback of
last resort, but going forward we are going to depend on `__VA_ARGS__`
for macros that cannot be re-implemented using a static inline function.

Fixes: #2681
2022-06-30 01:46:32 +01:00
Philip Withnall
e5ccbe09da Merge branch 'atomic-exchange-pre-value' into 'main'
gatomic: Add Compare and Exchange functions that returns the previous value

See merge request GNOME/glib!2766
2022-06-23 13:19:05 +00:00
Philip Withnall
5655af6ada Merge branch 'more-async-gfile' into 'main'
gfile (and GAppInfo): Add some missing async APIs and ensure async calls always use them

See merge request GNOME/glib!2717
2022-06-23 11:49:55 +00:00
Marco Trevisan (Treviño)
bfdeb37f6e gatomic: Add Compare and Exchange functions that returns the previous value
Atomic primitives allow to do conditional compare and exchange but also
to get the value that was previously stored in the atomic variable.

Now, we provided an exchange function that allows to do an exchange if
the atomic value matches an expected value but we had no way to know
at the same time what was the value in the atomic at the moment of the
exchange try, an this can be useful in case that the operation fails,
for example if the current value is still acceptable for us, allowing
to do a kind of "OR" check:

  gint old_value;
  gint valid_value = 222;
  while (!g_atomic_pointer_compare_and_exchange_value (&atomic,
                                                       valid_value, 555,
                                                       &old_value)
    {
      if (old_value == 555 || old_value == 222)
        valid_value = old_value;
    }
2022-06-22 23:01:19 +02:00
Marco Trevisan (Treviño)
8aee5fc628 GAppInfo: Add async API to get default Application for URI scheme
Make possible to fetch the default application for URI scheme in a
thread without using blocking I/O.
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
44dbd43170 GAppInfo: Add async API to get default Application for content type
Make possible to fetch the Application for default content type in a
thread without using blocking I/O.
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
22e951e6ac gfile: Add Async API to create a temporary directory and return as GFile
While it's possible to create a directory synchronously via
g_dir_make_tmp(), there's no such API that performs it asynchronously.

So implement it using GFile, using a thread to perform such task.
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
fa24391529 gfile: Add API to create a new temporary file asynchronously
Make possible to create a new gfile with a temporary name in async
way, using the same API of g_file_new_tmp().
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
b64fd312da gerror: Add an utility function to get the GIO Error from GFileError
When GIO functions are using GLib file utils functions we expect to
return a GIO Error, so provide a way to map such error values.
2022-06-22 20:07:25 +02:00
Philip Withnall
d312647230 docs: Sync glib.doap to set of users listed in CODEOWNERS
Listing a user in `glib.doap` is important for ensuring their access
rights are correct in GitLab (as they are synced from the DOAP file by a
sysadmin script).

When `CODEOWNERS` was written, we were assuming that GNOME’s GitLab
would get support for the `CODEOWNERS` feature in GitLab. Unfortunately,
that’s not happened, and it remains an enterprise-only feature.

As such, that means that listing a co-maintainer of GLib in `CODEOWNERS`
is not sufficient to grant them permissions to actually merge MRs or
triage issues. That means they can’t really do any co-maintaining.

So fix that by updating the DOAP from `CODEOWNERS`. This doesn’t change
the list of co-maintainers at all, or the amount of trust assumed of
anybody.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-22 15:54:49 +01:00
Philip Withnall
70cb59ec90 docs: Document the release process
This documents what we already do, rather than trying to make any
improvements to the process. They can happen separately, later, as
they’re a little more involved than just writing a Markdown document.

For example, we really should automate some of this.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-21 16:16:10 +01:00
Philip Withnall
9cc2859e08 docs: Add Marco Trevisan as a co-maintainer 2022-06-20 16:03:01 +00:00
Eli Schwartz
24ec80cfb4
meson: simplify iconv lookups using Meson's builtin dependency lookup
iconv is complicated to look up. That complexity now resides in
Meson, since 0.60.0, via a `dependency('iconv')` lookup, so use that
instead.

No effort is made to support the old option for which type of iconv to
use. It was a false choice, because if only one was available, then
that's the only one you can use, and if both are available, the external
iconv shadows the builtin one and renders the builtin one unusable,
so there is still only one you can use.

This meant that when configuring glib with -Diconv=libc on systems that
had an external iconv, the configure check would detect a valid libc
iconv, try to use it, and then fail during the build because iconv.h
belongs to the external iconv and generates machine code using the
external iconv ABI, but fails to link to the iconv `find_library()`.
Meson handles this transparently.
2022-06-16 12:04:59 -04:00
Philip Withnall
b3f49d08a6 build: Move gvdb to a subproject
Rather than carrying the copylib around inside GLib, which is a pain to
synchronise and affects our code coverage statistics.

This requires updating the CI images to cache the new subproject,
including updating the `cache-subprojects.sh` script to pull in git
submodules.

It also requires adding `gioenumtypes_dep` to be added to the
dependencies list of `libgio`, since it needs to be build before GVDB as
it’s pulled in by the GIO headers which GVDB includes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2603
2022-06-16 10:12:07 +01:00
Marco Trevisan (Treviño)
04718a9692 gfile: Implement interface API to make symbolic links asynchronously
The interface was ready for this API but it was not provided.

So implement this, using a thread that calls the sync API for now.

Add tests.

Helps with: GNOME/glib#157
2022-06-15 19:49:38 +02:00
Philip Withnall
7674fd1504 docs: Add a testing policy
This documents our existing testing best practices, and tries to explain
some of the rationale around them.

There’s some new policy around performance tests, specifying that they
are good to keep around if they are high quality (so they can be used
again, the effort put into them not thrown away, and the numbers
compared over time) and that they should be runnable automatically to
avoid bitrot.

Everything else just documents existing practice.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-14 15:19:32 +01:00
Marco Trevisan (Treviño)
fa4e34667c gatomic: Add APIs to perform atomic int / pointer exchanges
Atomic APIs provide a way to exchange values only if we compare a value
that is equal to the old value, but not to just exchange the value
returning the old one.

However, compilers provide such built-in functions, so we can use them
to expose such functionality to GLib.

The only drawback is that when using an old version of gcc not providing
atomic APIs to swap values, we need to re-implement it with an
implementation that may not be fully atomic, but that is safe enough.

However this codepath should really not be used currently as gcc
introduced __atomic_exchange_n() at version 4.7.4, so 8 years ago.
2022-06-07 17:10:57 +02:00
Philip Withnall
89f4c876ef Merge branch 'roadmap-docs' into 'main'
docs: Add a roadmap policy

See merge request GNOME/glib!2681
2022-06-06 13:07:09 +00:00
Philip Withnall
876335d9f7 Merge branch 'backports-policy' into 'main'
docs: Add a backports policy

See merge request GNOME/glib!2670
2022-05-31 12:18:24 +00:00
nitinosiris
b33ef610de Add functionality to preserve nanosecond timestamps
file copy doesn't preserve nanosecond timestamps

Closes #369
2022-05-27 17:03:35 +01:00
Thomas Haller
ee247c0a2d array: add support for %NULL termination in GPtrArray
GArray supports a "zero_terminated" flag, but GPtrArray doesn't.
This is odd, because especially for a pointer array it makes sense
to have a %NULL sentinel. This would be for example useful to track
or construct a strv array with a GPtrArray.

As workaround for this missing feature you could use a GArray instead
(ugly) or to explicitly add the %NULL element. However the latter increases
the "len" of the array, which can be problematic if you want to still use
the GPtrArray for other purposes.

Add API for marking a GPtrArray as %NULL terminated. In that case, the
API will ensure that there is always a valid %NULL sentinel after the
array. Note that the API does not enforce that a %NULL terminated API
actually has any data allocated. That means, even with a %NULL terminated
array, pdata can still be %NULL (only if len is zero).

Add g_ptr_array_new_null_terminated() constructor. The null-terminated flag
cannot be cleared. Once the GPtrArray is flagged to be %NULL terminated, it
sticks. The purpose is that once a user checks whether a GPtrArray instance
is safe to be treated as a %NULL terminated array, the decision does
not need to be re-evaluated.

Also add a g_ptr_array_is_null_terminated(). That is useful because it
allows you to check whether a GPtrArray created by somebody else is safe
to use as a %NULL terminated array. Since there is no API to make an
array not %NULL terminated anymore, this is not error prone.

The new flag is tracked as a guint8 in GRealPtrArray. On common 64 bit
architectures this does not increase the size of the struct as it fits
in an existing hole. Note that this is not a bitfield because it's
probably more efficient to access the entire guint8. However, there is
still a 3 bytes hole (on common 32 and 64 architectures), so if we need
to add more flags in the future, we still have space for 24 bits,
despite the new flag not being a bitfield.

The biggest downside of the patch is the runtime overhead that most
operations now need to check whether %NULL termination is requested.

Includes some tweaks and additional tests by Philip Withnall.

https://gitlab.gnome.org/GNOME/glib/-/issues/353
2022-05-27 15:27:19 +01:00
Philip Withnall
93bf87528d Merge branch 'ebassi/source-once' into 'main'
Add one-shot idle and timeout functions

See merge request GNOME/glib!2684
2022-05-27 12:25:51 +00:00
Emmanuele Bassi
12571a0821 Add one-shot idle and timeout functions
Many idle and timeout sources are installed as "one shot": called once
and immediately removed. While it's easy to write a simple callback that
returns G_SOURCE_REMOVE, it would also be useful to have some sort of
"visual" marker when reading the code; a way to immediately see that a
callback (which may be defined elsewhere in the code) is meant to be
invoked just once.

Includes additional unit tests by Philip Withnall.
2022-05-27 12:57:55 +01:00
Matthias Clasen
dacfe8c88a param: Add g_param_value_is_valid
This is wrapper for the new value_is_valid vfunc,
but it falls back to using value_validate to
obtain the same information.
2022-05-23 15:48:28 -04:00
Matthias Clasen
0415bf9412 Add g_datalist_id_remove_multiple
This is more efficient than calling
g_datalist_id_remove() multiple times
in a row, since it only takes the locks
once.

Allow up to 16 keys to be removed in one go.
That is enough for the use we have in GObject,
and it avoids any danger of blowing the stack.
2022-05-23 09:19:45 -04:00
Matthias Clasen
aaef7f30b3 value: Add G_VALUE_COLLECT_INIT2
Add a variant of the G_VALUE_COLLECT_INIT() macro
that provides the GTypeValueTable to the caller.
2022-05-23 05:57:36 -04:00
Philip Withnall
50877bb2d1 docs: Add a roadmap policy
This describes how releases are planned and scheduled, and where users
of GLib can look to see what the current (loose) roadmap is.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-22 17:10:52 +01:00
Philip Withnall
8f9c5090db docs: Use G_PARAM_STATIC_STRINGS in examples and explain it more
Make it a bit clearer in the documentation that using
`G_PARAM_STATIC_STRINGS` everywhere is a good thing.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-20 12:57:36 +01:00
Philip Withnall
49cfb3720e docs: Add a backports policy
This tries to encode all the decision making which goes on when working
out whether to backport a commit from the unstable to stable branch.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-19 12:52:26 +01:00
Philip Withnall
54a7e8a3a4 docs: Update supported platforms list
This just updates the list to reflect what we currently have in CI,
rather than any radical changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-18 08:36:50 +01:00
Philip Withnall
446e016923 docs: Formatting improvements to supported-platforms.md
This doesn’t change the content.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-18 08:36:50 +01:00
Philip Withnall
aa60b45ff8 docs: Add compiler and toolchain requirements from the wiki
These files are Markdown-ified versions of the following wiki pages:
 * https://wiki.gnome.org/Projects/GLib/CompilerRequirements
 * https://wiki.gnome.org/Projects/GLib/SupportedPlatforms

Keeping the files in version control with the rest of the documentation
means they should be easier to find, and easier to remember to keep up
to date.

They have not been modified other than to change to Markdown and tweak
the formatting. Content updates to them will be done in future commits.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-18 08:36:36 +01:00
Philip Withnall
768c87697e build: Specify all inputs to concat-files-helper.py
Since Meson 0.52, a list of inputs is correctly supported, so our
workaround can be removed.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-17 14:04:24 +01:00
Philip Withnall
5efbd51ea8 Merge branch 'cleanup-root' into 'main'
Various updates to documentation and misc files in the root directory

See merge request GNOME/glib!2649
2022-05-17 12:58:25 +00:00
Xavier Claessens
5942103937 meson: Use range() instead of listing all stable versions
Note that range(), like in python, has start value included and stop
value excluded. That's why we use last_version + 2.
2022-05-11 14:34:00 -04:00
Philip Withnall
cdb0cc8800 docs: Move README.rationale to docs subdirectory
This is part of an effort to rationalise our developer documentation a
bit, putting it all in one directory rather than cluttering up the root
directory.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-11 13:02:49 +01:00
Philip Withnall
25ab87d8e5 build: Drop checks and workarounds for older Meson versions
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-06 13:01:44 +01:00
Philip Withnall
7fd4ebacb3 docs: Add a Meson version policy
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2596
2022-05-06 13:01:44 +01:00
Philip Withnall
e2426dd74d Merge branch 'list-store-equal-full' into 'main'
gio: Add g_list_store_find_with_equal_func_full()

Closes #2447

See merge request GNOME/glib!2549
2022-04-05 18:02:15 +00:00
Jason Francis
a85246af3b gio: Add g_list_store_find_with_equal_func_full()
Fixes: #2447
2022-04-05 18:34:39 +01:00
Jason Francis
2a842b1173 gobject: Add g_signal_group_connect_closure 2022-04-05 15:32:20 +01:00
Philip Withnall
4f79f0712c gversionmacros: Add version macros for GLib 2.74
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-28 12:55:20 +01:00
Philip Withnall
6aa210e6af gio: Remove fam file monitor support
libgamin was last released in 2007 and is dead
[upstream](https://gitlab.gnome.org/Archive/gamin). Distributions may
still ship it (although Fedora no longer does), but we want people to
use inotify on Linux since it’s actively supported.

BSDs use kqueue. Windows uses win32filemonitor.

FAM might still be used on some commercial Unix distributions, but there
are no contributors from those distributions, and certainly no CI for
them to prevent regressions.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2614
2022-03-23 15:41:54 +00:00
Philip Withnall
2759dd71be gio: Remove remaining references to fen file monitor
It used to exist on Solaris, but GLib’s support for it was mostly
removed in 2015 in commit 21ab660cf8.

Remove the final few references.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-23 15:40:41 +00:00
Philip Withnall
e951bf1ae3 docs: Improve formatting for some file monitor documentation
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-23 15:34:19 +00:00
Philip Withnall
bbf1dca06a docs: Drop reference to G_LOCAL_DIRECTORY_MONITOR_EXTENSION_POINT_NAME
Support for separate directory monitors was dropped in commit
b995c08bf3, in 2015.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-23 15:32:37 +00:00
Philip Withnall
b5873878cd Merge branch '1190-debugging-docs' into 'main'
gdebugcontroller: Add documentation and tests

Closes #1190

See merge request GNOME/glib!2486
2022-02-15 12:47:50 +00:00
Philip Withnall
1b3e6bab53 gdebugcontrollerdbus: Add stop() method
This allows the controller to explicitly be removed from the bus, in a
way that allows the caller to synchronise with it and know that all
other references to the controller should have been dropped (i.e. after
this method returns, there should be no in-flight D-Bus calls still
holding a reference to the object).

This is needed to be able to guarantee finalisation of the controller in
unit tests (and comparable real-world situations).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #1190
2022-02-14 14:42:17 +00:00
Emmanuele Bassi
7bc6ef8734 Do not generate C resources for all possible toolchains
The resources data is generated for both GCC and MSVC toolchains, even
though we know beforehand which toolchain we're going to compile it for.
By dropping the data duplication we make the generated resources file
faster to compile, especially when dealing with large embedded data,
instead of relying on the C pre-processor to walk the whole file and
discard the branch we're not using.
2022-02-14 13:09:22 +00:00
Philip Withnall
f9c08308ea Merge branch 'ebassi/aligned-alloc' into 'main'
Add aligned memory allocators

Closes #2574

See merge request GNOME/glib!2421
2022-02-11 15:04:25 +00:00
Emmanuele Bassi
475d574440 Add aligned memory allocators
When working with storage (especially GInputStream or GOutputStream) it
is preferred to use page-aligned buffers so that the operating system
can do page-mapping tricks as the operation passes through the kernel.

Another use case is allocating memory used for vectorised operations,
which must be aligned to specific boundaries.

POSIX and Windows, as well as the C11 specification, provide this kind
of allocator functions, and GLib already makes use of it inside GSlice.
It would be convenient to have a public, portable wrapper that other
projects can use.

Fixes: #2574
2022-02-11 14:44:09 +00:00
Philip Withnall
29edfc1169 gdebugcontroller: Drop dup_default() method as it’s broken
If `GDebugControllerDBus` remains as the only, or default,
implementation of `GDebugController`, `dup_default()` cannot work.
`GDebugControllerDBus` requires a `GDBusConnection` at construction
time, which the `GIOModule` construction code can’t provide it.

Either we use a default D-Bus connection (but which one? and how would
it be changed by the user later if it was the wrong one?), or delegate
singleton handling of the `GDebugController` to the user.

The latter approach seems more flexible.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #1190
2022-02-10 19:21:24 +00:00
Philip Withnall
50d23f9680 Merge branch 'feature/move_async' into 'main'
Implement async file movement

See merge request GNOME/glib!2469
2022-02-07 14:29:52 +00:00
Lucas Schwiderski
eeb2bcf5a9 Implement async file movement 2022-02-07 14:03:47 +00:00
Christian Hergert
dd43471f60 gobject: add GSignalGroup
Much like GBindingGroup, the GSignalGroup object allows you to connect many
signal connections for an object and connect/disconnect/block/unblock them
as a group.

This is useful when using many connections on an object to ensure that they
are properly removed when changing state or disposing a third-party
object.

This has been used for years in various GNOME projects and makes sense to
have upstream instead of multiple copies.
2022-02-01 17:09:14 -08:00
Christian Hergert
0d9de09192 gobject: add GBindingGroup
Originally, GBindingGroup started with Builder as a way to simplify all
of the third-degree object bindings necessary around Model-Controller
objects such as TextBuffer/TextView.

Over time, it has grown to be useful in a number of scenarios outside
of Builder and has been copied into a number of projects such as GNOME
Text Editor, GtkSourceView, libdazzle, and more.

It makes sense at this point to unify on a single implementation and
include that upstream in GObject directly alongside GBinding.
2022-01-28 16:01:22 -08:00
Philip Withnall
7f519624e2 Merge branch '1190-debug-interface' into 'main'
gdebugcontroller: Add debug controller API and D-Bus implementation

Closes #1190

See merge request GNOME/glib!2330
2022-01-27 11:00:40 +00:00
Philip Withnall
0c8f7de55a gdebugcontroller: Add debug controller API and D-Bus implementation
This is intended to provide a uniform interface for controlling whether
the debug output from an application (or service) is emitted, typically
to journald, but actually to wherever the application chooses to output
it.

The main implementation of `GDebugController` is `GDebugControllerDBus`,
which is intended to be used on Linux. Other implementations may be
added in future for other platforms, or larger applications may want to
provide their own implementation which integrates with their ecosystem.

The `GDebugControllerDBus` implementation exposes a D-Bus interface at
`/org/gtk/Debugging` with a method to enable or disable debug
output at runtime.

This could be used by external harnesses, such as GNOME Builder or
systemd, to give a uniform way to get debug output from an application.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #1190
2022-01-26 15:19:27 +00:00
Philip Withnall
bb4bec0921 gmessages: Expose a property for enabling debug message output
This is an API analogue of the G_MESSAGES_DEBUG environment variable. It
is intended to be exposed outside applications (for example, as a D-Bus
interface — see follow-up commits) so that there is a uniform interface
for controlling the debug output of an application.

Helps: #1190
2022-01-26 15:17:02 +00:00
Marc-André Lureau
83d45c4f35 gio: compile GUnixConnection on all platforms
On !UNIX, return an error for send_fd() & receive_fd().
(the unixfdmessage unit is not compiled on !UNIX)

The header is installed under the common GIO include directory.

Ensure G_TYPE_UNIX_CONNECTION is registered on all platforms.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
af1777d3d3 meson: compile GUnixCredentialsMessage on all platforms
The header is now also installed under the common GIO include directory.

Sorry if it breaks any build, you had to use the correct header path.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
3308cfb020 gio: compile GUnixSocketAddress on all platforms
Move the header under the common GIO include directory.

Sorry if it breaks any build, you had to use the correct header path.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
4339192b53 gio: add fallback afunix.h header
afunix.h is only recently distributed with Windows SDK & MinGW.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:23 +04:00
Emmanuele Bassi
1437be8049 docs: Add --generate-rst to the gdbus-codegen docs 2022-01-22 01:30:16 +00:00
Philip Withnall
3be0fc867e Merge branch 'wip/hash-table-from' into 'main'
ghash: Add g_hash_table_new_similar

See merge request GNOME/glib!2405
2022-01-19 11:19:07 +00:00
Jonas Ådahl
283d9e0c15 ghash: Add g_hash_table_new_similar()
This function creates a new hash table, but inherits the functions used
for the hash, comparison, and key/value memory management functions from
another hash table.

The primary use case is to implement a behaviour where you maintain a
hash table by regenerating it, letting the values not migrated be freed.
See the following pseudo code:

```
GHashTable *ht;

init(GList *resources) {
  ht = g_hash_table_new (g_str_hash, g_str_equal, g_free, g_free);
  for (r in resources)
    g_hash_table_insert (ht, strdup (resource_get_key (r)), create_value (r));
}

update(GList *resources) {
  GHashTable *new_ht = g_hash_table_new_similar (ht);

  for (r in resources) {
    if (g_hash_table_steal_extended (ht, resource_get_key (r), &key, &value))
      g_hash_table_insert (new_ht, key, value);
    else
      g_hash_table_insert (new_ht, strdup (resource_get_key (r)), create_value (r));
  }
  g_hash_table_unref (ht);
  ht = new_ht;
}
```
2022-01-18 22:19:55 +01:00
Alexander Schwinn
28d833a075 Make clear in doc that signals are emitted synchroniously 2022-01-18 08:53:20 +00:00
Patrick Griffis
96ce3feeb9 gtlscertificate: Add ability to load PKCS #12 encrypted files
This depends on the GTlsBackend implementing these properties
2022-01-07 11:27:56 -06:00
Sophie Herold
68eab1d999 utils: Add XDG_STATE_HOME support 2021-12-24 20:11:39 +00:00
Mohammed Sadiq
3bd2ab4550 docs: Improve GVariant docs
Fix a typo and expand examples to include freeing memory
where it's not obvious
2021-11-29 15:24:15 +05:30
Marc-André Lureau
b4631c44ad galloca: Add new API g_alloca0 and g_newa0
Added `g_alloca0()` which wraps `g_alloca()` and initializes
allocated memory to zeroes.

Added `g_newa0()` which wraps `g_alloca0()` in a typesafe manner.

Refreshed and tweaked by Nishal Kulkarni.
2021-11-26 12:24:23 +00:00
Sebastian Dröge
6d8045ddb4 Merge branch 'gdbus-call-interactive' into 'main'
gdbus: Add --interactive option to `gdbus call`

See merge request GNOME/glib!2329
2021-11-22 13:58:46 +00:00
Alvarito050506
03753cda79 Better detection of the cleanup attribute.
Use g_macro__has_attribute to detect it instead of
hardcoding __GNUC__ || __clang__. This adds support
for a few compiler and is consistent with the rest
of the gmacros.h file.
2021-11-16 15:13:07 +00:00
gonyere
5eeac53793 Changed gendered terms to be gender-neutral 2021-11-12 21:32:21 -05:00
Philip Withnall
b75a16b048 gdbus: Add --interactive option to gdbus call
This allows the flag to allow interactive auth to be set. Previously, it
was unconditionally unset.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-11 11:26:22 +00:00
Vinícius dos Santos Oliveira
7ba86be594 Add g_main_context_new_with_flags()
This constructor is useful to set options that can't change after
creation.
2021-09-21 14:50:30 +01:00
Philip Withnall
94b74c761d gversionmacros: Add version macros for GLib 2.72
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-09-17 11:35:21 +01:00
Evan Miller
508352339a Fix false deprecation warnings on old GCC/MSVC
Closes #2472
2021-09-07 11:21:20 +01:00
Simon McVittie
a076dbcb68 gtestutils: Allow failing a test with a printf-style message
This allows a pattern like

    g_test_message ("cannot reticulate splines: %s", error->message);
    g_test_fail ();

to be replaced by the simpler

    g_test_fail_printf ("cannot reticulate splines: %s", error->message);

with the secondary benefit of making the message available to TAP
consumers as part of the "not ok" message.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-19 09:49:11 +01:00
Simon McVittie
182d9995ca gtestutils: Allow skipping tests with a printf-style message
Forming the g_test_skip() message from printf-style arguments seems
common enough to deserve a convenience function.

g_test_incomplete() is mechanically almost equivalent to g_test_skip()
(the semantics are different but the implementation is very similar),
so give it a similar mechanism for symmetry.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-19 09:41:08 +01:00
Bastien Nocera
9645cbffa8 gio: Add portal version of GPowerProfileMonitor 2021-08-13 01:32:31 +02:00
Philip Withnall
709df8eeb4 Merge branch 'docgen-fixes' into 'main'
Adapt documentation to gi-docgen

See merge request GNOME/glib!2206
2021-08-03 13:53:38 +00:00
Guido Günther
791218a5f5 GNotification: Allow to set a category
Some backends like the FDO one allow to set a category. This helps the
notification daemon to select a proper feedback type.
2021-08-02 19:26:38 +02:00
Emmanuele Bassi
6081e92daf docs: Match GZlib(De)Compressor section with the type name
Otherwise the introspection scanner won't be able to match the
documentation stanza to the corresponding type.
2021-08-02 13:27:55 +01:00
Patrick Griffis
889bdb994f Add GPowerProfileMonitor 2021-07-28 15:56:02 +02:00