void osd_setup_buttons (NotifyNotification *notification) { notify_notification_clear_actions (notification); if (! aud_get_bool ("notify", "actions")) return; notify_notification_add_action (notification, "default", _("Show"), NOTIFY_ACTION_CALLBACK (show_cb), NULL, NULL); bool_t playing = aud_drct_get_playing (); bool_t paused = aud_drct_get_paused (); if (playing && ! paused) notify_notification_add_action (notification, "media-playback-pause", _("Pause"), NOTIFY_ACTION_CALLBACK (aud_drct_pause), NULL, NULL); else notify_notification_add_action (notification, "media-playback-start", _("Play"), NOTIFY_ACTION_CALLBACK (aud_drct_play), NULL, NULL); if (playing) notify_notification_add_action (notification, "media-skip-forward", _("Next"), NOTIFY_ACTION_CALLBACK (aud_drct_pl_next), NULL, NULL); }
static void process_unread_mails(hybrid_imap *imap, gint unread) { if (imap->unread == unread || unread == 0) { if (unread == 0) { imap->unread = 0; } return; } #ifdef USE_LIBNOTIFY gchar *summary; GdkPixbuf *pixbuf; const gchar *title = _("New Mail."); NotifyNotification *notification = NULL; summary = g_strdup_printf(_("<b>%s</b>\n<span size='xx-large' " "foreground='red'><b>%d</b></span> " "<span size='large'>unread mails.</span>"), imap->email_addr, unread); #ifdef LIBNOTIFY_OLD notification = notify_notification_new(title, summary, NULL, NULL); #else notification = notify_notification_new(title, summary, NULL); #endif notify_notification_set_timeout(notification, 5000); imap->tmp_unread = unread; notify_notification_clear_actions(notification); notify_notification_add_action(notification, "test", _("I Know"), NOTIFY_ACTION_CALLBACK(action_cb), imap, NULL); pixbuf = hybrid_create_proto_icon(imap->account->proto->info->name, 48); if (pixbuf) { notify_notification_set_icon_from_pixbuf(notification, pixbuf); g_object_unref(pixbuf); } notify_notification_show(notification, NULL); g_free(summary); #endif }
void show_notification(const gchar *summary, const gchar *message, const gchar *action, gint timeout, GCallback handler) { NotifyActionCallback callback; #ifndef HAVE_APP_INDICATOR GdkScreen *screen; GdkRectangle area; #endif /* HAVE_APP_INDICATOR */ if (notify_is_initted() == FALSE) return; if (notify) { g_signal_handlers_destroy(notify); notify_notification_close(notify, NULL); } notify = notify_notification_new(summary, message, ACTIVE_ICON_NAME); notify_notification_set_timeout(notify, timeout); #ifndef HAVE_APP_INDICATOR if (gtk_status_icon_get_visible(statusicon) == TRUE) { gtk_status_icon_get_geometry(statusicon, &screen, &area, NULL); notify_notification_set_hint_int32(notify, "x", area.x + area.width / 2); notify_notification_set_hint_int32(notify, "y", area.y + area.height / 2); } #endif /* HAVE_APP_INDICATOR */ notify_notification_set_urgency(notify, NOTIFY_URGENCY_NORMAL); callback = handler ? NOTIFY_ACTION_CALLBACK(handler) : notify_action; notify_notification_add_action(notify, "default", "action", callback, NULL, NULL); if (action != NULL) notify_notification_add_action(notify, "button", action, callback, NULL, NULL); notify_notification_show(notify, NULL); }
void init() { if (!notify_is_initted()) { notify_init(QGSTRING(QCoreApplication::applicationName())); } Q_Q(QchNotification); notification = hildon_notification_new(QGSTRING(title), QGSTRING(text), QGSTRING(iconSource), NULL); notify_notification_add_action(NOTIFY_NOTIFICATION(notification), "default", QGSTRING(QCoreApplication::applicationName()), NOTIFY_ACTION_CALLBACK(onNotificationClicked), q, NULL); g_signal_connect(G_OBJECT(notification), "closed", G_CALLBACK(onNotificationClosed), q); setNotificationCategory(); setNotificationHints(); setNotificationSound(); setNotificationTimeout(); if (showOnInit) { showNotification(); } }
static void show_warning_notification (DrWright *dr, gboolean show) { NotifyNotification *notification; gint minutes, seconds; gchar *summary, *body; GError *error = NULL; if (show == FALSE) { if (dr->notification) { gboolean success = notify_notification_close (dr->notification, &error); if (success) { g_object_unref (dr->notification); dr->notification = NULL; } else { g_warning ("%s", error->message); } g_clear_error (&error); } dr->num_minutes_last_displayed = -1; return; } seconds = dr->type_time - drw_timer_elapsed (dr->timer) - dr->save_last_time; minutes = (seconds / 60) + 1; if (minutes == dr->num_minutes_last_displayed) { return; } dr->num_minutes_last_displayed = minutes; summary = _("Typing Break Reminder"); if (minutes > 1) { body = g_strdup_printf (ngettext ("Approximately %d minute to the next break.", "Approximately %d minutes to the next break.", minutes), minutes); } else { body = g_strdup (_("Less than one minute to the next break.")); } if (dr->notification) { notification = dr->notification; notify_notification_update (notification, summary, body, "typing-monitor"); } else { notification = notify_notification_new (summary, body, "typing-monitor"); notify_notification_set_hint (notification, "resident", g_variant_new_boolean (TRUE)); notify_notification_add_action (notification, "settings", _("Settings…"), NOTIFY_ACTION_CALLBACK (notification_action_cb), dr, NULL); notify_notification_add_action (notification, "take-break", _("Take Break Now"), NOTIFY_ACTION_CALLBACK (notification_action_cb), dr, NULL); dr->notification = notification; } if (!notify_notification_show (notification, &error)) { g_warning ("%s", error->message); } g_clear_error (&error); g_free (body); }
bool wxTaskBarIconEx::SetBalloon(const wxIcon& icon, const wxString title, const wxString message, unsigned int iconballoon) { wxLogTrace(wxT("Function Start/End"), wxT("wxTaskBarIconEx::SetBalloon - Function Begin")); bool retval = false; GError* error = NULL; if (!IsOK()) return false; if (!icon.Ok()) return false; if (!SetIcon(icon, wxEmptyString)) return false; gchar* desired_icon = NULL; switch(iconballoon) { case BALLOONTYPE_INFO: desired_icon = GTK_STOCK_DIALOG_INFO; break; case BALLOONTYPE_WARNING: desired_icon = GTK_STOCK_DIALOG_WARNING; break; case BALLOONTYPE_ERROR: desired_icon = GTK_STOCK_DIALOG_ERROR; break; } if (!g_pNotification) { // Old Style if (my_notify_notification_new_with_status_icon) { g_pNotification = (*my_notify_notification_new_with_status_icon)( title.mb_str(), message.mb_str(), desired_icon, g_pStatusIcon ); } // New Style if (my_notify_notification_new) { g_pNotification = (*my_notify_notification_new)( title.mb_str(), message.mb_str(), gtk_status_icon_get_icon_name(g_pStatusIcon) ); } g_signal_connect( g_pNotification, "closed", G_CALLBACK(status_icon_notification_closed), this ); notify_notification_add_action( g_pNotification, "default", "Do Default Action", NOTIFY_ACTION_CALLBACK(status_icon_notification_actions), this, NULL ); } else { notify_notification_update( g_pNotification, title.mb_str(), message.mb_str(), desired_icon ); } retval = notify_notification_show(g_pNotification, &error); g_clear_error(&error); wxLogTrace(wxT("Function Start/End"), wxT("wxTaskBarIconEx::SetBalloon - Function End")); return retval; }