Mercurial > geeqie.yaz
annotate src/view_file_list.c @ 633:fe700864cb5a
Use vf_* functions where possible.
author | zas_ |
---|---|
date | Sun, 11 May 2008 21:11:54 +0000 |
parents | 6e9413e92be5 |
children | 92208e71673b |
rev | line source |
---|---|
9 | 1 /* |
196 | 2 * Geeqie |
9 | 3 * (C) 2004 John Ellis |
475 | 4 * Copyright (C) 2008 The Geeqie Team |
9 | 5 * |
6 * Author: John Ellis | |
7 * | |
8 * This software is released under the GNU General Public License (GNU GPL). | |
9 * Please read the included file COPYING for more information. | |
10 * This software comes with no warranty of any kind, use at your own risk! | |
11 */ | |
12 | |
281 | 13 #include "main.h" |
9 | 14 #include "view_file_list.h" |
15 | |
16 #include "cache_maint.h" | |
507 | 17 #include "debug.h" |
9 | 18 #include "dnd.h" |
19 #include "editors.h" | |
20 #include "img-view.h" | |
21 #include "info.h" | |
22 #include "layout.h" | |
23 #include "layout_image.h" | |
24 #include "menu.h" | |
25 #include "thumb.h" | |
26 #include "utilops.h" | |
27 #include "ui_bookmark.h" | |
28 #include "ui_fileops.h" | |
29 #include "ui_menu.h" | |
30 #include "ui_tree_edit.h" | |
633 | 31 #include "view_file.h" |
9 | 32 |
33 #include <gdk/gdkkeysyms.h> /* for keyboard values */ | |
34 | |
557
d8d61dc4ff52
Introduce ViewFileInfoList and ViewFileInfoIcon (not used yet).
zas_
parents:
555
diff
changeset
|
35 #define VFLIST_INFO_POINTER(_vf_) ((ViewFileInfoList *)(_vf_->info)) |
d8d61dc4ff52
Introduce ViewFileInfoList and ViewFileInfoIcon (not used yet).
zas_
parents:
555
diff
changeset
|
36 #define VFLIST_INFO(_vf_, _part_) (VFLIST_INFO_POINTER(_vf_)->_part_) |
9 | 37 |
38 enum { | |
39 FILE_COLUMN_POINTER = 0, | |
40 FILE_COLUMN_THUMB, | |
41 FILE_COLUMN_NAME, | |
139 | 42 FILE_COLUMN_SIDECARS, |
9 | 43 FILE_COLUMN_SIZE, |
44 FILE_COLUMN_DATE, | |
45 FILE_COLUMN_COLOR, | |
139 | 46 FILE_COLUMN_MARKS, |
47 FILE_COLUMN_MARKS_LAST = FILE_COLUMN_MARKS + FILEDATA_MARKS_SIZE - 1, | |
9 | 48 FILE_COLUMN_COUNT |
49 }; | |
50 | |
51 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
52 static gint vflist_row_is_selected(ViewFile *vf, FileData *fd); |
9 | 53 static gint vflist_row_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
54 static void vflist_populate_view(ViewFile *vf); |
9 | 55 |
56 | |
57 /* | |
58 *----------------------------------------------------------------------------- | |
59 * misc | |
60 *----------------------------------------------------------------------------- | |
61 */ | |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
62 typedef struct { |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
63 FileData *fd; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
64 GtkTreeIter *iter; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
65 gint found; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
66 gint row; |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
67 } ViewFileFindRowData; |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
68 |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
69 static gboolean vflist_find_row_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
70 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
71 ViewFileFindRowData *find = data; |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
72 FileData *fd; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
73 gtk_tree_model_get(model, iter, FILE_COLUMN_POINTER, &fd, -1); |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
74 if (fd == find->fd) |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
75 { |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
76 *find->iter = *iter; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
77 find->found = 1; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
78 return TRUE; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
79 } |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
80 find->row++; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
81 return FALSE; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
82 } |
9 | 83 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
84 static gint vflist_find_row(ViewFile *vf, FileData *fd, GtkTreeIter *iter) |
9 | 85 { |
86 GtkTreeModel *store; | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
87 ViewFileFindRowData data = {fd, iter, 0, 0}; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
88 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
89 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
90 gtk_tree_model_foreach(store, vflist_find_row_cb, &data); |
9 | 91 |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
92 if (data.found) |
9 | 93 { |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
94 return data.row; |
9 | 95 } |
96 | |
97 return -1; | |
98 } | |
99 | |
169 | 100 |
259 | 101 /* |
169 | 102 static gint vflist_find_sidecar_list_idx(GList *work, FileData *fd) |
103 { | |
104 gint i = 0; | |
105 while (work) | |
106 { | |
107 FileData *fd_p = work->data; | |
108 if (fd == fd_p) return i; | |
442 | 109 |
169 | 110 i++; |
111 | |
112 GList *work2 = fd_p->sidecar_files; | |
113 while (work2) | |
114 { | |
442 | 115 fd_p = work2->data; |
169 | 116 if (fd == fd_p) return i; |
442 | 117 |
169 | 118 i++; |
119 work2 = work2->next; | |
120 } | |
121 work = work->next; | |
122 } | |
123 return -1; | |
124 } | |
259 | 125 */ |
169 | 126 |
127 static gint vflist_sidecar_list_count(GList *work) | |
128 { | |
129 gint i = 0; | |
130 while (work) | |
131 { | |
132 FileData *fd = work->data; | |
133 i++; | |
134 | |
135 GList *work2 = fd->sidecar_files; | |
136 while (work2) | |
137 { | |
138 i++; | |
139 work2 = work2->next; | |
140 } | |
141 work = work->next; | |
142 } | |
143 return i; | |
144 } | |
145 | |
146 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
147 static void vflist_color_set(ViewFile *vf, FileData *fd, gint color_set) |
9 | 148 { |
149 GtkTreeModel *store; | |
150 GtkTreeIter iter; | |
151 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
152 if (vflist_find_row(vf, fd, &iter) < 0) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
153 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
154 gtk_tree_store_set(GTK_TREE_STORE(store), &iter, FILE_COLUMN_COLOR, color_set, -1); |
9 | 155 } |
156 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
157 static void vflist_move_cursor(ViewFile *vf, GtkTreeIter *iter) |
9 | 158 { |
159 GtkTreeModel *store; | |
160 GtkTreePath *tpath; | |
161 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
162 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 163 |
164 tpath = gtk_tree_model_get_path(store, iter); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
165 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vf->listview), tpath, NULL, FALSE); |
9 | 166 gtk_tree_path_free(tpath); |
167 } | |
168 | |
157 | 169 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
170 static gint vflist_column_idx(ViewFile *vf, gint store_idx) |
157 | 171 { |
172 GList *columns, *work; | |
173 gint i = 0; | |
174 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
175 columns = gtk_tree_view_get_columns(GTK_TREE_VIEW(vf->listview)); |
157 | 176 work = columns; |
177 while (work) | |
178 { | |
179 GtkTreeViewColumn *column = work->data; | |
180 if (store_idx == GPOINTER_TO_INT(g_object_get_data (G_OBJECT(column), "column_store_idx"))) | |
181 break; | |
182 work = work->next; | |
183 i++; | |
184 } | |
442 | 185 |
157 | 186 g_list_free(columns); |
187 return i; | |
188 } | |
189 | |
190 | |
9 | 191 /* |
192 *----------------------------------------------------------------------------- | |
193 * dnd | |
194 *----------------------------------------------------------------------------- | |
195 */ | |
196 | |
197 static void vflist_dnd_get(GtkWidget *widget, GdkDragContext *context, | |
198 GtkSelectionData *selection_data, guint info, | |
199 guint time, gpointer data) | |
200 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
201 ViewFile *vf = data; |
9 | 202 GList *list = NULL; |
203 gchar *uri_text = NULL; | |
204 gint total; | |
205 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
206 if (!VFLIST_INFO(vf, click_fd)) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
207 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
208 if (vflist_row_is_selected(vf, VFLIST_INFO(vf, click_fd))) |
9 | 209 { |
633 | 210 list = vf_selection_get_list(vf); |
9 | 211 } |
212 else | |
213 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
214 list = g_list_append(NULL, file_data_ref(VFLIST_INFO(vf, click_fd))); |
9 | 215 } |
216 | |
217 if (!list) return; | |
218 | |
138 | 219 uri_text = uri_text_from_filelist(list, &total, (info == TARGET_TEXT_PLAIN)); |
220 filelist_free(list); | |
9 | 221 |
495 | 222 DEBUG_1(uri_text); |
9 | 223 |
64
04ff0df3ad2f
Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
224 gtk_selection_data_set(selection_data, selection_data->target, |
04ff0df3ad2f
Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
225 8, (guchar *)uri_text, total); |
9 | 226 g_free(uri_text); |
227 } | |
228 | |
229 static void vflist_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
230 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
231 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
232 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
233 vflist_color_set(vf, VFLIST_INFO(vf, click_fd), TRUE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
234 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
235 if (VFLIST_INFO(vf, thumbs_enabled) && |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
236 VFLIST_INFO(vf, click_fd) && VFLIST_INFO(vf, click_fd)->pixbuf) |
9 | 237 { |
238 gint items; | |
239 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
240 if (vflist_row_is_selected(vf, VFLIST_INFO(vf, click_fd))) |
633 | 241 items = vf_selection_count(vf, NULL); |
9 | 242 else |
243 items = 1; | |
244 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
245 dnd_set_drag_icon(widget, context, VFLIST_INFO(vf, click_fd)->pixbuf, items); |
9 | 246 } |
247 } | |
248 | |
249 static void vflist_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
250 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
251 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
252 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
253 vflist_color_set(vf, VFLIST_INFO(vf, click_fd), FALSE); |
9 | 254 |
255 if (context->action == GDK_ACTION_MOVE) | |
256 { | |
633 | 257 vf_refresh(vf); |
9 | 258 } |
259 } | |
260 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
261 void vflist_dnd_init(ViewFile *vf) |
9 | 262 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
263 gtk_drag_source_set(vf->listview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, |
9 | 264 dnd_file_drag_types, dnd_file_drag_types_count, |
265 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
266 g_signal_connect(G_OBJECT(vf->listview), "drag_data_get", |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
267 G_CALLBACK(vflist_dnd_get), vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
268 g_signal_connect(G_OBJECT(vf->listview), "drag_begin", |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
269 G_CALLBACK(vflist_dnd_begin), vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
270 g_signal_connect(G_OBJECT(vf->listview), "drag_end", |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
271 G_CALLBACK(vflist_dnd_end), vf); |
9 | 272 } |
273 | |
274 /* | |
275 *----------------------------------------------------------------------------- | |
276 * pop-up menu | |
277 *----------------------------------------------------------------------------- | |
278 */ | |
279 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
280 static GList *vflist_pop_menu_file_list(ViewFile *vf) |
9 | 281 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
282 if (!VFLIST_INFO(vf, click_fd)) return NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
283 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
284 if (vflist_row_is_selected(vf, VFLIST_INFO(vf, click_fd))) |
9 | 285 { |
633 | 286 return vf_selection_get_list(vf); |
9 | 287 } |
288 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
289 return g_list_append(NULL, file_data_ref(VFLIST_INFO(vf, click_fd))); |
9 | 290 } |
291 | |
292 static void vflist_pop_menu_edit_cb(GtkWidget *widget, gpointer data) | |
293 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
294 ViewFile *vf; |
9 | 295 gint n; |
296 GList *list; | |
297 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
298 vf = submenu_item_get_data(widget); |
9 | 299 n = GPOINTER_TO_INT(data); |
300 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
301 if (!vf) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
302 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
303 list = vflist_pop_menu_file_list(vf); |
138 | 304 start_editor_from_filelist(n, list); |
305 filelist_free(list); | |
9 | 306 } |
307 | |
308 static void vflist_pop_menu_info_cb(GtkWidget *widget, gpointer data) | |
309 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
310 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
311 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
312 info_window_new(NULL, vflist_pop_menu_file_list(vf), NULL); |
9 | 313 } |
314 | |
315 static void vflist_pop_menu_view_cb(GtkWidget *widget, gpointer data) | |
316 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
317 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
318 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
319 if (vflist_row_is_selected(vf, VFLIST_INFO(vf, click_fd))) |
9 | 320 { |
321 GList *list; | |
322 | |
633 | 323 list = vf_selection_get_list(vf); |
9 | 324 view_window_new_from_list(list); |
138 | 325 filelist_free(list); |
9 | 326 } |
327 else | |
328 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
329 view_window_new(VFLIST_INFO(vf, click_fd)); |
9 | 330 } |
331 } | |
332 | |
333 static void vflist_pop_menu_copy_cb(GtkWidget *widget, gpointer data) | |
334 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
335 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
336 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
337 file_util_copy(NULL, vflist_pop_menu_file_list(vf), NULL, vf->listview); |
9 | 338 } |
339 | |
497 | 340 static void vflist_pop_menu_copy_path_cb(GtkWidget *widget, gpointer data) |
341 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
342 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
343 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
344 file_util_copy_path_list_to_clipboard(vflist_pop_menu_file_list(vf)); |
497 | 345 } |
346 | |
9 | 347 static void vflist_pop_menu_move_cb(GtkWidget *widget, gpointer data) |
348 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
349 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
350 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
351 file_util_move(NULL, vflist_pop_menu_file_list(vf), NULL, vf->listview); |
9 | 352 } |
353 | |
354 static void vflist_pop_menu_rename_cb(GtkWidget *widget, gpointer data) | |
355 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
356 ViewFile *vf = data; |
9 | 357 GList *list; |
358 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
359 list = vflist_pop_menu_file_list(vf); |
341
15c6b94545a2
Move safe_delete* and in place rename options to file_ops
zas_
parents:
334
diff
changeset
|
360 if (options->file_ops.enable_in_place_rename && |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
361 list && !list->next && VFLIST_INFO(vf, click_fd)) |
9 | 362 { |
363 GtkTreeModel *store; | |
364 GtkTreeIter iter; | |
365 | |
138 | 366 filelist_free(list); |
9 | 367 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
368 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
369 if (vflist_find_row(vf, VFLIST_INFO(vf, click_fd), &iter) >= 0) |
9 | 370 { |
371 GtkTreePath *tpath; | |
372 | |
373 tpath = gtk_tree_model_get_path(store, &iter); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
374 tree_edit_by_path(GTK_TREE_VIEW(vf->listview), tpath, |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
375 vflist_column_idx(vf, FILE_COLUMN_NAME), VFLIST_INFO(vf, click_fd)->name, |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
376 vflist_row_rename_cb, vf); |
9 | 377 gtk_tree_path_free(tpath); |
378 } | |
379 return; | |
380 } | |
381 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
382 file_util_rename(NULL, list, vf->listview); |
9 | 383 } |
384 | |
385 static void vflist_pop_menu_delete_cb(GtkWidget *widget, gpointer data) | |
386 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
387 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
388 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
389 file_util_delete(NULL, vflist_pop_menu_file_list(vf), vf->listview); |
9 | 390 } |
391 | |
392 static void vflist_pop_menu_sort_cb(GtkWidget *widget, gpointer data) | |
393 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
394 ViewFile *vf; |
9 | 395 SortType type; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
111
diff
changeset
|
396 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
111
diff
changeset
|
397 if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return; |
442 | 398 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
399 vf = submenu_item_get_data(widget); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
400 if (!vf) return; |
9 | 401 |
402 type = (SortType)GPOINTER_TO_INT(data); | |
403 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
404 if (vf->layout) |
9 | 405 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
406 layout_sort_set(vf->layout, type, vf->sort_ascend); |
9 | 407 } |
408 else | |
409 { | |
633 | 410 vf_sort_set(vf, type, vf->sort_ascend); |
9 | 411 } |
412 } | |
413 | |
414 static void vflist_pop_menu_sort_ascend_cb(GtkWidget *widget, gpointer data) | |
415 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
416 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
417 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
418 if (vf->layout) |
9 | 419 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
420 layout_sort_set(vf->layout, vf->sort_method, !vf->sort_ascend); |
9 | 421 } |
422 else | |
423 { | |
633 | 424 vf_sort_set(vf, vf->sort_method, !vf->sort_ascend); |
9 | 425 } |
426 } | |
427 | |
428 static void vflist_pop_menu_icons_cb(GtkWidget *widget, gpointer data) | |
429 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
430 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
431 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
432 if (vf->layout) layout_views_set(vf->layout, vf->layout->dir_view_type, TRUE); |
9 | 433 } |
434 | |
435 static void vflist_pop_menu_thumbs_cb(GtkWidget *widget, gpointer data) | |
436 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
437 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
438 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
439 vflist_color_set(vf, VFLIST_INFO(vf, click_fd), FALSE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
440 if (vf->layout) |
9 | 441 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
442 layout_thumb_set(vf->layout, !VFLIST_INFO(vf, thumbs_enabled)); |
9 | 443 } |
444 else | |
445 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
446 vflist_thumb_set(vf, !VFLIST_INFO(vf, thumbs_enabled)); |
9 | 447 } |
448 } | |
449 | |
450 static void vflist_pop_menu_refresh_cb(GtkWidget *widget, gpointer data) | |
451 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
452 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
453 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
454 vflist_color_set(vf, VFLIST_INFO(vf, click_fd), FALSE); |
633 | 455 vf_refresh(vf); |
9 | 456 } |
457 | |
150 | 458 static void vflist_pop_menu_sel_mark_cb(GtkWidget *widget, gpointer data) |
459 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
460 ViewFile *vf = data; |
633 | 461 vf_mark_to_selection(vf, vf->active_mark, MTS_MODE_SET); |
161 | 462 } |
463 | |
464 static void vflist_pop_menu_sel_mark_and_cb(GtkWidget *widget, gpointer data) | |
465 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
466 ViewFile *vf = data; |
633 | 467 vf_mark_to_selection(vf, vf->active_mark, MTS_MODE_AND); |
161 | 468 } |
469 | |
470 static void vflist_pop_menu_sel_mark_or_cb(GtkWidget *widget, gpointer data) | |
471 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
472 ViewFile *vf = data; |
633 | 473 vf_mark_to_selection(vf, vf->active_mark, MTS_MODE_OR); |
161 | 474 } |
475 | |
476 static void vflist_pop_menu_sel_mark_minus_cb(GtkWidget *widget, gpointer data) | |
477 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
478 ViewFile *vf = data; |
633 | 479 vf_mark_to_selection(vf, vf->active_mark, MTS_MODE_MINUS); |
150 | 480 } |
481 | |
482 static void vflist_pop_menu_set_mark_sel_cb(GtkWidget *widget, gpointer data) | |
483 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
484 ViewFile *vf = data; |
633 | 485 vf_selection_to_mark(vf, vf->active_mark, STM_MODE_SET); |
150 | 486 } |
487 | |
488 static void vflist_pop_menu_res_mark_sel_cb(GtkWidget *widget, gpointer data) | |
489 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
490 ViewFile *vf = data; |
633 | 491 vf_selection_to_mark(vf, vf->active_mark, STM_MODE_RESET); |
150 | 492 } |
493 | |
494 static void vflist_pop_menu_toggle_mark_sel_cb(GtkWidget *widget, gpointer data) | |
495 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
496 ViewFile *vf = data; |
633 | 497 vf_selection_to_mark(vf, vf->active_mark, STM_MODE_TOGGLE); |
150 | 498 } |
499 | |
500 | |
9 | 501 static void vflist_popup_destroy_cb(GtkWidget *widget, gpointer data) |
502 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
503 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
504 vflist_color_set(vf, VFLIST_INFO(vf, click_fd), FALSE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
505 VFLIST_INFO(vf, click_fd) = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
506 vf->popup = NULL; |
9 | 507 } |
508 | |
150 | 509 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
510 static GtkWidget *vflist_pop_menu(ViewFile *vf, FileData *fd, gint col_idx) |
9 | 511 { |
512 GtkWidget *menu; | |
513 GtkWidget *item; | |
514 GtkWidget *submenu; | |
515 gint active; | |
516 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
517 vflist_color_set(vf, fd, TRUE); |
9 | 518 active = (fd != NULL); |
519 | |
520 menu = popup_menu_short_lived(); | |
521 g_signal_connect(G_OBJECT(menu), "destroy", | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
522 G_CALLBACK(vflist_popup_destroy_cb), vf); |
9 | 523 |
150 | 524 if (col_idx >= FILE_COLUMN_MARKS && col_idx <= FILE_COLUMN_MARKS_LAST) |
525 { | |
526 gint mark = col_idx - FILE_COLUMN_MARKS; | |
527 gchar *str_set_mark = g_strdup_printf(_("_Set mark %d"), mark + 1); | |
528 gchar *str_res_mark = g_strdup_printf(_("_Reset mark %d"), mark + 1); | |
529 gchar *str_toggle_mark = g_strdup_printf(_("_Toggle mark %d"), mark + 1); | |
530 gchar *str_sel_mark = g_strdup_printf(_("_Select mark %d"), mark + 1); | |
161 | 531 gchar *str_sel_mark_or = g_strdup_printf(_("_Add mark %d"), mark + 1); |
532 gchar *str_sel_mark_and = g_strdup_printf(_("_Intersection with mark %d"), mark + 1); | |
533 gchar *str_sel_mark_minus = g_strdup_printf(_("_Unselect mark %d"), mark + 1); | |
442 | 534 |
535 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
536 vf->active_mark = mark; |
150 | 537 menu_item_add_sensitive(menu, str_set_mark, active, |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
538 G_CALLBACK(vflist_pop_menu_set_mark_sel_cb), vf); |
442 | 539 |
150 | 540 menu_item_add_sensitive(menu, str_res_mark, active, |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
541 G_CALLBACK(vflist_pop_menu_res_mark_sel_cb), vf); |
442 | 542 |
150 | 543 menu_item_add_sensitive(menu, str_toggle_mark, active, |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
544 G_CALLBACK(vflist_pop_menu_toggle_mark_sel_cb), vf); |
161 | 545 |
546 menu_item_add_divider(menu); | |
442 | 547 |
150 | 548 menu_item_add_sensitive(menu, str_sel_mark, active, |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
549 G_CALLBACK(vflist_pop_menu_sel_mark_cb), vf); |
161 | 550 menu_item_add_sensitive(menu, str_sel_mark_or, active, |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
551 G_CALLBACK(vflist_pop_menu_sel_mark_or_cb), vf); |
161 | 552 menu_item_add_sensitive(menu, str_sel_mark_and, active, |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
553 G_CALLBACK(vflist_pop_menu_sel_mark_and_cb), vf); |
161 | 554 menu_item_add_sensitive(menu, str_sel_mark_minus, active, |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
555 G_CALLBACK(vflist_pop_menu_sel_mark_minus_cb), vf); |
442 | 556 |
150 | 557 menu_item_add_divider(menu); |
442 | 558 |
150 | 559 g_free(str_set_mark); |
560 g_free(str_res_mark); | |
561 g_free(str_toggle_mark); | |
562 g_free(str_sel_mark); | |
161 | 563 g_free(str_sel_mark_and); |
564 g_free(str_sel_mark_or); | |
565 g_free(str_sel_mark_minus); | |
150 | 566 } |
567 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
568 submenu_add_edit(menu, &item, G_CALLBACK(vflist_pop_menu_edit_cb), vf); |
9 | 569 gtk_widget_set_sensitive(item, active); |
570 | |
571 menu_item_add_stock_sensitive(menu, _("_Properties"), GTK_STOCK_PROPERTIES, active, | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
572 G_CALLBACK(vflist_pop_menu_info_cb), vf); |
9 | 573 menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, active, |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
574 G_CALLBACK(vflist_pop_menu_view_cb), vf); |
9 | 575 |
576 menu_item_add_divider(menu); | |
577 menu_item_add_stock_sensitive(menu, _("_Copy..."), GTK_STOCK_COPY, active, | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
578 G_CALLBACK(vflist_pop_menu_copy_cb), vf); |
9 | 579 menu_item_add_sensitive(menu, _("_Move..."), active, |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
580 G_CALLBACK(vflist_pop_menu_move_cb), vf); |
9 | 581 menu_item_add_sensitive(menu, _("_Rename..."), active, |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
582 G_CALLBACK(vflist_pop_menu_rename_cb), vf); |
9 | 583 menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, active, |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
584 G_CALLBACK(vflist_pop_menu_delete_cb), vf); |
497 | 585 if (options->show_copy_path) |
586 menu_item_add_sensitive(menu, _("_Copy path"), active, | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
587 G_CALLBACK(vflist_pop_menu_copy_path_cb), vf); |
9 | 588 |
589 menu_item_add_divider(menu); | |
590 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
591 submenu = submenu_add_sort(NULL, G_CALLBACK(vflist_pop_menu_sort_cb), vf, |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
592 FALSE, FALSE, TRUE, vf->sort_method); |
9 | 593 menu_item_add_divider(submenu); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
594 menu_item_add_check(submenu, _("Ascending"), vf->sort_ascend, |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
595 G_CALLBACK(vflist_pop_menu_sort_ascend_cb), vf); |
9 | 596 |
597 item = menu_item_add(menu, _("_Sort"), NULL, NULL); | |
598 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); | |
599 | |
600 menu_item_add_check(menu, _("View as _icons"), FALSE, | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
601 G_CALLBACK(vflist_pop_menu_icons_cb), vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
602 menu_item_add_check(menu, _("Show _thumbnails"), VFLIST_INFO(vf, thumbs_enabled), |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
603 G_CALLBACK(vflist_pop_menu_thumbs_cb), vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
604 menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH, G_CALLBACK(vflist_pop_menu_refresh_cb), vf); |
9 | 605 |
606 return menu; | |
607 } | |
608 | |
609 /* | |
610 *----------------------------------------------------------------------------- | |
611 * callbacks | |
612 *----------------------------------------------------------------------------- | |
613 */ | |
614 | |
615 static gint vflist_row_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data) | |
616 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
617 ViewFile *vf = data; |
9 | 618 gchar *old_path; |
619 gchar *new_path; | |
620 | |
621 if (strlen(new) == 0) return FALSE; | |
622 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
623 old_path = concat_dir_and_file(vf->path, old); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
624 new_path = concat_dir_and_file(vf->path, new); |
9 | 625 |
626 if (strchr(new, '/') != NULL) | |
627 { | |
628 gchar *text = g_strdup_printf(_("Invalid file name:\n%s"), new); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
629 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, vf->listview); |
9 | 630 g_free(text); |
631 } | |
632 else if (isfile(new_path)) | |
633 { | |
634 gchar *text = g_strdup_printf(_("A file with name %s already exists."), new); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
635 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, vf->listview); |
9 | 636 g_free(text); |
637 } | |
442 | 638 else |
9 | 639 { |
633 | 640 gint row = vf_index_by_path(vf, old_path); |
442 | 641 if (row >= 0) |
138 | 642 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
643 GList *work = g_list_nth(vf->list, row); |
138 | 644 FileData *fd = work->data; |
442 | 645 |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
142
diff
changeset
|
646 if (!file_data_add_change_info(fd, FILEDATA_CHANGE_RENAME, old_path, new_path) || !rename_file_ext(fd)) |
138 | 647 { |
648 gchar *text = g_strdup_printf(_("Unable to rename file:\n%s\nto:\n%s"), old, new); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
649 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, vf->listview); |
138 | 650 g_free(text); |
651 } | |
652 } | |
653 | |
9 | 654 } |
655 g_free(old_path); | |
656 g_free(new_path); | |
657 | |
658 return FALSE; | |
659 } | |
660 | |
661 static void vflist_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) | |
662 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
663 ViewFile *vf = data; |
9 | 664 GtkTreeModel *store; |
665 GtkTreeIter iter; | |
666 GtkTreePath *tpath; | |
667 gint cw, ch; | |
668 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
669 if (vflist_find_row(vf, VFLIST_INFO(vf, click_fd), &iter) < 0) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
670 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 671 tpath = gtk_tree_model_get_path(store, &iter); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
672 tree_view_get_cell_clamped(GTK_TREE_VIEW(vf->listview), tpath, FILE_COLUMN_NAME - 1, TRUE, x, y, &cw, &ch); |
9 | 673 gtk_tree_path_free(tpath); |
674 *y += ch; | |
675 popup_menu_position_clamp(menu, x, y, 0); | |
676 } | |
677 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
678 gint vflist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
9 | 679 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
680 ViewFile *vf = data; |
9 | 681 GtkTreePath *tpath; |
682 | |
683 if (event->keyval != GDK_Menu) return FALSE; | |
684 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
685 gtk_tree_view_get_cursor(GTK_TREE_VIEW(vf->listview), &tpath, NULL); |
9 | 686 if (tpath) |
687 { | |
688 GtkTreeModel *store; | |
689 GtkTreeIter iter; | |
690 | |
691 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); | |
692 gtk_tree_model_get_iter(store, &iter, tpath); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
693 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &VFLIST_INFO(vf, click_fd), -1); |
9 | 694 gtk_tree_path_free(tpath); |
695 } | |
696 else | |
697 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
698 VFLIST_INFO(vf, click_fd) = NULL; |
9 | 699 } |
700 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
701 vf->popup = vflist_pop_menu(vf, VFLIST_INFO(vf, click_fd), 0); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
702 gtk_menu_popup(GTK_MENU(vf->popup), NULL, NULL, vflist_menu_position_cb, vf, 0, GDK_CURRENT_TIME); |
9 | 703 |
704 return TRUE; | |
705 } | |
706 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
707 gint vflist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
9 | 708 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
709 ViewFile *vf = data; |
9 | 710 GtkTreePath *tpath; |
711 GtkTreeIter iter; | |
712 FileData *fd = NULL; | |
149 | 713 GtkTreeViewColumn *column; |
150 | 714 gint col_idx = 0; |
442 | 715 |
9 | 716 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, |
132 | 717 &tpath, &column, NULL, NULL)) |
9 | 718 { |
719 GtkTreeModel *store; | |
513
985fdfebd89e
Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents:
512
diff
changeset
|
720 col_idx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), "column_store_idx")); |
442 | 721 |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
722 if (bevent->button == MOUSE_BUTTON_LEFT && |
149 | 723 col_idx >= FILE_COLUMN_MARKS && col_idx <= FILE_COLUMN_MARKS_LAST) |
724 return FALSE; | |
442 | 725 |
149 | 726 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); |
9 | 727 |
728 gtk_tree_model_get_iter(store, &iter, tpath); | |
729 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
730 #if 0 | |
731 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE); | |
732 #endif | |
733 gtk_tree_path_free(tpath); | |
734 } | |
735 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
736 VFLIST_INFO(vf, click_fd) = fd; |
9 | 737 |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
738 if (bevent->button == MOUSE_BUTTON_RIGHT) |
9 | 739 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
740 vf->popup = vflist_pop_menu(vf, VFLIST_INFO(vf, click_fd), col_idx); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
741 gtk_menu_popup(GTK_MENU(vf->popup), NULL, NULL, NULL, NULL, |
9 | 742 bevent->button, bevent->time); |
743 return TRUE; | |
744 } | |
745 | |
746 if (!fd) return FALSE; | |
747 | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
748 if (bevent->button == MOUSE_BUTTON_MIDDLE) |
9 | 749 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
750 if (!vflist_row_is_selected(vf, fd)) |
9 | 751 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
752 vflist_color_set(vf, fd, TRUE); |
9 | 753 } |
754 return TRUE; | |
755 } | |
756 | |
757 | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
758 if (bevent->button == MOUSE_BUTTON_LEFT && bevent->type == GDK_BUTTON_PRESS && |
9 | 759 !(bevent->state & GDK_SHIFT_MASK ) && |
760 !(bevent->state & GDK_CONTROL_MASK ) && | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
761 vflist_row_is_selected(vf, fd)) |
9 | 762 { |
526 | 763 GtkTreeSelection *selection; |
764 | |
9 | 765 gtk_widget_grab_focus(widget); |
526 | 766 |
767 | |
768 /* returning FALSE and further processing of the event is needed for | |
769 correct operation of the expander, to show the sidecar files. | |
770 It however resets the selection of multiple files. With this condition | |
771 it should work for both cases */ | |
772 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); | |
773 return (gtk_tree_selection_count_selected_rows(selection) > 1); | |
9 | 774 } |
775 | |
776 #if 0 | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
777 if (bevent->button == MOUSE_BUTTON_LEFT && bevent->type == GDK_2BUTTON_PRESS) |
9 | 778 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
779 if (vf->layout) layout_image_full_screen_start(vf->layout); |
9 | 780 } |
781 #endif | |
782 | |
783 return FALSE; | |
784 } | |
785 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
786 gint vflist_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
9 | 787 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
788 ViewFile *vf = data; |
9 | 789 GtkTreePath *tpath; |
790 GtkTreeIter iter; | |
791 FileData *fd = NULL; | |
792 | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
793 if (bevent->button == MOUSE_BUTTON_MIDDLE) |
9 | 794 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
795 vflist_color_set(vf, VFLIST_INFO(vf, click_fd), FALSE); |
9 | 796 } |
797 | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
798 if (bevent->button != MOUSE_BUTTON_LEFT && bevent->button != MOUSE_BUTTON_MIDDLE) |
9 | 799 { |
800 return TRUE; | |
801 } | |
802 | |
803 if ((bevent->x != 0 || bevent->y != 0) && | |
804 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, | |
805 &tpath, NULL, NULL, NULL)) | |
806 { | |
807 GtkTreeModel *store; | |
808 | |
809 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); | |
810 gtk_tree_model_get_iter(store, &iter, tpath); | |
811 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
812 gtk_tree_path_free(tpath); | |
813 } | |
814 | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
815 if (bevent->button == MOUSE_BUTTON_MIDDLE) |
9 | 816 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
817 if (fd && VFLIST_INFO(vf, click_fd) == fd) |
9 | 818 { |
819 GtkTreeSelection *selection; | |
820 | |
821 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
822 if (vflist_row_is_selected(vf, fd)) |
9 | 823 { |
824 gtk_tree_selection_unselect_iter(selection, &iter); | |
825 } | |
826 else | |
827 { | |
828 gtk_tree_selection_select_iter(selection, &iter); | |
829 } | |
830 } | |
831 return TRUE; | |
832 } | |
833 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
834 if (fd && VFLIST_INFO(vf, click_fd) == fd && |
9 | 835 !(bevent->state & GDK_SHIFT_MASK ) && |
836 !(bevent->state & GDK_CONTROL_MASK ) && | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
837 vflist_row_is_selected(vf, fd)) |
9 | 838 { |
839 GtkTreeSelection *selection; | |
840 | |
841 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); | |
842 gtk_tree_selection_unselect_all(selection); | |
843 gtk_tree_selection_select_iter(selection, &iter); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
844 vflist_move_cursor(vf, &iter); |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
845 // return TRUE;// FIXME - expand |
9 | 846 } |
847 | |
848 return FALSE; | |
849 } | |
850 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
851 static void vflist_select_image(ViewFile *vf, FileData *sel_fd) |
9 | 852 { |
138 | 853 FileData *read_ahead_fd = NULL; |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
854 gint row; |
144 | 855 FileData *cur_fd; |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
856 if (!sel_fd) return; |
442 | 857 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
858 cur_fd = layout_image_get_fd(vf->layout); |
144 | 859 if (sel_fd == cur_fd) return; /* no change */ |
442 | 860 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
861 row = g_list_index(vf->list, sel_fd); |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
862 // FIXME sidecar data |
9 | 863 |
334 | 864 if (sel_fd && options->image.enable_read_ahead && row >= 0) |
9 | 865 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
866 if (row > g_list_index(vf->list, cur_fd) && |
633 | 867 row + 1 < vf_count(vf, NULL)) |
9 | 868 { |
633 | 869 read_ahead_fd = vf_index_get_data(vf, row + 1); |
9 | 870 } |
871 else if (row > 0) | |
872 { | |
633 | 873 read_ahead_fd = vf_index_get_data(vf, row - 1); |
9 | 874 } |
875 } | |
876 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
877 layout_image_set_with_ahead(vf->layout, sel_fd, read_ahead_fd); |
9 | 878 } |
879 | |
880 static gint vflist_select_idle_cb(gpointer data) | |
881 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
882 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
883 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
884 if (!vf->layout) |
9 | 885 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
886 VFLIST_INFO(vf, select_idle_id) = -1; |
9 | 887 return FALSE; |
888 } | |
889 | |
633 | 890 vf_send_update(vf); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
891 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
892 if (VFLIST_INFO(vf, select_fd)) |
9 | 893 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
894 vflist_select_image(vf, VFLIST_INFO(vf, select_fd)); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
895 VFLIST_INFO(vf, select_fd) = NULL; |
9 | 896 } |
897 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
898 VFLIST_INFO(vf, select_idle_id) = -1; |
9 | 899 return FALSE; |
900 } | |
901 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
902 static void vflist_select_idle_cancel(ViewFile *vf) |
9 | 903 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
904 if (VFLIST_INFO(vf, select_idle_id) != -1) g_source_remove(VFLIST_INFO(vf, select_idle_id)); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
905 VFLIST_INFO(vf, select_idle_id) = -1; |
9 | 906 } |
907 | |
908 static gboolean vflist_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath, | |
909 gboolean path_currently_selected, gpointer data) | |
910 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
911 ViewFile *vf = data; |
9 | 912 GtkTreeIter iter; |
913 | |
914 if (!path_currently_selected && | |
915 gtk_tree_model_get_iter(store, &iter, tpath)) | |
916 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
917 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &VFLIST_INFO(vf, select_fd), -1); |
9 | 918 } |
919 else | |
920 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
921 VFLIST_INFO(vf, select_fd) = NULL; |
9 | 922 } |
923 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
924 if (vf->layout && |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
925 VFLIST_INFO(vf, select_idle_id) == -1) |
9 | 926 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
927 VFLIST_INFO(vf, select_idle_id) = g_idle_add(vflist_select_idle_cb, vf); |
9 | 928 } |
929 | |
930 return TRUE; | |
931 } | |
932 | |
933 /* | |
934 *----------------------------------------------------------------------------- | |
935 * misc | |
936 *----------------------------------------------------------------------------- | |
937 */ | |
938 | |
259 | 939 /* |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
940 static gboolean vflist_dummy_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath, |
442 | 941 gboolean path_currently_selected, gpointer data) |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
942 { |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
943 return TRUE; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
944 } |
259 | 945 */ |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
946 |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
947 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
948 static void vflist_setup_iter(ViewFile *vf, GtkTreeStore *store, GtkTreeIter *iter, FileData *fd) |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
949 { |
167 | 950 int i; |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
951 gchar *size; |
167 | 952 gchar *sidecars = NULL; |
953 | |
954 if (fd->sidecar_files) | |
596 | 955 sidecars = file_data_sc_list_to_string(fd); |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
956 size = text_from_size(fd->size); |
442 | 957 |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
958 gtk_tree_store_set(store, iter, FILE_COLUMN_POINTER, fd, |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
959 FILE_COLUMN_THUMB, (VFLIST_INFO(vf, thumbs_enabled)) ? fd->pixbuf : NULL, |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
960 FILE_COLUMN_NAME, fd->name, |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
961 FILE_COLUMN_SIDECARS, sidecars, |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
962 FILE_COLUMN_SIZE, size, |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
963 FILE_COLUMN_DATE, text_from_time(fd->date), |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
964 FILE_COLUMN_COLOR, FALSE, -1); |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
965 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
966 gtk_tree_store_set(store, iter, FILE_COLUMN_MARKS + i, fd->marks[i], -1); |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
967 |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
968 g_free(size); |
167 | 969 if (sidecars) |
970 g_free(sidecars); | |
971 } | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
972 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
973 static void vflist_setup_iter_with_sidecars(ViewFile *vf, GtkTreeStore *store, GtkTreeIter *iter, FileData *fd) |
167 | 974 { |
975 GList *work; | |
976 GtkTreeIter s_iter; | |
977 gint valid; | |
978 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
979 vflist_setup_iter(vf, store, iter, fd); |
167 | 980 |
981 | |
442 | 982 /* this is almost the same code as in vflist_populate_view |
167 | 983 maybe it should be made more generic and used in both places */ |
442 | 984 |
985 | |
167 | 986 valid = gtk_tree_model_iter_children(GTK_TREE_MODEL(store), &s_iter, iter); |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
987 |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
988 work = fd->sidecar_files; |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
989 while (work) |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
990 { |
167 | 991 gint match; |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
992 FileData *sfd = work->data; |
167 | 993 gint done = FALSE; |
994 | |
995 while (!done) | |
996 { | |
997 FileData *old_sfd = NULL; | |
442 | 998 |
167 | 999 if (valid) |
1000 { | |
1001 gtk_tree_model_get(GTK_TREE_MODEL(store), &s_iter, FILE_COLUMN_POINTER, &old_sfd, -1); | |
442 | 1002 |
167 | 1003 if (sfd == old_sfd) |
1004 { | |
1005 match = 0; | |
1006 } | |
1007 else | |
1008 { | |
1009 match = filelist_sort_compare_filedata_full(sfd, old_sfd, SORT_NAME, TRUE); | |
1010 } | |
1011 } | |
442 | 1012 |
167 | 1013 else |
1014 { | |
1015 match = -1; | |
1016 } | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1017 |
167 | 1018 if (match < 0) |
1019 { | |
1020 GtkTreeIter new; | |
442 | 1021 |
167 | 1022 if (valid) |
1023 { | |
1024 gtk_tree_store_insert_before(store, &new, iter, &s_iter); | |
1025 } | |
1026 else | |
1027 { | |
1028 gtk_tree_store_append(store, &new, iter); | |
1029 } | |
442 | 1030 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1031 vflist_setup_iter(vf, store, &new, sfd); |
167 | 1032 |
1033 done = TRUE; | |
1034 } | |
1035 else if (match > 0) | |
1036 { | |
1037 valid = gtk_tree_store_remove(store, &s_iter); | |
1038 } | |
1039 else | |
1040 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1041 vflist_setup_iter(vf, store, &s_iter, sfd); |
167 | 1042 |
1043 if (valid) valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &s_iter); | |
1044 | |
1045 done = TRUE; | |
1046 } | |
1047 } | |
1048 work = work->next; | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1049 } |
167 | 1050 |
1051 while (valid) | |
1052 { | |
1053 valid = gtk_tree_store_remove(store, &s_iter); | |
1054 } | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1055 } |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1056 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1057 void vflist_sort_set(ViewFile *vf, SortType type, gint ascend) |
9 | 1058 { |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1059 gint i; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1060 GHashTable *fd_idx_hash = g_hash_table_new(NULL, NULL); |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1061 gint *new_order; |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1062 GtkTreeStore *store; |
9 | 1063 GList *work; |
1064 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1065 if (vf->sort_method == type && vf->sort_ascend == ascend) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1066 if (!vf->list) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1067 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1068 work = vf->list; |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1069 i = 0; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1070 while (work) |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1071 { |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1072 FileData *fd = work->data; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1073 g_hash_table_insert(fd_idx_hash, fd, GINT_TO_POINTER(i)); |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1074 i++; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1075 work = work->next; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1076 } |
9 | 1077 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1078 vf->sort_method = type; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1079 vf->sort_ascend = ascend; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1080 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1081 vf->list = filelist_sort(vf->list, vf->sort_method, vf->sort_ascend); |
442 | 1082 |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1083 new_order = g_malloc(i * sizeof(gint)); |
442 | 1084 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1085 work = vf->list; |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1086 i = 0; |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1087 while (work) |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1088 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1089 FileData *fd = work->data; |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1090 new_order[i] = GPOINTER_TO_INT(g_hash_table_lookup(fd_idx_hash, fd)); |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1091 i++; |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1092 work = work->next; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1093 } |
442 | 1094 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1095 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1096 gtk_tree_store_reorder(store, NULL, new_order); |
442 | 1097 |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1098 g_free(new_order); |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
1099 g_hash_table_destroy(fd_idx_hash); |
9 | 1100 } |
1101 | |
1102 /* | |
1103 *----------------------------------------------------------------------------- | |
1104 * thumb updates | |
1105 *----------------------------------------------------------------------------- | |
1106 */ | |
1107 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1108 static gint vflist_thumb_next(ViewFile *vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1109 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1110 static void vflist_thumb_status(ViewFile *vf, gdouble val, const gchar *text) |
9 | 1111 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1112 if (vf->func_thumb_status) |
9 | 1113 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1114 vf->func_thumb_status(vf, val, text, vf->data_thumb_status); |
9 | 1115 } |
1116 } | |
1117 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1118 static void vflist_thumb_cleanup(ViewFile *vf) |
9 | 1119 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1120 vflist_thumb_status(vf, 0.0, NULL); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1121 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1122 vf->thumbs_count = 0; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1123 vf->thumbs_running = FALSE; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1124 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1125 thumb_loader_free(vf->thumbs_loader); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1126 vf->thumbs_loader = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1127 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1128 vf->thumbs_filedata = NULL; |
9 | 1129 } |
1130 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1131 static void vflist_thumb_stop(ViewFile *vf) |
9 | 1132 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1133 if (vf->thumbs_running) vflist_thumb_cleanup(vf); |
9 | 1134 } |
1135 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1136 static void vflist_thumb_do(ViewFile *vf, ThumbLoader *tl, FileData *fd) |
9 | 1137 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1138 GtkTreeStore *store; |
9 | 1139 GtkTreeIter iter; |
1140 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1141 if (!fd || vflist_find_row(vf, fd, &iter) < 0) return; |
9 | 1142 |
1143 if (fd->pixbuf) g_object_unref(fd->pixbuf); | |
1144 fd->pixbuf = thumb_loader_get_pixbuf(tl, TRUE); | |
1145 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1146 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1147 gtk_tree_store_set(store, &iter, FILE_COLUMN_THUMB, fd->pixbuf, -1); |
9 | 1148 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1149 vflist_thumb_status(vf, (gdouble)(vf->thumbs_count) / vflist_sidecar_list_count(vf->list), _("Loading thumbs...")); |
9 | 1150 } |
1151 | |
1152 static void vflist_thumb_error_cb(ThumbLoader *tl, gpointer data) | |
1153 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1154 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1155 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1156 if (vf->thumbs_filedata && vf->thumbs_loader == tl) |
9 | 1157 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1158 vflist_thumb_do(vf, tl, vf->thumbs_filedata); |
9 | 1159 } |
1160 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1161 while (vflist_thumb_next(vf)); |
9 | 1162 } |
1163 | |
1164 static void vflist_thumb_done_cb(ThumbLoader *tl, gpointer data) | |
1165 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1166 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1167 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1168 if (vf->thumbs_filedata && vf->thumbs_loader == tl) |
9 | 1169 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1170 vflist_thumb_do(vf, tl, vf->thumbs_filedata); |
9 | 1171 } |
1172 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1173 while (vflist_thumb_next(vf)); |
9 | 1174 } |
1175 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1176 static gint vflist_thumb_next(ViewFile *vf) |
9 | 1177 { |
1178 GtkTreePath *tpath; | |
1179 FileData *fd = NULL; | |
1180 | |
1181 /* first check the visible files */ | |
1182 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1183 if (GTK_WIDGET_REALIZED(vf->listview) && |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1184 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL)) |
9 | 1185 { |
1186 GtkTreeModel *store; | |
1187 GtkTreeIter iter; | |
1188 gint valid = TRUE; | |
1189 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1190 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 1191 gtk_tree_model_get_iter(store, &iter, tpath); |
1192 gtk_tree_path_free(tpath); | |
1193 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1194 while (!fd && valid && tree_view_row_get_visibility(GTK_TREE_VIEW(vf->listview), &iter, FALSE) == 0) |
9 | 1195 { |
1196 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
1197 if (fd->pixbuf) fd = NULL; | |
1198 | |
1199 valid = gtk_tree_model_iter_next(store, &iter); | |
1200 } | |
1201 } | |
1202 | |
1203 /* then find first undone */ | |
1204 | |
1205 if (!fd) | |
1206 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1207 GList *work = vf->list; |
9 | 1208 while (work && !fd) |
1209 { | |
1210 FileData *fd_p = work->data; | |
442 | 1211 if (!fd_p->pixbuf) |
169 | 1212 fd = fd_p; |
1213 else | |
1214 { | |
1215 GList *work2 = fd_p->sidecar_files; | |
442 | 1216 |
169 | 1217 while (work2 && !fd) |
1218 { | |
442 | 1219 fd_p = work2->data; |
169 | 1220 if (!fd_p->pixbuf) fd = fd_p; |
1221 work2 = work2->next; | |
1222 } | |
1223 } | |
9 | 1224 work = work->next; |
1225 } | |
1226 } | |
1227 | |
1228 if (!fd) | |
1229 { | |
1230 /* done */ | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1231 vflist_thumb_cleanup(vf); |
9 | 1232 return FALSE; |
1233 } | |
1234 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1235 vf->thumbs_count++; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1236 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1237 vf->thumbs_filedata = fd; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1238 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1239 thumb_loader_free(vf->thumbs_loader); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1240 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1241 vf->thumbs_loader = thumb_loader_new(options->thumbnails.max_width, options->thumbnails.max_height); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1242 thumb_loader_set_callbacks(vf->thumbs_loader, |
9 | 1243 vflist_thumb_done_cb, |
1244 vflist_thumb_error_cb, | |
1245 NULL, | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1246 vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1247 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1248 if (!thumb_loader_start(vf->thumbs_loader, fd->path)) |
9 | 1249 { |
1250 /* set icon to unknown, continue */ | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1251 DEBUG_1("thumb loader start failed %s", vf->thumbs_loader->path); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1252 vflist_thumb_do(vf, vf->thumbs_loader, fd); |
9 | 1253 |
1254 return TRUE; | |
1255 } | |
1256 | |
1257 return FALSE; | |
1258 } | |
1259 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1260 static void vflist_thumb_update(ViewFile *vf) |
9 | 1261 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1262 vflist_thumb_stop(vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1263 if (!VFLIST_INFO(vf, thumbs_enabled)) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1264 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1265 vflist_thumb_status(vf, 0.0, _("Loading thumbs...")); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1266 vf->thumbs_running = TRUE; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1267 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1268 while (vflist_thumb_next(vf)); |
9 | 1269 } |
1270 | |
1271 /* | |
1272 *----------------------------------------------------------------------------- | |
1273 * row stuff | |
1274 *----------------------------------------------------------------------------- | |
1275 */ | |
1276 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1277 FileData *vflist_index_get_data(ViewFile *vf, gint row) |
9 | 1278 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1279 return g_list_nth_data(vf->list, row); |
9 | 1280 } |
1281 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1282 static gint vflist_row_by_path(ViewFile *vf, const gchar *path, FileData **fd) |
9 | 1283 { |
1284 gint p = 0; | |
1285 GList *work; | |
1286 | |
1287 if (!path) return -1; | |
1288 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1289 work = vf->list; |
9 | 1290 while (work) |
1291 { | |
1292 FileData *fd_n = work->data; | |
1293 if (strcmp(path, fd_n->path) == 0) | |
1294 { | |
1295 if (fd) *fd = fd_n; | |
1296 return p; | |
1297 } | |
1298 work = work->next; | |
1299 p++; | |
1300 } | |
1301 | |
1302 if (fd) *fd = NULL; | |
1303 return -1; | |
1304 } | |
1305 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1306 gint vflist_index_by_path(ViewFile *vf, const gchar *path) |
9 | 1307 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1308 return vflist_row_by_path(vf, path, NULL); |
9 | 1309 } |
1310 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1311 gint vflist_count(ViewFile *vf, gint64 *bytes) |
9 | 1312 { |
1313 if (bytes) | |
1314 { | |
1315 gint64 b = 0; | |
1316 GList *work; | |
1317 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1318 work = vf->list; |
9 | 1319 while (work) |
1320 { | |
1321 FileData *fd = work->data; | |
1322 work = work->next; | |
1323 b += fd->size; | |
1324 } | |
1325 | |
1326 *bytes = b; | |
1327 } | |
1328 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1329 return g_list_length(vf->list); |
9 | 1330 } |
1331 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1332 GList *vflist_get_list(ViewFile *vf) |
9 | 1333 { |
1334 GList *list = NULL; | |
1335 GList *work; | |
1336 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1337 work = vf->list; |
9 | 1338 while (work) |
1339 { | |
1340 FileData *fd = work->data; | |
1341 work = work->next; | |
1342 | |
138 | 1343 list = g_list_prepend(list, file_data_ref(fd)); |
9 | 1344 } |
1345 | |
1346 return g_list_reverse(list); | |
1347 } | |
1348 | |
1349 /* | |
1350 *----------------------------------------------------------------------------- | |
1351 * selections | |
1352 *----------------------------------------------------------------------------- | |
1353 */ | |
1354 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1355 static gint vflist_row_is_selected(ViewFile *vf, FileData *fd) |
9 | 1356 { |
1357 GtkTreeModel *store; | |
1358 GtkTreeSelection *selection; | |
1359 GList *slist; | |
1360 GList *work; | |
1361 gint found = FALSE; | |
1362 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1363 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1364 slist = gtk_tree_selection_get_selected_rows(selection, &store); |
1365 work = slist; | |
1366 while (!found && work) | |
1367 { | |
1368 GtkTreePath *tpath = work->data; | |
1369 FileData *fd_n; | |
1370 GtkTreeIter iter; | |
1371 | |
1372 gtk_tree_model_get_iter(store, &iter, tpath); | |
1373 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd_n, -1); | |
1374 if (fd_n == fd) found = TRUE; | |
1375 work = work->next; | |
1376 } | |
1377 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1378 g_list_free(slist); | |
1379 | |
1380 return found; | |
1381 } | |
1382 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1383 gint vflist_index_is_selected(ViewFile *vf, gint row) |
9 | 1384 { |
1385 FileData *fd; | |
1386 | |
633 | 1387 fd = vf_index_get_data(vf, row); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1388 return vflist_row_is_selected(vf, fd); |
9 | 1389 } |
1390 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1391 gint vflist_selection_count(ViewFile *vf, gint64 *bytes) |
9 | 1392 { |
1393 GtkTreeModel *store; | |
1394 GtkTreeSelection *selection; | |
1395 GList *slist; | |
1396 gint count; | |
1397 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1398 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1399 slist = gtk_tree_selection_get_selected_rows(selection, &store); |
1400 | |
1401 if (bytes) | |
1402 { | |
1403 gint64 b = 0; | |
1404 GList *work; | |
1405 | |
1406 work = slist; | |
1407 while (work) | |
1408 { | |
1409 GtkTreePath *tpath = work->data; | |
1410 GtkTreeIter iter; | |
1411 FileData *fd; | |
1412 | |
1413 gtk_tree_model_get_iter(store, &iter, tpath); | |
1414 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
1415 b += fd->size; | |
1416 | |
1417 work = work->next; | |
1418 } | |
1419 | |
1420 *bytes = b; | |
1421 } | |
1422 | |
1423 count = g_list_length(slist); | |
1424 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1425 g_list_free(slist); | |
1426 | |
1427 return count; | |
1428 } | |
1429 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1430 GList *vflist_selection_get_list(ViewFile *vf) |
9 | 1431 { |
1432 GtkTreeModel *store; | |
1433 GtkTreeSelection *selection; | |
1434 GList *slist; | |
1435 GList *list = NULL; | |
1436 GList *work; | |
1437 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1438 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1439 slist = gtk_tree_selection_get_selected_rows(selection, &store); |
1440 work = slist; | |
1441 while (work) | |
1442 { | |
1443 GtkTreePath *tpath = work->data; | |
1444 FileData *fd; | |
1445 GtkTreeIter iter; | |
1446 | |
1447 gtk_tree_model_get_iter(store, &iter, tpath); | |
1448 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
1449 | |
138 | 1450 list = g_list_prepend(list, file_data_ref(fd)); |
9 | 1451 |
1452 work = work->next; | |
1453 } | |
1454 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1455 g_list_free(slist); | |
1456 | |
1457 return g_list_reverse(list); | |
1458 } | |
1459 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1460 GList *vflist_selection_get_list_by_index(ViewFile *vf) |
9 | 1461 { |
1462 GtkTreeModel *store; | |
1463 GtkTreeSelection *selection; | |
1464 GList *slist; | |
1465 GList *list = NULL; | |
1466 GList *work; | |
1467 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1468 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1469 slist = gtk_tree_selection_get_selected_rows(selection, &store); |
1470 work = slist; | |
1471 while (work) | |
1472 { | |
1473 GtkTreePath *tpath = work->data; | |
1474 FileData *fd; | |
1475 GtkTreeIter iter; | |
1476 | |
1477 gtk_tree_model_get_iter(store, &iter, tpath); | |
1478 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
1479 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1480 list = g_list_prepend(list, GINT_TO_POINTER(g_list_index(vf->list, fd))); |
9 | 1481 |
1482 work = work->next; | |
1483 } | |
1484 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1485 g_list_free(slist); | |
1486 | |
1487 return g_list_reverse(list); | |
1488 } | |
1489 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1490 void vflist_select_all(ViewFile *vf) |
9 | 1491 { |
1492 GtkTreeSelection *selection; | |
1493 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1494 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1495 gtk_tree_selection_select_all(selection); |
1496 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1497 VFLIST_INFO(vf, select_fd) = NULL; |
9 | 1498 } |
1499 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1500 void vflist_select_none(ViewFile *vf) |
9 | 1501 { |
1502 GtkTreeSelection *selection; | |
1503 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1504 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1505 gtk_tree_selection_unselect_all(selection); |
1506 } | |
1507 | |
601 | 1508 static gboolean tree_model_iter_prev(GtkTreeModel *store, GtkTreeIter *iter) |
1509 { | |
1510 GtkTreePath *tpath; | |
1511 gboolean result; | |
1512 | |
1513 tpath = gtk_tree_model_get_path(store, iter); | |
1514 result = gtk_tree_path_prev(tpath); | |
1515 if (result) | |
1516 gtk_tree_model_get_iter(store, iter, tpath); | |
1517 | |
1518 gtk_tree_path_free(tpath); | |
1519 | |
1520 return result; | |
1521 } | |
1522 | |
1523 static gboolean tree_model_get_iter_last(GtkTreeModel *store, GtkTreeIter *iter) | |
1524 { | |
1525 if (!gtk_tree_model_get_iter_first(store, iter)) | |
1526 return FALSE; | |
1527 | |
1528 while (TRUE) | |
1529 { | |
1530 GtkTreeIter next = *iter; | |
1531 | |
1532 if (gtk_tree_model_iter_next(store, &next)) | |
1533 *iter = next; | |
1534 else | |
1535 break; | |
1536 } | |
1537 | |
1538 return TRUE; | |
1539 } | |
1540 | |
1541 void vflist_select_invert(ViewFile *vf) | |
1542 { | |
1543 GtkTreeIter iter; | |
1544 GtkTreeSelection *selection; | |
1545 GtkTreeModel *store; | |
1546 gboolean valid; | |
1547 | |
1548 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); | |
1549 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); | |
1550 | |
1551 /* Backward iteration prevents scrolling to the end of the list, | |
1552 * it scrolls to the first selected row instead. */ | |
1553 valid = tree_model_get_iter_last(store, &iter); | |
1554 | |
1555 while (valid) | |
1556 { | |
1557 gint selected = gtk_tree_selection_iter_is_selected(selection, &iter); | |
1558 | |
1559 if (selected) | |
1560 gtk_tree_selection_unselect_iter(selection, &iter); | |
1561 else | |
1562 gtk_tree_selection_select_iter(selection, &iter); | |
1563 | |
1564 valid = tree_model_iter_prev(store, &iter); | |
1565 } | |
1566 } | |
1567 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1568 void vflist_select_by_fd(ViewFile *vf, FileData *fd) |
138 | 1569 { |
9 | 1570 GtkTreeIter iter; |
1571 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1572 if (vflist_find_row(vf, fd, &iter) < 0) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1573 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1574 tree_view_row_make_visible(GTK_TREE_VIEW(vf->listview), &iter, TRUE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1575 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1576 if (!vflist_row_is_selected(vf, fd)) |
9 | 1577 { |
1578 GtkTreeSelection *selection; | |
1579 GtkTreeModel *store; | |
1580 GtkTreePath *tpath; | |
1581 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1582 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1583 gtk_tree_selection_unselect_all(selection); |
1584 gtk_tree_selection_select_iter(selection, &iter); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1585 vflist_move_cursor(vf, &iter); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1586 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1587 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 1588 tpath = gtk_tree_model_get_path(store, &iter); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1589 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vf->listview), tpath, NULL, FALSE); |
9 | 1590 gtk_tree_path_free(tpath); |
1591 } | |
1592 } | |
1593 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1594 void vflist_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode) |
150 | 1595 { |
1596 GtkTreeModel *store; | |
1597 GtkTreeIter iter; | |
1598 GtkTreeSelection *selection; | |
1599 gint valid; | |
442 | 1600 |
150 | 1601 g_assert(mark >= 0 && mark < FILEDATA_MARKS_SIZE); |
1602 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1603 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1604 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
442 | 1605 |
150 | 1606 valid = gtk_tree_model_get_iter_first(store, &iter); |
1607 while (valid) | |
1608 { | |
1609 FileData *fd; | |
161 | 1610 gboolean mark_val, selected; |
150 | 1611 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &fd, -1); |
442 | 1612 |
161 | 1613 mark_val = fd->marks[mark]; |
1614 selected = gtk_tree_selection_iter_is_selected(selection, &iter); | |
442 | 1615 |
1616 switch (mode) | |
161 | 1617 { |
1618 case MTS_MODE_SET: selected = mark_val; | |
1619 break; | |
1620 case MTS_MODE_OR: selected = mark_val | selected; | |
1621 break; | |
1622 case MTS_MODE_AND: selected = mark_val & selected; | |
1623 break; | |
1624 case MTS_MODE_MINUS: selected = !mark_val & selected; | |
1625 break; | |
1626 } | |
442 | 1627 |
161 | 1628 if (selected) |
150 | 1629 gtk_tree_selection_select_iter(selection, &iter); |
161 | 1630 else |
1631 gtk_tree_selection_unselect_iter(selection, &iter); | |
150 | 1632 |
1633 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); | |
1634 } | |
1635 } | |
1636 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1637 void vflist_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode) |
150 | 1638 { |
1639 GtkTreeModel *store; | |
1640 GtkTreeSelection *selection; | |
1641 GList *slist; | |
1642 GList *work; | |
1643 | |
1644 g_assert(mark >= 0 && mark < FILEDATA_MARKS_SIZE); | |
1645 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1646 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
150 | 1647 slist = gtk_tree_selection_get_selected_rows(selection, &store); |
1648 work = slist; | |
1649 while (work) | |
1650 { | |
1651 GtkTreePath *tpath = work->data; | |
1652 FileData *fd; | |
1653 GtkTreeIter iter; | |
1654 | |
1655 gtk_tree_model_get_iter(store, &iter, tpath); | |
1656 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
442 | 1657 |
161 | 1658 switch (mode) |
1659 { | |
1660 case STM_MODE_SET: fd->marks[mark] = 1; | |
1661 break; | |
1662 case STM_MODE_RESET: fd->marks[mark] = 0; | |
1663 break; | |
1664 case STM_MODE_TOGGLE: fd->marks[mark] = !fd->marks[mark]; | |
1665 break; | |
1666 } | |
442 | 1667 |
1668 gtk_tree_store_set(GTK_TREE_STORE(store), &iter, FILE_COLUMN_MARKS + mark, fd->marks[mark], -1); | |
150 | 1669 |
1670 work = work->next; | |
1671 } | |
1672 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1673 g_list_free(slist); | |
1674 } | |
1675 | |
9 | 1676 /* |
1677 *----------------------------------------------------------------------------- | |
1678 * core (population) | |
1679 *----------------------------------------------------------------------------- | |
1680 */ | |
1681 | |
1682 static void vflist_listview_set_height(GtkWidget *listview, gint thumb) | |
1683 { | |
1684 GtkTreeViewColumn *column; | |
1685 GtkCellRenderer *cell; | |
1686 GList *list; | |
1687 | |
1688 column = gtk_tree_view_get_column(GTK_TREE_VIEW(listview), FILE_COLUMN_THUMB - 1); | |
1689 if (!column) return; | |
1690 | |
333 | 1691 gtk_tree_view_column_set_fixed_width(column, ((thumb) ? options->thumbnails.max_width : 4) + 10); |
9 | 1692 |
1693 list = gtk_tree_view_column_get_cell_renderers(column); | |
1694 if (!list) return; | |
1695 cell = list->data; | |
1696 g_list_free(list); | |
1697 | |
333 | 1698 g_object_set(G_OBJECT(cell), "height", (thumb) ? options->thumbnails.max_height : -1, NULL); |
9 | 1699 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(listview)); |
1700 } | |
1701 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1702 static void vflist_populate_view(ViewFile *vf) |
9 | 1703 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1704 GtkTreeStore *store; |
9 | 1705 GtkTreeIter iter; |
1706 gint thumbs; | |
1707 GList *work; | |
1708 GtkTreeRowReference *visible_row = NULL; | |
1709 GtkTreePath *tpath; | |
1710 gint valid; | |
1711 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1712 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1713 thumbs = VFLIST_INFO(vf, thumbs_enabled); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1714 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1715 vflist_thumb_stop(vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1716 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1717 if (!vf->list) |
9 | 1718 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1719 gtk_tree_store_clear(store); |
633 | 1720 vf_send_update(vf); |
9 | 1721 return; |
1722 } | |
1723 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1724 if (GTK_WIDGET_REALIZED(vf->listview) && |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1725 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL)) |
9 | 1726 { |
1727 visible_row = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), tpath); | |
1728 gtk_tree_path_free(tpath); | |
1729 } | |
1730 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1731 vflist_listview_set_height(vf->listview, thumbs); |
9 | 1732 |
1733 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); | |
1734 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1735 work = vf->list; |
9 | 1736 while (work) |
1737 { | |
1738 gint match; | |
1739 FileData *fd = work->data; | |
1740 gint done = FALSE; | |
1741 | |
1742 while (!done) | |
1743 { | |
1744 FileData *old_fd = NULL; | |
442 | 1745 |
9 | 1746 if (valid) |
1747 { | |
1748 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &old_fd, -1); | |
442 | 1749 |
167 | 1750 if (fd == old_fd) |
1751 { | |
1752 match = 0; | |
1753 } | |
1754 else | |
1755 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1756 match = filelist_sort_compare_filedata_full(fd, old_fd, vf->sort_method, vf->sort_ascend); |
167 | 1757 if (match == 0) |
1758 match = -1; /* probably should not happen*/ | |
1759 } | |
9 | 1760 } |
442 | 1761 |
9 | 1762 else |
1763 { | |
1764 match = -1; | |
1765 } | |
1766 | |
1767 if (match < 0) | |
1768 { | |
1769 GtkTreeIter new; | |
442 | 1770 |
9 | 1771 if (valid) |
1772 { | |
167 | 1773 gtk_tree_store_insert_before(store, &new, NULL, &iter); |
9 | 1774 } |
1775 else | |
1776 { | |
167 | 1777 gtk_tree_store_append(store, &new, NULL); |
9 | 1778 } |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1779 vflist_setup_iter_with_sidecars(vf, store, &new, fd); |
9 | 1780 |
1781 done = TRUE; | |
1782 } | |
1783 else if (match > 0) | |
1784 { | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1785 valid = gtk_tree_store_remove(store, &iter); |
9 | 1786 } |
1787 else | |
1788 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1789 vflist_setup_iter_with_sidecars(vf, store, &iter, fd); |
9 | 1790 |
1791 if (valid) valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); | |
1792 | |
1793 done = TRUE; | |
1794 } | |
1795 } | |
1796 work = work->next; | |
1797 } | |
1798 | |
1799 while (valid) | |
1800 { | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1801 valid = gtk_tree_store_remove(store, &iter); |
9 | 1802 } |
1803 | |
1804 if (visible_row) | |
1805 { | |
1806 if (gtk_tree_row_reference_valid(visible_row)) | |
1807 { | |
1808 tpath = gtk_tree_row_reference_get_path(visible_row); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1809 gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(vf->listview), tpath, NULL, TRUE, 0.0, 0.0); |
9 | 1810 gtk_tree_path_free(tpath); |
1811 } | |
1812 gtk_tree_row_reference_free(visible_row); | |
1813 } | |
1814 | |
633 | 1815 vf_send_update(vf); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1816 vflist_thumb_update(vf); |
9 | 1817 } |
1818 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1819 gint vflist_refresh(ViewFile *vf) |
9 | 1820 { |
1821 GList *old_list; | |
1822 gint ret = TRUE; | |
1823 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1824 old_list = vf->list; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1825 vf->list = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1826 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1827 if (vf->path) |
9 | 1828 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1829 ret = filelist_read(vf->path, &vf->list, NULL); |
9 | 1830 } |
1831 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1832 vf->list = filelist_sort(vf->list, vf->sort_method, vf->sort_ascend); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1833 vflist_populate_view(vf); |
9 | 1834 |
1835 filelist_free(old_list); | |
1836 | |
1837 return ret; | |
1838 } | |
1839 | |
1840 /* this overrides the low default of a GtkCellRenderer from 100 to CELL_HEIGHT_OVERRIDE, something sane for our purposes */ | |
1841 | |
1842 #define CELL_HEIGHT_OVERRIDE 512 | |
1843 | |
1844 static void cell_renderer_height_override(GtkCellRenderer *renderer) | |
1845 { | |
1846 GParamSpec *spec; | |
1847 | |
1848 spec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(renderer)), "height"); | |
1849 if (spec && G_IS_PARAM_SPEC_INT(spec)) | |
1850 { | |
1851 GParamSpecInt *spec_int; | |
1852 | |
1853 spec_int = G_PARAM_SPEC_INT(spec); | |
1854 if (spec_int->maximum < CELL_HEIGHT_OVERRIDE) spec_int->maximum = CELL_HEIGHT_OVERRIDE; | |
1855 } | |
1856 } | |
1857 | |
1858 static GdkColor *vflist_listview_color_shifted(GtkWidget *widget) | |
1859 { | |
1860 static GdkColor color; | |
1861 static GtkWidget *done = NULL; | |
1862 | |
1863 if (done != widget) | |
1864 { | |
1865 GtkStyle *style; | |
1866 | |
1867 style = gtk_widget_get_style(widget); | |
1868 memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color)); | |
1869 shift_color(&color, -1, 0); | |
1870 done = widget; | |
1871 } | |
1872 | |
1873 return &color; | |
1874 } | |
1875 | |
1876 static void vflist_listview_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, | |
1877 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) | |
1878 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1879 ViewFile *vf = data; |
9 | 1880 gboolean set; |
1881 | |
1882 gtk_tree_model_get(tree_model, iter, FILE_COLUMN_COLOR, &set, -1); | |
1883 g_object_set(G_OBJECT(cell), | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1884 "cell-background-gdk", vflist_listview_color_shifted(vf->listview), |
9 | 1885 "cell-background-set", set, NULL); |
1886 } | |
1887 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1888 static void vflist_listview_add_column(ViewFile *vf, gint n, const gchar *title, gint image, gint right_justify, gint expand) |
9 | 1889 { |
1890 GtkTreeViewColumn *column; | |
1891 GtkCellRenderer *renderer; | |
1892 | |
1893 column = gtk_tree_view_column_new(); | |
1894 gtk_tree_view_column_set_title(column, title); | |
1895 gtk_tree_view_column_set_min_width(column, 4); | |
1896 | |
1897 if (!image) | |
1898 { | |
149 | 1899 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY); |
9 | 1900 renderer = gtk_cell_renderer_text_new(); |
1901 if (right_justify) | |
1902 { | |
1903 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL); | |
1904 } | |
1905 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
1906 gtk_tree_view_column_add_attribute(column, renderer, "text", n); | |
149 | 1907 if (expand) |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1908 gtk_tree_view_column_set_expand(column, TRUE); |
149 | 1909 } |
9 | 1910 else |
1911 { | |
1912 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); | |
1913 renderer = gtk_cell_renderer_pixbuf_new(); | |
1914 cell_renderer_height_override(renderer); | |
1915 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
1916 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", n); | |
1917 } | |
1918 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1919 gtk_tree_view_column_set_cell_data_func(column, renderer, vflist_listview_color_cb, vf, NULL); |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1920 g_object_set_data(G_OBJECT(column), "column_store_idx", GUINT_TO_POINTER(n)); |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1921 g_object_set_data(G_OBJECT(renderer), "column_store_idx", GUINT_TO_POINTER(n)); |
9 | 1922 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1923 gtk_tree_view_append_column(GTK_TREE_VIEW(vf->listview), column); |
9 | 1924 } |
1925 | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1926 static void vflist_listview_mark_toggled(GtkCellRendererToggle *cell, gchar *path_str, GtkTreeStore *store) |
132 | 1927 { |
149 | 1928 GtkTreePath *path = gtk_tree_path_new_from_string(path_str); |
1929 GtkTreeIter iter; | |
1930 FileData *fd; | |
1931 gboolean mark; | |
1932 guint col_idx; | |
442 | 1933 |
149 | 1934 if (!path || !gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path)) |
1935 return; | |
132 | 1936 |
513
985fdfebd89e
Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents:
512
diff
changeset
|
1937 col_idx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cell), "column_store_idx")); |
442 | 1938 |
149 | 1939 g_assert(col_idx >= FILE_COLUMN_MARKS && col_idx <= FILE_COLUMN_MARKS_LAST); |
442 | 1940 |
149 | 1941 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &fd, col_idx, &mark, -1); |
150 | 1942 mark = !mark; |
149 | 1943 fd->marks[col_idx - FILE_COLUMN_MARKS] = mark; |
442 | 1944 |
149 | 1945 gtk_tree_store_set(store, &iter, col_idx, mark, -1); |
1946 gtk_tree_path_free(path); | |
132 | 1947 } |
1948 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1949 static void vflist_listview_add_column_toggle(ViewFile *vf, gint n, const gchar *title) |
132 | 1950 { |
149 | 1951 GtkTreeViewColumn *column; |
1952 GtkCellRenderer *renderer; | |
1953 GtkTreeStore *store; | |
1954 gint index; | |
442 | 1955 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1956 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
132 | 1957 |
149 | 1958 renderer = gtk_cell_renderer_toggle_new(); |
1959 column = gtk_tree_view_column_new_with_attributes(title, renderer, "active", n, NULL); | |
132 | 1960 |
149 | 1961 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1962 g_object_set_data(G_OBJECT(column), "column_store_idx", GUINT_TO_POINTER(n)); |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1963 g_object_set_data(G_OBJECT(renderer), "column_store_idx", GUINT_TO_POINTER(n)); |
442 | 1964 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1965 index = gtk_tree_view_append_column(GTK_TREE_VIEW(vf->listview), column); |
149 | 1966 gtk_tree_view_column_set_fixed_width(column, 16); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1967 gtk_tree_view_column_set_visible(column, vf->marks_enabled); |
132 | 1968 |
442 | 1969 |
149 | 1970 g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(vflist_listview_mark_toggled), store); |
132 | 1971 } |
1972 | |
9 | 1973 /* |
1974 *----------------------------------------------------------------------------- | |
1975 * base | |
1976 *----------------------------------------------------------------------------- | |
1977 */ | |
1978 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1979 gint vflist_set_path(ViewFile *vf, const gchar *path) |
9 | 1980 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1981 GtkTreeStore *store; |
9 | 1982 |
1983 if (!path) return FALSE; | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1984 if (vf->path && strcmp(path, vf->path) == 0) return TRUE; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1985 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1986 g_free(vf->path); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1987 vf->path = g_strdup(path); |
9 | 1988 |
1989 /* force complete reload */ | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1990 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1991 gtk_tree_store_clear(store); |
9 | 1992 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1993 filelist_free(vf->list); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1994 vf->list = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1995 |
633 | 1996 return vf_refresh(vf); |
9 | 1997 } |
1998 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1999 void vflist_destroy_cb(GtkWidget *widget, gpointer data) |
9 | 2000 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2001 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2002 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2003 vflist_select_idle_cancel(vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2004 vflist_thumb_stop(vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2005 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2006 filelist_free(vf->list); |
9 | 2007 } |
2008 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2009 ViewFile *vflist_new(ViewFile *vf, const gchar *path) |
9 | 2010 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
2011 GtkTreeStore *store; |
9 | 2012 GtkTreeSelection *selection; |
2013 | |
149 | 2014 GType flist_types[FILE_COLUMN_COUNT]; |
2015 int i; | |
442 | 2016 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2017 vf->info = g_new0(ViewFileInfoList, 1); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2018 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2019 VFLIST_INFO(vf, click_fd) = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2020 VFLIST_INFO(vf, select_fd) = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2021 VFLIST_INFO(vf, thumbs_enabled) = FALSE; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2022 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2023 VFLIST_INFO(vf, select_idle_id) = -1; |
9 | 2024 |
139 | 2025 flist_types[FILE_COLUMN_POINTER] = G_TYPE_POINTER; |
2026 flist_types[FILE_COLUMN_THUMB] = GDK_TYPE_PIXBUF; | |
2027 flist_types[FILE_COLUMN_NAME] = G_TYPE_STRING; | |
2028 flist_types[FILE_COLUMN_SIDECARS] = G_TYPE_STRING; | |
2029 flist_types[FILE_COLUMN_SIZE] = G_TYPE_STRING; | |
2030 flist_types[FILE_COLUMN_DATE] = G_TYPE_STRING; | |
2031 flist_types[FILE_COLUMN_COLOR] = G_TYPE_BOOLEAN; | |
2032 for (i = FILE_COLUMN_MARKS; i < FILE_COLUMN_MARKS + FILEDATA_MARKS_SIZE; i++) | |
2033 flist_types[i] = G_TYPE_BOOLEAN; | |
132 | 2034 |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
2035 store = gtk_tree_store_newv(FILE_COLUMN_COUNT, flist_types); |
442 | 2036 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2037 vf->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); |
9 | 2038 g_object_unref(store); |
2039 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2040 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 2041 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_MULTIPLE); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2042 gtk_tree_selection_set_select_function(selection, vflist_select_cb, vf, NULL); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2043 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2044 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vf->listview), FALSE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2045 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vf->listview), FALSE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2046 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2047 vflist_listview_add_column(vf, FILE_COLUMN_THUMB, "", TRUE, FALSE, FALSE); |
9 | 2048 |
518 | 2049 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2050 vflist_listview_add_column_toggle(vf, i + FILE_COLUMN_MARKS, ""); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2051 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2052 vflist_listview_add_column(vf, FILE_COLUMN_NAME, _("Name"), FALSE, FALSE, FALSE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2053 vflist_listview_add_column(vf, FILE_COLUMN_SIDECARS, _("SC"), FALSE, FALSE, FALSE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2054 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2055 vflist_listview_add_column(vf, FILE_COLUMN_SIZE, _("Size"), FALSE, TRUE, FALSE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2056 vflist_listview_add_column(vf, FILE_COLUMN_DATE, _("Date"), FALSE, TRUE, FALSE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2057 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2058 return vf; |
9 | 2059 } |
2060 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2061 void vflist_thumb_set(ViewFile *vf, gint enable) |
9 | 2062 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2063 if (VFLIST_INFO(vf, thumbs_enabled) == enable) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2064 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2065 VFLIST_INFO(vf, thumbs_enabled) = enable; |
633 | 2066 if (vf->layout) vf_refresh(vf); |
9 | 2067 } |
2068 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2069 void vflist_marks_set(ViewFile *vf, gint enable) |
132 | 2070 { |
149 | 2071 GList *columns, *work; |
442 | 2072 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2073 if (vf->marks_enabled == enable) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2074 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2075 vf->marks_enabled = enable; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2076 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2077 columns = gtk_tree_view_get_columns(GTK_TREE_VIEW(vf->listview)); |
442 | 2078 |
149 | 2079 work = columns; |
2080 while (work) | |
2081 { | |
2082 GtkTreeViewColumn *column = work->data; | |
513
985fdfebd89e
Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents:
512
diff
changeset
|
2083 gint col_idx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), "column_store_idx")); |
149 | 2084 work = work->next; |
442 | 2085 |
2086 if (col_idx <= FILE_COLUMN_MARKS_LAST && col_idx >= FILE_COLUMN_MARKS) | |
149 | 2087 gtk_tree_view_column_set_visible(column, enable); |
2088 } | |
442 | 2089 |
149 | 2090 g_list_free(columns); |
633 | 2091 //vf_refresh(vf); |
132 | 2092 } |
2093 | |
9 | 2094 /* |
2095 *----------------------------------------------------------------------------- | |
2096 * maintenance (for rename, move, remove) | |
2097 *----------------------------------------------------------------------------- | |
2098 */ | |
2099 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2100 static gint vflist_maint_find_closest(ViewFile *vf, gint row, gint count, GList *ignore_list) |
9 | 2101 { |
2102 GList *list = NULL; | |
2103 GList *work; | |
2104 gint rev = row - 1; | |
2105 row ++; | |
2106 | |
2107 work = ignore_list; | |
2108 while (work) | |
2109 { | |
633 | 2110 gint f = vf_index_by_path(vf, work->data); |
9 | 2111 if (f >= 0) list = g_list_prepend(list, GINT_TO_POINTER(f)); |
2112 work = work->next; | |
2113 } | |
2114 | |
2115 while (list) | |
2116 { | |
2117 gint c = TRUE; | |
2118 work = list; | |
2119 while (work && c) | |
2120 { | |
2121 gpointer p = work->data; | |
2122 work = work->next; | |
2123 if (row == GPOINTER_TO_INT(p)) | |
2124 { | |
2125 row++; | |
2126 c = FALSE; | |
2127 } | |
2128 if (rev == GPOINTER_TO_INT(p)) | |
2129 { | |
2130 rev--; | |
2131 c = FALSE; | |
2132 } | |
2133 if (!c) list = g_list_remove(list, p); | |
2134 } | |
2135 if (c && list) | |
2136 { | |
2137 g_list_free(list); | |
2138 list = NULL; | |
2139 } | |
2140 } | |
2141 if (row > count - 1) | |
2142 { | |
2143 if (rev < 0) | |
2144 return -1; | |
2145 else | |
2146 return rev; | |
2147 } | |
2148 else | |
2149 { | |
2150 return row; | |
2151 } | |
2152 } | |
2153 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2154 gint vflist_maint_renamed(ViewFile *vf, FileData *fd) |
9 | 2155 { |
2156 gint ret = FALSE; | |
2157 gchar *source_base; | |
2158 gchar *dest_base; | |
2159 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2160 if (g_list_index(vf->list, fd) < 0) return FALSE; |
9 | 2161 |
138 | 2162 source_base = remove_level_from_path(fd->change->source); |
2163 dest_base = remove_level_from_path(fd->change->dest); | |
9 | 2164 |
2165 | |
2166 if (strcmp(source_base, dest_base) == 0) | |
2167 { | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
2168 GtkTreeStore *store; |
9 | 2169 GtkTreeIter iter; |
2170 GtkTreeIter position; | |
2171 gint old_row; | |
2172 gint n; | |
2173 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2174 old_row = g_list_index(vf->list, fd); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2175 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2176 vf->list = g_list_remove(vf->list, fd); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2177 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2178 vf->list = filelist_insert_sort(vf->list, fd, vf->sort_method, vf->sort_ascend); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2179 n = g_list_index(vf->list, fd); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2180 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2181 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2182 if (vflist_find_row(vf, fd, &iter) >= 0 && |
9 | 2183 gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &position, NULL, n)) |
2184 { | |
2185 if (old_row >= n) | |
2186 { | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
2187 gtk_tree_store_move_before(store, &iter, &position); |
9 | 2188 } |
2189 else | |
2190 { | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
2191 gtk_tree_store_move_after(store, &iter, &position); |
9 | 2192 } |
2193 } | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
2194 gtk_tree_store_set(store, &iter, FILE_COLUMN_NAME, fd->name, -1); |
9 | 2195 |
2196 ret = TRUE; | |
2197 } | |
2198 else | |
2199 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2200 ret = vflist_maint_removed(vf, fd, NULL); |
9 | 2201 } |
2202 | |
2203 g_free(source_base); | |
2204 g_free(dest_base); | |
2205 | |
2206 return ret; | |
2207 } | |
2208 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2209 gint vflist_maint_removed(ViewFile *vf, FileData *fd, GList *ignore_list) |
9 | 2210 { |
2211 GtkTreeIter iter; | |
2212 GList *list; | |
2213 gint row; | |
2214 gint new_row = -1; | |
2215 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2216 row = g_list_index(vf->list, fd); |
9 | 2217 if (row < 0) return FALSE; |
2218 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2219 if (vflist_index_is_selected(vf, row) && |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2220 layout_image_get_collection(vf->layout, NULL) == NULL) |
9 | 2221 { |
2222 gint n; | |
2223 | |
633 | 2224 n = vf_count(vf, NULL); |
9 | 2225 if (ignore_list) |
2226 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2227 new_row = vflist_maint_find_closest(vf, row, n, ignore_list); |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
2228 DEBUG_1("row = %d, closest is %d", row, new_row); |
9 | 2229 } |
2230 else | |
2231 { | |
2232 if (row + 1 < n) | |
2233 { | |
2234 new_row = row + 1; | |
2235 } | |
2236 else if (row > 0) | |
2237 { | |
2238 new_row = row - 1; | |
2239 } | |
2240 } | |
633 | 2241 vf_select_none(vf); |
9 | 2242 if (new_row >= 0) |
2243 { | |
633 | 2244 fd = vf_index_get_data(vf, new_row); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2245 if (vflist_find_row(vf, fd, &iter) >= 0) |
9 | 2246 { |
2247 GtkTreeSelection *selection; | |
2248 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2249 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 2250 gtk_tree_selection_select_iter(selection, &iter); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2251 vflist_move_cursor(vf, &iter); |
9 | 2252 } |
2253 } | |
2254 } | |
2255 | |
633 | 2256 fd = vf_index_get_data(vf, row); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2257 if (vflist_find_row(vf, fd, &iter) >= 0) |
9 | 2258 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
2259 GtkTreeStore *store; |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2260 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
2261 gtk_tree_store_remove(store, &iter); |
9 | 2262 } |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2263 list = g_list_nth(vf->list, row); |
9 | 2264 fd = list->data; |
2265 | |
2266 /* thumbnail loader check */ | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2267 if (fd == vf->thumbs_filedata) vf->thumbs_filedata = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2268 if (vf->thumbs_count > 0) vf->thumbs_count--; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2269 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2270 vf->list = g_list_remove(vf->list, fd); |
138 | 2271 file_data_unref(fd); |
9 | 2272 |
633 | 2273 vf_send_update(vf); |
9 | 2274 |
2275 return TRUE; | |
2276 } | |
2277 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2278 gint vflist_maint_moved(ViewFile *vf, FileData *fd, GList *ignore_list) |
9 | 2279 { |
2280 gint ret = FALSE; | |
2281 gchar *buf; | |
2282 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2283 if (!fd->change->source || !vf->path) return FALSE; |
9 | 2284 |
138 | 2285 buf = remove_level_from_path(fd->change->source); |
9 | 2286 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2287 if (strcmp(buf, vf->path) == 0) |
9 | 2288 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2289 ret = vflist_maint_removed(vf, fd, ignore_list); |
9 | 2290 } |
2291 | |
2292 g_free(buf); | |
2293 | |
2294 return ret; | |
2295 } |