# HG changeset patch # User Colin Clark # Date 1500541077 -3600 # Node ID ff4f232cdf4bccf18a6fe328969b28f2c5c07afb # Parent 94011c997c042665a2ad33f0b310f64188bdd629 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. diff -r 94011c997c04 -r ff4f232cdf4b doc/docbook/GuideReferenceCommandLine.xml --- 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 @@ Command Line Options Geeqie is called by the command: - geeqie [options] [path_to_file] + + geeqie [options] [path_to_file_or_collection] 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. + These are the command line options available to Geeqie: diff -r 94011c997c04 -r ff4f232cdf4b src/main.c --- 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 */