1
/* The GIMP -- an image manipulation program
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
4
* The GIMP Help Browser
5
* Copyright (C) 1999 Sven Neumann <sven@gimp.org>
6
* Michael Natterer <mitschel@cs.tu-berlin.de>
8
* queue.c - a history queue
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
42
h = g_malloc (sizeof (Queue));
53
g_return_if_fail (h != NULL);
55
/* needs to free data in list as well! */
58
g_list_foreach (h->queue, (GFunc) g_free, NULL);
59
g_list_free (h->queue);
66
queue_move_prev (Queue *h)
68
if (!h || !h->queue || (h->current == g_list_first (h->queue)))
71
h->current = g_list_previous (h->current);
75
queue_move_next (Queue *h)
77
if (!h || !h->queue || (h->current == g_list_last (h->queue)))
80
h->current = g_list_next (h->current);
88
if (!h || !h->queue || (h->current == g_list_first (h->queue)))
91
p = g_list_previous (h->current);
93
return (const gchar *) p->data;
101
if (!h || !h->queue || (h->current == g_list_last(h->queue)))
104
p = g_list_next (h->current);
106
return (const gchar *) p->data;
115
g_return_if_fail (h != NULL);
116
g_return_if_fail (ref != NULL);
120
trash = h->current->next;
121
h->current->next = NULL;
124
h->queue = g_list_append (h->queue, g_strdup (ref));
125
h->current = g_list_last (h->queue);
129
g_list_foreach (trash, (GFunc) g_free, NULL);
135
queue_has_next (Queue *h)
137
if (!h || !h->queue || (h->current == g_list_last (h->queue)))
140
return (g_list_next (h->current) != NULL);
144
queue_has_prev (Queue *h)
146
if (!h || !h->queue || (h->current == g_list_first (h->queue)))
149
return (g_list_previous (h->current) != NULL);