"Fossies" - the Fresh Open Source Software Archive

Member "feh-3.4.1/src/list.c" (29 May 2020, 3021 Bytes) of package /linux/privat/feh-3.4.1.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "list.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 3.4_vs_3.4.1.

    1 /* list.c
    2 
    3 Copyright (C) 1999-2003 Tom Gilbert.
    4 Copyright (C) 2010-2020 Daniel Friesel.
    5 
    6 Permission is hereby granted, free of charge, to any person obtaining a copy
    7 of this software and associated documentation files (the "Software"), to
    8 deal in the Software without restriction, including without limitation the
    9 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   10 sell copies of the Software, and to permit persons to whom the Software is
   11 furnished to do so, subject to the following conditions:
   12 
   13 The above copyright notice and this permission notice shall be included in
   14 all copies of the Software and its documentation and acknowledgment shall be
   15 given in the documentation and software packages that this Software was
   16 used.
   17 
   18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   21 THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
   22 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
   23 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   24 
   25 */
   26 
   27 #include "feh.h"
   28 #include "filelist.h"
   29 #include "options.h"
   30 
   31 void init_list_mode(void)
   32 {
   33     gib_list *l;
   34     feh_file *file = NULL;
   35     int j = 0;
   36 
   37     mode = "list";
   38 
   39     if (!opt.customlist)
   40         fputs("NUM\tFORMAT\tWIDTH\tHEIGHT\tPIXELS\tSIZE\tALPHA\tFILENAME\n",
   41                 stdout);
   42 
   43     for (l = filelist; l; l = l->next) {
   44         file = FEH_FILE(l->data);
   45         if (opt.customlist)
   46             printf("%s\n", feh_printf(opt.customlist, file, NULL));
   47         else {
   48             printf("%d\t%s\t%d\t%d\t%s", ++j,
   49                     file->info->format, file->info->width,
   50                     file->info->height,
   51                     format_size(file->info->pixels));
   52             printf("\t%s\t%c\t%s\n",
   53                     format_size(file->info->size),
   54                     file->info->has_alpha ? 'X' : '-', file->filename);
   55         }
   56 
   57         feh_action_run(file, opt.actions[0], NULL);
   58     }
   59     exit(0);
   60 }
   61 
   62 void init_loadables_mode(void)
   63 {
   64     mode = "loadables";
   65     real_loadables_mode(1);
   66     return;
   67 }
   68 
   69 void init_unloadables_mode(void)
   70 {
   71     mode = "unloadables";
   72     real_loadables_mode(0);
   73     return;
   74 }
   75 
   76 void real_loadables_mode(int loadable)
   77 {
   78     feh_file *file;
   79     gib_list *l;
   80     char ret = 0;
   81 
   82     opt.quiet = 1;
   83 
   84     for (l = filelist; l; l = l->next) {
   85         Imlib_Image im = NULL;
   86 
   87         file = FEH_FILE(l->data);
   88 
   89         if (feh_load_image(&im, file)) {
   90             /* loaded ok */
   91             if (loadable) {
   92                 if (opt.verbose)
   93                     feh_display_status('.');
   94                 puts(file->filename);
   95                 fflush(stdout);
   96                 feh_action_run(file, opt.actions[0], NULL);
   97             }
   98             else {
   99                 if (opt.verbose)
  100                     feh_display_status('s');
  101                 ret = 1;
  102             }
  103             gib_imlib_free_image_and_decache(im);
  104         } else {
  105             /* Oh dear. */
  106             if (!loadable) {
  107                 if (opt.verbose)
  108                     feh_display_status('.');
  109                 puts(file->filename);
  110                 fflush(stdout);
  111                 feh_action_run(file, opt.actions[0], NULL);
  112             }
  113             else {
  114                 if (opt.verbose)
  115                     feh_display_status('s');
  116                 ret = 1;
  117             }
  118         }
  119     }
  120     if (opt.verbose)
  121         feh_display_status(0);
  122     exit(ret);
  123 }