/** * iconstate.c * Serialization of iconstate from/to GList's * * Copyright (C) 2009-2010 Nikias Bassen * Copyright (C) 2009-2010 Martin Szulecki * * 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 #endif #include #include #include #include #include #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; }