Commit Graph

66 Commits

Author SHA1 Message Date
Philip Withnall
5942cd7984 gio: Add SPDX license headers automatically
Add SPDX license (but not copyright) headers to all files which follow a
certain pattern in their existing non-machine-readable header comment.

This commit was entirely generated using the command:
```
git ls-files gio/*.[ch] | xargs perl -0777 -pi -e 's/\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/\n \*\n \* SPDX-License-Identifier: LGPL-2.1-or-later\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/igs'
```

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

Helps: #1415
2022-05-18 09:18:52 +01:00
Loic Le Page
e0ccf08284 Fix non-initialized variable in gio/gsettings-tool.c 2022-02-18 11:01:40 +01:00
Frederic Martinsons
296a8c6522 Sort output of gsettings command-line tool
Closes #1781

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-11-18 08:59:55 +01:00
Emmanuel Fleury
a7d3ecca77 Fix signedness warning in gio/gsettings-tool.c
gio/gsettings-tool.c: In function ‘gsettings_list_children’:
gio/gsettings-tool.c:199:30: error: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘gint’ {aka ‘int’}
  199 |     if (strlen (children[i]) > max)
      |                              ^
2021-04-05 12:03:51 +02:00
Chun-wei Fan
9f709fe1e9 gio tools: Use the proper string for default locale for setlocale()
This makes use of the string we now have from glib-private.h in the
last commit so that setlocale() sets the default system locale
correctly and therefore show the translated messages properly.

Fixes issue #1169.
2019-06-18 17:29:41 +08:00
Allison Lortie
235f4958a9 gsettings: remove redundancy in 'list-recursive'
Some projects use child schemas in an odd way: they link children which
already have their path pre-defined.  This causes the child schema (and
its keys) to be printed out twice:

 - once because it is, itself, a non-relocatable schema

 - once, as a recursion from its parent

We can avoid this by not recursing into child schemas that are
non-relocatable (on the assumption that they will be enumerated
elsewhere).

https://bugzilla.gnome.org/show_bug.cgi?id=723003
2018-02-02 14:41:00 +01:00
Arnaud Bonatti
6d009bc56a Add ‘gsettings list-schemas --print-paths’ option
Prints next to the name of non-relocatable schemas their paths.

https://bugzilla.gnome.org/show_bug.cgi?id=792064
2018-01-05 13:01:03 +00:00
Matthias Clasen
28cc6aeb19 gsettings: Try harder to describe keys
If a key has no description, show the summary,
rather than "(null)". Since thats not helpful at all.
2017-07-07 19:11:51 -04:00
Sébastien Wilmet
3bf4a720c3 gio/: LGPLv2+ -> LGPLv2.1+
Sub-directories inside gio/ already processed in a previous commit:
- fam/
- gdbus-2.0/ (which contains only codegen/)
- gvdb/
- inotify/
- tests/
- win32/
- xdgmime/

Other sub-directories inside gio/:
- completion/: no license headers
- kqueue/: not LGPL, BSD-style license

https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-29 19:53:34 +02:00
Piotr Drąg
10c490cdfe Use Unicode in translatable strings
See https://developer.gnome.org/hig/stable/typography.html

https://bugzilla.gnome.org/show_bug.cgi?id=772221
2016-10-12 21:30:42 +02:00
Jeremy Whiting
8fd72838ce Added describe command to gsettings command-line tool.
describe command shows description of given gsettings key.
Added documentation of describe command to gsettings man page.
2016-08-25 12:40:27 -06:00
Jan Alexander Steffens (heftig)
5a894c3232 gsettings: Don't crash when no schemas are installed
Still doesn't behave well ("gsettings help" causes an error),
but at least there's no segfault anymore.

https://bugzilla.gnome.org/show_bug.cgi?id=724847
2016-03-02 19:04:28 -05:00
Matthias Clasen
1dec512a66 Revert "GSettings: delay backend subscription"
This reverts commit 8ff5668a45.

This change has had considerable fallout, and there was no
follow-up to address it.

https://bugzilla.gnome.org/show_bug.cgi?id=733791
2015-09-01 10:21:26 -04:00
Dan Winship
e02fa68068 gsettings-tool: fix deprecated call 2015-08-07 09:50:13 -04:00
Ryan Lortie
bb8eea6148 gsettings tool: use schema for listing keys
Use the newly added g_settings_schema_list_keys() API instead of
g_settings_list_keys() in order to list keys.

Doing this allows the 'list-keys' command to work without creating a
GSettings object, which is more efficient.  It also means that we don't
have to provide a (meaningless and ignored) path when listing keys on
relocatable schemas.

While we're at it, update the 'range' command not to require creation of
a GSettings object, in a similar way.

https://bugzilla.gnome.org/show_bug.cgi?id=740308
2015-06-05 15:24:02 -04:00
Ryan Lortie
8ff5668a45 GSettings: delay backend subscription
GSettings objects begin watching for changes as soon as they are created
in order that they can emit the "changed" signal.

In the case of dconf, if we want to be able to emit the changed signal,
we need to go on the bus and add some match rules.  This requires
creating the dconf helper thread and also requires initialising GDBus
(which creates another thread).

Some users of GSettings are never interested in the "changed" signal.
One of these users is the glib-networking code that gets run every time
a new network connection is created.

Some users are reporting that they are annoyed that simply establishing
a network connection would spawn two extra threads and create a D-Bus
connection.

In order to avoid doing unnecessary work for these simple uses, delay
the subscription until we know that we will actually need to do it.

We do this in a simple way, using a simple argument: in order for the
user to care that a value changed then they must have:

 1) watched for a change signal; and then
 2) actually read a value

If the user didn't actually read a value then they cannot possibly be
interested in if the value changed or not (since they never knew the old
value to begin with and therefore would be unable to observe that it
ever changed, since they have nothing to compare the new value with).

This really is a behaviour change, however, and it does impact at least
one user: the 'monitor' functionality of the GSettings commandline tool,
which is interested in reporting changes without ever having known the
original values.  We add a workaround to the commandline tool in order
to ensure that it continues to function properly.

It's also possible to argue that it is completely valid to have read a
value and _then_ established a change signal connection under the
(correct) assumption that it would not have been possible to miss a
change signal by virtue of not having returned to the mainloop.
Although this argument is true, this pattern is extremely non-idiomatic,
and the problem is easily avoided by doing things in the usual order.

We never really talked about change notification in the overview
documentation for GSettings, so it seems like now is a good time to add
some discussion, including the new rules for when one can expect change
signals to be emitted.

https://bugzilla.gnome.org/show_bug.cgi?id=733791
2014-11-19 13:40:09 -05:00
Daniel Mustieles
078dbda148 Updated FSF's address 2014-01-31 14:31:55 +01:00
Ryan Lortie
420f90d849 gsettings tool: print GVariant errors in context
Use g_variant_parse_error_print_context() to format the error message
from the GVariant parser.

https://bugzilla.gnome.org/show_bug.cgi?id=715028
2013-12-22 11:41:43 -05:00
Ryan Lortie
43d19dae11 gsettings tool: stop using GMainLoop
Just iterate directly.
2013-11-27 12:42:32 -05:00
Ryan Lortie
f33a7f9ef2 gsettings tool: fix some sed damage
The previous patch to simplify the GSettings commandline tool by making
more use of global variables went a bit too far and broke 'gsettings
monitor' when used without a specific key.

Fix that up again.
2013-11-27 12:42:32 -05:00
Ryan Lortie
b30486985b gsettings(1): stop using deprecated APIs
Stop using the recently-deprecated GSettings APIs.

Use the GSettingsSchema-based APIs instead.

This fixes a number of bugs and also a net reduction of code. In
particular, list-schemas will now work in context of a given --schemadir
argument.

https://bugzilla.gnome.org/show_bug.cgi?id=695558
2013-10-28 11:49:10 -07:00
Ryan Lortie
a1a4dbf6ff gsettings(1): use global variables
The number of arguments passed to each function is about to increase, so
just use global variables instead.

This is a commandline tool, after all...

https://bugzilla.gnome.org/show_bug.cgi?id=695558
2013-10-28 11:48:32 -07:00
Jiro Matsuzawa
d5e2a57741 gsettings-tool: Add --version into general usage
https://bugzilla.gnome.org/show_bug.cgi?id=707002
2013-10-24 09:53:55 -04:00
Matthias Clasen
8753df9d70 gsettings tool: report failure to write
If a key is locked down, we should report an error if we
fail to write it.

https://bugzilla.gnome.org/show_bug.cgi?id=704424
2013-07-19 19:43:48 -04:00
David Gomes
bfb6ff0dbd gsettings: implemented --version command
This was discussed in
https://bugzilla.gnome.org/show_bug.cgi?id=697131
2013-04-03 21:35:57 -04:00
Jiro Matsuzawa
2549c33451 gsettings-tool: Make a string translatable
https://bugzilla.gnome.org/show_bug.cgi?id=695425
2013-03-09 23:56:02 +09:00
Dan Winship
3ac6cfaeaa win32: prototype _glib_get_dll_directory() and _glib_get_locale_dir()
Rather than using "extern" declarations of these win32 functions
everywhere they're needed, just prototype them in glib-private.h.
(Which also fixes the fact that they weren't prototyped in the files
where they're defined.)

https://bugzilla.gnome.org/show_bug.cgi?id=688109
2012-11-15 14:19:05 -05:00
Ryan Lortie
1dc774a653 Remove g_type_init() calls
Very many testcases, some GLib tools (resource compiler, etc) and
GApplication were calling g_type_init().

Remove those uses, as they are no longer required.

https://bugzilla.gnome.org/show_bug.cgi?id=686161
2012-10-16 09:39:24 -04:00
Daiki Ueno
030ebfb93b gsettings-tool: make list-recursively really recurse
https://bugzilla.gnome.org/show_bug.cgi?id=682586
2012-08-28 00:08:06 -04:00
Ryan Lortie
387ed239e2 gsettings tool: fix a memory error
8852d4e9a0 introduced a memory error by
taking the type of a GVariant, freeing the GVariant and using the type
after the free.

This delays the free until after we've used the type.

https://bugzilla.gnome.org/show_bug.cgi?id=669253
2012-02-02 10:53:50 -05:00
Matthias Clasen
8852d4e9a0 Fix a refcounting error
'new' is created floating, therefore it is consumed by
g_settings_set, and unreffing it after that call is not right.
2012-01-20 08:03:38 -05:00
Giovanni Campagna
466432830c gsettings-tool: allow specifying custom schema dirs
It happens that one wants to customize settings for plugins or
shell extensions, that installing schemas in nonstandard locations.
This patch adds the --schemadir option to gsettings, and ensure
that the appropriate schema is found.

https://bugzilla.gnome.org/show_bug.cgi?id=666415
2011-12-19 10:33:55 -05:00
Chun-wei Fan
09c98f18fc Update gsettings utilities in GIO
Avoid C99-style variable declaration
2011-06-07 10:49:29 +08:00
Ray Strode
eabad1923e Revert "gsettings-tool: warn if setting a value fails"
This reverts commit ea57feff96.

It makes the gsettings tool fail any time it tries to set a
key to a value, that the key already has.

https://bugzilla.gnome.org/show_bug.cgi?id=641768
2011-05-23 13:40:02 -04:00
Ryan Lortie
9793919d7b Whitespace fixes 2011-05-18 17:56:50 -04:00
Ryan Lortie
8148a3c396 Fix gsettings tool string handling
There are some bugs caused by the way that gsettings-tool currently
attempts to help the user when they leave the quotes off of a string
value that they are setting.

Simplify the code to make it more robust and add some comments about why
it should be done this way.

https://bugzilla.gnome.org/show_bug.cgi?id=649915
2011-05-17 11:58:46 -04:00
Colin Walters
bf087aabbf gsettings-tool fixes: Add missing _apply(), add unset-recursively to man page 2011-04-12 12:56:33 -04:00
Colin Walters
3fd9f2e8f9 gsettings: Implement reset-recursively
Motivation was the ability to:
$ gsettings reset-recursively org.gnome.gnome-panel

https://bugzilla.gnome.org/show_bug.cgi?id=647579
2011-04-12 12:13:43 -04:00
Dan Winship
ea57feff96 gsettings-tool: warn if setting a value fails
eg, if the dconf backend cannot connect to dbus

https://bugzilla.gnome.org/show_bug.cgi?id=641768
2011-04-09 12:45:16 -04:00
Matthias Clasen
766d70729b Allow to list keys in all schemas
Make the schema argument to gsettings list-recursively optional.
This allows to search for not exactly known keys by going

gsettings list-recursively | grep 'font'
2011-02-23 00:18:37 -05:00
Matthias Clasen
c3334490c7 Fix some problems with message handling
g_printerr() doesn't append a newline, so we have to consistently
do it everywhere. Also, we cannot call gettext on "", ever.
2011-02-12 12:45:25 -05:00
Matthias Clasen
51c87f6809 Update help and docs for gsettings cmdline tool
The man page had gotten quite out of sync.
2011-01-21 18:02:05 -05:00
Christian Persch
ce50df7e0e Better error reporting for g_variant_parse()
Add error codes, and use them when setting the GError.

Bug #634583.
2010-12-12 13:25:34 +01:00
Matthias Clasen
9574dbd228 Be more careful about overwriting errors
When trying to parse again, we don't want to overwrite the exiting
error.
2010-10-31 20:58:15 -04:00
Matthias Clasen
e24dfacd5b gsettings-tool: Support completion for enum values
https://bugzilla.gnome.org/show_bug.cgi?id=631264
2010-10-30 01:13:42 -04:00
Matthias Clasen
6298e88538 Add a command to list keys and values recursively
This is similar to gconftool-2 -R, which is very handy
for collecting information for bug reports, etc. It is now
possible to say gsettings list-recursively org.foo.bar, and
this will produce a list of schemas, keys and values for
org.foo.bar and all its child and grandchild schemata,
recursively.

https://bugzilla.gnome.org/show_bug.cgi?id=632571
2010-10-30 00:00:06 -04:00
Matthias Clasen
d619216686 Make gsettings-tool translatable again
This regression was caused by the recent rewrite.
2010-10-29 23:12:07 -04:00
Ryan Lortie
c4037230d4 gsettings-tool: Add 'range' subcommand
Provides access to the g_settings_get_range() functionality, converting
its return value to something that's reasonable for printing at the
console and potentially parseable.  The format may change.

Bug #631264.
2010-10-04 03:42:57 -04:00
Ryan Lortie
59bdba3cbb gsettings-tool: implement range-checking
Prevent assertion messages from spewing forth and also ensure that we
exit with an error status in the event that the value was out of range.

Bug #631264.
2010-10-04 03:42:43 -04:00
Ryan Lortie
2d6f8a8ea4 gsettings-tool: Rewrite
Rewrite the GSettings tool.

Improvements/changes:

 - simplify the code by performing common actions (like creating a
   schema) in only one place instead of one per-command

 - new features (list schemas, list keys, monitor multiple, etc)

 - factor-out bash completion and implement in shellscript

 - input validation: should never abort due to invalid inputs

Still to do:

 - proper error checking for ranges/choices

 - support for querying range/choice information

 - bash completion support for enums

Closes bug #629289, possibly among others.
2010-10-03 02:48:07 -04:00