aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-04-06 19:30:06 +0200
committerBert <ber.t@gmx.com>2011-04-06 19:30:06 +0200
commitfacd7e3b42cbf638c1a58caebd3bbaedf74e0b1a (patch)
tree947bcd7c6e1abbbf482e9bdae404f6280d798840
parent426edfb3498469b171aae6a582491c2c7e30fd51 (diff)
New option: -a, do not filter out unsupported files
-rw-r--r--Makefile2
-rw-r--r--README.md2
-rw-r--r--invalid.pngbin0 -> 351 bytes
-rw-r--r--main.c30
-rw-r--r--options.c8
-rw-r--r--options.h1
-rw-r--r--sxiv.17
7 files changed, 35 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index 4eee98c..8829469 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
all: sxiv
-VERSION=git-20110405
+VERSION=git-20110406
CC?=gcc
PREFIX?=/usr/local
diff --git a/README.md b/README.md
index 0b54eaf..064fb70 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,8 @@ small previews is displayed, making it easy to choose an image to open.
sxiv supports the following command-line options:
+ -a Display all given files, do not filter out unsupported files
+ (shorter startup time for long file list or slow file types)
-d Scale all images to 100%, but fit large images into window
-F Use size-hints to make the window fixed/floating
-f Start in fullscreen mode
diff --git a/invalid.png b/invalid.png
new file mode 100644
index 0000000..3846e4e
--- /dev/null
+++ b/invalid.png
Binary files differ
diff --git a/main.c b/main.c
index a20e62c..1efdfed 100644
--- a/main.c
+++ b/main.c
@@ -77,19 +77,22 @@ void cleanup() {
}
int load_image(int new) {
+ int ret = 0;
struct stat fstats;
if (new >= 0 && new < filecnt) {
+ win_set_cursor(&win, CURSOR_WATCH);
img_close(&img, 0);
fileidx = new;
if (!stat(filenames[fileidx], &fstats))
filesize = fstats.st_size;
else
filesize = 0;
- return img_load(&img, filenames[fileidx]);
- } else {
- return 0;
+ if (!(ret = img_load(&img, filenames[fileidx])))
+ win_set_cursor(&win, CURSOR_NONE);
}
+
+ return ret;
}
int main(int argc, char **argv) {
@@ -199,7 +202,7 @@ int check_append(const char *filename) {
if (access(filename, R_OK)) {
warn("could not open file: %s", filename);
return 0;
- } else if (img_check(filename)) {
+ } else if (options->all || img_check(filename)) {
if (fileidx == filecnt) {
filecnt *= 2;
filenames = (const char**) s_realloc(filenames,
@@ -353,10 +356,15 @@ unsigned char drag;
int mox, moy;
void redraw() {
- if (mode == MODE_NORMAL)
+ if (mode == MODE_NORMAL) {
img_render(&img, &win);
- else
+ if (timo_cursor)
+ win_set_cursor(&win, CURSOR_ARROW);
+ else if (!drag)
+ win_set_cursor(&win, CURSOR_NONE);
+ } else {
tns_render(&tns, &win);
+ }
update_title();
timo_redraw = 0;
}
@@ -390,7 +398,8 @@ void on_keypress(XKeyEvent *kev) {
}
redraw();
}
- win_set_cursor(&win, mode == MODE_NORMAL ? CURSOR_NONE : CURSOR_ARROW);
+ if (mode == MODE_THUMBS)
+ win_set_cursor(&win, CURSOR_ARROW);
return;
}
}
@@ -515,7 +524,6 @@ void on_keypress(XKeyEvent *kev) {
case XK_Return:
load_image(tns.sel);
mode = MODE_NORMAL;
- win_set_cursor(&win, CURSOR_NONE);
changed = 1;
break;
@@ -580,6 +588,9 @@ void on_buttonpress(XButtonEvent *bev) {
changed = 0;
if (mode == MODE_NORMAL) {
+ win_set_cursor(&win, CURSOR_ARROW);
+ timo_cursor = TO_CURSOR_HIDE;
+
switch (bev->button) {
case Button1:
if (fileidx + 1 < filecnt)
@@ -672,9 +683,6 @@ void run() {
timo_cursor = timo_redraw = 0;
drag = 0;
- if (mode == MODE_NORMAL)
- timo_cursor = TO_CURSOR_HIDE;
-
while (1) {
if (mode == MODE_THUMBS && tns.cnt < filecnt) {
win_set_cursor(&win, CURSOR_WATCH);
diff --git a/options.c b/options.c
index a769952..f5066f4 100644
--- a/options.c
+++ b/options.c
@@ -31,7 +31,7 @@ options_t _options;
const options_t *options = (const options_t*) &_options;
void print_usage() {
- printf("usage: sxiv [-dFfhpqrstvZ] [-g GEOMETRY] [-z ZOOM] FILES...\n");
+ printf("usage: sxiv [-adFfhpqrstvZ] [-g GEOMETRY] [-z ZOOM] FILES...\n");
}
void print_version() {
@@ -51,14 +51,18 @@ void parse_options(int argc, char **argv) {
_options.fullscreen = 0;
_options.geometry = NULL;
+ _options.all = 0;
_options.quiet = 0;
_options.recursive = 0;
- while ((opt = getopt(argc, argv, "dFfg:hpqrstvZz:")) != -1) {
+ while ((opt = getopt(argc, argv, "adFfg:hpqrstvZz:")) != -1) {
switch (opt) {
case '?':
print_usage();
exit(1);
+ case 'a':
+ _options.all = 1;
+ break;
case 'd':
_options.scalemode = SCALE_DOWN;
break;
diff --git a/options.h b/options.h
index 4ce9637..c32b50a 100644
--- a/options.h
+++ b/options.h
@@ -35,6 +35,7 @@ typedef struct {
unsigned char fullscreen;
char *geometry;
+ unsigned char all;
unsigned char quiet;
unsigned char recursive;
} options_t;
diff --git a/sxiv.1 b/sxiv.1
index 9ba376e..068b388 100644
--- a/sxiv.1
+++ b/sxiv.1
@@ -3,7 +3,7 @@
sxiv \- Simple (or small or suckless) X Image Viewer
.SH SYNOPSIS
.B sxiv
-.RB [ \-dFfhpqrstvZ ]
+.RB [ \-adFfhpqrstvZ ]
.RB [ \-g
.IR GEOMETRY ]
.RB [ \-z
@@ -28,6 +28,11 @@ Please note, that the fullscreen mode requires an EWMH/NetWM compliant window
manager.
.SH OPTIONS
.TP
+.B \-a
+Display all given files, do not filter out unsupported files. This might result
+in a much shorter startup time, when the file list is very long or contains
+large files of slow loadable types, e.g. gif and progressive jpg.
+.TP
.B \-d
Scale all images to 100%, but fit large images into window.
.TP