summaryrefslogtreecommitdiff
path: root/applets/clock
diff options
context:
space:
mode:
authorMonsta <[email protected]>2014-11-20 13:19:15 +0300
committerStefano Karapetsas <[email protected]>2014-11-22 12:19:05 +0100
commitf464fc13b1ce4c96807628f54a752a719d64ac66 (patch)
tree913ab9682c0ea386bbd809fe2beacce3972977cc /applets/clock
parentece05e7059f946f44ffb4a1f75ec4e4d3f565f72 (diff)
downloadmate-panel-f464fc13b1ce4c96807628f54a752a719d64ac66.tar.bz2
mate-panel-f464fc13b1ce4c96807628f54a752a719d64ac66.tar.xz
clock: Use lists instead of arrays
Closes https://github.com/mate-desktop/mate-panel/pull/258
Diffstat (limited to 'applets/clock')
-rw-r--r--applets/clock/clock.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/applets/clock/clock.c b/applets/clock/clock.c
index efaba2fd..56a991ea 100644
--- a/applets/clock/clock.c
+++ b/applets/clock/clock.c
@@ -2483,28 +2483,16 @@ loc_to_string (ClockLocation *loc)
static void
save_cities_store (ClockData *cd)
{
- ClockLocation *loc;
- GList *node = cd->locations;
- gint len = g_list_length(cd->locations);
- gchar **array[len + 1];
- gchar **array_reverse[len + 1];
- gint i = 0;
-
- while (node) {
- loc = CLOCK_LOCATION (node->data);
- array[i] = loc_to_string (loc);
- i++;
- node = node->next;
- }
- array[i] = NULL;
+ GList *locs = NULL;
+ GList *node;
- for (i = 0; i <= (len - 1); i++) {
- array_reverse [len - i - 1] = g_strdup (array [i]);
+ for (node = cd->locations; node != NULL; node = node->next) {
+ locs = g_list_prepend (locs, loc_to_string (CLOCK_LOCATION (node->data)));
}
- array_reverse[i] = NULL;
- g_settings_set_strv (cd->settings, KEY_CITIES, (const gchar **) array_reverse);
- /* FIXME free arrays */
+ locs = g_list_reverse (locs);
+ mate_panel_applet_settings_set_glist (cd->settings, KEY_CITIES, locs);
+ g_list_free_full (locs, g_free);
}
static void