Commit Graph

2490 Commits

Author SHA1 Message Date
Xavier Claessens
be3728b9fa Meson: Add glib_checks and glib_asserts options
In cases where performance are critical it can be useful to disable
checks and asserts. GStreamer has those options too, using the same name
and setting them yielding means we can set those options on the main
project (e.g. gst-build) and glib will inherit the same value when built
as subproject.
2020-04-09 09:17:35 -04:00
Ondrej Holy
5737d064f9 docs: Mention new gio tool options
New features were added for gio tool, but they are not mentioned in
man pages as it is not generated from GOptionEntry in contrast to the
help output. Let's update the man pages to reflect the recent changes.
2020-04-02 13:23:09 +02:00
Chris Mayo
84ad802c3a docs: Fix configuration with gtk_doc=true and installed_tests=false
Skip the gdbus-object-manager-example which is generated as part of
testing.

Program xsltproc found: YES (/usr/bin/xsltproc)
Run-time dependency gtk-doc found: YES 1.32

docs/reference/gio/gdbus-object-manager-example/meson.build:1:0: ERROR:
Unknown variable "libgdbus_example_objectmanager_dep".
2020-03-27 19:33:12 +00:00
Jehan
13d1697b67 gobject: Add g_{param_spec,signal}_is_valid_name() functions
Making this validation code public allows projects to validate a
GParamSpec name before creating it. While hard-coded GParamSpec don't
need this, we can't afford crashing the main program for dynamically
generated GParamSpec from user-created data.

In such case, we will need to validate the param names and return errors
instead of trying to create a GParamSpec with invalid names.

Includes modifications from Philip Withnall and Emmanuele Bassi to
rearrange the new function addition and split it into one function for
GParamSpecs and one for GSignals.
2020-03-04 14:46:28 +00:00
Philip Withnall
fb1e416a32 gversionmacros: Add version macros for GLib 2.66
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-03-04 14:46:28 +00:00
Nirbheek Chauhan
3732f9bd07 docs: Document generated headers caveats for genmarshal
And also link to the Meson FAQ that explains why this is needed so
people aren't just cargo-culting code.
2020-02-25 03:14:50 +05:30
Emmanuele Bassi
653e0f0813 Add links to Meson docs for genmarshal and mkenums 2020-02-24 16:14:33 +00:00
Emmanuele Bassi
83c13e52d5 docs: Mention Meson's gnome.mkenums_simple()
The mkenums_simple() function generates idiomatic GObject code, and
avoids templates and custom command line arguments.
2020-02-24 16:14:33 +00:00
Emmanuele Bassi
79cdd531d0 Add example of using glib-genmarshal with Meson
We're using Meson for GLib itself, and we recommend people to use it
for their own projects, so it would be good to have our documentation
present examples on how to use Meson with our tools.
2020-02-24 16:14:33 +00:00
Emmanuele Bassi
040803b34d Add example of using glib-mkenums with Meson
We're using Meson for GLib itself, and we recommend people to use it
for their own projects, so it would be good to have our documentation
present examples on how to use Meson with our tools.

Let's move the template example into its own section while we're at it,
since it's referenced by both Meson and Autotools examples.

Fixes: #1783
2020-02-24 15:46:35 +00:00
Emmanuele Bassi
15a4cf4d3f Ensure that we use @basename@ in the glib-mkenums docs
The documentation for @filename@ is not accurate either.
2020-02-24 15:08:49 +00:00
Philip Withnall
760c8ccbe6 docs: Don’t install object manager example separately
The relevant parts of the generated example documentation are already
`xi:include`d into the `migrating-gdbus.xml` page, so are turned into
HTML there. Installing them separately means they also get installed
into `/usr/share/gtk-doc/html/gdbus-object-manager-example/`, which
seems redundant.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-11 11:47:03 +00:00
Philip Withnall
a0e74a8c47 Merge branch '1993-codegen-version-args' into 'master'
Rename gdbus-codegen --glib-min-version argument to --glib-min-required and add --glib-max-allowed

Closes #1993

See merge request GNOME/glib!1342
2020-01-31 13:49:20 +00:00
Philip Withnall
e855e30d6d Merge branch 'gtkdoc-check-fix' into 'master'
Various fixes to make gtkdoc-check pass on glib

See merge request GNOME/glib!978
2020-01-31 13:23:42 +00:00
Philip Withnall
c07d9434f4 Merge branch 'wip/oholy/gfile-docs' into 'master'
Symlink-related fixes for `g_file_move()`

Closes #986

See merge request GNOME/glib!900
2020-01-31 12:56:15 +00:00
Michael Catanzaro
d58e5de9e9 Revert "gtlscertificate: Add support for PKCS #11 backed certificates"
This reverts commit b6d8efbebc.

This GLib API is good, but the implentation is not ready, so there's no
reason to commit to the API in GLib 2.64. We can reland again when the
implementation is ready.

There are three problems: (a) The glib-networking implementation normally
works, but the test has been broken for a long time. I'm not comfortable
with adding a major new feature without a working test. This is
glib-networking#104. (b) The WebKit implementation never landed. There
is a working patch, but it hasn't been accepted upstream yet. This API
isn't needed in GLib until WebKit is ready to start using it.
https://bugs.webkit.org/show_bug.cgi?id=200805. (c) Similarly, even if
the WebKit API was ready, that itself isn't useful until an application
is ready to start using it, and the Epiphany level work never happened.

Let's try again for GLib 2.66. Reverting this commit now just means we
gain another six months before committing to the API forever. No reason
to keep this in GLib 2.64 when nothing is using it yet.
2020-01-30 04:19:22 -06:00
Xavier Claessens
5bd78907a7 doc: Add gtk-doc subproject fallback
Now that we require Meson 0.52 to build the doc, we can also pull
gtk-doc as subproject when missing from the system. This requires
to pull gtk-doc master because needed changes there haven't been release
yet.
2020-01-29 15:54:53 +01:00
Xavier Claessens
ed0e06097c doc: Requires Meson >=0.52.0 to build documentation 2020-01-29 15:54:53 +01:00
Xavier Claessens
09d995286b doc: Run gtkdoc-check with unit tests
This has the side effect of always rebuilding the doc at each build when
gtk_doc option is enabled (not by default). Most importantly, this will
enable doc check on our CI.
2020-01-29 15:54:53 +01:00
Xavier Claessens
74bb6c98cb doc: add missing indexes 2020-01-29 15:54:53 +01:00
Xavier Claessens
6e8a7c2cd4 doc: Add back gdbus-object-manager-example
This requires Meson 0.52.0 for the return value of gnome.gtkdoc().
2020-01-29 15:40:17 +01:00
Xavier Claessens
6d05ac2fa9 Revert "docs: remove GDBusObjectManager example"
This reverts commit 398c048c66.

It got removed because it used to cause build issues, but now that we
have a CI let's hope it won't be a problem any more.
2020-01-29 15:40:17 +01:00
Nelson Benítez León
fc1e2bc9f0 docs: tag enclose 'all' and 'help' values
so they are not confused as being normal text.

Seen at:
https://developer.gnome.org/glib/stable/glib-running.html
2020-01-29 12:11:24 +00:00
Philip Withnall
9734e4854e gdbus-codegen: Add --glib-max-allowed argument
This complements the `--glib-min-required` argument, just like the
`GLIB_MIN_REQUIRED` and `GLIB_MAX_ALLOWED` preprocessor defines which
control access to APIs in C.

Currently, it doesn’t affect code generation at all. When we next change
code generation, we will need to gate any new API usage on this
argument.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1993
2020-01-27 10:42:26 +00:00
Philip Withnall
4d1c3e15f9 gdbus-codegen: Rename --glib-min-version to --glib-min-required
This makes it consistent with the `GLIB_MIN_REQUIRED` defines which are
used for API stability/versioning in C code.

It doesn’t otherwise change the behaviour of the `--glib-min-version`
argument.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1993
2020-01-27 10:11:46 +00:00
Marc-André Lureau
fd61a21ecd Add and use G_SIZEOF_MEMBER() macro
A convenient macro present in the Linux kernel, named FIELD_SIZE() there.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-01-21 19:54:55 +04:00
wouter bolsterlee
809a9210c3 Support multiple directories in GSETTINGS_SCHEMA_DIR
This adds support for specifying multiple directories in the
GSETTINGS_SCHEMA_DIR environment variable by separating the values
using G_SEARCHPATH_SEPARATOR_S (colon on UNIX-like systems).

While programs could already register multiple custom GSettings schema
directories, it was not possible to achieve the same without writing
custom code, e.g. when using the gsettings command line tool.

Fixes #1998.
2020-01-16 10:20:34 +00:00
Matthew Leeds
2a605f6e15 gdbus-codegen: Add call_flags and timeout_msec args
Currently the code generated by gdbus-codegen uses
G_DBUS_CALL_FLAGS_NONE in its D-Bus calls, which occur for each method
defined by the input XML, and for proxy_set_property functions. This
means that if the daemon which implements the methods checks for
G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION and only does interactive
authorization if that flag is present, users of the generated code have
no way to cause the daemon to use interactive authorization (e.g. polkit
dialogs).

If we simply changed the generated code to always use
G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION, its users would have no
way to disallow interactive authorization (except for manually calling
the D-Bus method themselves).

So instead, this commit adds a GDBusCallFlags argument to method call
functions. Since this is an API break which will require changes in
projects using gdbus-codegen code, the change is conditional on the
command line argument --glib-min-version having the value 2.64 or
higher.

The impetus for this change is that I'm changing accountsservice to
properly respect G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION, and
libaccountsservice uses generated code for D-Bus method calls. So
these changes will allow libaccountsservice to continue allowing
interactive authorization, and avoid breaking any users of it which
expect that. See
https://gitlab.freedesktop.org/accountsservice/accountsservice/merge_requests/46

It might make sense to also let GDBusCallFlags be specified for property
set operations, but that is not needed in the case of accountsservice,
and would require significant work and breaking API in multiple places.

Similarly, the generated code currently hard codes -1 as the timeout
value when calling g_dbus_proxy_call*(). Add a timeout_msec argument so
the user of the generated code can specify the timeout as well.

Also, test this new API. In gio/tests/codegen.py we test that the new
arguments are generated if and only of --glib-min-version is used with a
value greater than or equal to 2.64, and in gio/tests/meson.build we
test that the generated code with the new API can be linked against.

The test_unix_fd_list() test also needed modification to continue
working now that we're using gdbus-test-codegen.c with code generated
with --glib-min-version=2.64 in one test.

Finally, update the docs for gdbus-codegen to explain the effect of
using --glib-min-version 2.64, both from this commit and from
"gdbus-codegen: Emit GUnixFDLists if an arg has type `h` w/
min-version".
2020-01-15 09:37:41 -08:00
Philip Withnall
eda096243b docs: Add g_source_set_dispose_function() to documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-12-16 13:57:28 +00:00
Philip Withnall
467b4d6789 docs: Update GMemoryMonitor listings in docs
Fix a few things missed in code review.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-12-16 13:57:28 +00:00
Emmanuele Bassi
4ad429c7ca Merge branch 'revert-1277-i-got-it-wrong' into 'master'
Revert "Revert "docs: remove GDBusObjectManager example""

See merge request GNOME/glib!1282
2019-12-16 12:37:34 +00:00
Emmanuele Bassi
f9bbee7db2 Merge branch '1726-codegen-glib-min-version' into 'master'
gdbus-codegen: Emit GUnixFDLists if an arg has type `h` w/ min-version

Closes #1726

See merge request GNOME/glib!1263
2019-12-12 12:49:34 +00:00
Philip Withnall
df8745fabc Revert "Revert "docs: remove GDBusObjectManager example""
This reverts commit df4fb2cd32.

It needed to be coupled with the other commit from !978, and introduces
breakage into the documentation when compiled by itself. My mistake for
not testing properly.

See discussion on https://gitlab.gnome.org/GNOME/glib/merge_requests/1277#note_666761
2019-12-12 11:30:36 +00:00
Philip Withnall
fcc1367383 Merge branch 'gtkdoc-check-fix' into 'master'
Various gtk-doc improvements

See merge request GNOME/glib!1277
2019-12-11 13:02:20 +00:00
Xavier Claessens
df4fb2cd32 Revert "docs: remove GDBusObjectManager example"
This reverts commit 398c048c66.

It got removed because it used to cause build issues, but now that we
have a CI let's hope it won't be a problem any more.
2019-12-11 12:16:27 +00:00
Bastien Nocera
cd6612dfb7 gio: Add GMemoryMonitor to monitor for low-memory
Add a memory monitor object, with D-Bus and Portal based
implementations. The D-Bus implementation uses the Linux-only
low-memory-monitor Freedesktop project.

Low Memory Monitor D-Bus API:
https://hadess.pages.freedesktop.org/low-memory-monitor/

Android API:
https://developer.android.com/reference/android/content/ComponentCallbacks2.html#onTrimMemory(int)

iOS API:
https://developer.apple.com/documentation/uikit/app_and_environment/managing_your_app_s_life_cycle/responding_to_memory_warnings

Win32 API:
https://docs.microsoft.com/en-us/dotnet/api/microsoft.win32.systemevents.lowmemory?view=netframework-4.8

Tizen API:
https://samsung.github.io/TizenFX/master/api/Tizen.Applications.EventManager.SystemEvents.LowMemory.html
2019-12-11 11:44:42 +00:00
Philip Withnall
90f0733858 gdbus-codegen: Add a --glib-min-version argument
This can be used by callers to opt-in to backwards-incompatible changes
to the behaviour or output of `gdbus-codegen` in future. This commit
doesn’t introduce any such changes, though.

Documentation and unit tests included.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1726
2019-12-11 10:40:07 +00:00
Philip Withnall
b698327b99 Merge branch 'cherry-pick-6ea0dcc6' into 'master'
doc: Add missing --ignore-decorators

Closes #1953

See merge request GNOME/glib!1260
2019-12-03 12:48:37 +00:00
Xavier Claessens
160143ae27 gtk-doc: Ensure we have recent enough version
Older versions won't produce errors, but will silently miss
documentation for a few symbols.
2019-12-01 08:25:04 -05:00
Xavier Claessens
7b65b77a65 doc: Add missing --ignore-decorators
(cherry picked from commit 6ea0dcc6c9af0c0e8cfebc77412838f5174b7dbc)
2019-11-29 18:43:10 +00:00
Emmanuele Bassi
cc3716a943 Merge branch 'thread-safe-getpwnam' into 'master'
glocalvfs: Use thread-safe getpwnam_r() rather than getpwnam()

Closes #1687

See merge request GNOME/glib!681
2019-11-27 11:58:51 +00:00
Philip Withnall
34cb297a86 Merge branch 'wip/nielsdg/g-list-store-find' into 'master'
gliststore: Add item lookup functions

Closes #1011

See merge request GNOME/glib!1096
2019-11-27 11:22:56 +00:00
Philip Withnall
94a800fb9d glib-unix: Add g_unix_get_passwd_entry() function
This is a convenience wrapper around getpwnam_r() which handles all the
memory allocation faff.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1687
2019-11-26 12:17:04 +00:00
Ernestas Kulik
58ba7d78fb list, slist: Add g_clear_{s,}list()
Although not quite as often-occurring, this should help with constructs
like this:

  if (list)
    {
      g_list_free_full (list, foo);
      list = NULL;
    }

Closes https://gitlab.gnome.org/GNOME/glib/issues/1943
2019-11-25 13:09:25 +01:00
Garrett Regier
6cac760551 task: Add return/propagate API for GValue
This is useful for bindings.

Related: https://gitlab.gnome.org/GNOME/glib/issues/668
2019-11-15 10:37:42 +00:00
Simon McVittie
81936ca580 Make ld executable configurable
Tools like this should be configurable in a cross or native file. In
particular, if we are cross-compiling (with an executable wrapper like
qemu-arm), the build system ld is not necessarily able to manipulate
host system objects.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-11-04 15:08:33 +00:00
Simon McVittie
61f693fb21 Merge branch '1916-objcopy-cross-compilation' into 'master'
tests: Use objcopy from the cross-compilation file, if configured

Closes #1916

See merge request GNOME/glib!1188
2019-10-28 20:06:50 +00:00
Philip Withnall
c73bd53eb8 Merge branch 'fbsd_build' into 'master'
Update documentation with FreeBSD build instructions

See merge request GNOME/glib!1120
2019-10-28 17:26:26 +00:00
Philip Withnall
57aaee76d5 docs: Add objcopy to example cross-compilation file
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1916
2019-10-28 12:11:12 +00:00
Philip Withnall
21f8f89820 gmain: Add GMainContextPusher convenience API
This is like `GMutexLocker`, in that if you are able to use
`g_autoptr()`, it makes popping a `GMainContext` off the thread-default
main context stack easier when exiting a function.

A few uses of `G_GNUC_{BEGIN,END}_IGNORE_DEPRECATIONS` are needed to
avoid warnings when building apps against GLib with
`GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_64`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-23 11:35:58 +01:00