comparison src/collect.c @ 2878:8b1c451c8ff2

Additional remote commands --get-filelist:[<FOLDER>] Get list of files and class --get-filelist-recurse:[<FOLDER>] Get list of files and class recursive --get-collection:<COLLECTION> Get collection content --get-collection-list Get list of collections Changed command: --tell Print filename of current image [and Collection, if collection being displayed]
author Colin Clark <colin.clark@cclark.uk>
date Fri, 04 Jan 2019 13:44:58 +0000
parents b20a96b979a3
children 2e7fd08bfbe4
comparison
equal deleted inserted replaced
2877:92494a7432e9 2878:8b1c451c8ff2
343 * @param[in] param Filename, with or without extension of any collection 343 * @param[in] param Filename, with or without extension of any collection
344 * @returns full pathname if found or NULL 344 * @returns full pathname if found or NULL
345 * 345 *
346 * Return value must be freed with g_free() 346 * Return value must be freed with g_free()
347 */ 347 */
348 gchar *collection_path(gchar *param) 348 gchar *collection_path(const gchar *param)
349 { 349 {
350 gchar *path = NULL; 350 gchar *path = NULL;
351 gchar *full_name = NULL; 351 gchar *full_name = NULL;
352 352
353 if (file_extension_match(param, GQ_COLLECTION_EXT)) 353 if (file_extension_match(param, GQ_COLLECTION_EXT))
375 * @param[in] param Filename with or without extension of any collection 375 * @param[in] param Filename with or without extension of any collection
376 * @returns TRUE if found 376 * @returns TRUE if found
377 * 377 *
378 * 378 *
379 */ 379 */
380 gboolean is_collection(gchar *param) 380 gboolean is_collection(const gchar *param)
381 { 381 {
382 gchar *name = NULL; 382 gchar *name = NULL;
383 383
384 name = collection_path(param); 384 name = collection_path(param);
385 if (name) 385 if (name)
386 { 386 {
387 g_free(name); 387 g_free(name);
388 return TRUE; 388 return TRUE;
389 } 389 }
390 return FALSE; 390 return FALSE;
391 }
392
393 /**
394 * @brief Creates a text list of the image paths of the contents of a Collection
395 * @param[in] name The name of the collection, with or wihout extension
396 * @param[inout] contents A GString to which the image paths are appended
397 *
398 *
399 */
400 void collection_contents(const gchar *name, GString **contents)
401 {
402 gchar *path;
403 CollectionData *cd;
404 CollectInfo *ci;
405 GList *work;
406 FileData *fd;
407
408 if (is_collection(name))
409 {
410 path = collection_path(name);
411 cd = collection_new("");
412 collection_load(cd, path, COLLECTION_LOAD_APPEND);
413 work = cd->list;
414 while (work)
415 {
416 ci = work->data;
417 fd = ci->fd;
418 *contents = g_string_append(*contents, g_strdup(fd->path));
419 *contents = g_string_append(*contents, "\n");
420
421 work = work->next;
422 }
423 g_free(path);
424 collection_free(cd);
425 }
391 } 426 }
392 427
393 /* 428 /*
394 *------------------------------------------------------------------- 429 *-------------------------------------------------------------------
395 * please use these to actually add/remove stuff 430 * please use these to actually add/remove stuff