Krolyxon
Commit e09a6b5

Branches

Refs →

nsxive09a6b5

Appropriate title for thumbnail mode

Author
Bert
Date
2011-02-17 14:45 +0100
Parent
1c072cc
Commit
e09a6b5e3f8c3869617fb3e749c4e455ba50989a

+20 −17

3 files changed

  1. M main.c +17 −16
  2. M thumbs.c +1 −0
  3. M thumbs.h +2 −1
M main.c View
@@ -158,15 +158,21 @@ void update_title() {
158158 float size;
159159 const char *unit;
160160
161− if (img.valid) {
162− size = filesize;
163− size_readable(&size, &unit);
164− n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] <%d%%> (%.2f%s) %s",
165− fileidx + 1, filecnt, (int) (img.zoom * 100.0), size, unit,
166− filenames[fileidx]);
161+ if (mode == MODE_THUMBS) {
162+ n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] %s",
163+ tns.cnt ? tns.sel + 1 : 0, tns.cnt,
164+ tns.cnt ? tns.thumbs[tns.sel].filename : "");
167165 } else {
168− n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] broken: %s",
169− fileidx + 1, filecnt, filenames[fileidx]);
166+ if (img.valid) {
167+ size = filesize;
168+ size_readable(&size, &unit);
169+ n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] <%d%%> (%.2f%s) %s",
170+ fileidx + 1, filecnt, (int) (img.zoom * 100.0), size, unit,
171+ filenames[fileidx]);
172+ } else {
173+ n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] broken: %s",
174+ fileidx + 1, filecnt, filenames[fileidx]);
175+ }
170176 }
171177
172178 if (n >= TITLE_LEN) {
@@ -491,7 +497,7 @@ void run() {
491497 if (tns_loaded == filecnt)
492498 win_set_cursor(&win, CURSOR_ARROW);
493499 if (!XPending(win.env.dpy)) {
494− tns_render(&tns, &win);
500+ redraw();
495501 continue;
496502 } else {
497503 timeout = 1;
@@ -503,13 +509,8 @@ void run() {
503509 FD_ZERO(&fds);
504510 FD_SET(xfd, &fds);
505511
506− if (!XPending(win.env.dpy) && !select(xfd + 1, &fds, 0, 0, &t)) {
507− timeout = 0;
508− if (mode == MODE_NORMAL)
509− img_render(&img, &win);
510− else
511− tns_render(&tns, &win);
512− }
512+ if (!XPending(win.env.dpy) && !select(xfd + 1, &fds, 0, 0, &t))
513+ redraw();
513514 }
514515
515516 if (!XNextEvent(win.env.dpy, &ev)) {
M thumbs.c View
@@ -69,6 +69,7 @@ void tns_load(tns_t *tns, win_t *win, const char *filename) {
6969 z = MIN(zw, zh);
7070
7171 t = &tns->thumbs[tns->cnt++];
72+ t->filename = filename;
7273 t->w = z * w;
7374 t->h = z * h;
7475
M thumbs.h View
@@ -22,11 +22,12 @@
2222 #include "window.h"
2323
2424 typedef struct thumb_s {
25+ Pixmap pm;
26+ const char *filename;
2527 int x;
2628 int y;
2729 int w;
2830 int h;
29− Pixmap pm;
3031 } thumb_t;
3132
3233 typedef struct tns_s {