Mercurial > geeqie.yaz
comparison src/bar_sort.c @ 138:71e1ebee420e
replaced gchar* path with FileData *fd
author | nadvornik |
---|---|
date | Tue, 11 Sep 2007 20:06:29 +0000 |
parents | f63ecca6c087 |
children | f6e307c7bad6 |
comparison
equal
deleted
inserted
replaced
137:be3328a58875 | 138:71e1ebee420e |
---|---|
80 static gint bar_sort_mode_state = BAR_SORT_MODE_FOLDER; | 80 static gint bar_sort_mode_state = BAR_SORT_MODE_FOLDER; |
81 static gint bar_sort_action_state = BAR_SORT_COPY; | 81 static gint bar_sort_action_state = BAR_SORT_COPY; |
82 static gint bar_sort_selection_state = BAR_SORT_SELECTION_IMAGE; | 82 static gint bar_sort_selection_state = BAR_SORT_SELECTION_IMAGE; |
83 | 83 |
84 | 84 |
85 static void bar_sort_undo_set(SortData *sd, GList *src_list, const gchar *src, const gchar *dest); | 85 static void bar_sort_undo_set(SortData *sd, GList *src_list, FileData *src, const gchar *dest); |
86 static void bar_sort_add_close(SortData *sd); | 86 static void bar_sort_add_close(SortData *sd); |
87 | 87 |
88 | 88 |
89 static void bar_sort_collection_list_build(GtkWidget *bookmarks) | 89 static void bar_sort_collection_list_build(GtkWidget *bookmarks) |
90 { | 90 { |
120 } | 120 } |
121 bookmark_list_add(bookmarks, name, path); | 121 bookmark_list_add(bookmarks, name, path); |
122 g_free(name); | 122 g_free(name); |
123 } | 123 } |
124 | 124 |
125 path_list_free(list); | 125 string_list_free(list); |
126 } | 126 } |
127 | 127 |
128 static void bar_sort_mode_sync(SortData *sd, SortModeType mode) | 128 static void bar_sort_mode_sync(SortData *sd, SortModeType mode) |
129 { | 129 { |
130 gint folder_mode; | 130 gint folder_mode; |
168 bar_sort_mode_sync(sd, BAR_SORT_MODE_COLLECTION); | 168 bar_sort_mode_sync(sd, BAR_SORT_MODE_COLLECTION); |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 /* this takes control of src_list */ | 172 /* this takes control of src_list */ |
173 static void bar_sort_undo_set(SortData *sd, GList *src_list, const gchar *src, const gchar *dest) | 173 static void bar_sort_undo_set(SortData *sd, GList *src_list, FileData *src, const gchar *dest) |
174 { | 174 { |
175 path_list_free(sd->undo_src_list); | 175 string_list_free(sd->undo_src_list); |
176 sd->undo_src_list = src_list; | 176 sd->undo_src_list = filelist_to_path_list(src_list); |
177 | 177 |
178 g_free(sd->undo_src); | 178 g_free(sd->undo_src); |
179 sd->undo_src = g_strdup(src); | 179 sd->undo_src = src ? g_strdup(src->path) : NULL; |
180 g_free(sd->undo_dest); | 180 g_free(sd->undo_dest); |
181 sd->undo_dest = g_strdup(dest); | 181 sd->undo_dest = g_strdup(dest); |
182 | 182 |
183 sd->undo_action = sd->action; | 183 sd->undo_action = sd->action; |
184 | 184 |
198 case BAR_SORT_MOVE: | 198 case BAR_SORT_MOVE: |
199 { | 199 { |
200 GList *list; | 200 GList *list; |
201 gchar *src_dir; | 201 gchar *src_dir; |
202 | 202 |
203 list = g_list_append(NULL, g_strdup(sd->undo_dest)); | 203 list = g_list_append(NULL, file_data_new_simple(sd->undo_dest)); |
204 src_dir = remove_level_from_path(sd->undo_src); | 204 src_dir = remove_level_from_path(sd->undo_src); |
205 file_util_move_simple(list, src_dir); | 205 file_util_move_simple(list, src_dir); |
206 g_free(src_dir); | 206 g_free(src_dir); |
207 } | 207 } |
208 break; | 208 break; |
209 case BAR_SORT_COPY: | 209 case BAR_SORT_COPY: |
210 file_util_delete(sd->undo_dest, NULL, button); | 210 file_util_delete(file_data_new_simple(sd->undo_dest), NULL, button); |
211 break; | 211 break; |
212 case BAR_SORT_LINK: | 212 case BAR_SORT_LINK: |
213 if (!unlink_file(sd->undo_dest)) | 213 if (!unlink_file(sd->undo_dest)) |
214 { | 214 { |
215 gchar *buf; | 215 gchar *buf; |
223 | 223 |
224 layout_refresh(sd->lw); | 224 layout_refresh(sd->lw); |
225 | 225 |
226 if (isfile(sd->undo_src)) | 226 if (isfile(sd->undo_src)) |
227 { | 227 { |
228 layout_image_set_path(sd->lw, sd->undo_src); | 228 layout_image_set_fd(sd->lw, file_data_new_simple(sd->undo_src)); |
229 } | 229 } |
230 | 230 |
231 bar_sort_undo_set(sd, NULL, NULL, NULL); | 231 bar_sort_undo_set(sd, NULL, NULL, NULL); |
232 } | 232 } |
233 | 233 |
240 { | 240 { |
241 gchar *source; | 241 gchar *source; |
242 | 242 |
243 source = work->data; | 243 source = work->data; |
244 work = work->next; | 244 work = work->next; |
245 collect_manager_remove(source, sd->undo_dest); | 245 collect_manager_remove(file_data_new_simple(source), sd->undo_dest); |
246 } | 246 } |
247 | 247 |
248 bar_sort_undo_set(sd, NULL, NULL, NULL); | 248 bar_sort_undo_set(sd, NULL, NULL, NULL); |
249 } | 249 } |
250 | 250 |
260 { | 260 { |
261 bar_sort_undo_collection(sd); | 261 bar_sort_undo_collection(sd); |
262 } | 262 } |
263 } | 263 } |
264 | 264 |
265 static void bar_sort_bookmark_select_folder(SortData *sd, const gchar *source, const gchar *path) | 265 static void bar_sort_bookmark_select_folder(SortData *sd, FileData *source, const gchar *path) |
266 { | 266 { |
267 GList *list; | 267 GList *list; |
268 gchar *dest_path; | 268 gchar *dest_path; |
269 | 269 |
270 if (!isdir(path)) return; | 270 if (!isdir(path)) return; |
271 | 271 |
272 dest_path = concat_dir_and_file(path, filename_from_path(source)); | 272 dest_path = concat_dir_and_file(path, source->name); |
273 bar_sort_undo_set(sd, NULL, source, dest_path); | 273 bar_sort_undo_set(sd, NULL, source, dest_path); |
274 | 274 |
275 list = g_list_append(NULL, g_strdup(source)); | 275 list = g_list_append(NULL, file_data_ref(source)); |
276 | 276 |
277 switch (sd->action) | 277 switch (sd->action) |
278 { | 278 { |
279 case BAR_SORT_COPY: | 279 case BAR_SORT_COPY: |
280 file_util_copy_simple(list, path); | 280 file_util_copy_simple(list, path); |
284 case BAR_SORT_MOVE: | 284 case BAR_SORT_MOVE: |
285 file_util_move_simple(list, path); | 285 file_util_move_simple(list, path); |
286 list = NULL; | 286 list = NULL; |
287 break; | 287 break; |
288 case BAR_SORT_LINK: | 288 case BAR_SORT_LINK: |
289 if (symlink_utf8(source, dest_path)) | 289 if (symlink_utf8(source->path, dest_path)) |
290 { | 290 { |
291 layout_image_next(sd->lw); | 291 layout_image_next(sd->lw); |
292 } | 292 } |
293 else | 293 else |
294 { | 294 { |
304 | 304 |
305 g_list_free(list); | 305 g_list_free(list); |
306 g_free(dest_path); | 306 g_free(dest_path); |
307 } | 307 } |
308 | 308 |
309 static void bar_sort_bookmark_select_collection(SortData *sd, const gchar *source, const gchar *path) | 309 static void bar_sort_bookmark_select_collection(SortData *sd, FileData *source, const gchar *path) |
310 { | 310 { |
311 GList *list = NULL; | 311 GList *list = NULL; |
312 | 312 |
313 switch (sd->selection) | 313 switch (sd->selection) |
314 { | 314 { |
315 case BAR_SORT_SELECTION_IMAGE: | 315 case BAR_SORT_SELECTION_IMAGE: |
316 list = g_list_append(NULL, g_strdup(source)); | 316 list = g_list_append(NULL, file_data_ref(source)); |
317 break; | 317 break; |
318 case BAR_SORT_SELECTION_SELECTED: | 318 case BAR_SORT_SELECTION_SELECTED: |
319 list = layout_selection_list(sd->lw); | 319 list = layout_selection_list(sd->lw); |
320 break; | 320 break; |
321 } | 321 } |
328 | 328 |
329 bar_sort_undo_set(sd, list, NULL, path); | 329 bar_sort_undo_set(sd, list, NULL, path); |
330 | 330 |
331 while (list) | 331 while (list) |
332 { | 332 { |
333 gchar *image_path; | 333 FileData *image_fd; |
334 | 334 |
335 image_path = list->data; | 335 image_fd = list->data; |
336 list = list->next; | 336 list = list->next; |
337 collect_manager_add(image_path, path); | 337 collect_manager_add(image_fd, path); |
338 } | 338 } |
339 } | 339 } |
340 | 340 |
341 static void bar_sort_bookmark_select(const gchar *path, gpointer data) | 341 static void bar_sort_bookmark_select(const gchar *path, gpointer data) |
342 { | 342 { |
343 SortData *sd = data; | 343 SortData *sd = data; |
344 const gchar *source; | 344 FileData *source; |
345 | 345 |
346 source = layout_image_get_path(sd->lw); | 346 source = layout_image_get_fd(sd->lw); |
347 if (!path || !source) return; | 347 if (!path || !source) return; |
348 | 348 |
349 if (sd->mode == BAR_SORT_MODE_FOLDER) | 349 if (sd->mode == BAR_SORT_MODE_FOLDER) |
350 { | 350 { |
351 bar_sort_bookmark_select_folder(sd, source, path); | 351 bar_sort_bookmark_select_folder(sd, source, path); |