Use '-1' for undefined progress

This commit is contained in:
Benedikt Heine 2017-10-29 17:58:21 +01:00
parent e111f5393e
commit 11af7402fa
4 changed files with 9 additions and 9 deletions

View File

@ -262,7 +262,7 @@ static void on_notify(GDBusConnection *connection,
n->raw_icon = raw_icon; n->raw_icon = raw_icon;
n->timeout = timeout < 0 ? -1 : timeout * 1000; n->timeout = timeout < 0 ? -1 : timeout * 1000;
n->markup = settings.markup; n->markup = settings.markup;
n->progress = (progress < 0 || progress > 100) ? 0 : progress + 1; n->progress = (progress < 0 || progress > 100) ? -1 : progress;
n->urgency = urgency; n->urgency = urgency;
n->category = category; n->category = category;
n->dbus_client = g_strdup(sender); n->dbus_client = g_strdup(sender);

View File

@ -154,7 +154,7 @@ int dunst_main(int argc, char *argv[])
n->appname = g_strdup("dunst"); n->appname = g_strdup("dunst");
n->summary = g_strdup("startup"); n->summary = g_strdup("startup");
n->body = g_strdup("dunst is up and running"); n->body = g_strdup("dunst is up and running");
n->progress = 0; n->progress = -1;
n->timeout = 10 * G_USEC_PER_SEC; n->timeout = 10 * G_USEC_PER_SEC;
n->markup = MARKUP_NO; n->markup = MARKUP_NO;
n->urgency = LOW; n->urgency = LOW;

View File

@ -359,23 +359,23 @@ void notification_init(notification *n)
MARKUP_NO); MARKUP_NO);
break; break;
case 'p': case 'p':
if (n->progress) if (n->progress != -1)
sprintf(pg, "[%3d%%]", n->progress - 1); sprintf(pg, "[%3d%%]", n->progress);
notification_replace_single_field( notification_replace_single_field(
&n->msg, &n->msg,
&substr, &substr,
n->progress ? pg : "", n->progress != -1 ? pg : "",
MARKUP_NO); MARKUP_NO);
break; break;
case 'n': case 'n':
if (n->progress) if (n->progress != -1)
sprintf(pg, "%d", n->progress - 1); sprintf(pg, "%d", n->progress);
notification_replace_single_field( notification_replace_single_field(
&n->msg, &n->msg,
&substr, &substr,
n->progress ? pg : "", n->progress != -1 ? pg : "",
MARKUP_NO); MARKUP_NO);
break; break;
case '%': case '%':

View File

@ -54,7 +54,7 @@ typedef struct _notification {
bool first_render; bool first_render;
bool transient; bool transient;
int progress; /* percentage + 1, 0 to hide */ int progress; /* percentage (-1: undefined) */
int history_ignore; int history_ignore;
const char *script; const char *script;
char *urls; char *urls;