GConf and storing GSList - how?
- From: Jukka Alasalmi <jualasal mail student oulu fi>
- To: gconf-list gnome org
- Subject: GConf and storing GSList - how?
- Date: Mon, 20 Mar 2006 09:04:45 +0000
Hi everyone,
I have a problem that I haven't found the answer to, despite looking for
source codes.
I am using gconf 2.6, and I would like to store a list of integers into the
gconf (to keep track of bookmarks).
I use following kind of code (actually separated into different functions, but
here for clarity shortened, removed error checks etc):
GConfValue *conf_value;
gconf_value = gconf_client_get_without_default(gconf_client,
KEY_BOOKMARKS_LIST, NULL);
GSList *list = gconf_value_get_list(gconf_value);
g_slist_foreach(list, add_bookmark_to_list, NULL);
void add_bookmark_to_list(gpointer list_data, gpointer user_data)
{
gint bookmark_id;
gint *tmp = list_data;
bookmark_id = *tmp; /***/
}
/***/: If I understand correctly, this should return the numeric value that
the list item holds. But this always has the value 2. If I put *(tmp + 1)
here, it works correctly, but I have no idea why.
Now, the same problem occurs when saving the list. But I have no idea in what
format the numbers should be appended to list. I am using following:
[...]
g_slist_append(list_copy, GINT_TO_POINTER(bookmark_id))
gconf_client_set_list(gconf_client, KEY_BOOKMARKS_LIST, GCONF_VALUE_INT,
list_copy, NULL);
g_slist_free(list_copy);
[...]
This, however, saves just random data to the gconf.
This all hints that there is some container, for example a struct, used
internally in GConf, and those are stored to GSList, but I haven't found any
clarification to this by searching the source codes.
Could someone tell how can I fix this problem?
Thanks in advance,
Jukka Alasalmi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]