Ticket #5: feh-fmmode-new.patch

File feh-fmmode-new.patch, 8.8 kB (added by giblet, 3 years ago)

New patch from Falko

  • feh-1.3.3/src/fmmode.c

    old new  
     1/* fmmode.c 
     2 
     3Copyright (C) 2005 Falko Schmidt. 
     4 
     5Permission is hereby granted, free of charge, to any person obtaining a copy 
     6of this software and associated documentation files (the "Software"), to 
     7deal in the Software without restriction, including without limitation the 
     8rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 
     9sell copies of the Software, and to permit persons to whom the Software is 
     10furnished to do so, subject to the following conditions: 
     11 
     12The above copyright notice and this permission notice shall be included in 
     13all copies of the Software and its documentation and acknowledgment shall be 
     14given in the documentation and software packages that this Software was 
     15used. 
     16 
     17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
     18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
     19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
     20THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
     21IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
     22CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     23 
     24*/ 
     25 
     26#include <dirent.h> 
     27#include <sys/types.h> 
     28#include <sys/stat.h> 
     29#include "feh.h" 
     30#include "filelist.h" 
     31#include "options.h" 
     32 
     33void fmmode(void) 
     34{ 
     35   char *initial_file_path; 
     36   char *initial_file_dir; 
     37   struct dirent *dirstr; 
     38   struct stat statstr; 
     39   DIR *directory; 
     40   int i = 0; 
     41   int j = 0; 
     42   gib_list *remove_list = NULL; 
     43    
     44   initial_file_path = (FEH_FILE(filelist->data)->filename); 
     45   initial_file_dir = strdup(initial_file_path); 
     46   initial_file_dir = dirname(initial_file_dir); 
     47    
     48/* in case fmmode is invoked with an image with relative path. */ 
     49   if (!strcmp(initial_file_dir,".")) 
     50   { 
     51      initial_file_dir = getcwd (NULL, 0); 
     52      initial_file_path = estrjoin("", initial_file_dir, "/",  
     53                                   initial_file_path, NULL); 
     54      j = 1; 
     55   } 
     56   if (!strncmp("/", initial_file_dir,1)) 
     57      ; 
     58   else 
     59   { 
     60      initial_file_dir = estrjoin("", getcwd (NULL, 0), "/",  
     61                                  initial_file_dir, NULL); 
     62      initial_file_path = estrjoin("", getcwd (NULL, 0), "/",  
     63                                   initial_file_path, NULL); 
     64      j = 0; 
     65   }  
     66    
     67   /* error handling. */ 
     68   if ((directory = opendir(initial_file_dir)) == NULL) 
     69      { 
     70         if (!opt.quiet) 
     71            weprintf("couldn't open directory %s:", initial_file_dir); 
     72         free(initial_file_dir); 
     73         D_RETURN_(5); 
     74      } 
     75 
     76   chdir(initial_file_dir); 
     77    
     78/* just in case... */ 
     79   filelist = NULL; 
     80     
     81/* add all files in the current directory to the filelist. */ 
     82   while ((dirstr = readdir(directory)) != NULL) 
     83   { 
     84      stat(dirstr->d_name, &statstr); 
     85      if (S_ISDIR(statstr.st_mode)) 
     86         ; 
     87      else if (S_ISREG(statstr.st_mode)) 
     88      { 
     89         char *newfile; 
     90         newfile = estrjoin("", initial_file_dir, "/", dirstr->d_name, NULL); 
     91         add_file_to_filelist_recursively(newfile, FILELIST_FIRST); 
     92         free(newfile); 
     93      } 
     94   }  
     95   filelist_len = gib_list_length(filelist); 
     96   closedir(directory); 
     97 
     98   feh_prepare_filelist(); 
     99   current_file = filelist; 
     100   if (j == 2) 
     101   { 
     102      remove_list= gib_list_add_front(remove_list, gib_list_last(current_file)); 
     103      current_file = filelist; 
     104   } 
     105   while (i<(filelist_len) && 
     106          strcmp((FEH_FILE(current_file->data)->filename),initial_file_path)) 
     107      { 
     108         filelist = gib_list_add_end(filelist, 
     109                    feh_file_new(FEH_FILE(current_file->data)->filename)); 
     110         remove_list = gib_list_add_front(remove_list, current_file); 
     111         current_file = current_file->next; 
     112         i++; 
     113      } 
     114    
     115   if (j == 3) 
     116   {    
     117      remove_list = gib_list_add_front(remove_list, current_file); 
     118   } 
     119    
     120   if (remove_list) 
     121   { 
     122      for (current_file=remove_list;current_file; 
     123           current_file=current_file->next) 
     124         filelist = gib_list_remove(filelist, (gib_list *) current_file->data); 
     125 
     126      gib_list_free(remove_list); 
     127   } 
     128    
     129   free(initial_file_dir); 
     130} 
  • feh-1.3.3/src/fmmode.h

    old new  
     1/* fmmode.h 
     2 
     3Copyright (C) 2005 Falko Schmidt. 
     4 
     5Permission is hereby granted, free of charge, to any person obtaining a copy 
     6of this software and associated documentation files (the "Software"), to 
     7deal in the Software without restriction, including without limitation the 
     8rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 
     9sell copies of the Software, and to permit persons to whom the Software is 
     10furnished to do so, subject to the following conditions: 
     11 
     12The above copyright notice and this permission notice shall be included in 
     13all copies of the Software and its documentation and acknowledgment shall be 
     14given in the documentation and software packages that this Software was 
     15used. 
     16 
     17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
     18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
     19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
     20THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
     21IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
     22CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     23 
     24*/ 
     25 
     26#ifndef FMMODE_H 
     27#define FMMODE_H 
     28 
     29void fmmode(void); 
     30 
     31#endif 
  • feh-1.3.3/src/main.c

    old new  
    3030#include "options.h" 
    3131#include "events.h" 
    3232#include "support.h" 
     33#include "fmmode.h" 
    3334 
    3435char **cmdargv = NULL; 
    3536int cmdargc = 0; 
     
    6768      feh_wm_set_bg_file(opt.output_file, opt.bgmode); 
    6869      exit(0); 
    6970   } 
    70 /*   else if (opt.fmmode) 
     71   else if (opt.fmmode) 
    7172   { 
    7273      fmmode(); 
    7374      opt.slideshow = 1; 
    74       init_slideshow_mode();  
     75      init_slideshow_mode(); 
     76      opt.fmmode = 0; 
    7577   } 
    76  */ 
     78  
    7779   else 
    7880   { 
    7981      /* Slideshow mode is the default. Because it's spiffy */ 
     
    186188         } 
    187189      } 
    188190   } 
     191   else if (opt.fmmode) 
     192   { 
     193      fmmode(); 
     194      opt.slideshow = 1; 
     195      init_slideshow_mode(); 
     196   } 
    189197   else 
    190198   { 
    191199      /* Don't block if there are events in the queue. That's a bit rude ;-) */ 
  • feh-1.3.3/src/Makefile.am

    old new  
    1616filelist.c filelist.h multiwindow.c imlib.c index.c slideshow.c \ 
    1717utils.c utils.h keyevents.c timers.c timers.h list.c collage.c debug.h \ 
    1818events.c events.h support.c support.h transupp.c transupp.h \ 
    19 thumbnail.c thumbnail.h ipc.c ipc.h md5.c md5.h feh_png.c feh_png.h 
     19thumbnail.c thumbnail.h ipc.c ipc.h md5.c md5.h feh_png.c feh_png.h \ 
     20fmmode.c fmmode.h 
    2021 
    2122feh_LDADD         = -lX11 -lz -lpng @IMLIB_LIBS@ @GIBLIB_LIBS@ 
    2223 
  • feh-1.3.3/src/Makefile.in

    old new  
    8383LIBOBJS = @LIBOBJS@ 
    8484 
    8585bin_PROGRAMS = feh 
    86 feh_SOURCES = main.c getopt.c getopt1.c getopt.h feh.h options.c options.h winwidget.c winwidget.h menu.c menu.h structs.h filelist.c filelist.h multiwindow.c imlib.c index.c slideshow.c utils.c utils.h keyevents.c timers.c timers.h list.c collage.c debug.h events.c events.h support.c support.h transupp.c transupp.h thumbnail.c thumbnail.h ipc.c ipc.h md5.c md5.h feh_png.c feh_png.h 
     86feh_SOURCES = main.c getopt.c getopt1.c getopt.h feh.h options.c options.h winwidget.c winwidget.h menu.c menu.h structs.h filelist.c filelist.h multiwindow.c imlib.c index.c slideshow.c utils.c utils.h keyevents.c timers.c timers.h list.c collage.c debug.h events.c events.h support.c support.h transupp.c transupp.h thumbnail.c thumbnail.h ipc.c ipc.h md5.c md5.h feh_png.c feh_png.h fmmode.c fmmode.h 
    8787 
    8888 
    8989feh_LDADD = -lX11 -lz -lpng @IMLIB_LIBS@ @GIBLIB_LIBS@ 
     
    107107feh_OBJECTS =  main.o getopt.o getopt1.o options.o winwidget.o menu.o \ 
    108108filelist.o multiwindow.o imlib.o index.o slideshow.o utils.o \ 
    109109keyevents.o timers.o list.o collage.o events.o support.o transupp.o \ 
    110 thumbnail.o ipc.o md5.o feh_png.o 
     110thumbnail.o ipc.o md5.o feh_png.o fmmode.o 
    111111feh_DEPENDENCIES =  
    112112feh_LDFLAGS =  
    113113CFLAGS = @CFLAGS@