From: Colin Clark Date: Tue, 2 Feb 2016 13:15:49 +0000 (+0000) Subject: Feature Request #70 Navigation menu option and button for parent directory X-Git-Tag: v1.3~73 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=e9fc1363be4852aac7705a4423e7dceee84af892 Feature Request #70 Navigation menu option and button for parent directory This request was made some years ago: https://sourceforge.net/p/geeqie/feature-requests/70/ I have attached a patch which implements this. Also, keyboard-only users will be able to use keyboard-accelerators to map a key to the Up function. Unfortunately there is a usability problem. If the configuration file geeqirc.xml exists (which it will except for first-time installations) geeqie will not look at the programmed defaults, but will create the toolbar from the config file - and the Up icon will not be displayed. If the user first executes a command such as this: sed -i '/toolitem action = "Back"/a ' ~/.config/geeqie/geeqierc.xml then all will be well. This is not ideal, but I see no other solution. Colin Clark --- diff --git a/src/layout_util.c b/src/layout_util.c index a9540192..5d99ea38 100644 --- a/src/layout_util.c +++ b/src/layout_util.c @@ -1066,6 +1066,25 @@ static void layout_menu_home_cb(GtkAction *action, gpointer data) } } +static void layout_menu_up_cb(GtkAction *action, gpointer data) +{ + LayoutWindow *lw = data; + ViewDir *vd = lw->vd; + gchar *path; + + if (!vd->dir_fd || strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) == 0) return; + path = remove_level_from_path(vd->dir_fd->path); + + if (vd->select_func) + { + FileData *fd = file_data_new_dir(path); + vd->select_func(vd, fd, vd->select_data); + file_data_unref(fd); + } + + g_free(path); +} + /* *----------------------------------------------------------------------------- @@ -1275,6 +1294,7 @@ static GtkActionEntry menu_entries[] = { { "LastImage", GTK_STOCK_GOTO_BOTTOM, N_("_Last Image"), "End", N_("Last Image"), CB(layout_menu_image_last_cb) }, { "Back", GTK_STOCK_GO_BACK, N_("_Back"), NULL, N_("Back"), CB(layout_menu_back_cb) }, { "Home", GTK_STOCK_HOME, N_("_Home"), NULL, N_("Home"), CB(layout_menu_home_cb) }, + { "Up", GTK_STOCK_GO_UP, N_("_Up"), NULL, N_("Up"), CB(layout_menu_up_cb) }, { "NewWindow", GTK_STOCK_NEW, N_("New _window"), "N", N_("New window"), CB(layout_menu_new_window_cb) }, { "NewCollection", GTK_STOCK_INDEX, N_("_New collection"), "C", N_("New collection"), CB(layout_menu_new_cb) }, @@ -1466,6 +1486,7 @@ static const gchar *menu_ui_description = " " " " " " +" " " " " " " " @@ -2152,6 +2173,7 @@ void layout_toolbar_add_default(LayoutWindow *lw, ToolbarType type) case TOOLBAR_MAIN: layout_toolbar_add(lw, type, "Thumbnails"); layout_toolbar_add(lw, type, "Back"); + layout_toolbar_add(lw, type, "Up"); layout_toolbar_add(lw, type, "Home"); layout_toolbar_add(lw, type, "Refresh"); layout_toolbar_add(lw, type, "ZoomIn"); diff --git a/src/view_dir_list.c b/src/view_dir_list.c index fa65a74e..959eb318 100644 --- a/src/view_dir_list.c +++ b/src/view_dir_list.c @@ -146,15 +146,7 @@ static gboolean vdlist_populate(ViewDir *vd, gboolean clear) ret = filelist_read(vd->dir_fd, NULL, &VDLIST(vd)->list); VDLIST(vd)->list = filelist_sort(VDLIST(vd)->list, sort_type, sort_ascend); - /* add . and .. */ - - if (strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) != 0) - { - filepath = g_build_filename(vd->dir_fd->path, "..", NULL); - fd = file_data_new_dir(filepath); - VDLIST(vd)->list = g_list_prepend(VDLIST(vd)->list, fd); - g_free(filepath); - } + /* add . */ if (options->file_filter.show_dot_directory) {