Mercurial > geeqie
comparison src/slideshow.c @ 3:c0e337a01cb7
0.8.0
author | gqview |
---|---|
date | Thu, 13 Apr 2000 12:55:19 +0000 |
parents | b3e0e515fabf |
children | d907d608745f |
comparison
equal
deleted
inserted
replaced
2:0591360d4e38 | 3:c0e337a01cb7 |
---|---|
1 /* | 1 /* |
2 * GQview image viewer | 2 * GQview image viewer |
3 * (C)1999 John Ellis | 3 * (C)2000 John Ellis |
4 * | 4 * |
5 * Author: John Ellis | 5 * Author: John Ellis |
6 * | 6 * |
7 */ | 7 */ |
8 | 8 |
9 #include "gqview.h" | 9 #include "gqview.h" |
10 | 10 |
11 static GList *slide_list = NULL; | 11 static GList *slide_list = NULL; |
12 static GList *past_slide_list = NULL; | |
12 static gchar *slide_img = NULL; | 13 static gchar *slide_img = NULL; |
13 static gchar *slide_path = NULL; | 14 static gchar *slide_path = NULL; |
14 static gint slide_count = 0; | 15 static gint slide_count = 0; |
15 static gint slide_active = FALSE; | 16 static gint slide_active = FALSE; |
16 static gint slide_sel_list = FALSE; | 17 static gint slide_sel_list = FALSE; |
21 slide_active = FALSE; | 22 slide_active = FALSE; |
22 | 23 |
23 g_list_free(slide_list); | 24 g_list_free(slide_list); |
24 slide_list = NULL; | 25 slide_list = NULL; |
25 | 26 |
27 g_list_free(past_slide_list); | |
28 past_slide_list = NULL; | |
29 | |
26 g_free(slide_path); | 30 g_free(slide_path); |
27 slide_path = NULL; | 31 slide_path = NULL; |
28 | 32 |
29 g_free(slide_img); | 33 g_free(slide_img); |
30 slide_img = NULL; | 34 slide_img = NULL; |
86 if (slide_list) | 90 if (slide_list) |
87 { | 91 { |
88 g_list_free(slide_list); | 92 g_list_free(slide_list); |
89 } | 93 } |
90 | 94 |
95 if (past_slide_list) | |
96 { | |
97 g_list_free(past_slide_list); | |
98 past_slide_list = NULL; | |
99 } | |
100 | |
91 if (slideshow_random) | 101 if (slideshow_random) |
92 { | 102 { |
93 slide_list = generate_random_list(); | 103 slide_list = generate_random_list(); |
94 } | 104 } |
95 else | 105 else |
96 { | 106 { |
97 slide_list = generate_list(); | 107 slide_list = generate_list(); |
108 } | |
109 } | |
110 | |
111 static void slideshow_move_list(gint forward) | |
112 { | |
113 if (forward) | |
114 { | |
115 if (slide_list) | |
116 { | |
117 past_slide_list = g_list_prepend (past_slide_list, slide_list->data); | |
118 slide_list = g_list_remove(slide_list, slide_list->data); | |
119 } | |
120 } | |
121 else | |
122 { | |
123 if (past_slide_list) | |
124 { | |
125 slide_list = g_list_prepend(slide_list, past_slide_list->data); | |
126 past_slide_list = g_list_remove(past_slide_list, past_slide_list->data); | |
127 } | |
98 } | 128 } |
99 } | 129 } |
100 | 130 |
101 static gint slideshow_should_continue() | 131 static gint slideshow_should_continue() |
102 { | 132 { |
110 } | 140 } |
111 | 141 |
112 return TRUE; | 142 return TRUE; |
113 } | 143 } |
114 | 144 |
115 static gint slideshow_loop_cb(gpointer data) | 145 static gint real_slideshow_prev() |
116 { | 146 { |
117 gint row; | 147 gint row; |
118 gchar *buf; | 148 gchar *buf; |
119 | 149 |
150 if (!slide_active) return FALSE; | |
151 if (!past_slide_list || !past_slide_list->next) return TRUE; | |
152 | |
120 if (!slideshow_should_continue()) | 153 if (!slideshow_should_continue()) |
121 { | 154 { |
122 slideshow_free_all(); | 155 slideshow_free_all(); |
123 slide_timeout_id = -1; | 156 slide_timeout_id = -1; |
124 return FALSE; | 157 return FALSE; |
125 } | 158 } |
126 | 159 |
127 row = GPOINTER_TO_INT(slide_list->data); | 160 slideshow_move_list(FALSE); |
161 | |
162 row = GPOINTER_TO_INT(past_slide_list->data); | |
128 | 163 |
129 g_free(slide_img); | 164 g_free(slide_img); |
130 slide_img = NULL; | 165 slide_img = NULL; |
131 buf = file_get_path(row); | 166 buf = file_get_path(row); |
132 slide_list = g_list_remove(slide_list, slide_list->data); | |
133 | |
134 if (!slide_list && slideshow_repeat) | |
135 { | |
136 slideshow_init_list(); | |
137 } | |
138 | 167 |
139 if (slide_sel_list) | 168 if (slide_sel_list) |
140 { | 169 { |
141 image_change_to(buf); | 170 image_change_to(buf); |
142 update_status_label(NULL); | 171 update_status_label(NULL); |
146 file_image_change_to(row); | 175 file_image_change_to(row); |
147 } | 176 } |
148 | 177 |
149 slide_img = buf; | 178 slide_img = buf; |
150 | 179 |
151 if (!slide_list) | 180 return TRUE; |
181 } | |
182 | |
183 /* the return is TRUE if slideshow should continue */ | |
184 static gint real_slideshow_next() | |
185 { | |
186 gint row; | |
187 gchar *buf; | |
188 | |
189 if (!slide_active) return FALSE; | |
190 | |
191 if (!slideshow_should_continue()) | |
152 { | 192 { |
153 slideshow_free_all(); | 193 slideshow_free_all(); |
154 slide_timeout_id = -1; | 194 slide_timeout_id = -1; |
155 return FALSE; | 195 return FALSE; |
156 } | 196 } |
157 | 197 |
198 row = GPOINTER_TO_INT(slide_list->data); | |
199 | |
200 g_free(slide_img); | |
201 slide_img = NULL; | |
202 buf = file_get_path(row); | |
203 slideshow_move_list(TRUE); | |
204 | |
205 if (!slide_list && slideshow_repeat) | |
206 { | |
207 slideshow_init_list(); | |
208 } | |
209 | |
210 if (slide_sel_list) | |
211 { | |
212 image_change_to(buf); | |
213 update_status_label(NULL); | |
214 } | |
215 else | |
216 { | |
217 file_image_change_to(row); | |
218 } | |
219 | |
220 slide_img = buf; | |
221 | |
222 if (!slide_list) | |
223 { | |
224 slideshow_free_all(); | |
225 slide_timeout_id = -1; | |
226 return FALSE; | |
227 } | |
228 | |
158 return TRUE; | 229 return TRUE; |
230 } | |
231 | |
232 static gint slideshow_loop_cb(gpointer data) | |
233 { | |
234 return real_slideshow_next(); | |
159 } | 235 } |
160 | 236 |
161 void slideshow_start() | 237 void slideshow_start() |
162 { | 238 { |
163 gint row; | 239 gint row; |
176 slide_path = g_strdup(current_path); | 252 slide_path = g_strdup(current_path); |
177 slide_count = file_count(); | 253 slide_count = file_count(); |
178 g_free(slide_img); | 254 g_free(slide_img); |
179 slide_img = NULL; | 255 slide_img = NULL; |
180 buf = file_get_path(row); | 256 buf = file_get_path(row); |
181 slide_list = g_list_remove(slide_list, slide_list->data); | 257 slideshow_move_list(TRUE); |
182 | 258 |
183 if (slide_sel_list) | 259 if (slide_sel_list) |
184 { | 260 { |
185 image_change_to(buf); | 261 image_change_to(buf); |
186 update_status_label(NULL); | 262 update_status_label(NULL); |
206 slide_timeout_id = -1; | 282 slide_timeout_id = -1; |
207 } | 283 } |
208 update_status_label(NULL); | 284 update_status_label(NULL); |
209 } | 285 } |
210 | 286 |
287 static void slideshow_reset_timeout(gint reset) | |
288 { | |
289 if (reset) | |
290 { | |
291 if (slide_timeout_id != -1) gtk_timeout_remove(slide_timeout_id); | |
292 slide_timeout_id = gtk_timeout_add(slideshow_delay * 1000, slideshow_loop_cb, NULL); | |
293 } | |
294 else | |
295 { | |
296 if (slide_timeout_id != -1) | |
297 { | |
298 gtk_timeout_remove(slide_timeout_id); | |
299 slide_timeout_id = -1; | |
300 } | |
301 } | |
302 } | |
303 | |
304 void slideshow_next() | |
305 { | |
306 if (!slide_active) return; | |
307 slideshow_reset_timeout(real_slideshow_next()); | |
308 } | |
309 | |
310 void slideshow_prev() | |
311 { | |
312 if (!slide_active) return; | |
313 slideshow_reset_timeout(real_slideshow_prev()); | |
314 } | |
315 | |
211 void slideshow_toggle() | 316 void slideshow_toggle() |
212 { | 317 { |
213 if (!slide_active) | 318 if (!slide_active) |
214 { | 319 { |
215 slideshow_start(); | 320 slideshow_start(); |