Mercurial > geeqie.yaz
comparison src/view_file_list.c @ 142:b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
This is just a prototype to test the functionality, it needs more work.
Please test, omments are welcome :)
author | nadvornik |
---|---|
date | Tue, 02 Oct 2007 21:49:02 +0000 |
parents | 754c1e4349b6 |
children | 0d1bf3ac6cd8 |
comparison
equal
deleted
inserted
replaced
141:bdc16027fa6f | 142:b5aa95241859 |
---|---|
92 GtkTreeModel *store; | 92 GtkTreeModel *store; |
93 GtkTreeIter iter; | 93 GtkTreeIter iter; |
94 | 94 |
95 if (vflist_find_row(vfl, fd, &iter) < 0) return; | 95 if (vflist_find_row(vfl, fd, &iter) < 0) return; |
96 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)); | 96 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)); |
97 gtk_list_store_set(GTK_LIST_STORE(store), &iter, FILE_COLUMN_COLOR, color_set, -1); | 97 gtk_tree_store_set(GTK_TREE_STORE(store), &iter, FILE_COLUMN_COLOR, color_set, -1); |
98 } | 98 } |
99 | 99 |
100 static void vflist_move_cursor(ViewFileList *vfl, GtkTreeIter *iter) | 100 static void vflist_move_cursor(ViewFileList *vfl, GtkTreeIter *iter) |
101 { | 101 { |
102 GtkTreeModel *store; | 102 GtkTreeModel *store; |
581 !(bevent->state & GDK_SHIFT_MASK ) && | 581 !(bevent->state & GDK_SHIFT_MASK ) && |
582 !(bevent->state & GDK_CONTROL_MASK ) && | 582 !(bevent->state & GDK_CONTROL_MASK ) && |
583 vflist_row_is_selected(vfl, fd)) | 583 vflist_row_is_selected(vfl, fd)) |
584 { | 584 { |
585 gtk_widget_grab_focus(widget); | 585 gtk_widget_grab_focus(widget); |
586 return TRUE; | 586 // return TRUE; // FIXME - expand |
587 } | 587 } |
588 | 588 |
589 #if 0 | 589 #if 0 |
590 if (bevent->button == 1 && bevent->type == GDK_2BUTTON_PRESS) | 590 if (bevent->button == 1 && bevent->type == GDK_2BUTTON_PRESS) |
591 { | 591 { |
653 | 653 |
654 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); | 654 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); |
655 gtk_tree_selection_unselect_all(selection); | 655 gtk_tree_selection_unselect_all(selection); |
656 gtk_tree_selection_select_iter(selection, &iter); | 656 gtk_tree_selection_select_iter(selection, &iter); |
657 vflist_move_cursor(vfl, &iter); | 657 vflist_move_cursor(vfl, &iter); |
658 return TRUE; | 658 // return TRUE;// FIXME - expand |
659 } | 659 } |
660 | 660 |
661 return FALSE; | 661 return FALSE; |
662 } | 662 } |
663 | 663 |
664 static void vflist_select_image(ViewFileList *vfl, gint row) | 664 static void vflist_select_image(ViewFileList *vfl, FileData *sel_fd) |
665 { | 665 { |
666 FileData *path; | |
667 FileData *read_ahead_fd = NULL; | 666 FileData *read_ahead_fd = NULL; |
668 | 667 gint row; |
669 path = vflist_index_get_data(vfl, row); | 668 if (!sel_fd) return; |
670 if (!path) return; | 669 row = g_list_index(vfl->list, sel_fd); |
671 | 670 // FIXME sidecar data |
672 if (path && enable_read_ahead) | 671 |
672 if (sel_fd && enable_read_ahead && row >= 0) | |
673 { | 673 { |
674 FileData *fd; | 674 FileData *fd; |
675 if (row > vflist_index_by_path(vfl, layout_image_get_path(vfl->layout)) && | 675 if (row > vflist_index_by_path(vfl, layout_image_get_path(vfl->layout)) && |
676 row + 1 < vflist_count(vfl, NULL)) | 676 row + 1 < vflist_count(vfl, NULL)) |
677 { | 677 { |
686 fd = NULL; | 686 fd = NULL; |
687 } | 687 } |
688 if (fd) read_ahead_fd = fd; | 688 if (fd) read_ahead_fd = fd; |
689 } | 689 } |
690 | 690 |
691 layout_image_set_with_ahead(vfl->layout, path, read_ahead_fd); | 691 layout_image_set_with_ahead(vfl->layout, sel_fd, read_ahead_fd); |
692 } | 692 } |
693 | 693 |
694 static gint vflist_select_idle_cb(gpointer data) | 694 static gint vflist_select_idle_cb(gpointer data) |
695 { | 695 { |
696 ViewFileList *vfl = data; | 696 ViewFileList *vfl = data; |
703 | 703 |
704 vflist_send_update(vfl); | 704 vflist_send_update(vfl); |
705 | 705 |
706 if (vfl->select_fd) | 706 if (vfl->select_fd) |
707 { | 707 { |
708 vflist_select_image(vfl, g_list_index(vfl->list, vfl->select_fd)); | 708 vflist_select_image(vfl, vfl->select_fd); |
709 vfl->select_fd = NULL; | 709 vfl->select_fd = NULL; |
710 } | 710 } |
711 | 711 |
712 vfl->select_idle_id = -1; | 712 vfl->select_idle_id = -1; |
713 return FALSE; | 713 return FALSE; |
754 gboolean path_currently_selected, gpointer data) | 754 gboolean path_currently_selected, gpointer data) |
755 { | 755 { |
756 return TRUE; | 756 return TRUE; |
757 } | 757 } |
758 | 758 |
759 | |
760 | |
761 void vflist_setup_iter(ViewFileList *vfl, GtkTreeStore *store, GtkTreeIter *iter, FileData *fd, GtkTreeIter *before) | |
762 { | |
763 gchar *size; | |
764 gchar *sidecars; | |
765 int i; | |
766 GList *work; | |
767 | |
768 sidecars = sidecar_file_data_list_to_string(fd); | |
769 size = text_from_size(fd->size); | |
770 | |
771 if (before) | |
772 { | |
773 gtk_tree_store_insert_before(store, iter, NULL, before); | |
774 } | |
775 else | |
776 { | |
777 gtk_tree_store_append(store, iter, NULL); | |
778 } | |
779 | |
780 gtk_tree_store_set(store, iter, FILE_COLUMN_POINTER, fd, | |
781 FILE_COLUMN_THUMB, (vfl->thumbs_enabled) ? fd->pixbuf : NULL, | |
782 FILE_COLUMN_NAME, fd->name, | |
783 FILE_COLUMN_SIDECARS, sidecars, | |
784 FILE_COLUMN_SIZE, size, | |
785 FILE_COLUMN_DATE, text_from_time(fd->date), | |
786 FILE_COLUMN_COLOR, FALSE, -1); | |
787 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) | |
788 gtk_tree_store_set(store, iter, FILE_COLUMN_MARKS + i, fd->marks[i], -1); | |
789 | |
790 g_free(size); | |
791 g_free(sidecars); | |
792 | |
793 | |
794 work = fd->sidecar_files; | |
795 while (work) | |
796 { | |
797 GtkTreeIter s_iter; | |
798 | |
799 FileData *sfd = work->data; | |
800 work = work->next; | |
801 | |
802 size = text_from_size(sfd->size); | |
803 gtk_tree_store_append(store, &s_iter, iter); | |
804 gtk_tree_store_set(store, &s_iter, | |
805 FILE_COLUMN_POINTER, sfd, | |
806 FILE_COLUMN_NAME, sfd->name, | |
807 FILE_COLUMN_SIZE, size, | |
808 FILE_COLUMN_DATE, text_from_time(sfd->date), | |
809 -1); | |
810 g_free(size); | |
811 } | |
812 | |
813 } | |
814 | |
815 | |
759 void vflist_sort_set(ViewFileList *vfl, SortType type, gint ascend) | 816 void vflist_sort_set(ViewFileList *vfl, SortType type, gint ascend) |
760 { | 817 { |
761 GtkTreeModel *model; | 818 GtkTreeModel *model; |
762 GtkListStore *store; | 819 GtkTreeStore *store; |
763 GList *work; | 820 GList *work; |
764 GtkTreeSelection *selection; | 821 GtkTreeSelection *selection; |
765 GtkTreePath *tpath; | 822 GtkTreePath *tpath; |
766 GtkTreeIter iter; | 823 GtkTreeIter iter; |
767 GList *select_list; | 824 GList *select_list; |
779 | 836 |
780 /* now reorder the treeview, maintaining current selection */ | 837 /* now reorder the treeview, maintaining current selection */ |
781 | 838 |
782 #if 0 | 839 #if 0 |
783 /* this is simpler, but much slower */ | 840 /* this is simpler, but much slower */ |
784 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); | 841 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); |
785 | 842 |
786 work = g_list_last(vfl->list); | 843 work = g_list_last(vfl->list); |
787 while (work) | 844 while (work) |
788 { | 845 { |
789 FileData *fd; | 846 FileData *fd; |
790 GtkTreeIter iter; | 847 GtkTreeIter iter; |
791 | 848 |
792 fd = work->data; | 849 fd = work->data; |
793 if (vflist_find_row(vfl, fd, &iter) >= 0) | 850 if (vflist_find_row(vfl, fd, &iter) >= 0) |
794 { | 851 { |
795 gtk_list_store_move_after(store, &iter, NULL); | 852 gtk_tree_store_move_after(store, &iter, NULL); |
796 } | 853 } |
797 | 854 |
798 work = work->prev; | 855 work = work->prev; |
799 } | 856 } |
800 #endif | 857 #endif |
803 | 860 |
804 gtk_tree_selection_set_select_function(selection, vflist_dummy_select_cb, vfl, NULL); | 861 gtk_tree_selection_set_select_function(selection, vflist_dummy_select_cb, vfl, NULL); |
805 | 862 |
806 select_list = gtk_tree_selection_get_selected_rows(selection, &model); | 863 select_list = gtk_tree_selection_get_selected_rows(selection, &model); |
807 work = select_list; | 864 work = select_list; |
808 while (work) | 865 while (work) // FIXME this does not work for tree view |
809 { | 866 { |
810 FileData *fd; | 867 FileData *fd; |
811 | 868 |
812 tpath = work->data; | 869 tpath = work->data; |
813 gtk_tree_model_get_iter(model, &iter, tpath); | 870 gtk_tree_model_get_iter(model, &iter, tpath); |
831 } | 888 } |
832 | 889 |
833 single_select = (select_list && !select_list->next); | 890 single_select = (select_list && !select_list->next); |
834 if (single_select) cursor_fd = select_list->data; | 891 if (single_select) cursor_fd = select_list->data; |
835 | 892 |
836 store = GTK_LIST_STORE(model); | 893 store = GTK_TREE_STORE(model); |
837 gtk_list_store_clear(store); | 894 gtk_tree_store_clear(store); |
838 | 895 |
839 work = vfl->list; | 896 work = vfl->list; |
840 while (work) | 897 while (work) |
841 { | 898 { |
842 FileData *fd; | 899 FileData *fd = work->data; |
843 gchar *size; | 900 |
844 gchar *sidecars; | 901 vflist_setup_iter(vfl, store, &iter, fd, NULL); |
845 int i; | |
846 | |
847 fd = work->data; | |
848 sidecars = sidecar_file_data_list_to_string(fd); | |
849 size = text_from_size(fd->size); | |
850 gtk_list_store_append(store, &iter); | |
851 gtk_list_store_set(store, &iter, FILE_COLUMN_POINTER, fd, | |
852 FILE_COLUMN_THUMB, (vfl->thumbs_enabled) ? fd->pixbuf : NULL, | |
853 FILE_COLUMN_NAME, fd->name, | |
854 FILE_COLUMN_SIDECARS, sidecars, | |
855 FILE_COLUMN_SIZE, size, | |
856 FILE_COLUMN_DATE, text_from_time(fd->date), | |
857 FILE_COLUMN_COLOR, FALSE, -1); | |
858 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) | |
859 gtk_list_store_set(store, &iter, FILE_COLUMN_MARKS + i, fd->marks[i], -1); | |
860 | |
861 g_free(size); | |
862 g_free(sidecars); | |
863 | 902 |
864 if (select_list && select_list->data == fd) | 903 if (select_list && select_list->data == fd) |
865 { | 904 { |
866 select_list = g_list_remove(select_list, fd); | 905 select_list = g_list_remove(select_list, fd); |
867 gtk_tree_selection_select_iter(selection, &iter); | 906 gtk_tree_selection_select_iter(selection, &iter); |
922 if (vfl->thumbs_running) vflist_thumb_cleanup(vfl); | 961 if (vfl->thumbs_running) vflist_thumb_cleanup(vfl); |
923 } | 962 } |
924 | 963 |
925 static void vflist_thumb_do(ViewFileList *vfl, ThumbLoader *tl, FileData *fd) | 964 static void vflist_thumb_do(ViewFileList *vfl, ThumbLoader *tl, FileData *fd) |
926 { | 965 { |
927 GtkListStore *store; | 966 GtkTreeStore *store; |
928 GtkTreeIter iter; | 967 GtkTreeIter iter; |
929 | 968 |
930 if (!fd || vflist_find_row(vfl, fd, &iter) < 0) return; | 969 if (!fd || vflist_find_row(vfl, fd, &iter) < 0) return; |
931 | 970 |
932 if (fd->pixbuf) g_object_unref(fd->pixbuf); | 971 if (fd->pixbuf) g_object_unref(fd->pixbuf); |
933 fd->pixbuf = thumb_loader_get_pixbuf(tl, TRUE); | 972 fd->pixbuf = thumb_loader_get_pixbuf(tl, TRUE); |
934 | 973 |
935 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); | 974 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); |
936 gtk_list_store_set(store, &iter, FILE_COLUMN_THUMB, fd->pixbuf, -1); | 975 gtk_tree_store_set(store, &iter, FILE_COLUMN_THUMB, fd->pixbuf, -1); |
937 | 976 |
938 vflist_thumb_status(vfl, (gdouble)(vfl->thumbs_count) / g_list_length(vfl->list), _("Loading thumbs...")); | 977 vflist_thumb_status(vfl, (gdouble)(vfl->thumbs_count) / g_list_length(vfl->list), _("Loading thumbs...")); |
939 } | 978 } |
940 | 979 |
941 static void vflist_thumb_error_cb(ThumbLoader *tl, gpointer data) | 980 static void vflist_thumb_error_cb(ThumbLoader *tl, gpointer data) |
1340 GList *list; | 1379 GList *list; |
1341 | 1380 |
1342 column = gtk_tree_view_get_column(GTK_TREE_VIEW(listview), FILE_COLUMN_THUMB - 1); | 1381 column = gtk_tree_view_get_column(GTK_TREE_VIEW(listview), FILE_COLUMN_THUMB - 1); |
1343 if (!column) return; | 1382 if (!column) return; |
1344 | 1383 |
1345 gtk_tree_view_column_set_fixed_width(column, (thumb) ? thumb_max_width : FILE_COLUMN_MARKS); | 1384 gtk_tree_view_column_set_fixed_width(column, ((thumb) ? thumb_max_width : 4) + 50); |
1346 | 1385 |
1347 list = gtk_tree_view_column_get_cell_renderers(column); | 1386 list = gtk_tree_view_column_get_cell_renderers(column); |
1348 if (!list) return; | 1387 if (!list) return; |
1349 cell = list->data; | 1388 cell = list->data; |
1350 g_list_free(list); | 1389 g_list_free(list); |
1353 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(listview)); | 1392 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(listview)); |
1354 } | 1393 } |
1355 | 1394 |
1356 static void vflist_populate_view(ViewFileList *vfl) | 1395 static void vflist_populate_view(ViewFileList *vfl) |
1357 { | 1396 { |
1358 GtkListStore *store; | 1397 GtkTreeStore *store; |
1359 GtkTreeIter iter; | 1398 GtkTreeIter iter; |
1360 gint thumbs; | 1399 gint thumbs; |
1361 GList *work; | 1400 GList *work; |
1362 GtkTreeRowReference *visible_row = NULL; | 1401 GtkTreeRowReference *visible_row = NULL; |
1363 GtkTreePath *tpath; | 1402 GtkTreePath *tpath; |
1364 gint valid; | 1403 gint valid; |
1365 | 1404 |
1366 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); | 1405 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); |
1367 thumbs = vfl->thumbs_enabled; | 1406 thumbs = vfl->thumbs_enabled; |
1368 | 1407 |
1369 vflist_thumb_stop(vfl); | 1408 vflist_thumb_stop(vfl); |
1370 | 1409 |
1371 if (!vfl->list) | 1410 if (!vfl->list) |
1372 { | 1411 { |
1373 gtk_list_store_clear(store); | 1412 gtk_tree_store_clear(store); |
1374 vflist_send_update(vfl); | 1413 vflist_send_update(vfl); |
1375 return; | 1414 return; |
1376 } | 1415 } |
1377 | 1416 |
1378 if (GTK_WIDGET_REALIZED(vfl->listview) && | 1417 if (GTK_WIDGET_REALIZED(vfl->listview) && |
1409 } | 1448 } |
1410 | 1449 |
1411 if (match < 0) | 1450 if (match < 0) |
1412 { | 1451 { |
1413 GtkTreeIter new; | 1452 GtkTreeIter new; |
1414 gchar *size; | |
1415 gchar *sidecars; | |
1416 | |
1417 size = text_from_size(fd->size); | |
1418 sidecars = sidecar_file_data_list_to_string(fd); | |
1419 | 1453 |
1420 if (valid) | 1454 if (valid) |
1421 { | 1455 { |
1422 gtk_list_store_insert_before(store, &new, &iter); | 1456 vflist_setup_iter(vfl, store, &new, fd, &iter); |
1423 } | 1457 } |
1424 else | 1458 else |
1425 { | 1459 { |
1426 gtk_list_store_append(store, &new); | 1460 vflist_setup_iter(vfl, store, &new, fd, NULL); |
1427 } | 1461 } |
1428 gtk_list_store_set(store, &new, FILE_COLUMN_POINTER, fd, | |
1429 FILE_COLUMN_THUMB, (thumbs) ? fd->pixbuf : NULL, | |
1430 FILE_COLUMN_NAME, fd->name, | |
1431 FILE_COLUMN_SIDECARS, sidecars, | |
1432 FILE_COLUMN_SIZE, size, | |
1433 FILE_COLUMN_DATE, text_from_time(fd->date), | |
1434 FILE_COLUMN_COLOR, FALSE, -1); | |
1435 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) | |
1436 gtk_list_store_set(store, &new, FILE_COLUMN_MARKS + i, fd->marks[i], -1); | |
1437 | |
1438 g_free(size); | |
1439 g_free(sidecars); | |
1440 | 1462 |
1441 done = TRUE; | 1463 done = TRUE; |
1442 } | 1464 } |
1443 else if (match > 0) | 1465 else if (match > 0) |
1444 { | 1466 { |
1445 valid = gtk_list_store_remove(store, &iter); | 1467 valid = gtk_tree_store_remove(store, &iter); |
1446 } | 1468 } |
1447 else | 1469 else |
1448 { | 1470 { |
1449 gtk_list_store_set(store, &iter, FILE_COLUMN_POINTER, fd, -1); | 1471 gtk_tree_store_set(store, &iter, FILE_COLUMN_POINTER, fd, -1); |
1450 if (fd->date != old_fd->date) | 1472 if (fd->date != old_fd->date) |
1451 { | 1473 { |
1452 gchar *size; | 1474 gchar *size; |
1453 | 1475 |
1454 /* update, file changed */ | 1476 /* update, file changed */ |
1455 size = text_from_size(fd->size); | 1477 size = text_from_size(fd->size); |
1456 gtk_list_store_set(store, &iter, FILE_COLUMN_SIZE, size, | 1478 gtk_tree_store_set(store, &iter, FILE_COLUMN_SIZE, size, |
1457 FILE_COLUMN_DATE, text_from_time(fd->date), -1); | 1479 FILE_COLUMN_DATE, text_from_time(fd->date), -1); |
1458 g_free(size); | 1480 g_free(size); |
1459 } | 1481 } |
1460 else if (fd != old_fd) | 1482 else if (fd != old_fd) |
1461 { | 1483 { |
1463 if (fd->pixbuf) g_object_unref(fd->pixbuf); | 1485 if (fd->pixbuf) g_object_unref(fd->pixbuf); |
1464 fd->pixbuf = old_fd->pixbuf; | 1486 fd->pixbuf = old_fd->pixbuf; |
1465 if (fd->pixbuf) g_object_ref(fd->pixbuf); | 1487 if (fd->pixbuf) g_object_ref(fd->pixbuf); |
1466 } | 1488 } |
1467 | 1489 |
1468 gtk_list_store_set(store, &iter, FILE_COLUMN_THUMB, (thumbs) ? fd->pixbuf : NULL, -1); | 1490 gtk_tree_store_set(store, &iter, FILE_COLUMN_THUMB, (thumbs) ? fd->pixbuf : NULL, -1); |
1469 | 1491 |
1470 if (vfl->select_fd == old_fd) vfl->select_fd = fd; | 1492 if (vfl->select_fd == old_fd) vfl->select_fd = fd; |
1471 | 1493 |
1472 if (valid) valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); | 1494 if (valid) valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); |
1473 | 1495 |
1477 work = work->next; | 1499 work = work->next; |
1478 } | 1500 } |
1479 | 1501 |
1480 while (valid) | 1502 while (valid) |
1481 { | 1503 { |
1482 valid = gtk_list_store_remove(store, &iter); | 1504 valid = gtk_tree_store_remove(store, &iter); |
1483 } | 1505 } |
1484 | 1506 |
1485 if (visible_row) | 1507 if (visible_row) |
1486 { | 1508 { |
1487 if (gtk_tree_row_reference_valid(visible_row)) | 1509 if (gtk_tree_row_reference_valid(visible_row)) |
1575 gtk_tree_view_column_set_title(column, title); | 1597 gtk_tree_view_column_set_title(column, title); |
1576 gtk_tree_view_column_set_min_width(column, 4); | 1598 gtk_tree_view_column_set_min_width(column, 4); |
1577 | 1599 |
1578 if (!image) | 1600 if (!image) |
1579 { | 1601 { |
1580 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY); | 1602 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
1581 renderer = gtk_cell_renderer_text_new(); | 1603 renderer = gtk_cell_renderer_text_new(); |
1582 if (right_justify) | 1604 if (right_justify) |
1583 { | 1605 { |
1584 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL); | 1606 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL); |
1585 } | 1607 } |
1586 gtk_tree_view_column_pack_start(column, renderer, TRUE); | 1608 gtk_tree_view_column_pack_start(column, renderer, TRUE); |
1587 gtk_tree_view_column_add_attribute(column, renderer, "text", n); | 1609 gtk_tree_view_column_add_attribute(column, renderer, "text", n); |
1588 if (expand) | 1610 if (expand) |
1589 gtk_tree_view_column_set_expand(column, TRUE); | 1611 gtk_tree_view_column_set_expand(column, TRUE); |
1590 } | 1612 } |
1591 else | 1613 else |
1592 { | 1614 { |
1593 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); | 1615 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); |
1594 renderer = gtk_cell_renderer_pixbuf_new(); | 1616 renderer = gtk_cell_renderer_pixbuf_new(); |
1600 gtk_tree_view_column_set_cell_data_func(column, renderer, vflist_listview_color_cb, vfl, NULL); | 1622 gtk_tree_view_column_set_cell_data_func(column, renderer, vflist_listview_color_cb, vfl, NULL); |
1601 | 1623 |
1602 gtk_tree_view_append_column(GTK_TREE_VIEW(vfl->listview), column); | 1624 gtk_tree_view_append_column(GTK_TREE_VIEW(vfl->listview), column); |
1603 } | 1625 } |
1604 | 1626 |
1605 static void vflist_listview_mark_toggled(GtkCellRendererToggle *cell, gchar *path_str, GtkListStore *store) | 1627 static void vflist_listview_mark_toggled(GtkCellRendererToggle *cell, gchar *path_str, GtkTreeStore *store) |
1606 { | 1628 { |
1607 GtkTreePath *path = gtk_tree_path_new_from_string(path_str); | 1629 GtkTreePath *path = gtk_tree_path_new_from_string(path_str); |
1608 guint *marks; | 1630 guint *marks; |
1609 GtkTreeIter iter; | 1631 GtkTreeIter iter; |
1610 FileData *fd; | 1632 FileData *fd; |
1618 | 1640 |
1619 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &fd, column, &mark, -1); | 1641 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &fd, column, &mark, -1); |
1620 mark ^= 1; | 1642 mark ^= 1; |
1621 fd->marks[column] = mark; | 1643 fd->marks[column] = mark; |
1622 | 1644 |
1623 gtk_list_store_set(store, &iter, column, mark, -1); | 1645 gtk_tree_store_set(store, &iter, column, mark, -1); |
1624 gtk_tree_path_free(path); | 1646 gtk_tree_path_free(path); |
1625 } | 1647 } |
1626 | 1648 |
1627 static void vflist_listview_add_column_toggle(ViewFileList *vfl, gint n, const gchar *title) | 1649 static void vflist_listview_add_column_toggle(ViewFileList *vfl, gint n, const gchar *title) |
1628 { | 1650 { |
1629 GtkTreeViewColumn *column; | 1651 GtkTreeViewColumn *column; |
1630 GtkCellRenderer *renderer; | 1652 GtkCellRenderer *renderer; |
1631 GtkListStore *store; | 1653 GtkTreeStore *store; |
1632 gint index; | 1654 gint index; |
1633 | 1655 |
1634 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); | 1656 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); |
1635 | 1657 |
1636 renderer = gtk_cell_renderer_toggle_new(); | 1658 renderer = gtk_cell_renderer_toggle_new(); |
1637 column = gtk_tree_view_column_new_with_attributes(title, renderer, "active", n, NULL); | 1659 column = gtk_tree_view_column_new_with_attributes(title, renderer, "active", n, NULL); |
1638 | 1660 |
1639 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); | 1661 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); |
1654 *----------------------------------------------------------------------------- | 1676 *----------------------------------------------------------------------------- |
1655 */ | 1677 */ |
1656 | 1678 |
1657 gint vflist_set_path(ViewFileList *vfl, const gchar *path) | 1679 gint vflist_set_path(ViewFileList *vfl, const gchar *path) |
1658 { | 1680 { |
1659 GtkListStore *store; | 1681 GtkTreeStore *store; |
1660 | 1682 |
1661 if (!path) return FALSE; | 1683 if (!path) return FALSE; |
1662 if (vfl->path && strcmp(path, vfl->path) == 0) return TRUE; | 1684 if (vfl->path && strcmp(path, vfl->path) == 0) return TRUE; |
1663 | 1685 |
1664 g_free(vfl->path); | 1686 g_free(vfl->path); |
1665 vfl->path = g_strdup(path); | 1687 vfl->path = g_strdup(path); |
1666 | 1688 |
1667 /* force complete reload */ | 1689 /* force complete reload */ |
1668 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); | 1690 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); |
1669 gtk_list_store_clear(store); | 1691 gtk_tree_store_clear(store); |
1670 | 1692 |
1671 filelist_free(vfl->list); | 1693 filelist_free(vfl->list); |
1672 vfl->list = NULL; | 1694 vfl->list = NULL; |
1673 | 1695 |
1674 return vflist_refresh(vfl); | 1696 return vflist_refresh(vfl); |
1694 } | 1716 } |
1695 | 1717 |
1696 ViewFileList *vflist_new(const gchar *path, gint thumbs) | 1718 ViewFileList *vflist_new(const gchar *path, gint thumbs) |
1697 { | 1719 { |
1698 ViewFileList *vfl; | 1720 ViewFileList *vfl; |
1699 GtkListStore *store; | 1721 GtkTreeStore *store; |
1700 GtkTreeSelection *selection; | 1722 GtkTreeSelection *selection; |
1701 | 1723 |
1702 GType *flist_types; | 1724 GType *flist_types; |
1703 int i; | 1725 int i; |
1704 | 1726 |
1737 flist_types[FILE_COLUMN_DATE] = G_TYPE_STRING; | 1759 flist_types[FILE_COLUMN_DATE] = G_TYPE_STRING; |
1738 flist_types[FILE_COLUMN_COLOR] = G_TYPE_BOOLEAN; | 1760 flist_types[FILE_COLUMN_COLOR] = G_TYPE_BOOLEAN; |
1739 for (i = FILE_COLUMN_MARKS; i < FILE_COLUMN_MARKS + FILEDATA_MARKS_SIZE; i++) | 1761 for (i = FILE_COLUMN_MARKS; i < FILE_COLUMN_MARKS + FILEDATA_MARKS_SIZE; i++) |
1740 flist_types[i] = G_TYPE_BOOLEAN; | 1762 flist_types[i] = G_TYPE_BOOLEAN; |
1741 | 1763 |
1742 store = gtk_list_store_newv(FILE_COLUMN_COUNT, flist_types); | 1764 store = gtk_tree_store_newv(FILE_COLUMN_COUNT, flist_types); |
1743 g_free(flist_types); | 1765 g_free(flist_types); |
1744 | 1766 |
1745 vfl->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); | 1767 vfl->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); |
1746 g_object_unref(store); | 1768 g_object_unref(store); |
1747 | 1769 |
1748 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview)); | 1770 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview)); |
1749 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_MULTIPLE); | 1771 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_MULTIPLE); |
1750 gtk_tree_selection_set_select_function(selection, vflist_select_cb, vfl, NULL); | 1772 gtk_tree_selection_set_select_function(selection, vflist_select_cb, vfl, NULL); |
1751 | 1773 |
1752 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vfl->listview), FALSE); | 1774 // gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vfl->listview), FALSE); |
1753 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vfl->listview), FALSE); | 1775 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vfl->listview), FALSE); |
1754 | 1776 |
1755 vflist_listview_add_column(vfl, FILE_COLUMN_THUMB, "", TRUE, FALSE, FALSE); | 1777 vflist_listview_add_column(vfl, FILE_COLUMN_THUMB, "", TRUE, FALSE, FALSE); |
1756 vflist_listview_add_column(vfl, FILE_COLUMN_NAME, _("Name"), FALSE, FALSE, FALSE); | 1778 vflist_listview_add_column(vfl, FILE_COLUMN_NAME, _("Name"), FALSE, FALSE, FALSE); |
1757 vflist_listview_add_column(vfl, FILE_COLUMN_SIDECARS, _("sidecars"), FALSE, FALSE, FALSE); | 1779 vflist_listview_add_column(vfl, FILE_COLUMN_SIDECARS, _("Sidecars"), FALSE, FALSE, FALSE); |
1758 vflist_listview_add_column(vfl, FILE_COLUMN_SIZE, _("Size"), FALSE, TRUE, FALSE); | 1780 vflist_listview_add_column(vfl, FILE_COLUMN_SIZE, _("Size"), FALSE, TRUE, FALSE); |
1759 vflist_listview_add_column(vfl, FILE_COLUMN_DATE, _("Date"), FALSE, TRUE, TRUE); | 1781 vflist_listview_add_column(vfl, FILE_COLUMN_DATE, _("Date"), FALSE, TRUE, TRUE); |
1760 | 1782 |
1761 for(i = 0; i < FILEDATA_MARKS_SIZE;i++) | 1783 for(i = 0; i < FILEDATA_MARKS_SIZE;i++) |
1762 vflist_listview_add_column_toggle(vfl, i + FILE_COLUMN_MARKS, ""); | 1784 vflist_listview_add_column_toggle(vfl, i + FILE_COLUMN_MARKS, ""); |
1804 vflist_refresh(vfl); | 1826 vflist_refresh(vfl); |
1805 } | 1827 } |
1806 | 1828 |
1807 void vflist_marks_set(ViewFileList *vfl, gint enable) | 1829 void vflist_marks_set(ViewFileList *vfl, gint enable) |
1808 { | 1830 { |
1809 GtkListStore *store; | 1831 GtkTreeStore *store; |
1810 GtkTreeViewColumn *column; | 1832 GtkTreeViewColumn *column; |
1811 int i; | 1833 int i; |
1812 | 1834 |
1813 if (vfl->marks_enabled == enable) return; | 1835 if (vfl->marks_enabled == enable) return; |
1814 | 1836 |
1904 dest_base = remove_level_from_path(fd->change->dest); | 1926 dest_base = remove_level_from_path(fd->change->dest); |
1905 | 1927 |
1906 | 1928 |
1907 if (strcmp(source_base, dest_base) == 0) | 1929 if (strcmp(source_base, dest_base) == 0) |
1908 { | 1930 { |
1909 GtkListStore *store; | 1931 GtkTreeStore *store; |
1910 GtkTreeIter iter; | 1932 GtkTreeIter iter; |
1911 GtkTreeIter position; | 1933 GtkTreeIter position; |
1912 gint old_row; | 1934 gint old_row; |
1913 gint n; | 1935 gint n; |
1914 | 1936 |
1917 vfl->list = g_list_remove(vfl->list, fd); | 1939 vfl->list = g_list_remove(vfl->list, fd); |
1918 | 1940 |
1919 vfl->list = filelist_insert_sort(vfl->list, fd, vfl->sort_method, vfl->sort_ascend); | 1941 vfl->list = filelist_insert_sort(vfl->list, fd, vfl->sort_method, vfl->sort_ascend); |
1920 n = g_list_index(vfl->list, fd); | 1942 n = g_list_index(vfl->list, fd); |
1921 | 1943 |
1922 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); | 1944 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); |
1923 row = vflist_find_row(vfl, fd, &iter); | 1945 row = vflist_find_row(vfl, fd, &iter); |
1924 if (vflist_find_row(vfl, fd, &iter) >= 0 && | 1946 if (vflist_find_row(vfl, fd, &iter) >= 0 && |
1925 gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &position, NULL, n)) | 1947 gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &position, NULL, n)) |
1926 { | 1948 { |
1927 if (old_row >= n) | 1949 if (old_row >= n) |
1928 { | 1950 { |
1929 gtk_list_store_move_before(store, &iter, &position); | 1951 gtk_tree_store_move_before(store, &iter, &position); |
1930 } | 1952 } |
1931 else | 1953 else |
1932 { | 1954 { |
1933 gtk_list_store_move_after(store, &iter, &position); | 1955 gtk_tree_store_move_after(store, &iter, &position); |
1934 } | 1956 } |
1935 } | 1957 } |
1936 gtk_list_store_set(store, &iter, FILE_COLUMN_NAME, fd->name, -1); | 1958 gtk_tree_store_set(store, &iter, FILE_COLUMN_NAME, fd->name, -1); |
1937 | 1959 |
1938 ret = TRUE; | 1960 ret = TRUE; |
1939 } | 1961 } |
1940 else | 1962 else |
1941 { | 1963 { |
1996 } | 2018 } |
1997 | 2019 |
1998 fd = vflist_index_get_data(vfl, row); | 2020 fd = vflist_index_get_data(vfl, row); |
1999 if (vflist_find_row(vfl, fd, &iter) >= 0) | 2021 if (vflist_find_row(vfl, fd, &iter) >= 0) |
2000 { | 2022 { |
2001 GtkListStore *store; | 2023 GtkTreeStore *store; |
2002 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); | 2024 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); |
2003 gtk_list_store_remove(store, &iter); | 2025 gtk_tree_store_remove(store, &iter); |
2004 } | 2026 } |
2005 list = g_list_nth(vfl->list, row); | 2027 list = g_list_nth(vfl->list, row); |
2006 fd = list->data; | 2028 fd = list->data; |
2007 | 2029 |
2008 /* thumbnail loader check */ | 2030 /* thumbnail loader check */ |