Do not display recent files if there aren't any

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Sebastian Ramacher 2015-07-26 23:38:10 +02:00
parent 5d490f6895
commit 7da7bcb4c1
2 changed files with 26 additions and 7 deletions

View File

@ -2,11 +2,25 @@
#
# See LICENSE file for license and copyright information
import os.path
import glob
import time
dirname = os.path.dirname(__file__)
files = glob.glob(os.path.join(dirname, '*.rst'))
files.extend(glob.glob(os.path.join(dirname, '*.txt')))
maxdate = 0
for path in files:
s = os.stat(path)
maxdate = max(maxdate, s.st_mtime)
# -- General configuration ------------------------------------------------
source_suffix = '.rst'
master_doc = 'zathura.1'
templates_path = ['_templates']
today = time.strftime('%Y-%m-%d', time.gmtime(maxdate))
# -- Project configuration ------------------------------------------------

View File

@ -196,13 +196,18 @@ list_files_for_cc(zathura_t* zathura, const char* input, bool check_file_ext, in
goto error_free;
}
const size_t path_len = strlen(path);
GIRARA_LIST_FOREACH(recent_files, const char*, iter, file)
if (strncmp(path, file, path_len) == 0) {
girara_completion_group_add_element(history_group, file, NULL);
}
GIRARA_LIST_FOREACH_END(recent_files, const char*, iter, file);
girara_list_free(recent_files);
if (girara_list_size(recent_files) != 0) {
const size_t path_len = strlen(path);
GIRARA_LIST_FOREACH(recent_files, const char*, iter, file)
if (strncmp(path, file, path_len) == 0) {
girara_completion_group_add_element(history_group, file, NULL);
}
GIRARA_LIST_FOREACH_END(recent_files, const char*, iter, file);
girara_list_free(recent_files);
} else {
girara_completion_group_free(history_group);
history_group = NULL;
}
}
g_free(path);