changeset 388:5186f8e38cb8

Make directory view popup menu common and move it to view_dir.{c,h}.
author zas_
date Wed, 16 Apr 2008 20:36:10 +0000
parents de6060230ec5
children b78077f65eff
files src/view_dir.c src/view_dir.h src/view_dir_list.c src/view_dir_list.h src/view_dir_tree.c src/view_dir_tree.h
diffstat 6 files changed, 301 insertions(+), 449 deletions(-) [+]
line wrap: on
line diff
--- a/src/view_dir.c	Wed Apr 16 20:32:44 2008 +0000
+++ b/src/view_dir.c	Wed Apr 16 20:36:10 2008 +0000
@@ -12,8 +12,11 @@
 #include "main.h"
 #include "view_dir.h"
 
+#include "dupe.h"
 #include "filelist.h"
+#include "layout_image.h"
 #include "layout_util.h"
+#include "ui_fileops.h"
 #include "ui_menu.h"
 #include "utilops.h"
 #include "view_dir_list.h"
@@ -220,3 +223,287 @@
 	return menu;
 }
 
+/*
+ *-----------------------------------------------------------------------------
+ * pop-up menu
+ *-----------------------------------------------------------------------------
+ */ 
+
+static void vd_pop_menu_up_cb(GtkWidget *widget, gpointer data)
+{
+	ViewDir *vd = data;
+	gchar *path;
+
+	if (!vd->path || strcmp(vd->path, "/") == 0) return;
+	path = remove_level_from_path(vd->path);
+
+	if (vd->select_func)
+		{
+		vd->select_func(vd, path, vd->select_data);
+		}
+
+	g_free(path);
+}
+
+static void vd_pop_menu_slide_cb(GtkWidget *widget, gpointer data)
+{
+	ViewDir *vd = data;
+	gchar *path;
+
+	if (!vd->layout) return;
+	if (!vd->click_fd) return;
+
+	path = vd->click_fd->path;
+
+	layout_set_path(vd->layout, path);
+	layout_select_none(vd->layout);
+	layout_image_slideshow_stop(vd->layout);
+	layout_image_slideshow_start(vd->layout);
+}
+
+static void vd_pop_menu_slide_rec_cb(GtkWidget *widget, gpointer data)
+{
+	ViewDir *vd = data;
+	gchar *path;
+	GList *list;
+
+	if (!vd->layout) return;
+	if (!vd->click_fd) return;
+
+	path = vd->click_fd->path;
+
+	list = filelist_recursive(path);
+
+	layout_image_slideshow_stop(vd->layout);
+	layout_image_slideshow_start_from_list(vd->layout, list);
+}
+
+static void vd_pop_menu_dupe(ViewDir *vd, gint recursive)
+{
+	DupeWindow *dw;
+	GList *list = NULL;
+
+	if (!vd->click_fd) return;
+
+	if (recursive)
+		{
+		list = g_list_append(list, file_data_ref(vd->click_fd));
+		}
+	else
+		{
+		filelist_read(vd->click_fd->path, &list, NULL);
+		list = filelist_filter(list, FALSE);
+		}
+
+	dw = dupe_window_new(DUPE_MATCH_NAME);
+	dupe_window_add_files(dw, list, recursive);
+
+	filelist_free(list);
+}
+
+static void vd_pop_menu_dupe_cb(GtkWidget *widget, gpointer data)
+{
+	ViewDir *vd = data;
+	vd_pop_menu_dupe(vd, FALSE);
+}
+
+static void vd_pop_menu_dupe_rec_cb(GtkWidget *widget, gpointer data)
+{
+	ViewDir *vd = data;
+	vd_pop_menu_dupe(vd, TRUE);
+}
+
+static void vd_pop_menu_delete_cb(GtkWidget *widget, gpointer data)
+{
+	ViewDir *vd = data;
+
+	if (!vd->click_fd) return;
+	file_util_delete_dir(vd->click_fd, vd->widget);
+}
+
+static void vd_pop_menu_dir_view_as_cb(GtkWidget *widget, gpointer data)
+{
+	ViewDir *vd = data;
+	DirViewType new_type = DIRVIEW_LIST;
+
+	if (!vd->layout) return;
+
+	switch(vd->type)
+	{
+	case DIRVIEW_LIST: new_type = DIRVIEW_TREE; break;
+	case DIRVIEW_TREE: new_type = DIRVIEW_LIST; break;
+	}
+	
+	layout_views_set(vd->layout, new_type, vd->layout->icon_view);
+}
+
+static void vd_pop_menu_refresh_cb(GtkWidget *widget, gpointer data)
+{
+	ViewDir *vd = data;
+
+	if (vd->layout) layout_refresh(vd->layout);
+}
+
+static void vd_toggle_show_hidden_files_cb(GtkWidget *widget, gpointer data)
+{
+	ViewDir *vd = data;
+
+	options->file_filter.show_hidden_files = !options->file_filter.show_hidden_files;
+	if (vd->layout) layout_refresh(vd->layout);
+}
+
+static void vd_pop_menu_new_cb(GtkWidget *widget, gpointer data)
+{
+	ViewDir *vd = data;
+	const gchar *path = NULL;
+	gchar *new_path;
+	gchar *buf;
+
+	switch(vd->type)
+		{
+		case DIRVIEW_LIST:
+			{
+			if (!vd->path) return;
+			path = vd->path;
+			};
+			break;
+		case DIRVIEW_TREE:
+			{
+			if (!vd->click_fd) return;
+			path = vd->click_fd->path;
+			};
+			break;
+		}
+
+	buf = concat_dir_and_file(path, _("new_folder"));
+	new_path = unique_filename(buf, NULL, NULL, FALSE);
+	g_free(buf);
+	if (!new_path) return;
+
+	if (!mkdir_utf8(new_path, 0755))
+		{
+		gchar *text;
+
+		text = g_strdup_printf(_("Unable to create folder:\n%s"), new_path);
+		file_util_warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, vd->view);
+		g_free(text);
+		}
+	else
+		{
+		switch(vd->type)
+			{
+			case DIRVIEW_LIST:
+				{
+				FileData *fd;
+	
+				vd_refresh(vd);
+				fd = vdlist_row_by_path(vd, new_path, NULL);
+	
+				vdlist_rename_by_row(vd, fd);
+				};
+				break;
+			case DIRVIEW_TREE:
+				{
+				FileData *fd;
+
+				fd = vdtree_populate_path(vd, new_path, TRUE, TRUE);
+				vdtree_rename_by_data(vd, fd);
+				};
+				break;
+			}
+		}
+
+	g_free(new_path);
+}
+
+static void vd_pop_menu_rename_cb(GtkWidget *widget, gpointer data)
+{
+	ViewDir *vd = data;
+	
+	switch(vd->type)
+	{
+	case DIRVIEW_LIST: vdlist_rename_by_row(vd, vd->click_fd); break;
+	case DIRVIEW_TREE: vdtree_rename_by_data(vd, vd->click_fd); break;
+	}
+}
+
+GtkWidget *vd_pop_menu(ViewDir *vd, FileData *fd)
+{
+	GtkWidget *menu;
+	gint active;
+	gint rename_delete_active = FALSE;
+	gint new_folder_active = FALSE;
+
+	active = (fd != NULL);
+	if (fd)
+		{
+		switch(vd->type)
+			{
+			case DIRVIEW_LIST:
+				{
+				/* check using . (always row 0) */
+				new_folder_active = (vd->path && access_file(vd->path , W_OK | X_OK));
+
+				/* ignore .. and . */
+				rename_delete_active = (new_folder_active &&
+					strcmp(fd->name, ".") != 0 &&
+		  			strcmp(fd->name, "..") != 0 &&
+		  			access_file(fd->path, W_OK | X_OK));
+				};
+				break;
+			case DIRVIEW_TREE:
+				{
+				gchar *parent;
+
+				new_folder_active = (fd && access_file(fd->path, W_OK | X_OK));
+				parent = remove_level_from_path(fd->path);
+				rename_delete_active = access_file(parent, W_OK | X_OK);
+				g_free(parent);
+				};
+				break;
+			}
+
+		}
+	menu = popup_menu_short_lived();
+	g_signal_connect(G_OBJECT(menu), "destroy",
+			 G_CALLBACK(vd_popup_destroy_cb), vd);
+
+	menu_item_add_stock_sensitive(menu, _("_Up to parent"), GTK_STOCK_GO_UP,
+				      (vd->path && strcmp(vd->path, "/") != 0),
+				      G_CALLBACK(vd_pop_menu_up_cb), vd);
+
+	menu_item_add_divider(menu);
+	menu_item_add_sensitive(menu, _("_Slideshow"), active,
+				G_CALLBACK(vd_pop_menu_slide_cb), vd);
+	menu_item_add_sensitive(menu, _("Slideshow recursive"), active,
+				G_CALLBACK(vd_pop_menu_slide_rec_cb), vd);
+
+	menu_item_add_divider(menu);
+	menu_item_add_stock_sensitive(menu, _("Find _duplicates..."), GTK_STOCK_FIND, active,
+				      G_CALLBACK(vd_pop_menu_dupe_cb), vd);
+	menu_item_add_stock_sensitive(menu, _("Find duplicates recursive..."), GTK_STOCK_FIND, active,
+				      G_CALLBACK(vd_pop_menu_dupe_rec_cb), vd);
+
+	menu_item_add_divider(menu);
+
+	menu_item_add_sensitive(menu, _("_New folder..."), new_folder_active,
+				G_CALLBACK(vd_pop_menu_new_cb), vd);
+
+	menu_item_add_sensitive(menu, _("_Rename..."), rename_delete_active,
+				G_CALLBACK(vd_pop_menu_rename_cb), vd);
+	menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, rename_delete_active,
+				      G_CALLBACK(vd_pop_menu_delete_cb), vd);
+
+	menu_item_add_divider(menu);
+	/* FIXME */
+	menu_item_add_check(menu, _("View as _tree"), vd->type,
+			    G_CALLBACK(vd_pop_menu_dir_view_as_cb), vd);
+	menu_item_add_check(menu, _("Show _hidden files"), options->file_filter.show_hidden_files,
+			    G_CALLBACK(vd_toggle_show_hidden_files_cb), vd);
+
+	menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH,
+			    G_CALLBACK(vd_pop_menu_refresh_cb), vd);
+
+	return menu;
+}
+
--- a/src/view_dir.h	Wed Apr 16 20:32:44 2008 +0000
+++ b/src/view_dir.h	Wed Apr 16 20:36:10 2008 +0000
@@ -39,6 +39,7 @@
 void vd_popup_destroy_cb(GtkWidget *widget, gpointer data);
 
 GtkWidget *vd_drop_menu(ViewDir *vd, gint active);
+GtkWidget *vd_pop_menu(ViewDir *vd, FileData *fd);
 
 
 #endif
--- a/src/view_dir_list.c	Wed Apr 16 20:32:44 2008 +0000
+++ b/src/view_dir_list.c	Wed Apr 16 20:36:10 2008 +0000
@@ -100,7 +100,7 @@
 	return FALSE;
 }
 
-static void vdlist_rename_by_row(ViewDir *vd, FileData *fd)
+void vdlist_rename_by_row(ViewDir *vd, FileData *fd)
 {
 	GtkTreeModel *store;
 	GtkTreePath *tpath;
@@ -115,7 +115,7 @@
 	gtk_tree_path_free(tpath);
 }
 
-static FileData *vdlist_row_by_path(ViewDir *vd, const gchar *path, gint *row)
+FileData *vdlist_row_by_path(ViewDir *vd, const gchar *path, gint *row)
 {
 	GList *work;
 	gint n;
@@ -146,224 +146,6 @@
 
 /*
  *-----------------------------------------------------------------------------
- * pop-up menu
- *-----------------------------------------------------------------------------
- */ 
-
-static void vdlist_pop_menu_up_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-	gchar *path;
-
-	if (!vd->path || strcmp(vd->path, "/") == 0) return;
-	path = remove_level_from_path(vd->path);
-
-	if (vd->select_func)
-		{
-		vd->select_func(vd, path, vd->select_data);
-		}
-
-	g_free(path);
-}
-
-static void vdlist_pop_menu_slide_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-	gchar *path;
-
-	if (!vd->layout) return;
-	if (!vd->click_fd) return;
-
-	path = vd->click_fd->path;
-
-	layout_set_path(vd->layout, path);
-	layout_select_none(vd->layout);
-	layout_image_slideshow_stop(vd->layout);
-	layout_image_slideshow_start(vd->layout);
-}
-
-static void vdlist_pop_menu_slide_rec_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-	gchar *path;
-	GList *list;
-
-	if (!vd->layout) return;
-	if (!vd->click_fd) return;
-
-	path = vd->click_fd->path;
-
-	list = filelist_recursive(path);
-
-	layout_image_slideshow_stop(vd->layout);
-	layout_image_slideshow_start_from_list(vd->layout, list);
-}
-
-static void vdlist_pop_menu_dupe(ViewDir *vd, gint recursive)
-{
-	DupeWindow *dw;
-	GList *list = NULL;
-
-	if (!vd->click_fd) return;
-
-	if (recursive)
-		{
-		list = g_list_append(list, file_data_ref(vd->click_fd));
-		}
-	else
-		{
-		filelist_read(vd->click_fd->path, &list, NULL);
-		list = filelist_filter(list, FALSE);
-		}
-
-	dw = dupe_window_new(DUPE_MATCH_NAME);
-	dupe_window_add_files(dw, list, recursive);
-
-	filelist_free(list);
-}
-
-static void vdlist_pop_menu_dupe_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-	vdlist_pop_menu_dupe(vd, FALSE);
-}
-
-static void vdlist_pop_menu_dupe_rec_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-	vdlist_pop_menu_dupe(vd, TRUE);
-}
-
-static void vdlist_pop_menu_new_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-	gchar *new_path;
-	gchar *buf;
-
-	if (!vd->path) return;
-
-	buf = concat_dir_and_file(vd->path, _("new_folder"));
-	new_path = unique_filename(buf, NULL, NULL, FALSE);
-	g_free(buf);
-	if (!new_path) return;
-
-	if (!mkdir_utf8(new_path, 0755))
-		{
-		gchar *text;
-
-		text = g_strdup_printf(_("Unable to create folder:\n%s"), new_path);
-		file_util_warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, vd->view);
-		g_free(text);
-		}
-	else
-		{
-		FileData *fd;
-
-		vdlist_refresh(vd);
-		fd = vdlist_row_by_path(vd, new_path, NULL);
-
-		vdlist_rename_by_row(vd, fd);
-		}
-
-	g_free(new_path);
-}
-
-static void vdlist_pop_menu_rename_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-
-	vdlist_rename_by_row(vd, vd->click_fd);
-}
-
-static void vdlist_pop_menu_delete_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-
-	if (!vd->click_fd) return;
-	file_util_delete_dir(vd->click_fd, vd->widget);
-}
-
-static void vdlist_pop_menu_dir_view_as_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-
-	if (vd->layout) layout_views_set(vd->layout, DIRVIEW_TREE, vd->layout->icon_view);
-}
-
-static void vdlist_pop_menu_refresh_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-
-	if (vd->layout) layout_refresh(vd->layout);
-}
-
-static void vdlist_toggle_show_hidden_files_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-
-	options->file_filter.show_hidden_files = !options->file_filter.show_hidden_files;
-	if (vd->layout) layout_refresh(vd->layout);
-}
-
-static GtkWidget *vdlist_pop_menu(ViewDir *vd, FileData *fd)
-{
-	GtkWidget *menu;
-	gint active;
-
-	active = (fd != NULL);
-
-	menu = popup_menu_short_lived();
-	g_signal_connect(G_OBJECT(menu), "destroy",
-			 G_CALLBACK(vd_popup_destroy_cb), vd);
-
-	menu_item_add_stock_sensitive(menu, _("_Up to parent"), GTK_STOCK_GO_UP,
-				      (vd->path && strcmp(vd->path, "/") != 0),
-				      G_CALLBACK(vdlist_pop_menu_up_cb), vd);
-
-	menu_item_add_divider(menu);
-	menu_item_add_sensitive(menu, _("_Slideshow"), active,
-				G_CALLBACK(vdlist_pop_menu_slide_cb), vd);
-	menu_item_add_sensitive(menu, _("Slideshow recursive"), active,
-				G_CALLBACK(vdlist_pop_menu_slide_rec_cb), vd);
-
-	menu_item_add_divider(menu);
-	menu_item_add_stock_sensitive(menu, _("Find _duplicates..."), GTK_STOCK_FIND, active,
-				      G_CALLBACK(vdlist_pop_menu_dupe_cb), vd);
-	menu_item_add_stock_sensitive(menu, _("Find duplicates recursive..."), GTK_STOCK_FIND, active,
-				      G_CALLBACK(vdlist_pop_menu_dupe_rec_cb), vd);
-
-	menu_item_add_divider(menu);
-
-	/* check using . (always row 0) */
-	active = (vd->path && access_file(vd->path , W_OK | X_OK));
-	menu_item_add_sensitive(menu, _("_New folder..."), active,
-				G_CALLBACK(vdlist_pop_menu_new_cb), vd);
-
-	/* ignore .. and . */
-	active = (active && fd &&
-		  strcmp(fd->name, ".") != 0 &&
-		  strcmp(fd->name, "..") != 0 &&
-		  access_file(fd->path, W_OK | X_OK));
-	menu_item_add_sensitive(menu, _("_Rename..."), active,
-				G_CALLBACK(vdlist_pop_menu_rename_cb), vd);
-	menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, active,
-				      G_CALLBACK(vdlist_pop_menu_delete_cb), vd);
-
-	menu_item_add_divider(menu);
-	menu_item_add_check(menu, _("View as _tree"), FALSE,
-			    G_CALLBACK(vdlist_pop_menu_dir_view_as_cb), vd);
-	menu_item_add_check(menu, _("Show _hidden files"), options->file_filter.show_hidden_files,
-			    G_CALLBACK(vdlist_toggle_show_hidden_files_cb), vd);
-
-	menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH,
-			    G_CALLBACK(vdlist_pop_menu_refresh_cb), vd);
-
-	return menu;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
  * dnd
  *-----------------------------------------------------------------------------
  */
@@ -866,7 +648,7 @@
 
 	vd_color_set(vd, vd->click_fd, TRUE);
 
-	vd->popup = vdlist_pop_menu(vd, vd->click_fd);
+	vd->popup = vd_pop_menu(vd, vd->click_fd);
 
 	gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, vdlist_menu_position_cb, vd, 0, GDK_CURRENT_TIME);
 
@@ -897,7 +679,7 @@
 
 	if (bevent->button == 3)
 		{
-		vd->popup = vdlist_pop_menu(vd, vd->click_fd);
+		vd->popup = vd_pop_menu(vd, vd->click_fd);
 		gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL,
 			       bevent->button, bevent->time);
 		}
--- a/src/view_dir_list.h	Wed Apr 16 20:32:44 2008 +0000
+++ b/src/view_dir_list.h	Wed Apr 16 20:36:10 2008 +0000
@@ -21,6 +21,9 @@
 const gchar *vdlist_row_get_path(ViewDir *vd, gint row);
 gint vdlist_find_row(ViewDir *vd, FileData *fd, GtkTreeIter *iter);
 
+void vdlist_rename_by_row(ViewDir *vd, FileData *fd);
+FileData *vdlist_row_by_path(ViewDir *vd, const gchar *path, gint *row);
+
 
 #endif
 
--- a/src/view_dir_tree.c	Wed Apr 16 20:32:44 2008 +0000
+++ b/src/view_dir_tree.c	Wed Apr 16 20:36:10 2008 +0000
@@ -52,7 +52,6 @@
 
 
 static gint vdtree_populate_path_by_iter(ViewDir *vd, GtkTreeIter *iter, gint force, const gchar *target_path);
-static FileData *vdtree_populate_path(ViewDir *vd, const gchar *path, gint expand, gint force);
 
 
 /*
@@ -198,7 +197,7 @@
 	return FALSE;
 }
 
-static void vdtree_rename_by_data(ViewDir *vd, FileData *fd)
+void vdtree_rename_by_data(ViewDir *vd, FileData *fd)
 {
 	GtkTreeModel *store;
 	GtkTreePath *tpath;
@@ -224,228 +223,6 @@
 }
 
 /*
- *-----------------------------------------------------------------------------
- * pop-up menu
- *-----------------------------------------------------------------------------
- */
-
-static void vdtree_pop_menu_up_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-	gchar *path;
-
-	if (!vd->path || strcmp(vd->path, "/") == 0) return;
-	path = remove_level_from_path(vd->path);
-
-	if (vd->select_func)
-		{
-		vd->select_func(vd, path, vd->select_data);
-		}
-
-	g_free(path);
-}
-
-static void vdtree_pop_menu_slide_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-	gchar *path;
-
-	if (!vd->layout) return;
-
-	if (!vd->click_fd) return;
-	path = vd->click_fd->path;
-
-	layout_set_path(vd->layout, path);
-	layout_select_none(vd->layout);
-	layout_image_slideshow_stop(vd->layout);
-	layout_image_slideshow_start(vd->layout);
-}
-
-static void vdtree_pop_menu_slide_rec_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-	gchar *path;
-	GList *list;
-
-	if (!vd->layout) return;
-
-	if (!vd->click_fd) return;
-	path = vd->click_fd->path;
-
-	list = filelist_recursive(path);
-
-	layout_image_slideshow_stop(vd->layout);
-	layout_image_slideshow_start_from_list(vd->layout, list);
-}
-
-static void vdtree_pop_menu_dupe(ViewDir *vd, gint recursive)
-{
-	DupeWindow *dw;
-	GList *list = NULL;
-
-	if (!vd->click_fd) return;
-
-	if (recursive)
-		{
-		list = g_list_append(list, file_data_ref(vd->click_fd));
-		}
-	else
-		{
-		filelist_read(vd->click_fd->path, &list, NULL);
-		list = filelist_filter(list, FALSE);
-		}
-
-	dw = dupe_window_new(DUPE_MATCH_NAME);
-	dupe_window_add_files(dw, list, recursive);
-
-	filelist_free(list);
-}
-
-static void vdtree_pop_menu_dupe_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-	vdtree_pop_menu_dupe(vd, FALSE);
-}
-
-static void vdtree_pop_menu_dupe_rec_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-	vdtree_pop_menu_dupe(vd, TRUE);
-}
-
-static void vdtree_pop_menu_new_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-	const gchar *path;
-	gchar *new_path;
-	gchar *buf;
-
-	if (!vd->click_fd) return;
-	path = vd->click_fd->path;
-
-	buf = concat_dir_and_file(path, _("new_folder"));
-	new_path = unique_filename(buf, NULL, NULL, FALSE);
-	g_free(buf);
-	if (!new_path) return;
-
-	if (!mkdir_utf8(new_path, 0755))
-		{
-		gchar *text;
-
-		text = g_strdup_printf(_("Unable to create folder:\n%s"), new_path);
-		file_util_warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, vd->view);
-		g_free(text);
-		}
-	else
-		{
-		FileData *fd;
-
-		fd = vdtree_populate_path(vd, new_path, TRUE, TRUE);
-
-		vdtree_rename_by_data(vd, fd);
-		}
-
-	g_free(new_path);
-}
-
-static void vdtree_pop_menu_rename_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-
-	vdtree_rename_by_data(vd, vd->click_fd);
-}
-
-static void vdtree_pop_menu_delete_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-
-	if (!vd->click_fd) return;
-	file_util_delete_dir(vd->click_fd, vd->widget);
-}
-
-static void vdtree_pop_menu_dir_view_as_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-
-	if (vd->layout) layout_views_set(vd->layout, DIRVIEW_LIST, vd->layout->icon_view);
-}
-
-static void vdtree_pop_menu_refresh_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-
-	if (vd->layout) layout_refresh(vd->layout);
-}
-
-static void vdtree_toggle_show_hidden_files_cb(GtkWidget *widget, gpointer data)
-{
-	ViewDir *vd = data;
-
-	options->file_filter.show_hidden_files = !options->file_filter.show_hidden_files;
-	if (vd->layout) layout_refresh(vd->layout);
-}
-
-static GtkWidget *vdtree_pop_menu(ViewDir *vd, FileData *fd)
-{
-	GtkWidget *menu;
-	gint active;
-	gint parent_active = FALSE;
-
-	active = (fd != NULL);
-	if (fd)
-		{
-		gchar *parent;
-
-		parent = remove_level_from_path(fd->path);
-		parent_active = access_file(parent, W_OK | X_OK);
-		g_free(parent);
-		}
-
-	menu = popup_menu_short_lived();
-	g_signal_connect(G_OBJECT(menu), "destroy",
-			 G_CALLBACK(vd_popup_destroy_cb), vd);
-
-	menu_item_add_stock_sensitive(menu, _("_Up to parent"), GTK_STOCK_GO_UP,
-		       		      (vd->path && strcmp(vd->path, "/") != 0),
-				      G_CALLBACK(vdtree_pop_menu_up_cb), vd);
-
-	menu_item_add_divider(menu);
-	menu_item_add_sensitive(menu, _("_Slideshow"), active,
-				G_CALLBACK(vdtree_pop_menu_slide_cb), vd);
-	menu_item_add_sensitive(menu, _("Slideshow recursive"), active,
-				G_CALLBACK(vdtree_pop_menu_slide_rec_cb), vd);
-
-	menu_item_add_divider(menu);
-	menu_item_add_stock_sensitive(menu, _("Find _duplicates..."), GTK_STOCK_FIND, active,
-				      G_CALLBACK(vdtree_pop_menu_dupe_cb), vd);
-	menu_item_add_stock_sensitive(menu, _("Find duplicates recursive..."), GTK_STOCK_FIND, active,
-				      G_CALLBACK(vdtree_pop_menu_dupe_rec_cb), vd);
-
-	menu_item_add_divider(menu);
-
-	active = (fd &&
-		  access_file(fd->path, W_OK | X_OK));
-	menu_item_add_sensitive(menu, _("_New folder..."), active,
-				G_CALLBACK(vdtree_pop_menu_new_cb), vd);
-
-	menu_item_add_sensitive(menu, _("_Rename..."), parent_active,
-				G_CALLBACK(vdtree_pop_menu_rename_cb), vd);
-	menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, parent_active,
-				      G_CALLBACK(vdtree_pop_menu_delete_cb), vd);
-
-	menu_item_add_divider(menu);
-	menu_item_add_check(menu, _("View as _tree"), TRUE,
-			    G_CALLBACK(vdtree_pop_menu_dir_view_as_cb), vd);
-	menu_item_add_check(menu, _("Show _hidden files"), options->file_filter.show_hidden_files,
-			    G_CALLBACK(vdtree_toggle_show_hidden_files_cb), vd);
-
-	menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH,
-			    G_CALLBACK(vdtree_pop_menu_refresh_cb), vd);
-
-	return menu;
-}
-
-/*
  *----------------------------------------------------------------------------
  * dnd
  *----------------------------------------------------------------------------
@@ -1088,7 +865,7 @@
 	return TRUE;
 }
 
-static FileData *vdtree_populate_path(ViewDir *vd, const gchar *path, gint expand, gint force)
+FileData *vdtree_populate_path(ViewDir *vd, const gchar *path, gint expand, gint force)
 {
 	GList *list;
 	GList *work;
@@ -1311,7 +1088,7 @@
 			vd->click_fd = fd;
 			vd_color_set(vd, vd->click_fd, TRUE);
 
-			vd->popup = vdtree_pop_menu(vd, vd->click_fd);
+			vd->popup = vd_pop_menu(vd, vd->click_fd);
 			gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, vdtree_menu_position_cb, vd, 0, GDK_CURRENT_TIME);
 
 			return TRUE;
@@ -1400,7 +1177,7 @@
 
 	if (bevent->button == 3)
 		{
-		vd->popup = vdtree_pop_menu(vd, vd->click_fd);
+		vd->popup = vd_pop_menu(vd, vd->click_fd);
 		gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL,
 			       bevent->button, bevent->time);
 		}
--- a/src/view_dir_tree.h	Wed Apr 16 20:32:44 2008 +0000
+++ b/src/view_dir_tree.h	Wed Apr 16 20:36:10 2008 +0000
@@ -20,6 +20,8 @@
 const gchar *vdtree_row_get_path(ViewDir *vd, gint row);
 gint vdtree_find_row(ViewDir *vd, FileData *fd, GtkTreeIter *iter, GtkTreeIter *parent);
 
+FileData *vdtree_populate_path(ViewDir *vd, const gchar *path, gint expand, gint force);
+void vdtree_rename_by_data(ViewDir *vd, FileData *fd);
 
 #endif