1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 list.c for the Openbox window manager
4 Copyright (c) 2008 Derek Foreman
5 Copyright (c) 2008 Dana Jansens
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 See the COPYING file for a copy of the GNU General Public License.
23 LocoList* loco_list_prepend(LocoList **top, LocoList **bottom,
26 LocoList *n = g_new(LocoList, 1);
31 if (n->next) n->next->prev = n;
34 if (!*bottom) *bottom = n;
38 void loco_list_delete_link(LocoList **top, LocoList **bottom,
41 LocoList *prev = pos->prev;
42 LocoList *next = pos->next;
56 void loco_list_move_before(LocoList **top, LocoList **bottom,
57 LocoList *move, LocoList *before)
59 LocoList *prev, *next;
61 /* these won't move it anywhere */
62 if (move == before || move->next == before) return;
67 /* remove it from the list */
68 if (next) next->prev = prev;
70 if (prev) prev->next = next;
76 move->prev = before->prev;
77 move->next->prev = move;
78 if (move->prev) move->prev->next = move;
81 /* after the bottom */
84 if (move->prev) move->prev->next = move;
88 if (!move->prev) *top = move;