{
GtkTreeModel *store;
GtkTreePath *tpath;
+ NodeData *nd;
+ FileData *fd = NULL;
store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
tpath = gtk_tree_model_get_path(store, iter);
that the iter is populated */
g_signal_handlers_block_by_func(G_OBJECT(vd->view), vdtree_row_expanded, vd);
gtk_tree_view_expand_row(GTK_TREE_VIEW(vd->view), tpath, FALSE);
- vdtree_icon_set_by_iter(vd, iter, vd->pf->open);
+ gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
+ fd = (nd) ? nd->fd : NULL;
+
+ if (fd && islink(fd->path))
+ {
+ vdtree_icon_set_by_iter(vd, iter, vd->pf->link);
+ }
+ else
+ {
+ vdtree_icon_set_by_iter(vd, iter, vd->pf->open);
+ }
+
g_signal_handlers_unblock_by_func(G_OBJECT(vd->view), vdtree_row_expanded, vd);
}
else
GdkPixbuf *pixbuf;
NodeData *end;
GtkTreeIter empty;
+ gchar *link = NULL;
if (!fd) return;
if (access_file(fd->path, R_OK | X_OK))
{
- pixbuf = vd->pf->close;
+ if (islink(fd->path))
+ {
+ pixbuf = vd->pf->link;
+ }
+ else
+ {
+ pixbuf = vd->pf->close;
+ }
}
else
{
nd->expanded = FALSE;
nd->last_update = time(NULL);
+ if (islink(fd->path))
+ {
+ link = realpath(fd->path, NULL);
+ }
+ else
+ {
+ link = NULL;
+ }
+
store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)));
gtk_tree_store_append(store, &child, parent);
gtk_tree_store_set(store, &child, DIR_COLUMN_POINTER, nd,
DIR_COLUMN_ICON, pixbuf,
DIR_COLUMN_NAME, nd->fd->name,
+ DIR_COLUMN_LINK, link,
DIR_COLUMN_COLOR, FALSE, -1);
/* all nodes are created with an "empty" node, so that the expander is shown
}
gtk_tree_path_free(tpath);
}
+
+ g_free(link);
}
gboolean vdtree_populate_path_by_iter(ViewDir *vd, GtkTreeIter *iter, gboolean force, FileData *target_fd)
time_t current_time;
GtkTreeIter child;
NodeData *nd;
+ gboolean add_hidden = FALSE;
+ gchar *link = NULL;
store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
return TRUE;
}
file_data_check_changed_files(nd->fd); /* make sure we have recent info */
- if (nd->fd->version == nd->version) return TRUE;
}
- vdtree_busy_push(vd);
-
- filelist_read(nd->fd, NULL, &list);
-
/* when hidden files are not enabled, and the user enters a hidden path,
* allow the tree to display that path by specifically inserting the hidden entries
*/
n = strlen(nd->fd->path);
if (target_fd->path[n] == G_DIR_SEPARATOR && target_fd->path[n+1] == '.')
- {
- gchar *name8;
+ add_hidden = TRUE;
+ }
- n++;
+ if (nd->expanded && (!force && !add_hidden) && nd->fd->version == nd->version)
+ return TRUE;
- while (target_fd->path[n] != '\0' && target_fd->path[n] != G_DIR_SEPARATOR) n++;
- name8 = g_strndup(target_fd->path, n);
+ vdtree_busy_push(vd);
- if (isdir(name8))
- {
- list = g_list_prepend(list, file_data_new_dir(name8));
- }
+ filelist_read(nd->fd, NULL, &list);
+
+ if (add_hidden)
+ {
+ gint n;
+ gchar *name8;
+
+ n = strlen(nd->fd->path) + 1;
- g_free(name8);
+ while (target_fd->path[n] != '\0' && target_fd->path[n] != G_DIR_SEPARATOR) n++;
+ name8 = g_strndup(target_fd->path, n);
+
+ if (isdir(name8))
+ {
+ list = g_list_prepend(list, file_data_new_dir(name8));
}
+
+ g_free(name8);
}
old = NULL;
}
gtk_tree_store_set(GTK_TREE_STORE(store), &child, DIR_COLUMN_NAME, fd->name, -1);
+
+ if (islink(fd->path))
+ {
+ link = realpath(fd->path, NULL);
+ }
+ else
+ {
+ link = NULL;
+ }
+
+ gtk_tree_store_set(GTK_TREE_STORE(store), &child, DIR_COLUMN_LINK, link, -1);
+
cnd->version = fd->version;
old = g_list_remove(old, cnd);
file_data_unref(fd);
nd->expanded = TRUE;
nd->last_update = current_time;
+ g_free(link);
+
return TRUE;
}
const gchar *vdtree_row_get_path(ViewDir *vd, gint row)
{
+/** @FIXME no get row path */
log_printf("FIXME: no get row path\n");
return NULL;
}
if (fd)
{
vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->dir_fd);
- vdtree_icon_set_by_iter(vd, &iter, vd->pf->open);
+
+ if (islink(fd->path))
+ {
+ vdtree_icon_set_by_iter(vd, &iter, vd->pf->link);
+ }
+ else
+ {
+ vdtree_icon_set_by_iter(vd, &iter, vd->pf->open);
+ }
}
break;
}
GtkTreeViewColumn *column;
GtkTreeIter iter;
NodeData *nd = NULL;
+ FileData *fd;
if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y,
&tpath, &column, NULL, NULL))
!gtk_tree_view_row_expanded(GTK_TREE_VIEW(vd->view), tpath))
{
vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->dir_fd);
- vdtree_icon_set_by_iter(vd, &iter, vd->pf->open);
+
+ fd = (nd) ? nd->fd : NULL;
+ if (fd && islink(fd->path))
+ {
+ vdtree_icon_set_by_iter(vd, &iter, vd->pf->link);
+ }
+ else
+ {
+ vdtree_icon_set_by_iter(vd, &iter, vd->pf->open);
+ }
}
gtk_tree_path_free(tpath);
static void vdtree_row_expanded(GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *tpath, gpointer data)
{
ViewDir *vd = data;
+ GtkTreeModel *store;
+ NodeData *nd = NULL;
+ FileData *fd;
+
+ gtk_tree_view_set_tooltip_column(treeview, DIR_COLUMN_LINK);
vdtree_populate_path_by_iter(vd, iter, FALSE, NULL);
- vdtree_icon_set_by_iter(vd, iter, vd->pf->open);
+ store = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
+
+ gtk_tree_model_get_iter(store, iter, tpath);
+ gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
+
+ fd = (nd) ? nd->fd : NULL;
+ if (fd && islink(fd->path))
+ {
+ vdtree_icon_set_by_iter(vd, iter, vd->pf->link);
+ }
+ else
+ {
+ vdtree_icon_set_by_iter(vd, iter, vd->pf->open);
+ }
}
static void vdtree_row_collapsed(GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *tpath, gpointer data)
{
ViewDir *vd = data;
+ GtkTreeModel *store;
+ NodeData *nd = NULL;
+ FileData *fd;
- vdtree_icon_set_by_iter(vd, iter, vd->pf->close);
+ vdtree_populate_path_by_iter(vd, iter, FALSE, NULL);
+ store = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
+
+ gtk_tree_model_get_iter(store, iter, tpath);
+ gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
+
+ fd = (nd) ? nd->fd : NULL;
+ if (fd && islink(fd->path))
+ {
+ vdtree_icon_set_by_iter(vd, iter, vd->pf->link);
+ }
+ else
+ {
+ vdtree_icon_set_by_iter(vd, iter, vd->pf->close);
+ }
}
static gint vdtree_sort_cb(GtkTreeModel *store, GtkTreeIter *a, GtkTreeIter *b, gpointer data)
vd->dnd_drop_leave_func = vdtree_dnd_drop_expand_cancel;
vd->dnd_drop_update_func = vdtree_dnd_drop_expand;
- store = gtk_tree_store_new(4, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
+ store = gtk_tree_store_new(6, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING);
vd->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
g_object_unref(store);
gtk_tree_view_append_column(GTK_TREE_VIEW(vd->view), column);
+ gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(vd->view), DIR_COLUMN_LINK);
+
vdtree_setup_root(vd);
g_signal_connect(G_OBJECT(vd->view), "row_expanded",