31337 Commits

Author SHA1 Message Date
Julian Sparber
3a5ddf566f GPortalNotificationBackend: Use inline text responses
The xdg portal, since version 2, allows to set a special button purpose
for inline text responses.
We can serialize the `response action for text` (added in a
previous commit) into a button button with the correct purpose.
2025-02-17 17:49:59 +01:00
Julian Sparber
22066222ec GNotification: Add API for text responses
Some platforms support inline text responses e.g. xdg portal since
version 2. This allows apps to specify an action that will be called
when the user submits text from the notification.
2025-02-17 17:49:59 +01:00
Julian Sparber
944fb70942 tests: Add test for GNotification portal backend
The portal backend for notifications didn't have any tests this adds
add least some. This also adjusts the mock notification server used to
test the GTK backend to allow to test the portal as well.
2025-02-17 17:49:59 +01:00
Julian Sparber
c15ce5f9b8 GPortalNotificationBackend: Serialize custom sound
The portal uses a special button purpose to play custom sound. We need
to parse the action that will be invoked to play sound as button.
2025-02-17 17:49:59 +01:00
Julian Sparber
cd4ecc7daf GPortalNotificationBackend: Serialize button purpose
The notification portal v2 supports the button purpose, use the property.
2025-02-17 17:49:59 +01:00
Julian Sparber
cafcf0da40 GNotification: Add button purpose property
This is similar to categories but for buttons. This allows apps to
specify what a button does so that the notification server can present
it specially.
2025-02-17 17:49:59 +01:00
Julian Sparber
de7b235098 GPortalNotificationBackend: Serialize category
The notification portal v2 supports category, use the property.
2025-02-17 17:49:59 +01:00
Julian Sparber
1242c28e9a GNotification: Improve category property
This adds a number of standardized categories, which should help the user
to pick the correct one. It also improves the wording of the
documentation for categories.
2025-02-17 17:49:59 +01:00
Julian Sparber
b3c01aa5b1 GPortalNotificationBackend: Serialize markup-body
The notification portal v2 supports markup-body, use the property.
2025-02-17 17:49:59 +01:00
Julian Sparber
c8a5404070 GNotification: Allow to set body with markup
The `markup_body` takes precedence over `body`, if the platform supports
markup. If `body` isn't set then `markup_body` stripped of
markup is used on platforms that don't support markup.

This behavior doesn't break existing apps or backends.
2025-02-17 17:49:59 +01:00
Julian Sparber
ccae74e208 GNotification: Fix wrong NULL check in set_body()
According to the docs `g_notification_set_body()` takes also no body, so
make sure the body string isn't "" but allow passing NULL.
2025-02-17 17:49:59 +01:00
Julian Sparber
ba1b29d1b6 GPortalNotificationBackend: Serialize display-hint
The notification portal v2 supports the display-hint, use the property.
2025-02-17 17:49:59 +01:00
Julian Sparber
935293c86b GNotification: Add new display-hint property
This property allows applications to control how a notification is
displayed.
2025-02-17 17:49:59 +01:00
Julian Sparber
6e416fc25a GPortalNotificationBackend: Serialize sound property
The notification portal v2 supports setting a sound for a notification,
use the property.
2025-02-17 17:49:59 +01:00
Julian Sparber
13e0deefc5 GNotification: Add sound property
Allow applications to specify whether a sound should be played
when it is shown. And allow setting custom sound.

The default behavior is to not play any sound, in order to not break current
apps that play the sound themself.
2025-02-17 17:49:59 +01:00
Julian Sparber
a172f22c95 GPortalNotificationBackend: Parse GBytesIcon and GLoadableIcon for v2
The notification portal v2 accepts a sealable `memfd`. We can load
`GBytesIcon` and `GLoadableIcon` into a `memfd` automatically. For version 1
of the portal we can load `GLoadableIcon` into a `GBytesIcon` to
increase support for more `GIcon` formats.

This doesn't include `GEmblemedIcon` it's likely that it will be
deprecated soon https://gitlab.gnome.org/GNOME/glib/-/issues/3544

Closes: https://gitlab.gnome.org/GNOME/glib/-/issues/3108
2025-02-17 17:49:59 +01:00
Julian Sparber
06c94b9edf GPortalNotificationBackend: Get notification portal version
Version 2 of the portal has a lot of additional features but we need to
check the version before sending new properties because version 1 would
fail with the new properties. New properties are added in a future commit.
2025-02-17 17:49:59 +01:00
Julian Sparber
f5be07b755 GPortalNotificationBackend: Implement it's own serialization method
The portal and GTK notifications will diverge, since they follow
different specs. For now it wasn't a problem since the portal was
strongly limited and essentially the same as the org.gtk.Notifications
interface. The serialization code is mostly the same as the already existing
serialization code.
2025-02-17 17:49:59 +01:00
Philip Withnall
4738951270 Merge branch 'gbsneto/fix-gsubprocess-pid' into 'main'
gio/subprocess: Initialize pid variable to 0

See merge request GNOME/glib!4494
2025-02-15 10:12:02 +00:00
Georges Basile Stavracas Neto
14909ffe1e
gio/subprocess: Initialize pid variable to 0
The documentation for g_spawn_async_with_pipes_and_fds() states:

> If an error occurs, child_pid, stdin_pipe_out, stdout_pipe_out, and
> stderr_pipe_out will not be filled with valid values.

Before 2dc3a6f0c80e5a8f786369eee0c45bfe19b55f4f, the `child_pid`
argument was `self->pid`, and GObject zero-initializes structs. So
the pid field was properly initialized to zero.

After 2dc3a6f0c80e5a8f786369eee0c45bfe19b55f4f, however, the out
variable is now declared inside initable_init(), and it's unitialized.
So if g_spawn_async_with_pipes_and_fds() errors out, `pid` will have
trash value in it, and the following assertion will fail:

```
g_assert (success == (pid != 0));
```

Fix that by initializing the `pid` variable to zero. Add a test to
exercise the fail code path, and prevent errors like this in the
future.
2025-02-14 21:20:24 -03:00
Philip Withnall
c5d82f9099 Merge branch 'keyfile-docs' into 'main'
gkeyfile: Convert docs to gi-docgen linking syntax

See merge request GNOME/glib!4472
2025-02-14 00:56:06 +00:00
Philip Withnall
985cc08d43 Merge branch 'wip/3v1n0/gsubprocess-races-fix' into 'main'
gio/subprocess: Lock while writing on shared pid and status values

See merge request GNOME/glib!4490
2025-02-13 22:17:48 +00:00
Marco Trevisan
2dc3a6f0c8 gio/subprocess: Lock while writing on shared pid and status values
The process PID is initialized by the initable vfunc, while
g_subprocess_exited sets it again, when we're protecting it via a lock.
The status is set when the process exits instead, again while locking.

This makes the thread sanitizer unhappy (even if it shouldn't really be
a race for the PID init case), but still locking during initialization is
not a bad thing to do.

At the same time g_subprocess_wait() and friends were using the pid and status
values without any protection, so let's ensure this is not the case anymore.

WARNING: ThreadSanitizer: data race (pid=8213)
  Write of size 4 at 0x7b200000084c by thread T1:
    #0 g_subprocess_exited ../gio/gsubprocess.c:284
    #1 g_child_watch_dispatch ../glib/gmain.c:5963
    #2 g_main_dispatch ../glib/gmain.c:3373
    #3 g_main_context_dispatch_unlocked ../glib/gmain.c:4224
    #4 g_main_context_iterate_unlocked ../glib/gmain.c:4289
    #5 g_main_context_iteration ../glib/gmain.c:4354
    #6 glib_worker_main ../glib/gmain.c:6553
    #7 g_thread_proxy ../glib/gthread.c:892
  Previous read of size 4 at 0x7b200000084c by main thread:
    #0 g_subprocess_wait ../gio/gsubprocess.c:908
    #1 g_subprocess_wait_check ../gio/gsubprocess.c:939
    #2 end_element ../gio/glib-compile-resources.c:342
    #3 emit_end_element ../glib/gmarkup.c:1045
    #4 g_markup_parse_context_parse ../glib/gmarkup.c:1603
    #5 parse_resource_file ../gio/glib-compile-resources.c:578
    #6 main ../gio/glib-compile-resources.c:967
  Location is heap block of size 120 at 0x7b2000000800 allocated by main
  thread:
    #0 calloc <null>
    #1 g_malloc0 ../glib/gmem.c:133
    #2 g_type_create_instance ../gobject/gtype.c:1933
    #3 g_object_new_internal ../gobject/gobject.c:2621
    #4 g_object_new_valist ../gobject/gobject.c:2960
    #5 g_initable_new_valist ../gio/ginitable.c:245
    #6 g_initable_new ../gio/ginitable.c:163
    #7 g_subprocess_newv ../gio/gsubprocess.c:619
    #8 g_subprocess_new ../gio/gsubprocess.c:590
    #9 end_element ../gio/glib-compile-resources.c:334
    #10 emit_end_element ../glib/gmarkup.c:1045
    #11 g_markup_parse_context_parse ../glib/gmarkup.c:1603
    #12 parse_resource_file ../gio/glib-compile-resources.c:578
    #13 main ../gio/glib-compile-resources.c:967
  Thread T1 'gmain' (tid=8228, running) created by main thread at:
    #0 pthread_create <null>
    #1 g_system_thread_new ../glib/gthread-posix.c:762
    #2 g_thread_new_internal ../glib/gthread.c:996
    #3 g_thread_new ../glib/gthread.c:949
    #4 g_get_worker_context ../glib/gmain.c:6580
    #5 initable_init ../gio/gsubprocess.c:443
    #6 g_initable_init ../gio/ginitable.c:129
    #7 g_initable_new_valist ../gio/ginitable.c:249
    #8 g_initable_new ../gio/ginitable.c:163
    #9 g_subprocess_newv ../gio/gsubprocess.c:619
    #10 g_subprocess_new ../gio/gsubprocess.c:590
    #11 end_element ../gio/glib-compile-resources.c:334
    #12 emit_end_element ../glib/gmarkup.c:1045
    #13 g_markup_parse_context_parse ../glib/gmarkup.c:1603
    #14 parse_resource_file ../gio/glib-compile-resources.c:578
    #15 main ../gio/glib-compile-resources.c:967
SUMMARY: ThreadSanitizer: data race ../gio/gsubprocess.c:284 in
g_subprocess_exited

======================================

WARNING: ThreadSanitizer: data race (pid=15959)
  Read of size 4 at 0x7b200000084c by main thread:
    #0 g_subprocess_wait ../gio/gsubprocess.c:913
    #1 g_subprocess_wait_check ../gio/gsubprocess.c:944
    #2 test_cat_utf8 ../gio/tests/gsubprocess.c:489
    #3 test_case_run ../glib/gtestutils.c:3115
    #4 g_test_run_suite_internal ../glib/gtestutils.c:3210
    #5 g_test_run_suite_internal ../glib/gtestutils.c:3229
    #6 g_test_run_suite ../glib/gtestutils.c:3310
    #7 g_test_run ../glib/gtestutils.c:2379
    #8 main ../gio/tests/gsubprocess.c:2266

  Previous write of size 4 at 0x7b200000084c by thread T1:
    #0 g_subprocess_exited ../gio/gsubprocess.c:284
    #1 g_child_watch_dispatch ../glib/gmain.c:5963
    #2 g_main_dispatch ../glib/gmain.c:3373
    #3 g_main_context_dispatch_unlocked ../glib/gmain.c:4224
    #4 g_main_context_iterate_unlocked ../glib/gmain.c:4289
    #5 g_main_context_iteration ../glib/gmain.c:4354
    #6 glib_worker_main ../glib/gmain.c:6553
    #7 g_thread_proxy ../glib/gthread.c:892
2025-02-13 22:17:48 +00:00
Marco Trevisan
a3d3e3b96e Merge branch 'file-monitor-props-cleanups' into 'main'
gfilemonitor: Various cleanups and minor fixes to property handling

See merge request GNOME/glib!4492
2025-02-13 19:22:44 +00:00
Philip Withnall
f2878327f4
gfilemonitor: Fix value of GFileMonitor:cancelled via g_object_get_property()
It was hard-coded to return `FALSE` for some reason. Fix that.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-13 18:58:30 +00:00
Philip Withnall
06077435c9
gfilemonitor: Emit GObject::notify by pspec rather than property name
This is equivalent, but slightly faster, as it avoids a pspec lookup.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-13 18:57:58 +00:00
Philip Withnall
8ffdbb55d9
gfilemonitor: Install properties all at once
This is a minor performance improvement, since the pspec list for the
class now only has to be modified once, rather than twice.

It also means we now have the `GParamSpec` pointers to hand in a `props`
array, which will be used in the upcoming commits.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-13 18:57:04 +00:00
Philip Withnall
5aa42683ee
gfilemonitor: Use an enum for properties to allow -Wswitch-enum
This lets the compiler tell us if we’ve accidentally missed a property
implementation from `get_property()` or `set_property()`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-13 18:56:04 +00:00
Philip Withnall
40fd0e4759 Merge branch 'wip/3v1n0/gfilemonitor-atomic-cancelled' into 'main'
gio/gfilemonitor: Use atomic API to get / store cancelled state

See merge request GNOME/glib!4487
2025-02-13 18:43:50 +00:00
Philip Withnall
2fab2c38ff Merge branch 'rafaelff/update-pt_BR' into 'main'
Update Brazilian Portuguese translation

See merge request GNOME/glib!4491
2025-02-13 18:39:36 +00:00
Rafael Fontenelle
2e928adfd1 Update Brazilian Portuguese translation 2025-02-13 16:43:55 +00:00
Marco Trevisan (Treviño)
795a56d623 gio/gfilemonitor: Reorder includes as expected by syntax checker 2025-02-13 15:03:57 +01:00
Marco Trevisan (Treviño)
175e02f15c gio/gfilemonitor: Do not mark the filemonitor cancelled until vfunc is done
As per previous commit we used atomic logic to handle the cancellation,
but that lead to a slightly different behavior because the file monitor
was then marked as cancelled before the vfunc implementation was called.

Use similar behavior now (by still relying on the atomic logic), by
marking the state as about-to-cancel as soon as we're starting the
cancellation (preventing other threads to cancel it), and eventually
fully marking it as cancelled.
2025-02-13 15:03:57 +01:00
Marco Trevisan (Treviño)
218b298a1b gio/gfilemonitor: Use atomic API to get / store cancelled state
The cancelled state may be set and read by different threads, so ensure
that it's stored and managed in an atomic way.

We could in fact end up check for `g_file_monitor_is_cancelled()` in a
thread and `g_file_monitor_cancel()` or `g_file_monitor_emit_event` in
in another one.
2025-02-13 15:03:57 +01:00
Philip Withnall
3c03076ac5 Merge branch 'unify-tests-launcher-scripts' into 'main'
tests: Cleanup python tests and add tests for gi-compile-repository and gi-inspect-typelib

See merge request GNOME/glib!4476
2025-02-12 17:00:15 +00:00
Marco Trevisan (Treviño)
fe25e4aad5 tests/lib/testprogramrunner: Support overriding the environment 2025-02-12 17:37:25 +01:00
Marco Trevisan (Treviño)
044e77a384 girepository/tests: Add tests for basic inspector operations
Add some initial tests for the inspector
2025-02-12 17:37:25 +01:00
Philip Withnall
23948a4db5
gkeyfile: Convert docs to gi-docgen linking syntax
Improve formatting while I’m there, and try and ensure all the docs in
these two files matches the
[guidelines](https://developer.gnome.org/documentation/guidelines/devel-docs.html#writing-api-references).

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

Helps: #3250
2025-02-12 11:34:20 +00:00
Philip Withnall
7ca70303b7
gkeyfile: Add missing (transfer full) annotations to ref/free functions
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-12 11:31:10 +00:00
Philip Withnall
9c5409e229
gkeyfile: Update links to various fdo specifications
The old links still work, but we might as well avoid a redirect.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-12 11:31:03 +00:00
Philip Withnall
3e5c454a02
gkeyfilesettingsbackend: Convert docs to gi-docgen linking syntax
Improve formatting while I’m there, and try and ensure all the docs in
these two files matches the
[guidelines](https://developer.gnome.org/documentation/guidelines/devel-docs.html#writing-api-references).

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

Helps: #3250
2025-02-12 11:30:55 +00:00
Marco Trevisan (Treviño)
6160747fe5 girepository/tests: Add tests for the compiler basic operations
Adding some initial test for the compiler behavior and its expected
output.

Also, when using sanitizers we want to be able to test the compiler memory
management.
2025-02-11 21:02:56 +01:00
Marco Trevisan (Treviño)
bf9ea337a2 girepository/tests: Add tests on compiler open/write failures 2025-02-11 21:02:56 +01:00
Marco Trevisan (Treviño)
26890fbb82 ci: Enable introspection for installed tests 2025-02-11 18:51:15 +01:00
Marco Trevisan (Treviño)
00ebf4e1eb tests/lib: Add a new unittest type to simplify launching test programs
We were reusing the same logic everywhere, while we can just reuse an
unique class to base our tests on that avoids having to copy-and-paste
code for no good reason
2025-02-11 18:51:15 +01:00
Marco Trevisan (Treviño)
4bcd99de43 tests: Avoid reusing and installing multiple files the taptestrunner
Add some basic support for having glib-tests-only python libraries that
can be shared across the various projects, so that we don't have to
maintain multiple copies of them.
2025-02-11 18:51:15 +01:00
Marco Trevisan
15edb1b07e Merge branch 'typo' into 'main'
meson: Fix typo in comment about python shebang

See merge request GNOME/glib!4486
2025-02-11 17:09:57 +00:00
Nirbheek Chauhan
8d07ae7ef1 meson: Fix typo in comment about python shebang 2025-02-11 21:37:49 +05:30
Marco Trevisan
589c8295ea Merge branch 'callable-info-test-leak' into 'main'
tests: Fix a memory leak if a callable-info test is skipped

See merge request GNOME/glib!4483
2025-02-11 13:57:20 +00:00
Philip Withnall
ca760eeeac Merge branch 'windows-fix-shebang' into 'main'
Windows: fix Python path can contain spaces

Closes #3331

See merge request GNOME/glib!4391
2025-02-11 13:42:32 +00:00