Commit Graph

8825 Commits

Author SHA1 Message Date
Philip Withnall
27c02a0be4
tests: Test against a sample mtab file in unix-mounts for getmntent()
The test in `unix-mounts` to see whether `g_unix_mounts_get_from_file()`
can parse an example file was working fine when GLib is built with
libmount, but not when built without it (and hence typically using
`getmntent()`).

This is because libmount supports mountinfo files (like
`/proc/self/mountinfo`), but `getmntent()` only supports mount files
(like `/proc/mounts`). The test was written only with the former.

So, change the test to use mount files when GLib is built without
libmount support.

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

Fixes: #3456
2024-08-27 12:13:35 +01:00
Philip Withnall
dfed38ef03
gmenumodel: Acknowledge in docs that the UI used in the example is old
This kind of deeply nested menu is definitely no longer good UI practice
for most apps (deeply nested menus make things hard to find, and require
good mouse control to navigate). However, it does serve as a good
demonstration of the concepts in `GMenuModel`, so keep it, with a
sentence to acknowledge that it’s not a good UI.

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

Fixes: #3451
2024-08-25 15:34:32 +01:00
Michael Catanzaro
255ffe09d4 Merge branch 'unixmounts-fixes' into 'main'
gunixmounts: Fix use of uninitialised variable

See merge request GNOME/glib!4197
2024-08-20 16:21:24 +00:00
Philip Withnall
ce71da63ba
Revert "gio/tests/cancellable: Explain failure on GCancellableSource tests on valgrind"
This reverts commit 365411ea32.

Since commit 3a07b2abd4, issue 2309 has
been fixed, so we should no longer have failures from valgrind here.
2024-08-20 13:02:43 +01:00
Philip Withnall
71cd903118
tests: Run expected-to-hang cancellable tests in subprocesses
These tests are expected to cause a thread to deadlock. That seems to be
fine with glibc on Linux, but the glibc version on FreeBSD can detect
the deadlock, and aborts the whole test process with:
```
GLib (gthread-posix.c): Unexpected error from C library during 'pthread_mutex_lock': Resource deadlock avoided.  Aborting.
```

This is fair enough.

To avoid this causing the test suite to fail, run those two tests in
subprocesses. This also means we’re not carrying a deadlocked thread
around for the rest of the test suite.

Improves on commit 62192925b6.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-08-20 13:02:36 +01:00
Philip Withnall
4235c11757
gunixmounts: Fix use of uninitialised variable
And drop a load of unused variables.

Fixes commit 5040cf1943.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-08-20 12:39:15 +01:00
Philip Withnall
f4aceb0e91 Merge branch 'wip/pwithnall/unix-mount-tests' into 'main'
gunixmounts: Add mount point/entry getters from files and add tests based on them

See merge request GNOME/glib!4163
2024-08-15 14:25:52 +00:00
Philip Withnall
b4332b0056
docs: Clarify distinction between GDrive, GVolume and GMount
Provide examples of what they all represent, and expand on the
descriptions of them in a few places.

Move references to their equivalents from `GnomeVFS` to lower down in
the documentation, since `GnomeVFS` has been deprecated for many years
now, and is unlikely to be pertinent to most readers.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-08-15 11:32:37 +01:00
Philip Withnall
02ffe6a779 Merge branch 'fix_3429' into 'main'
gsettings-tool: Always use the global_schema_source to lookup schemas in list-recursively

Closes #3429

See merge request GNOME/glib!4183
2024-08-14 16:14:45 +00:00
Lukáš Tyrychtr
018581adb5 gsettings-tool: Always use the global_schema_source to lookup schemas in list-recursively
When listing schemas from a specified directory, explicitly
create the GSettings object from the schema, don't allow g_settings_new
to do the usual lookup. That lookup fails if no other schemas are
installed in the default directories.

Fixes #3429.
2024-08-14 16:14:45 +00:00
Philip Withnall
ab616db01e Merge branch 'wip/3v1n0/ci-really-use-fedora-39' into 'main'
ci: Ignore lcov errors on source missing, handle atomic writes and actually use Fedora 39 image

Closes #3381

See merge request GNOME/glib!4096
2024-08-14 14:58:36 +00:00
Philip Withnall
93fb9951aa
gunixmounts: Drop some Interix and QNX support
This can never have been tested, it was returning `GUnixMountEntry`
structs from functions which are typed to return `GUnixMountPoint`s.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-08-14 15:52:11 +01:00
Philip Withnall
04ee011171
tests: Add tests for handling of fstab and mtab files
While GLib doesn’t parse these files, it does provide API to access the
fields from them, and does implement some logic based on options fields
in them. It would be nice to be able to test that, and get coverage of
the methods for `GUnixMountPoint` and `GUnixMountEntry`.
2024-08-14 15:52:02 +01:00
Philip Withnall
5040cf1943
gunixmounts: Add mount point/entry getters from files
We don’t expect users to start querying the fstab or mtab by explicitly
loading data from those file paths. These functions are mainly intended
to prove a controllable entry point into the `gunixmounts.c` code for
unit testing.

It means we can provide a file with controllable contents in order to
test the mount entry/point code on.

See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4155

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-08-14 15:51:49 +01:00
Philip Withnall
742f38fa93 Merge branch 'jsparber/open_uri_activation_token' into 'main'
gappinfo: Pass activation token from launch context to open_uri/file portal

Closes #2868

See merge request GNOME/glib!3933
2024-08-14 14:16:40 +00:00
Philip Withnall
c5e17bc37f Merge branch 'amolenaar/macos-launch-uris-async' into 'main'
macos: Implement GAppInfo launch_uris_async interface

Closes #3403

See merge request GNOME/glib!4129
2024-08-14 13:16:06 +00:00
Luke T. Shumaker
03a2ec8fee docs: g_socket_{get,set}_option: Fix the link to gnetworking.h 2024-08-13 15:19:21 -06:00
Luke T. Shumaker
e4a2aa8f39 docs: Wrap things that gi-docgen mistakes as HTML tags in backticks
This are nasty, because they mean words get dropped from the
documentation.  This can be seen at

 - https://docs.gtk.org/gio/ctor.DBusNodeInfo.new_for_xml.html where
   it reads "one top-level element" instead of "one top-level <node>
   element".

 - https://docs.gtk.org/gio/method.ProxyResolver.lookup.html where it
   reads "where could be" instead of "where <protocol> could be".

 - https://docs.gtk.org/gio/method.Socket.get_option.html where it
   reads "[][gio-gnetworking.h]" instead of
   "[<gio/gnetworking.h>][gio-gnetworking.h" (also, this markdown link
   needs fixed, but let's save that for another commit).

 - https://docs.gtk.org/glib/ctor.DateTime.new_from_iso8601.html where
   the text is incomprehensible; "strings of the form are supported"
   instead of "strings of the form <date><sep><time><tz> are
   supported"; further references to <sep>, <date>, <time>, and <tz>
   are similarly mangled.

 - https://docs.gtk.org/glib/method.MatchInfo.fetch_named.html and
   https://docs.gtk.org/glib/method.MatchInfo.fetch_named_pos.html
   where the regex reads as "(?Pa)?b" instead of as "(?P<X>a)?b",
   changing the meaning of it.

 - https://docs.gtk.org/glib/method.Regex.match_all_full.html is all
   wack because the "<a>" in the example string is taken to be an HTML
   link; and all example strings and regexes are mangled (also, one of
   the regexes has a stray ";" in it, but let's save that for another
   commit).

 - https://docs.gtk.org/glib/method.Regex.replace.html where it simply
   reads "\g" instead of "\g<number>" and "\g<name>".

Fix those.
2024-08-13 15:19:21 -06:00
Luke T. Shumaker
d0b59da656 docs: Transition remaining DocBook XML to markdown/HTML
These remaining DocBook tags are mostly harmless; they are passed as
HTML5 tags to the browser, which effectively treats them as just
<span> elements, so all this mistake is doing is dropping some
styling.

This lack of of styling can be seen at:

 - https://docs.gtk.org/gio/enum.DriveStartStopType.html "ATA SECURITY
   UNLOCK DEVICE" is not indicated to be a quote or anything.

 - https://docs.gtk.org/gio/struct.UnixMountEntry.html "/media/cdrom"
   is not rendered in monospace.

 - https://docs.gtk.org/gio/struct.UnixMountPoint.html "/dev" is not
   rendered in monospace.

 - https://docs.gtk.org/glib/type_func.Thread.init.html the notes are
   not indicated to be anything other than regular paragraphs.

Fix that.
2024-08-13 15:19:14 -06:00
Arjan Molenaar
2ad61ed0ee Fix formatting issues 2024-08-10 19:42:32 +02:00
Arjan Molenaar
d23c781e7b macos: Tune launch results for CI
It looks like we have no Finder running.
2024-08-10 19:34:29 +02:00
Arjan Molenaar
1053c016d9 macos: Add test case for invalid scheme
You may not always know which schemes are available.

The library should not bail out, but only show
an informal message. It's the responsibility of
the application to deal with invalid URI schemes.
2024-08-10 19:34:29 +02:00
Arjan Molenaar
fac8a8c8d8 macos: Add test for async launcher
The test brings a Finder window to the front. It's not ideal,
but I have no better idea at the moment. It would be cool if we
can make the test case register itself as handler for a particular
uri scheme, but I have no idea how to do that.
2024-08-10 19:34:29 +02:00
Arjan Molenaar
edd36a907b macos: simplify urlspec setup for launch_uris_async
NB. Using toll-free bridging to cast NSURL to a CFURLRef
See https://developer.apple.com/library/archive/documentation/General/Conceptual/CocoaEncyclopedia/Toll-FreeBridgin/Toll-FreeBridgin.html
2024-08-10 19:34:29 +02:00
Arjan Molenaar
9f0ff882c1 macos: Fill appUrl directly
No need to convert it to a char* first.
This also avoids threading issues with OsxAppInfo's get_filename() method.
2024-08-10 19:34:29 +02:00
Arjan Molenaar
71e87fc29c more indentation fixes 2024-08-10 19:34:29 +02:00
Arjan Molenaar
e9ee147ac9 macos: fix header indentation 2024-08-10 19:34:29 +02:00
Arjan Molenaar
c67ae98588 macos: Implement GAppInfo.launch_uris_async interface
The implementation is heavily inspired by the Windows implementation.
2024-08-10 19:34:29 +02:00
Emmanuele Bassi
c865680f96 Merge branch 'fix-up-gapplication-docs-a-little' into 'main'
docs: Linkify a function

See merge request GNOME/glib!4181
2024-08-05 12:55:32 +00:00
Matthias Clasen
653cdb73d7 docs: Linkify a function
I answered a question on irc about withdrawing notifications, and
when I handed out a link to the GApplication docs, I noticed we
don't have this function name linkified. Fix that.
2024-08-05 08:23:45 -04:00
Marco Trevisan (Treviño)
6c679fb37a gcancellable: Mark assert-only variable as unused 2024-08-02 13:57:29 +02:00
Julian Sparber
23b858a3de gappinfo: Pass activation token from launch context to open_uri/file portal
The `activation_token` option was added to the portal in v4, so let's
actually pass a activation token if we have one.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2868
2024-07-29 09:30:09 +02:00
Julian Sparber
6210708f05 gappinfo: Allow giving no GAppInfo for getting startup notify id
On Wayland the activation token returned by
`g_app_launch_context_get_startup_notify_id()` doesn't depend on the
`GAppInfo`. The token is only used to hand over focus to the
application that is launched. In some cases it's not even possible to know
what application will actually be used to open the files. For example
when using portals within a sandbox. Therefore, allow providing no
`GAppInfo`.

This also makes clear in the docs that the `files` argument can be `NULL`.
2024-07-29 09:30:09 +02:00
Julian Sparber
6ee0389f68 gopenuriportal: Rename functions and switch to GFile as argument
We want to add the support for the activation token, to get it we use
`g_app_launch_context_get_startup_notify_id` which takes a list of
files, so that we don't have to create a GFile twice simply change the
signature of the functions. Fortunately this isn't a public API.
2024-07-29 09:30:09 +02:00
Roshan-R
c534037e12 meson: Fix project not compiling in macOS
Fixes: #3419
2024-07-28 19:50:30 +05:30
Nirbheek Chauhan
a4483644e8 meson: Fix another kqueue build race on macOS
`gobject-visibility.h` is also needed at build time. To reproduce the
error, just run `ninja gio/kqueue/libkqueue.a`
2024-07-27 08:03:42 +05:30
Philip Withnall
460d284fce
gcontenttype: Add platform-independent top level API file
This file doesn’t contain any real implementation, it just call the
`impl` functions from the platform-specific files
`gcontenttype-{fdo,osx,win32}.[cm]`.

It serves as a location for the doc comments, introspection annotations
and API preconditions, and will be built on every platform. In
particular, this means that we get consistent GIR output for the
`g_content_type_*()` APIs regardless of whether GLib was built on Linux or
Windows or macOS.

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

Helps: #3399
2024-07-24 17:46:31 +02:00
Philip Withnall
7bec6327a2
gio: Rename gcontenttype.c to gcontenttype-fdo.c
This reflects its status as actually platform-dependent: it’s only built
on systems using the freedesktop.org content type system.

It makes the file naming match up with other platform-specific
implementations, such as `gcontenttype-win32.c` and
`gcontenttype-osx.m`.

A subsequent commit will introduce a platform-independent high level API
wrapper so that the introspection annotations from this file can be
reused between platforms.

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

Helps: #3399
2024-07-24 17:46:25 +02:00
Philip Withnall
bf630dd4fd
gio: Rename gosxcontenttype.m to gcontenttype-osx.m
To make it consistent with the other platform-specific content type
implementations.

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

Helps: #3399
2024-07-24 17:46:19 +02:00
Philip Withnall
21fdb3be24
gappinfo: Move all platform-independent API docs to gappinfo.c
Previously, some of the doc comments for platform-independent APIs were
in `gdesktopappinfo.c`, which is only built on Unix systems. This meant
the introspection annotations for those APIs were not used on non-Unix
systems, which caused platform differences in `Gio-2.0.gir`.

So, move those doc comments to `gappinfo.c` and put them next to some
new platform-independent wrapper functions which provide a consistent
entry point and location for the API preconditions.

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

Helps: #3399
2024-07-24 17:45:22 +02:00
Philip Withnall
d1945c7abb
gdesktopappinfo: Add additional links to the Desktop Entry Spec
Might as well make it easy for people to look up what we’re talking
about.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-24 14:37:18 +02:00
Philip Withnall
c474d4065d
gdesktopappinfo: Port doc comments to gi-docgen syntax
Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3250
2024-07-24 14:23:18 +02:00
Marco Trevisan (Treviño)
54d9c26b34 gcancellable: Reference the object before locking when doing signal emission
On g_cancellable_cancel() we were increasing the GCancellable ref count
before emitting the ::cancelled signal, this is a safe thing to do but
it was happening while the cancellable was locked, and this may have
potentially waken up some toggle notifications.

To prevent this, reference the GCancellable just before locking.
2024-07-24 00:21:35 +02:00
Marco Trevisan (Treviño)
3a07b2abd4 GCancellable: Use per-instance mutex logic instead of global critical sections
GCancellable is meant to be used in multi-thread operations but all the
cancellable instances were sharing a single mutex to synchronize them
which can be less optimal when many instances are in place.
Especially when we're doing a lock/unlock dances that may leave another
thread to take the control of a critical section in an unexpected way.

This in fact was leading to some races in GCancellableSources causing
leaks because we were assuming that the "cancelled" callback was always
called before our dispose implementation.

As per this, use per-instance mutexes.

The lock is also now used only to protect the calls that may interact
with cancelled state or that depends on that, as per this we can just
reduce it to the cancel and reset case, other than to the connect one to
prevent the race that we could have when connecting to a cancellable
that is reset from another thread.

We don't really need to release the locks during callbacks now as they
are per instance, and there's really no function that we allowed to call
during a ::cancelled signal callback that may require an unlocked state.
This could been done in case with a recursive lock, that is easy enough
to implement but not really needed for this case.

Fixes: #2309, #2313
2024-07-24 00:21:35 +02:00
Marco Trevisan (Treviño)
0a8cb10f22 gio/tests: Ensure that a GCancellableSource can be used muliple times
Closes: #774
2024-07-24 00:21:35 +02:00
Ondrej Holy
d9fec76b59 gfile: Add support for x-gvfs-trash mount option
Currently, the trash functionality is disabled for system internal mounts.
That might be a problem in some cases. The `x-gvfs-notrash` mount option
allows disabling the trash functionality for certain mounts. Let's add
support for the `x-gvfs-trash` mount option to allow the opposite.

See: https://issues.redhat.com/browse/RHEL-46828
2024-07-16 07:52:00 +02:00
Georges Basile Stavracas Neto
a84c67da71 gio/appinfo: Directly link GdkAppLaunchContext
We can only use the [class@Foo.Bar] syntax for identifiers under
namespaces included by the current namespace. Naturally, we cannot
include the GDK namespace.

Use a direct link for this instead.
2024-07-11 16:23:06 +01:00
Georges Basile Stavracas Neto
ecc9904996 gio/applaunchcontext: Port docs to gi-docgen
This one is a little more self-contained, even though the class name
doesn't match the file it is in.
2024-07-11 15:33:41 +01:00
Georges Basile Stavracas Neto
b8db83940b gio/appinfo: Port docs to gi-docgen
Adjust all docs to use the gi-docgen referencing syntax, reindent
some of the comments, and add missing annotations to some async
methods.

The error arguments are not necessary with gi-docgen so they're
removed.

Confusingly enough, the docks for GAppInfo is spread between two
files.
2024-07-11 15:33:41 +01:00
Georges Basile Stavracas Neto
110e76a140 gio/actionmap: Port docs to gi-docgen 2024-07-11 15:33:41 +01:00