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