Mercurial > geeqie
annotate src/view_file_icon.c @ 1088:fe0dce2161c0
Do not install doc/Makefile*. Reported and fixed by Krzysztof Kotlenga.
author | zas_ |
---|---|
date | Mon, 27 Oct 2008 13:31:39 +0000 |
parents | 1646720364cf |
children | 3692efcbd325 |
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 | |
1002 | 134 gint iconlist_sort_file_cb(gpointer a, gpointer b) |
138 | 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 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
168 if (!VFICON(vf)->click_id) return NULL; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
169 |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
170 if (VFICON(vf)->click_id->selected & SELECTION_SELECTED) |
9 | 171 { |
633 | 172 return vf_selection_get_list(vf); |
9 | 173 } |
174 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
175 return g_list_append(NULL, file_data_ref(VFICON(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 |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
182 if (!VFICON(vf)->click_id) return; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
183 |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
184 if (VFICON(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 { | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
194 view_window_new(VFICON(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; |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
222 vficon_selection_remove(vf, VFICON(vf)->click_id, SELECTION_PRELIGHT, NULL); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
223 VFICON(vf)->click_id = NULL; |
574
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 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
267 VFICON(vf)->show_text = !VFICON(vf)->show_text; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
268 options->show_icon_names = VFICON(vf)->show_text; |
574
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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
277 if (!VFICON(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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
300 *row = n / VFICON(vf)->columns; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
301 *col = n - (*row * VFICON(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)) | |
995 | 385 return; |
966 | 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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
412 if (VFICON(vf)->tip_window) return; |
574
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 |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
416 VFICON(vf)->tip_id = vficon_find_data_by_coord(vf, x, y, NULL); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
417 if (!VFICON(vf)->tip_id) return; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
418 |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
419 VFICON(vf)->tip_window = gtk_window_new(GTK_WINDOW_POPUP); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
420 gtk_window_set_resizable(GTK_WINDOW(VFICON(vf)->tip_window), FALSE); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
421 gtk_container_set_border_width(GTK_CONTAINER(VFICON(vf)->tip_window), 2); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
422 |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
423 label = gtk_label_new(VFICON(vf)->tip_id->fd->name); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
424 |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
425 g_object_set_data(G_OBJECT(VFICON(vf)->tip_window), "tip_label", label); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
426 gtk_container_add(GTK_CONTAINER(VFICON(vf)->tip_window), label); |
9 | 427 gtk_widget_show(label); |
428 | |
429 gdk_window_get_pointer(NULL, &x, &y, NULL); | |
430 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
431 if (!GTK_WIDGET_REALIZED(VFICON(vf)->tip_window)) gtk_widget_realize(VFICON(vf)->tip_window); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
432 gtk_window_move(GTK_WINDOW(VFICON(vf)->tip_window), x + 16, y + 16); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
433 gtk_widget_show(VFICON(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 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
438 if (VFICON(vf)->tip_window) gtk_widget_destroy(VFICON(vf)->tip_window); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
439 VFICON(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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
447 if (VFICON(vf)->tip_delay_id == -1) return FALSE; |
574
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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
457 VFICON(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 |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
465 if (VFICON(vf)->tip_delay_id != -1) |
9 | 466 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
467 g_source_remove(VFICON(vf)->tip_delay_id); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
468 VFICON(vf)->tip_delay_id = -1; |
9 | 469 } |
470 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
471 if (!VFICON(vf)->show_text) |
9 | 472 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
473 VFICON(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 |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
481 if (VFICON(vf)->tip_delay_id != -1) g_source_remove(VFICON(vf)->tip_delay_id); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
482 VFICON(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 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
487 if (VFICON(vf)->tip_window) |
9 | 488 { |
489 gint x, y; | |
490 | |
491 gdk_window_get_pointer(NULL, &x, &y, NULL); | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
492 gtk_window_move(GTK_WINDOW(VFICON(vf)->tip_window), x + 16, y + 16); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
493 |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
494 if (id != VFICON(vf)->tip_id) |
9 | 495 { |
496 GtkWidget *label; | |
497 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
498 VFICON(vf)->tip_id = id; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
499 |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
500 if (!VFICON(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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
507 label = g_object_get_data(G_OBJECT(VFICON(vf)->tip_window), "tip_label"); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
508 gtk_label_set_text(GTK_LABEL(label), VFICON(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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
532 if (!VFICON(vf)->click_id) return; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
533 |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
534 if (VFICON(vf)->click_id->selected & SELECTION_SELECTED) |
9 | 535 { |
633 | 536 list = vf_selection_get_list(vf); |
9 | 537 } |
538 else | |
539 { | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
540 list = g_list_append(NULL, file_data_ref(VFICON(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 |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
560 if (VFICON(vf)->click_id && VFICON(vf)->click_id->fd->thumb_pixbuf) |
9 | 561 { |
562 gint items; | |
563 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
564 if (VFICON(vf)->click_id->selected & SELECTION_SELECTED) |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
565 items = g_list_length(VFICON(vf)->selection); |
9 | 566 else |
567 items = 1; | |
568 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
569 dnd_set_drag_icon(widget, context, VFICON(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 |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
577 vficon_selection_remove(vf, VFICON(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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
664 work = VFICON(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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
672 VFICON(vf)->selection = g_list_remove(VFICON(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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
680 g_list_free(VFICON(vf)->selection); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
681 VFICON(vf)->selection = NULL; |
574
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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
689 VFICON(vf)->selection = g_list_append(VFICON(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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
700 work = VFICON(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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
709 g_list_free(VFICON(vf)->selection); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
710 VFICON(vf)->selection = NULL; |
574
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 { | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
727 VFICON(vf)->selection = g_list_remove(VFICON(vf)->selection, id); |
601 | 728 vficon_selection_remove(vf, id, SELECTION_SELECTED, NULL); |
729 } | |
730 else | |
731 { | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
732 VFICON(vf)->selection = g_list_append(VFICON(vf)->selection, id); |
601 | 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 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
742 VFICON(vf)->prev_selection = id; |
138 | 743 |
744 if (!id || id->selected & SELECTION_SELECTED) return; | |
745 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
746 VFICON(vf)->selection = g_list_append(VFICON(vf)->selection, id); |
574
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 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
754 VFICON(vf)->prev_selection = id; |
138 | 755 |
756 if (!id || !(id->selected & SELECTION_SELECTED) ) return; | |
757 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
758 VFICON(vf)->selection = g_list_remove(VFICON(vf)->selection, id); |
574
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 |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
786 VFICON(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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
855 work = VFICON(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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
869 return g_list_length(VFICON(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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
877 work = VFICON(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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
899 work = VFICON(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 { | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1044 new_row = VFICON(vf)->focus_row; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1045 new_col = VFICON(vf)->focus_column; |
9 | 1046 |
1047 new_row += row; | |
1048 if (new_row < 0) new_row = 0; | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1049 if (new_row >= VFICON(vf)->rows) new_row = VFICON(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--; | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1069 new_col = VFICON(vf)->columns - 1; |
9 | 1070 } |
1071 else | |
1072 { | |
1073 new_col = 0; | |
1074 } | |
1075 } | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1076 if (new_col >= VFICON(vf)->columns) |
9 | 1077 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1078 if (new_row < VFICON(vf)->rows - 1) |
9 | 1079 { |
1080 new_row++; | |
1081 new_col = 0; | |
1082 } | |
1083 else | |
1084 { | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1085 new_col = VFICON(vf)->columns - 1; |
9 | 1086 } |
1087 } | |
1088 } | |
1089 } | |
1090 else | |
1091 { | |
1092 new_row = row; | |
1093 new_col = col; | |
1094 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1095 if (new_row >= VFICON(vf)->rows) |
9 | 1096 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1097 if (VFICON(vf)->rows > 0) |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1098 new_row = VFICON(vf)->rows - 1; |
9 | 1099 else |
1100 new_row = 0; | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1101 new_col = VFICON(vf)->columns - 1; |
9 | 1102 } |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1103 if (new_col >= VFICON(vf)->columns) new_col = VFICON(vf)->columns - 1; |
9 | 1104 } |
1105 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1106 if (new_row == VFICON(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); |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1113 if (VFICON(vf)->rows > 1) l -= (VFICON(vf)->rows - 1) * VFICON(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 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1125 if (g_list_find(vf->list, VFICON(vf)->focus_id)) |
9 | 1126 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1127 if (id == VFICON(vf)->focus_id) |
9 | 1128 { |
1129 /* ensure focus row col are correct */ | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1130 vficon_find_position(vf, VFICON(vf)->focus_id, &VFICON(vf)->focus_row, &VFICON(vf)->focus_column); |
9 | 1131 return; |
1132 } | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1133 vficon_selection_remove(vf, VFICON(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 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1138 VFICON(vf)->focus_id = NULL; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1139 VFICON(vf)->focus_row = -1; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1140 VFICON(vf)->focus_column = -1; |
9 | 1141 return; |
1142 } | |
1143 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1144 VFICON(vf)->focus_id = id; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1145 VFICON(vf)->focus_row = row; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1146 VFICON(vf)->focus_column = col; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1147 vficon_selection_add(vf, VFICON(vf)->focus_id, SELECTION_FOCUS, NULL); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1148 |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1149 if (vficon_find_iter(vf, VFICON(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 | |
1005 | 1166 #if 0 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1167 static void vficon_update_focus(ViewFile *vf) |
9 | 1168 { |
1169 gint new_row = 0; | |
1170 gint new_col = 0; | |
1171 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1172 if (VFICON(vf)->focus_id && vficon_find_position(vf, VFICON(vf)->focus_id, &new_row, &new_col)) |
9 | 1173 { |
1174 /* first find the old focus, if it exists and is valid */ | |
1175 } | |
1176 else | |
1177 { | |
1178 /* (try to) stay where we were */ | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1179 new_row = VFICON(vf)->focus_row; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1180 new_col = VFICON(vf)->focus_column; |
9 | 1181 } |
1182 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1183 vficon_move_focus(vf, new_row, new_col, FALSE); |
9 | 1184 } |
1005 | 1185 #endif |
9 | 1186 |
1187 /* used to figure the page up/down distances */ | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1188 static gint page_height(ViewFile *vf) |
9 | 1189 { |
1190 GtkAdjustment *adj; | |
1191 gint page_size; | |
1192 gint row_height; | |
1193 gint ret; | |
1194 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1195 adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vf->listview)); |
9 | 1196 page_size = (gint)adj->page_increment; |
1197 | |
333 | 1198 row_height = options->thumbnails.max_height + THUMB_BORDER_PADDING * 2; |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1199 if (VFICON(vf)->show_text) row_height += options->thumbnails.max_height / 3; |
9 | 1200 |
1201 ret = page_size / row_height; | |
1202 if (ret < 1) ret = 1; | |
1203 | |
1204 return ret; | |
1205 } | |
1206 | |
1207 /* | |
1208 *------------------------------------------------------------------- | |
1209 * keyboard | |
1210 *------------------------------------------------------------------- | |
1211 */ | |
1212 | |
1213 static void vfi_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) | |
1214 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1215 ViewFile *vf = data; |
9 | 1216 GtkTreeModel *store; |
1217 GtkTreeIter iter; | |
1218 gint column; | |
1219 GtkTreePath *tpath; | |
1220 gint cw, ch; | |
1221 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1222 if (!vficon_find_iter(vf, VFICON(vf)->click_id, &iter, &column)) return; |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1223 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 1224 tpath = gtk_tree_model_get_path(store, &iter); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1225 tree_view_get_cell_clamped(GTK_TREE_VIEW(vf->listview), tpath, column, FALSE, x, y, &cw, &ch); |
9 | 1226 gtk_tree_path_free(tpath); |
1227 *y += ch; | |
1228 popup_menu_position_clamp(menu, x, y, 0); | |
1229 } | |
1230 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
562
diff
changeset
|
1231 gint vficon_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
9 | 1232 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1233 ViewFile *vf = data; |
9 | 1234 gint focus_row = 0; |
1235 gint focus_col = 0; | |
138 | 1236 IconData *id; |
85
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1237 gint stop_signal; |
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1238 |
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1239 stop_signal = TRUE; |
9 | 1240 switch (event->keyval) |
1241 { | |
1242 case GDK_Left: case GDK_KP_Left: | |
1243 focus_col = -1; | |
1244 break; | |
1245 case GDK_Right: case GDK_KP_Right: | |
1246 focus_col = 1; | |
1247 break; | |
1248 case GDK_Up: case GDK_KP_Up: | |
1249 focus_row = -1; | |
1250 break; | |
1251 case GDK_Down: case GDK_KP_Down: | |
1252 focus_row = 1; | |
1253 break; | |
1254 case GDK_Page_Up: case GDK_KP_Page_Up: | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1255 focus_row = -page_height(vf); |
9 | 1256 break; |
1257 case GDK_Page_Down: case GDK_KP_Page_Down: | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1258 focus_row = page_height(vf); |
9 | 1259 break; |
1260 case GDK_Home: case GDK_KP_Home: | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1261 focus_row = -VFICON(vf)->focus_row; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1262 focus_col = -VFICON(vf)->focus_column; |
9 | 1263 break; |
1264 case GDK_End: case GDK_KP_End: | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1265 focus_row = VFICON(vf)->rows - 1 - VFICON(vf)->focus_row; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1266 focus_col = VFICON(vf)->columns - 1 - VFICON(vf)->focus_column; |
9 | 1267 break; |
1268 case GDK_space: | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1269 id = vficon_find_data(vf, VFICON(vf)->focus_row, VFICON(vf)->focus_column, NULL); |
138 | 1270 if (id) |
9 | 1271 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1272 VFICON(vf)->click_id = id; |
9 | 1273 if (event->state & GDK_CONTROL_MASK) |
1274 { | |
1275 gint selected; | |
1276 | |
138 | 1277 selected = id->selected & SELECTION_SELECTED; |
9 | 1278 if (selected) |
1279 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1280 vficon_unselect(vf, id); |
9 | 1281 } |
1282 else | |
1283 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1284 vficon_select(vf, id); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1285 vficon_send_layout_select(vf, id); |
9 | 1286 } |
1287 } | |
1288 else | |
1289 { | |
633 | 1290 vf_select_none(vf); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1291 vficon_select(vf, id); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1292 vficon_send_layout_select(vf, id); |
9 | 1293 } |
1294 } | |
1295 break; | |
1296 case GDK_Menu: | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1297 id = vficon_find_data(vf, VFICON(vf)->focus_row, VFICON(vf)->focus_column, NULL); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1298 VFICON(vf)->click_id = id; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1299 |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1300 vficon_selection_add(vf, VFICON(vf)->click_id, SELECTION_PRELIGHT, NULL); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1301 tip_unschedule(vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1302 |
659
542bb47fef04
Merge vflist_pop_menu() and vficon_pop_menu() into vf_pop_menu().
zas_
parents:
658
diff
changeset
|
1303 vf->popup = vf_pop_menu(vf); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1304 gtk_menu_popup(GTK_MENU(vf->popup), NULL, NULL, vfi_menu_position_cb, vf, 0, GDK_CURRENT_TIME); |
9 | 1305 break; |
1306 default: | |
85
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1307 stop_signal = FALSE; |
9 | 1308 break; |
1309 } | |
1310 | |
1311 if (focus_row != 0 || focus_col != 0) | |
1312 { | |
138 | 1313 IconData *new_id; |
1314 IconData *old_id; | |
1315 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1316 old_id = vficon_find_data(vf, VFICON(vf)->focus_row, VFICON(vf)->focus_column, NULL); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1317 vficon_move_focus(vf, focus_row, focus_col, TRUE); |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1318 new_id = vficon_find_data(vf, VFICON(vf)->focus_row, VFICON(vf)->focus_column, NULL); |
138 | 1319 |
1320 if (new_id != old_id) | |
9 | 1321 { |
1322 if (event->state & GDK_SHIFT_MASK) | |
1323 { | |
330 | 1324 if (!options->collections.rectangular_selection) |
9 | 1325 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1326 vficon_select_region_util(vf, old_id, new_id, FALSE); |
9 | 1327 } |
1328 else | |
1329 { | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1330 vficon_select_region_util(vf, VFICON(vf)->click_id, old_id, FALSE); |
9 | 1331 } |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1332 vficon_select_region_util(vf, VFICON(vf)->click_id, new_id, TRUE); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1333 vficon_send_layout_select(vf, new_id); |
9 | 1334 } |
1335 else if (event->state & GDK_CONTROL_MASK) | |
1336 { | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1337 VFICON(vf)->click_id = new_id; |
9 | 1338 } |
1339 else | |
1340 { | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1341 VFICON(vf)->click_id = new_id; |
633 | 1342 vf_select_none(vf); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1343 vficon_select(vf, new_id); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1344 vficon_send_layout_select(vf, new_id); |
9 | 1345 } |
1346 } | |
1347 } | |
1348 | |
1349 if (stop_signal) | |
1350 { | |
85
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1351 #if 0 |
9 | 1352 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
|
1353 #endif |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1354 tip_unschedule(vf); |
9 | 1355 } |
1356 | |
1357 return stop_signal; | |
1358 } | |
1359 | |
1360 /* | |
1361 *------------------------------------------------------------------- | |
1362 * mouse | |
1363 *------------------------------------------------------------------- | |
1364 */ | |
1365 | |
1366 static gint vficon_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) | |
1367 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1368 ViewFile *vf = data; |
138 | 1369 IconData *id; |
1370 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1371 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
|
1372 tip_update(vf, id); |
9 | 1373 |
1374 return FALSE; | |
1375 } | |
1376 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
562
diff
changeset
|
1377 gint vficon_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
9 | 1378 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1379 ViewFile *vf = data; |
9 | 1380 GtkTreeIter iter; |
138 | 1381 IconData *id; |
9 | 1382 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1383 tip_unschedule(vf); |
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 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
|
1386 |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1387 VFICON(vf)->click_id = id; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1388 vficon_selection_add(vf, VFICON(vf)->click_id, SELECTION_PRELIGHT, &iter); |
9 | 1389 |
1390 switch (bevent->button) | |
1391 { | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
1392 case MOUSE_BUTTON_LEFT: |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1393 if (!GTK_WIDGET_HAS_FOCUS(vf->listview)) |
9 | 1394 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1395 gtk_widget_grab_focus(vf->listview); |
9 | 1396 } |
1397 #if 0 | |
1398 if (bevent->type == GDK_2BUTTON_PRESS && | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1399 vf->layout) |
9 | 1400 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1401 vficon_selection_remove(vf, VFICON(vf)->click_id, SELECTION_PRELIGHT, &iter); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1402 layout_image_full_screen_start(vf->layout); |
9 | 1403 } |
1404 #endif | |
1405 break; | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
1406 case MOUSE_BUTTON_RIGHT: |
659
542bb47fef04
Merge vflist_pop_menu() and vficon_pop_menu() into vf_pop_menu().
zas_
parents:
658
diff
changeset
|
1407 vf->popup = vf_pop_menu(vf); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1408 gtk_menu_popup(GTK_MENU(vf->popup), NULL, NULL, NULL, NULL, bevent->button, bevent->time); |
9 | 1409 break; |
1410 default: | |
1411 break; | |
1412 } | |
1413 | |
966 | 1414 return FALSE; |
9 | 1415 } |
1416 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
562
diff
changeset
|
1417 gint vficon_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
9 | 1418 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1419 ViewFile *vf = data; |
9 | 1420 GtkTreeIter iter; |
138 | 1421 IconData *id = NULL; |
580 | 1422 gint was_selected; |
9 | 1423 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1424 tip_schedule(vf); |
9 | 1425 |
580 | 1426 if ((gint)bevent->x != 0 || (gint)bevent->y != 0) |
9 | 1427 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1428 id = vficon_find_data_by_coord(vf, (gint)bevent->x, (gint)bevent->y, &iter); |
9 | 1429 } |
1430 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1431 if (VFICON(vf)->click_id) |
9 | 1432 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1433 vficon_selection_remove(vf, VFICON(vf)->click_id, SELECTION_PRELIGHT, NULL); |
9 | 1434 } |
1435 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1436 if (!id || VFICON(vf)->click_id != id) return TRUE; |
580 | 1437 |
1438 was_selected = (id->selected & SELECTION_SELECTED); | |
1439 | |
1440 switch (bevent->button) | |
9 | 1441 { |
580 | 1442 case MOUSE_BUTTON_LEFT: |
9 | 1443 { |
580 | 1444 vficon_set_focus(vf, id); |
1445 | |
1446 if (bevent->state & GDK_CONTROL_MASK) | |
9 | 1447 { |
580 | 1448 gint select; |
1449 | |
1450 select = !(id->selected & SELECTION_SELECTED); | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1451 if ((bevent->state & GDK_SHIFT_MASK) && VFICON(vf)->prev_selection) |
580 | 1452 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1453 vficon_select_region_util(vf, VFICON(vf)->prev_selection, id, select); |
580 | 1454 } |
1455 else | |
1456 { | |
1457 vficon_select_util(vf, id, select); | |
1458 } | |
9 | 1459 } |
1460 else | |
1461 { | |
633 | 1462 vf_select_none(vf); |
580 | 1463 |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1464 if ((bevent->state & GDK_SHIFT_MASK) && VFICON(vf)->prev_selection) |
580 | 1465 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1466 vficon_select_region_util(vf, VFICON(vf)->prev_selection, id, TRUE); |
580 | 1467 } |
1468 else | |
1469 { | |
1470 vficon_select_util(vf, id, TRUE); | |
1471 was_selected = FALSE; | |
1472 } | |
9 | 1473 } |
1474 } | |
580 | 1475 break; |
1476 case MOUSE_BUTTON_MIDDLE: | |
9 | 1477 { |
580 | 1478 vficon_select_util(vf, id, !(id->selected & SELECTION_SELECTED)); |
9 | 1479 } |
580 | 1480 break; |
1481 default: | |
1482 break; | |
9 | 1483 } |
580 | 1484 |
1485 if (!was_selected && (id->selected & SELECTION_SELECTED)) | |
9 | 1486 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1487 vficon_send_layout_select(vf, id); |
9 | 1488 } |
1489 | |
1490 return TRUE; | |
1491 } | |
1492 | |
1493 static gint vficon_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data) | |
1494 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1495 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1496 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1497 tip_unschedule(vf); |
9 | 1498 return FALSE; |
1499 } | |
1500 | |
1501 /* | |
1502 *------------------------------------------------------------------- | |
1503 * population | |
1504 *------------------------------------------------------------------- | |
1505 */ | |
1506 | |
1507 static gboolean vficon_destroy_node_cb(GtkTreeModel *store, GtkTreePath *tpath, GtkTreeIter *iter, gpointer data) | |
1508 { | |
1509 GList *list; | |
1510 | |
1511 gtk_tree_model_get(store, iter, FILE_COLUMN_POINTER, &list, -1); | |
1512 g_list_free(list); | |
1513 | |
1514 return FALSE; | |
1515 } | |
1516 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1517 static void vficon_clear_store(ViewFile *vf) |
9 | 1518 { |
1519 GtkTreeModel *store; | |
1520 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1521 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 1522 gtk_tree_model_foreach(store, vficon_destroy_node_cb, NULL); |
1523 | |
1524 gtk_list_store_clear(GTK_LIST_STORE(store)); | |
1525 } | |
1526 | |
838 | 1527 static void vficon_set_thumb(ViewFile *vf, FileData *fd) |
9 | 1528 { |
1529 GtkTreeModel *store; | |
1530 GtkTreeIter iter; | |
1531 GList *list; | |
1532 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1533 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
|
1534 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1535 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 1536 |
1537 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); | |
1538 gtk_list_store_set(GTK_LIST_STORE(store), &iter, FILE_COLUMN_POINTER, list, -1); | |
1539 } | |
1540 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1541 static GList *vficon_add_row(ViewFile *vf, GtkTreeIter *iter) |
9 | 1542 { |
1543 GtkListStore *store; | |
1544 GList *list = NULL; | |
1545 gint i; | |
1546 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1547 for (i = 0; i < VFICON(vf)->columns; i++) list = g_list_prepend(list, NULL); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1548 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1549 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
9 | 1550 gtk_list_store_append(store, iter); |
1551 gtk_list_store_set(store, iter, FILE_COLUMN_POINTER, list, -1); | |
1552 | |
1553 return list; | |
1554 } | |
1555 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1556 static void vficon_populate(ViewFile *vf, gint resize, gint keep_position) |
9 | 1557 { |
1558 GtkTreeModel *store; | |
1559 GtkTreePath *tpath; | |
1560 GList *work; | |
138 | 1561 IconData *visible_id = NULL; |
805 | 1562 gint r, c; |
1563 gint valid; | |
1564 GtkTreeIter iter; | |
9 | 1565 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1566 vficon_verify_selections(vf); |
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1569 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1570 if (keep_position && GTK_WIDGET_REALIZED(vf->listview) && |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1571 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL)) |
9 | 1572 { |
1573 GtkTreeIter iter; | |
1574 GList *list; | |
1575 | |
1576 gtk_tree_model_get_iter(store, &iter, tpath); | |
1577 gtk_tree_path_free(tpath); | |
1578 | |
1579 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); | |
138 | 1580 if (list) visible_id = list->data; |
9 | 1581 } |
1582 | |
1583 | |
1584 if (resize) | |
1585 { | |
1586 gint i; | |
1587 gint thumb_width; | |
805 | 1588 |
1589 vficon_clear_store(vf); | |
9 | 1590 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1591 thumb_width = vficon_get_icon_width(vf); |
9 | 1592 |
1593 for (i = 0; i < VFICON_MAX_COLUMNS; i++) | |
1594 { | |
1595 GtkTreeViewColumn *column; | |
1596 GtkCellRenderer *cell; | |
1597 GList *list; | |
1598 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1599 column = gtk_tree_view_get_column(GTK_TREE_VIEW(vf->listview), i); |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1600 gtk_tree_view_column_set_visible(column, (i < VFICON(vf)->columns)); |
9 | 1601 gtk_tree_view_column_set_fixed_width(column, thumb_width + (THUMB_BORDER_PADDING * 6)); |
1602 | |
1603 list = gtk_tree_view_column_get_cell_renderers(column); | |
1604 cell = (list) ? list->data : NULL; | |
1605 g_list_free(list); | |
1606 | |
1607 if (cell && GQV_IS_CELL_RENDERER_ICON(cell)) | |
1608 { | |
1609 g_object_set(G_OBJECT(cell), "fixed_width", thumb_width, | |
333 | 1610 "fixed_height", options->thumbnails.max_height, |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1611 "show_text", VFICON(vf)->show_text, |
852 | 1612 "show_marks", vf->marks_enabled, |
1613 "num_marks", FILEDATA_MARKS_SIZE, | |
1614 NULL); | |
9 | 1615 } |
1616 } | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1617 if (GTK_WIDGET_REALIZED(vf->listview)) gtk_tree_view_columns_autosize(GTK_TREE_VIEW(vf->listview)); |
9 | 1618 } |
1619 | |
805 | 1620 r = -1; |
1621 c = 0; | |
1622 | |
1623 valid = gtk_tree_model_iter_children(store, &iter, NULL); | |
1624 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1625 work = vf->list; |
9 | 1626 while (work) |
1627 { | |
1628 GList *list; | |
805 | 1629 r++; |
1630 c = 0; | |
1631 if (valid) | |
1632 { | |
1633 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); | |
1634 gtk_list_store_set(GTK_LIST_STORE(store), &iter, FILE_COLUMN_POINTER, list, -1); | |
1635 } | |
1636 else | |
1637 { | |
1638 list = vficon_add_row(vf, &iter); | |
1639 } | |
1640 | |
1641 while (list) | |
9 | 1642 { |
585 | 1643 IconData *id; |
1644 | |
805 | 1645 if (work) |
1646 { | |
1647 id = work->data; | |
1648 work = work->next; | |
1649 c++; | |
1650 | |
1651 id->row = r; | |
1652 } | |
1653 else | |
1654 { | |
1655 id = NULL; | |
1656 } | |
1657 | |
1658 list->data = id; | |
9 | 1659 list = list->next; |
1660 } | |
805 | 1661 if (valid) valid = gtk_tree_model_iter_next(store, &iter); |
9 | 1662 } |
1663 | |
805 | 1664 r++; |
1665 while (valid) | |
1666 { | |
1667 GList *list; | |
1668 | |
1669 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); | |
1670 valid = gtk_list_store_remove(GTK_LIST_STORE(store), &iter); | |
1671 g_list_free(list); | |
1672 } | |
1673 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1674 VFICON(vf)->rows = r; |
805 | 1675 |
138 | 1676 if (visible_id && |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1677 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL)) |
9 | 1678 { |
1679 GtkTreeIter iter; | |
1680 GList *list; | |
1681 | |
1682 gtk_tree_model_get_iter(store, &iter, tpath); | |
1683 gtk_tree_path_free(tpath); | |
1684 | |
1685 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); | |
138 | 1686 if (g_list_find(list, visible_id) == NULL && |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1687 vficon_find_iter(vf, visible_id, &iter, NULL)) |
9 | 1688 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1689 tree_view_row_make_visible(GTK_TREE_VIEW(vf->listview), &iter, FALSE); |
9 | 1690 } |
1691 } | |
1692 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1693 |
633 | 1694 vf_send_update(vf); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1695 vficon_thumb_update(vf); |
9 | 1696 } |
1697 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1698 static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint h, gint force) |
9 | 1699 { |
1700 gint new_cols; | |
1701 gint thumb_width; | |
1702 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1703 thumb_width = vficon_get_icon_width(vf); |
9 | 1704 |
1705 new_cols = w / (thumb_width + (THUMB_BORDER_PADDING * 6)); | |
1706 if (new_cols < 1) new_cols = 1; | |
1707 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1708 if (!force && new_cols == VFICON(vf)->columns) return; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1709 |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1710 VFICON(vf)->columns = new_cols; |
574
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 vficon_populate(vf, TRUE, TRUE); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1713 |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1714 DEBUG_1("col tab pop cols=%d rows=%d", VFICON(vf)->columns, VFICON(vf)->rows); |
9 | 1715 } |
1716 | |
817
ad7f56cea841
dropped vficon_sync, use vficon_refresh everywhere
nadvornik
parents:
814
diff
changeset
|
1717 #if 0 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1718 static void vficon_sync(ViewFile *vf) |
9 | 1719 { |
1720 GtkTreeModel *store; | |
1721 GtkTreeIter iter; | |
1722 GList *work; | |
1723 gint r, c; | |
804 | 1724 gint valid; |
9 | 1725 |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1726 if (VFICON(vf)->rows == 0) return; |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1727 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1728 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 1729 |
1730 r = -1; | |
1731 c = 0; | |
1732 | |
804 | 1733 valid = gtk_tree_model_iter_children(store, &iter, NULL); |
1734 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1735 work = vf->list; |
9 | 1736 while (work) |
1737 { | |
1738 GList *list; | |
1739 r++; | |
1740 c = 0; | |
804 | 1741 if (valid) |
9 | 1742 { |
1743 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); | |
1744 gtk_list_store_set(GTK_LIST_STORE(store), &iter, FILE_COLUMN_POINTER, list, -1); | |
1745 } | |
1746 else | |
1747 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1748 list = vficon_add_row(vf, &iter); |
9 | 1749 } |
442 | 1750 |
9 | 1751 while (list) |
1752 { | |
138 | 1753 IconData *id; |
111
3a69a7a3f461
Wed Nov 15 02:05:27 2006 John Ellis <johne@verizon.net>
gqview
parents:
85
diff
changeset
|
1754 |
9 | 1755 if (work) |
1756 { | |
138 | 1757 id = work->data; |
9 | 1758 work = work->next; |
1759 c++; | |
111
3a69a7a3f461
Wed Nov 15 02:05:27 2006 John Ellis <johne@verizon.net>
gqview
parents:
85
diff
changeset
|
1760 |
138 | 1761 id->row = r; |
9 | 1762 } |
1763 else | |
1764 { | |
138 | 1765 id = NULL; |
9 | 1766 } |
111
3a69a7a3f461
Wed Nov 15 02:05:27 2006 John Ellis <johne@verizon.net>
gqview
parents:
85
diff
changeset
|
1767 |
138 | 1768 list->data = id; |
111
3a69a7a3f461
Wed Nov 15 02:05:27 2006 John Ellis <johne@verizon.net>
gqview
parents:
85
diff
changeset
|
1769 list = list->next; |
9 | 1770 } |
804 | 1771 if (valid) valid = gtk_tree_model_iter_next(store, &iter); |
9 | 1772 } |
1773 | |
1774 r++; | |
804 | 1775 while (valid) |
9 | 1776 { |
1777 GList *list; | |
1778 | |
1779 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); | |
804 | 1780 valid = gtk_list_store_remove(GTK_LIST_STORE(store), &iter); |
9 | 1781 g_list_free(list); |
1782 } | |
1783 | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1784 VFICON(vf)->rows = r; |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1785 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1786 vficon_update_focus(vf); |
9 | 1787 } |
817
ad7f56cea841
dropped vficon_sync, use vficon_refresh everywhere
nadvornik
parents:
814
diff
changeset
|
1788 #endif |
9 | 1789 |
812 | 1790 #if 0 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1791 static void vficon_sync_idle(ViewFile *vf) |
9 | 1792 { |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1793 if (VFICON(vf)->sync_idle_id == -1) |
9 | 1794 { |
1795 /* high priority, the view needs to be resynced before a redraw | |
1796 * may contain invalid pointers at this time | |
1797 */ | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
1798 VFICON(vf)->sync_idle_id = g_idle_add_full(G_PRIORITY_HIGH, vficon_sync_idle_cb, vf, NULL); |
9 | 1799 } |
1800 } | |
812 | 1801 #endif |
9 | 1802 |
1803 static void vficon_sized_cb(GtkWidget *widget, GtkAllocation *allocation, gpointer data) | |
1804 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1805 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1806 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1807 vficon_populate_at_new_size(vf, allocation->width, allocation->height, FALSE); |
9 | 1808 } |
1809 | |
1810 /* | |
1811 *----------------------------------------------------------------------------- | |
1812 * misc | |
1813 *----------------------------------------------------------------------------- | |
1814 */ | |
1815 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1816 void vficon_sort_set(ViewFile *vf, SortType type, gint ascend) |
9 | 1817 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1818 if (vf->sort_method == type && vf->sort_ascend == ascend) return; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1819 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1820 vf->sort_method = type; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1821 vf->sort_ascend = ascend; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1822 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1823 if (!vf->list) return; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1824 |
817
ad7f56cea841
dropped vficon_sync, use vficon_refresh everywhere
nadvornik
parents:
814
diff
changeset
|
1825 vf_refresh(vf); |
9 | 1826 } |
1827 | |
1828 /* | |
1829 *----------------------------------------------------------------------------- | |
1830 * thumb updates | |
1831 *----------------------------------------------------------------------------- | |
1832 */ | |
1833 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1834 static gint vficon_thumb_next(ViewFile *vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1835 |
843 | 1836 static gdouble vficon_thumb_progress(ViewFile *vf) |
1837 { | |
1838 gint count = 0; | |
1839 gint done = 0; | |
1840 | |
1841 GList *work = vf->list; | |
1842 while (work) | |
1843 { | |
1844 IconData *id = work->data; | |
1845 FileData *fd = id->fd; | |
1846 work = work->next; | |
1847 | |
845 | 1848 if (fd->thumb_pixbuf) done++; |
843 | 1849 count++; |
1850 } | |
1851 DEBUG_1("thumb progress: %d of %d", done, count); | |
1852 return (gdouble)done / count; | |
1853 } | |
1854 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1855 static void vficon_thumb_status(ViewFile *vf, gdouble val, const gchar *text) |
9 | 1856 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1857 if (vf->func_thumb_status) |
9 | 1858 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1859 vf->func_thumb_status(vf, val, text, vf->data_thumb_status); |
9 | 1860 } |
1861 } | |
1862 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1863 static void vficon_thumb_cleanup(ViewFile *vf) |
9 | 1864 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1865 vficon_thumb_status(vf, 0.0, NULL); |
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 vf->thumbs_running = FALSE; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1868 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1869 thumb_loader_free(vf->thumbs_loader); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1870 vf->thumbs_loader = NULL; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1871 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1872 vf->thumbs_filedata = NULL; |
9 | 1873 } |
1874 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1875 static void vficon_thumb_stop(ViewFile *vf) |
9 | 1876 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1877 if (vf->thumbs_running) vficon_thumb_cleanup(vf); |
9 | 1878 } |
1879 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1880 static void vficon_thumb_do(ViewFile *vf, ThumbLoader *tl, FileData *fd) |
9 | 1881 { |
1882 if (!fd) return; | |
1883 | |
838 | 1884 vficon_set_thumb(vf, fd); |
9 | 1885 |
843 | 1886 vficon_thumb_status(vf, vficon_thumb_progress(vf), _("Loading thumbs...")); |
9 | 1887 } |
1888 | |
1889 static void vficon_thumb_error_cb(ThumbLoader *tl, gpointer data) | |
1890 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1891 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1892 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1893 if (vf->thumbs_filedata && vf->thumbs_loader == tl) |
9 | 1894 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1895 vficon_thumb_do(vf, tl, vf->thumbs_filedata); |
9 | 1896 } |
1897 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1898 while (vficon_thumb_next(vf)); |
9 | 1899 } |
1900 | |
1901 static void vficon_thumb_done_cb(ThumbLoader *tl, gpointer data) | |
1902 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1903 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1904 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1905 if (vf->thumbs_filedata && vf->thumbs_loader == tl) |
9 | 1906 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1907 vficon_thumb_do(vf, tl, vf->thumbs_filedata); |
9 | 1908 } |
1909 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1910 while (vficon_thumb_next(vf)); |
9 | 1911 } |
1912 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1913 static gint vficon_thumb_next(ViewFile *vf) |
9 | 1914 { |
1915 GtkTreePath *tpath; | |
1916 FileData *fd = NULL; | |
1917 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1918 if (!GTK_WIDGET_REALIZED(vf->listview)) |
9 | 1919 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1920 vficon_thumb_status(vf, 0.0, NULL); |
9 | 1921 return FALSE; |
1922 } | |
1923 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1924 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL)) |
9 | 1925 { |
1926 GtkTreeModel *store; | |
1927 GtkTreeIter iter; | |
1928 gint valid = TRUE; | |
1929 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1930 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 1931 gtk_tree_model_get_iter(store, &iter, tpath); |
1932 gtk_tree_path_free(tpath); | |
1933 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1934 while (!fd && valid && tree_view_row_get_visibility(GTK_TREE_VIEW(vf->listview), &iter, FALSE) == 0) |
9 | 1935 { |
1936 GList *list; | |
1937 | |
1938 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); | |
1939 | |
1940 while (!fd && list) | |
1941 { | |
138 | 1942 IconData *id = list->data; |
845 | 1943 if (id && !id->fd->thumb_pixbuf) fd = id->fd; |
9 | 1944 list = list->next; |
1945 } | |
1946 | |
1947 valid = gtk_tree_model_iter_next(store, &iter); | |
1948 } | |
1949 } | |
1950 | |
1951 /* then find first undone */ | |
1952 | |
1953 if (!fd) | |
1954 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1955 GList *work = vf->list; |
9 | 1956 while (work && !fd) |
1957 { | |
138 | 1958 IconData *id = work->data; |
1959 FileData *fd_p = id->fd; | |
9 | 1960 work = work->next; |
1961 | |
845 | 1962 if (!fd_p->thumb_pixbuf) fd = fd_p; |
9 | 1963 } |
1964 } | |
1965 | |
1966 if (!fd) | |
1967 { | |
1968 /* done */ | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1969 vficon_thumb_cleanup(vf); |
9 | 1970 return FALSE; |
1971 } | |
1972 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1973 vf->thumbs_filedata = fd; |
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 thumb_loader_free(vf->thumbs_loader); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1976 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1977 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
|
1978 thumb_loader_set_callbacks(vf->thumbs_loader, |
9 | 1979 vficon_thumb_done_cb, |
1980 vficon_thumb_error_cb, | |
1981 NULL, | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1982 vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1983 |
838 | 1984 if (!thumb_loader_start(vf->thumbs_loader, fd)) |
9 | 1985 { |
1986 /* set icon to unknown, continue */ | |
838 | 1987 DEBUG_1("thumb loader start failed %s", fd->path); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1988 vficon_thumb_do(vf, vf->thumbs_loader, fd); |
9 | 1989 |
1990 return TRUE; | |
1991 } | |
1992 | |
1993 return FALSE; | |
1994 } | |
1995 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1996 static void vficon_thumb_update(ViewFile *vf) |
9 | 1997 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1998 vficon_thumb_stop(vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1999 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2000 vficon_thumb_status(vf, 0.0, _("Loading thumbs...")); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2001 vf->thumbs_running = TRUE; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2002 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2003 while (vficon_thumb_next(vf)); |
9 | 2004 } |
2005 | |
2006 /* | |
2007 *----------------------------------------------------------------------------- | |
2008 * row stuff | |
2009 *----------------------------------------------------------------------------- | |
2010 */ | |
2011 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2012 FileData *vficon_index_get_data(ViewFile *vf, gint row) |
9 | 2013 { |
138 | 2014 IconData *id; |
442 | 2015 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2016 id = g_list_nth_data(vf->list, row); |
138 | 2017 return id ? id->fd : NULL; |
9 | 2018 } |
2019 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2020 gint vficon_index_by_path(ViewFile *vf, const gchar *path) |
9 | 2021 { |
2022 gint p = 0; | |
2023 GList *work; | |
2024 | |
2025 if (!path) return -1; | |
2026 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2027 work = vf->list; |
9 | 2028 while (work) |
2029 { | |
138 | 2030 IconData *id = work->data; |
2031 FileData *fd = id->fd; | |
9 | 2032 if (strcmp(path, fd->path) == 0) return p; |
2033 work = work->next; | |
2034 p++; | |
2035 } | |
2036 | |
2037 return -1; | |
2038 } | |
2039 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2040 gint vficon_index_by_fd(ViewFile *vf, FileData *in_fd) |
138 | 2041 { |
2042 gint p = 0; | |
2043 GList *work; | |
2044 | |
2045 if (!in_fd) return -1; | |
2046 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2047 work = vf->list; |
138 | 2048 while (work) |
2049 { | |
2050 IconData *id = work->data; | |
2051 FileData *fd = id->fd; | |
2052 if (fd == in_fd) return p; | |
2053 work = work->next; | |
2054 p++; | |
2055 } | |
2056 | |
2057 return -1; | |
2058 } | |
2059 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2060 static gint vficon_index_by_id(ViewFile *vf, IconData *in_id) |
138 | 2061 { |
2062 gint p = 0; | |
2063 GList *work; | |
2064 | |
2065 if (!in_id) return -1; | |
2066 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2067 work = vf->list; |
138 | 2068 while (work) |
2069 { | |
2070 IconData *id = work->data; | |
2071 if (id == in_id) return p; | |
2072 work = work->next; | |
2073 p++; | |
2074 } | |
2075 | |
2076 return -1; | |
2077 } | |
2078 | |
736 | 2079 guint vficon_count(ViewFile *vf, gint64 *bytes) |
9 | 2080 { |
2081 if (bytes) | |
2082 { | |
2083 gint64 b = 0; | |
2084 GList *work; | |
2085 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2086 work = vf->list; |
9 | 2087 while (work) |
2088 { | |
138 | 2089 IconData *id = work->data; |
2090 FileData *fd = id->fd; | |
9 | 2091 work = work->next; |
579 | 2092 |
9 | 2093 b += fd->size; |
2094 } | |
2095 | |
2096 *bytes = b; | |
2097 } | |
2098 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2099 return g_list_length(vf->list); |
9 | 2100 } |
2101 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2102 GList *vficon_get_list(ViewFile *vf) |
9 | 2103 { |
2104 GList *list = NULL; | |
2105 GList *work; | |
2106 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2107 work = vf->list; |
9 | 2108 while (work) |
2109 { | |
138 | 2110 IconData *id = work->data; |
2111 FileData *fd = id->fd; | |
9 | 2112 work = work->next; |
2113 | |
138 | 2114 list = g_list_prepend(list, file_data_ref(fd)); |
9 | 2115 } |
2116 | |
2117 return g_list_reverse(list); | |
2118 } | |
2119 | |
2120 /* | |
2121 *----------------------------------------------------------------------------- | |
2122 * | |
2123 *----------------------------------------------------------------------------- | |
2124 */ | |
2125 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2126 static gint vficon_refresh_real(ViewFile *vf, gint keep_position) |
9 | 2127 { |
2128 gint ret = TRUE; | |
810 | 2129 GList *work, *work_fd; |
138 | 2130 IconData *focus_id; |
810 | 2131 GList *new_filelist = NULL; |
996
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2132 FileData *first_selected = NULL; |
832 | 2133 GList *new_iconlist = NULL; |
138 | 2134 |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2135 focus_id = VFICON(vf)->focus_id; |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2136 |
783 | 2137 if (vf->dir_fd) |
9 | 2138 { |
810 | 2139 ret = filelist_read(vf->dir_fd, &new_filelist, NULL); |
964 | 2140 new_filelist = file_data_filter_marks_list(new_filelist, vf_marks_get_filter(vf)); |
9 | 2141 } |
2142 | |
810 | 2143 vf->list = iconlist_sort(vf->list, vf->sort_method, vf->sort_ascend); /* the list might not be sorted if there were renames */ |
2144 new_filelist = filelist_sort(new_filelist, vf->sort_method, vf->sort_ascend); | |
2145 | |
996
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2146 if (VFICON(vf)->selection) |
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2147 { |
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2148 first_selected = ((IconData *)(VFICON(vf)->selection->data))->fd; |
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2149 file_data_ref(first_selected); |
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2150 g_list_free(VFICON(vf)->selection); |
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2151 VFICON(vf)->selection = NULL; |
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2152 |
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2153 |
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2154 } |
811 | 2155 |
9 | 2156 /* check for same files from old_list */ |
810 | 2157 work = vf->list; |
2158 work_fd = new_filelist; | |
2159 while (work || work_fd) | |
9 | 2160 { |
810 | 2161 IconData *id = NULL; |
2162 FileData *fd = NULL; | |
2163 FileData *new_fd = NULL; | |
2164 gint match; | |
2165 | |
2166 if (work && work_fd) | |
9 | 2167 { |
810 | 2168 id = work->data; |
2169 fd = id->fd; | |
2170 | |
2171 new_fd = work_fd->data; | |
2172 | |
2173 if (fd == new_fd) | |
9 | 2174 { |
810 | 2175 /* not changed, go to next */ |
2176 work = work->next; | |
2177 work_fd = work_fd->next; | |
996
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2178 if (id->selected & SELECTION_SELECTED) |
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2179 { |
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2180 VFICON(vf)->selection = g_list_prepend(VFICON(vf)->selection, id); |
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2181 } |
810 | 2182 continue; |
9 | 2183 } |
810 | 2184 |
2185 match = filelist_sort_compare_filedata_full(fd, new_fd, vf->sort_method, vf->sort_ascend); | |
2186 if (match == 0) g_warning("multiple fd for the same path"); | |
2187 } | |
2188 else if (work) | |
2189 { | |
2190 id = work->data; | |
2191 fd = id->fd; | |
2192 match = -1; | |
2193 } | |
2194 else /* work_fd */ | |
2195 { | |
2196 new_fd = work_fd->data; | |
2197 match = 1; | |
9 | 2198 } |
810 | 2199 |
2200 if (match < 0) | |
2201 { | |
2202 /* file no longer exists, delete from vf->list */ | |
2203 GList *to_delete = work; | |
2204 work = work->next; | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2205 if (id == VFICON(vf)->prev_selection) VFICON(vf)->prev_selection = NULL; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2206 if (id == VFICON(vf)->click_id) VFICON(vf)->click_id = NULL; |
810 | 2207 file_data_unref(fd); |
2208 g_free(id); | |
2209 vf->list = g_list_delete_link(vf->list, to_delete); | |
2210 } | |
2211 else | |
2212 { | |
2213 /* new file, add to vf->list */ | |
2214 id = g_new0(IconData, 1); | |
2215 | |
2216 id->selected = SELECTION_NONE; | |
2217 id->row = -1; | |
2218 id->fd = file_data_ref(new_fd); | |
832 | 2219 if (work) |
2220 vf->list = g_list_insert_before(vf->list, work, id); | |
2221 else | |
2222 new_iconlist = g_list_prepend(new_iconlist, id); /* it is faster to append all new entries together later */ | |
2223 | |
810 | 2224 work_fd = work_fd->next; |
2225 } | |
2226 | |
9 | 2227 } |
2228 | |
832 | 2229 if (new_iconlist) |
2230 { | |
2231 vf->list = g_list_concat(vf->list, g_list_reverse(new_iconlist)); | |
2232 } | |
996
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2233 |
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2234 VFICON(vf)->selection = g_list_reverse(VFICON(vf)->selection); |
832 | 2235 |
810 | 2236 filelist_free(new_filelist); |
9 | 2237 |
831
b02a24ebf441
fixed iconview update after deletion of selected image
nadvornik
parents:
817
diff
changeset
|
2238 vficon_populate(vf, TRUE, keep_position); |
b02a24ebf441
fixed iconview update after deletion of selected image
nadvornik
parents:
817
diff
changeset
|
2239 |
996
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2240 if (first_selected && !VFICON(vf)->selection) |
811 | 2241 { |
2242 /* all selected files disappeared */ | |
996
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2243 vficon_select_closest(vf, first_selected); |
811 | 2244 } |
996
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2245 file_data_unref(first_selected); |
4794cf5ecd8e
correctly maintain selection during iconlist refresh
nadvornik
parents:
995
diff
changeset
|
2246 |
9 | 2247 /* attempt to keep focus on same icon when refreshing */ |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2248 if (focus_id && g_list_find(vf->list, focus_id)) |
9 | 2249 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2250 vficon_set_focus(vf, focus_id); |
9 | 2251 } |
2252 | |
2253 return ret; | |
2254 } | |
2255 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2256 gint vficon_refresh(ViewFile *vf) |
9 | 2257 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2258 return vficon_refresh_real(vf, TRUE); |
9 | 2259 } |
2260 | |
2261 /* | |
2262 *----------------------------------------------------------------------------- | |
2263 * draw, etc. | |
2264 *----------------------------------------------------------------------------- | |
2265 */ | |
2266 | |
2267 typedef struct _ColumnData ColumnData; | |
2268 struct _ColumnData | |
2269 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2270 ViewFile *vf; |
9 | 2271 gint number; |
2272 }; | |
2273 | |
2274 static void vficon_cell_data_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, | |
2275 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) | |
2276 { | |
2277 ColumnData *cd = data; | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2278 ViewFile *vf; |
9 | 2279 GtkStyle *style; |
2280 GList *list; | |
2281 GdkColor color_fg; | |
2282 GdkColor color_bg; | |
138 | 2283 IconData *id; |
9 | 2284 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2285 vf = cd->vf; |
9 | 2286 |
2287 gtk_tree_model_get(tree_model, iter, FILE_COLUMN_POINTER, &list, -1); | |
442 | 2288 |
138 | 2289 id = g_list_nth_data(list, cd->number); |
442 | 2290 |
138 | 2291 if (id) g_assert(id->fd->magick == 0x12345678); |
442 | 2292 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2293 style = gtk_widget_get_style(vf->listview); |
138 | 2294 if (id && id->selected & SELECTION_SELECTED) |
9 | 2295 { |
2296 memcpy(&color_fg, &style->text[GTK_STATE_SELECTED], sizeof(color_fg)); | |
2297 memcpy(&color_bg, &style->base[GTK_STATE_SELECTED], sizeof(color_bg)); | |
2298 } | |
2299 else | |
2300 { | |
2301 memcpy(&color_fg, &style->text[GTK_STATE_NORMAL], sizeof(color_fg)); | |
2302 memcpy(&color_bg, &style->base[GTK_STATE_NORMAL], sizeof(color_bg)); | |
2303 } | |
2304 | |
138 | 2305 if (id && id->selected & SELECTION_PRELIGHT) |
9 | 2306 { |
2307 #if 0 | |
2308 shift_color(&color_fg, -1, 0); | |
2309 #endif | |
2310 shift_color(&color_bg, -1, 0); | |
2311 } | |
2312 | |
2313 if (GQV_IS_CELL_RENDERER_ICON(cell)) | |
442 | 2314 { |
138 | 2315 if (id) |
9 | 2316 { |
851 | 2317 gchar *name_sidecars = (gchar *)id->fd->name; |
2318 gchar *sidecars = NULL; | |
2319 | |
2320 if (id->fd->sidecar_files) | |
2321 { | |
2322 sidecars = file_data_sc_list_to_string(id->fd); | |
2323 name_sidecars = g_strdup_printf("%s %s", id->fd->name, sidecars); | |
2324 } | |
2325 | |
845 | 2326 g_object_set(cell, "pixbuf", id->fd->thumb_pixbuf, |
851 | 2327 "text", name_sidecars, |
966 | 2328 "marks", file_data_get_marks(id->fd), |
852 | 2329 "show_marks", vf->marks_enabled, |
9 | 2330 "cell-background-gdk", &color_bg, |
2331 "cell-background-set", TRUE, | |
2332 "foreground-gdk", &color_fg, | |
2333 "foreground-set", TRUE, | |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2334 "has-focus", (VFICON(vf)->focus_id == id), NULL); |
851 | 2335 if (sidecars) |
2336 { | |
2337 g_free(sidecars); | |
2338 g_free(name_sidecars); | |
2339 } | |
9 | 2340 } |
2341 else | |
2342 { | |
2343 g_object_set(cell, "pixbuf", NULL, | |
2344 "text", NULL, | |
852 | 2345 "show_marks", FALSE, |
9 | 2346 "cell-background-set", FALSE, |
2347 "foreground-set", FALSE, | |
2348 "has-focus", FALSE, NULL); | |
442 | 2349 } |
9 | 2350 } |
2351 } | |
2352 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2353 static void vficon_append_column(ViewFile *vf, gint n) |
9 | 2354 { |
2355 ColumnData *cd; | |
2356 GtkTreeViewColumn *column; | |
2357 GtkCellRenderer *renderer; | |
2358 | |
2359 column = gtk_tree_view_column_new(); | |
2360 gtk_tree_view_column_set_min_width(column, 0); | |
2361 | |
2362 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); | |
2363 gtk_tree_view_column_set_alignment(column, 0.5); | |
2364 | |
2365 renderer = gqv_cell_renderer_icon_new(); | |
2366 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
2367 g_object_set(G_OBJECT(renderer), "xpad", THUMB_BORDER_PADDING * 2, | |
2368 "ypad", THUMB_BORDER_PADDING, | |
2369 "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL); | |
2370 | |
2371 g_object_set_data(G_OBJECT(column), "column_number", GINT_TO_POINTER(n)); | |
966 | 2372 g_object_set_data(G_OBJECT(renderer), "column_number", GINT_TO_POINTER(n)); |
9 | 2373 |
2374 cd = g_new0(ColumnData, 1); | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2375 cd->vf = vf; |
9 | 2376 cd->number = n; |
2377 gtk_tree_view_column_set_cell_data_func(column, renderer, vficon_cell_data_cb, cd, g_free); | |
2378 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2379 gtk_tree_view_append_column(GTK_TREE_VIEW(vf->listview), column); |
966 | 2380 |
2381 g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(vficon_mark_toggled_cb), vf); | |
9 | 2382 } |
2383 | |
2384 /* | |
2385 *----------------------------------------------------------------------------- | |
2386 * base | |
2387 *----------------------------------------------------------------------------- | |
2388 */ | |
2389 | |
783 | 2390 gint vficon_set_fd(ViewFile *vf, FileData *dir_fd) |
9 | 2391 { |
2392 gint ret; | |
2393 | |
783 | 2394 if (!dir_fd) return FALSE; |
2395 if (vf->dir_fd == dir_fd) return TRUE; | |
2396 | |
2397 file_data_unref(vf->dir_fd); | |
2398 vf->dir_fd = file_data_ref(dir_fd); | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2399 |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2400 g_list_free(VFICON(vf)->selection); |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2401 VFICON(vf)->selection = NULL; |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2402 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2403 iconlist_free(vf->list); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2404 vf->list = NULL; |
9 | 2405 |
2406 /* NOTE: populate will clear the store for us */ | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2407 ret = vficon_refresh_real(vf, FALSE); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2408 |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2409 VFICON(vf)->focus_id = NULL; |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2410 vficon_move_focus(vf, 0, 0, FALSE); |
9 | 2411 |
2412 return ret; | |
2413 } | |
2414 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
562
diff
changeset
|
2415 void vficon_destroy_cb(GtkWidget *widget, gpointer data) |
9 | 2416 { |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2417 ViewFile *vf = data; |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2418 |
814 | 2419 vf_refresh_idle_cancel(vf); |
787 | 2420 |
814 | 2421 file_data_unregister_notify_func(vf_notify_cb, vf); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2422 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2423 tip_unschedule(vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2424 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2425 vficon_thumb_cleanup(vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2426 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2427 iconlist_free(vf->list); |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2428 g_list_free(VFICON(vf)->selection); |
9 | 2429 } |
2430 | |
783 | 2431 ViewFile *vficon_new(ViewFile *vf, FileData *dir_fd) |
9 | 2432 { |
2433 GtkListStore *store; | |
2434 GtkTreeSelection *selection; | |
2435 gint i; | |
2436 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2437 vf->info = g_new0(ViewFileInfoIcon, 1); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2438 |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2439 VFICON(vf)->selection = NULL; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2440 VFICON(vf)->prev_selection = NULL; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2441 |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2442 VFICON(vf)->tip_window = NULL; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2443 VFICON(vf)->tip_delay_id = -1; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2444 |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2445 VFICON(vf)->focus_row = 0; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2446 VFICON(vf)->focus_column = 0; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2447 VFICON(vf)->focus_id = NULL; |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2448 |
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2449 VFICON(vf)->show_text = options->show_icon_names; |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2450 |
9 | 2451 store = gtk_list_store_new(1, G_TYPE_POINTER); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2452 vf->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); |
9 | 2453 g_object_unref(store); |
2454 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2455 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 2456 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_NONE); |
2457 | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2458 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
|
2459 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vf->listview), FALSE); |
9 | 2460 |
2461 for (i = 0; i < VFICON_MAX_COLUMNS; i++) | |
2462 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2463 vficon_append_column(vf, i); |
9 | 2464 } |
2465 | |
2466 /* 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
|
2467 vficon_append_column(vf, i); |
9 | 2468 /* end column to fill white space */ |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2469 vficon_append_column(vf, i); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2470 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2471 g_signal_connect(G_OBJECT(vf->listview), "size_allocate", |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2472 G_CALLBACK(vficon_sized_cb), vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2473 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2474 gtk_widget_set_events(vf->listview, GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK | |
9 | 2475 GDK_BUTTON_PRESS_MASK | GDK_LEAVE_NOTIFY_MASK); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2476 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2477 g_signal_connect(G_OBJECT(vf->listview),"motion_notify_event", |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2478 G_CALLBACK(vficon_motion_cb), vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2479 g_signal_connect(G_OBJECT(vf->listview), "leave_notify_event", |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2480 G_CALLBACK(vficon_leave_cb), vf); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2481 |
968
065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
zas_
parents:
967
diff
changeset
|
2482 /* force VFICON(vf)->columns to be at least 1 (sane) - this will be corrected in the size_cb */ |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2483 vficon_populate_at_new_size(vf, 1, 1, FALSE); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2484 |
814 | 2485 file_data_register_notify_func(vf_notify_cb, vf, NOTIFY_PRIORITY_MEDIUM); |
787 | 2486 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
2487 return vf; |
9 | 2488 } |
2489 | |
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
1005
diff
changeset
|
2490 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |