Merge pull request #426 from bebehei/progress

Use '-1' for undefined progress
This commit is contained in:
Nikos Tsipinakis 2017-11-02 07:29:29 +02:00 committed by GitHub
commit 48fab3f887
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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->timeout = timeout < 0 ? -1 : timeout * 1000;
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->category = category;
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->summary = g_strdup("startup");
n->body = g_strdup("dunst is up and running");
n->progress = 0;
n->progress = -1;
n->timeout = 10 * G_USEC_PER_SEC;
n->markup = MARKUP_NO;
n->urgency = LOW;

View File

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

View File

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