Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
GLib
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Simon McVittie
GLib
Commits
8dddf649
Commit
8dddf649
authored
Apr 25, 2010
by
Allison Karlitskaya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GSettingsBackend API/ABI change
- add list() virtual method - add 'default_value' flag to read() call
parent
9ba690b3
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
96 additions
and
35 deletions
+96
-35
gio/gdelayedsettingsbackend.c
gio/gdelayedsettingsbackend.c
+5
-3
gio/gio.symbols
gio/gio.symbols
+1
-0
gio/gkeyfilesettingsbackend.c
gio/gkeyfilesettingsbackend.c
+5
-1
gio/gmemorysettingsbackend.c
gio/gmemorysettingsbackend.c
+5
-2
gio/gnullsettingsbackend.c
gio/gnullsettingsbackend.c
+2
-1
gio/gsettings.c
gio/gsettings.c
+1
-1
gio/gsettingsbackend.c
gio/gsettingsbackend.c
+66
-25
gio/gsettingsbackend.h
gio/gsettingsbackend.h
+9
-1
gio/gsettingsbackendinternal.h
gio/gsettingsbackendinternal.h
+2
-1
No files found.
gio/gdelayedsettingsbackend.c
View file @
8dddf649
...
...
@@ -42,16 +42,18 @@ G_DEFINE_TYPE (GDelayedSettingsBackend,
static
GVariant
*
g_delayed_settings_backend_read
(
GSettingsBackend
*
backend
,
const
gchar
*
key
,
const
GVariantType
*
expected_type
)
const
GVariantType
*
expected_type
,
gboolean
default_value
)
{
GDelayedSettingsBackend
*
delayed
=
G_DELAYED_SETTINGS_BACKEND
(
backend
);
GVariant
*
result
;
if
((
result
=
g_tree_lookup
(
delayed
->
priv
->
delayed
,
key
)))
if
(
!
default_value
&&
(
result
=
g_tree_lookup
(
delayed
->
priv
->
delayed
,
key
)))
return
g_variant_ref
(
result
);
return
g_settings_backend_read
(
delayed
->
priv
->
backend
,
key
,
expected_type
);
key
,
expected_type
,
default_value
);
}
static
gboolean
g_delayed_settings_backend_write
(
GSettingsBackend
*
backend
,
...
...
gio/gio.symbols
View file @
8dddf649
...
...
@@ -1387,6 +1387,7 @@ g_settings_backend_setup_keyfile
g_settings_backend_setup
g_settings_backend_get_type
g_settings_backend_changed
g_settings_backend_flatten_tree
g_settings_backend_keys_changed
g_settings_backend_path_changed
g_settings_backend_path_writable_changed
...
...
gio/gkeyfilesettingsbackend.c
View file @
8dddf649
...
...
@@ -54,11 +54,15 @@ struct _GKeyfileSettingsBackendPrivate
static
GVariant
*
g_keyfile_settings_backend_read
(
GSettingsBackend
*
backend
,
const
gchar
*
key
,
const
GVariantType
*
expected_type
)
const
GVariantType
*
expected_type
,
gboolean
default_value
)
{
GKeyfileSettingsBackend
*
kf_backend
=
G_KEYFILE_SETTINGS_BACKEND
(
backend
);
GVariant
*
value
;
if
(
default_value
)
return
NULL
;
value
=
g_hash_table_lookup
(
kf_backend
->
priv
->
table
,
key
);
if
(
value
!=
NULL
)
...
...
gio/gmemorysettingsbackend.c
View file @
8dddf649
...
...
@@ -48,11 +48,14 @@ G_DEFINE_TYPE_WITH_CODE (GMemorySettingsBackend,
static
GVariant
*
g_memory_settings_backend_read
(
GSettingsBackend
*
backend
,
const
gchar
*
key
,
const
GVariantType
*
expected_type
)
const
GVariantType
*
expected_type
,
gboolean
default_value
)
{
GMemorySettingsBackend
*
memory
=
G_MEMORY_SETTINGS_BACKEND
(
backend
);
GVariant
*
value
;
GMemorySettingsBackend
*
memory
=
G_MEMORY_SETTINGS_BACKEND
(
backend
);
if
(
default_value
)
return
NULL
;
value
=
g_hash_table_lookup
(
memory
->
table
,
key
);
...
...
gio/gnullsettingsbackend.c
View file @
8dddf649
...
...
@@ -42,7 +42,8 @@ G_DEFINE_TYPE (GNullSettingsBackend,
static
GVariant
*
g_null_settings_backend_read
(
GSettingsBackend
*
backend
,
const
gchar
*
key
,
const
GVariantType
*
expected_type
)
const
GVariantType
*
expected_type
,
gboolean
default_value
)
{
return
NULL
;
}
...
...
gio/gsettings.c
View file @
8dddf649
...
...
@@ -751,7 +751,7 @@ g_settings_get_value (GSettings *settings,
path
=
g_strconcat
(
settings
->
priv
->
path
,
key
,
NULL
);
type
=
g_variant_get_type
(
sval
);
value
=
g_settings_backend_read
(
settings
->
priv
->
backend
,
path
,
type
);
value
=
g_settings_backend_read
(
settings
->
priv
->
backend
,
path
,
type
,
FALSE
);
g_free
(
path
);
if
(
options
!=
NULL
)
...
...
gio/gsettingsbackend.c
View file @
8dddf649
...
...
@@ -368,17 +368,18 @@ g_settings_backend_path_writable_changed (GSettingsBackend *backend,
typedef
struct
{
const
gchar
**
keys
;
GVariant
**
values
;
gint
prefix_len
;
gchar
*
prefix
;
gchar
**
items
;
}
GetKeysState
;
}
FlattenState
;
static
gboolean
tree_get_keys
(
gpointer
key
,
gpointer
value
,
gpointer
user_data
)
g_settings_backend_flatten_one
(
gpointer
key
,
gpointer
value
,
gpointer
user_data
)
{
GetKeys
State
*
state
=
user_data
;
Flatten
State
*
state
=
user_data
;
const
gchar
*
skey
=
key
;
gint
i
;
...
...
@@ -419,11 +420,60 @@ tree_get_keys (gpointer key,
/* save the entire item into the array.
* the prefixes will be removed later.
*/
*
state
->
items
++
=
key
;
*
state
->
keys
++
=
key
;
if
(
state
->
values
)
*
state
->
values
++
=
value
;
return
FALSE
;
}
/**
* g_settings_backend_flatten_tree:
* @tree: a #GTree containing the changes
* @path: the location to save the path
* @keys: the location to save the relative keys
* @values: the location to save the values, or %NULL
*
* Calculate the longest common prefix of all keys in a tree and write
* out an array of the key names relative to that prefix and,
* optionally, the value to store at each of those keys.
*
* You must free the value returned in @path, @keys and @values using
* g_free(). You should not attempt to free or unref the contents of
* @keys or @values.
*
* Since: 2.26
**/
void
g_settings_backend_flatten_tree
(
GTree
*
tree
,
gchar
**
path
,
const
gchar
***
keys
,
GVariant
***
values
)
{
FlattenState
state
=
{
0
,
};
gsize
nnodes
;
gsize
i
;
nnodes
=
g_tree_nnodes
(
tree
);
*
keys
=
state
.
keys
=
g_new
(
const
gchar
*
,
nnodes
+
1
);
state
.
keys
[
nnodes
]
=
NULL
;
if
(
values
!=
NULL
)
{
*
values
=
state
.
values
=
g_new
(
GVariant
*
,
nnodes
+
1
);
state
.
values
[
nnodes
]
=
NULL
;
}
g_tree_foreach
(
tree
,
g_settings_backend_flatten_one
,
&
state
);
g_return_if_fail
(
*
keys
+
nnodes
==
state
.
keys
);
*
path
=
state
.
prefix
;
for
(
i
=
0
;
i
<
nnodes
;
i
++
)
state
.
keys
[
i
]
+=
state
.
prefix_len
;
}
/**
* g_settings_backend_changed_tree:
* @backend: a #GSettingsBackend implementation
...
...
@@ -442,28 +492,18 @@ g_settings_backend_changed_tree (GSettingsBackend *backend,
gpointer
origin_tag
)
{
GSettingsBackendWatch
*
watch
;
GetKeysState
state
=
{
0
,
}
;
gchar
*
*
list
;
const
gchar
**
keys
;
gchar
*
path
;
g_return_if_fail
(
G_IS_SETTINGS_BACKEND
(
backend
));
list
=
g_new
(
gchar
*
,
g_tree_nnodes
(
tree
)
+
1
);
state
.
items
=
list
;
g_tree_foreach
(
tree
,
tree_get_keys
,
&
state
);
g_return_if_fail
(
list
+
g_tree_nnodes
(
tree
)
==
state
.
items
);
*
state
.
items
=
NULL
;
while
(
state
.
items
--
!=
list
)
*
state
.
items
+=
state
.
prefix_len
;
g_settings_backend_flatten_tree
(
tree
,
&
path
,
&
keys
,
NULL
);
for
(
watch
=
backend
->
priv
->
watches
;
watch
;
watch
=
watch
->
next
)
watch
->
keys_changed
(
backend
,
state
.
prefix
,
(
const
gchar
*
const
*
)
list
,
origin_tag
,
watch
->
user_data
);
watch
->
keys_changed
(
backend
,
path
,
keys
,
origin_tag
,
watch
->
user_data
);
g_free
(
list
);
g_free
(
state
.
prefix
);
g_free
(
path
);
g_free
(
keys
);
}
/*< private >
...
...
@@ -487,10 +527,11 @@ g_settings_backend_changed_tree (GSettingsBackend *backend,
GVariant
*
g_settings_backend_read
(
GSettingsBackend
*
backend
,
const
gchar
*
key
,
const
GVariantType
*
expected_type
)
const
GVariantType
*
expected_type
,
gboolean
default_value
)
{
return
G_SETTINGS_BACKEND_GET_CLASS
(
backend
)
->
read
(
backend
,
key
,
expected_type
);
->
read
(
backend
,
key
,
expected_type
,
default_value
);
}
/*< private >
...
...
gio/gsettingsbackend.h
View file @
8dddf649
...
...
@@ -69,7 +69,11 @@ struct _GSettingsBackendClass
GVariant
*
(
*
read
)
(
GSettingsBackend
*
backend
,
const
gchar
*
key
,
const
GVariantType
*
expected_type
);
const
GVariantType
*
expected_type
,
gboolean
default_value
);
gchar
**
(
*
list
)
(
GSettingsBackend
*
backend
,
const
gchar
*
path
,
gsize
*
length
);
gboolean
(
*
write
)
(
GSettingsBackend
*
backend
,
const
gchar
*
key
,
GVariant
*
value
,
...
...
@@ -112,6 +116,10 @@ void g_settings_backend_changed (GSettin
void
g_settings_backend_path_changed
(
GSettingsBackend
*
backend
,
const
gchar
*
path
,
gpointer
origin_tag
);
void
g_settings_backend_flatten_tree
(
GTree
*
tree
,
gchar
**
path
,
const
gchar
***
keys
,
GVariant
***
values
);
void
g_settings_backend_keys_changed
(
GSettingsBackend
*
backend
,
const
gchar
*
path
,
gchar
const
*
const
*
items
,
...
...
gio/gsettingsbackendinternal.h
View file @
8dddf649
...
...
@@ -67,7 +67,8 @@ GTree * g_settings_backend_create_tree (void);
G_GNUC_INTERNAL
GVariant
*
g_settings_backend_read
(
GSettingsBackend
*
backend
,
const
gchar
*
key
,
const
GVariantType
*
expected_type
);
const
GVariantType
*
expected_type
,
gboolean
default_value
);
G_GNUC_INTERNAL
gboolean
g_settings_backend_write
(
GSettingsBackend
*
backend
,
const
gchar
*
key
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment