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