Mercurial > geeqie
annotate src/view_dir_tree.c @ 978:9ff64efe11eb
Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
| author | zas_ |
|---|---|
| date | Thu, 21 Aug 2008 22:47:49 +0000 |
| parents | b483d8cdedb6 |
| children | 8732c06d8aeb |
| rev | line source |
|---|---|
| 9 | 1 /* |
| 196 | 2 * Geeqie |
|
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
3 * (C) 2006 John Ellis |
| 475 | 4 * Copyright (C) 2008 The Geeqie Team |
| 9 | 5 * |
| 6 * Author: John Ellis | |
| 7 * | |
| 8 * This software is released under the GNU General Public License (GNU GPL). | |
| 9 * Please read the included file COPYING for more information. | |
| 10 * This software comes with no warranty of any kind, use at your own risk! | |
| 11 */ | |
| 12 | |
| 281 | 13 #include "main.h" |
| 9 | 14 #include "view_dir_tree.h" |
| 15 | |
| 16 | |
| 17 #include "dnd.h" | |
| 18 #include "dupe.h" | |
| 586 | 19 #include "filedata.h" |
| 9 | 20 #include "layout.h" |
| 21 #include "layout_image.h" | |
| 22 #include "layout_util.h" | |
| 23 #include "utilops.h" | |
| 24 #include "ui_fileops.h" | |
| 25 #include "ui_menu.h" | |
| 26 #include "ui_tree_edit.h" | |
|
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
356
diff
changeset
|
27 #include "view_dir.h" |
| 9 | 28 |
| 29 #include <gdk/gdkkeysyms.h> /* for keyboard values */ | |
| 30 | |
| 31 | |
|
978
9ff64efe11eb
Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents:
943
diff
changeset
|
32 #define VDTREE(_vf_) ((ViewDirInfoTree *)(_vf_->info)) |
| 9 | 33 |
| 34 | |
| 35 typedef struct _PathData PathData; | |
| 36 struct _PathData | |
| 37 { | |
| 38 gchar *name; | |
| 39 FileData *node; | |
| 40 }; | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 /* | |
| 46 *---------------------------------------------------------------------------- | |
| 47 * utils | |
| 48 *---------------------------------------------------------------------------- | |
| 49 */ | |
| 50 | |
| 51 static void set_cursor(GtkWidget *widget, GdkCursorType cursor_type) | |
| 52 { | |
| 53 GdkCursor *cursor = NULL; | |
| 54 | |
| 55 if (!widget || !widget->window) return; | |
| 56 | |
|
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
475
diff
changeset
|
57 if (cursor_type > -1) cursor = gdk_cursor_new(cursor_type); |
|
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
475
diff
changeset
|
58 gdk_window_set_cursor(widget->window, cursor); |
| 9 | 59 if (cursor) gdk_cursor_unref(cursor); |
| 60 gdk_flush(); | |
| 61 } | |
| 62 | |
| 382 | 63 static void vdtree_busy_push(ViewDir *vd) |
| 9 | 64 { |
|
978
9ff64efe11eb
Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents:
943
diff
changeset
|
65 if (VDTREE(vd)->busy_ref == 0) set_cursor(vd->view, GDK_WATCH); |
|
9ff64efe11eb
Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents:
943
diff
changeset
|
66 VDTREE(vd)->busy_ref++; |
| 9 | 67 } |
| 68 | |
| 382 | 69 static void vdtree_busy_pop(ViewDir *vd) |
| 9 | 70 { |
|
978
9ff64efe11eb
Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents:
943
diff
changeset
|
71 if (VDTREE(vd)->busy_ref == 1) set_cursor(vd->view, -1); |
|
9ff64efe11eb
Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents:
943
diff
changeset
|
72 if (VDTREE(vd)->busy_ref > 0) VDTREE(vd)->busy_ref--; |
| 9 | 73 } |
| 74 | |
|
383
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
382
diff
changeset
|
75 gint vdtree_find_row(ViewDir *vd, FileData *fd, GtkTreeIter *iter, GtkTreeIter *parent) |
| 9 | 76 { |
| 77 GtkTreeModel *store; | |
| 78 gint valid; | |
| 79 | |
| 382 | 80 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); |
| 9 | 81 if (parent) |
| 82 { | |
| 83 valid = gtk_tree_model_iter_children(store, iter, parent); | |
| 84 } | |
| 85 else | |
| 86 { | |
| 87 valid = gtk_tree_model_get_iter_first(store, iter); | |
| 88 } | |
| 89 while (valid) | |
| 90 { | |
| 91 NodeData *nd; | |
| 92 GtkTreeIter found; | |
| 93 | |
| 94 gtk_tree_model_get(GTK_TREE_MODEL(store), iter, DIR_COLUMN_POINTER, &nd, -1); | |
| 95 if (nd->fd == fd) return TRUE; | |
| 96 | |
| 382 | 97 if (vdtree_find_row(vd, fd, &found, iter)) |
| 9 | 98 { |
| 99 memcpy(iter, &found, sizeof(found)); | |
| 100 return TRUE; | |
| 101 } | |
| 102 | |
| 103 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), iter); | |
| 104 } | |
| 105 | |
| 106 return FALSE; | |
| 107 } | |
| 108 | |
| 382 | 109 static void vdtree_icon_set_by_iter(ViewDir *vd, GtkTreeIter *iter, GdkPixbuf *pixbuf) |
| 9 | 110 { |
| 111 GtkTreeModel *store; | |
| 112 GdkPixbuf *old; | |
| 113 | |
| 382 | 114 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); |
| 9 | 115 gtk_tree_model_get(store, iter, DIR_COLUMN_ICON, &old, -1); |
| 382 | 116 if (old != vd->pf->deny) |
| 9 | 117 { |
| 118 gtk_tree_store_set(GTK_TREE_STORE(store), iter, DIR_COLUMN_ICON, pixbuf, -1); | |
| 119 } | |
| 120 } | |
| 121 | |
| 382 | 122 static void vdtree_expand_by_iter(ViewDir *vd, GtkTreeIter *iter, gint expand) |
| 9 | 123 { |
| 124 GtkTreeModel *store; | |
| 125 GtkTreePath *tpath; | |
| 126 | |
| 382 | 127 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); |
| 9 | 128 tpath = gtk_tree_model_get_path(store, iter); |
| 129 if (expand) | |
| 130 { | |
| 382 | 131 gtk_tree_view_expand_row(GTK_TREE_VIEW(vd->view), tpath, FALSE); |
| 132 vdtree_icon_set_by_iter(vd, iter, vd->pf->open); | |
| 9 | 133 } |
| 134 else | |
| 135 { | |
| 382 | 136 gtk_tree_view_collapse_row(GTK_TREE_VIEW(vd->view), tpath); |
| 9 | 137 } |
| 138 gtk_tree_path_free(tpath); | |
| 139 } | |
| 140 | |
| 382 | 141 static void vdtree_expand_by_data(ViewDir *vd, FileData *fd, gint expand) |
| 9 | 142 { |
| 143 GtkTreeIter iter; | |
| 144 | |
| 389 | 145 if (vd_find_row(vd, fd, &iter)) |
| 9 | 146 { |
| 382 | 147 vdtree_expand_by_iter(vd, &iter, expand); |
| 9 | 148 } |
| 149 } | |
| 150 | |
| 151 static void vdtree_node_free(NodeData *nd) | |
| 152 { | |
| 153 if (!nd) return; | |
| 154 | |
| 138 | 155 file_data_unref(nd->fd); |
| 9 | 156 g_free(nd); |
| 157 } | |
| 158 | |
| 159 /* | |
| 160 *---------------------------------------------------------------------------- | |
| 161 * dnd | |
| 162 *---------------------------------------------------------------------------- | |
| 163 */ | |
| 164 | |
| 165 static gint vdtree_dnd_drop_expand_cb(gpointer data) | |
| 166 { | |
| 382 | 167 ViewDir *vd = data; |
| 9 | 168 GtkTreeIter iter; |
| 169 | |
| 394 | 170 if (vd->drop_fd && vd_find_row(vd, vd->drop_fd, &iter)) |
| 9 | 171 { |
| 783 | 172 vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->dir_fd); |
| 382 | 173 vdtree_expand_by_data(vd, vd->drop_fd, TRUE); |
| 9 | 174 } |
| 175 | |
|
978
9ff64efe11eb
Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents:
943
diff
changeset
|
176 VDTREE(vd)->drop_expand_id = -1; |
| 9 | 177 return FALSE; |
| 178 } | |
| 179 | |
| 407 | 180 static void vdtree_dnd_drop_expand_cancel(ViewDir *vd) |
| 9 | 181 { |
|
978
9ff64efe11eb
Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents:
943
diff
changeset
|
182 if (VDTREE(vd)->drop_expand_id != -1) g_source_remove(VDTREE(vd)->drop_expand_id); |
|
9ff64efe11eb
Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents:
943
diff
changeset
|
183 VDTREE(vd)->drop_expand_id = -1; |
| 9 | 184 } |
| 185 | |
| 407 | 186 static void vdtree_dnd_drop_expand(ViewDir *vd) |
| 9 | 187 { |
| 382 | 188 vdtree_dnd_drop_expand_cancel(vd); |
|
978
9ff64efe11eb
Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents:
943
diff
changeset
|
189 VDTREE(vd)->drop_expand_id = g_timeout_add(1000, vdtree_dnd_drop_expand_cb, vd); |
| 9 | 190 } |
| 191 | |
| 192 /* | |
| 193 *---------------------------------------------------------------------------- | |
| 194 * parts lists | |
| 195 *---------------------------------------------------------------------------- | |
| 196 */ | |
| 197 | |
| 198 static GList *parts_list(const gchar *path) | |
| 199 { | |
| 200 GList *list = NULL; | |
| 201 const gchar *strb, *strp; | |
| 202 gint l; | |
| 203 | |
| 204 strp = path; | |
| 205 | |
| 726 | 206 if (*strp != G_DIR_SEPARATOR) return NULL; |
| 9 | 207 |
| 208 strp++; | |
| 209 strb = strp; | |
| 210 l = 0; | |
| 211 | |
| 212 while (*strp != '\0') | |
| 213 { | |
| 726 | 214 if (*strp == G_DIR_SEPARATOR) |
| 9 | 215 { |
| 216 if (l > 0) list = g_list_prepend(list, g_strndup(strb, l)); | |
| 217 strp++; | |
| 218 strb = strp; | |
| 219 l = 0; | |
| 220 } | |
| 221 else | |
| 222 { | |
| 223 strp++; | |
| 224 l++; | |
| 225 } | |
| 226 } | |
| 227 if (l > 0) list = g_list_prepend(list, g_strndup(strb, l)); | |
| 228 | |
| 229 list = g_list_reverse(list); | |
| 230 | |
| 725 | 231 list = g_list_prepend(list, g_strdup(G_DIR_SEPARATOR_S)); |
| 9 | 232 |
| 233 return list; | |
| 234 } | |
| 235 | |
| 236 static void parts_list_free(GList *list) | |
| 237 { | |
| 238 GList *work = list; | |
| 239 while (work) | |
| 240 { | |
| 241 PathData *pd = work->data; | |
| 242 g_free(pd->name); | |
| 243 g_free(pd); | |
| 244 work = work->next; | |
| 245 } | |
| 246 | |
| 247 g_list_free(list); | |
| 248 } | |
| 249 | |
| 382 | 250 static GList *parts_list_add_node_points(ViewDir *vd, GList *list) |
| 9 | 251 { |
| 252 GList *work; | |
| 253 GtkTreeModel *store; | |
| 254 GtkTreeIter iter; | |
| 255 gint valid; | |
| 256 | |
| 382 | 257 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); |
| 9 | 258 valid = gtk_tree_model_get_iter_first(store, &iter); |
| 259 | |
| 260 work = list; | |
| 261 while (work) | |
| 262 { | |
| 263 PathData *pd; | |
| 264 FileData *fd = NULL; | |
| 265 | |
| 266 pd = g_new0(PathData, 1); | |
| 267 pd->name = work->data; | |
| 268 | |
| 269 while (valid && !fd) | |
| 270 { | |
| 271 NodeData *nd; | |
| 272 | |
| 273 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1); | |
| 274 if (strcmp(nd->fd->name, pd->name) == 0) | |
| 275 { | |
| 276 fd = nd->fd; | |
| 277 } | |
| 278 else | |
| 279 { | |
| 280 valid = gtk_tree_model_iter_next(store, &iter); | |
| 281 } | |
| 282 } | |
| 283 | |
| 284 pd->node = fd; | |
| 285 work->data = pd; | |
| 286 | |
| 287 if (fd) | |
| 288 { | |
| 289 GtkTreeIter parent; | |
| 290 memcpy(&parent, &iter, sizeof(parent)); | |
| 291 valid = gtk_tree_model_iter_children(store, &iter, &parent); | |
| 292 } | |
| 293 | |
| 294 work = work->next; | |
| 295 } | |
| 296 | |
| 297 return list; | |
| 298 } | |
| 299 | |
| 300 /* | |
| 301 *---------------------------------------------------------------------------- | |
| 302 * misc | |
| 303 *---------------------------------------------------------------------------- | |
| 304 */ | |
| 305 | |
| 306 #if 0 | |
| 307 static void vdtree_row_deleted_cb(GtkTreeModel *tree_model, GtkTreePath *tpath, gpointer data) | |
| 308 { | |
| 309 GtkTreeIter iter; | |
| 310 NodeData *nd; | |
| 311 | |
| 312 gtk_tree_model_get_iter(tree_model, &iter, tpath); | |
| 313 gtk_tree_model_get(tree_model, &iter, DIR_COLUMN_POINTER, &nd, -1); | |
| 314 | |
| 315 if (!nd) return; | |
| 316 | |
| 138 | 317 file_data_unref(nd->fd); |
| 9 | 318 g_free(nd); |
| 319 } | |
| 320 #endif | |
| 321 | |
| 322 /* | |
| 323 *---------------------------------------------------------------------------- | |
| 324 * node traversal, management | |
| 325 *---------------------------------------------------------------------------- | |
| 326 */ | |
| 327 | |
| 382 | 328 static gint vdtree_find_iter_by_data(ViewDir *vd, GtkTreeIter *parent, NodeData *nd, GtkTreeIter *iter) |
| 9 | 329 { |
| 330 GtkTreeModel *store; | |
| 331 | |
| 382 | 332 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); |
| 9 | 333 if (!nd || !gtk_tree_model_iter_children(store, iter, parent)) return -1; |
| 334 do { | |
| 335 NodeData *cnd; | |
| 336 | |
| 337 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &cnd, -1); | |
| 338 if (cnd == nd) return TRUE; | |
| 339 } while (gtk_tree_model_iter_next(store, iter)); | |
| 340 | |
| 341 return FALSE; | |
| 342 } | |
| 343 | |
| 382 | 344 static NodeData *vdtree_find_iter_by_name(ViewDir *vd, GtkTreeIter *parent, const gchar *name, GtkTreeIter *iter) |
| 9 | 345 { |
| 346 GtkTreeModel *store; | |
| 347 | |
| 382 | 348 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); |
| 9 | 349 if (!name || !gtk_tree_model_iter_children(store, iter, parent)) return NULL; |
| 350 do { | |
| 351 NodeData *nd; | |
| 352 | |
| 353 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1); | |
| 354 if (nd && strcmp(nd->fd->name, name) == 0) return nd; | |
| 355 } while (gtk_tree_model_iter_next(store, iter)); | |
| 356 | |
| 357 return NULL; | |
| 358 } | |
| 359 | |
| 382 | 360 static void vdtree_add_by_data(ViewDir *vd, FileData *fd, GtkTreeIter *parent) |
| 9 | 361 { |
| 362 GtkTreeStore *store; | |
| 363 GtkTreeIter child; | |
| 364 NodeData *nd; | |
| 365 GdkPixbuf *pixbuf; | |
| 366 NodeData *end; | |
| 367 GtkTreeIter empty; | |
| 368 | |
| 369 if (!fd) return; | |
| 370 | |
| 371 if (access_file(fd->path, R_OK | X_OK)) | |
| 372 { | |
| 382 | 373 pixbuf = vd->pf->close; |
| 9 | 374 } |
| 375 else | |
| 376 { | |
| 382 | 377 pixbuf = vd->pf->deny; |
| 9 | 378 } |
| 379 | |
| 380 nd = g_new0(NodeData, 1); | |
| 381 nd->fd = fd; | |
| 907 | 382 nd->version = fd->version; |
| 9 | 383 nd->expanded = FALSE; |
| 384 nd->last_update = time(NULL); | |
| 385 | |
| 382 | 386 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view))); |
| 9 | 387 gtk_tree_store_append(store, &child, parent); |
| 388 gtk_tree_store_set(store, &child, DIR_COLUMN_POINTER, nd, | |
| 389 DIR_COLUMN_ICON, pixbuf, | |
| 390 DIR_COLUMN_NAME, nd->fd->name, | |
| 391 DIR_COLUMN_COLOR, FALSE, -1); | |
| 392 | |
| 393 /* all nodes are created with an "empty" node, so that the expander is shown | |
| 394 * this is removed when the child is populated */ | |
| 395 end = g_new0(NodeData, 1); | |
| 138 | 396 end->fd = file_data_new_simple(""); |
| 9 | 397 end->expanded = TRUE; |
| 398 | |
| 399 gtk_tree_store_append(store, &empty, &child); | |
| 400 gtk_tree_store_set(store, &empty, DIR_COLUMN_POINTER, end, | |
| 401 DIR_COLUMN_NAME, "empty", -1); | |
| 402 | |
| 403 if (parent) | |
| 404 { | |
| 405 NodeData *pnd; | |
| 406 GtkTreePath *tpath; | |
| 407 | |
| 408 gtk_tree_model_get(GTK_TREE_MODEL(store), parent, DIR_COLUMN_POINTER, &pnd, -1); | |
| 409 tpath = gtk_tree_model_get_path(GTK_TREE_MODEL(store), parent); | |
| 320 | 410 if (options->tree_descend_subdirs && |
| 382 | 411 gtk_tree_view_row_expanded(GTK_TREE_VIEW(vd->view), tpath) && |
| 9 | 412 !nd->expanded) |
| 413 { | |
| 783 | 414 vdtree_populate_path_by_iter(vd, &child, FALSE, vd->dir_fd); |
| 9 | 415 } |
| 416 gtk_tree_path_free(tpath); | |
| 417 } | |
| 418 } | |
| 419 | |
| 907 | 420 gint vdtree_populate_path_by_iter(ViewDir *vd, GtkTreeIter *iter, gint force, FileData *target_fd) |
| 9 | 421 { |
| 422 GtkTreeModel *store; | |
| 423 GList *list; | |
| 424 GList *work; | |
| 425 GList *old; | |
| 426 time_t current_time; | |
| 427 GtkTreeIter child; | |
| 428 NodeData *nd; | |
| 429 | |
| 382 | 430 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); |
| 9 | 431 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1); |
| 432 | |
| 433 if (!nd) return FALSE; | |
| 434 | |
| 435 current_time = time(NULL); | |
| 442 | 436 |
| 9 | 437 if (nd->expanded) |
| 438 { | |
| 439 if (!isdir(nd->fd->path)) | |
| 440 { | |
| 382 | 441 if (vd->click_fd == nd->fd) vd->click_fd = NULL; |
| 442 if (vd->drop_fd == nd->fd) vd->drop_fd = NULL; | |
| 9 | 443 gtk_tree_store_remove(GTK_TREE_STORE(store), iter); |
| 444 vdtree_node_free(nd); | |
| 445 return FALSE; | |
| 446 } | |
| 943 | 447 if (!force && current_time - nd->last_update < 2) |
| 448 { | |
| 449 DEBUG_1("Too frequent update of %s", nd->fd->path); | |
| 450 return TRUE; | |
| 451 } | |
| 452 if (nd->fd->version == nd->version) return TRUE; | |
| 9 | 453 } |
| 454 | |
| 382 | 455 vdtree_busy_push(vd); |
| 9 | 456 |
| 783 | 457 filelist_read(nd->fd, NULL, &list); |
| 9 | 458 |
| 459 /* when hidden files are not enabled, and the user enters a hidden path, | |
| 460 * allow the tree to display that path by specifically inserting the hidden entries | |
| 461 */ | |
| 356 | 462 if (!options->file_filter.show_hidden_files && |
| 783 | 463 target_fd && |
| 464 strncmp(nd->fd->path, target_fd->path, strlen(nd->fd->path)) == 0) | |
| 9 | 465 { |
| 466 gint n; | |
| 467 | |
| 468 n = strlen(nd->fd->path); | |
| 783 | 469 if (target_fd->path[n] == G_DIR_SEPARATOR && target_fd->path[n+1] == '.') |
| 9 | 470 { |
| 471 gchar *name8; | |
| 472 struct stat sbuf; | |
| 473 | |
| 474 n++; | |
| 475 | |
| 783 | 476 while (target_fd->path[n] != '\0' && target_fd->path[n] != G_DIR_SEPARATOR) n++; |
| 477 name8 = g_strndup(target_fd->path, n); | |
| 9 | 478 |
| 479 if (stat_utf8(name8, &sbuf)) | |
| 480 { | |
|
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
138
diff
changeset
|
481 list = g_list_prepend(list, file_data_new_simple(name8)); |
| 9 | 482 } |
| 483 | |
| 484 g_free(name8); | |
| 485 } | |
| 486 } | |
| 487 | |
| 488 old = NULL; | |
| 489 if (gtk_tree_model_iter_children(store, &child, iter)) | |
| 490 { | |
| 491 do { | |
| 492 NodeData *cnd; | |
| 493 | |
| 494 gtk_tree_model_get(store, &child, DIR_COLUMN_POINTER, &cnd, -1); | |
| 495 old = g_list_prepend(old, cnd); | |
| 496 } while (gtk_tree_model_iter_next(store, &child)); | |
| 497 } | |
| 498 | |
| 499 work = list; | |
| 500 while (work) | |
| 501 { | |
| 502 FileData *fd; | |
| 503 | |
| 504 fd = work->data; | |
| 505 work = work->next; | |
| 506 | |
| 507 if (strcmp(fd->name, ".") == 0 || strcmp(fd->name, "..") == 0) | |
| 508 { | |
| 138 | 509 file_data_unref(fd); |
| 9 | 510 } |
| 511 else | |
| 512 { | |
| 513 NodeData *cnd; | |
| 514 | |
| 382 | 515 cnd = vdtree_find_iter_by_name(vd, iter, fd->name, &child); |
| 9 | 516 if (cnd) |
| 517 { | |
| 518 old = g_list_remove(old, cnd); | |
| 907 | 519 if (cnd->expanded && cnd->version != fd->version && |
| 783 | 520 vdtree_populate_path_by_iter(vd, &child, FALSE, target_fd)) |
| 9 | 521 { |
|
916
64fd2fc5cb7a
Fix warning: passing argument 1 of 'gtk_tree_store_set' from incompatible pointer type
zas_
parents:
907
diff
changeset
|
522 gtk_tree_store_set(GTK_TREE_STORE(store), &child, DIR_COLUMN_NAME, fd->name, -1); |
| 907 | 523 cnd->version = fd->version; |
| 9 | 524 } |
| 525 | |
| 138 | 526 file_data_unref(fd); |
| 9 | 527 } |
| 528 else | |
| 529 { | |
| 382 | 530 vdtree_add_by_data(vd, fd, iter); |
| 9 | 531 } |
| 532 } | |
| 533 } | |
| 534 | |
| 535 work = old; | |
| 536 while (work) | |
| 537 { | |
| 538 NodeData *cnd = work->data; | |
| 539 work = work->next; | |
| 540 | |
| 382 | 541 if (vd->click_fd == cnd->fd) vd->click_fd = NULL; |
| 542 if (vd->drop_fd == cnd->fd) vd->drop_fd = NULL; | |
| 9 | 543 |
| 382 | 544 if (vdtree_find_iter_by_data(vd, iter, cnd, &child)) |
| 9 | 545 { |
| 546 gtk_tree_store_remove(GTK_TREE_STORE(store), &child); | |
| 547 vdtree_node_free(cnd); | |
| 548 } | |
| 549 } | |
| 550 | |
| 551 g_list_free(old); | |
| 552 g_list_free(list); | |
| 553 | |
| 382 | 554 vdtree_busy_pop(vd); |
| 9 | 555 |
| 556 nd->expanded = TRUE; | |
| 557 nd->last_update = current_time; | |
| 558 | |
| 559 return TRUE; | |
| 560 } | |
| 561 | |
| 783 | 562 FileData *vdtree_populate_path(ViewDir *vd, FileData *target_fd, gint expand, gint force) |
| 9 | 563 { |
| 564 GList *list; | |
| 565 GList *work; | |
| 566 FileData *fd = NULL; | |
| 567 | |
| 783 | 568 if (!target_fd) return NULL; |
| 9 | 569 |
| 382 | 570 vdtree_busy_push(vd); |
| 9 | 571 |
| 783 | 572 list = parts_list(target_fd->path); |
| 382 | 573 list = parts_list_add_node_points(vd, list); |
| 9 | 574 |
| 575 work = list; | |
| 576 while (work) | |
| 577 { | |
| 578 PathData *pd = work->data; | |
| 579 if (pd->node == NULL) | |
| 580 { | |
| 581 PathData *parent_pd; | |
| 582 GtkTreeIter parent_iter; | |
| 583 GtkTreeIter iter; | |
| 584 NodeData *nd; | |
| 585 | |
| 586 if (work == list) | |
| 587 { | |
| 588 /* should not happen */ | |
|
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
586
diff
changeset
|
589 log_printf("vdtree warning, root node not found\n"); |
| 9 | 590 parts_list_free(list); |
| 382 | 591 vdtree_busy_pop(vd); |
| 9 | 592 return NULL; |
| 593 } | |
| 594 | |
| 595 parent_pd = work->prev->data; | |
| 596 | |
| 389 | 597 if (!vd_find_row(vd, parent_pd->node, &parent_iter) || |
| 783 | 598 !vdtree_populate_path_by_iter(vd, &parent_iter, force, target_fd) || |
| 382 | 599 (nd = vdtree_find_iter_by_name(vd, &parent_iter, pd->name, &iter)) == NULL) |
| 9 | 600 { |
|
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
586
diff
changeset
|
601 log_printf("vdtree warning, aborted at %s\n", parent_pd->name); |
| 9 | 602 parts_list_free(list); |
| 382 | 603 vdtree_busy_pop(vd); |
| 9 | 604 return NULL; |
| 605 } | |
| 606 | |
| 607 pd->node = nd->fd; | |
| 608 | |
| 609 if (pd->node) | |
| 610 { | |
| 611 if (expand) | |
| 612 { | |
| 382 | 613 vdtree_expand_by_iter(vd, &parent_iter, TRUE); |
| 614 vdtree_expand_by_iter(vd, &iter, TRUE); | |
| 9 | 615 } |
| 783 | 616 vdtree_populate_path_by_iter(vd, &iter, force, target_fd); |
| 9 | 617 } |
| 618 } | |
| 619 else | |
| 620 { | |
| 621 GtkTreeIter iter; | |
| 622 | |
| 389 | 623 if (vd_find_row(vd, pd->node, &iter)) |
| 9 | 624 { |
| 382 | 625 if (expand) vdtree_expand_by_iter(vd, &iter, TRUE); |
| 783 | 626 vdtree_populate_path_by_iter(vd, &iter, force, target_fd); |
| 9 | 627 } |
| 628 } | |
| 629 | |
| 630 work = work->next; | |
| 631 } | |
| 632 | |
| 633 work = g_list_last(list); | |
| 634 if (work) | |
| 635 { | |
| 636 PathData *pd = work->data; | |
| 637 fd = pd->node; | |
| 638 } | |
| 639 parts_list_free(list); | |
| 640 | |
| 382 | 641 vdtree_busy_pop(vd); |
| 9 | 642 |
| 643 return fd; | |
| 644 } | |
| 645 | |
| 646 /* | |
| 647 *---------------------------------------------------------------------------- | |
| 648 * access | |
| 649 *---------------------------------------------------------------------------- | |
| 650 */ | |
| 651 | |
| 652 static gint selection_is_ok = FALSE; | |
| 653 | |
| 654 static gboolean vdtree_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath, | |
| 442 | 655 gboolean path_currently_selected, gpointer data) |
| 9 | 656 { |
| 657 return selection_is_ok; | |
| 658 } | |
| 659 | |
| 396 | 660 void vdtree_select_row(ViewDir *vd, FileData *fd) |
| 9 | 661 { |
| 662 GtkTreeSelection *selection; | |
| 663 GtkTreeIter iter; | |
| 442 | 664 |
| 389 | 665 if (!vd_find_row(vd, fd, &iter)) return; |
| 382 | 666 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vd->view)); |
| 9 | 667 |
| 668 /* hack, such that selection is only allowed to be changed from here */ | |
| 669 selection_is_ok = TRUE; | |
| 670 gtk_tree_selection_select_iter(selection, &iter); | |
| 671 selection_is_ok = FALSE; | |
| 672 | |
| 783 | 673 if (!vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->dir_fd)) return; |
| 9 | 674 |
| 382 | 675 vdtree_expand_by_iter(vd, &iter, TRUE); |
| 9 | 676 |
| 442 | 677 if (fd && vd->select_func) |
| 678 { | |
| 679 vd->select_func(vd, fd->path, vd->select_data); | |
| 680 } | |
| 9 | 681 } |
| 682 | |
| 783 | 683 gint vdtree_set_fd(ViewDir *vd, FileData *dir_fd) |
| 9 | 684 { |
| 685 FileData *fd; | |
| 686 GtkTreeIter iter; | |
| 687 | |
| 783 | 688 if (!dir_fd) return FALSE; |
| 689 if (vd->dir_fd == dir_fd) return TRUE; | |
| 9 | 690 |
| 783 | 691 file_data_unref(vd->dir_fd); |
| 692 vd->dir_fd = file_data_ref(dir_fd);; | |
| 9 | 693 |
| 783 | 694 fd = vdtree_populate_path(vd, vd->dir_fd, TRUE, FALSE); |
| 9 | 695 |
| 696 if (!fd) return FALSE; | |
| 697 | |
| 389 | 698 if (vd_find_row(vd, fd, &iter)) |
| 9 | 699 { |
| 700 GtkTreeModel *store; | |
| 701 GtkTreePath *tpath; | |
| 702 | |
| 382 | 703 tree_view_row_make_visible(GTK_TREE_VIEW(vd->view), &iter, TRUE); |
| 9 | 704 |
| 382 | 705 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); |
| 9 | 706 tpath = gtk_tree_model_get_path(store, &iter); |
| 382 | 707 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vd->view), tpath, NULL, FALSE); |
| 9 | 708 gtk_tree_path_free(tpath); |
| 709 | |
| 382 | 710 vdtree_select_row(vd, fd); |
| 9 | 711 } |
| 712 | |
| 713 return TRUE; | |
| 714 } | |
| 715 | |
| 716 #if 0 | |
| 382 | 717 const gchar *vdtree_get_path(ViewDir *vd) |
| 9 | 718 { |
| 382 | 719 return vd->path; |
| 9 | 720 } |
| 721 #endif | |
| 722 | |
| 382 | 723 void vdtree_refresh(ViewDir *vd) |
| 9 | 724 { |
| 783 | 725 vdtree_populate_path(vd, vd->dir_fd, FALSE, TRUE); |
| 9 | 726 } |
| 727 | |
| 382 | 728 const gchar *vdtree_row_get_path(ViewDir *vd, gint row) |
| 9 | 729 { |
|
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
586
diff
changeset
|
730 log_printf("FIXME: no get row path\n"); |
| 9 | 731 return NULL; |
| 732 } | |
| 733 | |
| 734 /* | |
| 735 *---------------------------------------------------------------------------- | |
| 736 * callbacks | |
| 737 *---------------------------------------------------------------------------- | |
| 738 */ | |
| 739 | |
|
401
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
397
diff
changeset
|
740 gint vdtree_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
| 9 | 741 { |
| 382 | 742 ViewDir *vd = data; |
| 9 | 743 GtkTreePath *tpath; |
| 744 GtkTreeIter iter; | |
| 745 FileData *fd = NULL; | |
| 746 | |
| 382 | 747 gtk_tree_view_get_cursor(GTK_TREE_VIEW(vd->view), &tpath, NULL); |
| 9 | 748 if (tpath) |
| 749 { | |
| 750 GtkTreeModel *store; | |
| 751 NodeData *nd; | |
| 752 | |
| 753 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); | |
| 754 gtk_tree_model_get_iter(store, &iter, tpath); | |
| 755 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1); | |
| 756 | |
| 757 gtk_tree_path_free(tpath); | |
| 758 | |
| 759 fd = (nd) ? nd->fd : NULL; | |
| 760 } | |
| 761 | |
| 762 switch (event->keyval) | |
| 763 { | |
| 764 case GDK_Menu: | |
| 382 | 765 vd->click_fd = fd; |
|
383
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
382
diff
changeset
|
766 vd_color_set(vd, vd->click_fd, TRUE); |
| 9 | 767 |
|
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
768 vd->popup = vd_pop_menu(vd, vd->click_fd); |
| 395 | 769 gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, vd_menu_position_cb, vd, 0, GDK_CURRENT_TIME); |
| 9 | 770 |
| 771 return TRUE; | |
| 772 break; | |
| 773 case GDK_plus: | |
| 774 case GDK_Right: | |
| 775 case GDK_KP_Add: | |
| 776 if (fd) | |
| 777 { | |
| 783 | 778 vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->dir_fd); |
| 382 | 779 vdtree_icon_set_by_iter(vd, &iter, vd->pf->open); |
| 9 | 780 } |
| 781 break; | |
| 782 } | |
| 783 | |
| 784 return FALSE; | |
| 785 } | |
| 786 | |
| 787 static gint vdtree_clicked_on_expander(GtkTreeView *treeview, GtkTreePath *tpath, | |
| 788 GtkTreeViewColumn *column, gint x, gint y, gint *left_of_expander) | |
| 789 { | |
| 790 gint depth; | |
| 791 gint size; | |
| 792 gint sep; | |
| 793 gint exp_width; | |
| 794 | |
| 795 if (column != gtk_tree_view_get_expander_column(treeview)) return FALSE; | |
| 796 | |
| 797 gtk_widget_style_get(GTK_WIDGET(treeview), "expander-size", &size, "horizontal-separator", &sep, NULL); | |
| 798 depth = gtk_tree_path_get_depth(tpath); | |
| 799 | |
| 800 exp_width = sep + size + sep; | |
| 801 | |
| 802 if (x <= depth * exp_width) | |
| 803 { | |
| 804 if (left_of_expander) *left_of_expander = !(x >= (depth - 1) * exp_width); | |
| 805 return TRUE; | |
| 806 } | |
| 807 | |
| 808 return FALSE; | |
| 809 } | |
| 810 | |
|
401
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
397
diff
changeset
|
811 gint vdtree_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
| 9 | 812 { |
| 382 | 813 ViewDir *vd = data; |
| 9 | 814 GtkTreePath *tpath; |
| 815 GtkTreeViewColumn *column; | |
| 816 GtkTreeIter iter; | |
| 817 NodeData *nd = NULL; | |
| 818 | |
| 819 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, | |
| 820 &tpath, &column, NULL, NULL)) | |
| 821 { | |
| 822 GtkTreeModel *store; | |
| 823 gint left_of_expander; | |
| 824 | |
| 825 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); | |
| 826 gtk_tree_model_get_iter(store, &iter, tpath); | |
| 827 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1); | |
| 828 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE); | |
| 829 | |
| 830 if (vdtree_clicked_on_expander(GTK_TREE_VIEW(widget), tpath, column, bevent->x, bevent->y, &left_of_expander)) | |
| 831 { | |
| 382 | 832 vd->click_fd = NULL; |
| 9 | 833 |
| 834 /* clicking this region should automatically reveal an expander, if necessary | |
| 835 * treeview bug: the expander will not expand until a button_motion_event highlights it. | |
| 836 */ | |
|
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
442
diff
changeset
|
837 if (bevent->button == MOUSE_BUTTON_LEFT && |
| 9 | 838 !left_of_expander && |
| 382 | 839 !gtk_tree_view_row_expanded(GTK_TREE_VIEW(vd->view), tpath)) |
| 9 | 840 { |
| 783 | 841 vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->dir_fd); |
| 382 | 842 vdtree_icon_set_by_iter(vd, &iter, vd->pf->open); |
| 9 | 843 } |
| 844 | |
| 845 gtk_tree_path_free(tpath); | |
| 846 return FALSE; | |
| 847 } | |
| 848 | |
| 849 gtk_tree_path_free(tpath); | |
| 850 } | |
| 851 | |
| 382 | 852 vd->click_fd = (nd) ? nd->fd : NULL; |
|
383
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
382
diff
changeset
|
853 vd_color_set(vd, vd->click_fd, TRUE); |
| 9 | 854 |
|
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
442
diff
changeset
|
855 if (bevent->button == MOUSE_BUTTON_RIGHT) |
| 9 | 856 { |
|
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
857 vd->popup = vd_pop_menu(vd, vd->click_fd); |
| 382 | 858 gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL, |
| 9 | 859 bevent->button, bevent->time); |
| 860 } | |
| 861 | |
|
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
442
diff
changeset
|
862 return (bevent->button != MOUSE_BUTTON_LEFT); |
| 9 | 863 } |
| 864 | |
| 865 static void vdtree_row_expanded(GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *tpath, gpointer data) | |
| 866 { | |
| 382 | 867 ViewDir *vd = data; |
| 9 | 868 |
| 382 | 869 vdtree_populate_path_by_iter(vd, iter, FALSE, NULL); |
| 870 vdtree_icon_set_by_iter(vd, iter, vd->pf->open); | |
| 9 | 871 } |
| 872 | |
| 873 static void vdtree_row_collapsed(GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *tpath, gpointer data) | |
| 874 { | |
| 382 | 875 ViewDir *vd = data; |
| 9 | 876 |
| 382 | 877 vdtree_icon_set_by_iter(vd, iter, vd->pf->close); |
| 9 | 878 } |
| 879 | |
| 880 static gint vdtree_sort_cb(GtkTreeModel *store, GtkTreeIter *a, GtkTreeIter *b, gpointer data) | |
| 881 { | |
| 882 NodeData *nda; | |
| 883 NodeData *ndb; | |
| 884 | |
| 885 gtk_tree_model_get(store, a, DIR_COLUMN_POINTER, &nda, -1); | |
| 886 gtk_tree_model_get(store, b, DIR_COLUMN_POINTER, &ndb, -1); | |
| 887 | |
| 785 | 888 if (options->file_sort.case_sensitive) |
| 819 | 889 return strcmp(nda->fd->collate_key_name, ndb->fd->collate_key_name); |
| 785 | 890 else |
| 819 | 891 return strcmp(nda->fd->collate_key_name_nocase, ndb->fd->collate_key_name_nocase); |
| 9 | 892 } |
| 893 | |
| 894 /* | |
| 895 *---------------------------------------------------------------------------- | |
| 896 * core | |
| 897 *---------------------------------------------------------------------------- | |
| 898 */ | |
| 899 | |
| 382 | 900 static void vdtree_setup_root(ViewDir *vd) |
| 9 | 901 { |
| 725 | 902 const gchar *path = G_DIR_SEPARATOR_S; |
| 9 | 903 FileData *fd; |
| 904 | |
| 138 | 905 |
| 906 fd = file_data_new_simple(path); | |
| 382 | 907 vdtree_add_by_data(vd, fd, NULL); |
| 9 | 908 |
| 382 | 909 vdtree_expand_by_data(vd, fd, TRUE); |
| 783 | 910 vdtree_populate_path(vd, fd, FALSE, FALSE); |
| 9 | 911 } |
| 912 | |
| 913 static gboolean vdtree_destroy_node_cb(GtkTreeModel *store, GtkTreePath *tpath, GtkTreeIter *iter, gpointer data) | |
| 914 { | |
| 915 NodeData *nd; | |
| 916 | |
| 917 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1); | |
| 918 vdtree_node_free(nd); | |
| 919 | |
| 920 return FALSE; | |
| 921 } | |
| 922 | |
|
401
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
397
diff
changeset
|
923 void vdtree_destroy_cb(GtkWidget *widget, gpointer data) |
| 9 | 924 { |
| 382 | 925 ViewDir *vd = data; |
| 9 | 926 GtkTreeModel *store; |
| 927 | |
| 382 | 928 vdtree_dnd_drop_expand_cancel(vd); |
| 394 | 929 vd_dnd_drop_scroll_cancel(vd); |
| 382 | 930 widget_auto_scroll_stop(vd->view); |
| 9 | 931 |
| 382 | 932 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); |
| 933 gtk_tree_model_foreach(store, vdtree_destroy_node_cb, vd); | |
| 9 | 934 } |
| 935 | |
| 783 | 936 ViewDir *vdtree_new(ViewDir *vd, FileData *dir_fd) |
| 9 | 937 { |
| 938 GtkTreeStore *store; | |
| 939 GtkTreeSelection *selection; | |
| 940 GtkTreeViewColumn *column; | |
| 941 GtkCellRenderer *renderer; | |
| 942 | |
| 382 | 943 vd->info = g_new0(ViewDirInfoTree, 1); |
| 944 vd->type = DIRVIEW_TREE; | |
| 9 | 945 |
|
978
9ff64efe11eb
Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents:
943
diff
changeset
|
946 VDTREE(vd)->drop_expand_id = -1; |
|
9ff64efe11eb
Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents:
943
diff
changeset
|
947 VDTREE(vd)->busy_ref = 0; |
| 442 | 948 |
| 407 | 949 vd->dnd_drop_leave_func = vdtree_dnd_drop_expand_cancel; |
| 950 vd->dnd_drop_update_func = vdtree_dnd_drop_expand; | |
| 9 | 951 |
| 952 store = gtk_tree_store_new(4, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT); | |
| 382 | 953 vd->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); |
| 9 | 954 g_object_unref(store); |
| 955 | |
| 382 | 956 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vd->view), FALSE); |
| 957 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vd->view), FALSE); | |
| 958 gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store), vdtree_sort_cb, vd, NULL); | |
| 9 | 959 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), |
| 960 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING); | |
| 961 | |
| 382 | 962 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vd->view)); |
| 9 | 963 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); |
| 382 | 964 gtk_tree_selection_set_select_function(selection, vdtree_select_cb, vd, NULL); |
| 9 | 965 |
| 966 column = gtk_tree_view_column_new(); | |
| 967 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY); | |
| 968 | |
| 969 renderer = gtk_cell_renderer_pixbuf_new(); | |
| 970 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
| 971 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", DIR_COLUMN_ICON); | |
| 396 | 972 gtk_tree_view_column_set_cell_data_func(column, renderer, vd_color_cb, vd, NULL); |
| 9 | 973 |
| 974 renderer = gtk_cell_renderer_text_new(); | |
| 975 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
| 976 gtk_tree_view_column_add_attribute(column, renderer, "text", DIR_COLUMN_NAME); | |
| 396 | 977 gtk_tree_view_column_set_cell_data_func(column, renderer, vd_color_cb, vd, NULL); |
| 9 | 978 |
| 382 | 979 gtk_tree_view_append_column(GTK_TREE_VIEW(vd->view), column); |
| 9 | 980 |
| 382 | 981 vdtree_setup_root(vd); |
| 9 | 982 |
| 405 | 983 g_signal_connect(G_OBJECT(vd->view), "row_expanded", |
| 984 G_CALLBACK(vdtree_row_expanded), vd); | |
| 985 g_signal_connect(G_OBJECT(vd->view), "row_collapsed", | |
| 986 G_CALLBACK(vdtree_row_collapsed), vd); | |
| 9 | 987 |
| 382 | 988 return vd; |
| 9 | 989 } |
