Krolyxon
Commit facd7e3

Branches

Refs →

nsxivfacd7e3

New option: -a, do not filter out unsupported files

Author
Bert
Date
2011-04-06 19:30 +0200
Parent
426edfb
Commit
facd7e3b42cbf638c1a58caebd3bbaedf74e0b1a

+35 −15

7 files changed

  1. M Makefile +1 −1
  2. M README.md +2 −0
  3. A invalid.png
  4. M main.c +19 −11
  5. M options.c +6 −2
  6. M options.h +1 −0
  7. M sxiv.1 +6 −1
M Makefile View
@@ -1,6 +1,6 @@
11 all: sxiv
22
3−VERSION=git-20110405
3+VERSION=git-20110406
44
55 CC?=gcc
66 PREFIX?=/usr/local
M README.md View
@@ -34,6 +34,8 @@ small previews is displayed, making it easy to choose an image to open.
3434
3535 sxiv supports the following command-line options:
3636
37+ -a Display all given files, do not filter out unsupported files
38+ (shorter startup time for long file list or slow file types)
3739 -d Scale all images to 100%, but fit large images into window
3840 -F Use size-hints to make the window fixed/floating
3941 -f Start in fullscreen mode
A invalid.png View

[Binary file]

M main.c View
@@ -77,19 +77,22 @@ void cleanup() {
7777 }
7878
7979 int load_image(int new) {
80+ int ret = 0;
8081 struct stat fstats;
8182
8283 if (new >= 0 && new < filecnt) {
84+ win_set_cursor(&win, CURSOR_WATCH);
8385 img_close(&img, 0);
8486 fileidx = new;
8587 if (!stat(filenames[fileidx], &fstats))
8688 filesize = fstats.st_size;
8789 else
8890 filesize = 0;
89− return img_load(&img, filenames[fileidx]);
90− } else {
91− return 0;
91+ if (!(ret = img_load(&img, filenames[fileidx])))
92+ win_set_cursor(&win, CURSOR_NONE);
9293 }
94+
95+ return ret;
9396 }
9497
9598 int main(int argc, char **argv) {
@@ -199,7 +202,7 @@ int check_append(const char *filename) {
199202 if (access(filename, R_OK)) {
200203 warn("could not open file: %s", filename);
201204 return 0;
202− } else if (img_check(filename)) {
205+ } else if (options->all || img_check(filename)) {
203206 if (fileidx == filecnt) {
204207 filecnt *= 2;
205208 filenames = (const char**) s_realloc(filenames,
@@ -353,10 +356,15 @@ unsigned char drag;
353356 int mox, moy;
354357
355358 void redraw() {
356− if (mode == MODE_NORMAL)
359+ if (mode == MODE_NORMAL) {
357360 img_render(&img, &win);
358− else
361+ if (timo_cursor)
362+ win_set_cursor(&win, CURSOR_ARROW);
363+ else if (!drag)
364+ win_set_cursor(&win, CURSOR_NONE);
365+ } else {
359366 tns_render(&tns, &win);
367+ }
360368 update_title();
361369 timo_redraw = 0;
362370 }
@@ -390,7 +398,8 @@ void on_keypress(XKeyEvent *kev) {
390398 }
391399 redraw();
392400 }
393− win_set_cursor(&win, mode == MODE_NORMAL ? CURSOR_NONE : CURSOR_ARROW);
401+ if (mode == MODE_THUMBS)
402+ win_set_cursor(&win, CURSOR_ARROW);
394403 return;
395404 }
396405 }
@@ -515,7 +524,6 @@ void on_keypress(XKeyEvent *kev) {
515524 case XK_Return:
516525 load_image(tns.sel);
517526 mode = MODE_NORMAL;
518− win_set_cursor(&win, CURSOR_NONE);
519527 changed = 1;
520528 break;
521529
@@ -580,6 +588,9 @@ void on_buttonpress(XButtonEvent *bev) {
580588 changed = 0;
581589
582590 if (mode == MODE_NORMAL) {
591+ win_set_cursor(&win, CURSOR_ARROW);
592+ timo_cursor = TO_CURSOR_HIDE;
593+
583594 switch (bev->button) {
584595 case Button1:
585596 if (fileidx + 1 < filecnt)
@@ -672,9 +683,6 @@ void run() {
672683 timo_cursor = timo_redraw = 0;
673684 drag = 0;
674685
675− if (mode == MODE_NORMAL)
676− timo_cursor = TO_CURSOR_HIDE;
677−
678686 while (1) {
679687 if (mode == MODE_THUMBS && tns.cnt < filecnt) {
680688 win_set_cursor(&win, CURSOR_WATCH);
M options.c View
@@ -31,7 +31,7 @@ options_t _options;
3131 const options_t *options = (const options_t*) &_options;
3232
3333 void print_usage() {
34− printf("usage: sxiv [-dFfhpqrstvZ] [-g GEOMETRY] [-z ZOOM] FILES...\n");
34+ printf("usage: sxiv [-adFfhpqrstvZ] [-g GEOMETRY] [-z ZOOM] FILES...\n");
3535 }
3636
3737 void print_version() {
@@ -51,14 +51,18 @@ void parse_options(int argc, char **argv) {
5151 _options.fullscreen = 0;
5252 _options.geometry = NULL;
5353
54+ _options.all = 0;
5455 _options.quiet = 0;
5556 _options.recursive = 0;
5657
57− while ((opt = getopt(argc, argv, "dFfg:hpqrstvZz:")) != -1) {
58+ while ((opt = getopt(argc, argv, "adFfg:hpqrstvZz:")) != -1) {
5859 switch (opt) {
5960 case '?':
6061 print_usage();
6162 exit(1);
63+ case 'a':
64+ _options.all = 1;
65+ break;
6266 case 'd':
6367 _options.scalemode = SCALE_DOWN;
6468 break;
M options.h View
@@ -35,6 +35,7 @@ typedef struct {
3535 unsigned char fullscreen;
3636 char *geometry;
3737
38+ unsigned char all;
3839 unsigned char quiet;
3940 unsigned char recursive;
4041 } options_t;
M sxiv.1 View
@@ -3,7 +3,7 @@
33 sxiv \- Simple (or small or suckless) X Image Viewer
44 .SH SYNOPSIS
55 .B sxiv
6−.RB [ \-dFfhpqrstvZ ]
6+.RB [ \-adFfhpqrstvZ ]
77 .RB [ \-g
88 .IR GEOMETRY ]
99 .RB [ \-z
@@ -28,6 +28,11 @@ Please note, that the fullscreen mode requires an EWMH/NetWM compliant window
2828 manager.
2929 .SH OPTIONS
3030 .TP
31+.B \-a
32+Display all given files, do not filter out unsupported files. This might result
33+in a much shorter startup time, when the file list is very long or contains
34+large files of slow loadable types, e.g. gif and progressive jpg.
35+.TP
3136 .B \-d
3237 Scale all images to 100%, but fit large images into window.
3338 .TP