comparison src/layout.c @ 574:3da75054d4e1

Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
author zas_
date Sun, 04 May 2008 18:45:06 +0000
parents 2996f1bbc305
children de3e2bc22336
comparison
equal deleted inserted replaced
573:2996f1bbc305 574:3da75054d4e1
26 #include "pixbuf-renderer.h" 26 #include "pixbuf-renderer.h"
27 #include "pixbuf_util.h" 27 #include "pixbuf_util.h"
28 #include "utilops.h" 28 #include "utilops.h"
29 #include "view_dir.h" 29 #include "view_dir.h"
30 #include "view_file.h" 30 #include "view_file.h"
31 #include "view_file_icon.h"
32 #include "ui_bookmark.h" 31 #include "ui_bookmark.h"
33 #include "ui_fileops.h" 32 #include "ui_fileops.h"
34 #include "ui_menu.h" 33 #include "ui_menu.h"
35 #include "ui_misc.h" 34 #include "ui_misc.h"
36 #include "ui_tabcomp.h" 35 #include "ui_tabcomp.h"
725 LayoutWindow *lw = data; 724 LayoutWindow *lw = data;
726 725
727 layout_status_update_progress(lw, val, text); 726 layout_status_update_progress(lw, val, text);
728 } 727 }
729 728
730 static void layout_icon_status_cb(ViewFileIcon *vfi, gpointer data)
731 {
732 LayoutWindow *lw = data;
733
734 layout_status_update_info(lw, NULL);
735 }
736
737 static void layout_icon_thumb_cb(ViewFileIcon *vfi, gdouble val, const gchar *text, gpointer data)
738 {
739 LayoutWindow *lw = data;
740
741 layout_status_update_progress(lw, val, text);
742 }
743
744 static GtkWidget *layout_list_new(LayoutWindow *lw) 729 static GtkWidget *layout_list_new(LayoutWindow *lw)
745 { 730 {
746 GtkWidget *widget = NULL; 731 lw->vf = vf_new(lw->file_view_type, NULL);
732 vf_set_layout(lw->vf, lw);
733
734 vf_set_status_func(lw->vf, layout_list_status_cb, lw);
735 vf_set_thumb_status_func(lw->vf, layout_list_thumb_cb, lw);
736
737 vf_marks_set(lw->vf, lw->marks_enabled);
747 738
748 switch (lw->file_view_type) 739 switch (lw->file_view_type)
749 { 740 {
750 case FILEVIEW_ICON: 741 case FILEVIEW_ICON:
751 {
752 lw->vfi = vficon_new(NULL);
753 vficon_set_layout(lw->vfi, lw);
754
755 vficon_set_status_func(lw->vfi, layout_icon_status_cb, lw);
756 vficon_set_thumb_status_func(lw->vfi, layout_icon_thumb_cb, lw);
757 /* FIXME vficon_marks_set(lw->vfi, lw->marks_enabled); */
758
759 widget = lw->vfi->widget;
760 }
761 break; 742 break;
762 case FILEVIEW_LIST: 743 case FILEVIEW_LIST:
763 {
764 lw->vf = vf_new(lw->file_view_type, NULL);
765 vf_set_layout(lw->vf, lw);
766
767 vf_set_status_func(lw->vf, layout_list_status_cb, lw);
768 vf_set_thumb_status_func(lw->vf, layout_list_thumb_cb, lw);
769
770 vf_marks_set(lw->vf, lw->marks_enabled);
771 vf_thumb_set(lw->vf, lw->thumbs_enabled); 744 vf_thumb_set(lw->vf, lw->thumbs_enabled);
772
773 widget = lw->vf->widget;
774 }
775 break; 745 break;
776 } 746 }
777 747
778 return widget; 748 return lw->vf->widget;
779 } 749 }
780 750
781 static void layout_list_sync_thumb(LayoutWindow *lw) 751 static void layout_list_sync_thumb(LayoutWindow *lw)
782 { 752 {
783 if (lw->vf) vf_thumb_set(lw->vf, lw->thumbs_enabled); 753 if (lw->vf) vf_thumb_set(lw->vf, lw->thumbs_enabled);
791 static void layout_list_scroll_to_subpart(LayoutWindow *lw, const gchar *needle) 761 static void layout_list_scroll_to_subpart(LayoutWindow *lw, const gchar *needle)
792 { 762 {
793 if (!lw) return; 763 if (!lw) return;
794 #if 0 764 #if 0
795 if (lw->vf) vf_scroll_to_subpart(lw->vf, needle); 765 if (lw->vf) vf_scroll_to_subpart(lw->vf, needle);
796 if (lw->vfi) vficon_scroll_to_subpart(lw->vfi, needle);
797 #endif 766 #endif
798 } 767 }
799 768
800 GList *layout_list(LayoutWindow *lw) 769 GList *layout_list(LayoutWindow *lw)
801 { 770 {
802 if (!layout_valid(&lw)) return NULL; 771 if (!layout_valid(&lw)) return NULL;
803 772
804 if (lw->vf) return vf_get_list(lw->vf); 773 if (lw->vf) return vf_get_list(lw->vf);
805 if (lw->vfi) return vficon_get_list(lw->vfi);
806 774
807 return NULL; 775 return NULL;
808 } 776 }
809 777
810 gint layout_list_count(LayoutWindow *lw, gint64 *bytes) 778 gint layout_list_count(LayoutWindow *lw, gint64 *bytes)
811 { 779 {
812 if (!layout_valid(&lw)) return 0; 780 if (!layout_valid(&lw)) return 0;
813 781
814 if (lw->vf) return vf_count(lw->vf, bytes); 782 if (lw->vf) return vf_count(lw->vf, bytes);
815 if (lw->vfi) return vficon_count(lw->vfi, bytes);
816 783
817 return 0; 784 return 0;
818 } 785 }
819 786
820 const gchar *layout_list_get_path(LayoutWindow *lw, gint index) 787 const gchar *layout_list_get_path(LayoutWindow *lw, gint index)
821 { 788 {
822 if (!layout_valid(&lw)) return NULL; 789 if (!layout_valid(&lw)) return NULL;
823 790
824 if (lw->vf) return vf_index_get_path(lw->vf, index); 791 if (lw->vf) return vf_index_get_path(lw->vf, index);
825 if (lw->vfi) return vficon_index_get_path(lw->vfi, index);
826 792
827 return NULL; 793 return NULL;
828 } 794 }
829 795
830 FileData *layout_list_get_fd(LayoutWindow *lw, gint index) 796 FileData *layout_list_get_fd(LayoutWindow *lw, gint index)
831 { 797 {
832 if (!layout_valid(&lw)) return NULL; 798 if (!layout_valid(&lw)) return NULL;
833 799
834 if (lw->vf) return vf_index_get_data(lw->vf, index); 800 if (lw->vf) return vf_index_get_data(lw->vf, index);
835 if (lw->vfi) return vficon_index_get_data(lw->vfi, index);
836 801
837 return NULL; 802 return NULL;
838 } 803 }
839 804
840 gint layout_list_get_index(LayoutWindow *lw, const gchar *path) 805 gint layout_list_get_index(LayoutWindow *lw, const gchar *path)
841 { 806 {
842 if (!layout_valid(&lw)) return -1; 807 if (!layout_valid(&lw)) return -1;
843 808
844 if (lw->vf) return vf_index_by_path(lw->vf, path); 809 if (lw->vf) return vf_index_by_path(lw->vf, path);
845 if (lw->vfi) return vficon_index_by_path(lw->vfi, path);
846 810
847 return -1; 811 return -1;
848 } 812 }
849 813
850 void layout_list_sync_fd(LayoutWindow *lw, FileData *fd) 814 void layout_list_sync_fd(LayoutWindow *lw, FileData *fd)
851 { 815 {
852 if (!layout_valid(&lw)) return; 816 if (!layout_valid(&lw)) return;
853 817
854 if (lw->vf) vf_select_by_fd(lw->vf, fd); 818 if (lw->vf) vf_select_by_fd(lw->vf, fd);
855 if (lw->vfi) vficon_select_by_fd(lw->vfi, fd);
856 } 819 }
857 820
858 static void layout_list_sync_sort(LayoutWindow *lw) 821 static void layout_list_sync_sort(LayoutWindow *lw)
859 { 822 {
860 if (!layout_valid(&lw)) return; 823 if (!layout_valid(&lw)) return;
861 824
862 if (lw->vf) vf_sort_set(lw->vf, lw->sort_method, lw->sort_ascend); 825 if (lw->vf) vf_sort_set(lw->vf, lw->sort_method, lw->sort_ascend);
863 if (lw->vfi) vficon_sort_set(lw->vfi, lw->sort_method, lw->sort_ascend);
864 } 826 }
865 827
866 GList *layout_selection_list(LayoutWindow *lw) 828 GList *layout_selection_list(LayoutWindow *lw)
867 { 829 {
868 if (!layout_valid(&lw)) return NULL; 830 if (!layout_valid(&lw)) return NULL;
875 if (fd) return g_list_append(NULL, file_data_ref(fd)); 837 if (fd) return g_list_append(NULL, file_data_ref(fd));
876 return NULL; 838 return NULL;
877 } 839 }
878 840
879 if (lw->vf) return vf_selection_get_list(lw->vf); 841 if (lw->vf) return vf_selection_get_list(lw->vf);
880 if (lw->vfi) return vficon_selection_get_list(lw->vfi);
881 842
882 return NULL; 843 return NULL;
883 } 844 }
884 845
885 GList *layout_selection_list_by_index(LayoutWindow *lw) 846 GList *layout_selection_list_by_index(LayoutWindow *lw)
886 { 847 {
887 if (!layout_valid(&lw)) return NULL; 848 if (!layout_valid(&lw)) return NULL;
888 849
889 if (lw->vf) return vf_selection_get_list_by_index(lw->vf); 850 if (lw->vf) return vf_selection_get_list_by_index(lw->vf);
890 if (lw->vfi) return vficon_selection_get_list_by_index(lw->vfi);
891 851
892 return NULL; 852 return NULL;
893 } 853 }
894 854
895 gint layout_selection_count(LayoutWindow *lw, gint64 *bytes) 855 gint layout_selection_count(LayoutWindow *lw, gint64 *bytes)
896 { 856 {
897 if (!layout_valid(&lw)) return 0; 857 if (!layout_valid(&lw)) return 0;
898 858
899 if (lw->vf) return vf_selection_count(lw->vf, bytes); 859 if (lw->vf) return vf_selection_count(lw->vf, bytes);
900 if (lw->vfi) return vficon_selection_count(lw->vfi, bytes);
901 860
902 return 0; 861 return 0;
903 } 862 }
904 863
905 void layout_select_all(LayoutWindow *lw) 864 void layout_select_all(LayoutWindow *lw)
906 { 865 {
907 if (!layout_valid(&lw)) return; 866 if (!layout_valid(&lw)) return;
908 867
909 if (lw->vf) vf_select_all(lw->vf); 868 if (lw->vf) vf_select_all(lw->vf);
910 if (lw->vfi) vficon_select_all(lw->vfi);
911 } 869 }
912 870
913 void layout_select_none(LayoutWindow *lw) 871 void layout_select_none(LayoutWindow *lw)
914 { 872 {
915 if (!layout_valid(&lw)) return; 873 if (!layout_valid(&lw)) return;
916 874
917 if (lw->vf) vf_select_none(lw->vf); 875 if (lw->vf) vf_select_none(lw->vf);
918 if (lw->vfi) vficon_select_none(lw->vfi);
919 } 876 }
920 877
921 void layout_mark_to_selection(LayoutWindow *lw, gint mark, MarkToSelectionMode mode) 878 void layout_mark_to_selection(LayoutWindow *lw, gint mark, MarkToSelectionMode mode)
922 { 879 {
923 if (!layout_valid(&lw)) return; 880 if (!layout_valid(&lw)) return;
924 881
925 if (lw->vf) vf_mark_to_selection(lw->vf, mark, mode); 882 if (lw->vf) vf_mark_to_selection(lw->vf, mark, mode);
926 if (lw->vfi) vficon_mark_to_selection(lw->vfi, mark, mode);
927 } 883 }
928 884
929 void layout_selection_to_mark(LayoutWindow *lw, gint mark, SelectionToMarkMode mode) 885 void layout_selection_to_mark(LayoutWindow *lw, gint mark, SelectionToMarkMode mode)
930 { 886 {
931 if (!layout_valid(&lw)) return; 887 if (!layout_valid(&lw)) return;
932 888
933 if (lw->vf) vf_selection_to_mark(lw->vf, mark, mode); 889 if (lw->vf) vf_selection_to_mark(lw->vf, mark, mode);
934 if (lw->vfi) vficon_selection_to_mark(lw->vfi, mark, mode);
935 890
936 layout_status_update_info(lw, NULL); /* osd in fullscreen mode */ 891 layout_status_update_info(lw, NULL); /* osd in fullscreen mode */
937 } 892 }
938 893
939 /* 894 /*
956 911
957 if (lw->path_entry) gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->path); 912 if (lw->path_entry) gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->path);
958 if (lw->vd) vd_set_path(lw->vd, lw->path); 913 if (lw->vd) vd_set_path(lw->vd, lw->path);
959 914
960 if (lw->vf) vf_set_path(lw->vf, lw->path); 915 if (lw->vf) vf_set_path(lw->vf, lw->path);
961 if (lw->vfi) vficon_set_path(lw->vfi, lw->path);
962 } 916 }
963 917
964 gint layout_set_path(LayoutWindow *lw, const gchar *path) 918 gint layout_set_path(LayoutWindow *lw, const gchar *path)
965 { 919 {
966 gint have_file = FALSE; 920 gint have_file = FALSE;
1030 if (lw->path) lw->last_time = filetime(lw->path); 984 if (lw->path) lw->last_time = filetime(lw->path);
1031 985
1032 if (lw->vd) vd_refresh(lw->vd); 986 if (lw->vd) vd_refresh(lw->vd);
1033 987
1034 if (lw->vf) vf_refresh(lw->vf); 988 if (lw->vf) vf_refresh(lw->vf);
1035 if (lw->vfi) vficon_refresh(lw->vfi);
1036 } 989 }
1037 990
1038 static void layout_refresh_by_time(LayoutWindow *lw) 991 static void layout_refresh_by_time(LayoutWindow *lw)
1039 { 992 {
1040 layout_refresh_lists(lw); 993 layout_refresh_lists(lw);
1305 else 1258 else
1306 { 1259 {
1307 if (!GTK_WIDGET_VISIBLE(lw->tools)) 1260 if (!GTK_WIDGET_VISIBLE(lw->tools))
1308 { 1261 {
1309 gtk_widget_show(lw->tools); 1262 gtk_widget_show(lw->tools);
1310 if (lw->vfi) vficon_refresh(lw->vfi); 1263 if (lw->vf) vf_refresh(lw->vf);
1311 } 1264 }
1312 } 1265 }
1313 1266
1314 lw->tools_hidden = hide; 1267 lw->tools_hidden = hide;
1315 } 1268 }
1676 lw->dir_view = NULL; 1629 lw->dir_view = NULL;
1677 lw->vd = NULL; 1630 lw->vd = NULL;
1678 1631
1679 lw->file_view = NULL; 1632 lw->file_view = NULL;
1680 lw->vf = NULL; 1633 lw->vf = NULL;
1681 lw->vfi = NULL; 1634 lw->vf = NULL;
1682 1635
1683 lw->info_box = NULL; 1636 lw->info_box = NULL;
1684 lw->info_progress_bar = NULL; 1637 lw->info_progress_bar = NULL;
1685 lw->info_sort = NULL; 1638 lw->info_sort = NULL;
1686 lw->info_color = NULL; 1639 lw->info_color = NULL;
2059 gint update = FALSE; 2012 gint update = FALSE;
2060 2013
2061 if (lw->image) layout_image_maint_renamed(lw, fd); 2014 if (lw->image) layout_image_maint_renamed(lw, fd);
2062 2015
2063 if (lw->vf) update |= vf_maint_renamed(lw->vf, fd); 2016 if (lw->vf) update |= vf_maint_renamed(lw->vf, fd);
2064 if (lw->vfi) update |= vficon_maint_renamed(lw->vfi, fd);
2065 2017
2066 if (update) layout_real_time_update(lw); 2018 if (update) layout_real_time_update(lw);
2067 } 2019 }
2068 2020
2069 static void layout_real_removed(LayoutWindow *lw, FileData *fd, GList *ignore_list) 2021 static void layout_real_removed(LayoutWindow *lw, FileData *fd, GList *ignore_list)
2071 gint update = FALSE; 2023 gint update = FALSE;
2072 2024
2073 if (lw->image) layout_image_maint_removed(lw, fd); 2025 if (lw->image) layout_image_maint_removed(lw, fd);
2074 2026
2075 if (lw->vf) update |= vf_maint_removed(lw->vf, fd, ignore_list); 2027 if (lw->vf) update |= vf_maint_removed(lw->vf, fd, ignore_list);
2076 if (lw->vfi) update |= vficon_maint_removed(lw->vfi, fd, ignore_list);
2077 2028
2078 if (update) layout_real_time_update(lw); 2029 if (update) layout_real_time_update(lw);
2079 } 2030 }
2080 2031
2081 static void layout_real_moved(LayoutWindow *lw, FileData *fd, GList *ignore_list) 2032 static void layout_real_moved(LayoutWindow *lw, FileData *fd, GList *ignore_list)
2083 gint update = FALSE; 2034 gint update = FALSE;
2084 2035
2085 if (lw->image) layout_image_maint_moved(lw, fd); 2036 if (lw->image) layout_image_maint_moved(lw, fd);
2086 2037
2087 if (lw->vf) update |= vf_maint_moved(lw->vf, fd, ignore_list); 2038 if (lw->vf) update |= vf_maint_moved(lw->vf, fd, ignore_list);
2088 if (lw->vfi) update |= vficon_maint_moved(lw->vfi, fd, ignore_list);
2089 2039
2090 if (update) layout_real_time_update(lw); 2040 if (update) layout_real_time_update(lw);
2091 } 2041 }
2092 2042
2093 void layout_maint_renamed(FileData *fd) 2043 void layout_maint_renamed(FileData *fd)