add back notification merging

this was removed without warning or explanation in r82118:

    e: Change notification module to use internal notification API
    Patch by: José Roberto de Souza  <zehortigoza@profusion.mobi>

currently broken by T1954 for lines longer than 36 characters
This commit is contained in:
Mike Blumenkrantz 2014-12-28 17:25:59 -05:00
parent 0083aa552a
commit 5f1a0b4dcd
1 changed files with 56 additions and 0 deletions

View File

@ -28,6 +28,57 @@ _notification_timer_cb(Popup_Data *popup)
return EINA_FALSE;
}
static Popup_Data *
_notification_popup_merge(E_Notification_Notify *n)
{
Eina_List *l;
Popup_Data *popup;
char *body_final;
size_t len;
if (!n->app_name) return NULL;
EINA_LIST_FOREACH(notification_cfg->popups, l, popup)
{
if (!popup->notif) continue;
if (popup->notif->app_name == n->app_name) break;
}
if (!popup)
{
/* printf("- no poup to merge\n"); */
return NULL;
}
if (n->summary && (n->summary != popup->notif->summary))
{
/* printf("- summary doesn match, %s, %s\n", str1, str2); */
return NULL;
}
/* TODO p->n is not fallback alert..*/
/* TODO both allow merging */
len = strlen(popup->notif->body);
len += strlen(n->body);
len += 5; /* \xE2\x80\xA9 or <PS/> */
if (len < 8192) body_final = alloca(len + 1);
else body_final = malloc(len + 1);
/* Hack to allow e to include markup */
snprintf(body_final, len + 1, "%s<ps/>%s", popup->notif->body, n->body);
/* printf("set body %s\n", body_final); */
eina_stringshare_replace(&n->body, body_final);
e_object_del(E_OBJECT(popup->notif));
popup->notif = n;
if (len >= 8192) free(body_final);
return popup;
}
void
notification_popup_notify(E_Notification_Notify *n,
unsigned int id)
@ -60,6 +111,11 @@ notification_popup_notify(E_Notification_Notify *n,
popup->id = id;
_notification_popup_refresh(popup);
}
else if (!n->replaces_id)
{
if ((popup = _notification_popup_merge(n)))
_notification_popup_refresh(popup);
}
if (!popup)
{