diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2010-03-26 17:26:55 +0100 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2010-03-26 17:26:55 +0100 |
commit | 69d69f145763f01724efdce119f6312272022740 (patch) | |
tree | 8a47478e20bd194fc0530ff46eec0f7ea558dc35 | |
parent | 8b999887036b7b75e01352e86d960c16a7d39bc8 (diff) |
Patch by muennich: Correctly set [Paused] window title
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | src/slideshow.c | 11 | ||||
-rw-r--r-- | src/winwidget.c | 20 |
3 files changed, 23 insertions, 11 deletions
@@ -1,6 +1,7 @@ * git HEAD * Replace autoconf by config.mk - * patch: Use z key to randomly jump in the filelist + * patch by decklin: Use z key to randomly jump in the filelist + * patch by muennich: Correctly set [Paused] window title in slideshow mode * Fix problems with unexpectedly empty filelists Tue Mar 16 07:56:36 CET 2010 Daniel Friesel <derf@chaosdorf.de> diff --git a/src/slideshow.c b/src/slideshow.c index 314374c..0d509e4 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -280,20 +280,13 @@ void slideshow_change_image(winwidget winwid, int change) void slideshow_pause_toggle(winwidget w) { - char *title, *new_title; - int len; - if (!opt.paused) { opt.paused = 1; - - len = strlen(w->name) + sizeof(" [Paused]") + 1; - new_title = emalloc(len); - snprintf(new_title, len, "%s [Paused]", w->name); - title = estrdup(w->name); - winwidget_rename(w, new_title); } else { opt.paused = 0; } + + winwidget_rename(w, NULL); } char *slideshow_create_name(feh_file * file) diff --git a/src/winwidget.c b/src/winwidget.c index 6280f46..5ee7ace 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -868,10 +868,28 @@ winwidget winwidget_get_from_window(Window win) void winwidget_rename(winwidget winwid, char *newname) { + /* newname == NULL -> update current title */ + char *p_str; + D_ENTER(4); + if (newname == NULL) + newname = estrdup(winwid->name ? winwid->name : ""); if (winwid->name) free(winwid->name); - winwid->name = estrdup(newname); + + winwid->name = emalloc(strlen(newname) + 10); + strcpy(winwid->name, newname); + + if (strlen(winwid->name) > 9) + p_str = winwid->name + strlen(winwid->name) - 9; + else + p_str = winwid->name; + + if (opt.paused && strcmp(p_str, " [Paused]") != 0) + strcat(winwid->name, " [Paused]"); + else if (!opt.paused && strcmp(p_str, " [Paused]") == 0) + *p_str = '\0'; + winwidget_update_title(winwid); D_RETURN_(4); } |