Mercurial > geeqie
changeset 1637:cc3ccf3c7c27
unify code paths for New directory
keep the directory visible after rename
https://sourceforge.net/tracker/?func=detail&aid=1951183&group_id=222125&atid=1054680
author | nadvornik |
---|---|
date | Mon, 08 Jun 2009 19:05:49 +0000 |
parents | 157ef2c48fa2 |
children | 511c979c2e7c |
files | src/layout_util.c src/utilops.c src/utilops.h src/view_dir.c src/view_dir.h |
diffstat | 5 files changed, 36 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/layout_util.c Sun Jun 07 10:11:05 2009 +0000 +++ b/src/layout_util.c Mon Jun 08 19:05:49 2009 +0000 @@ -263,7 +263,7 @@ { LayoutWindow *lw = data; - file_util_create_dir(lw->dir_fd, layout_window(lw), NULL, NULL); + if (lw->vd) vd_new_folder(lw->vd, lw->dir_fd); } static void layout_menu_copy_cb(GtkAction *action, gpointer data)
--- a/src/utilops.c Sun Jun 07 10:11:05 2009 +0000 +++ b/src/utilops.c Mon Jun 08 19:05:49 2009 +0000 @@ -935,7 +935,8 @@ gint error = CHANGE_OK; gchar *desc = NULL; - if (ud->type != UTILITY_TYPE_CREATE_FOLDER) + if (ud->type != UTILITY_TYPE_CREATE_FOLDER && + ud->type != UTILITY_TYPE_RENAME_FOLDER) { if (ud->dest_path && !isdir(ud->dest_path)) { @@ -2580,7 +2581,7 @@ } -static void file_util_rename_dir_full(FileData *fd, const gchar *new_path, GtkWidget *parent, UtilityPhase phase) +static void file_util_rename_dir_full(FileData *fd, const gchar *new_path, GtkWidget *parent, UtilityPhase phase, FileUtilDoneFunc done_func, gpointer done_data) { UtilityData *ud; @@ -2594,6 +2595,10 @@ ud->flist = NULL; ud->content_list = NULL; ud->parent = parent; + + ud->done_func = done_func; + ud->done_data = done_data; + ud->dest_path = g_strdup(new_path); ud->messages.title = _("Rename"); ud->messages.question = _("Rename folder?"); @@ -2732,9 +2737,9 @@ file_util_create_dir_full(dir_fd, NULL, parent, UTILITY_PHASE_ENTERING, done_func, done_data); } -void file_util_rename_dir(FileData *source_fd, const gchar *new_path, GtkWidget *parent) +void file_util_rename_dir(FileData *source_fd, const gchar *new_path, GtkWidget *parent, FileUtilDoneFunc done_func, gpointer done_data) { - file_util_rename_dir_full(source_fd, new_path, parent, UTILITY_PHASE_ENTERING); + file_util_rename_dir_full(source_fd, new_path, parent, UTILITY_PHASE_ENTERING, done_func, done_data); }
--- a/src/utilops.h Sun Jun 07 10:11:05 2009 +0000 +++ b/src/utilops.h Mon Jun 08 19:05:49 2009 +0000 @@ -41,7 +41,7 @@ void file_util_create_dir(FileData *dir_fd, GtkWidget *parent, FileUtilDoneFunc done_func, gpointer done_data); -void file_util_rename_dir(FileData *source_fd, const gchar *new_path, GtkWidget *parent); +void file_util_rename_dir(FileData *source_fd, const gchar *new_path, GtkWidget *parent, FileUtilDoneFunc done_func, gpointer done_data); /* these avoid the location entry dialog, list must be files only and * dest_path must be a valid directory path
--- a/src/view_dir.c Sun Jun 07 10:11:05 2009 +0000 +++ b/src/view_dir.c Mon Jun 08 19:05:49 2009 +0000 @@ -242,6 +242,23 @@ return fd; } +static void vd_rename_finished_cb(gboolean success, const gchar *new_path, gpointer data) +{ + ViewDir *vd = data; + if (success) + { + FileData *fd = file_data_new_simple(new_path); + GtkTreeIter iter; + + if (vd_find_row(vd, fd, &iter)) + { + tree_view_row_make_visible(GTK_TREE_VIEW(vd->view), &iter, TRUE); + } + + file_data_unref(fd); + } +} + static gboolean vd_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data) { ViewDir *vd = data; @@ -256,7 +273,7 @@ new_path = g_build_filename(base, new, NULL); g_free(base); - file_util_rename_dir(fd, new_path, vd->view); + file_util_rename_dir(fd, new_path, vd->view, vd_rename_finished_cb, vd); g_free(new_path); @@ -686,6 +703,11 @@ return menu; } +void vd_new_folder(ViewDir *vd, FileData *dir_fd) +{ + file_util_create_dir(dir_fd, vd->widget, vd_pop_menu_new_rename_cb, vd); +} + /* *----------------------------------------------------------------------------- * dnd
--- a/src/view_dir.h Sun Jun 07 10:11:05 2009 +0000 +++ b/src/view_dir.h Mon Jun 08 19:05:49 2009 +0000 @@ -42,6 +42,8 @@ GtkWidget *vd_drop_menu(ViewDir *vd, gint active); GtkWidget *vd_pop_menu(ViewDir *vd, FileData *fd); +void vd_new_folder(ViewDir *vd, FileData *dir_fd); + void vd_dnd_drop_scroll_cancel(ViewDir *vd); void vd_dnd_init(ViewDir *vd);