gboolean panel_layout_load (void) { char **toplevels; char **objects; int i; panel_layout_init (); toplevels = g_settings_get_strv (layout_settings, PANEL_LAYOUT_TOPLEVEL_ID_LIST_KEY); if (!toplevels[0]) { g_strfreev (toplevels); toplevels = panel_layout_load_default (); if (!toplevels) return FALSE; } for (i = 0; toplevels[i] != NULL; i++) panel_layout_load_toplevel (toplevels[i]); g_strfreev (toplevels); objects = g_settings_get_strv (layout_settings, PANEL_LAYOUT_OBJECT_ID_LIST_KEY); for (i = 0; objects[i] != NULL; i++) panel_layout_load_object (objects[i]); g_strfreev (objects); g_signal_connect (layout_settings, "changed", G_CALLBACK (panel_layout_changed), NULL); panel_object_loader_do_load (TRUE); return TRUE; }
static void panel_layout_changed_object (void) { char **ids; GSList *to_remove; gboolean found; const char *id; GSList *l; int i; ids = g_settings_get_strv (layout_settings, PANEL_LAYOUT_OBJECT_ID_LIST_KEY); /* Remove what is not in the layout anymore */ to_remove = NULL; for (l = panel_applet_list_applets (); l != NULL; l = l->next) { id = panel_applet_get_id (l->data); found = FALSE; for (i = 0; ids[i] != NULL; i++) { if (g_strcmp0 (ids[i], id) == 0) { found = TRUE; break; } } if (!found) to_remove = g_slist_prepend (to_remove, l->data); } for (l = to_remove; l != NULL; l = l->next) panel_applet_clean (l->data); g_slist_free (to_remove); /* Add what appeared in the layout */ for (i = 0; ids[i] != NULL; i++) { found = FALSE; if (panel_object_loader_is_queued (ids[i])) continue; for (l = panel_applet_list_applets (); l != NULL; l = l->next) { id = panel_applet_get_id (l->data); if (g_strcmp0 (ids[i], id) == 0) { found = TRUE; break; } } if (!found) panel_layout_load_object (ids[i]); } g_strfreev (ids); /* Always do this, even if there is no object that got loaded: if a * panel has been created, we want a do_load() to unhide it, even if * there is no object to load */ panel_object_loader_do_load (FALSE); }
gboolean panel_layout_load (void) { char **toplevels; char **objects; int i; panel_layout_init (); toplevels = g_settings_get_strv (layout_settings, PANEL_LAYOUT_TOPLEVEL_ID_LIST_KEY); if (!toplevels[0]) { char *default_layout_file; g_strfreev (toplevels); if (!g_settings_is_writable (layout_settings, PANEL_LAYOUT_TOPLEVEL_ID_LIST_KEY) || !g_settings_is_writable (layout_settings, PANEL_LAYOUT_OBJECT_ID_LIST_KEY)) { g_printerr (_("Cannot create initial panel layout.\n")); return FALSE; } default_layout_file = panel_layout_get_default_layout_file (); panel_layout_append_from_file (default_layout_file); g_free (default_layout_file); toplevels = g_settings_get_strv (layout_settings, PANEL_LAYOUT_TOPLEVEL_ID_LIST_KEY); if (!toplevels[0]) { g_strfreev (toplevels); g_printerr (_("Cannot create initial panel layout.\n")); return FALSE; } } for (i = 0; toplevels[i] != NULL; i++) panel_layout_load_toplevel (toplevels[i]); g_strfreev (toplevels); objects = g_settings_get_strv (layout_settings, PANEL_LAYOUT_OBJECT_ID_LIST_KEY); for (i = 0; objects[i] != NULL; i++) panel_layout_load_object (objects[i]); g_strfreev (objects); g_signal_connect (layout_settings, "changed", G_CALLBACK (panel_layout_changed), NULL); /* This needs to happen after we've loaded the current toplevels (to * know if we have toplevels on all screens), and after we've connected * to the settings changed notifications (to automatically load created * toplevels) */ panel_layout_ensure_toplevel_per_screen (); panel_object_loader_do_load (TRUE); return TRUE; }