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