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