summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/slideshow.c11
-rw-r--r--src/winwidget.c20
2 files changed, 21 insertions, 10 deletions
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);
}