2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 * See the COPYING file for license information.
18 * Guillaume Chazarain <guichaz@yahoo.fr>
28 #include "rendering.h"
31 extern options_struct
*options
;
33 static GList
*list
= NULL
;
34 static GList
*node
= NULL
; /* Currrent position in the list. */
36 static gint count
= 0; /* Number of elements in the list. */
38 /* Returns item->next. */
39 static GList
*free_item(GList
* item
)
47 g_list_delete_link(list
, item
);
51 /* Free the elements from there to the end. */
52 static void free_list(GList
* item
)
55 item
= free_item(item
);
58 /* Keep the list from being larger than options->history_size. */
59 void clean_history(void)
61 if (options
->history_size
< 0)
62 /* Unlimited history. */
65 while (count
> options
->history_size
) {
68 list
= free_item(list
);
75 /* Add the current configuration to the end of the list. */
76 void append_history(void)
80 if (options
->history_size
== 0)
84 item
= g_list_alloc();
87 item
->data
= g_new(gfloat
, 8);
88 matrix_cpy(item
->data
, NULL
);
90 /* We are at the end of the list. */
95 /* This is the first element. */
98 if (node
->next
!= NULL
)
99 /* We discard what was after us. */
100 free_list(node
->next
);
110 static void set_state(GList
* item
)
112 if (item
!= NULL
&& item
->data
!= NULL
) {
114 matrix_cpy(NULL
, item
->data
);
115 refresh(REFRESH_IMAGE
| REFRESH_STATUS
);
121 set_state(g_list_previous(node
));
126 set_state(g_list_next(node
));
129 /* Restart from scratch. */
130 void clear_history(void)