Deduplicate FILE_COLUMN_POINTER
[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 #include <ctime>
25
26 #include <glib.h>
27 #include <gtk/gtk.h>
28
29 #include "typedefs.h"
30
31 struct FileData;
32 struct LayoutWindow;
33 struct ThumbLoader;
34
35 struct ViewFile
36 {
37         FileViewType type;      /**< @todo (xsdg): Turn this into a union (see VFLIST and VFICON). */
38
39         gpointer info;
40
41         GtkWidget *widget;
42         GtkWidget *listview;
43         GtkWidget *scrolled;
44         GtkWidget *filter;
45         GtkWidget *filter_check[FILEDATA_MARKS_SIZE];
46
47         struct {
48                 GtkWidget *combo;
49                 GtkWidget *frame;
50                 gint count;
51                 gint last_selected;
52                 gboolean case_sensitive;
53         } file_filter;
54
55         FileData *dir_fd;
56         GList *list;
57
58         SortType sort_method;
59         gboolean sort_ascend;
60         gboolean sort_case;
61
62         /* func list */
63         void (*func_thumb_status)(ViewFile *vf, gdouble val, const gchar *text, gpointer data);
64         gpointer data_thumb_status;
65
66         void (*func_status)(ViewFile *vf, gpointer data);
67         gpointer data_status;
68
69         LayoutWindow *layout;
70
71         GtkWidget *popup;
72
73         /* thumbs updates*/
74         gboolean thumbs_running;
75         ThumbLoader *thumbs_loader;
76         FileData *thumbs_filedata;
77
78         /* marks */
79         gboolean marks_enabled;
80         gint active_mark;
81         gint clicked_mark;
82
83         /* stars */
84         FileData *stars_filedata;
85         guint stars_id;
86
87         /* refresh */
88         guint refresh_idle_id; /**< event source id */
89         time_t time_refresh_set; /**< time when refresh_idle_id was set */
90
91         GList *editmenu_fd_list; /**< file list for edit menu */
92
93         guint read_metadata_in_idle_id;
94 };
95
96 struct ViewFileInfoList
97 {
98         FileData *click_fd;
99         FileData *select_fd;
100
101         gboolean thumbs_enabled;
102
103         guint select_idle_id; /**< event source id */
104 };
105
106 struct ViewFileInfoIcon
107 {
108         /* table stuff */
109         gint columns;
110         gint rows;
111
112         GList *selection;
113         FileData *prev_selection;
114
115         GtkWidget *tip_window;
116         guint tip_delay_id; /**< event source id */
117         FileData *tip_fd;
118
119         FileData *click_fd;
120
121         FileData *focus_fd;
122         gint focus_row;
123         gint focus_column;
124
125         gboolean show_text;
126 };
127
128 #define VFLIST(_vf_) ((ViewFileInfoList *)(_vf_->info))
129 #define VFICON(_vf_) ((ViewFileInfoIcon *)(_vf_->info))
130
131 const gint VIEW_FILE_COLUMN_POINTER = 0; // @todo Use inline constexpr in C++17
132
133 void vf_send_update(ViewFile *vf);
134
135 ViewFile *vf_new(FileViewType type, FileData *dir_fd);
136
137 void vf_set_status_func(ViewFile *vf, void (*func)(ViewFile *vf, gpointer data), gpointer data);
138 void vf_set_thumb_status_func(ViewFile *vf, void (*func)(ViewFile *vf, gdouble val, const gchar *text, gpointer data), gpointer data);
139
140 void vf_set_layout(ViewFile *vf, LayoutWindow *layout);
141
142 gboolean vf_set_fd(ViewFile *vf, FileData *fd);
143 gboolean vf_refresh(ViewFile *vf);
144 void vf_refresh_idle(ViewFile *vf);
145
146 void vf_thumb_set(ViewFile *vf, gboolean enable);
147 void vf_marks_set(ViewFile *vf, gboolean enable);
148 void vf_star_rating_set(ViewFile *vf, gboolean enable);
149 void vf_sort_set(ViewFile *vf, SortType type, gboolean ascend, gboolean case_sensitive);
150
151 guint vf_marks_get_filter(ViewFile *vf);
152 void vf_mark_filter_toggle(ViewFile *vf, gint mark);
153
154 guint vf_class_get_filter(ViewFile *vf);
155
156 GList *vf_selection_get_one(ViewFile *vf, FileData *fd);
157 GList *vf_pop_menu_file_list(ViewFile *vf);
158 GtkWidget *vf_pop_menu(ViewFile *vf);
159
160 FileData *vf_index_get_data(ViewFile *vf, gint row);
161 gint vf_index_by_fd(ViewFile *vf, FileData *in_fd);
162 guint vf_count(ViewFile *vf, gint64 *bytes);
163 GList *vf_get_list(ViewFile *vf);
164
165 guint vf_selection_count(ViewFile *vf, gint64 *bytes);
166 GList *vf_selection_get_list(ViewFile *vf);
167 GList *vf_selection_get_list_by_index(ViewFile *vf);
168
169 void vf_select_all(ViewFile *vf);
170 void vf_select_none(ViewFile *vf);
171 void vf_select_invert(ViewFile *vf);
172 void vf_select_by_fd(ViewFile *vf, FileData *fd);
173 void vf_select_list(ViewFile *vf, GList *list);
174
175 void vf_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode);
176 void vf_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode);
177
178 void vf_refresh_idle_cancel(ViewFile *vf);
179 void vf_notify_cb(FileData *fd, NotifyType type, gpointer data);
180
181 void vf_thumb_update(ViewFile *vf);
182 void vf_thumb_cleanup(ViewFile *vf);
183 void vf_thumb_stop(ViewFile *vf);
184 void vf_read_metadata_in_idle(ViewFile *vf);
185 void vf_file_filter_set(ViewFile *vf, gboolean enable);
186 GRegex *vf_file_filter_get_filter(ViewFile *vf);
187
188 void vf_star_update(ViewFile *vf);
189 gboolean vf_stars_cb(gpointer data);
190 void vf_star_stop(ViewFile *vf);
191 void vf_star_cleanup(ViewFile *vf);
192
193 #endif /* VIEW_FILE_H */
194 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */