Mercurial > hg > forks > geeqie
changeset 2561:ff4f232cdf4b
Collections on command line
In the current implementation, the complete path must be used when
opening a collection from the command line.
This commit permits just the collection name, with or without extension,
to be used.
author | Colin Clark <colin.clark@cclark.uk> |
---|---|
date | Thu, 20 Jul 2017 09:57:57 +0100 |
parents | 94011c997c04 |
children | 4e1c0f3b2d49 |
files | doc/docbook/GuideReferenceCommandLine.xml src/main.c |
diffstat | 2 files changed, 48 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/docbook/GuideReferenceCommandLine.xml Tue Jul 18 19:39:58 2017 +0100 +++ b/doc/docbook/GuideReferenceCommandLine.xml Thu Jul 20 09:57:57 2017 +0100 @@ -3,7 +3,9 @@ <title>Command Line Options</title> <para> Geeqie is called by the command: - <programlisting>geeqie [options] [path_to_file]</programlisting> + <programlisting> + geeqie [options] [path_to_file_or_collection] <footnote id='ref1'>The name of a collection, with or without either path or extension (.gqv) may be used. If a path is not used and there is a name conflict with a file or folder, that will take precedence.</footnote> + </programlisting> </para> <para>These are the command line options available to Geeqie:</para> <table frame="all">
--- a/src/main.c Tue Jul 18 19:39:58 2017 +0100 +++ b/src/main.c Thu Jul 20 09:57:57 2017 +0100 @@ -214,6 +214,32 @@ parse_command_line_add_file(file_path, path, file, list, collection_list); } +static gboolean is_collection(gchar *cmd_param) +{ + gchar *path = NULL; + gchar *full_name = NULL; + gboolean result = FALSE; + + if (file_extension_match(cmd_param, GQ_COLLECTION_EXT)) + { + path = g_build_filename(get_collections_dir(), cmd_param, NULL); + } + else if (file_extension_match(cmd_param, NULL)) + { + full_name = g_strconcat(cmd_param, GQ_COLLECTION_EXT, NULL); + path = g_build_filename(get_collections_dir(), full_name, NULL); + } + + if (isfile(path)) + { + result = TRUE; + } + + g_free(path); + g_free(full_name); + return result; +} + static void parse_command_line(gint argc, gchar *argv[]) { GList *list = NULL; @@ -256,6 +282,25 @@ parse_command_line_process_file(cmd_all, &command_line->path, &command_line->file, &list, &command_line->collection_list, &first_dir); } + else if (is_collection(cmd_line)) + { + gchar *path = NULL; + gchar *full_name = NULL; + + if (file_extension_match(cmd_line, GQ_COLLECTION_EXT)) + { + path = g_build_filename(get_collections_dir(), cmd_line, NULL); + } + else + { + full_name = g_strconcat(cmd_line, GQ_COLLECTION_EXT, NULL); + path = g_build_filename(get_collections_dir(), full_name, NULL); + } + parse_command_line_process_file(path, &command_line->path, &command_line->file, + &list, &command_line->collection_list, &first_dir); + g_free(path); + g_free(full_name); + } else if (strncmp(cmd_line, "--debug", 7) == 0 && (cmd_line[7] == '\0' || cmd_line[7] == '=')) { /* do nothing but do not produce warnings */