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