Commit Graph

135 Commits

Author SHA1 Message Date
Lars Uebernickel
0f1579e62c g_settings_get: only check for non-copying format string
396d40af introduced a redundant call to g_variant_check_format_string().
Checking whether the format string copies all values is enough.

https://bugzilla.gnome.org/show_bug.cgi?id=719979
2013-12-09 15:51:56 +01:00
Lars Uebernickel
396d40af23 g_settings_get: check validity of format string
Allow only format strings that copy all values (i.e, don't contain '&'),
as the returned pointers might become invalid in some rare cases.

Since this is technically an API break, this patch only prints a
critical when a faulty format string is detected, but still fetches the
values.

https://bugzilla.gnome.org/show_bug.cgi?id=719979
2013-12-06 16:48:00 +01:00
Matthias Clasen
0cb8454b5c Small documentation improvement 2013-11-08 20:57:04 -05:00
Ryan Lortie
bcb030a474 GSettingsSchemaKey: add introspection APIs
Add g_settings_schema_has_key() and _get_range(), _range_check(),
_get_value_type(), _get_default_value() methods on GSettingsSchemaKey.

Deprecate the equivalent APIs on GSettings.

https://bugzilla.gnome.org/show_bug.cgi?id=683017
2013-10-28 11:31:48 -07:00
Ryan Lortie
bebdfb8e62 GSettings: add getters for user/default value
Add two new APIs: g_settings_get_user_value() and
g_settings_get_default_value().   Together, these should allow the
inspection of all interesting cases of "is this key set?" and "what
would happen if I reset this key?"

https://bugzilla.gnome.org/show_bug.cgi?id=668233
2013-10-28 10:19:49 -07:00
Ryan Lortie
2d06dbeef1 GSettings: small internal refactor
Add two boolean parameters to our internal getter utility function in
anticipation of the coming addition of g_settings_get_user_value() and
g_settings_get_default_value() APIs.

https://bugzilla.gnome.org/show_bug.cgi?id=668233
2013-10-28 10:19:49 -07:00
Ryan Lortie
6568843624 GSettings: verify path validity on constructors
Don't allow constructing GSettings objects with invalid paths.

https://bugzilla.gnome.org/show_bug.cgi?id=704802
2013-10-24 09:53:55 -04:00
Emmanuele Bassi
54cc43630d Rename the generated private data getter function
As it turns out, we have examples of internal functions called
type_name_get_private() in the wild (especially among older libraries),
so we need to use a name for the per-instance private data getter
function that hopefully won't conflict with anything.
2013-06-24 15:43:04 +01:00
Emmanuele Bassi
32747def4b gio: Use the new private instance data declaration
Use the newly added macros, and remove the explicit calls to
g_type_class_add_private().

https://bugzilla.gnome.org/show_bug.cgi?id=700035
2013-06-24 14:18:01 +01:00
Dan Winship
4b94c0831e Use 'dumb quotes' rather than `really dumb quotes'
Back in the far-off twentieth century, it was normal on unix
workstations for U+0060 GRAVE ACCENT to be drawn as "‛" and for U+0027
APOSTROPHE to be drawn as "’". This led to the convention of using
them as poor-man's ‛smart quotes’ in ASCII-only text.

However, "'" is now universally drawn as a vertical line, and "`" at a
45-degree angle, making them an `odd couple' when used together.

Unfortunately, there are lots of very old strings in glib, and also
lots of new strings in which people have kept up the old tradition,
perhaps entirely unaware that it used to not look stupid.

Fix this by just using 'dumb quotes' everywhere.

https://bugzilla.gnome.org/show_bug.cgi?id=700746
2013-05-21 11:23:22 -03:00
Ryan Lortie
1a20d56a89 g_settings_bind: use canonical property name
We were using the user-passed value of the @property argument for
several purposes in g_settings_bind(): error messages, binding
uniqueness (ie: one-binding-per-property-per-object) and most
importantly, connecting to the detailed notify:: signal.

The user may pass a string like "property_name" when the property's
canonical name is "property-name".  g_object_class_find_property() will
find the property under these circumstances, but a connection to
"notify::property_name" will not notice notifies emitted for
"property-name".

We can solve this by using the user's string to perform the lookup and
then using pspec->name for everything after that.

https://bugzilla.gnome.org/show_bug.cgi?id=684882
2012-10-15 19:28:28 -04:00
Ryan Lortie
ed492a5de2 GSettings: be more careful about keys names with /
Prevent attempts to access keys ending with slashes that exist in the
schema file as references to child schemas.

Also: don't emit change signals for these same keys.
2012-07-06 13:44:17 -04:00
Ryan Lortie
192892b52c GSettings docs: clarify what is a good path
Add an explicit note to the docs about choosing paths based on domain
names, not ones like "/apps/", "/desktop/" or "/system/".
2012-04-12 20:04:32 -04:00
Ryan Lortie
da386705f9 GSettings: two memory use fixes
First, correct a rather dubious case of accessing a GSettingsSchemaKey
after clearing it.  This was technically okay because only the key name
was accessed (and it is not owned by the struct) but it looks very
wrong.

Second, have g_settings_backend_write() sink the passed in GVariant*.
Not all backends get this right, and I'm starting to like the pattern of
virtual function wrappers being responsible for sinking the parameters
that they are documented as consuming.
2012-01-27 03:00:23 -05:00
Ryan Lortie
1d98d18f64 add a way to create a GAction from GSettings
g_settings_create_action() will create a GAction for the named key,
allowing it to be added to the action group of the application (so that
the setting can be directly manipulated from menus, for example).

https://bugzilla.gnome.org/show_bug.cgi?id=668279
2012-01-19 10:50:29 -05:00
Ryan Lortie
a795e563df Drop last uses of @returns: 2011-11-21 12:02:02 -05:00
Ryan Lortie
f9cc078671 We need <locale.h> in gsettingsschema.c now
for LC_TIME (since we moved a bunch of code over from gsettings.c).
2011-11-18 09:41:52 +00:00
Ryan Lortie
7f28529190 g_settings_new_full(): more docs 2011-11-17 17:33:19 +00:00
Jasper St. Pierre
f47264ef5c gsettings: add annotations for _new_full()
The path and backend arguments to g_settings_new_full are optional.
2011-11-17 14:03:39 +00:00
Ryan Lortie
148f731748 Add test case and fix some bugs
Add the first test case for the schema source functionality and fix a
couple of bugs that got uncovered by that.
2011-11-17 14:03:39 +00:00
Ryan Lortie
446eda8c2b Clarify docs/params for 'schema' vs 'schema id'
Clean up our parameter naming and documentation to draw a clearer line
between a schema and its identifier.
2011-11-17 14:03:39 +00:00
Ryan Lortie
1e70072065 Add g_settings_new_full() taking GSettingsSchema 2011-11-17 14:03:39 +00:00
Ryan Lortie
1c8ae819ed GSettings: add 'settings-schema' property
Ideally we'd have called this 'schema', but it is already used.
2011-11-17 14:03:39 +00:00
Ryan Lortie
c25a36c920 Drop the 'schema_name' field of GSettings
This is strictly redundant now that we can get the ID from the schema
itself.  Its only other purpose was to get the schema name from the
set_property() call to the constructed() call and we can avoid that by
doing the schema lookup at the time of the property being set.
2011-11-17 14:03:39 +00:00
Ryan Lortie
48b99017de speak of 'schema id' rather than 'schema name'
Schemas are identified by id='' in the xml file, so we should use the
same language on the C and GObject property APIs.
2011-11-17 14:03:39 +00:00
Ryan Lortie
736a286dce GSettings: deprecate 'schema' property
This should have been called 'schema-name'.
2011-11-17 14:03:39 +00:00
Ryan Lortie
3bcf1137f4 drop the now-trivial g_settings_schema_new
Combine it into g_settings_constructed()
2011-11-17 14:03:39 +00:00
Ryan Lortie
104f7353a7 move GSettingsSchemaKey to gsettingsschema.c
These functions no longer have anything to do with GSettings itself, so
they should not be in that file anymore.

GSettings still wants direct access to the GSettingsSchemaKey structure,
so put that one in gsettingsschema-internal.h.
2011-11-17 14:03:38 +00:00
Ryan Lortie
53b5918545 GSettingsSchemaKey: store the GSettingsSchema* 2011-11-17 14:03:38 +00:00
Ryan Lortie
54964e22d4 g_settings_schema_key_init: take GSettingsSchema*
instead of of GSettings *
2011-11-17 14:03:38 +00:00
Ryan Lortie
e6b4074e41 rename GSettingsKeyInfo to GSettingsSchemaKey 2011-11-17 14:03:38 +00:00
Ryan Lortie
426b146e5f GSettingsKeyInfo: rename field 'key' to 'name' 2011-11-17 14:03:38 +00:00
Ryan Lortie
ca2004fe73 remove GSettings* from GSettingsKeyInfo
This way GSettingsKeyInfo depends strictly on the information in the
schema.  Pass the GSettings* around separately where we need it.
2011-11-17 14:03:38 +00:00
Ryan Lortie
d6c3c2f3c2 store some extra info in GSettingsKeyInfo 2011-11-17 14:03:38 +00:00
Ryan Lortie
f60e0e7242 GSettingsKeyInfo: drop unused variable 2011-11-17 14:03:38 +00:00
Ryan Lortie
11ef4d7981 rename gsettingsschema.h to -internal.h 2011-11-17 14:03:38 +00:00
Ryan Lortie
577faeae5b unGObjectify GSettingsSchema 2011-11-17 14:03:38 +00:00
Javier Jardón
8d3250016d gio: Use G_VALUE_INIT 2011-10-18 17:12:33 +01:00
Dan Winship
59f1f54655 Add g_main_context_ref_thread_default()
Add g_main_context_ref_thread_default(), which always returns a
reffed GMainContext, rather than sometimes returning a (non-reffed)
GMainContext, and sometimes returning NULL. This simplifies the
bookkeeping in any code that needs to keep a reference to the
thread-default context for a while.

https://bugzilla.gnome.org/show_bug.cgi?id=660994
2011-10-07 10:14:34 -04:00
Ryan Lortie
3106391694 Revert "GSettings: don't abort on missing schemas"
This reverts commit c841c2ce3f.

This approach has been an unmitigated disaster.  We're getting all sorts
of crashes due to functions that are returning NULL because they can't
find the schema for the default value.  The people who get these crashes
are then confused about the root cause of the problem and waste a lot of
time trying to figure it out.

Until we find a better solution, we should go back to what we had
before.

https://bugzilla.gnome.org/show_bug.cgi?id=655366
2011-10-03 10:19:38 -04:00
Matthias Clasen
1b28408b8b Spelling fixes
Spelling fixes in comments and docs, provided by
Kjartan Maraas in bug 657336.
2011-08-29 14:49:32 -04:00
Ryan Lortie
2b0171a808 g_settings_bind: add some g_return checks
https://bugzilla.gnome.org/show_bug.cgi?id=636405
2011-08-15 10:43:32 -04:00
Ryan Lortie
c841c2ce3f GSettings: don't abort on missing schemas
Give a g_critical instead.
2011-07-20 14:06:36 +02:00
Johan Dahlin
ec98953e42 Pass in NULL instead of g_cclosure_marshal_generic
NULL is now a shortcut for g_cclosure_marshal_generic, so avoid
referencing it directly.

https://bugzilla.gnome.org/show_bug.cgi?id=654917
2011-07-19 14:38:34 -03:00
Ryan Lortie
fe6dad271b GSettings: remove key length restrictions
The key length now stands effectively unlimited at 1024 characters.

https://bugzilla.gnome.org/show_bug.cgi?id=654536
2011-07-19 16:12:30 +02:00
Ryan Lortie
58c247e51b GVariant: add g_variant_take_ref()
This function implements the following logic:

  if (g_variant_is_floating (value))
    g_variant_ref_sink (value);

which is used for consuming the return value of callbacks that may or
may not return floating references.

This patch also replaces a few instances of the above code with the new
function (GSettings, GDBus) and lifts a long-standing restriction on the
use of floating values as the return value for signal handlers by
improving g_value_take_variant().

https://bugzilla.gnome.org/show_bug.cgi?id=627974
2011-07-12 19:44:21 +02:00
Colin Walters
b74e2a720a Stop using glib-genmarshal at build time
To help cross compilation, don't use glib-genmarshal in our
build.  This is easy now that we have g_cclosure_marshal_generic().

In gobject/, add gmarshal.[ch] to git (making the existing entry
points stubs).

In gio/, simply switch to using g_cclosure_marshal_generic().

https://bugzilla.gnome.org/show_bug.cgi?id=652168
2011-06-20 17:24:07 -04:00
Ryan Lortie
c2a2350cc1 GSettings: fix example in the docs 2011-05-10 15:25:54 +02:00
Dan Winship
e56498ee0b Fix usage of _GNU_SOURCE
_GNU_SOURCE must be defined before including any other (system)
header, so defining it in glib-unix.h (and hoping no one has included
anything else before that) is wrong. And the "#define _USE_GNU"
workaround for this problem in gnetworkingprivate.h is even wronger
(and still prone to failure anyway due to single-include guards).

Fix this by defining _GNU_SOURCE in config.h when building against
glibc. In theory this is bad because new releases of glibc may include
symbols that conflict with glib symbols, which could then cause
compile failures. However, most people only see new releases of glibc
when they upgrade their distro, at which point they also generally get
new releases of gcc, which have new warnings/errors to clean up
anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=649201
2011-05-03 07:07:41 -04:00
Matthias Clasen
a3722d0408 Slight docs rewording
Proposed by Thomas Andersen,
https://bugzilla.gnome.org/show_bug.cgi?id=647700
2011-04-14 20:41:54 -04:00