/*
- * Geeqie
- * (C) 2006 John Ellis
- * Copyright (C) 2008 - 2010 The Geeqie Team
+ * Copyright (C) 2006 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
*
* Author: John Ellis
*
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "main.h"
{
GdkCursor *cursor = NULL;
- if (!widget || !widget->window) return;
+ if (!widget || !gtk_widget_get_window(widget)) return;
if (cursor_type > -1) cursor = gdk_cursor_new(cursor_type);
- gdk_window_set_cursor(widget->window, cursor);
+ gdk_window_set_cursor(gtk_widget_get_window(widget), cursor);
if (cursor) gdk_cursor_unref(cursor);
gdk_flush();
}
{
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
return list;
}
-/*
- *----------------------------------------------------------------------------
- * misc
- *----------------------------------------------------------------------------
- */
-
-#if 0
-static void vdtree_row_deleted_cb(GtkTreeModel *tree_model, GtkTreePath *tpath, gpointer data)
-{
- GtkTreeIter iter;
- NodeData *nd;
-
- gtk_tree_model_get_iter(tree_model, &iter, tpath);
- gtk_tree_model_get(tree_model, &iter, DIR_COLUMN_POINTER, &nd, -1);
-
- if (!nd) return;
-
- file_data_unref(nd->fd);
- g_free(nd);
-}
-#endif
/*
*----------------------------------------------------------------------------
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);
DEBUG_1("Too frequent update of %s", nd->fd->path);
return TRUE;
}
- if (nd->fd->version == nd->version) return TRUE;
+ file_data_check_changed_files(nd->fd); /* make sure we have recent info */
}
- 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;
- struct stat sbuf;
+ 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 (stat_utf8(name8, &sbuf))
- {
- list = g_list_prepend(list, file_data_new_simple(name8));
- }
+ filelist_read(nd->fd, NULL, &list);
+
+ if (add_hidden)
+ {
+ gint n;
+ gchar *name8;
- g_free(name8);
+ n = strlen(nd->fd->path) + 1;
+
+ 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;
}
gtk_tree_view_get_cursor(GTK_TREE_VIEW(vd->view), &old_tpath, NULL);
tpath = gtk_tree_model_get_path(store, &iter);
-
+
if (!old_tpath || gtk_tree_path_compare(tpath, old_tpath) != 0)
{
/* setting the cursor scrolls the view; do not do that unless it is necessary */
gtk_tree_view_set_cursor(GTK_TREE_VIEW(vd->view), tpath, NULL, FALSE);
-
+
/* gtk_tree_view_set_cursor scrolls the window itself, but it sometimes
does not work (switch from dir_list to dir_tree) */
tree_view_row_make_visible(GTK_TREE_VIEW(vd->view), &iter, TRUE);
return TRUE;
}
-#if 0
-const gchar *vdtree_get_path(ViewDir *vd)
-{
- return vd->path;
-}
-#endif
-
void vdtree_refresh(ViewDir *vd)
{
vdtree_populate_path(vd, vd->dir_fd, FALSE, 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;
}
switch (event->keyval)
{
- case GDK_Menu:
+ case GDK_KEY_Menu:
vd->click_fd = fd;
vd_color_set(vd, vd->click_fd, TRUE);
return TRUE;
break;
- case GDK_plus:
- case GDK_Right:
- case GDK_KP_Add:
+ case GDK_KEY_plus:
+ case GDK_KEY_Right:
+ case GDK_KEY_KP_Add:
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_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);
- vdtree_icon_set_by_iter(vd, iter, vd->pf->close);
+ 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)
FileData *fd;
- fd = file_data_new_simple(path);
+ fd = file_data_new_dir(path);
vdtree_add_by_data(vd, fd, NULL);
vdtree_expand_by_data(vd, fd, TRUE);
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",