Mercurial > geeqie
annotate src/view_file_list.c @ 138:71e1ebee420e
replaced gchar* path with FileData *fd
author | nadvornik |
---|---|
date | Tue, 11 Sep 2007 20:06:29 +0000 |
parents | 661cd91e5a7e |
children | 754c1e4349b6 |
rev | line source |
---|---|
9 | 1 /* |
2 * GQview | |
3 * (C) 2004 John Ellis | |
4 * | |
5 * Author: John Ellis | |
6 * | |
7 * This software is released under the GNU General Public License (GNU GPL). | |
8 * Please read the included file COPYING for more information. | |
9 * This software comes with no warranty of any kind, use at your own risk! | |
10 */ | |
11 | |
12 #include "gqview.h" | |
13 #include "view_file_list.h" | |
14 | |
15 #include "cache_maint.h" | |
16 #include "dnd.h" | |
17 #include "editors.h" | |
18 #include "img-view.h" | |
19 #include "info.h" | |
20 #include "layout.h" | |
21 #include "layout_image.h" | |
22 #include "menu.h" | |
23 #include "thumb.h" | |
24 #include "utilops.h" | |
25 #include "ui_bookmark.h" | |
26 #include "ui_fileops.h" | |
27 #include "ui_menu.h" | |
28 #include "ui_tree_edit.h" | |
132 | 29 #include "typedefs.h" |
9 | 30 |
31 #include <gdk/gdkkeysyms.h> /* for keyboard values */ | |
32 | |
33 | |
34 enum { | |
35 FILE_COLUMN_POINTER = 0, | |
36 FILE_COLUMN_THUMB, | |
37 FILE_COLUMN_NAME, | |
38 FILE_COLUMN_SIZE, | |
39 FILE_COLUMN_DATE, | |
40 FILE_COLUMN_COLOR, | |
132 | 41 FILE_COLUMN_MARKS, |
9 | 42 FILE_COLUMN_COUNT |
43 }; | |
44 | |
45 | |
46 static gint vflist_row_is_selected(ViewFileList *vfl, FileData *fd); | |
47 static gint vflist_row_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data); | |
48 static void vflist_populate_view(ViewFileList *vfl); | |
49 | |
50 /* | |
51 *----------------------------------------------------------------------------- | |
52 * signals | |
53 *----------------------------------------------------------------------------- | |
54 */ | |
55 | |
56 static void vflist_send_update(ViewFileList *vfl) | |
57 { | |
58 if (vfl->func_status) vfl->func_status(vfl, vfl->data_status); | |
59 } | |
60 | |
61 /* | |
62 *----------------------------------------------------------------------------- | |
63 * misc | |
64 *----------------------------------------------------------------------------- | |
65 */ | |
66 | |
67 static gint vflist_find_row(ViewFileList *vfl, FileData *fd, GtkTreeIter *iter) | |
68 { | |
69 GtkTreeModel *store; | |
70 gint valid; | |
71 gint row = 0; | |
72 | |
73 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)); | |
74 valid = gtk_tree_model_get_iter_first(store, iter); | |
75 while (valid) | |
76 { | |
77 FileData *fd_n; | |
78 gtk_tree_model_get(GTK_TREE_MODEL(store), iter, FILE_COLUMN_POINTER, &fd_n, -1); | |
79 if (fd_n == fd) return row; | |
80 | |
81 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), iter); | |
82 row++; | |
83 } | |
84 | |
85 return -1; | |
86 } | |
87 | |
88 static void vflist_color_set(ViewFileList *vfl, FileData *fd, gint color_set) | |
89 { | |
90 GtkTreeModel *store; | |
91 GtkTreeIter iter; | |
92 | |
93 if (vflist_find_row(vfl, fd, &iter) < 0) return; | |
94 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)); | |
95 gtk_list_store_set(GTK_LIST_STORE(store), &iter, FILE_COLUMN_COLOR, color_set, -1); | |
96 } | |
97 | |
98 static void vflist_move_cursor(ViewFileList *vfl, GtkTreeIter *iter) | |
99 { | |
100 GtkTreeModel *store; | |
101 GtkTreePath *tpath; | |
102 | |
103 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)); | |
104 | |
105 tpath = gtk_tree_model_get_path(store, iter); | |
106 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vfl->listview), tpath, NULL, FALSE); | |
107 gtk_tree_path_free(tpath); | |
108 } | |
109 | |
110 /* | |
111 *----------------------------------------------------------------------------- | |
112 * dnd | |
113 *----------------------------------------------------------------------------- | |
114 */ | |
115 | |
116 static void vflist_dnd_get(GtkWidget *widget, GdkDragContext *context, | |
117 GtkSelectionData *selection_data, guint info, | |
118 guint time, gpointer data) | |
119 { | |
120 ViewFileList *vfl = data; | |
121 GList *list = NULL; | |
122 gchar *uri_text = NULL; | |
123 gint total; | |
124 | |
125 if (!vfl->click_fd) return; | |
126 | |
127 if (vflist_row_is_selected(vfl, vfl->click_fd)) | |
128 { | |
129 list = vflist_selection_get_list(vfl); | |
130 } | |
131 else | |
132 { | |
138 | 133 list = g_list_append(NULL, file_data_ref(vfl->click_fd)); |
9 | 134 } |
135 | |
136 if (!list) return; | |
137 | |
138 | 138 uri_text = uri_text_from_filelist(list, &total, (info == TARGET_TEXT_PLAIN)); |
139 filelist_free(list); | |
9 | 140 |
141 if (debug) printf(uri_text); | |
142 | |
64
04ff0df3ad2f
Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
143 gtk_selection_data_set(selection_data, selection_data->target, |
04ff0df3ad2f
Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
144 8, (guchar *)uri_text, total); |
9 | 145 g_free(uri_text); |
146 } | |
147 | |
148 static void vflist_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
149 { | |
150 ViewFileList *vfl = data; | |
151 | |
152 vflist_color_set(vfl, vfl->click_fd, TRUE); | |
153 | |
154 if (vfl->thumbs_enabled && | |
155 vfl->click_fd && vfl->click_fd->pixbuf) | |
156 { | |
157 gint items; | |
158 | |
159 if (vflist_row_is_selected(vfl, vfl->click_fd)) | |
160 items = vflist_selection_count(vfl, NULL); | |
161 else | |
162 items = 1; | |
163 | |
164 dnd_set_drag_icon(widget, context, vfl->click_fd->pixbuf, items); | |
165 } | |
166 } | |
167 | |
168 static void vflist_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
169 { | |
170 ViewFileList *vfl = data; | |
171 | |
172 vflist_color_set(vfl, vfl->click_fd, FALSE); | |
173 | |
174 if (context->action == GDK_ACTION_MOVE) | |
175 { | |
176 vflist_refresh(vfl); | |
177 } | |
178 } | |
179 | |
180 static void vflist_dnd_init(ViewFileList *vfl) | |
181 { | |
182 gtk_drag_source_set(vfl->listview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, | |
183 dnd_file_drag_types, dnd_file_drag_types_count, | |
184 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); | |
185 g_signal_connect(G_OBJECT(vfl->listview), "drag_data_get", | |
186 G_CALLBACK(vflist_dnd_get), vfl); | |
187 g_signal_connect(G_OBJECT(vfl->listview), "drag_begin", | |
188 G_CALLBACK(vflist_dnd_begin), vfl); | |
189 g_signal_connect(G_OBJECT(vfl->listview), "drag_end", | |
190 G_CALLBACK(vflist_dnd_end), vfl); | |
191 } | |
192 | |
193 /* | |
194 *----------------------------------------------------------------------------- | |
195 * pop-up menu | |
196 *----------------------------------------------------------------------------- | |
197 */ | |
198 | |
199 static GList *vflist_pop_menu_file_list(ViewFileList *vfl) | |
200 { | |
201 if (!vfl->click_fd) return NULL; | |
202 | |
203 if (vflist_row_is_selected(vfl, vfl->click_fd)) | |
204 { | |
205 return vflist_selection_get_list(vfl); | |
206 } | |
207 | |
138 | 208 return g_list_append(NULL, file_data_ref(vfl->click_fd)); |
9 | 209 } |
210 | |
211 static void vflist_pop_menu_edit_cb(GtkWidget *widget, gpointer data) | |
212 { | |
213 ViewFileList *vfl; | |
214 gint n; | |
215 GList *list; | |
216 | |
217 vfl = submenu_item_get_data(widget); | |
218 n = GPOINTER_TO_INT(data); | |
219 | |
220 if (!vfl) return; | |
221 | |
222 list = vflist_pop_menu_file_list(vfl); | |
138 | 223 start_editor_from_filelist(n, list); |
224 filelist_free(list); | |
9 | 225 } |
226 | |
227 static void vflist_pop_menu_info_cb(GtkWidget *widget, gpointer data) | |
228 { | |
229 ViewFileList *vfl = data; | |
230 | |
231 info_window_new(NULL, vflist_pop_menu_file_list(vfl)); | |
232 } | |
233 | |
234 static void vflist_pop_menu_view_cb(GtkWidget *widget, gpointer data) | |
235 { | |
236 ViewFileList *vfl = data; | |
237 | |
238 if (vflist_row_is_selected(vfl, vfl->click_fd)) | |
239 { | |
240 GList *list; | |
241 | |
242 list = vflist_selection_get_list(vfl); | |
243 view_window_new_from_list(list); | |
138 | 244 filelist_free(list); |
9 | 245 } |
246 else | |
247 { | |
138 | 248 view_window_new(vfl->click_fd); |
9 | 249 } |
250 } | |
251 | |
252 static void vflist_pop_menu_copy_cb(GtkWidget *widget, gpointer data) | |
253 { | |
254 ViewFileList *vfl = data; | |
255 | |
256 file_util_copy(NULL, vflist_pop_menu_file_list(vfl), NULL, vfl->listview); | |
257 } | |
258 | |
259 static void vflist_pop_menu_move_cb(GtkWidget *widget, gpointer data) | |
260 { | |
261 ViewFileList *vfl = data; | |
262 | |
263 file_util_move(NULL, vflist_pop_menu_file_list(vfl), NULL, vfl->listview); | |
264 } | |
265 | |
266 static void vflist_pop_menu_rename_cb(GtkWidget *widget, gpointer data) | |
267 { | |
268 ViewFileList *vfl = data; | |
269 GList *list; | |
270 | |
271 list = vflist_pop_menu_file_list(vfl); | |
272 if (enable_in_place_rename && | |
273 list && !list->next && vfl->click_fd) | |
274 { | |
275 GtkTreeModel *store; | |
276 GtkTreeIter iter; | |
277 | |
138 | 278 filelist_free(list); |
9 | 279 |
280 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)); | |
281 if (vflist_find_row(vfl, vfl->click_fd, &iter) >= 0) | |
282 { | |
283 GtkTreePath *tpath; | |
284 | |
285 tpath = gtk_tree_model_get_path(store, &iter); | |
286 tree_edit_by_path(GTK_TREE_VIEW(vfl->listview), tpath, | |
287 FILE_COLUMN_NAME -1, vfl->click_fd->name, | |
288 vflist_row_rename_cb, vfl); | |
289 gtk_tree_path_free(tpath); | |
290 } | |
291 return; | |
292 } | |
293 | |
294 file_util_rename(NULL, list, vfl->listview); | |
295 } | |
296 | |
297 static void vflist_pop_menu_delete_cb(GtkWidget *widget, gpointer data) | |
298 { | |
299 ViewFileList *vfl = data; | |
300 | |
301 file_util_delete(NULL, vflist_pop_menu_file_list(vfl), vfl->listview); | |
302 } | |
303 | |
304 static void vflist_pop_menu_sort_cb(GtkWidget *widget, gpointer data) | |
305 { | |
306 ViewFileList *vfl; | |
307 SortType type; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
111
diff
changeset
|
308 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
111
diff
changeset
|
309 if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return; |
9 | 310 |
311 vfl = submenu_item_get_data(widget); | |
312 if (!vfl) return; | |
313 | |
314 type = (SortType)GPOINTER_TO_INT(data); | |
315 | |
316 if (vfl->layout) | |
317 { | |
318 layout_sort_set(vfl->layout, type, vfl->sort_ascend); | |
319 } | |
320 else | |
321 { | |
322 vflist_sort_set(vfl, type, vfl->sort_ascend); | |
323 } | |
324 } | |
325 | |
326 static void vflist_pop_menu_sort_ascend_cb(GtkWidget *widget, gpointer data) | |
327 { | |
328 ViewFileList *vfl = data; | |
329 | |
330 if (vfl->layout) | |
331 { | |
332 layout_sort_set(vfl->layout, vfl->sort_method, !vfl->sort_ascend); | |
333 } | |
334 else | |
335 { | |
336 vflist_sort_set(vfl, vfl->sort_method, !vfl->sort_ascend); | |
337 } | |
338 } | |
339 | |
340 static void vflist_pop_menu_icons_cb(GtkWidget *widget, gpointer data) | |
341 { | |
342 ViewFileList *vfl = data; | |
343 | |
344 if (vfl->layout) layout_views_set(vfl->layout, vfl->layout->tree_view, TRUE); | |
345 } | |
346 | |
347 static void vflist_pop_menu_thumbs_cb(GtkWidget *widget, gpointer data) | |
348 { | |
349 ViewFileList *vfl = data; | |
350 | |
351 vflist_color_set(vfl, vfl->click_fd, FALSE); | |
352 if (vfl->layout) | |
353 { | |
354 layout_thumb_set(vfl->layout, !vfl->thumbs_enabled); | |
355 } | |
356 else | |
357 { | |
358 vflist_thumb_set(vfl, !vfl->thumbs_enabled); | |
359 } | |
360 } | |
361 | |
362 static void vflist_pop_menu_refresh_cb(GtkWidget *widget, gpointer data) | |
363 { | |
364 ViewFileList *vfl = data; | |
365 | |
366 vflist_color_set(vfl, vfl->click_fd, FALSE); | |
367 vflist_refresh(vfl); | |
368 } | |
369 | |
370 static void vflist_popup_destroy_cb(GtkWidget *widget, gpointer data) | |
371 { | |
372 ViewFileList *vfl = data; | |
373 vflist_color_set(vfl, vfl->click_fd, FALSE); | |
374 vfl->click_fd = NULL; | |
375 vfl->popup = NULL; | |
376 } | |
377 | |
378 static GtkWidget *vflist_pop_menu(ViewFileList *vfl, FileData *fd) | |
379 { | |
380 GtkWidget *menu; | |
381 GtkWidget *item; | |
382 GtkWidget *submenu; | |
383 gint active; | |
384 | |
385 vflist_color_set(vfl, fd, TRUE); | |
386 active = (fd != NULL); | |
387 | |
388 menu = popup_menu_short_lived(); | |
389 g_signal_connect(G_OBJECT(menu), "destroy", | |
390 G_CALLBACK(vflist_popup_destroy_cb), vfl); | |
391 | |
392 submenu_add_edit(menu, &item, G_CALLBACK(vflist_pop_menu_edit_cb), vfl); | |
393 gtk_widget_set_sensitive(item, active); | |
394 | |
395 menu_item_add_stock_sensitive(menu, _("_Properties"), GTK_STOCK_PROPERTIES, active, | |
396 G_CALLBACK(vflist_pop_menu_info_cb), vfl); | |
397 menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, active, | |
398 G_CALLBACK(vflist_pop_menu_view_cb), vfl); | |
399 | |
400 menu_item_add_divider(menu); | |
401 menu_item_add_stock_sensitive(menu, _("_Copy..."), GTK_STOCK_COPY, active, | |
402 G_CALLBACK(vflist_pop_menu_copy_cb), vfl); | |
403 menu_item_add_sensitive(menu, _("_Move..."), active, | |
404 G_CALLBACK(vflist_pop_menu_move_cb), vfl); | |
405 menu_item_add_sensitive(menu, _("_Rename..."), active, | |
406 G_CALLBACK(vflist_pop_menu_rename_cb), vfl); | |
407 menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, active, | |
408 G_CALLBACK(vflist_pop_menu_delete_cb), vfl); | |
409 | |
410 menu_item_add_divider(menu); | |
411 | |
412 submenu = submenu_add_sort(NULL, G_CALLBACK(vflist_pop_menu_sort_cb), vfl, | |
413 FALSE, FALSE, TRUE, vfl->sort_method); | |
414 menu_item_add_divider(submenu); | |
415 menu_item_add_check(submenu, _("Ascending"), vfl->sort_ascend, | |
416 G_CALLBACK(vflist_pop_menu_sort_ascend_cb), vfl); | |
417 | |
418 item = menu_item_add(menu, _("_Sort"), NULL, NULL); | |
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); | |
420 | |
421 menu_item_add_check(menu, _("View as _icons"), FALSE, | |
422 G_CALLBACK(vflist_pop_menu_icons_cb), vfl); | |
423 menu_item_add_check(menu, _("Show _thumbnails"), vfl->thumbs_enabled, | |
424 G_CALLBACK(vflist_pop_menu_thumbs_cb), vfl); | |
425 menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH, G_CALLBACK(vflist_pop_menu_refresh_cb), vfl); | |
426 | |
427 return menu; | |
428 } | |
429 | |
430 /* | |
431 *----------------------------------------------------------------------------- | |
432 * callbacks | |
433 *----------------------------------------------------------------------------- | |
434 */ | |
435 | |
436 static gint vflist_row_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data) | |
437 { | |
438 ViewFileList *vfl = data; | |
439 gchar *old_path; | |
440 gchar *new_path; | |
441 | |
442 if (strlen(new) == 0) return FALSE; | |
443 | |
444 old_path = concat_dir_and_file(vfl->path, old); | |
445 new_path = concat_dir_and_file(vfl->path, new); | |
446 | |
447 if (strchr(new, '/') != NULL) | |
448 { | |
449 gchar *text = g_strdup_printf(_("Invalid file name:\n%s"), new); | |
450 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, vfl->listview); | |
451 g_free(text); | |
452 } | |
453 else if (isfile(new_path)) | |
454 { | |
455 gchar *text = g_strdup_printf(_("A file with name %s already exists."), new); | |
456 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, vfl->listview); | |
457 g_free(text); | |
458 } | |
138 | 459 else |
9 | 460 { |
138 | 461 gint row = vflist_index_by_path(vfl, old_path); |
462 if (row >= 0) | |
463 { | |
464 GList *work = g_list_nth(vfl->list, row); | |
465 FileData *fd = work->data; | |
466 file_data_change_info_new(old_path, new_path, fd); | |
467 if (!rename_file_ext(fd)) | |
468 { | |
469 gchar *text = g_strdup_printf(_("Unable to rename file:\n%s\nto:\n%s"), old, new); | |
470 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, vfl->listview); | |
471 g_free(text); | |
472 } | |
473 } | |
474 | |
9 | 475 } |
476 g_free(old_path); | |
477 g_free(new_path); | |
478 | |
479 return FALSE; | |
480 } | |
481 | |
482 static void vflist_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) | |
483 { | |
484 ViewFileList *vfl = data; | |
485 GtkTreeModel *store; | |
486 GtkTreeIter iter; | |
487 GtkTreePath *tpath; | |
488 gint cw, ch; | |
489 | |
490 if (vflist_find_row(vfl, vfl->click_fd, &iter) < 0) return; | |
491 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)); | |
492 tpath = gtk_tree_model_get_path(store, &iter); | |
493 tree_view_get_cell_clamped(GTK_TREE_VIEW(vfl->listview), tpath, FILE_COLUMN_NAME - 1, TRUE, x, y, &cw, &ch); | |
494 gtk_tree_path_free(tpath); | |
495 *y += ch; | |
496 popup_menu_position_clamp(menu, x, y, 0); | |
497 } | |
498 | |
499 static gint vflist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) | |
500 { | |
501 ViewFileList *vfl = data; | |
502 GtkTreePath *tpath; | |
503 | |
504 if (event->keyval != GDK_Menu) return FALSE; | |
505 | |
506 gtk_tree_view_get_cursor(GTK_TREE_VIEW(vfl->listview), &tpath, NULL); | |
507 if (tpath) | |
508 { | |
509 GtkTreeModel *store; | |
510 GtkTreeIter iter; | |
511 | |
512 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); | |
513 gtk_tree_model_get_iter(store, &iter, tpath); | |
514 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &vfl->click_fd, -1); | |
515 gtk_tree_path_free(tpath); | |
516 } | |
517 else | |
518 { | |
519 vfl->click_fd = NULL; | |
520 } | |
521 | |
522 vfl->popup = vflist_pop_menu(vfl, vfl->click_fd); | |
523 gtk_menu_popup(GTK_MENU(vfl->popup), NULL, NULL, vflist_menu_position_cb, vfl, 0, GDK_CURRENT_TIME); | |
524 | |
525 return TRUE; | |
526 } | |
527 | |
528 static gint vflist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) | |
529 { | |
530 ViewFileList *vfl = data; | |
531 GtkTreePath *tpath; | |
532 GtkTreeIter iter; | |
533 FileData *fd = NULL; | |
132 | 534 GtkTreeViewColumn *column; |
535 gint colnum; | |
536 | |
9 | 537 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, |
132 | 538 &tpath, &column, NULL, NULL)) |
9 | 539 { |
540 GtkTreeModel *store; | |
132 | 541 colnum = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(column), "column")); |
542 | |
543 if (colnum <= FILE_COLUMN_MARKS - 2 + FILEDATA_MARKS_SIZE && colnum >= FILE_COLUMN_MARKS - 2) | |
544 return FALSE; | |
545 | |
546 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); | |
9 | 547 |
548 gtk_tree_model_get_iter(store, &iter, tpath); | |
549 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
550 #if 0 | |
551 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE); | |
552 #endif | |
553 gtk_tree_path_free(tpath); | |
554 } | |
555 | |
556 vfl->click_fd = fd; | |
557 | |
558 if (bevent->button == 3) | |
559 { | |
560 vfl->popup = vflist_pop_menu(vfl, vfl->click_fd); | |
561 gtk_menu_popup(GTK_MENU(vfl->popup), NULL, NULL, NULL, NULL, | |
562 bevent->button, bevent->time); | |
563 return TRUE; | |
564 } | |
565 | |
566 if (!fd) return FALSE; | |
567 | |
568 if (bevent->button == 2) | |
569 { | |
570 if (!vflist_row_is_selected(vfl, fd)) | |
571 { | |
572 vflist_color_set(vfl, fd, TRUE); | |
573 } | |
574 return TRUE; | |
575 } | |
576 | |
577 | |
578 if (bevent->button == 1 && bevent->type == GDK_BUTTON_PRESS && | |
579 !(bevent->state & GDK_SHIFT_MASK ) && | |
580 !(bevent->state & GDK_CONTROL_MASK ) && | |
581 vflist_row_is_selected(vfl, fd)) | |
582 { | |
583 gtk_widget_grab_focus(widget); | |
584 return TRUE; | |
585 } | |
586 | |
587 #if 0 | |
588 if (bevent->button == 1 && bevent->type == GDK_2BUTTON_PRESS) | |
589 { | |
590 if (vfl->layout) layout_image_full_screen_start(vfl->layout); | |
591 } | |
592 #endif | |
593 | |
594 return FALSE; | |
595 } | |
596 | |
597 static gint vflist_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) | |
598 { | |
599 ViewFileList *vfl = data; | |
600 GtkTreePath *tpath; | |
601 GtkTreeIter iter; | |
602 FileData *fd = NULL; | |
603 | |
604 if (bevent->button == 2) | |
605 { | |
606 vflist_color_set(vfl, vfl->click_fd, FALSE); | |
607 } | |
608 | |
609 if (bevent->button != 1 && bevent->button != 2) | |
610 { | |
611 return TRUE; | |
612 } | |
613 | |
614 if ((bevent->x != 0 || bevent->y != 0) && | |
615 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, | |
616 &tpath, NULL, NULL, NULL)) | |
617 { | |
618 GtkTreeModel *store; | |
619 | |
620 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); | |
621 gtk_tree_model_get_iter(store, &iter, tpath); | |
622 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
623 gtk_tree_path_free(tpath); | |
624 } | |
625 | |
626 if (bevent->button == 2) | |
627 { | |
628 if (fd && vfl->click_fd == fd) | |
629 { | |
630 GtkTreeSelection *selection; | |
631 | |
632 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); | |
633 if (vflist_row_is_selected(vfl, fd)) | |
634 { | |
635 gtk_tree_selection_unselect_iter(selection, &iter); | |
636 } | |
637 else | |
638 { | |
639 gtk_tree_selection_select_iter(selection, &iter); | |
640 } | |
641 } | |
642 return TRUE; | |
643 } | |
644 | |
645 if (fd && vfl->click_fd == fd && | |
646 !(bevent->state & GDK_SHIFT_MASK ) && | |
647 !(bevent->state & GDK_CONTROL_MASK ) && | |
648 vflist_row_is_selected(vfl, fd)) | |
649 { | |
650 GtkTreeSelection *selection; | |
651 | |
652 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); | |
653 gtk_tree_selection_unselect_all(selection); | |
654 gtk_tree_selection_select_iter(selection, &iter); | |
655 vflist_move_cursor(vfl, &iter); | |
656 return TRUE; | |
657 } | |
658 | |
659 return FALSE; | |
660 } | |
661 | |
662 static void vflist_select_image(ViewFileList *vfl, gint row) | |
663 { | |
138 | 664 FileData *path; |
665 FileData *read_ahead_fd = NULL; | |
9 | 666 |
138 | 667 path = vflist_index_get_data(vfl, row); |
9 | 668 if (!path) return; |
669 | |
670 if (path && enable_read_ahead) | |
671 { | |
672 FileData *fd; | |
673 if (row > vflist_index_by_path(vfl, layout_image_get_path(vfl->layout)) && | |
674 row + 1 < vflist_count(vfl, NULL)) | |
675 { | |
676 fd = vflist_index_get_data(vfl, row + 1); | |
677 } | |
678 else if (row > 0) | |
679 { | |
680 fd = vflist_index_get_data(vfl, row - 1); | |
681 } | |
682 else | |
683 { | |
684 fd = NULL; | |
685 } | |
138 | 686 if (fd) read_ahead_fd = fd; |
9 | 687 } |
688 | |
138 | 689 layout_image_set_with_ahead(vfl->layout, path, read_ahead_fd); |
9 | 690 } |
691 | |
692 static gint vflist_select_idle_cb(gpointer data) | |
693 { | |
694 ViewFileList *vfl = data; | |
695 | |
696 if (!vfl->layout) | |
697 { | |
698 vfl->select_idle_id = -1; | |
699 return FALSE; | |
700 } | |
701 | |
702 vflist_send_update(vfl); | |
703 | |
704 if (vfl->select_fd) | |
705 { | |
706 vflist_select_image(vfl, g_list_index(vfl->list, vfl->select_fd)); | |
707 vfl->select_fd = NULL; | |
708 } | |
709 | |
710 vfl->select_idle_id = -1; | |
711 return FALSE; | |
712 } | |
713 | |
714 static void vflist_select_idle_cancel(ViewFileList *vfl) | |
715 { | |
716 if (vfl->select_idle_id != -1) g_source_remove(vfl->select_idle_id); | |
717 vfl->select_idle_id = -1; | |
718 } | |
719 | |
720 static gboolean vflist_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath, | |
721 gboolean path_currently_selected, gpointer data) | |
722 { | |
723 ViewFileList *vfl = data; | |
724 GtkTreeIter iter; | |
725 | |
726 if (!path_currently_selected && | |
727 gtk_tree_model_get_iter(store, &iter, tpath)) | |
728 { | |
729 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &vfl->select_fd, -1); | |
730 } | |
731 else | |
732 { | |
733 vfl->select_fd = NULL; | |
734 } | |
735 | |
736 if (vfl->layout && | |
737 vfl->select_idle_id == -1) | |
738 { | |
739 vfl->select_idle_id = g_idle_add(vflist_select_idle_cb, vfl); | |
740 } | |
741 | |
742 return TRUE; | |
743 } | |
744 | |
745 /* | |
746 *----------------------------------------------------------------------------- | |
747 * misc | |
748 *----------------------------------------------------------------------------- | |
749 */ | |
750 | |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
751 static gboolean vflist_dummy_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath, |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
752 gboolean path_currently_selected, gpointer data) |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
753 { |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
754 return TRUE; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
755 } |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
756 |
9 | 757 void vflist_sort_set(ViewFileList *vfl, SortType type, gint ascend) |
758 { | |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
759 GtkTreeModel *model; |
9 | 760 GtkListStore *store; |
761 GList *work; | |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
762 GtkTreeSelection *selection; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
763 GtkTreePath *tpath; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
764 GtkTreeIter iter; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
765 GList *select_list; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
766 FileData *cursor_fd = NULL; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
767 gint single_select; |
9 | 768 |
769 if (vfl->sort_method == type && vfl->sort_ascend == ascend) return; | |
770 | |
771 vfl->sort_method = type; | |
772 vfl->sort_ascend = ascend; | |
773 | |
774 if (!vfl->list) return; | |
775 | |
776 vfl->list = filelist_sort(vfl->list, vfl->sort_method, vfl->sort_ascend); | |
777 | |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
778 /* now reorder the treeview, maintaining current selection */ |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
779 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
780 #if 0 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
781 /* this is simpler, but much slower */ |
9 | 782 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); |
783 | |
784 work = g_list_last(vfl->list); | |
785 while (work) | |
786 { | |
787 FileData *fd; | |
788 GtkTreeIter iter; | |
789 | |
790 fd = work->data; | |
791 if (vflist_find_row(vfl, fd, &iter) >= 0) | |
792 { | |
793 gtk_list_store_move_after(store, &iter, NULL); | |
794 } | |
795 | |
796 work = work->prev; | |
797 } | |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
798 #endif |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
799 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
800 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview)); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
801 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
802 gtk_tree_selection_set_select_function(selection, vflist_dummy_select_cb, vfl, NULL); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
803 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
804 select_list = gtk_tree_selection_get_selected_rows(selection, &model); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
805 work = select_list; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
806 while (work) |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
807 { |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
808 FileData *fd; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
809 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
810 tpath = work->data; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
811 gtk_tree_model_get_iter(model, &iter, tpath); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
812 gtk_tree_model_get(model, &iter, FILE_COLUMN_POINTER, &fd, -1); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
813 gtk_tree_path_free(tpath); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
814 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
815 work->data = fd; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
816 work = work->next; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
817 } |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
818 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
819 select_list = filelist_sort(select_list, vfl->sort_method, vfl->sort_ascend); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
820 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
821 gtk_tree_view_get_cursor(GTK_TREE_VIEW(vfl->listview), &tpath, NULL); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
822 if (tpath) |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
823 { |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
824 if (gtk_tree_model_get_iter(model, &iter, tpath)) |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
825 { |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
826 gtk_tree_model_get(model, &iter, FILE_COLUMN_POINTER, &cursor_fd, -1); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
827 } |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
828 gtk_tree_path_free(tpath); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
829 } |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
830 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
831 single_select = (select_list && !select_list->next); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
832 if (single_select) cursor_fd = select_list->data; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
833 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
834 store = GTK_LIST_STORE(model); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
835 gtk_list_store_clear(store); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
836 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
837 work = vfl->list; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
838 while (work) |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
839 { |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
840 FileData *fd; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
841 gchar *size; |
132 | 842 int i; |
843 | |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
844 fd = work->data; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
845 size = text_from_size(fd->size); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
846 gtk_list_store_append(store, &iter); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
847 gtk_list_store_set(store, &iter, FILE_COLUMN_POINTER, fd, |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
848 FILE_COLUMN_THUMB, (vfl->thumbs_enabled) ? fd->pixbuf : NULL, |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
849 FILE_COLUMN_NAME, fd->name, |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
850 FILE_COLUMN_SIZE, size, |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
851 FILE_COLUMN_DATE, text_from_time(fd->date), |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
852 FILE_COLUMN_COLOR, FALSE, -1); |
132 | 853 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) |
854 gtk_list_store_set(store, &iter, FILE_COLUMN_MARKS + i, fd->marks[i], -1); | |
855 | |
856 g_free(size); | |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
857 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
858 if (select_list && select_list->data == fd) |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
859 { |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
860 select_list = g_list_remove(select_list, fd); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
861 gtk_tree_selection_select_iter(selection, &iter); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
862 } |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
863 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
864 work = work->next; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
865 } |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
866 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
867 g_list_free(select_list); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
868 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
869 if (cursor_fd && |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
870 vflist_find_row(vfl, cursor_fd, &iter) >= 0) |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
871 { |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
872 if (single_select) |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
873 { |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
874 vflist_move_cursor(vfl, &iter); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
875 } |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
876 else |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
877 { |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
878 tree_view_row_make_visible(GTK_TREE_VIEW(vfl->listview), &iter, TRUE); |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
879 } |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
880 } |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
881 |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
882 gtk_tree_selection_set_select_function(selection, vflist_select_cb, vfl, NULL); |
9 | 883 } |
884 | |
885 /* | |
886 *----------------------------------------------------------------------------- | |
887 * thumb updates | |
888 *----------------------------------------------------------------------------- | |
889 */ | |
890 | |
891 static gint vflist_thumb_next(ViewFileList *vfl); | |
892 | |
893 static void vflist_thumb_status(ViewFileList *vfl, gdouble val, const gchar *text) | |
894 { | |
895 if (vfl->func_thumb_status) | |
896 { | |
897 vfl->func_thumb_status(vfl, val, text, vfl->data_thumb_status); | |
898 } | |
899 } | |
900 | |
901 static void vflist_thumb_cleanup(ViewFileList *vfl) | |
902 { | |
903 vflist_thumb_status(vfl, 0.0, NULL); | |
904 | |
905 vfl->thumbs_count = 0; | |
906 vfl->thumbs_running = FALSE; | |
907 | |
908 thumb_loader_free(vfl->thumbs_loader); | |
909 vfl->thumbs_loader = NULL; | |
910 | |
911 vfl->thumbs_filedata = NULL; | |
912 } | |
913 | |
914 static void vflist_thumb_stop(ViewFileList *vfl) | |
915 { | |
916 if (vfl->thumbs_running) vflist_thumb_cleanup(vfl); | |
917 } | |
918 | |
919 static void vflist_thumb_do(ViewFileList *vfl, ThumbLoader *tl, FileData *fd) | |
920 { | |
921 GtkListStore *store; | |
922 GtkTreeIter iter; | |
923 | |
924 if (!fd || vflist_find_row(vfl, fd, &iter) < 0) return; | |
925 | |
926 if (fd->pixbuf) g_object_unref(fd->pixbuf); | |
927 fd->pixbuf = thumb_loader_get_pixbuf(tl, TRUE); | |
928 | |
929 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); | |
930 gtk_list_store_set(store, &iter, FILE_COLUMN_THUMB, fd->pixbuf, -1); | |
931 | |
932 vflist_thumb_status(vfl, (gdouble)(vfl->thumbs_count) / g_list_length(vfl->list), _("Loading thumbs...")); | |
933 } | |
934 | |
935 static void vflist_thumb_error_cb(ThumbLoader *tl, gpointer data) | |
936 { | |
937 ViewFileList *vfl = data; | |
938 | |
939 if (vfl->thumbs_filedata && vfl->thumbs_loader == tl) | |
940 { | |
941 vflist_thumb_do(vfl, tl, vfl->thumbs_filedata); | |
942 } | |
943 | |
944 while (vflist_thumb_next(vfl)); | |
945 } | |
946 | |
947 static void vflist_thumb_done_cb(ThumbLoader *tl, gpointer data) | |
948 { | |
949 ViewFileList *vfl = data; | |
950 | |
951 if (vfl->thumbs_filedata && vfl->thumbs_loader == tl) | |
952 { | |
953 vflist_thumb_do(vfl, tl, vfl->thumbs_filedata); | |
954 } | |
955 | |
956 while (vflist_thumb_next(vfl)); | |
957 } | |
958 | |
959 static gint vflist_thumb_next(ViewFileList *vfl) | |
960 { | |
961 GtkTreePath *tpath; | |
962 FileData *fd = NULL; | |
963 | |
964 /* first check the visible files */ | |
965 | |
966 if (GTK_WIDGET_REALIZED(vfl->listview) && | |
967 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vfl->listview), 0, 0, &tpath, NULL, NULL, NULL)) | |
968 { | |
969 GtkTreeModel *store; | |
970 GtkTreeIter iter; | |
971 gint valid = TRUE; | |
972 | |
973 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)); | |
974 gtk_tree_model_get_iter(store, &iter, tpath); | |
975 gtk_tree_path_free(tpath); | |
976 | |
977 while (!fd && valid && tree_view_row_get_visibility(GTK_TREE_VIEW(vfl->listview), &iter, FALSE) == 0) | |
978 { | |
979 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
980 if (fd->pixbuf) fd = NULL; | |
981 | |
982 valid = gtk_tree_model_iter_next(store, &iter); | |
983 } | |
984 } | |
985 | |
986 /* then find first undone */ | |
987 | |
988 if (!fd) | |
989 { | |
990 GList *work = vfl->list; | |
991 while (work && !fd) | |
992 { | |
993 FileData *fd_p = work->data; | |
994 work = work->next; | |
995 | |
996 if (!fd_p->pixbuf) fd = fd_p; | |
997 } | |
998 } | |
999 | |
1000 if (!fd) | |
1001 { | |
1002 /* done */ | |
1003 vflist_thumb_cleanup(vfl); | |
1004 return FALSE; | |
1005 } | |
1006 | |
1007 vfl->thumbs_count++; | |
1008 | |
1009 vfl->thumbs_filedata = fd; | |
1010 | |
1011 thumb_loader_free(vfl->thumbs_loader); | |
1012 | |
1013 vfl->thumbs_loader = thumb_loader_new(thumb_max_width, thumb_max_height); | |
1014 thumb_loader_set_callbacks(vfl->thumbs_loader, | |
1015 vflist_thumb_done_cb, | |
1016 vflist_thumb_error_cb, | |
1017 NULL, | |
1018 vfl); | |
1019 | |
1020 if (!thumb_loader_start(vfl->thumbs_loader, fd->path)) | |
1021 { | |
1022 /* set icon to unknown, continue */ | |
1023 if (debug) printf("thumb loader start failed %s\n", vfl->thumbs_loader->path); | |
1024 vflist_thumb_do(vfl, vfl->thumbs_loader, fd); | |
1025 | |
1026 return TRUE; | |
1027 } | |
1028 | |
1029 return FALSE; | |
1030 } | |
1031 | |
1032 static void vflist_thumb_update(ViewFileList *vfl) | |
1033 { | |
1034 vflist_thumb_stop(vfl); | |
1035 if (!vfl->thumbs_enabled) return; | |
1036 | |
1037 vflist_thumb_status(vfl, 0.0, _("Loading thumbs...")); | |
1038 vfl->thumbs_running = TRUE; | |
1039 | |
1040 while (vflist_thumb_next(vfl)); | |
1041 } | |
1042 | |
1043 /* | |
1044 *----------------------------------------------------------------------------- | |
1045 * row stuff | |
1046 *----------------------------------------------------------------------------- | |
1047 */ | |
1048 | |
1049 FileData *vflist_index_get_data(ViewFileList *vfl, gint row) | |
1050 { | |
1051 return g_list_nth_data(vfl->list, row); | |
1052 } | |
1053 | |
1054 gchar *vflist_index_get_path(ViewFileList *vfl, gint row) | |
1055 { | |
1056 FileData *fd; | |
1057 | |
1058 fd = g_list_nth_data(vfl->list, row); | |
1059 | |
1060 return (fd ? fd->path : NULL); | |
1061 } | |
1062 | |
1063 static gint vflist_row_by_path(ViewFileList *vfl, const gchar *path, FileData **fd) | |
1064 { | |
1065 gint p = 0; | |
1066 GList *work; | |
1067 | |
1068 if (!path) return -1; | |
1069 | |
1070 work = vfl->list; | |
1071 while (work) | |
1072 { | |
1073 FileData *fd_n = work->data; | |
1074 if (strcmp(path, fd_n->path) == 0) | |
1075 { | |
1076 if (fd) *fd = fd_n; | |
1077 return p; | |
1078 } | |
1079 work = work->next; | |
1080 p++; | |
1081 } | |
1082 | |
1083 if (fd) *fd = NULL; | |
1084 return -1; | |
1085 } | |
1086 | |
1087 gint vflist_index_by_path(ViewFileList *vfl, const gchar *path) | |
1088 { | |
1089 return vflist_row_by_path(vfl, path, NULL); | |
1090 } | |
1091 | |
1092 gint vflist_count(ViewFileList *vfl, gint64 *bytes) | |
1093 { | |
1094 if (bytes) | |
1095 { | |
1096 gint64 b = 0; | |
1097 GList *work; | |
1098 | |
1099 work = vfl->list; | |
1100 while (work) | |
1101 { | |
1102 FileData *fd = work->data; | |
1103 work = work->next; | |
1104 b += fd->size; | |
1105 } | |
1106 | |
1107 *bytes = b; | |
1108 } | |
1109 | |
1110 return g_list_length(vfl->list); | |
1111 } | |
1112 | |
1113 GList *vflist_get_list(ViewFileList *vfl) | |
1114 { | |
1115 GList *list = NULL; | |
1116 GList *work; | |
1117 | |
1118 work = vfl->list; | |
1119 while (work) | |
1120 { | |
1121 FileData *fd = work->data; | |
1122 work = work->next; | |
1123 | |
138 | 1124 list = g_list_prepend(list, file_data_ref(fd)); |
9 | 1125 } |
1126 | |
1127 return g_list_reverse(list); | |
1128 } | |
1129 | |
1130 /* | |
1131 *----------------------------------------------------------------------------- | |
1132 * selections | |
1133 *----------------------------------------------------------------------------- | |
1134 */ | |
1135 | |
1136 static gint vflist_row_is_selected(ViewFileList *vfl, FileData *fd) | |
1137 { | |
1138 GtkTreeModel *store; | |
1139 GtkTreeSelection *selection; | |
1140 GList *slist; | |
1141 GList *work; | |
1142 gint found = FALSE; | |
1143 | |
1144 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview)); | |
1145 slist = gtk_tree_selection_get_selected_rows(selection, &store); | |
1146 work = slist; | |
1147 while (!found && work) | |
1148 { | |
1149 GtkTreePath *tpath = work->data; | |
1150 FileData *fd_n; | |
1151 GtkTreeIter iter; | |
1152 | |
1153 gtk_tree_model_get_iter(store, &iter, tpath); | |
1154 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd_n, -1); | |
1155 if (fd_n == fd) found = TRUE; | |
1156 work = work->next; | |
1157 } | |
1158 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1159 g_list_free(slist); | |
1160 | |
1161 return found; | |
1162 } | |
1163 | |
1164 gint vflist_index_is_selected(ViewFileList *vfl, gint row) | |
1165 { | |
1166 FileData *fd; | |
1167 | |
1168 fd = vflist_index_get_data(vfl, row); | |
1169 return vflist_row_is_selected(vfl, fd); | |
1170 } | |
1171 | |
1172 gint vflist_selection_count(ViewFileList *vfl, gint64 *bytes) | |
1173 { | |
1174 GtkTreeModel *store; | |
1175 GtkTreeSelection *selection; | |
1176 GList *slist; | |
1177 gint count; | |
1178 | |
1179 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview)); | |
1180 slist = gtk_tree_selection_get_selected_rows(selection, &store); | |
1181 | |
1182 if (bytes) | |
1183 { | |
1184 gint64 b = 0; | |
1185 GList *work; | |
1186 | |
1187 work = slist; | |
1188 while (work) | |
1189 { | |
1190 GtkTreePath *tpath = work->data; | |
1191 GtkTreeIter iter; | |
1192 FileData *fd; | |
1193 | |
1194 gtk_tree_model_get_iter(store, &iter, tpath); | |
1195 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
1196 b += fd->size; | |
1197 | |
1198 work = work->next; | |
1199 } | |
1200 | |
1201 *bytes = b; | |
1202 } | |
1203 | |
1204 count = g_list_length(slist); | |
1205 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1206 g_list_free(slist); | |
1207 | |
1208 return count; | |
1209 } | |
1210 | |
1211 GList *vflist_selection_get_list(ViewFileList *vfl) | |
1212 { | |
1213 GtkTreeModel *store; | |
1214 GtkTreeSelection *selection; | |
1215 GList *slist; | |
1216 GList *list = NULL; | |
1217 GList *work; | |
1218 | |
1219 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview)); | |
1220 slist = gtk_tree_selection_get_selected_rows(selection, &store); | |
1221 work = slist; | |
1222 while (work) | |
1223 { | |
1224 GtkTreePath *tpath = work->data; | |
1225 FileData *fd; | |
1226 GtkTreeIter iter; | |
1227 | |
1228 gtk_tree_model_get_iter(store, &iter, tpath); | |
1229 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
1230 | |
138 | 1231 list = g_list_prepend(list, file_data_ref(fd)); |
9 | 1232 |
1233 work = work->next; | |
1234 } | |
1235 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1236 g_list_free(slist); | |
1237 | |
1238 return g_list_reverse(list); | |
1239 } | |
1240 | |
1241 GList *vflist_selection_get_list_by_index(ViewFileList *vfl) | |
1242 { | |
1243 GtkTreeModel *store; | |
1244 GtkTreeSelection *selection; | |
1245 GList *slist; | |
1246 GList *list = NULL; | |
1247 GList *work; | |
1248 | |
1249 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview)); | |
1250 slist = gtk_tree_selection_get_selected_rows(selection, &store); | |
1251 work = slist; | |
1252 while (work) | |
1253 { | |
1254 GtkTreePath *tpath = work->data; | |
1255 FileData *fd; | |
1256 GtkTreeIter iter; | |
1257 | |
1258 gtk_tree_model_get_iter(store, &iter, tpath); | |
1259 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
1260 | |
1261 list = g_list_prepend(list, GINT_TO_POINTER(g_list_index(vfl->list, fd))); | |
1262 | |
1263 work = work->next; | |
1264 } | |
1265 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1266 g_list_free(slist); | |
1267 | |
1268 return g_list_reverse(list); | |
1269 } | |
1270 | |
1271 void vflist_select_all(ViewFileList *vfl) | |
1272 { | |
1273 GtkTreeSelection *selection; | |
1274 | |
1275 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview)); | |
1276 gtk_tree_selection_select_all(selection); | |
1277 | |
1278 vfl->select_fd = NULL; | |
1279 } | |
1280 | |
1281 void vflist_select_none(ViewFileList *vfl) | |
1282 { | |
1283 GtkTreeSelection *selection; | |
1284 | |
1285 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview)); | |
1286 gtk_tree_selection_unselect_all(selection); | |
1287 } | |
1288 | |
1289 void vflist_select_by_path(ViewFileList *vfl, const gchar *path) | |
1290 { | |
1291 FileData *fd; | |
138 | 1292 |
1293 if (vflist_row_by_path(vfl, path, &fd) < 0) return; | |
1294 | |
1295 vflist_select_by_fd(vfl, fd); | |
1296 } | |
1297 | |
1298 void vflist_select_by_fd(ViewFileList *vfl, FileData *fd) | |
1299 { | |
9 | 1300 GtkTreeIter iter; |
1301 | |
1302 if (vflist_find_row(vfl, fd, &iter) < 0) return; | |
1303 | |
1304 tree_view_row_make_visible(GTK_TREE_VIEW(vfl->listview), &iter, TRUE); | |
1305 | |
1306 if (!vflist_row_is_selected(vfl, fd)) | |
1307 { | |
1308 GtkTreeSelection *selection; | |
1309 GtkTreeModel *store; | |
1310 GtkTreePath *tpath; | |
1311 | |
1312 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview)); | |
1313 gtk_tree_selection_unselect_all(selection); | |
1314 gtk_tree_selection_select_iter(selection, &iter); | |
1315 vflist_move_cursor(vfl, &iter); | |
1316 | |
1317 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)); | |
1318 tpath = gtk_tree_model_get_path(store, &iter); | |
1319 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vfl->listview), tpath, NULL, FALSE); | |
1320 gtk_tree_path_free(tpath); | |
1321 } | |
1322 } | |
1323 | |
1324 /* | |
1325 *----------------------------------------------------------------------------- | |
1326 * core (population) | |
1327 *----------------------------------------------------------------------------- | |
1328 */ | |
1329 | |
1330 static void vflist_listview_set_height(GtkWidget *listview, gint thumb) | |
1331 { | |
1332 GtkTreeViewColumn *column; | |
1333 GtkCellRenderer *cell; | |
1334 GList *list; | |
1335 | |
1336 column = gtk_tree_view_get_column(GTK_TREE_VIEW(listview), FILE_COLUMN_THUMB - 1); | |
1337 if (!column) return; | |
1338 | |
132 | 1339 gtk_tree_view_column_set_fixed_width(column, (thumb) ? thumb_max_width : FILE_COLUMN_MARKS); |
9 | 1340 |
1341 list = gtk_tree_view_column_get_cell_renderers(column); | |
1342 if (!list) return; | |
1343 cell = list->data; | |
1344 g_list_free(list); | |
1345 | |
1346 g_object_set(G_OBJECT(cell), "height", (thumb) ? thumb_max_height : -1, NULL); | |
1347 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(listview)); | |
1348 } | |
1349 | |
1350 static void vflist_populate_view(ViewFileList *vfl) | |
1351 { | |
1352 GtkListStore *store; | |
1353 GtkTreeIter iter; | |
1354 gint thumbs; | |
1355 GList *work; | |
1356 GtkTreeRowReference *visible_row = NULL; | |
1357 GtkTreePath *tpath; | |
1358 gint valid; | |
1359 | |
1360 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); | |
1361 thumbs = vfl->thumbs_enabled; | |
1362 | |
1363 vflist_thumb_stop(vfl); | |
1364 | |
1365 if (!vfl->list) | |
1366 { | |
1367 gtk_list_store_clear(store); | |
1368 vflist_send_update(vfl); | |
1369 return; | |
1370 } | |
1371 | |
1372 if (GTK_WIDGET_REALIZED(vfl->listview) && | |
1373 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vfl->listview), 0, 0, &tpath, NULL, NULL, NULL)) | |
1374 { | |
1375 visible_row = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), tpath); | |
1376 gtk_tree_path_free(tpath); | |
1377 } | |
1378 | |
1379 vflist_listview_set_height(vfl->listview, thumbs); | |
1380 | |
1381 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); | |
1382 | |
1383 work = vfl->list; | |
1384 while (work) | |
1385 { | |
1386 gint match; | |
1387 FileData *fd = work->data; | |
1388 gint done = FALSE; | |
1389 | |
1390 while (!done) | |
1391 { | |
1392 FileData *old_fd = NULL; | |
132 | 1393 int i; |
1394 | |
9 | 1395 if (valid) |
1396 { | |
1397 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &old_fd, -1); | |
1398 match = CASE_SORT(fd->name, old_fd->name); | |
1399 } | |
1400 else | |
1401 { | |
1402 match = -1; | |
1403 } | |
1404 | |
1405 if (match < 0) | |
1406 { | |
1407 GtkTreeIter new; | |
1408 gchar *size; | |
1409 | |
1410 size = text_from_size(fd->size); | |
1411 if (valid) | |
1412 { | |
1413 gtk_list_store_insert_before(store, &new, &iter); | |
1414 } | |
1415 else | |
1416 { | |
1417 gtk_list_store_append(store, &new); | |
1418 } | |
1419 gtk_list_store_set(store, &new, FILE_COLUMN_POINTER, fd, | |
1420 FILE_COLUMN_THUMB, (thumbs) ? fd->pixbuf : NULL, | |
1421 FILE_COLUMN_NAME, fd->name, | |
1422 FILE_COLUMN_SIZE, size, | |
1423 FILE_COLUMN_DATE, text_from_time(fd->date), | |
1424 FILE_COLUMN_COLOR, FALSE, -1); | |
132 | 1425 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) |
1426 gtk_list_store_set(store, &new, FILE_COLUMN_MARKS + i, fd->marks[i], -1); | |
1427 | |
1428 g_free(size); | |
9 | 1429 |
1430 done = TRUE; | |
1431 } | |
1432 else if (match > 0) | |
1433 { | |
1434 valid = gtk_list_store_remove(store, &iter); | |
1435 } | |
1436 else | |
1437 { | |
1438 gtk_list_store_set(store, &iter, FILE_COLUMN_POINTER, fd, -1); | |
1439 if (fd->date != old_fd->date) | |
1440 { | |
1441 gchar *size; | |
1442 | |
1443 /* update, file changed */ | |
1444 size = text_from_size(fd->size); | |
1445 gtk_list_store_set(store, &iter, FILE_COLUMN_SIZE, size, | |
1446 FILE_COLUMN_DATE, text_from_time(fd->date), -1); | |
1447 g_free(size); | |
1448 } | |
1449 else if (fd != old_fd) | |
1450 { | |
1451 /* preserve thumbnail */ | |
1452 if (fd->pixbuf) g_object_unref(fd->pixbuf); | |
1453 fd->pixbuf = old_fd->pixbuf; | |
1454 if (fd->pixbuf) g_object_ref(fd->pixbuf); | |
1455 } | |
1456 | |
1457 gtk_list_store_set(store, &iter, FILE_COLUMN_THUMB, (thumbs) ? fd->pixbuf : NULL, -1); | |
1458 | |
1459 if (vfl->select_fd == old_fd) vfl->select_fd = fd; | |
1460 | |
1461 if (valid) valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); | |
1462 | |
1463 done = TRUE; | |
1464 } | |
1465 } | |
1466 work = work->next; | |
1467 } | |
1468 | |
1469 while (valid) | |
1470 { | |
1471 valid = gtk_list_store_remove(store, &iter); | |
1472 } | |
1473 | |
1474 if (visible_row) | |
1475 { | |
1476 if (gtk_tree_row_reference_valid(visible_row)) | |
1477 { | |
1478 tpath = gtk_tree_row_reference_get_path(visible_row); | |
1479 gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(vfl->listview), tpath, NULL, TRUE, 0.0, 0.0); | |
1480 gtk_tree_path_free(tpath); | |
1481 } | |
1482 gtk_tree_row_reference_free(visible_row); | |
1483 } | |
1484 | |
1485 vflist_send_update(vfl); | |
1486 vflist_thumb_update(vfl); | |
1487 } | |
1488 | |
1489 gint vflist_refresh(ViewFileList *vfl) | |
1490 { | |
1491 GList *old_list; | |
1492 gint ret = TRUE; | |
1493 | |
1494 old_list = vfl->list; | |
1495 vfl->list = NULL; | |
1496 | |
1497 if (vfl->path) | |
1498 { | |
1499 ret = filelist_read(vfl->path, &vfl->list, NULL); | |
1500 } | |
1501 | |
1502 vfl->list = filelist_sort(vfl->list, vfl->sort_method, vfl->sort_ascend); | |
1503 vflist_populate_view(vfl); | |
1504 | |
1505 filelist_free(old_list); | |
1506 | |
1507 return ret; | |
1508 } | |
1509 | |
1510 /* this overrides the low default of a GtkCellRenderer from 100 to CELL_HEIGHT_OVERRIDE, something sane for our purposes */ | |
1511 | |
1512 #define CELL_HEIGHT_OVERRIDE 512 | |
1513 | |
1514 static void cell_renderer_height_override(GtkCellRenderer *renderer) | |
1515 { | |
1516 GParamSpec *spec; | |
1517 | |
1518 spec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(renderer)), "height"); | |
1519 if (spec && G_IS_PARAM_SPEC_INT(spec)) | |
1520 { | |
1521 GParamSpecInt *spec_int; | |
1522 | |
1523 spec_int = G_PARAM_SPEC_INT(spec); | |
1524 if (spec_int->maximum < CELL_HEIGHT_OVERRIDE) spec_int->maximum = CELL_HEIGHT_OVERRIDE; | |
1525 } | |
1526 } | |
1527 | |
1528 static GdkColor *vflist_listview_color_shifted(GtkWidget *widget) | |
1529 { | |
1530 static GdkColor color; | |
1531 static GtkWidget *done = NULL; | |
1532 | |
1533 if (done != widget) | |
1534 { | |
1535 GtkStyle *style; | |
1536 | |
1537 style = gtk_widget_get_style(widget); | |
1538 memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color)); | |
1539 shift_color(&color, -1, 0); | |
1540 done = widget; | |
1541 } | |
1542 | |
1543 return &color; | |
1544 } | |
1545 | |
1546 static void vflist_listview_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, | |
1547 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) | |
1548 { | |
1549 ViewFileList *vfl = data; | |
1550 gboolean set; | |
1551 | |
1552 gtk_tree_model_get(tree_model, iter, FILE_COLUMN_COLOR, &set, -1); | |
1553 g_object_set(G_OBJECT(cell), | |
1554 "cell-background-gdk", vflist_listview_color_shifted(vfl->listview), | |
1555 "cell-background-set", set, NULL); | |
1556 } | |
1557 | |
132 | 1558 static void vflist_listview_add_column(ViewFileList *vfl, gint n, const gchar *title, gint image, gint right_justify, gint expand) |
9 | 1559 { |
1560 GtkTreeViewColumn *column; | |
1561 GtkCellRenderer *renderer; | |
1562 | |
1563 column = gtk_tree_view_column_new(); | |
1564 gtk_tree_view_column_set_title(column, title); | |
1565 gtk_tree_view_column_set_min_width(column, 4); | |
1566 | |
1567 if (!image) | |
1568 { | |
1569 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY); | |
1570 renderer = gtk_cell_renderer_text_new(); | |
1571 if (right_justify) | |
1572 { | |
1573 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL); | |
1574 } | |
1575 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
1576 gtk_tree_view_column_add_attribute(column, renderer, "text", n); | |
132 | 1577 if (expand) |
1578 gtk_tree_view_column_set_expand(column, TRUE); | |
1579 } | |
9 | 1580 else |
1581 { | |
1582 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); | |
1583 renderer = gtk_cell_renderer_pixbuf_new(); | |
1584 cell_renderer_height_override(renderer); | |
1585 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
1586 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", n); | |
1587 } | |
1588 | |
1589 gtk_tree_view_column_set_cell_data_func(column, renderer, vflist_listview_color_cb, vfl, NULL); | |
1590 | |
1591 gtk_tree_view_append_column(GTK_TREE_VIEW(vfl->listview), column); | |
1592 } | |
1593 | |
132 | 1594 static void vflist_listview_mark_toggled(GtkCellRendererToggle *cell, gchar *path_str, GtkListStore *store) |
1595 { | |
1596 GtkTreePath *path = gtk_tree_path_new_from_string(path_str); | |
1597 guint *marks; | |
1598 GtkTreeIter iter; | |
1599 FileData *fd; | |
1600 gboolean mark; | |
1601 guint column; | |
1602 | |
1603 if (!path || !gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path)) | |
1604 return; | |
1605 | |
1606 column = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(cell), "column")); | |
1607 | |
1608 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &fd, column, &mark, -1); | |
1609 mark ^= 1; | |
1610 fd->marks[column] = mark; | |
1611 | |
1612 gtk_list_store_set(store, &iter, column, mark, -1); | |
1613 gtk_tree_path_free(path); | |
1614 } | |
1615 | |
1616 static void vflist_listview_add_column_toggle(ViewFileList *vfl, gint n, const gchar *title) | |
1617 { | |
1618 GtkTreeViewColumn *column; | |
1619 GtkCellRenderer *renderer; | |
1620 GtkListStore *store; | |
1621 gint index; | |
1622 | |
1623 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); | |
1624 | |
1625 renderer = gtk_cell_renderer_toggle_new(); | |
1626 column = gtk_tree_view_column_new_with_attributes(title, renderer, "active", n, NULL); | |
1627 | |
1628 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); | |
1629 g_object_set_data (G_OBJECT (column), "column", GUINT_TO_POINTER(n)); | |
1630 g_object_set_data (G_OBJECT (renderer), "column", GUINT_TO_POINTER(n)); | |
1631 | |
1632 index = gtk_tree_view_append_column(GTK_TREE_VIEW(vfl->listview), column); | |
1633 gtk_tree_view_column_set_fixed_width(column, 16); | |
1634 gtk_tree_view_column_set_visible(column, vfl->marks_enabled); | |
1635 | |
1636 | |
1637 g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(vflist_listview_mark_toggled), store); | |
1638 } | |
1639 | |
9 | 1640 /* |
1641 *----------------------------------------------------------------------------- | |
1642 * base | |
1643 *----------------------------------------------------------------------------- | |
1644 */ | |
1645 | |
1646 gint vflist_set_path(ViewFileList *vfl, const gchar *path) | |
1647 { | |
1648 GtkListStore *store; | |
1649 | |
1650 if (!path) return FALSE; | |
1651 if (vfl->path && strcmp(path, vfl->path) == 0) return TRUE; | |
1652 | |
1653 g_free(vfl->path); | |
1654 vfl->path = g_strdup(path); | |
1655 | |
1656 /* force complete reload */ | |
1657 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); | |
1658 gtk_list_store_clear(store); | |
1659 | |
1660 filelist_free(vfl->list); | |
1661 vfl->list = NULL; | |
1662 | |
1663 return vflist_refresh(vfl); | |
1664 } | |
1665 | |
1666 static void vflist_destroy_cb(GtkWidget *widget, gpointer data) | |
1667 { | |
1668 ViewFileList *vfl = data; | |
1669 | |
1670 if (vfl->popup) | |
1671 { | |
1672 g_signal_handlers_disconnect_matched(G_OBJECT(vfl->popup), G_SIGNAL_MATCH_DATA, | |
1673 0, 0, 0, NULL, vfl); | |
1674 gtk_widget_destroy(vfl->popup); | |
1675 } | |
1676 | |
1677 vflist_select_idle_cancel(vfl); | |
1678 vflist_thumb_stop(vfl); | |
1679 | |
1680 g_free(vfl->path); | |
1681 filelist_free(vfl->list); | |
1682 g_free(vfl); | |
1683 } | |
1684 | |
1685 ViewFileList *vflist_new(const gchar *path, gint thumbs) | |
1686 { | |
1687 ViewFileList *vfl; | |
1688 GtkListStore *store; | |
1689 GtkTreeSelection *selection; | |
1690 | |
132 | 1691 GType *flist_types; |
1692 int i; | |
1693 | |
9 | 1694 vfl = g_new0(ViewFileList, 1); |
1695 | |
1696 vfl->path = NULL; | |
1697 vfl->list = NULL; | |
1698 vfl->click_fd = NULL; | |
1699 vfl->select_fd = NULL; | |
1700 vfl->sort_method = SORT_NAME; | |
1701 vfl->sort_ascend = TRUE; | |
1702 vfl->thumbs_enabled = thumbs; | |
1703 | |
1704 vfl->thumbs_running = FALSE; | |
1705 vfl->thumbs_count = 0; | |
1706 vfl->thumbs_loader = NULL; | |
1707 vfl->thumbs_filedata = NULL; | |
1708 | |
1709 vfl->select_idle_id = -1; | |
1710 | |
1711 vfl->popup = NULL; | |
1712 | |
1713 vfl->widget = gtk_scrolled_window_new(NULL, NULL); | |
1714 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(vfl->widget), GTK_SHADOW_IN); | |
1715 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vfl->widget), | |
1716 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
1717 g_signal_connect(G_OBJECT(vfl->widget), "destroy", | |
1718 G_CALLBACK(vflist_destroy_cb), vfl); | |
1719 | |
132 | 1720 flist_types = g_new(GType, FILE_COLUMN_MARKS + FILEDATA_MARKS_SIZE); |
1721 flist_types[0] = G_TYPE_POINTER; | |
1722 flist_types[1] = GDK_TYPE_PIXBUF; | |
1723 flist_types[2] = G_TYPE_STRING; | |
1724 flist_types[3] = G_TYPE_STRING; | |
1725 flist_types[4] = G_TYPE_STRING; | |
1726 flist_types[5] = G_TYPE_BOOLEAN; | |
1727 for (i = FILE_COLUMN_MARKS; i < FILE_COLUMN_MARKS + FILEDATA_MARKS_SIZE; i++) | |
1728 flist_types[i] = G_TYPE_BOOLEAN; | |
1729 | |
1730 store = gtk_list_store_newv(FILE_COLUMN_MARKS + FILEDATA_MARKS_SIZE, flist_types); | |
1731 g_free(flist_types); | |
1732 | |
1733 vfl->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); | |
9 | 1734 g_object_unref(store); |
1735 | |
1736 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview)); | |
1737 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_MULTIPLE); | |
1738 gtk_tree_selection_set_select_function(selection, vflist_select_cb, vfl, NULL); | |
1739 | |
1740 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vfl->listview), FALSE); | |
1741 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vfl->listview), FALSE); | |
1742 | |
132 | 1743 vflist_listview_add_column(vfl, FILE_COLUMN_THUMB, "", TRUE, FALSE, FALSE); |
1744 vflist_listview_add_column(vfl, FILE_COLUMN_NAME, _("Name"), FALSE, FALSE, FALSE); | |
1745 vflist_listview_add_column(vfl, FILE_COLUMN_SIZE, _("Size"), FALSE, TRUE, FALSE); | |
1746 vflist_listview_add_column(vfl, FILE_COLUMN_DATE, _("Date"), FALSE, TRUE, TRUE); | |
9 | 1747 |
132 | 1748 for(i = 0; i < FILEDATA_MARKS_SIZE;i++) |
1749 vflist_listview_add_column_toggle(vfl, i + FILE_COLUMN_MARKS, ""); | |
1750 | |
1751 g_signal_connect(G_OBJECT(vfl->listview), "key_press_event", | |
9 | 1752 G_CALLBACK(vflist_press_key_cb), vfl); |
1753 | |
1754 gtk_container_add (GTK_CONTAINER(vfl->widget), vfl->listview); | |
1755 gtk_widget_show(vfl->listview); | |
1756 | |
1757 vflist_dnd_init(vfl); | |
132 | 1758 |
9 | 1759 g_signal_connect(G_OBJECT(vfl->listview), "button_press_event", |
1760 G_CALLBACK(vflist_press_cb), vfl); | |
1761 g_signal_connect(G_OBJECT(vfl->listview), "button_release_event", | |
1762 G_CALLBACK(vflist_release_cb), vfl); | |
132 | 1763 |
1764 | |
9 | 1765 if (path) vflist_set_path(vfl, path); |
1766 | |
1767 return vfl; | |
1768 } | |
1769 | |
1770 void vflist_set_status_func(ViewFileList *vfl, | |
1771 void (*func)(ViewFileList *vfl, gpointer data), gpointer data) | |
1772 { | |
1773 vfl->func_status = func; | |
1774 vfl->data_status = data; | |
1775 } | |
1776 | |
1777 void vflist_set_thumb_status_func(ViewFileList *vfl, | |
1778 void (*func)(ViewFileList *vfl, gdouble val, const gchar *text, gpointer data), | |
1779 gpointer data) | |
1780 { | |
1781 vfl->func_thumb_status = func; | |
1782 vfl->data_thumb_status = data; | |
1783 } | |
1784 | |
1785 void vflist_thumb_set(ViewFileList *vfl, gint enable) | |
1786 { | |
1787 if (vfl->thumbs_enabled == enable) return; | |
1788 | |
1789 vfl->thumbs_enabled = enable; | |
1790 vflist_refresh(vfl); | |
1791 } | |
1792 | |
132 | 1793 void vflist_marks_set(ViewFileList *vfl, gint enable) |
1794 { | |
1795 GtkListStore *store; | |
1796 GtkTreeViewColumn *column; | |
1797 int i; | |
1798 | |
1799 if (vfl->marks_enabled == enable) return; | |
1800 | |
1801 vfl->marks_enabled = enable; | |
1802 | |
1803 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) { | |
1804 /* index - 2 because column's store != tree view */ | |
1805 column = gtk_tree_view_get_column(GTK_TREE_VIEW(vfl->listview), i + FILE_COLUMN_MARKS - 2); | |
1806 | |
1807 gtk_tree_view_column_set_visible(column, enable); | |
1808 } | |
1809 | |
1810 //vflist_refresh(vfl); | |
1811 } | |
1812 | |
9 | 1813 void vflist_set_layout(ViewFileList *vfl, LayoutWindow *layout) |
1814 { | |
1815 vfl->layout = layout; | |
1816 } | |
1817 | |
1818 /* | |
1819 *----------------------------------------------------------------------------- | |
1820 * maintenance (for rename, move, remove) | |
1821 *----------------------------------------------------------------------------- | |
1822 */ | |
1823 | |
1824 static gint vflist_maint_find_closest(ViewFileList *vfl, gint row, gint count, GList *ignore_list) | |
1825 { | |
1826 GList *list = NULL; | |
1827 GList *work; | |
1828 gint rev = row - 1; | |
1829 row ++; | |
1830 | |
1831 work = ignore_list; | |
1832 while (work) | |
1833 { | |
1834 gint f = vflist_index_by_path(vfl, work->data); | |
1835 if (f >= 0) list = g_list_prepend(list, GINT_TO_POINTER(f)); | |
1836 work = work->next; | |
1837 } | |
1838 | |
1839 while (list) | |
1840 { | |
1841 gint c = TRUE; | |
1842 work = list; | |
1843 while (work && c) | |
1844 { | |
1845 gpointer p = work->data; | |
1846 work = work->next; | |
1847 if (row == GPOINTER_TO_INT(p)) | |
1848 { | |
1849 row++; | |
1850 c = FALSE; | |
1851 } | |
1852 if (rev == GPOINTER_TO_INT(p)) | |
1853 { | |
1854 rev--; | |
1855 c = FALSE; | |
1856 } | |
1857 if (!c) list = g_list_remove(list, p); | |
1858 } | |
1859 if (c && list) | |
1860 { | |
1861 g_list_free(list); | |
1862 list = NULL; | |
1863 } | |
1864 } | |
1865 if (row > count - 1) | |
1866 { | |
1867 if (rev < 0) | |
1868 return -1; | |
1869 else | |
1870 return rev; | |
1871 } | |
1872 else | |
1873 { | |
1874 return row; | |
1875 } | |
1876 } | |
1877 | |
138 | 1878 gint vflist_maint_renamed(ViewFileList *vfl, FileData *fd) |
9 | 1879 { |
1880 gint ret = FALSE; | |
1881 gint row; | |
1882 gchar *source_base; | |
1883 gchar *dest_base; | |
1884 GList *work; | |
1885 | |
138 | 1886 row = g_list_index(vfl->list, fd); |
9 | 1887 if (row < 0) return FALSE; |
1888 | |
138 | 1889 source_base = remove_level_from_path(fd->change->source); |
1890 dest_base = remove_level_from_path(fd->change->dest); | |
9 | 1891 |
1892 | |
1893 if (strcmp(source_base, dest_base) == 0) | |
1894 { | |
1895 GtkListStore *store; | |
1896 GtkTreeIter iter; | |
1897 GtkTreeIter position; | |
1898 gint old_row; | |
1899 gint n; | |
1900 | |
1901 old_row = g_list_index(vfl->list, fd); | |
1902 | |
1903 vfl->list = g_list_remove(vfl->list, fd); | |
1904 | |
1905 vfl->list = filelist_insert_sort(vfl->list, fd, vfl->sort_method, vfl->sort_ascend); | |
1906 n = g_list_index(vfl->list, fd); | |
1907 | |
1908 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); | |
1909 row = vflist_find_row(vfl, fd, &iter); | |
1910 if (vflist_find_row(vfl, fd, &iter) >= 0 && | |
1911 gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &position, NULL, n)) | |
1912 { | |
1913 if (old_row >= n) | |
1914 { | |
1915 gtk_list_store_move_before(store, &iter, &position); | |
1916 } | |
1917 else | |
1918 { | |
1919 gtk_list_store_move_after(store, &iter, &position); | |
1920 } | |
1921 } | |
1922 gtk_list_store_set(store, &iter, FILE_COLUMN_NAME, fd->name, -1); | |
1923 | |
1924 ret = TRUE; | |
1925 } | |
1926 else | |
1927 { | |
138 | 1928 ret = vflist_maint_removed(vfl, fd, NULL); |
9 | 1929 } |
1930 | |
1931 g_free(source_base); | |
1932 g_free(dest_base); | |
1933 | |
1934 return ret; | |
1935 } | |
1936 | |
138 | 1937 gint vflist_maint_removed(ViewFileList *vfl, FileData *fd, GList *ignore_list) |
9 | 1938 { |
1939 GtkTreeIter iter; | |
1940 GList *list; | |
1941 gint row; | |
1942 gint new_row = -1; | |
1943 | |
138 | 1944 row = g_list_index(vfl->list, fd); |
9 | 1945 if (row < 0) return FALSE; |
1946 | |
1947 if (vflist_index_is_selected(vfl, row) && | |
1948 layout_image_get_collection(vfl->layout, NULL) == NULL) | |
1949 { | |
1950 gint n; | |
1951 | |
1952 n = vflist_count(vfl, NULL); | |
1953 if (ignore_list) | |
1954 { | |
1955 new_row = vflist_maint_find_closest(vfl, row, n, ignore_list); | |
1956 if (debug) printf("row = %d, closest is %d\n", row, new_row); | |
1957 } | |
1958 else | |
1959 { | |
1960 if (row + 1 < n) | |
1961 { | |
1962 new_row = row + 1; | |
1963 } | |
1964 else if (row > 0) | |
1965 { | |
1966 new_row = row - 1; | |
1967 } | |
1968 } | |
1969 vflist_select_none(vfl); | |
1970 if (new_row >= 0) | |
1971 { | |
1972 fd = vflist_index_get_data(vfl, new_row); | |
1973 if (vflist_find_row(vfl, fd, &iter) >= 0) | |
1974 { | |
1975 GtkTreeSelection *selection; | |
1976 | |
1977 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview)); | |
1978 gtk_tree_selection_select_iter(selection, &iter); | |
1979 vflist_move_cursor(vfl, &iter); | |
1980 } | |
1981 } | |
1982 } | |
1983 | |
1984 fd = vflist_index_get_data(vfl, row); | |
1985 if (vflist_find_row(vfl, fd, &iter) >= 0) | |
1986 { | |
1987 GtkListStore *store; | |
1988 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview))); | |
1989 gtk_list_store_remove(store, &iter); | |
1990 } | |
1991 list = g_list_nth(vfl->list, row); | |
1992 fd = list->data; | |
1993 | |
1994 /* thumbnail loader check */ | |
1995 if (fd == vfl->thumbs_filedata) vfl->thumbs_filedata = NULL; | |
111
3a69a7a3f461
Wed Nov 15 02:05:27 2006 John Ellis <johne@verizon.net>
gqview
parents:
93
diff
changeset
|
1996 if (vfl->thumbs_count > 0) vfl->thumbs_count--; |
9 | 1997 |
1998 vfl->list = g_list_remove(vfl->list, fd); | |
138 | 1999 file_data_unref(fd); |
9 | 2000 |
2001 vflist_send_update(vfl); | |
2002 | |
2003 return TRUE; | |
2004 } | |
2005 | |
138 | 2006 gint vflist_maint_moved(ViewFileList *vfl, FileData *fd, GList *ignore_list) |
9 | 2007 { |
2008 gint ret = FALSE; | |
2009 gchar *buf; | |
2010 | |
138 | 2011 if (!fd->change->source || !vfl->path) return FALSE; |
9 | 2012 |
138 | 2013 buf = remove_level_from_path(fd->change->source); |
9 | 2014 |
2015 if (strcmp(buf, vfl->path) == 0) | |
2016 { | |
138 | 2017 ret = vflist_maint_removed(vfl, fd, ignore_list); |
9 | 2018 } |
2019 | |
2020 g_free(buf); | |
2021 | |
2022 return ret; | |
2023 } | |
2024 |