Esempio n. 1
0
        LibNotify.Notification ToNotify(Notification note)
        {
            LibNotify.Notification notify = new LibNotify.Notification();
            notify.Body    = GLib.Markup.EscapeText(note.Body);
            notify.Summary = GLib.Markup.EscapeText(note.Title);
            notify.Closed += (sender, e) => OnNotificationClosed(note);
            notify.Timeout = ReadableDurationForMessage(note.Title, note.Body);

            if (SupportsCapability(NotificationCapability.scaling) && !note.Icon.Contains("@"))
            {
                notify.IconName = string.IsNullOrEmpty(note.Icon)
                                        ? DefaultIconName
                                        : note.Icon;
            }
            else
            {
                notify.Icon = string.IsNullOrEmpty(note.Icon)
                                        ? DefaultIcon
                                        : IconProvider.PixbufFromIconName(note.Icon, IconSize);
            }

            if (note is ActionableNotification)
            {
                ActionableNotification anote = note as ActionableNotification;
                notify.AddAction(GLib.Markup.EscapeText(anote.ActionLabel),
                                 anote.ActionLabel, (sender, e) => anote.PerformAction());
            }

            return(notify);
        }
Esempio n. 2
0
 public NotificationHelper()
 {
     DefaultIcon = IconProvider.PixbufFromIconName(DefaultIconName, IconSize);
 }