summaryrefslogtreecommitdiffstats
path: root/src/iconstate.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2010-01-28 17:25:24 +0100
committerGravatar Martin Szulecki2010-01-28 18:12:30 +0100
commitb1b746ec1826c3c42652e098fad469e514c10087 (patch)
treec9101ede64798478316af5611fa449aada36e21e /src/iconstate.c
parentd7844e59f766ee95a04ecf00d1e26aca974e9229 (diff)
downloadsbmanager-b1b746ec1826c3c42652e098fad469e514c10087.tar.gz
sbmanager-b1b746ec1826c3c42652e098fad469e514c10087.tar.bz2
Split up code into more separate files
Diffstat (limited to 'src/iconstate.c')
-rw-r--r--src/iconstate.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/src/iconstate.c b/src/iconstate.c
new file mode 100644
index 0000000..91d528a
--- /dev/null
+++ b/src/iconstate.c
@@ -0,0 +1,113 @@
+/**
+ * iconstate.c
+ * Serialization of iconstate from/to GList's
+ *
+ * Copyright (C) 2009-2010 Nikias Bassen <nikias@gmx.li>
+ * Copyright (C) 2009-2010 Martin Szulecki <opensuse@sukimashita.com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more profile.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <plist/plist.h>
+#include <glib.h>
+
+#include "iconstate.h"
+
+GList * iconstate_to_g_list(plist_t iconstate, GError **error)
+{
+
+}
+
+plist_t g_list_to_iconstate(GList *iconstate, GError **error)
+{
+ plist_t iconstate = NULL;
+ plist_t pdockarray = NULL;
+ plist_t pdockitems = NULL;
+ guint i;
+
+ guint count = g_list_length(dockitems);
+ pdockitems = plist_new_array();
+ for (i = 0; i < count; i++) {
+ SBItem *item = g_list_nth_data(dockitems, i);
+ if (!item) {
+ continue;
+ }
+ plist_t valuenode = plist_dict_get_item(item->node, "displayIdentifier");
+ if (!valuenode) {
+ printf("could not get displayIdentifier\n");
+ continue;
+ }
+
+ plist_t pitem = plist_new_dict();
+ plist_dict_insert_item(pitem, "displayIdentifier", plist_copy(valuenode));
+ plist_array_append_item(pdockitems, pitem);
+ }
+ for (i = count; i < num_dock_items; i++) {
+ plist_array_append_item(pdockitems, plist_new_bool(0));
+ }
+ pdockarray = plist_new_array();
+ plist_array_append_item(pdockarray, pdockitems);
+
+ iconstate = plist_new_array();
+ plist_array_append_item(iconstate, pdockarray);
+
+ for (i = 0; i < g_list_length(sbpages); i++) {
+ GList *page = g_list_nth_data(sbpages, i);
+ if (page) {
+ guint j;
+ count = g_list_length(page);
+ if (count <= 0) {
+ continue;
+ }
+ plist_t ppage = plist_new_array();
+ plist_t row = NULL;
+ for (j = 0; j < 16; j++) {
+ SBItem *item = g_list_nth_data(page, j);
+ if ((j % 4) == 0) {
+ row = plist_new_array();
+ plist_array_append_item(ppage, row);
+ }
+ if (item && item->node) {
+ plist_t valuenode = plist_dict_get_item(item->node,
+ "displayIdentifier");
+ if (!valuenode) {
+ printf("could not get displayIdentifier\n");
+ continue;
+ }
+
+ plist_t pitem = plist_new_dict();
+ plist_dict_insert_item(pitem, "displayIdentifier", plist_copy(valuenode));
+ plist_array_append_item(row, pitem);
+ } else {
+ plist_array_append_item(row, plist_new_bool(0));
+ }
+ }
+ plist_array_append_item(iconstate, plist_copy(ppage));
+ plist_free(ppage);
+ }
+ }
+
+ return iconstate;
+}