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