Mercurial > geeqie
annotate src/bar_sort.c @ 779:8b21337bc47b
filelist_read_real(): optimize and clean up.
author | zas_ |
---|---|
date | Tue, 03 Jun 2008 09:41:00 +0000 |
parents | 7dbdd80610a3 |
children | 44128da39e13 |
rev | line source |
---|---|
9 | 1 /* |
196 | 2 * Geeqie |
67
f63ecca6c087
Fri Oct 13 05:22:43 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
3 * (C) 2006 John Ellis |
475 | 4 * Copyright (C) 2008 The Geeqie Team |
9 | 5 * |
6 * Author: John Ellis | |
7 * | |
8 * This software is released under the GNU General Public License (GNU GPL). | |
9 * Please read the included file COPYING for more information. | |
10 * This software comes with no warranty of any kind, use at your own risk! | |
11 */ | |
12 | |
13 | |
281 | 14 #include "main.h" |
9 | 15 #include "bar_sort.h" |
16 | |
17 #include "collect.h" | |
18 #include "collect-io.h" | |
586 | 19 #include "filedata.h" |
9 | 20 #include "layout.h" |
21 #include "layout_image.h" | |
22 #include "utilops.h" | |
753 | 23 #include "editors.h" |
9 | 24 #include "ui_bookmark.h" |
25 #include "ui_fileops.h" | |
26 #include "ui_menu.h" | |
27 #include "ui_misc.h" | |
28 | |
29 | |
30 /* | |
31 *------------------------------------------------------------------- | |
32 * sort bar | |
33 *------------------------------------------------------------------- | |
34 */ | |
35 | |
36 typedef enum { | |
37 BAR_SORT_MODE_FOLDER = 0, | |
491 | 38 BAR_SORT_MODE_COLLECTION, |
39 BAR_SORT_MODE_COUNT | |
9 | 40 } SortModeType; |
41 | |
42 typedef enum { | |
491 | 43 BAR_SORT_COPY = 0, |
9 | 44 BAR_SORT_MOVE, |
753 | 45 BAR_SORT_FILTER, |
46 BAR_SORT_ACTION_COUNT = BAR_SORT_FILTER + GQ_EDITOR_GENERIC_SLOTS | |
9 | 47 } SortActionType; |
48 | |
49 typedef enum { | |
491 | 50 BAR_SORT_SELECTION_IMAGE = 0, |
51 BAR_SORT_SELECTION_SELECTED, | |
52 BAR_SORT_SELECTION_COUNT | |
9 | 53 } SortSelectionType; |
54 | |
55 typedef struct _SortData SortData; | |
56 struct _SortData | |
57 { | |
58 GtkWidget *vbox; | |
59 GtkWidget *bookmarks; | |
60 LayoutWindow *lw; | |
61 | |
62 FileDialog *dialog; | |
63 GtkWidget *dialog_name_entry; | |
64 | |
65 SortModeType mode; | |
66 SortActionType action; | |
67 SortSelectionType selection; | |
68 | |
69 GtkWidget *folder_group; | |
70 GtkWidget *collection_group; | |
71 | |
72 GtkWidget *add_button; | |
73 GtkWidget *undo_button; | |
74 SortActionType undo_action; | |
75 GList *undo_src_list; | |
76 gchar *undo_src; | |
77 gchar *undo_dest; | |
78 }; | |
79 | |
80 | |
81 #define SORT_KEY_FOLDERS "sort_manager" | |
82 #define SORT_KEY_COLLECTIONS "sort_manager_collections" | |
83 | |
84 | |
138 | 85 static void bar_sort_undo_set(SortData *sd, GList *src_list, FileData *src, const gchar *dest); |
9 | 86 static void bar_sort_add_close(SortData *sd); |
87 | |
88 | |
89 static void bar_sort_collection_list_build(GtkWidget *bookmarks) | |
90 { | |
91 gchar *collect_path; | |
92 GList *list = NULL; | |
93 GList *work; | |
94 | |
95 history_list_free_key(SORT_KEY_COLLECTIONS); | |
96 bookmark_list_set_key(bookmarks, SORT_KEY_COLLECTIONS); | |
97 | |
700 | 98 collect_path = g_build_filename(homedir(), GQ_RC_DIR_COLLECTIONS, NULL); |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
521
diff
changeset
|
99 filelist_read(collect_path, &list, NULL); |
9 | 100 g_free(collect_path); |
101 | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
521
diff
changeset
|
102 list = filelist_sort_path(list); |
9 | 103 |
104 work = list; | |
105 while (work) | |
106 { | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
521
diff
changeset
|
107 FileData *fd; |
9 | 108 gchar *name; |
109 | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
521
diff
changeset
|
110 fd = work->data; |
9 | 111 work = work->next; |
112 | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
521
diff
changeset
|
113 if (file_extension_match(fd->path, ".gqv")) |
9 | 114 { |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
521
diff
changeset
|
115 name = remove_extension_from_path(fd->name); |
9 | 116 } |
117 else | |
118 { | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
521
diff
changeset
|
119 name = g_strdup(fd->name); |
9 | 120 } |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
521
diff
changeset
|
121 bookmark_list_add(bookmarks, name, fd->path); |
9 | 122 g_free(name); |
123 } | |
124 | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
521
diff
changeset
|
125 filelist_free(list); |
9 | 126 } |
127 | |
128 static void bar_sort_mode_sync(SortData *sd, SortModeType mode) | |
129 { | |
130 gint folder_mode; | |
131 | |
132 if (sd->mode == mode) return; | |
133 sd->mode = mode; | |
134 | |
135 folder_mode = (sd->mode == BAR_SORT_MODE_FOLDER); | |
136 | |
137 bookmark_list_set_no_defaults(sd->bookmarks, !folder_mode); | |
138 bookmark_list_set_editable(sd->bookmarks, folder_mode); | |
521
57007e49d767
Do not allow to add anything but directories to sort bar in
zas_
parents:
512
diff
changeset
|
139 bookmark_list_set_only_directories(sd->bookmarks, folder_mode); |
9 | 140 |
141 if (folder_mode) | |
142 { | |
143 gtk_widget_hide(sd->collection_group); | |
144 gtk_widget_show(sd->folder_group); | |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
491
diff
changeset
|
145 bookmark_list_set_key(sd->bookmarks, SORT_KEY_FOLDERS); |
9 | 146 } |
147 else | |
148 { | |
149 gtk_widget_hide(sd->folder_group); | |
150 gtk_widget_show(sd->collection_group); | |
151 bar_sort_collection_list_build(sd->bookmarks); | |
152 } | |
153 | |
154 bar_sort_add_close(sd); | |
155 | |
156 bar_sort_undo_set(sd, NULL, NULL, NULL); | |
157 } | |
158 | |
159 static void bar_sort_mode_cb(GtkWidget *combo, gpointer data) | |
160 { | |
161 SortData *sd = data; | |
162 | |
163 if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == BAR_SORT_MODE_FOLDER) | |
164 { | |
165 bar_sort_mode_sync(sd, BAR_SORT_MODE_FOLDER); | |
166 } | |
167 else | |
168 { | |
169 bar_sort_mode_sync(sd, BAR_SORT_MODE_COLLECTION); | |
170 } | |
491 | 171 options->panels.sort.mode_state = sd->mode; |
9 | 172 } |
173 | |
174 /* this takes control of src_list */ | |
138 | 175 static void bar_sort_undo_set(SortData *sd, GList *src_list, FileData *src, const gchar *dest) |
9 | 176 { |
138 | 177 string_list_free(sd->undo_src_list); |
178 sd->undo_src_list = filelist_to_path_list(src_list); | |
9 | 179 |
180 g_free(sd->undo_src); | |
138 | 181 sd->undo_src = src ? g_strdup(src->path) : NULL; |
9 | 182 g_free(sd->undo_dest); |
183 sd->undo_dest = g_strdup(dest); | |
184 | |
185 sd->undo_action = sd->action; | |
186 | |
187 if (sd->undo_button) | |
188 { | |
189 gtk_widget_set_sensitive(sd->undo_button, | |
190 ((sd->undo_src_list || sd->undo_src) && sd->undo_dest) ); | |
191 } | |
192 } | |
193 | |
194 static void bar_sort_undo_folder(SortData *sd, GtkWidget *button) | |
195 { | |
196 if (!sd->undo_src || !sd->undo_dest) return; | |
197 | |
198 switch (sd->undo_action) | |
199 { | |
200 case BAR_SORT_MOVE: | |
201 { | |
202 GList *list; | |
203 gchar *src_dir; | |
204 | |
138 | 205 list = g_list_append(NULL, file_data_new_simple(sd->undo_dest)); |
9 | 206 src_dir = remove_level_from_path(sd->undo_src); |
753 | 207 file_util_move_simple(list, src_dir, sd->lw->window); |
9 | 208 g_free(src_dir); |
209 } | |
210 break; | |
211 case BAR_SORT_COPY: | |
138 | 212 file_util_delete(file_data_new_simple(sd->undo_dest), NULL, button); |
9 | 213 break; |
491 | 214 default: |
753 | 215 /* undo external command */ |
216 file_util_delete(file_data_new_simple(sd->undo_dest), NULL, button); | |
491 | 217 break; |
9 | 218 } |
219 | |
220 layout_refresh(sd->lw); | |
221 | |
222 if (isfile(sd->undo_src)) | |
223 { | |
138 | 224 layout_image_set_fd(sd->lw, file_data_new_simple(sd->undo_src)); |
9 | 225 } |
226 | |
227 bar_sort_undo_set(sd, NULL, NULL, NULL); | |
228 } | |
229 | |
230 static void bar_sort_undo_collection(SortData *sd) | |
231 { | |
232 GList *work; | |
233 | |
234 work = sd->undo_src_list; | |
235 while (work) | |
236 { | |
237 gchar *source; | |
238 | |
239 source = work->data; | |
240 work = work->next; | |
138 | 241 collect_manager_remove(file_data_new_simple(source), sd->undo_dest); |
9 | 242 } |
243 | |
244 bar_sort_undo_set(sd, NULL, NULL, NULL); | |
245 } | |
246 | |
247 static void bar_sort_undo_cb(GtkWidget *button, gpointer data) | |
248 { | |
249 SortData *sd = data; | |
250 | |
251 if (sd->mode == BAR_SORT_MODE_FOLDER) | |
252 { | |
253 bar_sort_undo_folder(sd, button); | |
254 } | |
255 else | |
256 { | |
257 bar_sort_undo_collection(sd); | |
258 } | |
259 } | |
260 | |
138 | 261 static void bar_sort_bookmark_select_folder(SortData *sd, FileData *source, const gchar *path) |
9 | 262 { |
263 GList *list; | |
264 gchar *dest_path; | |
265 | |
266 if (!isdir(path)) return; | |
267 | |
702
e07895754e65
Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents:
700
diff
changeset
|
268 dest_path = g_build_filename(path, source->name, NULL); |
9 | 269 bar_sort_undo_set(sd, NULL, source, dest_path); |
270 | |
138 | 271 list = g_list_append(NULL, file_data_ref(source)); |
9 | 272 |
273 switch (sd->action) | |
274 { | |
275 case BAR_SORT_COPY: | |
753 | 276 file_util_copy_simple(list, path, sd->lw->window); |
9 | 277 list = NULL; |
278 layout_image_next(sd->lw); | |
279 break; | |
280 case BAR_SORT_MOVE: | |
753 | 281 file_util_move_simple(list, path, sd->lw->window); |
9 | 282 list = NULL; |
283 break; | |
753 | 284 default: |
285 if (sd->action >= BAR_SORT_FILTER && sd->action < BAR_SORT_ACTION_COUNT) | |
9 | 286 { |
753 | 287 file_util_start_filter_from_filelist(sd->action - BAR_SORT_FILTER, list, path, sd->lw->window); |
288 list = NULL; | |
9 | 289 layout_image_next(sd->lw); |
290 } | |
491 | 291 break; |
9 | 292 } |
293 | |
294 g_list_free(list); | |
295 g_free(dest_path); | |
296 } | |
297 | |
138 | 298 static void bar_sort_bookmark_select_collection(SortData *sd, FileData *source, const gchar *path) |
9 | 299 { |
300 GList *list = NULL; | |
301 | |
302 switch (sd->selection) | |
303 { | |
304 case BAR_SORT_SELECTION_IMAGE: | |
138 | 305 list = g_list_append(NULL, file_data_ref(source)); |
9 | 306 break; |
307 case BAR_SORT_SELECTION_SELECTED: | |
308 list = layout_selection_list(sd->lw); | |
309 break; | |
491 | 310 default: |
311 break; | |
9 | 312 } |
313 | |
314 if (!list) | |
315 { | |
316 bar_sort_undo_set(sd, NULL, NULL, NULL); | |
317 return; | |
318 } | |
319 | |
320 bar_sort_undo_set(sd, list, NULL, path); | |
321 | |
322 while (list) | |
323 { | |
138 | 324 FileData *image_fd; |
9 | 325 |
138 | 326 image_fd = list->data; |
9 | 327 list = list->next; |
138 | 328 collect_manager_add(image_fd, path); |
9 | 329 } |
330 } | |
331 | |
332 static void bar_sort_bookmark_select(const gchar *path, gpointer data) | |
333 { | |
334 SortData *sd = data; | |
138 | 335 FileData *source; |
9 | 336 |
138 | 337 source = layout_image_get_fd(sd->lw); |
9 | 338 if (!path || !source) return; |
339 | |
340 if (sd->mode == BAR_SORT_MODE_FOLDER) | |
341 { | |
342 bar_sort_bookmark_select_folder(sd, source, path); | |
343 } | |
344 else | |
345 { | |
346 bar_sort_bookmark_select_collection(sd, source, path); | |
347 } | |
348 } | |
349 | |
491 | 350 static void bar_sort_set_action(SortData *sd, SortActionType action) |
351 { | |
352 options->panels.sort.action_state = sd->action = action; | |
353 } | |
354 | |
9 | 355 static void bar_sort_set_copy_cb(GtkWidget *button, gpointer data) |
356 { | |
357 SortData *sd = data; | |
358 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) return; | |
491 | 359 bar_sort_set_action(sd, BAR_SORT_COPY); |
9 | 360 } |
361 | |
362 static void bar_sort_set_move_cb(GtkWidget *button, gpointer data) | |
363 { | |
364 SortData *sd = data; | |
365 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) return; | |
491 | 366 bar_sort_set_action(sd, BAR_SORT_MOVE); |
9 | 367 } |
368 | |
753 | 369 static void bar_sort_set_filter_cb(GtkWidget *button, gpointer data) |
9 | 370 { |
371 SortData *sd = data; | |
754
7dbdd80610a3
bar_sort_set_filter_cb(): filter_idx was set as uint so get it as uint.
zas_
parents:
753
diff
changeset
|
372 guint n; |
7dbdd80610a3
bar_sort_set_filter_cb(): filter_idx was set as uint so get it as uint.
zas_
parents:
753
diff
changeset
|
373 |
9 | 374 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) return; |
754
7dbdd80610a3
bar_sort_set_filter_cb(): filter_idx was set as uint so get it as uint.
zas_
parents:
753
diff
changeset
|
375 n = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(button), "filter_idx")); |
753 | 376 if (n == 0) return; |
377 n--; | |
378 bar_sort_set_action(sd, BAR_SORT_FILTER + n); | |
491 | 379 } |
380 | |
381 static void bar_sort_set_selection(SortData *sd, SortSelectionType selection) | |
382 { | |
383 options->panels.sort.selection_state = sd->selection = selection; | |
9 | 384 } |
385 | |
386 static void bar_sort_set_selection_image_cb(GtkWidget *button, gpointer data) | |
387 { | |
388 SortData *sd = data; | |
389 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) return; | |
491 | 390 bar_sort_set_selection(sd, BAR_SORT_SELECTION_IMAGE); |
9 | 391 } |
392 | |
393 static void bar_sort_set_selection_selected_cb(GtkWidget *button, gpointer data) | |
394 { | |
395 SortData *sd = data; | |
396 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) return; | |
491 | 397 bar_sort_set_selection(sd, BAR_SORT_SELECTION_SELECTED); |
9 | 398 } |
399 | |
400 static void bar_sort_add_close(SortData *sd) | |
401 { | |
402 if (sd->dialog) file_dialog_close(sd->dialog); | |
403 sd->dialog_name_entry = NULL; | |
404 sd->dialog = NULL; | |
405 } | |
406 | |
407 static void bar_sort_add_ok_cb(FileDialog *fd, gpointer data) | |
408 { | |
409 SortData *sd = data; | |
410 const gchar *name; | |
411 | |
412 name = gtk_entry_get_text(GTK_ENTRY(sd->dialog_name_entry)); | |
413 if (sd->mode == BAR_SORT_MODE_FOLDER) | |
414 { | |
415 if (strlen(name) == 0) | |
416 { | |
417 name = filename_from_path(fd->dest_path); | |
418 } | |
419 | |
420 bookmark_list_add(sd->bookmarks, name, fd->dest_path); | |
421 } | |
422 else | |
423 { | |
424 gchar *path; | |
700 | 425 |
9 | 426 if (strlen(name) == 0) return; |
427 | |
700 | 428 if (!file_extension_match(name, ".gqv")) |
9 | 429 { |
700 | 430 gchar *tmp = g_strconcat(name, ".gqv", NULL); |
431 g_free((gpointer) name); | |
432 name = tmp; | |
9 | 433 } |
434 | |
700 | 435 path = g_build_filename(homedir(), GQ_RC_DIR_COLLECTIONS, name, NULL); |
9 | 436 if (isfile(path)) |
437 { | |
438 gchar *text = g_strdup_printf(_("The collection:\n%s\nalready exists."), name); | |
439 file_util_warning_dialog(_("Collection exists"), text, GTK_STOCK_DIALOG_INFO, NULL); | |
440 g_free(text); | |
441 } | |
442 else | |
443 { | |
444 CollectionData *cd; | |
445 | |
446 cd = collection_new(path); | |
447 if (collection_save(cd, path)) | |
448 { | |
449 bar_sort_collection_list_build(sd->bookmarks); | |
450 } | |
451 else | |
452 { | |
453 gchar *text = g_strdup_printf(_("Failed to save the collection:\n%s"), path); | |
454 file_util_warning_dialog(_("Save Failed"), text, | |
455 GTK_STOCK_DIALOG_ERROR, GENERIC_DIALOG(fd)->dialog); | |
456 g_free(text); | |
457 } | |
458 collection_unref(cd); | |
459 } | |
460 | |
461 g_free(path); | |
462 } | |
463 | |
464 bar_sort_add_close(sd); | |
465 } | |
466 | |
467 static void bar_sort_add_cancel_cb(FileDialog *fd, gpointer data) | |
468 { | |
469 SortData *sd = data; | |
470 | |
471 bar_sort_add_close(sd); | |
472 } | |
473 | |
474 static void bar_sort_add_cb(GtkWidget *button, gpointer data) | |
475 { | |
476 SortData *sd = data; | |
477 GtkWidget *hbox; | |
478 const gchar *title; | |
479 | |
480 if (sd->dialog) | |
481 { | |
482 gtk_window_present(GTK_WINDOW(GENERIC_DIALOG(sd->dialog)->dialog)); | |
483 return; | |
484 } | |
485 | |
486 if (sd->mode == BAR_SORT_MODE_FOLDER) | |
487 { | |
488 title = _("Add Bookmark"); | |
489 } | |
490 else | |
491 { | |
492 title = _("Add Collection"); | |
493 } | |
494 | |
495 sd->dialog = file_util_file_dlg(title, | |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
228
diff
changeset
|
496 GQ_WMCLASS, "add_bookmark", button, |
9 | 497 bar_sort_add_cancel_cb, sd); |
498 file_dialog_add_button(sd->dialog, GTK_STOCK_OK, NULL, bar_sort_add_ok_cb, TRUE); | |
499 | |
500 generic_dialog_add_message(GENERIC_DIALOG(sd->dialog), NULL, title, NULL); | |
501 | |
502 if (sd->mode == BAR_SORT_MODE_FOLDER) | |
503 { | |
504 file_dialog_add_path_widgets(sd->dialog, NULL, NULL, "add_bookmark", NULL, NULL); | |
505 } | |
506 | |
507 hbox = pref_box_new(GENERIC_DIALOG(sd->dialog)->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP); | |
508 | |
509 pref_label_new(hbox, _("Name:")); | |
510 | |
511 sd->dialog_name_entry = gtk_entry_new(); | |
512 gtk_box_pack_start(GTK_BOX(hbox), sd->dialog_name_entry, TRUE, TRUE, 0); | |
513 generic_dialog_attach_default(GENERIC_DIALOG(sd->dialog), sd->dialog_name_entry); | |
514 gtk_widget_show(sd->dialog_name_entry); | |
515 | |
516 if (sd->mode == BAR_SORT_MODE_COLLECTION) | |
517 { | |
518 gtk_widget_grab_focus(sd->dialog_name_entry); | |
519 } | |
520 | |
521 gtk_widget_show(GENERIC_DIALOG(sd->dialog)->dialog); | |
522 } | |
523 | |
524 void bar_sort_close(GtkWidget *bar) | |
525 { | |
526 SortData *sd; | |
527 | |
528 sd = g_object_get_data(G_OBJECT(bar), "bar_sort_data"); | |
529 if (!sd) return; | |
530 | |
531 gtk_widget_destroy(sd->vbox); | |
532 } | |
533 | |
534 static void bar_sort_destroy(GtkWidget *widget, gpointer data) | |
535 { | |
536 SortData *sd = data; | |
537 | |
538 bar_sort_add_close(sd); | |
539 | |
540 g_free(sd->undo_src); | |
541 g_free(sd->undo_dest); | |
542 g_free(sd); | |
543 } | |
544 | |
545 GtkWidget *bar_sort_new(LayoutWindow *lw) | |
546 { | |
547 SortData *sd; | |
548 GtkWidget *buttongrp; | |
549 GtkWidget *label; | |
550 GtkWidget *tbar; | |
551 GtkWidget *combo; | |
491 | 552 SortModeType mode; |
753 | 553 guint i; |
9 | 554 |
555 if (!lw) return NULL; | |
556 | |
557 sd = g_new0(SortData, 1); | |
558 | |
559 sd->lw = lw; | |
491 | 560 |
561 mode = CLAMP(options->panels.sort.mode_state, 0, BAR_SORT_MODE_COUNT - 1); | |
562 sd->action = CLAMP(options->panels.sort.action_state, 0, BAR_SORT_ACTION_COUNT - 1); | |
753 | 563 |
564 while (sd->action >= BAR_SORT_FILTER && !editor_is_filter(sd->action - BAR_SORT_FILTER)) sd->action--; | |
565 | |
491 | 566 sd->selection = CLAMP(options->panels.sort.selection_state, 0, BAR_SORT_SELECTION_COUNT - 1); |
9 | 567 sd->undo_src = NULL; |
568 sd->undo_dest = NULL; | |
569 | |
570 sd->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP); | |
571 g_object_set_data(G_OBJECT(sd->vbox), "bar_sort_data", sd); | |
572 g_signal_connect(G_OBJECT(sd->vbox), "destroy", | |
573 G_CALLBACK(bar_sort_destroy), sd); | |
574 | |
575 label = gtk_label_new(_("Sort Manager")); | |
576 pref_label_bold(label, TRUE, FALSE); | |
577 gtk_box_pack_start(GTK_BOX(sd->vbox), label, FALSE, FALSE, 0); | |
578 gtk_widget_show(label); | |
579 | |
580 combo = gtk_combo_box_new_text(); | |
581 gtk_box_pack_start(GTK_BOX(sd->vbox), combo, FALSE, FALSE, 0); | |
582 gtk_widget_show(combo); | |
583 | |
584 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Folders")); | |
585 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Collections")); | |
586 | |
587 g_signal_connect(G_OBJECT(combo), "changed", | |
588 G_CALLBACK(bar_sort_mode_cb), sd); | |
589 | |
590 sd->folder_group = pref_box_new(sd->vbox, FALSE, GTK_ORIENTATION_VERTICAL, 0); | |
591 | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
592 buttongrp = pref_radiobutton_new(sd->folder_group, NULL, |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
593 _("Copy"), (sd->action == BAR_SORT_COPY), |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
594 G_CALLBACK(bar_sort_set_copy_cb), sd); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
595 pref_radiobutton_new(sd->folder_group, buttongrp, |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
596 _("Move"), (sd->action == BAR_SORT_MOVE), |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
597 G_CALLBACK(bar_sort_set_move_cb), sd); |
753 | 598 |
599 | |
600 for (i = 0; i < GQ_EDITOR_GENERIC_SLOTS; i++) | |
601 { | |
602 GtkWidget *button; | |
603 | |
604 const gchar *name = editor_get_name(i); | |
605 if (!name || !editor_is_filter(i)) continue; | |
606 | |
607 button = pref_radiobutton_new(sd->folder_group, buttongrp, | |
608 name, (sd->action == BAR_SORT_FILTER + i), | |
609 G_CALLBACK(bar_sort_set_filter_cb), sd); | |
610 | |
611 | |
612 g_object_set_data(G_OBJECT(button), "filter_idx", GUINT_TO_POINTER(i + 1)); | |
613 } | |
614 | |
9 | 615 |
616 sd->collection_group = pref_box_new(sd->vbox, FALSE, GTK_ORIENTATION_VERTICAL, 0); | |
617 | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
618 buttongrp = pref_radiobutton_new(sd->collection_group, NULL, |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
619 _("Add image"), (sd->selection == BAR_SORT_SELECTION_IMAGE), |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
620 G_CALLBACK(bar_sort_set_selection_image_cb), sd); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
621 pref_radiobutton_new(sd->collection_group, buttongrp, |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
622 _("Add selection"), (sd->selection == BAR_SORT_SELECTION_SELECTED), |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
623 G_CALLBACK(bar_sort_set_selection_selected_cb), sd); |
9 | 624 |
625 sd->bookmarks = bookmark_list_new(SORT_KEY_FOLDERS, bar_sort_bookmark_select, sd); | |
626 gtk_box_pack_start(GTK_BOX(sd->vbox), sd->bookmarks, TRUE, TRUE, 0); | |
627 gtk_widget_show(sd->bookmarks); | |
628 | |
629 tbar = pref_toolbar_new(sd->vbox, GTK_TOOLBAR_ICONS); | |
630 | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
631 sd->add_button = pref_toolbar_button(tbar, GTK_STOCK_ADD, NULL, FALSE, |
9 | 632 _("Add Bookmark"), |
633 G_CALLBACK(bar_sort_add_cb), sd); | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
634 sd->undo_button = pref_toolbar_button(tbar, GTK_STOCK_UNDO, NULL, FALSE, |
9 | 635 _("Undo last image"), |
636 G_CALLBACK(bar_sort_undo_cb), sd); | |
637 | |
638 sd->mode = -1; | |
491 | 639 bar_sort_mode_sync(sd, mode); |
9 | 640 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), sd->mode); |
442 | 641 |
9 | 642 return sd->vbox; |
643 } |