diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:11:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:11:51 +0000 |
commit | a6f3675fc4e21b3f899286b9a02005368d913f74 (patch) | |
tree | c9bfa92b223783ff03b8e941c3bb0d36c68d3b5e /lib/mcconfig/history.c | |
parent | Releasing progress-linux version 3:4.8.30-1~progress7.99u1. (diff) | |
download | mc-a6f3675fc4e21b3f899286b9a02005368d913f74.tar.xz mc-a6f3675fc4e21b3f899286b9a02005368d913f74.zip |
Merging upstream version 3:4.8.31.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/mcconfig/history.c')
-rw-r--r-- | lib/mcconfig/history.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/lib/mcconfig/history.c b/lib/mcconfig/history.c index bfbdf0a..57249c4 100644 --- a/lib/mcconfig/history.c +++ b/lib/mcconfig/history.c @@ -1,7 +1,7 @@ /* - Widgets for the Midnight Commander + Configure module for the Midnight Commander - Copyright (C) 1994-2023 + Copyright (C) 1994-2024 Free Software Foundation, Inc. Authors: @@ -10,7 +10,7 @@ Jakub Jelinek, 1995 Andrej Borsenkow, 1996 Norbert Warmuth, 1997 - Andrew Borodin <aborodin@vmail.ru>, 2009-2019 + Andrew Borodin <aborodin@vmail.ru>, 2009-2023 This file is part of the Midnight Commander. @@ -65,7 +65,7 @@ int num_history_items_recorded = 60; /* --------------------------------------------------------------------------------------------- */ /** - * Load the history from the ${XDG_CACHE_HOME}/mc/history file. + * Load the history from the ${XDG_DATA_HOME}/mc/history file. * It is called with the widgets history name and returns the GList list. */ @@ -95,6 +95,33 @@ mc_config_history_get (const char *name) /* --------------------------------------------------------------------------------------------- */ /** + * Get the recent item of a history from the ${XDG_DATA_HOME}/mc/history file. + * + * TODO: get rid of load the entire history to get the only top item. + */ + +char * +mc_config_history_get_recent_item (const char *name) +{ + GList *history; + char *item = NULL; + + history = mc_config_history_get (name); + if (history != NULL) + { + /* FIXME: can history->data be NULL? */ + item = (char *) history->data; + history->data = NULL; + history = g_list_first (history); + g_list_free_full (history, g_free); + } + + return item; +} + +/* --------------------------------------------------------------------------------------------- */ + +/** * Load history from the mc_config */ GList * @@ -177,8 +204,7 @@ mc_config_history_save (mc_config_t * cfg, const char *name, GList * h) for (i = 0; (i < num_history_items_recorded - 1) && (h->prev != NULL); i++) h = g_list_previous (h); - if (name != NULL) - mc_config_del_group (cfg, name); + mc_config_del_group (cfg, name); /* create charset conversion handler to convert strings from system codepage to UTF-8 */ |