Mercurial > geeqie.yaz
comparison src/bar_sort.c @ 1272:e0e12512cde2
read external editors from .desktop files
author | nadvornik |
---|---|
date | Sun, 01 Feb 2009 12:48:14 +0000 |
parents | 0bea79d87065 |
children | 8b89e3ff286b |
comparison
equal
deleted
inserted
replaced
1271:4fcdbb497df3 | 1272:e0e12512cde2 |
---|---|
42 | 42 |
43 typedef enum { | 43 typedef enum { |
44 BAR_SORT_COPY = 0, | 44 BAR_SORT_COPY = 0, |
45 BAR_SORT_MOVE, | 45 BAR_SORT_MOVE, |
46 BAR_SORT_FILTER, | 46 BAR_SORT_FILTER, |
47 BAR_SORT_ACTION_COUNT = BAR_SORT_FILTER + GQ_EDITOR_GENERIC_SLOTS | 47 BAR_SORT_ACTION_COUNT |
48 } SortActionType; | 48 } SortActionType; |
49 | 49 |
50 typedef enum { | 50 typedef enum { |
51 BAR_SORT_SELECTION_IMAGE = 0, | 51 BAR_SORT_SELECTION_IMAGE = 0, |
52 BAR_SORT_SELECTION_SELECTED, | 52 BAR_SORT_SELECTION_SELECTED, |
63 FileDialog *dialog; | 63 FileDialog *dialog; |
64 GtkWidget *dialog_name_entry; | 64 GtkWidget *dialog_name_entry; |
65 | 65 |
66 SortModeType mode; | 66 SortModeType mode; |
67 SortActionType action; | 67 SortActionType action; |
68 const gchar *filter_key; | |
69 | |
68 SortSelectionType selection; | 70 SortSelectionType selection; |
69 | 71 |
70 GtkWidget *folder_group; | 72 GtkWidget *folder_group; |
71 GtkWidget *collection_group; | 73 GtkWidget *collection_group; |
72 | 74 |
280 break; | 282 break; |
281 case BAR_SORT_MOVE: | 283 case BAR_SORT_MOVE: |
282 file_util_move_simple(list, path, sd->lw->window); | 284 file_util_move_simple(list, path, sd->lw->window); |
283 list = NULL; | 285 list = NULL; |
284 break; | 286 break; |
287 case BAR_SORT_FILTER: | |
288 file_util_start_filter_from_filelist(sd->filter_key, list, path, sd->lw->window); | |
289 list = NULL; | |
290 layout_image_next(sd->lw); | |
291 break; | |
285 default: | 292 default: |
286 if (sd->action >= BAR_SORT_FILTER && sd->action < BAR_SORT_ACTION_COUNT) | |
287 { | |
288 file_util_start_filter_from_filelist(sd->action - BAR_SORT_FILTER, list, path, sd->lw->window); | |
289 list = NULL; | |
290 layout_image_next(sd->lw); | |
291 } | |
292 break; | 293 break; |
293 } | 294 } |
294 | 295 |
295 g_list_free(list); | 296 g_list_free(list); |
296 g_free(dest_path); | 297 g_free(dest_path); |
346 { | 347 { |
347 bar_sort_bookmark_select_collection(sd, source, path); | 348 bar_sort_bookmark_select_collection(sd, source, path); |
348 } | 349 } |
349 } | 350 } |
350 | 351 |
351 static void bar_sort_set_action(SortData *sd, SortActionType action) | 352 static void bar_sort_set_action(SortData *sd, SortActionType action, const gchar *filter_key) |
352 { | 353 { |
353 options->panels.sort.action_state = sd->action = action; | 354 options->panels.sort.action_state = sd->action = action; |
355 if (action == BAR_SORT_FILTER) | |
356 { | |
357 if (!filter_key) filter_key = ""; | |
358 sd->filter_key = filter_key; | |
359 g_free(options->panels.sort.action_filter); | |
360 options->panels.sort.action_filter = g_strdup(filter_key); | |
361 } | |
362 else | |
363 { | |
364 sd->filter_key = NULL; | |
365 g_free(options->panels.sort.action_filter); | |
366 options->panels.sort.action_filter = g_strdup(""); | |
367 } | |
354 } | 368 } |
355 | 369 |
356 static void bar_sort_set_copy_cb(GtkWidget *button, gpointer data) | 370 static void bar_sort_set_copy_cb(GtkWidget *button, gpointer data) |
357 { | 371 { |
358 SortData *sd = data; | 372 SortData *sd = data; |
359 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) return; | 373 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) return; |
360 bar_sort_set_action(sd, BAR_SORT_COPY); | 374 bar_sort_set_action(sd, BAR_SORT_COPY, NULL); |
361 } | 375 } |
362 | 376 |
363 static void bar_sort_set_move_cb(GtkWidget *button, gpointer data) | 377 static void bar_sort_set_move_cb(GtkWidget *button, gpointer data) |
364 { | 378 { |
365 SortData *sd = data; | 379 SortData *sd = data; |
366 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) return; | 380 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) return; |
367 bar_sort_set_action(sd, BAR_SORT_MOVE); | 381 bar_sort_set_action(sd, BAR_SORT_MOVE, NULL); |
368 } | 382 } |
369 | 383 |
370 static void bar_sort_set_filter_cb(GtkWidget *button, gpointer data) | 384 static void bar_sort_set_filter_cb(GtkWidget *button, gpointer data) |
371 { | 385 { |
372 SortData *sd = data; | 386 SortData *sd = data; |
373 guint n; | 387 const gchar *key; |
374 | 388 |
375 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) return; | 389 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) return; |
376 n = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(button), "filter_idx")); | 390 key = g_object_get_data(G_OBJECT(button), "filter_key"); |
377 if (n == 0) return; | 391 bar_sort_set_action(sd, BAR_SORT_FILTER, key); |
378 n--; | |
379 bar_sort_set_action(sd, BAR_SORT_FILTER + n); | |
380 } | 392 } |
381 | 393 |
382 static void bar_sort_set_selection(SortData *sd, SortSelectionType selection) | 394 static void bar_sort_set_selection(SortData *sd, SortSelectionType selection) |
383 { | 395 { |
384 options->panels.sort.selection_state = sd->selection = selection; | 396 options->panels.sort.selection_state = sd->selection = selection; |
549 GtkWidget *buttongrp; | 561 GtkWidget *buttongrp; |
550 GtkWidget *label; | 562 GtkWidget *label; |
551 GtkWidget *tbar; | 563 GtkWidget *tbar; |
552 GtkWidget *combo; | 564 GtkWidget *combo; |
553 SortModeType mode; | 565 SortModeType mode; |
554 guint i; | 566 GList *editors_list, *work; |
567 gboolean have_filter; | |
555 | 568 |
556 if (!lw) return NULL; | 569 if (!lw) return NULL; |
557 | 570 |
558 sd = g_new0(SortData, 1); | 571 sd = g_new0(SortData, 1); |
559 | 572 |
560 sd->lw = lw; | 573 sd->lw = lw; |
561 | 574 |
562 mode = CLAMP(options->panels.sort.mode_state, 0, BAR_SORT_MODE_COUNT - 1); | 575 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); | 576 sd->action = CLAMP(options->panels.sort.action_state, 0, BAR_SORT_ACTION_COUNT - 1); |
564 | 577 |
565 while (sd->action >= BAR_SORT_FILTER && !editor_is_filter(sd->action - BAR_SORT_FILTER)) sd->action--; | 578 if (sd->action == BAR_SORT_FILTER && |
579 (!options->panels.sort.action_filter || !options->panels.sort.action_filter[0])) | |
580 sd->action = BAR_SORT_COPY; | |
566 | 581 |
567 sd->selection = CLAMP(options->panels.sort.selection_state, 0, BAR_SORT_SELECTION_COUNT - 1); | 582 sd->selection = CLAMP(options->panels.sort.selection_state, 0, BAR_SORT_SELECTION_COUNT - 1); |
568 sd->undo_src = NULL; | 583 sd->undo_src = NULL; |
569 sd->undo_dest = NULL; | 584 sd->undo_dest = NULL; |
570 | 585 |
596 pref_radiobutton_new(sd->folder_group, buttongrp, | 611 pref_radiobutton_new(sd->folder_group, buttongrp, |
597 _("Move"), (sd->action == BAR_SORT_MOVE), | 612 _("Move"), (sd->action == BAR_SORT_MOVE), |
598 G_CALLBACK(bar_sort_set_move_cb), sd); | 613 G_CALLBACK(bar_sort_set_move_cb), sd); |
599 | 614 |
600 | 615 |
601 for (i = 0; i < GQ_EDITOR_GENERIC_SLOTS; i++) | 616 have_filter = FALSE; |
617 editors_list = editor_list_get(); | |
618 work = editors_list; | |
619 while (work) | |
602 { | 620 { |
603 GtkWidget *button; | 621 GtkWidget *button; |
604 | 622 EditorDescription *editor = work->data; |
605 const gchar *name = editor_get_name(i); | 623 work = work->next; |
606 if (!name || !editor_is_filter(i)) continue; | 624 gboolean select = FALSE; |
625 | |
626 if (!editor_is_filter(editor->key)) continue; | |
627 | |
628 if (sd->action == BAR_SORT_FILTER && strcmp(editor->key, options->panels.sort.action_filter) == 0) | |
629 { | |
630 bar_sort_set_action(sd, sd->action, editor->key); | |
631 select = TRUE; | |
632 have_filter = TRUE; | |
633 } | |
607 | 634 |
608 button = pref_radiobutton_new(sd->folder_group, buttongrp, | 635 button = pref_radiobutton_new(sd->folder_group, buttongrp, |
609 name, (sd->action == BAR_SORT_FILTER + i), | 636 editor->name, select, |
610 G_CALLBACK(bar_sort_set_filter_cb), sd); | 637 G_CALLBACK(bar_sort_set_filter_cb), sd); |
611 | 638 |
612 | 639 |
613 g_object_set_data(G_OBJECT(button), "filter_idx", GUINT_TO_POINTER(i + 1)); | 640 g_object_set_data(G_OBJECT(button), "filter_key", editor->key); |
614 } | 641 } |
615 | 642 g_list_free(editors_list); |
643 | |
644 if (sd->action == BAR_SORT_FILTER && !have_filter) sd->action = BAR_SORT_COPY; | |
616 | 645 |
617 sd->collection_group = pref_box_new(sd->vbox, FALSE, GTK_ORIENTATION_VERTICAL, 0); | 646 sd->collection_group = pref_box_new(sd->vbox, FALSE, GTK_ORIENTATION_VERTICAL, 0); |
618 | 647 |
619 buttongrp = pref_radiobutton_new(sd->collection_group, NULL, | 648 buttongrp = pref_radiobutton_new(sd->collection_group, NULL, |
620 _("Add image"), (sd->selection == BAR_SORT_SELECTION_IMAGE), | 649 _("Add image"), (sd->selection == BAR_SORT_SELECTION_IMAGE), |