From 4ee953a0feaa4be188ef097dcd710647689a1b38 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Feb 2010 10:41:58 -0600 Subject: Basic parsing of the files. --- libindicator/indicator-desktop-shortcuts.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/libindicator/indicator-desktop-shortcuts.c b/libindicator/indicator-desktop-shortcuts.c index eeb97be..b46b115 100644 --- a/libindicator/indicator-desktop-shortcuts.c +++ b/libindicator/indicator-desktop-shortcuts.c @@ -216,6 +216,34 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe static void parse_keyfile (IndicatorDesktopShortcuts * ids) { + IndicatorDesktopShortcutsPrivate * priv = INDICATOR_DESKTOP_SHORTCUTS_GET_PRIVATE(ids); + + if (priv->keyfile == NULL) { + return; + } + + if (priv->identity == NULL) { + return; + } + + /* Okay, we've got everything we need. Let's get it on! */ + gint i; + gsize num_nicks = 0; + gchar ** nicks = g_key_file_get_string_list(priv->keyfile, G_KEY_FILE_DESKTOP_GROUP, SHORTCUTS_KEY, &num_nicks, NULL); + + /* If there is an error from get_string_list num_nicks should still + be zero, so this loop will drop out. */ + for (i = 0; i < num_nicks; i++) { + gchar * groupname = g_strdup_printf("%s" GROUP_SUFFIX, nicks[i]); + if (!g_key_file_has_group(priv->keyfile, groupname)) { + g_warning("Unable to find group '%s'", groupname); + g_free(groupname); + continue; + } + + gchar * nickalloc = g_strdup(nicks[i]); + g_array_append_val(priv->nicks, nickalloc); + } return; } -- cgit v1.2.3