static void notify(const char *title, const char *msg, const char *icon) { if (msg == NULL) return; /* Don't spam the same message */ if (notify_last_msg) { if (notify_last_msg && strcmp(msg, notify_last_msg) == 0) return; g_free(notify_last_msg); } notify_last_msg = g_strdup(msg); if (nn != NULL) notify_notification_close(nn, NULL); #if NOTIFY_CHECK_VERSION(0,7,0) nn = notify_notification_new(title, msg, icon); notify_notification_set_hint(nn, "transient", g_variant_new_boolean(TRUE)); #else if (gtk_status_icon_get_visible(status_icon)) nn = notify_notification_new_with_status_icon(title, msg, icon, status_icon); else nn = notify_notification_new(title, msg, icon, NULL); #endif notify_notification_set_timeout(nn, 5000); g_signal_connect(nn, "closed", G_CALLBACK(notify_closed), NULL); notify_notification_show(nn, NULL); }
void lassi_tray_show_notification(LassiTrayInfo *i, char *summary, char *body, LassiTrayNotificationIcon icon) { static const char * const icon_name[] = { [LASSI_TRAY_NOTIFICATION_WELCOME] = "user-desktop", [LASSI_TRAY_NOTIFICATION_LEFT] = "go-previous", [LASSI_TRAY_NOTIFICATION_RIGHT] = "go-next" }; NotifyNotification *n; n = notify_notification_new_with_status_icon(summary, body, icon_name[icon], i->status_icon); notify_notification_set_timeout(n, 10000); notify_notification_set_urgency(n, NOTIFY_URGENCY_LOW); notify_notification_set_category(n, "network"); notify_notification_show(n, NULL); }
static void status_icon_update_notification (EmpathyStatusIcon *icon) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); GdkPixbuf *pixbuf = NULL; if (!empathy_notification_is_enabled ()) { /* always close the notification if this happens */ notification_close_helper (priv); return; } if (priv->event) { pixbuf = empathy_misc_get_pixbuf_for_notification (priv->event->contact, priv->event->icon_name); if (priv->notification) { notify_notification_update (priv->notification, priv->event->header, priv->event->message, NULL); } else { priv->notification = notify_notification_new_with_status_icon (priv->event->header, priv->event->message, NULL, priv->icon); notify_notification_set_timeout (priv->notification, NOTIFY_EXPIRES_DEFAULT); g_signal_connect (priv->notification, "closed", G_CALLBACK (status_icon_notification_closed_cb), icon); } /* if icon doesn't exist libnotify will crash */ if (pixbuf != NULL) notify_notification_set_icon_from_pixbuf (priv->notification, pixbuf); notify_notification_show (priv->notification, NULL); g_object_unref (pixbuf); } else { notification_close_helper (priv); } }
static void status_icon_update_notification (EmpathyStatusIcon *icon) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); GdkPixbuf *pixbuf = NULL; if (!empathy_notify_manager_notification_is_enabled (priv->notify_mgr)) { /* always close the notification if this happens */ notification_close_helper (priv); return; } if (priv->event) { gchar *message_esc = NULL; gboolean has_x_canonical_append; NotifyNotification *notification = priv->notification; if (priv->event->message != NULL) message_esc = g_markup_escape_text (priv->event->message, -1); has_x_canonical_append = empathy_notify_manager_has_capability (priv->notify_mgr, EMPATHY_NOTIFY_MANAGER_CAP_X_CANONICAL_APPEND); if (notification != NULL && ! has_x_canonical_append) { /* if the notification server supports x-canonical-append, it is better to not use notify_notification_update to avoid overwriting the current notification message */ notify_notification_update (notification, priv->event->header, message_esc, NULL); } else { /* if the notification server supports x-canonical-append, the hint will be added, so that the message from the just created notification will be automatically appended to an existing notification with the same title. In this way the previous message will not be lost: the new message will appear below it, in the same notification */ notification = notify_notification_new_with_status_icon (priv->event->header, message_esc, NULL, priv->icon); if (priv->notification == NULL) { priv->notification = notification; } notify_notification_set_timeout (notification, NOTIFY_EXPIRES_DEFAULT); if (has_x_canonical_append) { notify_notification_set_hint_string (notification, EMPATHY_NOTIFY_MANAGER_CAP_X_CANONICAL_APPEND, ""); } if (empathy_notify_manager_has_capability (priv->notify_mgr, EMPATHY_NOTIFY_MANAGER_CAP_ACTIONS) && priv->event->type != EMPATHY_EVENT_TYPE_PRESENCE) { notify_notification_add_action (notification, "respond", _("Respond"), (NotifyActionCallback) notification_action_cb, icon, NULL); } g_signal_connect (notification, "closed", G_CALLBACK (status_icon_notification_closed_cb), icon); } pixbuf = empathy_notify_manager_get_pixbuf_for_notification ( priv->notify_mgr, priv->event->contact, priv->event->icon_name); if (pixbuf != NULL) { notify_notification_set_icon_from_pixbuf (notification, pixbuf); g_object_unref (pixbuf); } notify_notification_show (notification, NULL); g_free (message_esc); } else { notification_close_helper (priv); } }