Browse Source

Appropriate title for thumbnail mode

master
Bert 14 years ago
parent
commit
e09a6b5e3f
3 changed files with 20 additions and 17 deletions
  1. +17
    -16
      main.c
  2. +1
    -0
      thumbs.c
  3. +2
    -1
      thumbs.h

+ 17
- 16
main.c View File

@@ -158,15 +158,21 @@ void update_title() {
float size; float size;
const char *unit; const char *unit;


if (img.valid) { if (mode == MODE_THUMBS) {
size = filesize; n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] %s",
size_readable(&size, &unit); tns.cnt ? tns.sel + 1 : 0, tns.cnt,
n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] <%d%%> (%.2f%s) %s", tns.cnt ? tns.thumbs[tns.sel].filename : "");
fileidx + 1, filecnt, (int) (img.zoom * 100.0), size, unit,
filenames[fileidx]);
} else { } else {
n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] broken: %s", if (img.valid) {
fileidx + 1, filecnt, filenames[fileidx]); size = filesize;
size_readable(&size, &unit);
n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] <%d%%> (%.2f%s) %s",
fileidx + 1, filecnt, (int) (img.zoom * 100.0), size, unit,
filenames[fileidx]);
} else {
n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] broken: %s",
fileidx + 1, filecnt, filenames[fileidx]);
}
} }


if (n >= TITLE_LEN) { if (n >= TITLE_LEN) {
@@ -491,7 +497,7 @@ void run() {
if (tns_loaded == filecnt) if (tns_loaded == filecnt)
win_set_cursor(&win, CURSOR_ARROW); win_set_cursor(&win, CURSOR_ARROW);
if (!XPending(win.env.dpy)) { if (!XPending(win.env.dpy)) {
tns_render(&tns, &win); redraw();
continue; continue;
} else { } else {
timeout = 1; timeout = 1;
@@ -503,13 +509,8 @@ void run() {
FD_ZERO(&fds); FD_ZERO(&fds);
FD_SET(xfd, &fds); FD_SET(xfd, &fds);


if (!XPending(win.env.dpy) && !select(xfd + 1, &fds, 0, 0, &t)) { if (!XPending(win.env.dpy) && !select(xfd + 1, &fds, 0, 0, &t))
timeout = 0; redraw();
if (mode == MODE_NORMAL)
img_render(&img, &win);
else
tns_render(&tns, &win);
}
} }


if (!XNextEvent(win.env.dpy, &ev)) { if (!XNextEvent(win.env.dpy, &ev)) {


+ 1
- 0
thumbs.c View File

@@ -69,6 +69,7 @@ void tns_load(tns_t *tns, win_t *win, const char *filename) {
z = MIN(zw, zh); z = MIN(zw, zh);


t = &tns->thumbs[tns->cnt++]; t = &tns->thumbs[tns->cnt++];
t->filename = filename;
t->w = z * w; t->w = z * w;
t->h = z * h; t->h = z * h;




+ 2
- 1
thumbs.h View File

@@ -22,11 +22,12 @@
#include "window.h" #include "window.h"


typedef struct thumb_s { typedef struct thumb_s {
Pixmap pm;
const char *filename;
int x; int x;
int y; int y;
int w; int w;
int h; int h;
Pixmap pm;
} thumb_t; } thumb_t;


typedef struct tns_s { typedef struct tns_s {


||||||
x
 
000:0
Loading…
Cancel
Save