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