Ticket #5: feh-fmmode-new.patch
| File feh-fmmode-new.patch, 8.8 kB (added by giblet, 3 years ago) |
|---|
-
feh-1.3.3/src/fmmode.c
old new 1 /* fmmode.c 2 3 Copyright (C) 2005 Falko Schmidt. 4 5 Permission is hereby granted, free of charge, to any person obtaining a copy 6 of this software and associated documentation files (the "Software"), to 7 deal in the Software without restriction, including without limitation the 8 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9 sell copies of the Software, and to permit persons to whom the Software is 10 furnished to do so, subject to the following conditions: 11 12 The above copyright notice and this permission notice shall be included in 13 all copies of the Software and its documentation and acknowledgment shall be 14 given in the documentation and software packages that this Software was 15 used. 16 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 CONNECTION 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 33 void 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 3 Copyright (C) 2005 Falko Schmidt. 4 5 Permission is hereby granted, free of charge, to any person obtaining a copy 6 of this software and associated documentation files (the "Software"), to 7 deal in the Software without restriction, including without limitation the 8 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9 sell copies of the Software, and to permit persons to whom the Software is 10 furnished to do so, subject to the following conditions: 11 12 The above copyright notice and this permission notice shall be included in 13 all copies of the Software and its documentation and acknowledgment shall be 14 given in the documentation and software packages that this Software was 15 used. 16 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 24 */ 25 26 #ifndef FMMODE_H 27 #define FMMODE_H 28 29 void fmmode(void); 30 31 #endif -
feh-1.3.3/src/main.c
old new 30 30 #include "options.h" 31 31 #include "events.h" 32 32 #include "support.h" 33 #include "fmmode.h" 33 34 34 35 char **cmdargv = NULL; 35 36 int cmdargc = 0; … … 67 68 feh_wm_set_bg_file(opt.output_file, opt.bgmode); 68 69 exit(0); 69 70 } 70 /*else if (opt.fmmode)71 else if (opt.fmmode) 71 72 { 72 73 fmmode(); 73 74 opt.slideshow = 1; 74 init_slideshow_mode(); 75 init_slideshow_mode(); 76 opt.fmmode = 0; 75 77 } 76 */78 77 79 else 78 80 { 79 81 /* Slideshow mode is the default. Because it's spiffy */ … … 186 188 } 187 189 } 188 190 } 191 else if (opt.fmmode) 192 { 193 fmmode(); 194 opt.slideshow = 1; 195 init_slideshow_mode(); 196 } 189 197 else 190 198 { 191 199 /* Don't block if there are events in the queue. That's a bit rude ;-) */ -
feh-1.3.3/src/Makefile.am
old new 16 16 filelist.c filelist.h multiwindow.c imlib.c index.c slideshow.c \ 17 17 utils.c utils.h keyevents.c timers.c timers.h list.c collage.c debug.h \ 18 18 events.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 19 thumbnail.c thumbnail.h ipc.c ipc.h md5.c md5.h feh_png.c feh_png.h \ 20 fmmode.c fmmode.h 20 21 21 22 feh_LDADD = -lX11 -lz -lpng @IMLIB_LIBS@ @GIBLIB_LIBS@ 22 23 -
feh-1.3.3/src/Makefile.in
old new 83 83 LIBOBJS = @LIBOBJS@ 84 84 85 85 bin_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 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 fmmode.c fmmode.h 87 87 88 88 89 89 feh_LDADD = -lX11 -lz -lpng @IMLIB_LIBS@ @GIBLIB_LIBS@ … … 107 107 feh_OBJECTS = main.o getopt.o getopt1.o options.o winwidget.o menu.o \ 108 108 filelist.o multiwindow.o imlib.o index.o slideshow.o utils.o \ 109 109 keyevents.o timers.o list.o collage.o events.o support.o transupp.o \ 110 thumbnail.o ipc.o md5.o feh_png.o 110 thumbnail.o ipc.o md5.o feh_png.o fmmode.o 111 111 feh_DEPENDENCIES = 112 112 feh_LDFLAGS = 113 113 CFLAGS = @CFLAGS@
