From 1797b9e1a522b077f852aa560b35d0fca018c603 Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Mon, 11 Apr 2016 19:14:29 +0100 Subject: [PATCH] Issue #329 easier way to get cwd when copying https://github.com/BestImageViewer/geeqie/issues/329 A bookmark with the name "." (a single full-stop) is treated as a special case. Each time it is displayed, its path is loaded with Geeqie's current working folder. This bookmark, like any other, can be deleted and re-created at any time. --- doc/docbook/GuideImageManagementCopyMove.xml | 2 ++ src/options.c | 1 + src/ui_bookmark.c | 23 +++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/docbook/GuideImageManagementCopyMove.xml b/doc/docbook/GuideImageManagementCopyMove.xml index 00884fe0..1e8adf61 100644 --- a/doc/docbook/GuideImageManagementCopyMove.xml +++ b/doc/docbook/GuideImageManagementCopyMove.xml @@ -35,6 +35,8 @@ This list on the left side of the window allows you to save links to folders that are frequently used. Activating a bookmark will change the active path to that pointed to by the link. To add items to the bookmark list highlight a folder and press Ctrl + B, select “Add bookmark” from the folder's context menu, or drag a folder onto the bookmark list. The bookmark has a context menu that can be displayed by clicking the right mouse button, or pressing the Menu key when a bookmark has the focus. From the context menu you can edit a bookmark, move it up or down in the list, or remove the bookmark from the list. A bookmark can also be moved by pressing Shift + Up or Shift + Down while it has the focus. + + A bookmark with the name "." is treated as a special case. Each time this bookmark is displayed, its path is loaded with Geeqie's current working folder. This bookmark, like any other, can be deleted and re-created at any time. Folder list diff --git a/src/options.c b/src/options.c index 1c02f94b..fa6c23fb 100644 --- a/src/options.c +++ b/src/options.c @@ -141,6 +141,7 @@ void setup_default_options(ConfOptions *options) gchar *path; gint i; + bookmark_add_default(".", get_current_dir()); bookmark_add_default(_("Home"), homedir()); path = g_build_filename(homedir(), "Desktop", NULL); bookmark_add_default(_("Desktop"), path); diff --git a/src/ui_bookmark.c b/src/ui_bookmark.c index b9b56394..842b9479 100644 --- a/src/ui_bookmark.c +++ b/src/ui_bookmark.c @@ -550,6 +550,10 @@ static void bookmark_populate(BookMarkData *bm) history_list_add_to_key(bm->key, buf, 0); g_free(buf); + buf = bookmark_string(".", g_strdup(history_list_find_last_path_by_key("path_list")), NULL); + history_list_add_to_key(bm->key, buf, 0); + g_free(buf); + path = g_build_filename(homedir(), "Desktop", NULL); if (isname(path)) { @@ -570,7 +574,14 @@ static void bookmark_populate(BookMarkData *bm) path = work->data; work = work->next; - buf = bookmark_string(name, path, NULL); + if (strcmp(name, ".") == 0) + { + buf = bookmark_string(name, g_strdup(history_list_find_last_path_by_key("path_list")), NULL); + } + else + { + buf = bookmark_string(name, path, NULL); + } history_list_add_to_key(bm->key, buf, 0); g_free(buf); } @@ -585,6 +596,16 @@ static void bookmark_populate(BookMarkData *bm) b = bookmark_from_string(work->data); if (b) { + if (strcmp(b->name, ".") == 0) + { + gchar *buf; + + b->path = g_strdup(history_list_find_last_path_by_key("path_list")); + buf = bookmark_string(".", b->path, b->icon); + history_list_item_change("bookmarks", b->key, buf); + b->key = g_strdup(buf); + g_free(buf); + } GtkWidget *box; b->button = gtk_button_new(); -- 2.20.1