Mercurial > geeqie
annotate src/view_file_icon.c @ 967:eb5dbdff14f6
Move variable declaration at start of block.
author | zas_ |
---|---|
date | Sun, 17 Aug 2008 09:00:33 +0000 |
parents | c24a297efbef |
children | 065a129fd42b |
rev | line source |
---|---|
9 | 1 /* |
196 | 2 * Geeqie |
111
3a69a7a3f461
Wed Nov 15 02:05:27 2006 John Ellis <johne@verizon.net>
gqview
parents:
85
diff
changeset
|
3 * (C) 2006 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_icon.h" |
15 | |
16 #include "cellrenderericon.h" | |
17 #include "collect.h" | |
18 #include "collect-io.h" | |
19 #include "collect-table.h" | |
20 #include "dnd.h" | |
21 #include "editors.h" | |
22 #include "img-view.h" | |
23 #include "info.h" | |
586 | 24 #include "filedata.h" |
9 | 25 #include "layout.h" |
26 #include "layout_image.h" | |
27 #include "menu.h" | |
28 #include "thumb.h" | |
29 #include "utilops.h" | |
30 #include "ui_fileops.h" | |
31 #include "ui_menu.h" | |
32 #include "ui_tree_edit.h" | |
904
1698baa37871
Move uri_*() functions to separate files: uri_utils.[ch]
zas_
parents:
852
diff
changeset
|
33 #include "uri_utils.h" |
633 | 34 #include "view_file.h" |
9 | 35 |
36 #include <gdk/gdkkeysyms.h> /* for keyboard values */ | |
37 | |
557
d8d61dc4ff52
Introduce ViewFileInfoList and ViewFileInfoIcon (not used yet).
zas_
parents:
516
diff
changeset
|
38 |
9 | 39 /* between these, the icon width is increased by thumb_max_width / 2 */ |
40 #define THUMB_MIN_ICON_WIDTH 128 | |
41 #define THUMB_MAX_ICON_WIDTH 150 | |
42 | |
43 #define VFICON_MAX_COLUMNS 32 | |
44 #define THUMB_BORDER_PADDING 2 | |
45 | |
46 #define VFICON_TIP_DELAY 500 | |
47 | |
48 enum { | |
49 FILE_COLUMN_POINTER = 0, | |
50 FILE_COLUMN_COUNT | |
51 }; | |
52 | |
53 typedef enum { | |
54 SELECTION_NONE = 0, | |
55 SELECTION_SELECTED = 1 << 0, | |
56 SELECTION_PRELIGHT = 1 << 1, | |
57 SELECTION_FOCUS = 1 << 2 | |
58 } SelectionType; | |
59 | |
60 typedef struct _IconData IconData; | |
61 struct _IconData | |
62 { | |
63 SelectionType selected; | |
111
3a69a7a3f461
Wed Nov 15 02:05:27 2006 John Ellis <johne@verizon.net>
gqview
parents:
85
diff
changeset
|
64 gint row; |
138 | 65 FileData *fd; |
9 | 66 }; |
67 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
68 static gint vficon_index_by_id(ViewFile *vf, IconData *in_id); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
69 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
70 static IconData *vficon_icon_data(ViewFile *vf, FileData *fd) |
138 | 71 { |
72 IconData *id = NULL; | |
73 GList *work; | |
74 | |
75 if (!fd) return NULL; | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
76 work = vf->list; |
138 | 77 while (work && !id) |
78 { | |
79 IconData *chk = work->data; | |
80 work = work->next; | |
81 if (chk->fd == fd) id = chk; | |
82 } | |
83 return id; | |
84 } | |
85 | |
812 | 86 #if 0 |
87 /* not used */ | |
783 | 88 static gint iconlist_read(FileData *dir_fd, GList **list) |
9 | 89 { |
90 GList *temp; | |
91 GList *work; | |
92 | |
783 | 93 if (!filelist_read(dir_fd, &temp, NULL)) return FALSE; |
9 | 94 |
95 work = temp; | |
96 while (work) | |
97 { | |
98 FileData *fd; | |
99 IconData *id; | |
100 | |
101 fd = work->data; | |
442 | 102 g_assert(fd->magick == 0x12345678); |
9 | 103 id = g_new0(IconData, 1); |
104 | |
105 id->selected = SELECTION_NONE; | |
111
3a69a7a3f461
Wed Nov 15 02:05:27 2006 John Ellis <johne@verizon.net>
gqview
parents:
85
diff
changeset
|
106 id->row = -1; |
138 | 107 id->fd = fd; |
9 | 108 |
109 work->data = id; | |
110 work = work->next; | |
111 } | |
112 | |
113 *list = temp; | |
114 | |
115 return TRUE; | |
116 } | |
812 | 117 #endif |
9 | 118 |
119 static void iconlist_free(GList *list) | |
120 { | |
138 | 121 GList *work = list; |
122 while (work) | |
123 { | |
124 IconData *id = work->data; | |
125 file_data_unref(id->fd); | |
126 g_free(id); | |
442 | 127 work = work->next; |
128 } | |
129 | |
130 g_list_free(list); | |
138 | 131 |
132 } | |
133 | |
134 gint iconlist_sort_file_cb(void *a, void *b) | |
135 { | |
136 IconData *ida = a; | |
137 IconData *idb = b; | |
138 return filelist_sort_compare_filedata(ida->fd, idb->fd); | |
139 } | |
633 | 140 |
138 | 141 GList *iconlist_sort(GList *list, SortType method, gint ascend) |
142 { | |
143 return filelist_sort_full(list, method, ascend, (GCompareFunc) iconlist_sort_file_cb); | |
144 } | |
145 | |
146 GList *iconlist_insert_sort(GList *list, IconData *id, SortType method, gint ascend) | |
147 { | |
148 return filelist_insert_sort_full(list, id, method, ascend, (GCompareFunc) iconlist_sort_file_cb); | |
9 | 149 } |
150 | |
151 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
152 static void vficon_toggle_filenames(ViewFile *vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
153 static void vficon_selection_remove(ViewFile *vf, IconData *id, SelectionType mask, GtkTreeIter *iter); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
154 static void vficon_move_focus(ViewFile *vf, gint row, gint col, gint relative); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
155 static void vficon_set_focus(ViewFile *vf, IconData *id); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
156 static void vficon_thumb_update(ViewFile *vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
157 static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint h, gint force); |
9 | 158 |
159 | |
160 /* | |
161 *----------------------------------------------------------------------------- | |
162 * pop-up menu | |
163 *----------------------------------------------------------------------------- | |
164 */ | |
165 | |
634 | 166 GList *vficon_pop_menu_file_list(ViewFile *vf) |
9 | 167 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
168 if (!VFICON_INFO(vf, click_id)) return NULL; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
169 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
170 if (VFICON_INFO(vf, click_id)->selected & SELECTION_SELECTED) |
9 | 171 { |
633 | 172 return vf_selection_get_list(vf); |
9 | 173 } |
174 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
175 return g_list_append(NULL, file_data_ref(VFICON_INFO(vf, click_id)->fd)); |
9 | 176 } |
177 | |
637 | 178 void vficon_pop_menu_view_cb(GtkWidget *widget, gpointer data) |
9 | 179 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
180 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
181 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
182 if (!VFICON_INFO(vf, click_id)) return; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
183 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
184 if (VFICON_INFO(vf, click_id)->selected & SELECTION_SELECTED) |
9 | 185 { |
186 GList *list; | |
442 | 187 |
633 | 188 list = vf_selection_get_list(vf); |
9 | 189 view_window_new_from_list(list); |
138 | 190 filelist_free(list); |
9 | 191 } |
192 else | |
193 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
194 view_window_new(VFICON_INFO(vf, click_id)->fd); |
9 | 195 } |
196 } | |
197 | |
637 | 198 void vficon_pop_menu_rename_cb(GtkWidget *widget, gpointer data) |
9 | 199 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
200 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
201 |
634 | 202 file_util_rename(NULL, vf_pop_menu_file_list(vf), vf->listview); |
9 | 203 } |
204 | |
659
542bb47fef04
Merge vflist_pop_menu() and vficon_pop_menu() into vf_pop_menu().
zas_
parents:
658
diff
changeset
|
205 void vficon_pop_menu_show_names_cb(GtkWidget *widget, gpointer data) |
9 | 206 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
207 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
208 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
209 vficon_toggle_filenames(vf); |
9 | 210 } |
211 | |
637 | 212 void vficon_pop_menu_refresh_cb(GtkWidget *widget, gpointer data) |
9 | 213 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
214 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
215 |
633 | 216 vf_refresh(vf); |
9 | 217 } |
218 | |
637 | 219 void vficon_popup_destroy_cb(GtkWidget *widget, gpointer data) |
9 | 220 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
221 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
222 vficon_selection_remove(vf, VFICON_INFO(vf, click_id), SELECTION_PRELIGHT, NULL); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
223 VFICON_INFO(vf, click_id) = NULL; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
224 vf->popup = NULL; |
9 | 225 } |
226 | |
227 /* | |
228 *------------------------------------------------------------------- | |
229 * signals | |
230 *------------------------------------------------------------------- | |
231 */ | |
232 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
233 static void vficon_send_layout_select(ViewFile *vf, IconData *id) |
9 | 234 { |
138 | 235 FileData *read_ahead_fd = NULL; |
144 | 236 FileData *sel_fd; |
237 FileData *cur_fd; | |
238 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
239 if (!vf->layout || !id || !id->fd) return; |
144 | 240 |
241 sel_fd = id->fd; | |
442 | 242 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
243 cur_fd = layout_image_get_fd(vf->layout); |
144 | 244 if (sel_fd == cur_fd) return; /* no change */ |
442 | 245 |
334 | 246 if (options->image.enable_read_ahead) |
9 | 247 { |
248 gint row; | |
249 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
250 row = g_list_index(vf->list, id); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
251 if (row > vficon_index_by_fd(vf, cur_fd) && |
736 | 252 (guint) (row + 1) < vf_count(vf, NULL)) |
9 | 253 { |
633 | 254 read_ahead_fd = vf_index_get_data(vf, row + 1); |
9 | 255 } |
256 else if (row > 0) | |
257 { | |
633 | 258 read_ahead_fd = vf_index_get_data(vf, row - 1); |
9 | 259 } |
260 } | |
261 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
262 layout_image_set_with_ahead(vf->layout, sel_fd, read_ahead_fd); |
9 | 263 } |
264 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
265 static void vficon_toggle_filenames(ViewFile *vf) |
9 | 266 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
267 VFICON_INFO(vf, show_text) = !VFICON_INFO(vf, show_text); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
268 options->show_icon_names = VFICON_INFO(vf, show_text); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
269 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
270 vficon_populate_at_new_size(vf, vf->listview->allocation.width, vf->listview->allocation.height, TRUE); |
9 | 271 } |
272 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
273 static gint vficon_get_icon_width(ViewFile *vf) |
9 | 274 { |
275 gint width; | |
276 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
277 if (!VFICON_INFO(vf, show_text)) return options->thumbnails.max_width; |
333 | 278 |
279 width = options->thumbnails.max_width + options->thumbnails.max_width / 2; | |
9 | 280 if (width < THUMB_MIN_ICON_WIDTH) width = THUMB_MIN_ICON_WIDTH; |
333 | 281 if (width > THUMB_MAX_ICON_WIDTH) width = options->thumbnails.max_width; |
9 | 282 |
283 return width; | |
284 } | |
285 | |
286 /* | |
287 *------------------------------------------------------------------- | |
288 * misc utils | |
289 *------------------------------------------------------------------- | |
290 */ | |
291 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
292 static gint vficon_find_position(ViewFile *vf, IconData *id, gint *row, gint *col) |
9 | 293 { |
294 gint n; | |
295 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
296 n = g_list_index(vf->list, id); |
9 | 297 |
298 if (n < 0) return FALSE; | |
299 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
300 *row = n / VFICON_INFO(vf, columns); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
301 *col = n - (*row * VFICON_INFO(vf, columns)); |
9 | 302 |
303 return TRUE; | |
304 } | |
305 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
306 static gint vficon_find_iter(ViewFile *vf, IconData *id, GtkTreeIter *iter, gint *column) |
9 | 307 { |
308 GtkTreeModel *store; | |
309 gint row, col; | |
310 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
311 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
312 if (!vficon_find_position(vf, id, &row, &col)) return FALSE; |
9 | 313 if (!gtk_tree_model_iter_nth_child(store, iter, NULL, row)) return FALSE; |
314 if (column) *column = col; | |
315 | |
316 return TRUE; | |
317 } | |
318 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
319 static IconData *vficon_find_data(ViewFile *vf, gint row, gint col, GtkTreeIter *iter) |
9 | 320 { |
321 GtkTreeModel *store; | |
322 GtkTreeIter p; | |
323 | |
324 if (row < 0 || col < 0) return NULL; | |
325 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
326 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 327 if (gtk_tree_model_iter_nth_child(store, &p, NULL, row)) |
328 { | |
329 GList *list; | |
330 | |
331 gtk_tree_model_get(store, &p, FILE_COLUMN_POINTER, &list, -1); | |
332 if (!list) return NULL; | |
333 | |
334 if (iter) *iter = p; | |
335 | |
336 return g_list_nth_data(list, col); | |
337 } | |
338 | |
339 return NULL; | |
340 } | |
341 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
342 static IconData *vficon_find_data_by_coord(ViewFile *vf, gint x, gint y, GtkTreeIter *iter) |
9 | 343 { |
344 GtkTreePath *tpath; | |
345 GtkTreeViewColumn *column; | |
346 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
347 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), x, y, |
9 | 348 &tpath, &column, NULL, NULL)) |
349 { | |
350 GtkTreeModel *store; | |
351 GtkTreeIter row; | |
352 GList *list; | |
353 gint n; | |
354 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
355 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 356 gtk_tree_model_get_iter(store, &row, tpath); |
357 gtk_tree_path_free(tpath); | |
358 | |
359 gtk_tree_model_get(store, &row, FILE_COLUMN_POINTER, &list, -1); | |
360 | |
361 n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), "column_number")); | |
362 if (list) | |
363 { | |
364 if (iter) *iter = row; | |
365 return g_list_nth_data(list, n); | |
366 } | |
367 } | |
368 | |
369 return NULL; | |
370 } | |
371 | |
966 | 372 static void vficon_mark_toggled_cb(GtkCellRendererToggle *cell, gchar *path_str, gpointer data) |
373 { | |
374 ViewFile *vf = data; | |
375 GtkTreeModel *store; | |
376 GtkTreePath *path = gtk_tree_path_new_from_string(path_str); | |
377 GtkTreeIter row; | |
378 gint column; | |
379 GList *list; | |
380 guint toggled_mark; | |
967 | 381 IconData *id; |
966 | 382 |
383 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); | |
384 if (!path || !gtk_tree_model_get_iter(store, &row, path)) | |
385 return; | |
386 | |
387 gtk_tree_model_get(store, &row, FILE_COLUMN_POINTER, &list, -1); | |
388 | |
389 column = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cell), "column_number")); | |
390 g_object_get(G_OBJECT(cell), "toggled_mark", &toggled_mark, NULL); | |
391 | |
967 | 392 id = g_list_nth_data(list, column); |
966 | 393 if (id) |
394 { | |
395 FileData *fd = id->fd; | |
396 file_data_set_mark(fd, toggled_mark, !file_data_get_mark(fd, toggled_mark)); | |
397 } | |
398 } | |
399 | |
400 | |
9 | 401 /* |
402 *------------------------------------------------------------------- | |
403 * tooltip type window | |
404 *------------------------------------------------------------------- | |
405 */ | |
406 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
407 static void tip_show(ViewFile *vf) |
9 | 408 { |
409 GtkWidget *label; | |
410 gint x, y; | |
411 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
412 if (VFICON_INFO(vf, tip_window)) return; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
413 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
414 gdk_window_get_pointer(gtk_tree_view_get_bin_window(GTK_TREE_VIEW(vf->listview)), &x, &y, NULL); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
415 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
416 VFICON_INFO(vf, tip_id) = vficon_find_data_by_coord(vf, x, y, NULL); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
417 if (!VFICON_INFO(vf, tip_id)) return; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
418 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
419 VFICON_INFO(vf, tip_window) = gtk_window_new(GTK_WINDOW_POPUP); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
420 gtk_window_set_resizable(GTK_WINDOW(VFICON_INFO(vf, tip_window)), FALSE); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
421 gtk_container_set_border_width(GTK_CONTAINER(VFICON_INFO(vf, tip_window)), 2); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
422 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
423 label = gtk_label_new(VFICON_INFO(vf, tip_id)->fd->name); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
424 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
425 g_object_set_data(G_OBJECT(VFICON_INFO(vf, tip_window)), "tip_label", label); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
426 gtk_container_add(GTK_CONTAINER(VFICON_INFO(vf, tip_window)), label); |
9 | 427 gtk_widget_show(label); |
428 | |
429 gdk_window_get_pointer(NULL, &x, &y, NULL); | |
430 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
431 if (!GTK_WIDGET_REALIZED(VFICON_INFO(vf, tip_window))) gtk_widget_realize(VFICON_INFO(vf, tip_window)); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
432 gtk_window_move(GTK_WINDOW(VFICON_INFO(vf, tip_window)), x + 16, y + 16); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
433 gtk_widget_show(VFICON_INFO(vf, tip_window)); |
9 | 434 } |
435 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
436 static void tip_hide(ViewFile *vf) |
9 | 437 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
438 if (VFICON_INFO(vf, tip_window)) gtk_widget_destroy(VFICON_INFO(vf, tip_window)); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
439 VFICON_INFO(vf, tip_window) = NULL; |
9 | 440 } |
441 | |
442 static gint tip_schedule_cb(gpointer data) | |
443 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
444 ViewFile *vf = data; |
9 | 445 GtkWidget *window; |
446 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
447 if (VFICON_INFO(vf, tip_delay_id) == -1) return FALSE; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
448 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
449 window = gtk_widget_get_toplevel(vf->listview); |
9 | 450 |
451 if (GTK_WIDGET_SENSITIVE(window) && | |
452 GTK_WINDOW(window)->has_focus) | |
453 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
454 tip_show(vf); |
9 | 455 } |
456 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
457 VFICON_INFO(vf, tip_delay_id) = -1; |
9 | 458 return FALSE; |
459 } | |
460 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
461 static void tip_schedule(ViewFile *vf) |
9 | 462 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
463 tip_hide(vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
464 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
465 if (VFICON_INFO(vf, tip_delay_id) != -1) |
9 | 466 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
467 g_source_remove(VFICON_INFO(vf, tip_delay_id)); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
468 VFICON_INFO(vf, tip_delay_id) = -1; |
9 | 469 } |
470 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
471 if (!VFICON_INFO(vf, show_text)) |
9 | 472 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
473 VFICON_INFO(vf, tip_delay_id) = g_timeout_add(VFICON_TIP_DELAY, tip_schedule_cb, vf); |
9 | 474 } |
475 } | |
476 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
477 static void tip_unschedule(ViewFile *vf) |
9 | 478 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
479 tip_hide(vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
480 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
481 if (VFICON_INFO(vf, tip_delay_id) != -1) g_source_remove(VFICON_INFO(vf, tip_delay_id)); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
482 VFICON_INFO(vf, tip_delay_id) = -1; |
9 | 483 } |
484 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
485 static void tip_update(ViewFile *vf, IconData *id) |
9 | 486 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
487 if (VFICON_INFO(vf, tip_window)) |
9 | 488 { |
489 gint x, y; | |
490 | |
491 gdk_window_get_pointer(NULL, &x, &y, NULL); | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
492 gtk_window_move(GTK_WINDOW(VFICON_INFO(vf, tip_window)), x + 16, y + 16); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
493 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
494 if (id != VFICON_INFO(vf, tip_id)) |
9 | 495 { |
496 GtkWidget *label; | |
497 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
498 VFICON_INFO(vf, tip_id) = id; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
499 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
500 if (!VFICON_INFO(vf, tip_id)) |
9 | 501 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
502 tip_hide(vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
503 tip_schedule(vf); |
9 | 504 return; |
505 } | |
506 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
507 label = g_object_get_data(G_OBJECT(VFICON_INFO(vf, tip_window)), "tip_label"); |
583
de3e2bc22336
Revert patch 675, and correctly fix gtk assertion failure.
zas_
parents:
582
diff
changeset
|
508 gtk_label_set_text(GTK_LABEL(label), VFICON_INFO(vf, tip_id)->fd->name); |
9 | 509 } |
510 } | |
511 else | |
512 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
513 tip_schedule(vf); |
9 | 514 } |
515 } | |
516 | |
517 /* | |
518 *------------------------------------------------------------------- | |
519 * dnd | |
520 *------------------------------------------------------------------- | |
521 */ | |
522 | |
523 static void vficon_dnd_get(GtkWidget *widget, GdkDragContext *context, | |
524 GtkSelectionData *selection_data, guint info, | |
525 guint time, gpointer data) | |
526 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
527 ViewFile *vf = data; |
9 | 528 GList *list = NULL; |
529 gchar *uri_text = NULL; | |
530 gint total; | |
531 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
532 if (!VFICON_INFO(vf, click_id)) return; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
533 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
534 if (VFICON_INFO(vf, click_id)->selected & SELECTION_SELECTED) |
9 | 535 { |
633 | 536 list = vf_selection_get_list(vf); |
9 | 537 } |
538 else | |
539 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
540 list = g_list_append(NULL, file_data_ref(VFICON_INFO(vf, click_id)->fd)); |
9 | 541 } |
542 | |
543 if (!list) return; | |
138 | 544 uri_text = uri_text_from_filelist(list, &total, (info == TARGET_TEXT_PLAIN)); |
545 filelist_free(list); | |
9 | 546 |
495 | 547 DEBUG_1(uri_text); |
9 | 548 |
549 gtk_selection_data_set(selection_data, selection_data->target, | |
64
04ff0df3ad2f
Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
550 8, (guchar *)uri_text, total); |
9 | 551 g_free(uri_text); |
552 } | |
553 | |
554 static void vficon_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
555 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
556 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
557 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
558 tip_unschedule(vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
559 |
845 | 560 if (VFICON_INFO(vf, click_id) && VFICON_INFO(vf, click_id)->fd->thumb_pixbuf) |
9 | 561 { |
562 gint items; | |
563 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
564 if (VFICON_INFO(vf, click_id)->selected & SELECTION_SELECTED) |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
565 items = g_list_length(VFICON_INFO(vf, selection)); |
9 | 566 else |
567 items = 1; | |
568 | |
845 | 569 dnd_set_drag_icon(widget, context, VFICON_INFO(vf, click_id)->fd->thumb_pixbuf, items); |
9 | 570 } |
571 } | |
572 | |
573 static void vficon_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
574 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
575 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
576 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
577 vficon_selection_remove(vf, VFICON_INFO(vf, click_id), SELECTION_PRELIGHT, NULL); |
9 | 578 |
579 if (context->action == GDK_ACTION_MOVE) | |
580 { | |
633 | 581 vf_refresh(vf); |
9 | 582 } |
583 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
584 tip_unschedule(vf); |
9 | 585 } |
586 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
587 void vficon_dnd_init(ViewFile *vf) |
9 | 588 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
589 gtk_drag_source_set(vf->listview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, |
9 | 590 dnd_file_drag_types, dnd_file_drag_types_count, |
591 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
592 g_signal_connect(G_OBJECT(vf->listview), "drag_data_get", |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
593 G_CALLBACK(vficon_dnd_get), vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
594 g_signal_connect(G_OBJECT(vf->listview), "drag_begin", |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
595 G_CALLBACK(vficon_dnd_begin), vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
596 g_signal_connect(G_OBJECT(vf->listview), "drag_end", |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
597 G_CALLBACK(vficon_dnd_end), vf); |
9 | 598 } |
599 | |
600 /* | |
601 *------------------------------------------------------------------- | |
602 * cell updates | |
603 *------------------------------------------------------------------- | |
604 */ | |
605 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
606 static void vficon_selection_set(ViewFile *vf, IconData *id, SelectionType value, GtkTreeIter *iter) |
9 | 607 { |
608 GtkTreeModel *store; | |
609 GList *list; | |
610 | |
138 | 611 if (!id) return; |
612 | |
9 | 613 |
614 if (id->selected == value) return; | |
615 id->selected = value; | |
616 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
617 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 618 if (iter) |
619 { | |
620 gtk_tree_model_get(store, iter, FILE_COLUMN_POINTER, &list, -1); | |
621 if (list) gtk_list_store_set(GTK_LIST_STORE(store), iter, FILE_COLUMN_POINTER, list, -1); | |
622 } | |
623 else | |
624 { | |
625 GtkTreeIter row; | |
626 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
627 if (vficon_find_iter(vf, id, &row, NULL)) |
9 | 628 { |
629 gtk_tree_model_get(store, &row, FILE_COLUMN_POINTER, &list, -1); | |
630 if (list) gtk_list_store_set(GTK_LIST_STORE(store), &row, FILE_COLUMN_POINTER, list, -1); | |
631 } | |
632 } | |
633 } | |
634 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
635 static void vficon_selection_add(ViewFile *vf, IconData *id, SelectionType mask, GtkTreeIter *iter) |
9 | 636 { |
138 | 637 if (!id) return; |
638 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
639 vficon_selection_set(vf, id, id->selected | mask, iter); |
9 | 640 } |
641 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
642 static void vficon_selection_remove(ViewFile *vf, IconData *id, SelectionType mask, GtkTreeIter *iter) |
9 | 643 { |
138 | 644 if (!id) return; |
645 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
646 vficon_selection_set(vf, id, id->selected & ~mask, iter); |
9 | 647 } |
648 | |
852 | 649 void vficon_marks_set(ViewFile *vf, gint enable) |
650 { | |
651 vficon_populate_at_new_size(vf, vf->listview->allocation.width, vf->listview->allocation.height, TRUE); | |
652 } | |
653 | |
9 | 654 /* |
655 *------------------------------------------------------------------- | |
656 * selections | |
657 *------------------------------------------------------------------- | |
658 */ | |
659 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
660 static void vficon_verify_selections(ViewFile *vf) |
9 | 661 { |
662 GList *work; | |
663 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
664 work = VFICON_INFO(vf, selection); |
9 | 665 while (work) |
666 { | |
138 | 667 IconData *id = work->data; |
9 | 668 work = work->next; |
577 | 669 |
670 if (vficon_index_by_id(vf, id) >= 0) continue; | |
671 | |
672 VFICON_INFO(vf, selection) = g_list_remove(VFICON_INFO(vf, selection), id); | |
9 | 673 } |
674 } | |
675 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
676 void vficon_select_all(ViewFile *vf) |
9 | 677 { |
678 GList *work; | |
679 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
680 g_list_free(VFICON_INFO(vf, selection)); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
681 VFICON_INFO(vf, selection) = NULL; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
682 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
683 work = vf->list; |
9 | 684 while (work) |
685 { | |
138 | 686 IconData *id = work->data; |
577 | 687 work = work->next; |
688 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
689 VFICON_INFO(vf, selection) = g_list_append(VFICON_INFO(vf, selection), id); |
577 | 690 vficon_selection_add(vf, id, SELECTION_SELECTED, NULL); |
9 | 691 } |
692 | |
633 | 693 vf_send_update(vf); |
9 | 694 } |
695 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
696 void vficon_select_none(ViewFile *vf) |
9 | 697 { |
698 GList *work; | |
699 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
700 work = VFICON_INFO(vf, selection); |
9 | 701 while (work) |
702 { | |
577 | 703 IconData *id = work->data; |
9 | 704 work = work->next; |
577 | 705 |
706 vficon_selection_remove(vf, id, SELECTION_SELECTED, NULL); | |
9 | 707 } |
708 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
709 g_list_free(VFICON_INFO(vf, selection)); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
710 VFICON_INFO(vf, selection) = NULL; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
711 |
633 | 712 vf_send_update(vf); |
9 | 713 } |
714 | |
601 | 715 void vficon_select_invert(ViewFile *vf) |
716 { | |
717 GList *work; | |
718 | |
719 work = vf->list; | |
720 while (work) | |
721 { | |
722 IconData *id = work->data; | |
723 work = work->next; | |
724 | |
725 if (id->selected & SELECTION_SELECTED) | |
726 { | |
727 VFICON_INFO(vf, selection) = g_list_remove(VFICON_INFO(vf, selection), id); | |
728 vficon_selection_remove(vf, id, SELECTION_SELECTED, NULL); | |
729 } | |
730 else | |
731 { | |
732 VFICON_INFO(vf, selection) = g_list_append(VFICON_INFO(vf, selection), id); | |
733 vficon_selection_add(vf, id, SELECTION_SELECTED, NULL); | |
734 } | |
735 } | |
736 | |
633 | 737 vf_send_update(vf); |
601 | 738 } |
739 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
740 static void vficon_select(ViewFile *vf, IconData *id) |
9 | 741 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
742 VFICON_INFO(vf, prev_selection) = id; |
138 | 743 |
744 if (!id || id->selected & SELECTION_SELECTED) return; | |
745 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
746 VFICON_INFO(vf, selection) = g_list_append(VFICON_INFO(vf, selection), id); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
747 vficon_selection_add(vf, id, SELECTION_SELECTED, NULL); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
748 |
633 | 749 vf_send_update(vf); |
9 | 750 } |
751 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
752 static void vficon_unselect(ViewFile *vf, IconData *id) |
9 | 753 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
754 VFICON_INFO(vf, prev_selection) = id; |
138 | 755 |
756 if (!id || !(id->selected & SELECTION_SELECTED) ) return; | |
757 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
758 VFICON_INFO(vf, selection) = g_list_remove(VFICON_INFO(vf, selection), id); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
759 vficon_selection_remove(vf, id, SELECTION_SELECTED, NULL); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
760 |
633 | 761 vf_send_update(vf); |
9 | 762 } |
763 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
764 static void vficon_select_util(ViewFile *vf, IconData *id, gint select) |
9 | 765 { |
766 if (select) | |
767 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
768 vficon_select(vf, id); |
9 | 769 } |
770 else | |
771 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
772 vficon_unselect(vf, id); |
9 | 773 } |
774 } | |
775 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
776 static void vficon_select_region_util(ViewFile *vf, IconData *start, IconData *end, gint select) |
9 | 777 { |
778 gint row1, col1; | |
779 gint row2, col2; | |
780 gint t; | |
781 gint i, j; | |
782 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
783 if (!vficon_find_position(vf, start, &row1, &col1) || |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
784 !vficon_find_position(vf, end, &row2, &col2) ) return; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
785 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
786 VFICON_INFO(vf, prev_selection) = end; |
9 | 787 |
330 | 788 if (!options->collections.rectangular_selection) |
9 | 789 { |
790 GList *work; | |
138 | 791 IconData *id; |
9 | 792 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
793 if (g_list_index(vf->list, start) > g_list_index(vf->list, end)) |
9 | 794 { |
138 | 795 id = start; |
9 | 796 start = end; |
138 | 797 end = id; |
9 | 798 } |
799 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
800 work = g_list_find(vf->list, start); |
9 | 801 while (work) |
802 { | |
138 | 803 id = work->data; |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
804 vficon_select_util(vf, id, select); |
442 | 805 |
9 | 806 if (work->data != end) |
807 work = work->next; | |
808 else | |
809 work = NULL; | |
810 } | |
811 return; | |
812 } | |
813 | |
814 if (row2 < row1) | |
815 { | |
816 t = row1; | |
817 row1 = row2; | |
818 row2 = t; | |
819 } | |
820 if (col2 < col1) | |
821 { | |
822 t = col1; | |
823 col1 = col2; | |
824 col2 = t; | |
825 } | |
826 | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
499
diff
changeset
|
827 DEBUG_1("table: %d x %d to %d x %d", row1, col1, row2, col2); |
9 | 828 |
829 for (i = row1; i <= row2; i++) | |
830 { | |
831 for (j = col1; j <= col2; j++) | |
832 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
833 IconData *id = vficon_find_data(vf, i, j, NULL); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
834 if (id) vficon_select_util(vf, id, select); |
9 | 835 } |
836 } | |
837 } | |
838 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
839 gint vficon_index_is_selected(ViewFile *vf, gint row) |
9 | 840 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
841 IconData *id = g_list_nth_data(vf->list, row); |
138 | 842 |
843 if (!id) return FALSE; | |
844 | |
845 return (id->selected & SELECTION_SELECTED); | |
9 | 846 } |
847 | |
736 | 848 guint vficon_selection_count(ViewFile *vf, gint64 *bytes) |
9 | 849 { |
850 if (bytes) | |
851 { | |
852 gint64 b = 0; | |
853 GList *work; | |
854 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
855 work = VFICON_INFO(vf, selection); |
9 | 856 while (work) |
857 { | |
138 | 858 IconData *id = work->data; |
859 FileData *fd = id->fd; | |
442 | 860 g_assert(fd->magick == 0x12345678); |
9 | 861 b += fd->size; |
862 | |
863 work = work->next; | |
864 } | |
865 | |
866 *bytes = b; | |
867 } | |
868 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
869 return g_list_length(VFICON_INFO(vf, selection)); |
9 | 870 } |
871 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
872 GList *vficon_selection_get_list(ViewFile *vf) |
9 | 873 { |
874 GList *list = NULL; | |
875 GList *work; | |
876 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
877 work = VFICON_INFO(vf, selection); |
9 | 878 while (work) |
879 { | |
138 | 880 IconData *id = work->data; |
881 FileData *fd = id->fd; | |
442 | 882 g_assert(fd->magick == 0x12345678); |
138 | 883 |
884 list = g_list_prepend(list, file_data_ref(fd)); | |
9 | 885 |
886 work = work->next; | |
887 } | |
888 | |
889 list = g_list_reverse(list); | |
890 | |
891 return list; | |
892 } | |
893 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
894 GList *vficon_selection_get_list_by_index(ViewFile *vf) |
9 | 895 { |
896 GList *list = NULL; | |
897 GList *work; | |
898 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
899 work = VFICON_INFO(vf, selection); |
9 | 900 while (work) |
901 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
902 list = g_list_prepend(list, GINT_TO_POINTER(g_list_index(vf->list, work->data))); |
9 | 903 work = work->next; |
904 } | |
905 | |
906 return g_list_reverse(list); | |
907 } | |
908 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
909 static void vficon_select_by_id(ViewFile *vf, IconData *id) |
138 | 910 { |
911 if (!id) return; | |
912 | |
913 if (!(id->selected & SELECTION_SELECTED)) | |
914 { | |
633 | 915 vf_select_none(vf); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
916 vficon_select(vf, id); |
138 | 917 } |
918 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
919 vficon_set_focus(vf, id); |
138 | 920 } |
921 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
922 void vficon_select_by_fd(ViewFile *vf, FileData *fd) |
138 | 923 { |
924 IconData *id = NULL; | |
925 GList *work; | |
9 | 926 |
927 if (!fd) return; | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
928 work = vf->list; |
138 | 929 while (work && !id) |
9 | 930 { |
138 | 931 IconData *chk = work->data; |
932 work = work->next; | |
933 if (chk->fd == fd) id = chk; | |
9 | 934 } |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
935 vficon_select_by_id(vf, id); |
9 | 936 } |
937 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
938 void vficon_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode) |
165 | 939 { |
940 GList *work; | |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
941 gint n = mark - 1; |
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
942 |
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
943 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE); |
165 | 944 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
945 work = vf->list; |
165 | 946 while (work) |
947 { | |
948 IconData *id = work->data; | |
949 FileData *fd = id->fd; | |
950 gboolean mark_val, selected; | |
951 | |
442 | 952 g_assert(fd->magick == 0x12345678); |
165 | 953 |
800 | 954 mark_val = file_data_get_mark(fd, n); |
165 | 955 selected = (id->selected & SELECTION_SELECTED); |
442 | 956 |
957 switch (mode) | |
165 | 958 { |
959 case MTS_MODE_SET: selected = mark_val; | |
960 break; | |
961 case MTS_MODE_OR: selected = mark_val | selected; | |
962 break; | |
963 case MTS_MODE_AND: selected = mark_val & selected; | |
964 break; | |
965 case MTS_MODE_MINUS: selected = !mark_val & selected; | |
966 break; | |
967 } | |
442 | 968 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
969 vficon_select_util(vf, id, selected); |
165 | 970 |
971 work = work->next; | |
972 } | |
973 } | |
974 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
975 void vficon_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode) |
165 | 976 { |
977 GList *slist; | |
978 GList *work; | |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
979 gint n = mark -1; |
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
980 |
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
981 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE); |
165 | 982 |
633 | 983 slist = vf_selection_get_list(vf); |
165 | 984 work = slist; |
985 while (work) | |
986 { | |
987 FileData *fd = work->data; | |
442 | 988 |
165 | 989 switch (mode) |
990 { | |
800 | 991 case STM_MODE_SET: file_data_set_mark(fd, n, 1); |
165 | 992 break; |
800 | 993 case STM_MODE_RESET: file_data_set_mark(fd, n, 0); |
165 | 994 break; |
800 | 995 case STM_MODE_TOGGLE: file_data_set_mark(fd, n, !file_data_get_mark(fd, n)); |
165 | 996 break; |
997 } | |
998 work = work->next; | |
999 } | |
1000 filelist_free(slist); | |
1001 } | |
138 | 1002 |
811 | 1003 static void vficon_select_closest(ViewFile *vf, FileData *sel_fd) |
1004 { | |
1005 GList *work; | |
1006 | |
1007 if (sel_fd->parent) sel_fd = sel_fd->parent; | |
1008 work = vf->list; | |
1009 | |
1010 while (work) | |
1011 { | |
1012 gint match; | |
1013 IconData *id = work->data; | |
1014 FileData *fd = id->fd; | |
1015 work = work->next; | |
1016 | |
1017 | |
1018 match = filelist_sort_compare_filedata_full(fd, sel_fd, vf->sort_method, vf->sort_ascend); | |
1019 | |
1020 if (match >= 0) | |
1021 { | |
1022 vficon_select(vf, id); | |
831
b02a24ebf441
fixed iconview update after deletion of selected image
nadvornik
parents:
817
diff
changeset
|
1023 vficon_send_layout_select(vf, id); |
811 | 1024 break; |
1025 } | |
1026 } | |
1027 | |
1028 } | |
1029 | |
138 | 1030 |
9 | 1031 /* |
1032 *------------------------------------------------------------------- | |
1033 * focus | |
1034 *------------------------------------------------------------------- | |
1035 */ | |
1036 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1037 static void vficon_move_focus(ViewFile *vf, gint row, gint col, gint relative) |
9 | 1038 { |
1039 gint new_row; | |
1040 gint new_col; | |
1041 | |
1042 if (relative) | |
1043 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1044 new_row = VFICON_INFO(vf, focus_row); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1045 new_col = VFICON_INFO(vf, focus_column); |
9 | 1046 |
1047 new_row += row; | |
1048 if (new_row < 0) new_row = 0; | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1049 if (new_row >= VFICON_INFO(vf, rows)) new_row = VFICON_INFO(vf, rows) - 1; |
9 | 1050 |
516 | 1051 while (col != 0) |
9 | 1052 { |
1053 if (col < 0) | |
1054 { | |
1055 new_col--; | |
1056 col++; | |
1057 } | |
1058 else | |
1059 { | |
1060 new_col++; | |
1061 col--; | |
1062 } | |
1063 | |
1064 if (new_col < 0) | |
1065 { | |
1066 if (new_row > 0) | |
1067 { | |
1068 new_row--; | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1069 new_col = VFICON_INFO(vf, columns) - 1; |
9 | 1070 } |
1071 else | |
1072 { | |
1073 new_col = 0; | |
1074 } | |
1075 } | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1076 if (new_col >= VFICON_INFO(vf, columns)) |
9 | 1077 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1078 if (new_row < VFICON_INFO(vf, rows) - 1) |
9 | 1079 { |
1080 new_row++; | |
1081 new_col = 0; | |
1082 } | |
1083 else | |
1084 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1085 new_col = VFICON_INFO(vf, columns) - 1; |
9 | 1086 } |
1087 } | |
1088 } | |
1089 } | |
1090 else | |
1091 { | |
1092 new_row = row; | |
1093 new_col = col; | |
1094 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1095 if (new_row >= VFICON_INFO(vf, rows)) |
9 | 1096 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1097 if (VFICON_INFO(vf, rows) > 0) |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1098 new_row = VFICON_INFO(vf, rows) - 1; |
9 | 1099 else |
1100 new_row = 0; | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1101 new_col = VFICON_INFO(vf, columns) - 1; |
9 | 1102 } |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1103 if (new_col >= VFICON_INFO(vf, columns)) new_col = VFICON_INFO(vf, columns) - 1; |
9 | 1104 } |
1105 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1106 if (new_row == VFICON_INFO(vf, rows) - 1) |
9 | 1107 { |
1108 gint l; | |
1109 | |
1110 /* if we moved beyond the last image, go to the last image */ | |
1111 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1112 l = g_list_length(vf->list); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1113 if (VFICON_INFO(vf, rows) > 1) l -= (VFICON_INFO(vf, rows) - 1) * VFICON_INFO(vf, columns); |
9 | 1114 if (new_col >= l) new_col = l - 1; |
1115 } | |
1116 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1117 vficon_set_focus(vf, vficon_find_data(vf, new_row, new_col, NULL)); |
9 | 1118 } |
1119 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1120 static void vficon_set_focus(ViewFile *vf, IconData *id) |
9 | 1121 { |
1122 GtkTreeIter iter; | |
1123 gint row, col; | |
1124 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1125 if (g_list_find(vf->list, VFICON_INFO(vf, focus_id))) |
9 | 1126 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1127 if (id == VFICON_INFO(vf, focus_id)) |
9 | 1128 { |
1129 /* ensure focus row col are correct */ | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1130 vficon_find_position(vf, VFICON_INFO(vf, focus_id), &VFICON_INFO(vf, focus_row), &VFICON_INFO(vf, focus_column)); |
9 | 1131 return; |
1132 } | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1133 vficon_selection_remove(vf, VFICON_INFO(vf, focus_id), SELECTION_FOCUS, NULL); |
9 | 1134 } |
1135 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1136 if (!vficon_find_position(vf, id, &row, &col)) |
9 | 1137 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1138 VFICON_INFO(vf, focus_id) = NULL; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1139 VFICON_INFO(vf, focus_row) = -1; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1140 VFICON_INFO(vf, focus_column) = -1; |
9 | 1141 return; |
1142 } | |
1143 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1144 VFICON_INFO(vf, focus_id) = id; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1145 VFICON_INFO(vf, focus_row) = row; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1146 VFICON_INFO(vf, focus_column) = col; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1147 vficon_selection_add(vf, VFICON_INFO(vf, focus_id), SELECTION_FOCUS, NULL); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1148 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1149 if (vficon_find_iter(vf, VFICON_INFO(vf, focus_id), &iter, NULL)) |
9 | 1150 { |
1151 GtkTreePath *tpath; | |
1152 GtkTreeViewColumn *column; | |
1153 GtkTreeModel *store; | |
1154 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1155 tree_view_row_make_visible(GTK_TREE_VIEW(vf->listview), &iter, FALSE); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1156 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1157 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 1158 tpath = gtk_tree_model_get_path(store, &iter); |
1159 /* focus is set to an extra column with 0 width to hide focus, we draw it ourself */ | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1160 column = gtk_tree_view_get_column(GTK_TREE_VIEW(vf->listview), VFICON_MAX_COLUMNS); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1161 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vf->listview), tpath, column, FALSE); |
9 | 1162 gtk_tree_path_free(tpath); |
1163 } | |
1164 } | |
1165 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1166 static void vficon_update_focus(ViewFile *vf) |
9 | 1167 { |
1168 gint new_row = 0; | |
1169 gint new_col = 0; | |
1170 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1171 if (VFICON_INFO(vf, focus_id) && vficon_find_position(vf, VFICON_INFO(vf, focus_id), &new_row, &new_col)) |
9 | 1172 { |
1173 /* first find the old focus, if it exists and is valid */ | |
1174 } | |
1175 else | |
1176 { | |
1177 /* (try to) stay where we were */ | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1178 new_row = VFICON_INFO(vf, focus_row); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1179 new_col = VFICON_INFO(vf, focus_column); |
9 | 1180 } |
1181 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1182 vficon_move_focus(vf, new_row, new_col, FALSE); |
9 | 1183 } |
1184 | |
1185 /* used to figure the page up/down distances */ | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1186 static gint page_height(ViewFile *vf) |
9 | 1187 { |
1188 GtkAdjustment *adj; | |
1189 gint page_size; | |
1190 gint row_height; | |
1191 gint ret; | |
1192 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1193 adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vf->listview)); |
9 | 1194 page_size = (gint)adj->page_increment; |
1195 | |
333 | 1196 row_height = options->thumbnails.max_height + THUMB_BORDER_PADDING * 2; |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1197 if (VFICON_INFO(vf, show_text)) row_height += options->thumbnails.max_height / 3; |
9 | 1198 |
1199 ret = page_size / row_height; | |
1200 if (ret < 1) ret = 1; | |
1201 | |
1202 return ret; | |
1203 } | |
1204 | |
1205 /* | |
1206 *------------------------------------------------------------------- | |
1207 * keyboard | |
1208 *------------------------------------------------------------------- | |
1209 */ | |
1210 | |
1211 static void vfi_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) | |
1212 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1213 ViewFile *vf = data; |
9 | 1214 GtkTreeModel *store; |
1215 GtkTreeIter iter; | |
1216 gint column; | |
1217 GtkTreePath *tpath; | |
1218 gint cw, ch; | |
1219 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1220 if (!vficon_find_iter(vf, VFICON_INFO(vf, click_id), &iter, &column)) return; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1221 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 1222 tpath = gtk_tree_model_get_path(store, &iter); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1223 tree_view_get_cell_clamped(GTK_TREE_VIEW(vf->listview), tpath, column, FALSE, x, y, &cw, &ch); |
9 | 1224 gtk_tree_path_free(tpath); |
1225 *y += ch; | |
1226 popup_menu_position_clamp(menu, x, y, 0); | |
1227 } | |
1228 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
562
diff
changeset
|
1229 gint vficon_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
9 | 1230 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1231 ViewFile *vf = data; |
9 | 1232 gint focus_row = 0; |
1233 gint focus_col = 0; | |
138 | 1234 IconData *id; |
85
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1235 gint stop_signal; |
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1236 |
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1237 stop_signal = TRUE; |
9 | 1238 switch (event->keyval) |
1239 { | |
1240 case GDK_Left: case GDK_KP_Left: | |
1241 focus_col = -1; | |
1242 break; | |
1243 case GDK_Right: case GDK_KP_Right: | |
1244 focus_col = 1; | |
1245 break; | |
1246 case GDK_Up: case GDK_KP_Up: | |
1247 focus_row = -1; | |
1248 break; | |
1249 case GDK_Down: case GDK_KP_Down: | |
1250 focus_row = 1; | |
1251 break; | |
1252 case GDK_Page_Up: case GDK_KP_Page_Up: | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1253 focus_row = -page_height(vf); |
9 | 1254 break; |
1255 case GDK_Page_Down: case GDK_KP_Page_Down: | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1256 focus_row = page_height(vf); |
9 | 1257 break; |
1258 case GDK_Home: case GDK_KP_Home: | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1259 focus_row = -VFICON_INFO(vf, focus_row); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1260 focus_col = -VFICON_INFO(vf, focus_column); |
9 | 1261 break; |
1262 case GDK_End: case GDK_KP_End: | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1263 focus_row = VFICON_INFO(vf, rows) - 1 - VFICON_INFO(vf, focus_row); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1264 focus_col = VFICON_INFO(vf, columns) - 1 - VFICON_INFO(vf, focus_column); |
9 | 1265 break; |
1266 case GDK_space: | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1267 id = vficon_find_data(vf, VFICON_INFO(vf, focus_row), VFICON_INFO(vf, focus_column), NULL); |
138 | 1268 if (id) |
9 | 1269 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1270 VFICON_INFO(vf, click_id) = id; |
9 | 1271 if (event->state & GDK_CONTROL_MASK) |
1272 { | |
1273 gint selected; | |
1274 | |
138 | 1275 selected = id->selected & SELECTION_SELECTED; |
9 | 1276 if (selected) |
1277 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1278 vficon_unselect(vf, id); |
9 | 1279 } |
1280 else | |
1281 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1282 vficon_select(vf, id); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1283 vficon_send_layout_select(vf, id); |
9 | 1284 } |
1285 } | |
1286 else | |
1287 { | |
633 | 1288 vf_select_none(vf); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1289 vficon_select(vf, id); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1290 vficon_send_layout_select(vf, id); |
9 | 1291 } |
1292 } | |
1293 break; | |
1294 case GDK_Menu: | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1295 id = vficon_find_data(vf, VFICON_INFO(vf, focus_row), VFICON_INFO(vf, focus_column), NULL); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1296 VFICON_INFO(vf, click_id) = id; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1297 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1298 vficon_selection_add(vf, VFICON_INFO(vf, click_id), SELECTION_PRELIGHT, NULL); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1299 tip_unschedule(vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1300 |
659
542bb47fef04
Merge vflist_pop_menu() and vficon_pop_menu() into vf_pop_menu().
zas_
parents:
658
diff
changeset
|
1301 vf->popup = vf_pop_menu(vf); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1302 gtk_menu_popup(GTK_MENU(vf->popup), NULL, NULL, vfi_menu_position_cb, vf, 0, GDK_CURRENT_TIME); |
9 | 1303 break; |
1304 default: | |
85
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1305 stop_signal = FALSE; |
9 | 1306 break; |
1307 } | |
1308 | |
1309 if (focus_row != 0 || focus_col != 0) | |
1310 { | |
138 | 1311 IconData *new_id; |
1312 IconData *old_id; | |
1313 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1314 old_id = vficon_find_data(vf, VFICON_INFO(vf, focus_row), VFICON_INFO(vf, focus_column), NULL); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1315 vficon_move_focus(vf, focus_row, focus_col, TRUE); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1316 new_id = vficon_find_data(vf, VFICON_INFO(vf, focus_row), VFICON_INFO(vf, focus_column), NULL); |
138 | 1317 |
1318 if (new_id != old_id) | |
9 | 1319 { |
1320 if (event->state & GDK_SHIFT_MASK) | |
1321 { | |
330 | 1322 if (!options->collections.rectangular_selection) |
9 | 1323 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1324 vficon_select_region_util(vf, old_id, new_id, FALSE); |
9 | 1325 } |
1326 else | |
1327 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1328 vficon_select_region_util(vf, VFICON_INFO(vf, click_id), old_id, FALSE); |
9 | 1329 } |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1330 vficon_select_region_util(vf, VFICON_INFO(vf, click_id), new_id, TRUE); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1331 vficon_send_layout_select(vf, new_id); |
9 | 1332 } |
1333 else if (event->state & GDK_CONTROL_MASK) | |
1334 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1335 VFICON_INFO(vf, click_id) = new_id; |
9 | 1336 } |
1337 else | |
1338 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1339 VFICON_INFO(vf, click_id) = new_id; |
633 | 1340 vf_select_none(vf); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1341 vficon_select(vf, new_id); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1342 vficon_send_layout_select(vf, new_id); |
9 | 1343 } |
1344 } | |
1345 } | |
1346 | |
1347 if (stop_signal) | |
1348 { | |
85
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1349 #if 0 |
9 | 1350 g_signal_stop_emission_by_name(GTK_OBJECT(widget), "key_press_event"); |
85
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1351 #endif |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1352 tip_unschedule(vf); |
9 | 1353 } |
1354 | |
1355 return stop_signal; | |
1356 } | |
1357 | |
1358 /* | |
1359 *------------------------------------------------------------------- | |
1360 * mouse | |
1361 *------------------------------------------------------------------- | |
1362 */ | |
1363 | |
1364 static gint vficon_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) | |
1365 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1366 ViewFile *vf = data; |
138 | 1367 IconData *id; |
1368 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1369 id = vficon_find_data_by_coord(vf, (gint)bevent->x, (gint)bevent->y, NULL); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1370 tip_update(vf, id); |
9 | 1371 |
1372 return FALSE; | |
1373 } | |
1374 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
562
diff
changeset
|
1375 gint vficon_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
9 | 1376 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1377 ViewFile *vf = data; |
9 | 1378 GtkTreeIter iter; |
138 | 1379 IconData *id; |
9 | 1380 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1381 tip_unschedule(vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1382 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1383 id = vficon_find_data_by_coord(vf, (gint)bevent->x, (gint)bevent->y, &iter); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1384 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1385 VFICON_INFO(vf, click_id) = id; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1386 vficon_selection_add(vf, VFICON_INFO(vf, click_id), SELECTION_PRELIGHT, &iter); |
9 | 1387 |
1388 switch (bevent->button) | |
1389 { | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
1390 case MOUSE_BUTTON_LEFT: |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1391 if (!GTK_WIDGET_HAS_FOCUS(vf->listview)) |
9 | 1392 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1393 gtk_widget_grab_focus(vf->listview); |
9 | 1394 } |
1395 #if 0 | |
1396 if (bevent->type == GDK_2BUTTON_PRESS && | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1397 vf->layout) |
9 | 1398 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1399 vficon_selection_remove(vf, VFICON_INFO(vf, click_id), SELECTION_PRELIGHT, &iter); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1400 layout_image_full_screen_start(vf->layout); |
9 | 1401 } |
1402 #endif | |
1403 break; | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
1404 case MOUSE_BUTTON_RIGHT: |
659
542bb47fef04
Merge vflist_pop_menu() and vficon_pop_menu() into vf_pop_menu().
zas_
parents:
658
diff
changeset
|
1405 vf->popup = vf_pop_menu(vf); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1406 gtk_menu_popup(GTK_MENU(vf->popup), NULL, NULL, NULL, NULL, bevent->button, bevent->time); |
9 | 1407 break; |
1408 default: | |
1409 break; | |
1410 } | |
1411 | |
966 | 1412 return FALSE; |
9 | 1413 } |
1414 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
562
diff
changeset
|
1415 gint vficon_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
9 | 1416 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1417 ViewFile *vf = data; |
9 | 1418 GtkTreeIter iter; |
138 | 1419 IconData *id = NULL; |
580 | 1420 gint was_selected; |
9 | 1421 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1422 tip_schedule(vf); |
9 | 1423 |
580 | 1424 if ((gint)bevent->x != 0 || (gint)bevent->y != 0) |
9 | 1425 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1426 id = vficon_find_data_by_coord(vf, (gint)bevent->x, (gint)bevent->y, &iter); |
9 | 1427 } |
1428 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1429 if (VFICON_INFO(vf, click_id)) |
9 | 1430 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1431 vficon_selection_remove(vf, VFICON_INFO(vf, click_id), SELECTION_PRELIGHT, NULL); |
9 | 1432 } |
1433 | |
580 | 1434 if (!id || VFICON_INFO(vf, click_id) != id) return TRUE; |
1435 | |
1436 was_selected = (id->selected & SELECTION_SELECTED); | |
1437 | |
1438 switch (bevent->button) | |
9 | 1439 { |
580 | 1440 case MOUSE_BUTTON_LEFT: |
9 | 1441 { |
580 | 1442 vficon_set_focus(vf, id); |
1443 | |
1444 if (bevent->state & GDK_CONTROL_MASK) | |
9 | 1445 { |
580 | 1446 gint select; |
1447 | |
1448 select = !(id->selected & SELECTION_SELECTED); | |
1449 if ((bevent->state & GDK_SHIFT_MASK) && VFICON_INFO(vf, prev_selection)) | |
1450 { | |
1451 vficon_select_region_util(vf, VFICON_INFO(vf, prev_selection), id, select); | |
1452 } | |
1453 else | |
1454 { | |
1455 vficon_select_util(vf, id, select); | |
1456 } | |
9 | 1457 } |
1458 else | |
1459 { | |
633 | 1460 vf_select_none(vf); |
580 | 1461 |
1462 if ((bevent->state & GDK_SHIFT_MASK) && VFICON_INFO(vf, prev_selection)) | |
1463 { | |
1464 vficon_select_region_util(vf, VFICON_INFO(vf, prev_selection), id, TRUE); | |
1465 } | |
1466 else | |
1467 { | |
1468 vficon_select_util(vf, id, TRUE); | |
1469 was_selected = FALSE; | |
1470 } | |
9 | 1471 } |
1472 } | |
580 | 1473 break; |
1474 case MOUSE_BUTTON_MIDDLE: | |
9 | 1475 { |
580 | 1476 vficon_select_util(vf, id, !(id->selected & SELECTION_SELECTED)); |
9 | 1477 } |
580 | 1478 break; |
1479 default: | |
1480 break; | |
9 | 1481 } |
580 | 1482 |
1483 if (!was_selected && (id->selected & SELECTION_SELECTED)) | |
9 | 1484 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1485 vficon_send_layout_select(vf, id); |
9 | 1486 } |
1487 | |
1488 return TRUE; | |
1489 } | |
1490 | |
1491 static gint vficon_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data) | |
1492 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1493 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1494 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1495 tip_unschedule(vf); |
9 | 1496 return FALSE; |
1497 } | |
1498 | |
1499 /* | |
1500 *------------------------------------------------------------------- | |
1501 * population | |
1502 *------------------------------------------------------------------- | |
1503 */ | |
1504 | |
1505 static gboolean vficon_destroy_node_cb(GtkTreeModel *store, GtkTreePath *tpath, GtkTreeIter *iter, gpointer data) | |
1506 { | |
1507 GList *list; | |
1508 | |
1509 gtk_tree_model_get(store, iter, FILE_COLUMN_POINTER, &list, -1); | |
1510 g_list_free(list); | |
1511 | |
1512 return FALSE; | |
1513 } | |
1514 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1515 static void vficon_clear_store(ViewFile *vf) |
9 | 1516 { |
1517 GtkTreeModel *store; | |
1518 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1519 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 1520 gtk_tree_model_foreach(store, vficon_destroy_node_cb, NULL); |
1521 | |
1522 gtk_list_store_clear(GTK_LIST_STORE(store)); | |
1523 } | |
1524 | |
838 | 1525 static void vficon_set_thumb(ViewFile *vf, FileData *fd) |
9 | 1526 { |
1527 GtkTreeModel *store; | |
1528 GtkTreeIter iter; | |
1529 GList *list; | |
1530 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1531 if (!vficon_find_iter(vf, vficon_icon_data(vf, fd), &iter, NULL)) return; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1532 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1533 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 1534 |
1535 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); | |
1536 gtk_list_store_set(GTK_LIST_STORE(store), &iter, FILE_COLUMN_POINTER, list, -1); | |
1537 } | |
1538 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1539 static GList *vficon_add_row(ViewFile *vf, GtkTreeIter *iter) |
9 | 1540 { |
1541 GtkListStore *store; | |
1542 GList *list = NULL; | |
1543 gint i; | |
1544 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1545 for (i = 0; i < VFICON_INFO(vf, columns); i++) list = g_list_prepend(list, NULL); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1546 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1547 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
9 | 1548 gtk_list_store_append(store, iter); |
1549 gtk_list_store_set(store, iter, FILE_COLUMN_POINTER, list, -1); | |
1550 | |
1551 return list; | |
1552 } | |
1553 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1554 static void vficon_populate(ViewFile *vf, gint resize, gint keep_position) |
9 | 1555 { |
1556 GtkTreeModel *store; | |
1557 GtkTreePath *tpath; | |
1558 GList *work; | |
138 | 1559 IconData *visible_id = NULL; |
805 | 1560 gint r, c; |
1561 gint valid; | |
1562 GtkTreeIter iter; | |
9 | 1563 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1564 vficon_verify_selections(vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1565 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1566 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1567 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1568 if (keep_position && GTK_WIDGET_REALIZED(vf->listview) && |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1569 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL)) |
9 | 1570 { |
1571 GtkTreeIter iter; | |
1572 GList *list; | |
1573 | |
1574 gtk_tree_model_get_iter(store, &iter, tpath); | |
1575 gtk_tree_path_free(tpath); | |
1576 | |
1577 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); | |
138 | 1578 if (list) visible_id = list->data; |
9 | 1579 } |
1580 | |
1581 | |
1582 if (resize) | |
1583 { | |
1584 gint i; | |
1585 gint thumb_width; | |
805 | 1586 |
1587 vficon_clear_store(vf); | |
9 | 1588 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1589 thumb_width = vficon_get_icon_width(vf); |
9 | 1590 |
1591 for (i = 0; i < VFICON_MAX_COLUMNS; i++) | |
1592 { | |
1593 GtkTreeViewColumn *column; | |
1594 GtkCellRenderer *cell; | |
1595 GList *list; | |
1596 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1597 column = gtk_tree_view_get_column(GTK_TREE_VIEW(vf->listview), i); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1598 gtk_tree_view_column_set_visible(column, (i < VFICON_INFO(vf, columns))); |
9 | 1599 gtk_tree_view_column_set_fixed_width(column, thumb_width + (THUMB_BORDER_PADDING * 6)); |
1600 | |
1601 list = gtk_tree_view_column_get_cell_renderers(column); | |
1602 cell = (list) ? list->data : NULL; | |
1603 g_list_free(list); | |
1604 | |
1605 if (cell && GQV_IS_CELL_RENDERER_ICON(cell)) | |
1606 { | |
1607 g_object_set(G_OBJECT(cell), "fixed_width", thumb_width, | |
333 | 1608 "fixed_height", options->thumbnails.max_height, |
852 | 1609 "show_text", VFICON_INFO(vf, show_text), |
1610 "show_marks", vf->marks_enabled, | |
1611 "num_marks", FILEDATA_MARKS_SIZE, | |
1612 NULL); | |
9 | 1613 } |
1614 } | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1615 if (GTK_WIDGET_REALIZED(vf->listview)) gtk_tree_view_columns_autosize(GTK_TREE_VIEW(vf->listview)); |
9 | 1616 } |
1617 | |
805 | 1618 r = -1; |
1619 c = 0; | |
1620 | |
1621 valid = gtk_tree_model_iter_children(store, &iter, NULL); | |
1622 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1623 work = vf->list; |
9 | 1624 while (work) |
1625 { | |
1626 GList *list; | |
805 | 1627 r++; |
1628 c = 0; | |
1629 if (valid) | |
1630 { | |
1631 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); | |
1632 gtk_list_store_set(GTK_LIST_STORE(store), &iter, FILE_COLUMN_POINTER, list, -1); | |
1633 } | |
1634 else | |
1635 { | |
1636 list = vficon_add_row(vf, &iter); | |
1637 } | |
1638 | |
1639 while (list) | |
9 | 1640 { |
585 | 1641 IconData *id; |
1642 | |
805 | 1643 if (work) |
1644 { | |
1645 id = work->data; | |
1646 work = work->next; | |
1647 c++; | |
1648 | |
1649 id->row = r; | |
1650 } | |
1651 else | |
1652 { | |
1653 id = NULL; | |
1654 } | |
1655 | |
1656 list->data = id; | |
9 | 1657 list = list->next; |
1658 } | |
805 | 1659 if (valid) valid = gtk_tree_model_iter_next(store, &iter); |
9 | 1660 } |
1661 | |
805 | 1662 r++; |
1663 while (valid) | |
1664 { | |
1665 GList *list; | |
1666 | |
1667 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); | |
1668 valid = gtk_list_store_remove(GTK_LIST_STORE(store), &iter); | |
1669 g_list_free(list); | |
1670 } | |
1671 | |
1672 VFICON_INFO(vf, rows) = r; | |
1673 | |
138 | 1674 if (visible_id && |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1675 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL)) |
9 | 1676 { |
1677 GtkTreeIter iter; | |
1678 GList *list; | |
1679 | |
1680 gtk_tree_model_get_iter(store, &iter, tpath); | |
1681 gtk_tree_path_free(tpath); | |
1682 | |
1683 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); | |
138 | 1684 if (g_list_find(list, visible_id) == NULL && |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1685 vficon_find_iter(vf, visible_id, &iter, NULL)) |
9 | 1686 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1687 tree_view_row_make_visible(GTK_TREE_VIEW(vf->listview), &iter, FALSE); |
9 | 1688 } |
1689 } | |
1690 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1691 |
633 | 1692 vf_send_update(vf); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1693 vficon_thumb_update(vf); |
9 | 1694 } |
1695 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1696 static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint h, gint force) |
9 | 1697 { |
1698 gint new_cols; | |
1699 gint thumb_width; | |
1700 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1701 thumb_width = vficon_get_icon_width(vf); |
9 | 1702 |
1703 new_cols = w / (thumb_width + (THUMB_BORDER_PADDING * 6)); | |
1704 if (new_cols < 1) new_cols = 1; | |
1705 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1706 if (!force && new_cols == VFICON_INFO(vf, columns)) return; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1707 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1708 VFICON_INFO(vf, columns) = new_cols; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1709 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1710 vficon_populate(vf, TRUE, TRUE); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1711 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1712 DEBUG_1("col tab pop cols=%d rows=%d", VFICON_INFO(vf, columns), VFICON_INFO(vf, rows)); |
9 | 1713 } |
1714 | |
817
ad7f56cea841
dropped vficon_sync, use vficon_refresh everywhere
nadvornik
parents:
814
diff
changeset
|
1715 #if 0 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1716 static void vficon_sync(ViewFile *vf) |
9 | 1717 { |
1718 GtkTreeModel *store; | |
1719 GtkTreeIter iter; | |
1720 GList *work; | |
1721 gint r, c; | |
804 | 1722 gint valid; |
9 | 1723 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1724 if (VFICON_INFO(vf, rows) == 0) return; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1725 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1726 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 1727 |
1728 r = -1; | |
1729 c = 0; | |
1730 | |
804 | 1731 valid = gtk_tree_model_iter_children(store, &iter, NULL); |
1732 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1733 work = vf->list; |
9 | 1734 while (work) |
1735 { | |
1736 GList *list; | |
1737 r++; | |
1738 c = 0; | |
804 | 1739 if (valid) |
9 | 1740 { |
1741 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); | |
1742 gtk_list_store_set(GTK_LIST_STORE(store), &iter, FILE_COLUMN_POINTER, list, -1); | |
1743 } | |
1744 else | |
1745 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1746 list = vficon_add_row(vf, &iter); |
9 | 1747 } |
442 | 1748 |
9 | 1749 while (list) |
1750 { | |
138 | 1751 IconData *id; |
111
3a69a7a3f461
Wed Nov 15 02:05:27 2006 John Ellis <johne@verizon.net>
gqview
parents:
85
diff
changeset
|
1752 |
9 | 1753 if (work) |
1754 { | |
138 | 1755 id = work->data; |
9 | 1756 work = work->next; |
1757 c++; | |
111
3a69a7a3f461
Wed Nov 15 02:05:27 2006 John Ellis <johne@verizon.net>
gqview
parents:
85
diff
changeset
|
1758 |
138 | 1759 id->row = r; |
9 | 1760 } |
1761 else | |
1762 { | |
138 | 1763 id = NULL; |
9 | 1764 } |
111
3a69a7a3f461
Wed Nov 15 02:05:27 2006 John Ellis <johne@verizon.net>
gqview
parents:
85
diff
changeset
|
1765 |
138 | 1766 list->data = id; |
111
3a69a7a3f461
Wed Nov 15 02:05:27 2006 John Ellis <johne@verizon.net>
gqview
parents:
85
diff
changeset
|
1767 list = list->next; |
9 | 1768 } |
804 | 1769 if (valid) valid = gtk_tree_model_iter_next(store, &iter); |
9 | 1770 } |
1771 | |
1772 r++; | |
804 | 1773 while (valid) |
9 | 1774 { |
1775 GList *list; | |
1776 | |
1777 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); | |
804 | 1778 valid = gtk_list_store_remove(GTK_LIST_STORE(store), &iter); |
9 | 1779 g_list_free(list); |
1780 } | |
1781 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1782 VFICON_INFO(vf, rows) = r; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1783 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1784 vficon_update_focus(vf); |
9 | 1785 } |
817
ad7f56cea841
dropped vficon_sync, use vficon_refresh everywhere
nadvornik
parents:
814
diff
changeset
|
1786 #endif |
9 | 1787 |
812 | 1788 #if 0 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1789 static void vficon_sync_idle(ViewFile *vf) |
9 | 1790 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1791 if (VFICON_INFO(vf, sync_idle_id) == -1) |
9 | 1792 { |
1793 /* high priority, the view needs to be resynced before a redraw | |
1794 * may contain invalid pointers at this time | |
1795 */ | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1796 VFICON_INFO(vf, sync_idle_id) = g_idle_add_full(G_PRIORITY_HIGH, vficon_sync_idle_cb, vf, NULL); |
9 | 1797 } |
1798 } | |
812 | 1799 #endif |
9 | 1800 |
1801 static void vficon_sized_cb(GtkWidget *widget, GtkAllocation *allocation, gpointer data) | |
1802 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1803 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1804 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1805 vficon_populate_at_new_size(vf, allocation->width, allocation->height, FALSE); |
9 | 1806 } |
1807 | |
1808 /* | |
1809 *----------------------------------------------------------------------------- | |
1810 * misc | |
1811 *----------------------------------------------------------------------------- | |
1812 */ | |
1813 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1814 void vficon_sort_set(ViewFile *vf, SortType type, gint ascend) |
9 | 1815 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1816 if (vf->sort_method == type && vf->sort_ascend == ascend) return; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1817 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1818 vf->sort_method = type; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1819 vf->sort_ascend = ascend; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1820 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1821 if (!vf->list) return; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1822 |
817
ad7f56cea841
dropped vficon_sync, use vficon_refresh everywhere
nadvornik
parents:
814
diff
changeset
|
1823 vf_refresh(vf); |
9 | 1824 } |
1825 | |
1826 /* | |
1827 *----------------------------------------------------------------------------- | |
1828 * thumb updates | |
1829 *----------------------------------------------------------------------------- | |
1830 */ | |
1831 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1832 static gint vficon_thumb_next(ViewFile *vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1833 |
843 | 1834 static gdouble vficon_thumb_progress(ViewFile *vf) |
1835 { | |
1836 gint count = 0; | |
1837 gint done = 0; | |
1838 | |
1839 GList *work = vf->list; | |
1840 while (work) | |
1841 { | |
1842 IconData *id = work->data; | |
1843 FileData *fd = id->fd; | |
1844 work = work->next; | |
1845 | |
845 | 1846 if (fd->thumb_pixbuf) done++; |
843 | 1847 count++; |
1848 } | |
1849 DEBUG_1("thumb progress: %d of %d", done, count); | |
1850 return (gdouble)done / count; | |
1851 } | |
1852 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1853 static void vficon_thumb_status(ViewFile *vf, gdouble val, const gchar *text) |
9 | 1854 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1855 if (vf->func_thumb_status) |
9 | 1856 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1857 vf->func_thumb_status(vf, val, text, vf->data_thumb_status); |
9 | 1858 } |
1859 } | |
1860 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1861 static void vficon_thumb_cleanup(ViewFile *vf) |
9 | 1862 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1863 vficon_thumb_status(vf, 0.0, NULL); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1864 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1865 vf->thumbs_running = FALSE; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1866 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1867 thumb_loader_free(vf->thumbs_loader); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1868 vf->thumbs_loader = NULL; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1869 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1870 vf->thumbs_filedata = NULL; |
9 | 1871 } |
1872 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1873 static void vficon_thumb_stop(ViewFile *vf) |
9 | 1874 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1875 if (vf->thumbs_running) vficon_thumb_cleanup(vf); |
9 | 1876 } |
1877 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1878 static void vficon_thumb_do(ViewFile *vf, ThumbLoader *tl, FileData *fd) |
9 | 1879 { |
1880 if (!fd) return; | |
1881 | |
838 | 1882 vficon_set_thumb(vf, fd); |
9 | 1883 |
843 | 1884 vficon_thumb_status(vf, vficon_thumb_progress(vf), _("Loading thumbs...")); |
9 | 1885 } |
1886 | |
1887 static void vficon_thumb_error_cb(ThumbLoader *tl, gpointer data) | |
1888 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1889 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1890 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1891 if (vf->thumbs_filedata && vf->thumbs_loader == tl) |
9 | 1892 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1893 vficon_thumb_do(vf, tl, vf->thumbs_filedata); |
9 | 1894 } |
1895 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1896 while (vficon_thumb_next(vf)); |
9 | 1897 } |
1898 | |
1899 static void vficon_thumb_done_cb(ThumbLoader *tl, gpointer data) | |
1900 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1901 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1902 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1903 if (vf->thumbs_filedata && vf->thumbs_loader == tl) |
9 | 1904 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1905 vficon_thumb_do(vf, tl, vf->thumbs_filedata); |
9 | 1906 } |
1907 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1908 while (vficon_thumb_next(vf)); |
9 | 1909 } |
1910 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1911 static gint vficon_thumb_next(ViewFile *vf) |
9 | 1912 { |
1913 GtkTreePath *tpath; | |
1914 FileData *fd = NULL; | |
1915 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1916 if (!GTK_WIDGET_REALIZED(vf->listview)) |
9 | 1917 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1918 vficon_thumb_status(vf, 0.0, NULL); |
9 | 1919 return FALSE; |
1920 } | |
1921 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1922 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL)) |
9 | 1923 { |
1924 GtkTreeModel *store; | |
1925 GtkTreeIter iter; | |
1926 gint valid = TRUE; | |
1927 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1928 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 1929 gtk_tree_model_get_iter(store, &iter, tpath); |
1930 gtk_tree_path_free(tpath); | |
1931 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1932 while (!fd && valid && tree_view_row_get_visibility(GTK_TREE_VIEW(vf->listview), &iter, FALSE) == 0) |
9 | 1933 { |
1934 GList *list; | |
1935 | |
1936 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); | |
1937 | |
1938 while (!fd && list) | |
1939 { | |
138 | 1940 IconData *id = list->data; |
845 | 1941 if (id && !id->fd->thumb_pixbuf) fd = id->fd; |
9 | 1942 list = list->next; |
1943 } | |
1944 | |
1945 valid = gtk_tree_model_iter_next(store, &iter); | |
1946 } | |
1947 } | |
1948 | |
1949 /* then find first undone */ | |
1950 | |
1951 if (!fd) | |
1952 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1953 GList *work = vf->list; |
9 | 1954 while (work && !fd) |
1955 { | |
138 | 1956 IconData *id = work->data; |
1957 FileData *fd_p = id->fd; | |
9 | 1958 work = work->next; |
1959 | |
845 | 1960 if (!fd_p->thumb_pixbuf) fd = fd_p; |
9 | 1961 } |
1962 } | |
1963 | |
1964 if (!fd) | |
1965 { | |
1966 /* done */ | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1967 vficon_thumb_cleanup(vf); |
9 | 1968 return FALSE; |
1969 } | |
1970 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1971 vf->thumbs_filedata = fd; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1972 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1973 thumb_loader_free(vf->thumbs_loader); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1974 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1975 vf->thumbs_loader = thumb_loader_new(options->thumbnails.max_width, options->thumbnails.max_height); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1976 thumb_loader_set_callbacks(vf->thumbs_loader, |
9 | 1977 vficon_thumb_done_cb, |
1978 vficon_thumb_error_cb, | |
1979 NULL, | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1980 vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1981 |
838 | 1982 if (!thumb_loader_start(vf->thumbs_loader, fd)) |
9 | 1983 { |
1984 /* set icon to unknown, continue */ | |
838 | 1985 DEBUG_1("thumb loader start failed %s", fd->path); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1986 vficon_thumb_do(vf, vf->thumbs_loader, fd); |
9 | 1987 |
1988 return TRUE; | |
1989 } | |
1990 | |
1991 return FALSE; | |
1992 } | |
1993 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1994 static void vficon_thumb_update(ViewFile *vf) |
9 | 1995 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1996 vficon_thumb_stop(vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1997 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1998 vficon_thumb_status(vf, 0.0, _("Loading thumbs...")); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1999 vf->thumbs_running = TRUE; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2000 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2001 while (vficon_thumb_next(vf)); |
9 | 2002 } |
2003 | |
2004 /* | |
2005 *----------------------------------------------------------------------------- | |
2006 * row stuff | |
2007 *----------------------------------------------------------------------------- | |
2008 */ | |
2009 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2010 FileData *vficon_index_get_data(ViewFile *vf, gint row) |
9 | 2011 { |
138 | 2012 IconData *id; |
442 | 2013 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2014 id = g_list_nth_data(vf->list, row); |
138 | 2015 return id ? id->fd : NULL; |
9 | 2016 } |
2017 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2018 gint vficon_index_by_path(ViewFile *vf, const gchar *path) |
9 | 2019 { |
2020 gint p = 0; | |
2021 GList *work; | |
2022 | |
2023 if (!path) return -1; | |
2024 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2025 work = vf->list; |
9 | 2026 while (work) |
2027 { | |
138 | 2028 IconData *id = work->data; |
2029 FileData *fd = id->fd; | |
9 | 2030 if (strcmp(path, fd->path) == 0) return p; |
2031 work = work->next; | |
2032 p++; | |
2033 } | |
2034 | |
2035 return -1; | |
2036 } | |
2037 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2038 gint vficon_index_by_fd(ViewFile *vf, FileData *in_fd) |
138 | 2039 { |
2040 gint p = 0; | |
2041 GList *work; | |
2042 | |
2043 if (!in_fd) return -1; | |
2044 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2045 work = vf->list; |
138 | 2046 while (work) |
2047 { | |
2048 IconData *id = work->data; | |
2049 FileData *fd = id->fd; | |
2050 if (fd == in_fd) return p; | |
2051 work = work->next; | |
2052 p++; | |
2053 } | |
2054 | |
2055 return -1; | |
2056 } | |
2057 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2058 static gint vficon_index_by_id(ViewFile *vf, IconData *in_id) |
138 | 2059 { |
2060 gint p = 0; | |
2061 GList *work; | |
2062 | |
2063 if (!in_id) return -1; | |
2064 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2065 work = vf->list; |
138 | 2066 while (work) |
2067 { | |
2068 IconData *id = work->data; | |
2069 if (id == in_id) return p; | |
2070 work = work->next; | |
2071 p++; | |
2072 } | |
2073 | |
2074 return -1; | |
2075 } | |
2076 | |
736 | 2077 guint vficon_count(ViewFile *vf, gint64 *bytes) |
9 | 2078 { |
2079 if (bytes) | |
2080 { | |
2081 gint64 b = 0; | |
2082 GList *work; | |
2083 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2084 work = vf->list; |
9 | 2085 while (work) |
2086 { | |
138 | 2087 IconData *id = work->data; |
2088 FileData *fd = id->fd; | |
9 | 2089 work = work->next; |
579 | 2090 |
9 | 2091 b += fd->size; |
2092 } | |
2093 | |
2094 *bytes = b; | |
2095 } | |
2096 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2097 return g_list_length(vf->list); |
9 | 2098 } |
2099 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2100 GList *vficon_get_list(ViewFile *vf) |
9 | 2101 { |
2102 GList *list = NULL; | |
2103 GList *work; | |
2104 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2105 work = vf->list; |
9 | 2106 while (work) |
2107 { | |
138 | 2108 IconData *id = work->data; |
2109 FileData *fd = id->fd; | |
9 | 2110 work = work->next; |
2111 | |
138 | 2112 list = g_list_prepend(list, file_data_ref(fd)); |
9 | 2113 } |
2114 | |
2115 return g_list_reverse(list); | |
2116 } | |
2117 | |
2118 /* | |
2119 *----------------------------------------------------------------------------- | |
2120 * | |
2121 *----------------------------------------------------------------------------- | |
2122 */ | |
2123 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2124 static gint vficon_refresh_real(ViewFile *vf, gint keep_position) |
9 | 2125 { |
2126 gint ret = TRUE; | |
810 | 2127 GList *work, *work_fd; |
138 | 2128 IconData *focus_id; |
810 | 2129 GList *new_filelist = NULL; |
811 | 2130 GList *selected; |
2131 gint num_selected = 0; | |
832 | 2132 GList *new_iconlist = NULL; |
138 | 2133 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2134 focus_id = VFICON_INFO(vf, focus_id); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2135 |
783 | 2136 if (vf->dir_fd) |
9 | 2137 { |
810 | 2138 ret = filelist_read(vf->dir_fd, &new_filelist, NULL); |
964 | 2139 new_filelist = file_data_filter_marks_list(new_filelist, vf_marks_get_filter(vf)); |
9 | 2140 } |
2141 | |
810 | 2142 vf->list = iconlist_sort(vf->list, vf->sort_method, vf->sort_ascend); /* the list might not be sorted if there were renames */ |
2143 new_filelist = filelist_sort(new_filelist, vf->sort_method, vf->sort_ascend); | |
2144 | |
811 | 2145 selected = vficon_selection_get_list(vf); |
2146 | |
9 | 2147 /* check for same files from old_list */ |
810 | 2148 work = vf->list; |
2149 work_fd = new_filelist; | |
2150 while (work || work_fd) | |
9 | 2151 { |
810 | 2152 IconData *id = NULL; |
2153 FileData *fd = NULL; | |
2154 FileData *new_fd = NULL; | |
2155 gint match; | |
2156 | |
2157 if (work && work_fd) | |
9 | 2158 { |
810 | 2159 id = work->data; |
2160 fd = id->fd; | |
2161 | |
2162 new_fd = work_fd->data; | |
2163 | |
2164 if (fd == new_fd) | |
9 | 2165 { |
810 | 2166 /* not changed, go to next */ |
2167 work = work->next; | |
2168 work_fd = work_fd->next; | |
811 | 2169 if (id->selected & SELECTION_SELECTED) num_selected++; |
810 | 2170 continue; |
9 | 2171 } |
810 | 2172 |
2173 match = filelist_sort_compare_filedata_full(fd, new_fd, vf->sort_method, vf->sort_ascend); | |
2174 if (match == 0) g_warning("multiple fd for the same path"); | |
2175 } | |
2176 else if (work) | |
2177 { | |
2178 id = work->data; | |
2179 fd = id->fd; | |
2180 match = -1; | |
2181 } | |
2182 else /* work_fd */ | |
2183 { | |
2184 new_fd = work_fd->data; | |
2185 match = 1; | |
9 | 2186 } |
810 | 2187 |
2188 if (match < 0) | |
2189 { | |
2190 /* file no longer exists, delete from vf->list */ | |
2191 GList *to_delete = work; | |
2192 work = work->next; | |
2193 if (id == VFICON_INFO(vf, prev_selection)) VFICON_INFO(vf, prev_selection) = NULL; | |
2194 if (id == VFICON_INFO(vf, click_id)) VFICON_INFO(vf, click_id) = NULL; | |
2195 file_data_unref(fd); | |
2196 g_free(id); | |
2197 vf->list = g_list_delete_link(vf->list, to_delete); | |
2198 } | |
2199 else | |
2200 { | |
2201 /* new file, add to vf->list */ | |
2202 id = g_new0(IconData, 1); | |
2203 | |
2204 id->selected = SELECTION_NONE; | |
2205 id->row = -1; | |
2206 id->fd = file_data_ref(new_fd); | |
832 | 2207 if (work) |
2208 vf->list = g_list_insert_before(vf->list, work, id); | |
2209 else | |
2210 new_iconlist = g_list_prepend(new_iconlist, id); /* it is faster to append all new entries together later */ | |
2211 | |
810 | 2212 work_fd = work_fd->next; |
2213 } | |
2214 | |
9 | 2215 } |
2216 | |
832 | 2217 if (new_iconlist) |
2218 { | |
2219 vf->list = g_list_concat(vf->list, g_list_reverse(new_iconlist)); | |
2220 } | |
2221 | |
810 | 2222 filelist_free(new_filelist); |
9 | 2223 |
831
b02a24ebf441
fixed iconview update after deletion of selected image
nadvornik
parents:
817
diff
changeset
|
2224 vficon_populate(vf, TRUE, keep_position); |
b02a24ebf441
fixed iconview update after deletion of selected image
nadvornik
parents:
817
diff
changeset
|
2225 |
811 | 2226 if (selected && num_selected == 0) |
2227 { | |
2228 /* all selected files disappeared */ | |
2229 vficon_select_closest(vf, selected->data); | |
2230 } | |
2231 | |
2232 filelist_free(selected); | |
2233 | |
9 | 2234 /* attempt to keep focus on same icon when refreshing */ |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2235 if (focus_id && g_list_find(vf->list, focus_id)) |
9 | 2236 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2237 vficon_set_focus(vf, focus_id); |
9 | 2238 } |
2239 | |
2240 return ret; | |
2241 } | |
2242 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2243 gint vficon_refresh(ViewFile *vf) |
9 | 2244 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2245 return vficon_refresh_real(vf, TRUE); |
9 | 2246 } |
2247 | |
2248 /* | |
2249 *----------------------------------------------------------------------------- | |
2250 * draw, etc. | |
2251 *----------------------------------------------------------------------------- | |
2252 */ | |
2253 | |
2254 typedef struct _ColumnData ColumnData; | |
2255 struct _ColumnData | |
2256 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2257 ViewFile *vf; |
9 | 2258 gint number; |
2259 }; | |
2260 | |
2261 static void vficon_cell_data_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, | |
2262 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) | |
2263 { | |
2264 ColumnData *cd = data; | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2265 ViewFile *vf; |
9 | 2266 GtkStyle *style; |
2267 GList *list; | |
2268 GdkColor color_fg; | |
2269 GdkColor color_bg; | |
138 | 2270 IconData *id; |
9 | 2271 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2272 vf = cd->vf; |
9 | 2273 |
2274 gtk_tree_model_get(tree_model, iter, FILE_COLUMN_POINTER, &list, -1); | |
442 | 2275 |
138 | 2276 id = g_list_nth_data(list, cd->number); |
442 | 2277 |
138 | 2278 if (id) g_assert(id->fd->magick == 0x12345678); |
442 | 2279 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2280 style = gtk_widget_get_style(vf->listview); |
138 | 2281 if (id && id->selected & SELECTION_SELECTED) |
9 | 2282 { |
2283 memcpy(&color_fg, &style->text[GTK_STATE_SELECTED], sizeof(color_fg)); | |
2284 memcpy(&color_bg, &style->base[GTK_STATE_SELECTED], sizeof(color_bg)); | |
2285 } | |
2286 else | |
2287 { | |
2288 memcpy(&color_fg, &style->text[GTK_STATE_NORMAL], sizeof(color_fg)); | |
2289 memcpy(&color_bg, &style->base[GTK_STATE_NORMAL], sizeof(color_bg)); | |
2290 } | |
2291 | |
138 | 2292 if (id && id->selected & SELECTION_PRELIGHT) |
9 | 2293 { |
2294 #if 0 | |
2295 shift_color(&color_fg, -1, 0); | |
2296 #endif | |
2297 shift_color(&color_bg, -1, 0); | |
2298 } | |
2299 | |
2300 if (GQV_IS_CELL_RENDERER_ICON(cell)) | |
442 | 2301 { |
138 | 2302 if (id) |
9 | 2303 { |
851 | 2304 gchar *name_sidecars = (gchar *)id->fd->name; |
2305 gchar *sidecars = NULL; | |
2306 | |
2307 if (id->fd->sidecar_files) | |
2308 { | |
2309 sidecars = file_data_sc_list_to_string(id->fd); | |
2310 name_sidecars = g_strdup_printf("%s %s", id->fd->name, sidecars); | |
2311 } | |
2312 | |
845 | 2313 g_object_set(cell, "pixbuf", id->fd->thumb_pixbuf, |
851 | 2314 "text", name_sidecars, |
966 | 2315 "marks", file_data_get_marks(id->fd), |
852 | 2316 "show_marks", vf->marks_enabled, |
9 | 2317 "cell-background-gdk", &color_bg, |
2318 "cell-background-set", TRUE, | |
2319 "foreground-gdk", &color_fg, | |
2320 "foreground-set", TRUE, | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2321 "has-focus", (VFICON_INFO(vf, focus_id) == id), NULL); |
851 | 2322 if (sidecars) |
2323 { | |
2324 g_free(sidecars); | |
2325 g_free(name_sidecars); | |
2326 } | |
9 | 2327 } |
2328 else | |
2329 { | |
2330 g_object_set(cell, "pixbuf", NULL, | |
2331 "text", NULL, | |
852 | 2332 "show_marks", FALSE, |
9 | 2333 "cell-background-set", FALSE, |
2334 "foreground-set", FALSE, | |
2335 "has-focus", FALSE, NULL); | |
442 | 2336 } |
9 | 2337 } |
2338 } | |
2339 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2340 static void vficon_append_column(ViewFile *vf, gint n) |
9 | 2341 { |
2342 ColumnData *cd; | |
2343 GtkTreeViewColumn *column; | |
2344 GtkCellRenderer *renderer; | |
2345 | |
2346 column = gtk_tree_view_column_new(); | |
2347 gtk_tree_view_column_set_min_width(column, 0); | |
2348 | |
2349 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); | |
2350 gtk_tree_view_column_set_alignment(column, 0.5); | |
2351 | |
2352 renderer = gqv_cell_renderer_icon_new(); | |
2353 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
2354 g_object_set(G_OBJECT(renderer), "xpad", THUMB_BORDER_PADDING * 2, | |
2355 "ypad", THUMB_BORDER_PADDING, | |
2356 "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL); | |
2357 | |
2358 g_object_set_data(G_OBJECT(column), "column_number", GINT_TO_POINTER(n)); | |
966 | 2359 g_object_set_data(G_OBJECT(renderer), "column_number", GINT_TO_POINTER(n)); |
9 | 2360 |
2361 cd = g_new0(ColumnData, 1); | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2362 cd->vf = vf; |
9 | 2363 cd->number = n; |
2364 gtk_tree_view_column_set_cell_data_func(column, renderer, vficon_cell_data_cb, cd, g_free); | |
2365 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2366 gtk_tree_view_append_column(GTK_TREE_VIEW(vf->listview), column); |
966 | 2367 |
2368 g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(vficon_mark_toggled_cb), vf); | |
9 | 2369 } |
2370 | |
2371 /* | |
2372 *----------------------------------------------------------------------------- | |
2373 * base | |
2374 *----------------------------------------------------------------------------- | |
2375 */ | |
2376 | |
783 | 2377 gint vficon_set_fd(ViewFile *vf, FileData *dir_fd) |
9 | 2378 { |
2379 gint ret; | |
2380 | |
783 | 2381 if (!dir_fd) return FALSE; |
2382 if (vf->dir_fd == dir_fd) return TRUE; | |
2383 | |
2384 file_data_unref(vf->dir_fd); | |
2385 vf->dir_fd = file_data_ref(dir_fd); | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2386 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2387 g_list_free(VFICON_INFO(vf, selection)); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2388 VFICON_INFO(vf, selection) = NULL; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2389 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2390 iconlist_free(vf->list); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2391 vf->list = NULL; |
9 | 2392 |
2393 /* NOTE: populate will clear the store for us */ | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2394 ret = vficon_refresh_real(vf, FALSE); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2395 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2396 VFICON_INFO(vf, focus_id) = NULL; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2397 vficon_move_focus(vf, 0, 0, FALSE); |
9 | 2398 |
2399 return ret; | |
2400 } | |
2401 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
562
diff
changeset
|
2402 void vficon_destroy_cb(GtkWidget *widget, gpointer data) |
9 | 2403 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2404 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2405 |
814 | 2406 vf_refresh_idle_cancel(vf); |
787 | 2407 |
814 | 2408 file_data_unregister_notify_func(vf_notify_cb, vf); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2409 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2410 tip_unschedule(vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2411 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2412 vficon_thumb_cleanup(vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2413 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2414 iconlist_free(vf->list); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2415 g_list_free(VFICON_INFO(vf, selection)); |
9 | 2416 } |
2417 | |
783 | 2418 ViewFile *vficon_new(ViewFile *vf, FileData *dir_fd) |
9 | 2419 { |
2420 GtkListStore *store; | |
2421 GtkTreeSelection *selection; | |
2422 gint i; | |
2423 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2424 vf->info = g_new0(ViewFileInfoIcon, 1); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2425 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2426 VFICON_INFO(vf, selection) = NULL; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2427 VFICON_INFO(vf, prev_selection) = NULL; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2428 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2429 VFICON_INFO(vf, tip_window) = NULL; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2430 VFICON_INFO(vf, tip_delay_id) = -1; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2431 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2432 VFICON_INFO(vf, focus_row) = 0; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2433 VFICON_INFO(vf, focus_column) = 0; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2434 VFICON_INFO(vf, focus_id) = NULL; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2435 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2436 VFICON_INFO(vf, show_text) = options->show_icon_names; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2437 |
9 | 2438 store = gtk_list_store_new(1, G_TYPE_POINTER); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2439 vf->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); |
9 | 2440 g_object_unref(store); |
2441 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2442 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 2443 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_NONE); |
2444 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2445 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vf->listview), FALSE); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2446 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vf->listview), FALSE); |
9 | 2447 |
2448 for (i = 0; i < VFICON_MAX_COLUMNS; i++) | |
2449 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2450 vficon_append_column(vf, i); |
9 | 2451 } |
2452 | |
2453 /* zero width column to hide tree view focus, we draw it ourselves */ | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2454 vficon_append_column(vf, i); |
9 | 2455 /* end column to fill white space */ |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2456 vficon_append_column(vf, i); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2457 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2458 g_signal_connect(G_OBJECT(vf->listview), "size_allocate", |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2459 G_CALLBACK(vficon_sized_cb), vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2460 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2461 gtk_widget_set_events(vf->listview, GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK | |
9 | 2462 GDK_BUTTON_PRESS_MASK | GDK_LEAVE_NOTIFY_MASK); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2463 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2464 g_signal_connect(G_OBJECT(vf->listview),"motion_notify_event", |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2465 G_CALLBACK(vficon_motion_cb), vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2466 g_signal_connect(G_OBJECT(vf->listview), "leave_notify_event", |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2467 G_CALLBACK(vficon_leave_cb), vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2468 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2469 /* force VFICON_INFO(vf, columns) to be at least 1 (sane) - this will be corrected in the size_cb */ |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2470 vficon_populate_at_new_size(vf, 1, 1, FALSE); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2471 |
814 | 2472 file_data_register_notify_func(vf_notify_cb, vf, NOTIFY_PRIORITY_MEDIUM); |
787 | 2473 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2474 return vf; |
9 | 2475 } |
2476 |