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