eeea7da85e6d4e770ae6dda0fdc00561fbd93d01
[geeqie.git] / src / view-file.h
1 /*
2  * Copyright (C) 2008 - 2016 The Geeqie Team
3  *
4  * Author: Laurent Monin
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20
21 #ifndef VIEW_FILE_H
22 #define VIEW_FILE_H
23
24 struct FileData;
25 struct LayoutWindow;
26 struct ThumbLoader;
27
28 struct ViewFile
29 {
30         FileViewType type;      /**< @todo (xsdg): Turn this into a union (see VFLIST and VFICON). */
31
32         gpointer info;
33
34         GtkWidget *widget;
35         GtkWidget *listview;
36         GtkWidget *scrolled;
37         GtkWidget *filter;
38         GtkWidget *filter_check[FILEDATA_MARKS_SIZE];
39
40         struct {
41                 GtkWidget *combo;
42                 GtkWidget *frame;
43                 gint count;
44                 gint last_selected;
45                 gboolean case_sensitive;
46         } file_filter;
47
48         FileData *dir_fd;
49         GList *list;
50
51         SortType sort_method;
52         gboolean sort_ascend;
53         gboolean sort_case;
54
55         /* func list */
56         void (*func_thumb_status)(ViewFile *vf, gdouble val, const gchar *text, gpointer data);
57         gpointer data_thumb_status;
58
59         void (*func_status)(ViewFile *vf, gpointer data);
60         gpointer data_status;
61
62         LayoutWindow *layout;
63
64         GtkWidget *popup;
65
66         /* thumbs updates*/
67         gboolean thumbs_running;
68         ThumbLoader *thumbs_loader;
69         FileData *thumbs_filedata;
70
71         /* marks */
72         gboolean marks_enabled;
73         gint active_mark;
74         gint clicked_mark;
75
76         /* stars */
77         FileData *stars_filedata;
78         guint stars_id;
79
80         /* refresh */
81         guint refresh_idle_id; /**< event source id */
82         time_t time_refresh_set; /**< time when refresh_idle_id was set */
83
84         GList *editmenu_fd_list; /**< file list for edit menu */
85
86         guint read_metadata_in_idle_id;
87 };
88
89 struct ViewFileInfoList
90 {
91         FileData *click_fd;
92         FileData *select_fd;
93
94         gboolean thumbs_enabled;
95
96         guint select_idle_id; /**< event source id */
97 };
98
99 struct ViewFileInfoIcon
100 {
101         /* table stuff */
102         gint columns;
103         gint rows;
104
105         GList *selection;
106         FileData *prev_selection;
107
108         GtkWidget *tip_window;
109         guint tip_delay_id; /**< event source id */
110         FileData *tip_fd;
111
112         FileData *click_fd;
113
114         FileData *focus_fd;
115         gint focus_row;
116         gint focus_column;
117
118         gboolean show_text;
119 };
120
121 #define VFLIST(_vf_) ((ViewFileInfoList *)(_vf_->info))
122 #define VFICON(_vf_) ((ViewFileInfoIcon *)(_vf_->info))
123
124 void vf_send_update(ViewFile *vf);
125
126 ViewFile *vf_new(FileViewType type, FileData *dir_fd);
127
128 void vf_set_status_func(ViewFile *vf, void (*func)(ViewFile *vf, gpointer data), gpointer data);
129 void vf_set_thumb_status_func(ViewFile *vf, void (*func)(ViewFile *vf, gdouble val, const gchar *text, gpointer data), gpointer data);
130
131 void vf_set_layout(ViewFile *vf, LayoutWindow *layout);
132
133 gboolean vf_set_fd(ViewFile *vf, FileData *fd);
134 gboolean vf_refresh(ViewFile *vf);
135 void vf_refresh_idle(ViewFile *vf);
136
137 void vf_thumb_set(ViewFile *vf, gboolean enable);
138 void vf_marks_set(ViewFile *vf, gboolean enable);
139 void vf_star_rating_set(ViewFile *vf, gboolean enable);
140 void vf_sort_set(ViewFile *vf, SortType type, gboolean ascend, gboolean case_sensitive);
141
142 guint vf_marks_get_filter(ViewFile *vf);
143 void vf_mark_filter_toggle(ViewFile *vf, gint mark);
144
145 guint vf_class_get_filter(ViewFile *vf);
146
147 GList *vf_selection_get_one(ViewFile *vf, FileData *fd);
148 GList *vf_pop_menu_file_list(ViewFile *vf);
149 GtkWidget *vf_pop_menu(ViewFile *vf);
150
151 FileData *vf_index_get_data(ViewFile *vf, gint row);
152 gint vf_index_by_fd(ViewFile *vf, FileData *in_fd);
153 guint vf_count(ViewFile *vf, gint64 *bytes);
154 GList *vf_get_list(ViewFile *vf);
155
156 guint vf_selection_count(ViewFile *vf, gint64 *bytes);
157 GList *vf_selection_get_list(ViewFile *vf);
158 GList *vf_selection_get_list_by_index(ViewFile *vf);
159
160 void vf_select_all(ViewFile *vf);
161 void vf_select_none(ViewFile *vf);
162 void vf_select_invert(ViewFile *vf);
163 void vf_select_by_fd(ViewFile *vf, FileData *fd);
164 void vf_select_list(ViewFile *vf, GList *list);
165
166 void vf_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode);
167 void vf_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode);
168
169 void vf_refresh_idle_cancel(ViewFile *vf);
170 void vf_notify_cb(FileData *fd, NotifyType type, gpointer data);
171
172 void vf_thumb_update(ViewFile *vf);
173 void vf_thumb_cleanup(ViewFile *vf);
174 void vf_thumb_stop(ViewFile *vf);
175 void vf_read_metadata_in_idle(ViewFile *vf);
176 void vf_file_filter_set(ViewFile *vf, gboolean enable);
177 GRegex *vf_file_filter_get_filter(ViewFile *vf);
178
179 void vf_star_update(ViewFile *vf);
180 gboolean vf_stars_cb(gpointer data);
181 void vf_star_stop(ViewFile *vf);
182 void vf_star_cleanup(ViewFile *vf);
183
184 #endif /* VIEW_FILE_H */
185 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */