Mercurial > geeqie
annotate src/view_dir_list.c @ 181:c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
author | nadvornik |
---|---|
date | Wed, 13 Feb 2008 19:31:50 +0000 |
parents | 71e1ebee420e |
children | f6e307c7bad6 |
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_dir_list.h" | |
14 | |
15 #include "dnd.h" | |
16 #include "dupe.h" | |
17 #include "filelist.h" | |
18 #include "layout.h" | |
19 #include "layout_image.h" | |
20 #include "layout_util.h" | |
21 #include "utilops.h" | |
22 #include "ui_bookmark.h" | |
23 #include "ui_fileops.h" | |
24 #include "ui_menu.h" | |
25 #include "ui_tree_edit.h" | |
26 | |
27 #include <gdk/gdkkeysyms.h> /* for keyboard values */ | |
28 | |
29 | |
30 #define VDLIST_PAD 4 | |
31 | |
32 | |
33 enum { | |
34 DIR_COLUMN_POINTER = 0, | |
35 DIR_COLUMN_ICON, | |
36 DIR_COLUMN_NAME, | |
37 DIR_COLUMN_COLOR, | |
38 DIR_COLUMN_COUNT | |
39 }; | |
40 | |
41 | |
42 static void vdlist_popup_destroy_cb(GtkWidget *widget, gpointer data); | |
43 static gint vdlist_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data); | |
44 | |
45 /* | |
46 *----------------------------------------------------------------------------- | |
47 * misc | |
48 *----------------------------------------------------------------------------- | |
49 */ | |
50 | |
51 static gint vdlist_find_row(ViewDirList *vdl, FileData *fd, GtkTreeIter *iter) | |
52 { | |
53 GtkTreeModel *store; | |
54 gint valid; | |
55 gint row = 0; | |
56 | |
57 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)); | |
58 valid = gtk_tree_model_get_iter_first(store, iter); | |
59 while (valid) | |
60 { | |
61 FileData *fd_n; | |
62 gtk_tree_model_get(GTK_TREE_MODEL(store), iter, DIR_COLUMN_POINTER, &fd_n, -1); | |
63 if (fd_n == fd) return row; | |
64 | |
65 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), iter); | |
66 row++; | |
67 } | |
68 | |
69 return -1; | |
70 } | |
71 | |
72 static gint vdlist_rename_row_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data) | |
73 { | |
74 ViewDirList *vdl = data; | |
75 GtkTreeModel *store; | |
76 GtkTreeIter iter; | |
77 FileData *fd; | |
78 gchar *old_path; | |
79 gchar *new_path; | |
80 gchar *base; | |
81 | |
82 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)); | |
83 if (!gtk_tree_model_get_iter(store, &iter, td->path)) return FALSE; | |
84 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1); | |
85 if (!fd) return FALSE; | |
86 | |
87 old_path = g_strdup(fd->path); | |
88 | |
89 base = remove_level_from_path(old_path); | |
90 new_path = concat_dir_and_file(base, new); | |
91 g_free(base); | |
92 | |
138 | 93 if (file_util_rename_dir(fd, new_path, vdl->listview)) |
9 | 94 { |
95 if (vdl->layout && strcmp(vdl->path, old_path) == 0) | |
96 { | |
97 layout_set_path(vdl->layout, new_path); | |
98 } | |
99 else | |
100 { | |
101 vdlist_refresh(vdl); | |
102 } | |
103 } | |
104 | |
105 g_free(old_path); | |
106 g_free(new_path); | |
107 return FALSE; | |
108 } | |
109 | |
110 static void vdlist_rename_by_row(ViewDirList *vdl, FileData *fd) | |
111 { | |
112 GtkTreeModel *store; | |
113 GtkTreePath *tpath; | |
114 GtkTreeIter iter; | |
115 | |
116 if (vdlist_find_row(vdl, fd, &iter) < 0) return; | |
117 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)); | |
118 tpath = gtk_tree_model_get_path(store, &iter); | |
119 | |
120 tree_edit_by_path(GTK_TREE_VIEW(vdl->listview), tpath, 0, fd->name, | |
121 vdlist_rename_row_cb, vdl); | |
122 gtk_tree_path_free(tpath); | |
123 } | |
124 | |
125 static FileData *vdlist_row_by_path(ViewDirList *vdl, const gchar *path, gint *row) | |
126 { | |
127 GList *work; | |
128 gint n; | |
129 | |
130 if (!path) | |
131 { | |
132 if (row) *row = -1; | |
133 return NULL; | |
134 } | |
135 | |
136 n = 0; | |
137 work = vdl->list; | |
138 while (work) | |
139 { | |
140 FileData *fd = work->data; | |
141 if (strcmp(fd->path, path) == 0) | |
142 { | |
143 if (row) *row = n; | |
144 return fd; | |
145 } | |
146 work = work->next; | |
147 n++; | |
148 } | |
149 | |
150 if (row) *row = -1; | |
151 return NULL; | |
152 } | |
153 | |
154 static void vdlist_color_set(ViewDirList *vdl, FileData *fd, gint color_set) | |
155 { | |
156 GtkTreeModel *store; | |
157 GtkTreeIter iter; | |
158 | |
159 if (vdlist_find_row(vdl, fd, &iter) < 0) return; | |
160 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)); | |
161 gtk_list_store_set(GTK_LIST_STORE(store), &iter, DIR_COLUMN_COLOR, color_set, -1); | |
162 } | |
163 | |
164 /* | |
165 *----------------------------------------------------------------------------- | |
166 * drop menu (from dnd) | |
167 *----------------------------------------------------------------------------- | |
168 */ | |
169 | |
170 static void vdlist_drop_menu_copy_cb(GtkWidget *widget, gpointer data) | |
171 { | |
172 ViewDirList *vdl = data; | |
173 const gchar *path; | |
174 GList *list; | |
175 | |
176 if (!vdl->drop_fd) return; | |
177 | |
178 path = vdl->drop_fd->path; | |
179 list = vdl->drop_list; | |
180 vdl->drop_list = NULL; | |
181 | |
182 file_util_copy_simple(list, path); | |
183 } | |
184 | |
185 static void vdlist_drop_menu_move_cb(GtkWidget *widget, gpointer data) | |
186 { | |
187 ViewDirList *vdl = data; | |
188 const gchar *path; | |
189 GList *list; | |
190 | |
191 if (!vdl->drop_fd) return; | |
192 | |
193 path = vdl->drop_fd->path; | |
194 list = vdl->drop_list; | |
195 | |
196 vdl->drop_list = NULL; | |
197 | |
198 file_util_move_simple(list, path); | |
199 } | |
200 | |
201 static GtkWidget *vdlist_drop_menu(ViewDirList *vdl, gint active) | |
202 { | |
203 GtkWidget *menu; | |
204 | |
205 menu = popup_menu_short_lived(); | |
206 g_signal_connect(G_OBJECT(menu), "destroy", | |
207 G_CALLBACK(vdlist_popup_destroy_cb), vdl); | |
208 | |
209 menu_item_add_stock_sensitive(menu, _("_Copy"), GTK_STOCK_COPY, active, | |
210 G_CALLBACK(vdlist_drop_menu_copy_cb), vdl); | |
211 menu_item_add_sensitive(menu, _("_Move"), active, G_CALLBACK(vdlist_drop_menu_move_cb), vdl); | |
212 | |
213 menu_item_add_divider(menu); | |
214 menu_item_add_stock(menu, _("Cancel"), GTK_STOCK_CANCEL, NULL, vdl); | |
215 | |
216 return menu; | |
217 } | |
218 | |
219 /* | |
220 *----------------------------------------------------------------------------- | |
221 * pop-up menu | |
222 *----------------------------------------------------------------------------- | |
223 */ | |
224 | |
225 static void vdlist_pop_menu_up_cb(GtkWidget *widget, gpointer data) | |
226 { | |
227 ViewDirList *vdl = data; | |
228 gchar *path; | |
229 | |
230 if (!vdl->path || strcmp(vdl->path, "/") == 0) return; | |
231 path = remove_level_from_path(vdl->path); | |
232 | |
233 if (vdl->select_func) | |
234 { | |
235 vdl->select_func(vdl, path, vdl->select_data); | |
236 } | |
237 | |
238 g_free(path); | |
239 } | |
240 | |
241 static void vdlist_pop_menu_slide_cb(GtkWidget *widget, gpointer data) | |
242 { | |
243 ViewDirList *vdl = data; | |
244 gchar *path; | |
245 | |
246 if (!vdl->layout || !vdl->click_fd) return; | |
247 | |
248 path = g_strdup(vdl->click_fd->path); | |
249 | |
250 layout_set_path(vdl->layout, path); | |
251 layout_select_none(vdl->layout); | |
252 layout_image_slideshow_stop(vdl->layout); | |
253 layout_image_slideshow_start(vdl->layout); | |
254 | |
255 g_free(path); | |
256 } | |
257 | |
258 static void vdlist_pop_menu_slide_rec_cb(GtkWidget *widget, gpointer data) | |
259 { | |
260 ViewDirList *vdl = data; | |
261 gchar *path; | |
262 GList *list; | |
263 | |
264 if (!vdl->layout || !vdl->click_fd) return; | |
265 | |
266 path = g_strdup(vdl->click_fd->path); | |
267 | |
138 | 268 list = filelist_recursive(path); |
9 | 269 |
270 layout_image_slideshow_stop(vdl->layout); | |
271 layout_image_slideshow_start_from_list(vdl->layout, list); | |
272 | |
273 g_free(path); | |
274 } | |
275 | |
276 static void vdlist_pop_menu_dupe(ViewDirList *vdl, gint recursive) | |
277 { | |
278 DupeWindow *dw; | |
279 const gchar *path; | |
280 GList *list = NULL; | |
281 | |
282 if (!vdl->click_fd) return; | |
283 | |
284 if (recursive) | |
285 { | |
138 | 286 list = g_list_append(list, file_data_ref(vdl->click_fd)); |
9 | 287 } |
288 else | |
289 { | |
138 | 290 filelist_read(vdl->click_fd->path, &list, NULL); |
291 list = filelist_filter(list, FALSE); | |
9 | 292 } |
293 | |
294 dw = dupe_window_new(DUPE_MATCH_NAME); | |
295 dupe_window_add_files(dw, list, recursive); | |
296 | |
138 | 297 filelist_free(list); |
9 | 298 } |
299 | |
300 static void vdlist_pop_menu_dupe_cb(GtkWidget *widget, gpointer data) | |
301 { | |
302 ViewDirList *vdl = data; | |
303 vdlist_pop_menu_dupe(vdl, FALSE); | |
304 } | |
305 | |
306 static void vdlist_pop_menu_dupe_rec_cb(GtkWidget *widget, gpointer data) | |
307 { | |
308 ViewDirList *vdl = data; | |
309 vdlist_pop_menu_dupe(vdl, TRUE); | |
310 } | |
311 | |
312 static void vdlist_pop_menu_new_cb(GtkWidget *widget, gpointer data) | |
313 { | |
314 ViewDirList *vdl = data; | |
315 gchar *new_path; | |
316 gchar *buf; | |
317 | |
318 if (!vdl->path) return; | |
319 | |
320 buf = concat_dir_and_file(vdl->path, _("new_folder")); | |
321 new_path = unique_filename(buf, NULL, NULL, FALSE); | |
322 g_free(buf); | |
323 if (!new_path) return; | |
324 | |
325 if (!mkdir_utf8(new_path, 0755)) | |
326 { | |
327 gchar *text; | |
328 | |
329 text = g_strdup_printf(_("Unable to create folder:\n%s"), new_path); | |
330 file_util_warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, vdl->listview); | |
331 g_free(text); | |
332 } | |
333 else | |
334 { | |
335 FileData *fd; | |
336 | |
337 vdlist_refresh(vdl); | |
338 fd = vdlist_row_by_path(vdl, new_path, NULL); | |
339 | |
340 vdlist_rename_by_row(vdl, fd); | |
341 } | |
342 | |
343 g_free(new_path); | |
344 } | |
345 | |
346 static void vdlist_pop_menu_rename_cb(GtkWidget *widget, gpointer data) | |
347 { | |
348 ViewDirList *vdl = data; | |
349 | |
350 vdlist_rename_by_row(vdl, vdl->click_fd); | |
351 } | |
352 | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
353 static void vdlist_pop_menu_delete_cb(GtkWidget *widget, gpointer data) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
354 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
355 ViewDirList *vdl = data; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
356 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
357 if (!vdl->click_fd) return; |
138 | 358 file_util_delete_dir(vdl->click_fd, vdl->widget); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
359 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
360 |
9 | 361 static void vdlist_pop_menu_tree_cb(GtkWidget *widget, gpointer data) |
362 { | |
363 ViewDirList *vdl = data; | |
364 | |
365 if (vdl->layout) layout_views_set(vdl->layout, TRUE, vdl->layout->icon_view); | |
366 } | |
367 | |
368 static void vdlist_pop_menu_refresh_cb(GtkWidget *widget, gpointer data) | |
369 { | |
370 ViewDirList *vdl = data; | |
371 | |
372 if (vdl->layout) layout_refresh(vdl->layout); | |
373 } | |
374 | |
375 static GtkWidget *vdlist_pop_menu(ViewDirList *vdl, FileData *fd) | |
376 { | |
377 GtkWidget *menu; | |
378 gint active; | |
379 | |
380 active = (fd != NULL); | |
381 | |
382 menu = popup_menu_short_lived(); | |
383 g_signal_connect(G_OBJECT(menu), "destroy", | |
384 G_CALLBACK(vdlist_popup_destroy_cb), vdl); | |
385 | |
386 menu_item_add_stock_sensitive(menu, _("_Up to parent"), GTK_STOCK_GO_UP, | |
387 (vdl->path && strcmp(vdl->path, "/") != 0), | |
388 G_CALLBACK(vdlist_pop_menu_up_cb), vdl); | |
389 | |
390 menu_item_add_divider(menu); | |
391 menu_item_add_sensitive(menu, _("_Slideshow"), active, | |
392 G_CALLBACK(vdlist_pop_menu_slide_cb), vdl); | |
393 menu_item_add_sensitive(menu, _("Slideshow recursive"), active, | |
394 G_CALLBACK(vdlist_pop_menu_slide_rec_cb), vdl); | |
395 | |
396 menu_item_add_divider(menu); | |
397 menu_item_add_stock_sensitive(menu, _("Find _duplicates..."), GTK_STOCK_FIND, active, | |
398 G_CALLBACK(vdlist_pop_menu_dupe_cb), vdl); | |
399 menu_item_add_stock_sensitive(menu, _("Find duplicates recursive..."), GTK_STOCK_FIND, active, | |
400 G_CALLBACK(vdlist_pop_menu_dupe_rec_cb), vdl); | |
401 | |
402 menu_item_add_divider(menu); | |
403 | |
404 /* check using . (always row 0) */ | |
405 active = (vdl->path && access_file(vdl->path , W_OK | X_OK)); | |
406 menu_item_add_sensitive(menu, _("_New folder..."), active, | |
407 G_CALLBACK(vdlist_pop_menu_new_cb), vdl); | |
408 | |
409 /* ignore .. and . */ | |
410 active = (active && fd && | |
411 strcmp(fd->name, ".") != 0 && | |
412 strcmp(fd->name, "..") != 0 && | |
413 access_file(fd->path, W_OK | X_OK)); | |
414 menu_item_add_sensitive(menu, _("_Rename..."), active, | |
415 G_CALLBACK(vdlist_pop_menu_rename_cb), vdl); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
416 menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, active, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
417 G_CALLBACK(vdlist_pop_menu_delete_cb), vdl); |
9 | 418 |
419 menu_item_add_divider(menu); | |
420 menu_item_add_check(menu, _("View as _tree"), FALSE, | |
421 G_CALLBACK(vdlist_pop_menu_tree_cb), vdl); | |
422 menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH, | |
423 G_CALLBACK(vdlist_pop_menu_refresh_cb), vdl); | |
424 | |
425 return menu; | |
426 } | |
427 | |
428 static void vdlist_popup_destroy_cb(GtkWidget *widget, gpointer data) | |
429 { | |
430 ViewDirList *vdl = data; | |
431 | |
432 vdlist_color_set(vdl, vdl->click_fd, FALSE); | |
433 vdl->click_fd = NULL; | |
434 vdl->popup = NULL; | |
435 | |
436 vdlist_color_set(vdl, vdl->drop_fd, FALSE); | |
138 | 437 filelist_free(vdl->drop_list); |
9 | 438 vdl->drop_list = NULL; |
439 vdl->drop_fd = NULL; | |
440 } | |
441 | |
442 /* | |
443 *----------------------------------------------------------------------------- | |
444 * dnd | |
445 *----------------------------------------------------------------------------- | |
446 */ | |
447 | |
448 static GtkTargetEntry vdlist_dnd_drop_types[] = { | |
449 { "text/uri-list", 0, TARGET_URI_LIST } | |
450 }; | |
451 static gint vdlist_dnd_drop_types_count = 1; | |
452 | |
453 static void vdlist_dest_set(ViewDirList *vdl, gint enable) | |
454 { | |
455 if (enable) | |
456 { | |
457 gtk_drag_dest_set(vdl->listview, | |
458 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, | |
459 vdlist_dnd_drop_types, vdlist_dnd_drop_types_count, | |
460 GDK_ACTION_MOVE | GDK_ACTION_COPY); | |
461 } | |
462 else | |
463 { | |
464 gtk_drag_dest_unset(vdl->listview); | |
465 } | |
466 } | |
467 | |
468 static void vdlist_dnd_get(GtkWidget *widget, GdkDragContext *context, | |
469 GtkSelectionData *selection_data, guint info, | |
470 guint time, gpointer data) | |
471 { | |
472 ViewDirList *vdl = data; | |
473 gchar *path; | |
474 GList *list; | |
475 gchar *text = NULL; | |
476 gint length = 0; | |
477 | |
478 if (!vdl->click_fd) return; | |
479 | |
480 switch (info) | |
481 { | |
482 case TARGET_URI_LIST: | |
483 case TARGET_TEXT_PLAIN: | |
138 | 484 list = g_list_prepend(NULL, vdl->click_fd); |
485 text = uri_text_from_filelist(list, &length, (info == TARGET_TEXT_PLAIN)); | |
9 | 486 g_list_free(list); |
487 break; | |
488 } | |
489 if (text) | |
490 { | |
491 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:
44
diff
changeset
|
492 8, (guchar *)text, length); |
9 | 493 g_free(text); |
494 } | |
495 } | |
496 | |
497 static void vdlist_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
498 { | |
499 ViewDirList *vdl = data; | |
500 | |
501 vdlist_color_set(vdl, vdl->click_fd, TRUE); | |
502 vdlist_dest_set(vdl, FALSE); | |
503 } | |
504 | |
505 static void vdlist_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
506 { | |
507 ViewDirList *vdl = data; | |
508 | |
509 vdlist_color_set(vdl, vdl->click_fd, FALSE); | |
510 | |
511 if (context->action == GDK_ACTION_MOVE) | |
512 { | |
513 vdlist_refresh(vdl); | |
514 } | |
515 vdlist_dest_set(vdl, TRUE); | |
516 } | |
517 | |
518 static void vdlist_dnd_drop_receive(GtkWidget *widget, | |
519 GdkDragContext *context, gint x, gint y, | |
520 GtkSelectionData *selection_data, guint info, | |
521 guint time, gpointer data) | |
522 { | |
523 ViewDirList *vdl = data; | |
524 GtkTreePath *tpath; | |
525 GtkTreeIter iter; | |
526 FileData *fd = NULL; | |
527 | |
528 vdl->click_fd = NULL; | |
529 | |
530 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), x, y, | |
531 &tpath, NULL, NULL, NULL)) | |
532 { | |
533 GtkTreeModel *store; | |
534 | |
535 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); | |
536 gtk_tree_model_get_iter(store, &iter, tpath); | |
537 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1); | |
538 gtk_tree_path_free(tpath); | |
539 } | |
540 | |
541 if (!fd) return; | |
542 | |
543 if (info == TARGET_URI_LIST) | |
544 { | |
545 GList *list; | |
546 gint active; | |
547 | |
138 | 548 list = uri_filelist_from_text((gchar *)selection_data->data, TRUE); |
9 | 549 if (!list) return; |
550 | |
551 active = access_file(fd->path, W_OK | X_OK); | |
552 | |
553 vdlist_color_set(vdl, fd, TRUE); | |
554 vdl->popup = vdlist_drop_menu(vdl, active); | |
555 gtk_menu_popup(GTK_MENU(vdl->popup), NULL, NULL, NULL, NULL, 0, time); | |
556 | |
557 vdl->drop_fd = fd; | |
558 vdl->drop_list = list; | |
559 } | |
560 } | |
561 | |
562 #if 0 | |
563 static gint vdlist_get_row_visibility(ViewDirList *vdl, FileData *fd) | |
564 { | |
565 GtkTreeModel *store; | |
566 GtkTreeViewColumn *column; | |
567 GtkTreePath *tpath; | |
568 GtkTreeIter iter; | |
569 | |
570 GdkRectangle vrect; | |
571 GdkRectangle crect; | |
572 | |
573 if (!fd || vdlist_find_row(vdl, fd, &iter) < 0) return 0; | |
574 | |
575 column = gtk_tree_view_get_column(GTK_TREE_VIEW(vdl->listview), 0); | |
576 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)); | |
577 tpath = gtk_tree_model_get_path(store, &iter); | |
578 | |
579 gtk_tree_view_get_visible_rect(GTK_TREE_VIEW(vdl->listview), &vrect); | |
580 gtk_tree_view_get_cell_area(GTK_TREE_VIEW(vdl->listview), tpath, column, &crect); | |
581 printf("window: %d + %d; cell: %d + %d\n", vrect.y, vrect.height, crect.y, crect.height); | |
582 gtk_tree_path_free(tpath); | |
583 | |
584 if (crect.y + crect.height < vrect.y) return -1; | |
585 if (crect.y > vrect.y + vrect.height) return 1; | |
586 return 0; | |
587 } | |
588 #endif | |
589 | |
590 static void vdlist_scroll_to_row(ViewDirList *vdl, FileData *fd, gfloat y_align) | |
591 { | |
592 GtkTreeIter iter; | |
593 | |
594 if (GTK_WIDGET_REALIZED(vdl->listview) && | |
595 vdlist_find_row(vdl, fd, &iter) >= 0) | |
596 { | |
597 GtkTreeModel *store; | |
598 GtkTreePath *tpath; | |
599 | |
600 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)); | |
601 tpath = gtk_tree_model_get_path(store, &iter); | |
602 gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(vdl->listview), tpath, NULL, TRUE, y_align, 0.0); | |
603 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vdl->listview), tpath, NULL, FALSE); | |
604 gtk_tree_path_free(tpath); | |
605 | |
606 if (!GTK_WIDGET_HAS_FOCUS(vdl->listview)) gtk_widget_grab_focus(vdl->listview); | |
607 } | |
608 } | |
609 | |
610 static void vdlist_drop_update(ViewDirList *vdl, gint x, gint y) | |
611 { | |
612 GtkTreePath *tpath; | |
613 GtkTreeIter iter; | |
614 FileData *fd = NULL; | |
615 | |
616 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vdl->listview), x, y, | |
617 &tpath, NULL, NULL, NULL)) | |
618 { | |
619 GtkTreeModel *store; | |
620 | |
621 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)); | |
622 gtk_tree_model_get_iter(store, &iter, tpath); | |
623 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1); | |
624 gtk_tree_path_free(tpath); | |
625 } | |
626 | |
627 if (fd != vdl->drop_fd) | |
628 { | |
629 vdlist_color_set(vdl, vdl->drop_fd, FALSE); | |
630 vdlist_color_set(vdl, fd, TRUE); | |
631 } | |
632 | |
633 vdl->drop_fd = fd; | |
634 } | |
635 | |
636 static void vdlist_dnd_drop_scroll_cancel(ViewDirList *vdl) | |
637 { | |
638 if (vdl->drop_scroll_id != -1) g_source_remove(vdl->drop_scroll_id); | |
639 vdl->drop_scroll_id = -1; | |
640 } | |
641 | |
642 static gint vdlist_auto_scroll_idle_cb(gpointer data) | |
643 { | |
644 ViewDirList *vdl = data; | |
645 | |
646 if (vdl->drop_fd) | |
647 { | |
648 GdkWindow *window; | |
649 gint x, y; | |
650 gint w, h; | |
651 | |
652 window = vdl->listview->window; | |
653 gdk_window_get_pointer(window, &x, &y, NULL); | |
654 gdk_drawable_get_size(window, &w, &h); | |
655 if (x >= 0 && x < w && y >= 0 && y < h) | |
656 { | |
657 vdlist_drop_update(vdl, x, y); | |
658 } | |
659 } | |
660 | |
661 vdl->drop_scroll_id = -1; | |
662 return FALSE; | |
663 } | |
664 | |
665 static gint vdlist_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data) | |
666 { | |
667 ViewDirList *vdl = data; | |
668 | |
669 if (!vdl->drop_fd || vdl->drop_list) return FALSE; | |
670 | |
671 if (vdl->drop_scroll_id == -1) vdl->drop_scroll_id = g_idle_add(vdlist_auto_scroll_idle_cb, vdl); | |
672 | |
673 return TRUE; | |
674 } | |
675 | |
676 static gint vdlist_dnd_drop_motion(GtkWidget *widget, GdkDragContext *context, | |
677 gint x, gint y, guint time, gpointer data) | |
678 { | |
679 ViewDirList *vdl = data; | |
680 | |
681 vdl->click_fd = NULL; | |
682 | |
683 if (gtk_drag_get_source_widget(context) == vdl->listview) | |
684 { | |
685 /* from same window */ | |
686 gdk_drag_status(context, 0, time); | |
687 return TRUE; | |
688 } | |
689 else | |
690 { | |
691 gdk_drag_status(context, context->suggested_action, time); | |
692 } | |
693 | |
694 vdlist_drop_update(vdl, x, y); | |
695 | |
696 if (vdl->drop_fd) | |
697 { | |
698 GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vdl->listview)); | |
699 widget_auto_scroll_start(vdl->listview, adj, -1, -1, vdlist_auto_scroll_notify_cb, vdl); | |
700 } | |
701 | |
702 return FALSE; | |
703 } | |
704 | |
705 static void vdlist_dnd_drop_leave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer data) | |
706 { | |
707 ViewDirList *vdl = data; | |
708 | |
709 if (vdl->drop_fd != vdl->click_fd) vdlist_color_set(vdl, vdl->drop_fd, FALSE); | |
710 | |
711 vdl->drop_fd = NULL; | |
712 } | |
713 | |
714 static void vdlist_dnd_init(ViewDirList *vdl) | |
715 { | |
716 gtk_drag_source_set(vdl->listview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, | |
717 dnd_file_drag_types, dnd_file_drag_types_count, | |
718 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); | |
719 g_signal_connect(G_OBJECT(vdl->listview), "drag_data_get", | |
720 G_CALLBACK(vdlist_dnd_get), vdl); | |
721 g_signal_connect(G_OBJECT(vdl->listview), "drag_begin", | |
722 G_CALLBACK(vdlist_dnd_begin), vdl); | |
723 g_signal_connect(G_OBJECT(vdl->listview), "drag_end", | |
724 G_CALLBACK(vdlist_dnd_end), vdl); | |
725 | |
726 vdlist_dest_set(vdl, TRUE); | |
727 g_signal_connect(G_OBJECT(vdl->listview), "drag_data_received", | |
728 G_CALLBACK(vdlist_dnd_drop_receive), vdl); | |
729 g_signal_connect(G_OBJECT(vdl->listview), "drag_motion", | |
730 G_CALLBACK(vdlist_dnd_drop_motion), vdl); | |
731 g_signal_connect(G_OBJECT(vdl->listview), "drag_leave", | |
732 G_CALLBACK(vdlist_dnd_drop_leave), vdl); | |
733 } | |
734 | |
735 /* | |
736 *----------------------------------------------------------------------------- | |
737 * main | |
738 *----------------------------------------------------------------------------- | |
739 */ | |
740 | |
741 static void vdlist_select_row(ViewDirList *vdl, FileData *fd) | |
742 { | |
743 if (fd && vdl->select_func) | |
744 { | |
745 gchar *path; | |
746 | |
747 path = g_strdup(fd->path); | |
748 vdl->select_func(vdl, path, vdl->select_data); | |
749 g_free(path); | |
750 } | |
751 } | |
752 | |
753 const gchar *vdlist_row_get_path(ViewDirList *vdl, gint row) | |
754 { | |
755 FileData *fd; | |
756 | |
757 fd = g_list_nth_data(vdl->list, row); | |
758 | |
759 if (fd) return fd->path; | |
760 | |
761 return NULL; | |
762 } | |
763 | |
764 static void vdlist_populate(ViewDirList *vdl) | |
765 { | |
766 GtkListStore *store; | |
767 GList *work; | |
768 | |
769 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview))); | |
770 gtk_list_store_clear(store); | |
771 | |
772 work = vdl->list; | |
773 while (work) | |
774 { | |
775 FileData *fd; | |
776 GtkTreeIter iter; | |
777 GdkPixbuf *pixbuf; | |
778 | |
779 fd = work->data; | |
780 | |
781 if (access_file(fd->path, R_OK | X_OK) && fd->name) | |
782 { | |
783 if (fd->name[0] == '.' && fd->name[1] == '\0') | |
784 { | |
785 pixbuf = vdl->pf->open; | |
786 } | |
787 else if (fd->name[0] == '.' && fd->name[1] == '.' && fd->name[2] == '\0') | |
788 { | |
789 pixbuf = vdl->pf->parent; | |
790 } | |
791 else | |
792 { | |
793 pixbuf = vdl->pf->close; | |
794 } | |
795 } | |
796 else | |
797 { | |
798 pixbuf = vdl->pf->deny; | |
799 } | |
800 | |
801 gtk_list_store_append(store, &iter); | |
802 gtk_list_store_set(store, &iter, | |
803 DIR_COLUMN_POINTER, fd, | |
804 DIR_COLUMN_ICON, pixbuf, | |
805 DIR_COLUMN_NAME, fd->name, -1); | |
806 | |
807 work = work->next; | |
808 } | |
809 | |
810 vdl->click_fd = NULL; | |
811 vdl->drop_fd = NULL; | |
812 } | |
813 | |
814 gint vdlist_set_path(ViewDirList *vdl, const gchar *path) | |
815 { | |
816 gint ret; | |
817 FileData *fd; | |
818 gchar *old_path = NULL; | |
138 | 819 gchar *filepath; |
9 | 820 |
821 if (!path) return FALSE; | |
822 if (vdl->path && strcmp(path, vdl->path) == 0) return TRUE; | |
823 | |
824 if (vdl->path) | |
825 { | |
826 gchar *base; | |
827 | |
828 base = remove_level_from_path(vdl->path); | |
829 if (strcmp(base, path) == 0) | |
830 { | |
831 old_path = g_strdup(filename_from_path(vdl->path)); | |
832 } | |
833 g_free(base); | |
834 } | |
835 | |
836 g_free(vdl->path); | |
837 vdl->path = g_strdup(path); | |
838 | |
839 filelist_free(vdl->list); | |
840 vdl->list = NULL; | |
841 | |
842 ret = filelist_read(vdl->path, NULL, &vdl->list); | |
843 | |
844 vdl->list = filelist_sort(vdl->list, SORT_NAME, TRUE); | |
845 | |
846 /* add . and .. */ | |
847 | |
848 if (strcmp(vdl->path, "/") != 0) | |
849 { | |
138 | 850 filepath = g_strconcat(vdl->path, "/", "..", NULL); |
851 fd = file_data_new_simple(filepath); | |
9 | 852 vdl->list = g_list_prepend(vdl->list, fd); |
138 | 853 g_free(filepath); |
9 | 854 } |
138 | 855 filepath = g_strconcat(vdl->path, "/", ".", NULL); |
856 fd = file_data_new_simple(filepath); | |
9 | 857 vdl->list = g_list_prepend(vdl->list, fd); |
138 | 858 g_free(filepath); |
9 | 859 |
860 vdlist_populate(vdl); | |
861 | |
862 if (old_path) | |
863 { | |
864 /* scroll to make last path visible */ | |
865 FileData *found = NULL; | |
866 GList *work; | |
867 | |
868 work = vdl->list; | |
869 while (work && !found) | |
870 { | |
871 FileData *fd = work->data; | |
872 if (strcmp(old_path, fd->name) == 0) found = fd; | |
873 work = work->next; | |
874 } | |
875 | |
876 if (found) vdlist_scroll_to_row(vdl, found, 0.5); | |
877 | |
878 g_free(old_path); | |
879 return ret; | |
880 } | |
881 | |
882 if (GTK_WIDGET_REALIZED(vdl->listview)) | |
883 { | |
884 gtk_tree_view_scroll_to_point(GTK_TREE_VIEW(vdl->listview), 0, 0); | |
885 } | |
886 | |
887 return ret; | |
888 } | |
889 | |
890 void vdlist_refresh(ViewDirList *vdl) | |
891 { | |
892 gchar *path; | |
893 | |
894 path = g_strdup(vdl->path); | |
895 vdl->path = NULL; | |
896 vdlist_set_path(vdl, path); | |
897 g_free(path); | |
898 } | |
899 | |
900 static void vdlist_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) | |
901 { | |
902 ViewDirList *vdl = data; | |
903 GtkTreeModel *store; | |
904 GtkTreeIter iter; | |
905 GtkTreePath *tpath; | |
906 gint cw, ch; | |
907 | |
908 if (vdlist_find_row(vdl, vdl->click_fd, &iter) < 0) return; | |
909 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)); | |
910 tpath = gtk_tree_model_get_path(store, &iter); | |
911 tree_view_get_cell_clamped(GTK_TREE_VIEW(vdl->listview), tpath, 0, TRUE, x, y, &cw, &ch); | |
912 gtk_tree_path_free(tpath); | |
913 *y += ch; | |
914 popup_menu_position_clamp(menu, x, y, 0); | |
915 } | |
916 | |
917 static gint vdlist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) | |
918 { | |
919 ViewDirList *vdl = data; | |
920 GtkTreePath *tpath; | |
921 | |
922 if (event->keyval != GDK_Menu) return FALSE; | |
923 | |
924 gtk_tree_view_get_cursor(GTK_TREE_VIEW(vdl->listview), &tpath, NULL); | |
925 if (tpath) | |
926 { | |
927 GtkTreeModel *store; | |
928 GtkTreeIter iter; | |
929 | |
930 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); | |
931 gtk_tree_model_get_iter(store, &iter, tpath); | |
932 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &vdl->click_fd, -1); | |
933 | |
934 gtk_tree_path_free(tpath); | |
935 } | |
936 else | |
937 { | |
938 vdl->click_fd = NULL; | |
939 } | |
940 | |
941 vdlist_color_set(vdl, vdl->click_fd, TRUE); | |
942 | |
943 vdl->popup = vdlist_pop_menu(vdl, vdl->click_fd); | |
944 | |
945 gtk_menu_popup(GTK_MENU(vdl->popup), NULL, NULL, vdlist_menu_position_cb, vdl, 0, GDK_CURRENT_TIME); | |
946 | |
947 return TRUE; | |
948 } | |
949 | |
950 static gint vdlist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) | |
951 { | |
952 ViewDirList *vdl = data; | |
953 GtkTreePath *tpath; | |
954 GtkTreeIter iter; | |
955 FileData *fd = NULL; | |
956 | |
957 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, | |
958 &tpath, NULL, NULL, NULL)) | |
959 { | |
960 GtkTreeModel *store; | |
961 | |
962 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); | |
963 gtk_tree_model_get_iter(store, &iter, tpath); | |
964 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1); | |
965 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE); | |
966 gtk_tree_path_free(tpath); | |
967 } | |
968 | |
969 vdl->click_fd = fd; | |
970 vdlist_color_set(vdl, vdl->click_fd, TRUE); | |
971 | |
972 if (bevent->button == 3) | |
973 { | |
974 vdl->popup = vdlist_pop_menu(vdl, vdl->click_fd); | |
975 gtk_menu_popup(GTK_MENU(vdl->popup), NULL, NULL, NULL, NULL, | |
976 bevent->button, bevent->time); | |
977 } | |
978 | |
979 return TRUE; | |
980 } | |
981 | |
982 static gint vdlist_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) | |
983 { | |
984 ViewDirList *vdl = data; | |
985 GtkTreePath *tpath; | |
986 GtkTreeIter iter; | |
987 FileData *fd = NULL; | |
988 | |
989 vdlist_color_set(vdl, vdl->click_fd, FALSE); | |
990 | |
991 if (bevent->button != 1) return TRUE; | |
992 | |
993 if ((bevent->x != 0 || bevent->y != 0) && | |
994 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, | |
995 &tpath, NULL, NULL, NULL)) | |
996 { | |
997 GtkTreeModel *store; | |
998 | |
999 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); | |
1000 gtk_tree_model_get_iter(store, &iter, tpath); | |
1001 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1); | |
1002 gtk_tree_path_free(tpath); | |
1003 } | |
1004 | |
1005 if (fd && vdl->click_fd == fd) | |
1006 { | |
1007 vdlist_select_row(vdl, vdl->click_fd); | |
1008 } | |
1009 | |
1010 return TRUE; | |
1011 } | |
1012 | |
1013 static void vdlist_select_cb(GtkTreeView *tview, GtkTreePath *tpath, GtkTreeViewColumn *column, gpointer data) | |
1014 { | |
1015 ViewDirList *vdl = data; | |
1016 GtkTreeModel *store; | |
1017 GtkTreeIter iter; | |
1018 FileData *fd; | |
1019 | |
1020 store = gtk_tree_view_get_model(tview); | |
1021 gtk_tree_model_get_iter(store, &iter, tpath); | |
1022 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1); | |
1023 | |
1024 vdlist_select_row(vdl, fd); | |
1025 } | |
1026 | |
1027 static GdkColor *vdlist_color_shifted(GtkWidget *widget) | |
1028 { | |
1029 static GdkColor color; | |
1030 static GtkWidget *done = NULL; | |
1031 | |
1032 if (done != widget) | |
1033 { | |
1034 GtkStyle *style; | |
1035 | |
1036 style = gtk_widget_get_style(widget); | |
1037 memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color)); | |
1038 shift_color(&color, -1, 0); | |
1039 done = widget; | |
1040 } | |
1041 | |
1042 return &color; | |
1043 } | |
1044 | |
1045 static void vdlist_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, | |
1046 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) | |
1047 { | |
1048 ViewDirList *vdl = data; | |
1049 gboolean set; | |
1050 | |
1051 gtk_tree_model_get(tree_model, iter, DIR_COLUMN_COLOR, &set, -1); | |
1052 g_object_set(G_OBJECT(cell), | |
1053 "cell-background-gdk", vdlist_color_shifted(vdl->listview), | |
1054 "cell-background-set", set, NULL); | |
1055 } | |
1056 | |
1057 static void vdlist_destroy_cb(GtkWidget *widget, gpointer data) | |
1058 { | |
1059 ViewDirList *vdl = data; | |
1060 | |
1061 if (vdl->popup) | |
1062 { | |
1063 g_signal_handlers_disconnect_matched(G_OBJECT(vdl->popup), G_SIGNAL_MATCH_DATA, | |
1064 0, 0, 0, NULL, vdl); | |
1065 gtk_widget_destroy(vdl->popup); | |
1066 } | |
1067 | |
1068 vdlist_dnd_drop_scroll_cancel(vdl); | |
1069 widget_auto_scroll_stop(vdl->listview); | |
1070 | |
138 | 1071 filelist_free(vdl->drop_list); |
9 | 1072 |
1073 folder_icons_free(vdl->pf); | |
1074 | |
1075 g_free(vdl->path); | |
1076 filelist_free(vdl->list); | |
1077 g_free(vdl); | |
1078 } | |
1079 | |
1080 ViewDirList *vdlist_new(const gchar *path) | |
1081 { | |
1082 ViewDirList *vdl; | |
1083 GtkListStore *store; | |
1084 GtkTreeSelection *selection; | |
1085 GtkTreeViewColumn *column; | |
1086 GtkCellRenderer *renderer; | |
1087 | |
1088 vdl = g_new0(ViewDirList, 1); | |
1089 | |
1090 vdl->path = NULL; | |
1091 vdl->list = NULL; | |
1092 vdl->click_fd = NULL; | |
1093 | |
1094 vdl->drop_fd = NULL; | |
1095 vdl->drop_list = NULL; | |
1096 | |
1097 vdl->drop_scroll_id = -1; | |
1098 | |
1099 vdl->popup = NULL; | |
1100 | |
1101 vdl->widget = gtk_scrolled_window_new(NULL, NULL); | |
1102 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(vdl->widget), GTK_SHADOW_IN); | |
1103 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vdl->widget), | |
1104 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
1105 g_signal_connect(G_OBJECT(vdl->widget), "destroy", | |
1106 G_CALLBACK(vdlist_destroy_cb), vdl); | |
1107 | |
1108 store = gtk_list_store_new(4, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN); | |
1109 vdl->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); | |
1110 g_object_unref(store); | |
1111 | |
1112 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vdl->listview), FALSE); | |
1113 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vdl->listview), FALSE); | |
1114 g_signal_connect(G_OBJECT(vdl->listview), "row_activated", | |
1115 | |
1116 G_CALLBACK(vdlist_select_cb), vdl); | |
1117 | |
1118 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vdl->listview)); | |
1119 gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE); | |
1120 | |
1121 column = gtk_tree_view_column_new(); | |
1122 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
1123 | |
1124 renderer = gtk_cell_renderer_pixbuf_new(); | |
1125 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
1126 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", DIR_COLUMN_ICON); | |
1127 gtk_tree_view_column_set_cell_data_func(column, renderer, vdlist_color_cb, vdl, NULL); | |
1128 | |
1129 renderer = gtk_cell_renderer_text_new(); | |
1130 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
1131 gtk_tree_view_column_add_attribute(column, renderer, "text", DIR_COLUMN_NAME); | |
1132 gtk_tree_view_column_set_cell_data_func(column, renderer, vdlist_color_cb, vdl, NULL); | |
1133 | |
1134 gtk_tree_view_append_column(GTK_TREE_VIEW(vdl->listview), column); | |
1135 | |
1136 g_signal_connect(G_OBJECT(vdl->listview), "key_press_event", | |
1137 G_CALLBACK(vdlist_press_key_cb), vdl); | |
1138 gtk_container_add(GTK_CONTAINER(vdl->widget), vdl->listview); | |
1139 gtk_widget_show(vdl->listview); | |
1140 | |
1141 vdl->pf = folder_icons_new(); | |
1142 | |
1143 vdlist_dnd_init(vdl); | |
1144 | |
1145 g_signal_connect(G_OBJECT(vdl->listview), "button_press_event", | |
1146 G_CALLBACK(vdlist_press_cb), vdl); | |
1147 g_signal_connect(G_OBJECT(vdl->listview), "button_release_event", | |
1148 G_CALLBACK(vdlist_release_cb), vdl); | |
1149 | |
1150 if (path) vdlist_set_path(vdl, path); | |
1151 | |
1152 return vdl; | |
1153 } | |
1154 | |
1155 void vdlist_set_select_func(ViewDirList *vdl, | |
1156 void (*func)(ViewDirList *vdl, const gchar *path, gpointer data), gpointer data) | |
1157 { | |
1158 vdl->select_func = func; | |
1159 vdl->select_data = data; | |
1160 } | |
1161 | |
1162 void vdlist_set_layout(ViewDirList *vdl, LayoutWindow *layout) | |
1163 { | |
1164 vdl->layout = layout; | |
1165 } | |
1166 |