comparison src/view_file_icon.c @ 633:fe700864cb5a

Use vf_* functions where possible.
author zas_
date Sun, 11 May 2008 21:11:54 +0000
parents 6e9413e92be5
children 92208e71673b
comparison
equal deleted inserted replaced
632:6e9413e92be5 633:fe700864cb5a
30 #include "utilops.h" 30 #include "utilops.h"
31 #include "ui_bookmark.h" 31 #include "ui_bookmark.h"
32 #include "ui_fileops.h" 32 #include "ui_fileops.h"
33 #include "ui_menu.h" 33 #include "ui_menu.h"
34 #include "ui_tree_edit.h" 34 #include "ui_tree_edit.h"
35 35 #include "view_file.h"
36 36
37 #include <gdk/gdkkeysyms.h> /* for keyboard values */ 37 #include <gdk/gdkkeysyms.h> /* for keyboard values */
38 38
39 #define VFICON_INFO_POINTER(_vf_) ((ViewFileInfoIcon *)(_vf_->info)) 39 #define VFICON_INFO_POINTER(_vf_) ((ViewFileInfoIcon *)(_vf_->info))
40 #define VFICON_INFO(_vf_, _part_) (VFICON_INFO_POINTER(_vf_)->_part_) 40 #define VFICON_INFO(_vf_, _part_) (VFICON_INFO_POINTER(_vf_)->_part_)
136 { 136 {
137 IconData *ida = a; 137 IconData *ida = a;
138 IconData *idb = b; 138 IconData *idb = b;
139 return filelist_sort_compare_filedata(ida->fd, idb->fd); 139 return filelist_sort_compare_filedata(ida->fd, idb->fd);
140 } 140 }
141
141 GList *iconlist_sort(GList *list, SortType method, gint ascend) 142 GList *iconlist_sort(GList *list, SortType method, gint ascend)
142 { 143 {
143 return filelist_sort_full(list, method, ascend, (GCompareFunc) iconlist_sort_file_cb); 144 return filelist_sort_full(list, method, ascend, (GCompareFunc) iconlist_sort_file_cb);
144 } 145 }
145 146
167 { 168 {
168 if (!VFICON_INFO(vf, click_id)) return NULL; 169 if (!VFICON_INFO(vf, click_id)) return NULL;
169 170
170 if (VFICON_INFO(vf, click_id)->selected & SELECTION_SELECTED) 171 if (VFICON_INFO(vf, click_id)->selected & SELECTION_SELECTED)
171 { 172 {
172 return vficon_selection_get_list(vf); 173 return vf_selection_get_list(vf);
173 } 174 }
174 175
175 return g_list_append(NULL, file_data_ref(VFICON_INFO(vf, click_id)->fd)); 176 return g_list_append(NULL, file_data_ref(VFICON_INFO(vf, click_id)->fd));
176 } 177 }
177 178
206 207
207 if (VFICON_INFO(vf, click_id)->selected & SELECTION_SELECTED) 208 if (VFICON_INFO(vf, click_id)->selected & SELECTION_SELECTED)
208 { 209 {
209 GList *list; 210 GList *list;
210 211
211 list = vficon_selection_get_list(vf); 212 list = vf_selection_get_list(vf);
212 view_window_new_from_list(list); 213 view_window_new_from_list(list);
213 filelist_free(list); 214 filelist_free(list);
214 } 215 }
215 else 216 else
216 { 217 {
269 { 270 {
270 layout_sort_set(vf->layout, type, vf->sort_ascend); 271 layout_sort_set(vf->layout, type, vf->sort_ascend);
271 } 272 }
272 else 273 else
273 { 274 {
274 vficon_sort_set(vf, type, vf->sort_ascend); 275 vf_sort_set(vf, type, vf->sort_ascend);
275 } 276 }
276 } 277 }
277 278
278 static void vficon_pop_menu_sort_ascend_cb(GtkWidget *widget, gpointer data) 279 static void vficon_pop_menu_sort_ascend_cb(GtkWidget *widget, gpointer data)
279 { 280 {
283 { 284 {
284 layout_sort_set(vf->layout, vf->sort_method, !vf->sort_ascend); 285 layout_sort_set(vf->layout, vf->sort_method, !vf->sort_ascend);
285 } 286 }
286 else 287 else
287 { 288 {
288 vficon_sort_set(vf, vf->sort_method, !vf->sort_ascend); 289 vf_sort_set(vf, vf->sort_method, !vf->sort_ascend);
289 } 290 }
290 } 291 }
291 292
292 static void vficon_pop_menu_list_cb(GtkWidget *widget, gpointer data) 293 static void vficon_pop_menu_list_cb(GtkWidget *widget, gpointer data)
293 { 294 {
305 306
306 static void vficon_pop_menu_refresh_cb(GtkWidget *widget, gpointer data) 307 static void vficon_pop_menu_refresh_cb(GtkWidget *widget, gpointer data)
307 { 308 {
308 ViewFile *vf = data; 309 ViewFile *vf = data;
309 310
310 vficon_refresh(vf); 311 vf_refresh(vf);
311 } 312 }
312 313
313 static void vficon_popup_destroy_cb(GtkWidget *widget, gpointer data) 314 static void vficon_popup_destroy_cb(GtkWidget *widget, gpointer data)
314 { 315 {
315 ViewFile *vf = data; 316 ViewFile *vf = data;
374 *------------------------------------------------------------------- 375 *-------------------------------------------------------------------
375 * signals 376 * signals
376 *------------------------------------------------------------------- 377 *-------------------------------------------------------------------
377 */ 378 */
378 379
379 static void vficon_send_update(ViewFile *vf)
380 {
381 if (vf->func_status) vf->func_status(vf, vf->data_status);
382 }
383
384 static void vficon_send_layout_select(ViewFile *vf, IconData *id) 380 static void vficon_send_layout_select(ViewFile *vf, IconData *id)
385 { 381 {
386 FileData *read_ahead_fd = NULL; 382 FileData *read_ahead_fd = NULL;
387 FileData *sel_fd; 383 FileData *sel_fd;
388 FileData *cur_fd; 384 FileData *cur_fd;
398 { 394 {
399 gint row; 395 gint row;
400 396
401 row = g_list_index(vf->list, id); 397 row = g_list_index(vf->list, id);
402 if (row > vficon_index_by_fd(vf, cur_fd) && 398 if (row > vficon_index_by_fd(vf, cur_fd) &&
403 row + 1 < vficon_count(vf, NULL)) 399 row + 1 < vf_count(vf, NULL))
404 { 400 {
405 read_ahead_fd = vficon_index_get_data(vf, row + 1); 401 read_ahead_fd = vf_index_get_data(vf, row + 1);
406 } 402 }
407 else if (row > 0) 403 else if (row > 0)
408 { 404 {
409 read_ahead_fd = vficon_index_get_data(vf, row - 1); 405 read_ahead_fd = vf_index_get_data(vf, row - 1);
410 } 406 }
411 } 407 }
412 408
413 layout_image_set_with_ahead(vf->layout, sel_fd, read_ahead_fd); 409 layout_image_set_with_ahead(vf->layout, sel_fd, read_ahead_fd);
414 } 410 }
653 649
654 if (!VFICON_INFO(vf, click_id)) return; 650 if (!VFICON_INFO(vf, click_id)) return;
655 651
656 if (VFICON_INFO(vf, click_id)->selected & SELECTION_SELECTED) 652 if (VFICON_INFO(vf, click_id)->selected & SELECTION_SELECTED)
657 { 653 {
658 list = vficon_selection_get_list(vf); 654 list = vf_selection_get_list(vf);
659 } 655 }
660 else 656 else
661 { 657 {
662 list = g_list_append(NULL, file_data_ref(VFICON_INFO(vf, click_id)->fd)); 658 list = g_list_append(NULL, file_data_ref(VFICON_INFO(vf, click_id)->fd));
663 } 659 }
698 694
699 vficon_selection_remove(vf, VFICON_INFO(vf, click_id), SELECTION_PRELIGHT, NULL); 695 vficon_selection_remove(vf, VFICON_INFO(vf, click_id), SELECTION_PRELIGHT, NULL);
700 696
701 if (context->action == GDK_ACTION_MOVE) 697 if (context->action == GDK_ACTION_MOVE)
702 { 698 {
703 vficon_refresh(vf); 699 vf_refresh(vf);
704 } 700 }
705 701
706 tip_unschedule(vf); 702 tip_unschedule(vf);
707 } 703 }
708 704
805 801
806 VFICON_INFO(vf, selection) = g_list_append(VFICON_INFO(vf, selection), id); 802 VFICON_INFO(vf, selection) = g_list_append(VFICON_INFO(vf, selection), id);
807 vficon_selection_add(vf, id, SELECTION_SELECTED, NULL); 803 vficon_selection_add(vf, id, SELECTION_SELECTED, NULL);
808 } 804 }
809 805
810 vficon_send_update(vf); 806 vf_send_update(vf);
811 } 807 }
812 808
813 void vficon_select_none(ViewFile *vf) 809 void vficon_select_none(ViewFile *vf)
814 { 810 {
815 GList *work; 811 GList *work;
824 } 820 }
825 821
826 g_list_free(VFICON_INFO(vf, selection)); 822 g_list_free(VFICON_INFO(vf, selection));
827 VFICON_INFO(vf, selection) = NULL; 823 VFICON_INFO(vf, selection) = NULL;
828 824
829 vficon_send_update(vf); 825 vf_send_update(vf);
830 } 826 }
831 827
832 void vficon_select_invert(ViewFile *vf) 828 void vficon_select_invert(ViewFile *vf)
833 { 829 {
834 GList *work; 830 GList *work;
849 VFICON_INFO(vf, selection) = g_list_append(VFICON_INFO(vf, selection), id); 845 VFICON_INFO(vf, selection) = g_list_append(VFICON_INFO(vf, selection), id);
850 vficon_selection_add(vf, id, SELECTION_SELECTED, NULL); 846 vficon_selection_add(vf, id, SELECTION_SELECTED, NULL);
851 } 847 }
852 } 848 }
853 849
854 vficon_send_update(vf); 850 vf_send_update(vf);
855 } 851 }
856 852
857 static void vficon_select(ViewFile *vf, IconData *id) 853 static void vficon_select(ViewFile *vf, IconData *id)
858 { 854 {
859 VFICON_INFO(vf, prev_selection) = id; 855 VFICON_INFO(vf, prev_selection) = id;
861 if (!id || id->selected & SELECTION_SELECTED) return; 857 if (!id || id->selected & SELECTION_SELECTED) return;
862 858
863 VFICON_INFO(vf, selection) = g_list_append(VFICON_INFO(vf, selection), id); 859 VFICON_INFO(vf, selection) = g_list_append(VFICON_INFO(vf, selection), id);
864 vficon_selection_add(vf, id, SELECTION_SELECTED, NULL); 860 vficon_selection_add(vf, id, SELECTION_SELECTED, NULL);
865 861
866 vficon_send_update(vf); 862 vf_send_update(vf);
867 } 863 }
868 864
869 static void vficon_unselect(ViewFile *vf, IconData *id) 865 static void vficon_unselect(ViewFile *vf, IconData *id)
870 { 866 {
871 VFICON_INFO(vf, prev_selection) = id; 867 VFICON_INFO(vf, prev_selection) = id;
873 if (!id || !(id->selected & SELECTION_SELECTED) ) return; 869 if (!id || !(id->selected & SELECTION_SELECTED) ) return;
874 870
875 VFICON_INFO(vf, selection) = g_list_remove(VFICON_INFO(vf, selection), id); 871 VFICON_INFO(vf, selection) = g_list_remove(VFICON_INFO(vf, selection), id);
876 vficon_selection_remove(vf, id, SELECTION_SELECTED, NULL); 872 vficon_selection_remove(vf, id, SELECTION_SELECTED, NULL);
877 873
878 vficon_send_update(vf); 874 vf_send_update(vf);
879 } 875 }
880 876
881 static void vficon_select_util(ViewFile *vf, IconData *id, gint select) 877 static void vficon_select_util(ViewFile *vf, IconData *id, gint select)
882 { 878 {
883 if (select) 879 if (select)
1027 { 1023 {
1028 if (!id) return; 1024 if (!id) return;
1029 1025
1030 if (!(id->selected & SELECTION_SELECTED)) 1026 if (!(id->selected & SELECTION_SELECTED))
1031 { 1027 {
1032 vficon_select_none(vf); 1028 vf_select_none(vf);
1033 vficon_select(vf, id); 1029 vficon_select(vf, id);
1034 } 1030 }
1035 1031
1036 vficon_set_focus(vf, id); 1032 vficon_set_focus(vf, id);
1037 } 1033 }
1091 GList *slist; 1087 GList *slist;
1092 GList *work; 1088 GList *work;
1093 1089
1094 g_assert(mark >= 0 && mark < FILEDATA_MARKS_SIZE); 1090 g_assert(mark >= 0 && mark < FILEDATA_MARKS_SIZE);
1095 1091
1096 slist = vficon_selection_get_list(vf); 1092 slist = vf_selection_get_list(vf);
1097 work = slist; 1093 work = slist;
1098 while (work) 1094 while (work)
1099 { 1095 {
1100 FileData *fd = work->data; 1096 FileData *fd = work->data;
1101 1097
1370 vficon_send_layout_select(vf, id); 1366 vficon_send_layout_select(vf, id);
1371 } 1367 }
1372 } 1368 }
1373 else 1369 else
1374 { 1370 {
1375 vficon_select_none(vf); 1371 vf_select_none(vf);
1376 vficon_select(vf, id); 1372 vficon_select(vf, id);
1377 vficon_send_layout_select(vf, id); 1373 vficon_send_layout_select(vf, id);
1378 } 1374 }
1379 } 1375 }
1380 break; 1376 break;
1422 VFICON_INFO(vf, click_id) = new_id; 1418 VFICON_INFO(vf, click_id) = new_id;
1423 } 1419 }
1424 else 1420 else
1425 { 1421 {
1426 VFICON_INFO(vf, click_id) = new_id; 1422 VFICON_INFO(vf, click_id) = new_id;
1427 vficon_select_none(vf); 1423 vf_select_none(vf);
1428 vficon_select(vf, new_id); 1424 vficon_select(vf, new_id);
1429 vficon_send_layout_select(vf, new_id); 1425 vficon_send_layout_select(vf, new_id);
1430 } 1426 }
1431 } 1427 }
1432 } 1428 }
1542 vficon_select_util(vf, id, select); 1538 vficon_select_util(vf, id, select);
1543 } 1539 }
1544 } 1540 }
1545 else 1541 else
1546 { 1542 {
1547 vficon_select_none(vf); 1543 vf_select_none(vf);
1548 1544
1549 if ((bevent->state & GDK_SHIFT_MASK) && VFICON_INFO(vf, prev_selection)) 1545 if ((bevent->state & GDK_SHIFT_MASK) && VFICON_INFO(vf, prev_selection))
1550 { 1546 {
1551 vficon_select_region_util(vf, VFICON_INFO(vf, prev_selection), id, TRUE); 1547 vficon_select_region_util(vf, VFICON_INFO(vf, prev_selection), id, TRUE);
1552 } 1548 }
1740 } 1736 }
1741 } 1737 }
1742 1738
1743 VFICON_INFO(vf, rows) = row + 1; 1739 VFICON_INFO(vf, rows) = row + 1;
1744 1740
1745 vficon_send_update(vf); 1741 vf_send_update(vf);
1746 vficon_thumb_update(vf); 1742 vficon_thumb_update(vf);
1747 } 1743 }
1748 1744
1749 static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint h, gint force) 1745 static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint h, gint force)
1750 { 1746 {
2572 2568
2573 if (!VFICON_INFO(vf, selection)) 2569 if (!VFICON_INFO(vf, selection))
2574 { 2570 {
2575 gint n; 2571 gint n;
2576 2572
2577 n = vficon_count(vf, NULL); 2573 n = vf_count(vf, NULL);
2578 if (ignore_list) 2574 if (ignore_list)
2579 { 2575 {
2580 new_row = vficon_maint_find_closest(vf, row, n, ignore_list); 2576 new_row = vficon_maint_find_closest(vf, row, n, ignore_list);
2581 DEBUG_1("row = %d, closest is %d", row, new_row); 2577 DEBUG_1("row = %d, closest is %d", row, new_row);
2582 } 2578 }
2630 } 2626 }
2631 2627
2632 if (new_row == -1) 2628 if (new_row == -1)
2633 { 2629 {
2634 /* selection all ignored, use closest */ 2630 /* selection all ignored, use closest */
2635 new_row = vficon_maint_find_closest(vf, row, vficon_count(vf, NULL), ignore_list); 2631 new_row = vficon_maint_find_closest(vf, row, vf_count(vf, NULL), ignore_list);
2636 } 2632 }
2637 } 2633 }
2638 else 2634 else
2639 { 2635 {
2640 new_row = g_list_index(vf->list, VFICON_INFO(vf, selection)->data); 2636 new_row = g_list_index(vf->list, VFICON_INFO(vf, selection)->data);
2671 vf->list = g_list_remove(vf->list, id); 2667 vf->list = g_list_remove(vf->list, id);
2672 file_data_unref(fd); 2668 file_data_unref(fd);
2673 g_free(id); 2669 g_free(id);
2674 2670
2675 vficon_sync_idle(vf); 2671 vficon_sync_idle(vf);
2676 vficon_send_update(vf); 2672 vf_send_update(vf);
2677 2673
2678 return TRUE; 2674 return TRUE;
2679 } 2675 }
2680 2676
2681 gint vficon_maint_moved(ViewFile *vf, FileData *fd, GList *ignore_list) 2677 gint vficon_maint_moved(ViewFile *vf, FileData *fd, GList *ignore_list)