static int ui_gtk_popup(char *buf) { #ifdef CONFIG_MAEMOUI_ENABLED GtkWidget *w = NULL; gdk_threads_enter(); w = hildon_banner_show_information(NULL /* GTK_WIDGET(window) */, NULL, buf); gtk_widget_show_all(w); gdk_flush(); gdk_threads_leave(); USER_PRINT("We should print: %s\n", buf); #else #ifndef HAVE_LIBNOTIFY GtkDialog *diag = 0; char *str = 0, *tmp = 0; gdk_threads_enter(); ASSERT_TRUE(tmp = ship_pangoify(buf), err); ASSERT_TRUE(str = mallocz(strlen(tmp) + 64), err); sprintf(str, "<big>%s</big>", tmp); ASSERT_TRUE(diag = (GtkDialog*)gtk_message_dialog_new_with_markup(NULL, /* GTK_DIALOG_MODAL */0, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, str), err); gtk_dialog_run(diag); gtk_widget_destroy((GtkWidget*)diag); err: gdk_threads_leave(); freez(str); freez(tmp); #else /* new, libnotify-based notifications */ // thanks zenity; http://svn.gnome.org/viewvc/zenity/trunk/src/notification.c?view=markup NotifyNotification *notif; gdk_threads_enter(); /* this has changed with version 0.7xx */ #ifdef HAVE_LIBNOTIFY_NEW notif = notify_notification_new("p2pship", buf, GTK_STOCK_DIALOG_WARNING); #else notif = notify_notification_new("p2pship", buf, GTK_STOCK_DIALOG_WARNING, //GTK_STOCK_DIALOG_INFO, NULL); #endif notify_notification_show(notif, NULL); g_object_unref(notif); gdk_threads_leave(); #endif #endif return 0; }
LXMusicNotification lxmusic_do_notify_prepare(const gchar *artist, const gchar *title, const char *summary, GtkStatusIcon *status_icon) { #if HAVE_LIBNOTIFY if (!notify_is_initted ()) notify_init ("LXMusic"); GString* message = g_string_new(""); if ( (artist != NULL) && (title != NULL ) ) { /* metadata available */ g_string_append_printf(message, "<b>%s: </b><i>%s</i>", _("Artist"), artist ); g_string_append_printf(message, "\n<b>%s: </b><i>%s</i>", _("Title"), title ); } /* use filename without markup */ else g_string_append( message, title ); struct _LXMusicNotification *lxn = g_new ( struct _LXMusicNotification, 1); #if !defined(NOTIFY_VERSION_MINOR) || (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7) lxn->notify = notify_notification_new (summary, message->str, NULL, NULL); #else lxn->notify = notify_notification_new (summary, message->str, NULL); #endif notify_notification_set_urgency (lxn->notify, NOTIFY_URGENCY_NORMAL); #if !defined(NOTIFY_VERSION_MINOR) || (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7) notify_notification_attach_to_status_icon( lxn->notify, status_icon ); #endif notify_notification_set_timeout (lxn->notify, NOTIFY_EXPIRES_DEFAULT); g_string_free( message, TRUE ); return lxn; #endif /* HAVE_LIBNOTIFY */ }
static void show_notification(MnpAlarmInstance *alarm) { MnpAlarmInstancePrivate *priv = ALARM_INSTANCE_PRIVATE(alarm); gboolean once = FALSE; NotifyNotification *notify; char *string; MnpAlarmItem *item = priv->item; if (!once) { once = TRUE; notify_init(_("Alarm Notify")); } string = g_strdup_printf(_("Alarm at %d:%.2d %s"), item->hour, item->minute, item->am_pm ? _("am") : _("pm")); #ifdef HAVE_NOTIFY_0_7 notify = notify_notification_new(_("Dawati Alarm Notify"), string, NULL); #else notify = notify_notification_new(_("Dawati Alarm Notify"), string, NULL, NULL); #endif notify_notification_set_timeout(notify,10000); notify_notification_set_category(notify,_("AlarmNotifications")); notify_notification_set_urgency (notify,NOTIFY_URGENCY_CRITICAL); notify_notification_show(notify,NULL); g_free(string); }
static void _send_note (CarrickNotificationManager *self, gchar *title, gchar *message, const gchar *icon) { CarrickNotificationManagerPrivate *priv = self->priv; /* Don't show a notification if we've got the main window up */ if (carrick_shell_is_visible ()) return; if (priv->note) { notify_notification_update (priv->note, title, message, icon); } else { #ifdef HAVE_NOTIFY_0_7 priv->note = notify_notification_new (title, message, icon); #else priv->note = notify_notification_new (title, message, icon, NULL); #endif g_signal_connect (priv->note, "closed", G_CALLBACK (on_note_closed), self); } notify_notification_show (priv->note, NULL); }
void notification_backend_show (const char *title, const char *text) { NotifyNotification *notification; if (strip_markup) text = g_markup_escape_text (text, -1); #if NOTIFY_CHECK_VERSION(0,7,0) notification = notify_notification_new (title, text, "hexchat"); #else notification = notify_notification_new (title, text, "hexchat", NULL); #endif #if NOTIFY_CHECK_VERSION(0,6,0) notify_notification_set_hint (notification, "desktop-entry", g_variant_new_string ("hexchat")); #else notify_notification_set_hint_string (notification, "desktop-entry", "hexchat"); #endif notify_notification_show (notification, NULL); g_object_unref (notification); if (strip_markup) g_free ((char*)text); }
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); }
int main() { NotifyNotification *n1, *n2, *n3; notify_init("Size Changes"); n1 = notify_notification_new("Notification 1", "Notification number 1!", NULL, NULL); notify_notification_set_timeout(n1, 7000); if (!notify_notification_show(n1, NULL)) { fprintf(stderr, "failed to send notification\n"); return 1; } g_object_unref(G_OBJECT(n1)); n2 = notify_notification_new("Notification 2", "Notification number 2!", NULL, NULL); notify_notification_set_timeout(n2, 7000); if (!notify_notification_show(n2, NULL)) { fprintf(stderr, "failed to send notification\n"); return 1; } n3 = notify_notification_new("Notification 3", "Notification number 3!", NULL, NULL); notify_notification_set_timeout(n3, 7000); if (!notify_notification_show(n3, NULL)) { fprintf(stderr, "failed to send notification\n"); return 1; } g_object_unref(G_OBJECT(n3)); sleep(2); notify_notification_update(n2, "Longer Notification 2", "This is a much longer notification.\n" "Two lines.\n" "Well, okay, three.\n" "Last one.", NULL); if (!notify_notification_show(n2, NULL)) { fprintf(stderr, "failed to send notification\n"); return 1; } return 0; }
/* * open a notification window (expires in 5 seconds) to say thank you * to the user for his bug feedback. */ static void sent_an_oops(void) { char *summary = _("Kernel bug diagnostic information sent"); char *message = NULL; char *message_1 = _("Diagnostic information from your Linux kernel has been " "sent to http://oops.kernel.org/ " "for the Linux kernel developers to work on. \n" "Thank you for contributing to improve the quality of the Linux kernel.\n"); char *message_2 = _("Diagnostic information from your Linux kernel has been " "sent to http://oops.kernel.org " "for the Linux kernel developers to work on. \n" "Thank you for contributing to improve the quality of the Linux kernel.\n" "You can view your submitted oops here: %s\n"); NotifyActionCallback callback = notify_action; close_notification(); if (strlen(url_to_oops)==0) message = g_strdup_printf("%s", message_1); else message = g_strdup_printf(message_2, url_to_oops); url_to_oops[0] = 0; #if NOTIFY_CHECK_VERSION(0,7,0) notify = notify_notification_new(summary, message, "/usr/share/kerneloops/icon.png"); #else notify = notify_notification_new(summary, message, "/usr/share/kerneloops/icon.png", NULL); #endif notify_notification_set_timeout(notify, 5000); notify_notification_set_urgency(notify, NOTIFY_URGENCY_LOW); notify_notification_add_action(notify, "default", "action", callback, "default", NULL); if (user_preference <= 0) notify_notification_add_action(notify, "always", _("Always"), callback, "always", NULL); notify_notification_add_action(notify, "never", _("Never again"), callback, "never", NULL); notify_notification_show(notify, NULL); g_free(message); }
static void xfce_accessibility_helper_notification_show (XfceAccessibilityHelper *helper, const gchar *summary, const gchar *body) { /* early leave the avoid dbus errors, we already * told we were unable to connect during init */ if (notify_is_initted () == FALSE) return; /* close the running notification */ if (helper->notification == NULL) { /* create a new notification */ #ifdef NOTIFY_CHECK_VERSION #if NOTIFY_CHECK_VERSION (0, 7, 0) helper->notification = notify_notification_new (summary, body, "keyboard"); #else helper->notification = notify_notification_new (summary, body, "keyboard", NULL); #endif #else helper->notification = notify_notification_new (summary, body, "keyboard", NULL); #endif /* close signal */ g_signal_connect (G_OBJECT (helper->notification), "closed", G_CALLBACK (xfce_accessibility_helper_notification_closed), helper); } else { /* update the current notification */ notify_notification_update (helper->notification, summary, body, "keyboard"); } if (G_LIKELY (helper->notification)) { /* show the notification for (another) 2 seconds */ notify_notification_set_timeout (helper->notification, 2000); /* show the notification */ if (!notify_notification_show (helper->notification, NULL)) { /* show warning with the notification information */ g_warning ("Failed to show notification: %s (%s).", summary, body); /* failed to show the notification */ notify_notification_close (helper->notification, NULL); helper->notification = NULL; } } }
int main () { NotifyNotification *n; notify_init ("Basics"); /* Long summary */ n = notify_notification_new ("Summary that is very long 8374983278r32j4 rhjjfh dw8f 43jhf 8ds7 ur2389f jdbjkt h8924yf jkdbjkt 892hjfiHER98HEJIF BDSJHF hjdhF JKLH 890YRHEJHFU 89HRJKSHdd dddd ddddd dddd ddddd dddd ddddd dddd dddd ddd ddd dddd Fdd d ddddd dddddddd ddddddddhjkewdkjsjfjk sdhkjf hdkj dadasdadsa adsd asd sd saasd fadskfkhsjf hsdkhfkshfjkhsd kjfhsjdkhfj ksdhfkjshkjfsd sadhfjkhaskd jfhsdajkfhkjs dhfkjsdhfkjs adhjkfhasdkj fhdsakjhfjk asdhkjkfhd akfjshjfsk afhjkasdhf jkhsdaj hf kjsdfahkfh sakjhfksdah kfdashkjf ksdahfj shdjdh", "Content", NULL); notify_notification_set_timeout (n, 3000); //3 seconds if (!notify_notification_show (n, NULL)) { fprintf (stderr, "failed to send notification\n"); return 1; } g_object_unref (G_OBJECT (n)); /* Long message */ n = notify_notification_new ("Summary", "Content that is very long 8374983278r32j4 rhjjfh dw8f 43jhf 8ds7 ur2389f jdbjkt h8924yf jkdbjkt 892hjfiHER98HEJIF BDSJHF hjdhF JKLH 890YRHEJHFU 89HRJKSHdd dddd ddddd dddd ddddd dddd ddddd dddd dddd ddd ddd dddd Fdd d ddddd dddddddd ddddddddhjkewdkjsjfjk sdhkjf hdkj dadasdadsa adsd asd sd saasd fadskfkhsjf hsdkhfkshfjkhsd kjfhsjdkhfj ksdhfkjshkjfsd sadhfjkhaskd jfhsdajkfhkjs dhfkjsdhfkjs adhjkfhasdkj fhdsakjhfjk asdhkjkfhd akfjshjfsk afhjkasdhf jkhsdaj hf kjsdfahkfh sakjhfksdah kfdashkjf ksdahfj shdjdh", NULL); notify_notification_set_timeout (n, 3000); //3 seconds if (!notify_notification_show (n, NULL)) { fprintf (stderr, "failed to send notification\n"); return 1; } g_object_unref (G_OBJECT (n)); /* Summary only */ n = notify_notification_new ("Summary only there is no message content", NULL, NULL); notify_notification_set_timeout (n, NOTIFY_EXPIRES_NEVER); if (!notify_notification_show (n, NULL)) { fprintf (stderr, "failed to send notification\n"); return 1; } g_object_unref (G_OBJECT (n)); return 0; }
static void got_a_message(void) { char *summary = _("Your system had a kernel failure"); char *message = _("There is diagnostic information available for this failure." " Do you want to submit this information to the http://oops.kernel.org/" " website for use by the Linux kernel developers?\n"); NotifyActionCallback callback = notify_action; /* if there's a notification active already, close it first */ close_notification(); #if NOTIFY_CHECK_VERSION(0,7,0) notify = notify_notification_new(summary, message, "/usr/share/kerneloops/icon.png"); #else notify = notify_notification_new(summary, message, "/usr/share/kerneloops/icon.png", NULL); #endif notify_notification_set_timeout(notify, 0); notify_notification_set_urgency(notify, NOTIFY_URGENCY_CRITICAL); /* * add the buttons and default action */ notify_notification_add_action(notify, "default", "action", callback, "default", NULL); notify_notification_add_action(notify, "always", _("Always"), callback, "always", NULL); notify_notification_add_action(notify, "yes", _("Yes"), callback, "yes", NULL); notify_notification_add_action(notify, "no", _("No"), callback, "no", NULL); notify_notification_add_action(notify, "never", _("Never"), callback, "never", NULL); if (detail_file_name) { notify_notification_add_action(notify, "details", _("Show Details"), detail_action, "details", NULL); } notify_notification_show(notify, NULL); }
static void on_account_added (MailmeTelepathy *tp_provider, MailmeTelepathyAccount *account, gpointer user_data) { /* Translators: button on a "unread mail" notification, will open a web page (e.g. gmail.com inbox) or a mail client */ char *title = _("Open"); NotifyNotification *notification; notification = notify_notification_new ("", NULL, NULL); notify_notification_set_category (notification, "email.arrived"); notify_notification_add_action (notification, "open", title, on_open_action, account, NULL); g_object_set_data_full (G_OBJECT (account), "notification", notification, g_object_unref); g_object_set_data (G_OBJECT (account), "last-unread-count", GUINT_TO_POINTER(0)); g_signal_connect (account, "notify::unread-count", G_CALLBACK (on_unread_count_changed), NULL); }
static void nemo_main_application_notify_unmount_show (NemoApplication *application, const gchar *message) { NemoMainApplication *app = NEMO_MAIN_APPLICATION (application); gchar **strings; strings = g_strsplit (message, "\n", 0); if (!app->priv->unmount_notify) { app->priv->unmount_notify = notify_notification_new (strings[0], strings[1], "media-removable"); notify_notification_set_hint (app->priv->unmount_notify, "transient", g_variant_new_boolean (TRUE)); notify_notification_set_urgency (app->priv->unmount_notify, NOTIFY_URGENCY_CRITICAL); } else { notify_notification_update (app->priv->unmount_notify, strings[0], strings[1], "media-removable"); } notify_notification_show (app->priv->unmount_notify, NULL); g_strfreev (strings); }
void fe_tray_set_balloon(const char *title, const char *text) { #ifndef _WIN32 char *stext; WinStatus ws; NotifyNotification *n; /* no balloons if the window is focused */ ws = tray_get_window_status(); if (ws == WS_FOCUSED) return; /* bit 1 of flags means "no balloons unless hidden/iconified" */ if (ws != WS_HIDDEN && (prefs.gui_tray_flags & 2)) return; /* FIXME: this should close the current balloon */ if (!text) return; stext = strip_color(text, -1, STRIP_ALL); n = notify_notification_new(title, stext, NULL); notify_notification_set_icon_from_pixbuf(n, ICON_NORMAL); notify_notification_set_timeout(n, 20000); notify_notification_show(n, NULL); free(stext); g_object_unref(G_OBJECT(n)); #endif }
void main () { notify_init ("Hello world!"); NotifyNotification * Hello = notify_notification_new ("Hello world", "This is an example notification.", "dialog-information"); notify_notification_show (Hello, NULL); // g_object_unref(G_OBJECT(Hello)); // notify_uninit(); }
static void add_notify (char *summary, char *message) { NotifyNotification *notify = NULL; GError *error = NULL; gchar *escaped; escaped = g_markup_escape_text (message, strlen(message)); notify = notify_notification_new (summary, escaped, NULL); notify_notification_set_urgency (notify, NOTIFY_URGENCY_NORMAL); notify_notification_set_icon_from_pixbuf (notify, notify_icon); if (notify_manager_has_capability ("x-canonical-append")) notify_notification_set_hint_string(notify, "x-canonical-append", ""); if (!notify_notification_show (notify, &error)) { g_warning (_("Failed to send notification: %s\n"), error->message); g_error_free (error); return; } notifications = g_slist_prepend (notifications, notify); g_free (escaped); }
/** \copydoc notify */ void qcd::TrayIcon::notify(const QString& title, const QString& message, const QUrl url) { if (!url.isEmpty() && !url.isValid()) { qDebug() << "Url is invalid. Specified url: " << url; return; } #ifdef Q_OS_LINUX NotifyNotification *popup = notify_notification_new( QSTRING_TO_CHAR(title), QSTRING_TO_CHAR(message), "mail-message-new"); if (!url.isEmpty()) { auto* tray_data = new TrayNotifyData(url, this); notify_notification_add_action(popup, "default", "default", onNotifyClick, (gpointer)tray_data, NULL); notify_notification_add_action(popup, "open-url", "Otwórz", onNotifyClick, (gpointer)tray_data, NULL); } notify_notification_show(popup, NULL); if (url.isEmpty()) g_object_unref(G_OBJECT(popup)); #else url_to_open = QUrl(url); showMessage(title, message); #endif // Q_OS_LINUX // Change icon to notify the user (if has not clicked the notify baloon) setState(State::Notify); }
int main(int argc, char *argv[]) { NotifyNotification *n; GtkWidget *window; GtkWidget *button; gtk_init(&argc, &argv); notify_init("Replace Test"); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(gtk_main_quit), NULL); button = gtk_button_new_with_label("click here to change notification"); gtk_container_add(GTK_CONTAINER(window), button); gtk_widget_show_all(window); n = notify_notification_new("Widget Attachment Test", "Button has not been clicked yet", NULL, //no icon button); //attach to button notify_notification_set_timeout(n, 0); //don't timeout g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(on_clicked), n); g_signal_connect_after(G_OBJECT(button), "expose-event", G_CALLBACK(on_exposed), n); gtk_main(); return 0; }
void notifyInit(NotifyNotification **notification) { notify_init("Red"); *notification = notify_notification_new("Red", NULL, NULL); notify_notification_set_timeout(*notification, NOTIFY_TIMEOUT_MSEC); notify_notification_set_hint_string(*notification, "x-canonical-private-synchronous", ""); }
/* Display startup notification */ gboolean trayicon_notification_start(gpointer userdata) { START_FUNC struct trayicon *trayicon=(struct trayicon *)userdata; if (!notify_init(_("Florence"))) flo_warn(_("libnotify failed to initialize")); #ifdef ENABLE_NOTIFICATION_ICON trayicon->notification=notify_notification_new_with_status_icon( #else trayicon->notification=notify_notification_new( #endif _("Florence is running"), _("Click on Florence icon to show/hide Florence.\n" "Right click on it to display menu and get help."), #ifdef ENABLE_NOTIFICATION_ICON GTK_STOCK_INFO, trayicon->tray_icon); #else GTK_STOCK_INFO); #endif notify_notification_add_action(trayicon->notification, "STOP", _("Do not show again"), trayicon_notification_stop, NULL, NULL); notify_notification_set_timeout(trayicon->notification, 5000); if (!notify_notification_show(trayicon->notification, NULL)) flo_warn(_("Notification failed")); END_FUNC return FALSE; }
void DesktopNotifierLinux::showNotification(const std::string& notification_title, const std::string& notification_message, const std::string& notification_type) { LL_INFOS("DesktopNotifierLinux") << "New notification title: " << notification_title << LL_ENDL; LL_INFOS("DesktopNotifierLinux") << "New notification message: " << notification_message << LL_ENDL; LL_INFOS("DesktopNotifierLinux") << "New notification type: " << notification_type << LL_ENDL; static NotifyNotification* notification = notify_notification_new( "Emerald Viewer",//(gchar*)notification_title.c_str(), NULL,//(gchar*)notification_message.c_str(), icon_wholename, NULL ); notify_notification_update( notification, (gchar*)notification_title.c_str(), (gchar*)notification_message.c_str(), icon_wholename ); notify_notification_set_urgency(notification, NOTIFY_URGENCY_LOW); notify_notification_set_category(notification, (gchar*)notification_type.c_str()); notify_notification_set_timeout(notification, NOTIFICATION_TIMEOUT_MS); // NotifyOSD ignores this, sadly. GError* error = NULL; if (notify_notification_show(notification, &error)) { LL_INFOS("DesktopNotifierLinux") << "Linux desktop notification type " << notification_type << "sent." << LL_ENDL; } else { LL_WARNS("DesktopNotifierLinux") << "Linux desktop notification FAILED to send. " << error->message << LL_ENDL; } }
nsresult nsAlertsIconListener::ShowAlert(GdkPixbuf* aPixbuf) { mNotification = notify_notification_new(mAlertTitle.get(), mAlertText.get(), nullptr, nullptr); if (!mNotification) return NS_ERROR_OUT_OF_MEMORY; if (aPixbuf) notify_notification_set_icon_from_pixbuf(mNotification, aPixbuf); NS_ADDREF(this); if (mAlertHasAction) { // What we put as the label doesn't matter here, if the action // string is "default" then that makes the entire bubble clickable // rather than creating a button. notify_notification_add_action(mNotification, "default", "Activate", notify_action_cb, this, nullptr); } // Fedora 10 calls NotifyNotification "closed" signal handlers with a // different signature, so a marshaller is used instead of a C callback to // get the user_data (this) in a parseable format. |closure| is created // with a floating reference, which gets sunk by g_signal_connect_closure(). GClosure* closure = g_closure_new_simple(sizeof(GClosure), this); g_closure_set_marshal(closure, notify_closed_marshal); mClosureHandler = g_signal_connect_closure(mNotification, "closed", closure, FALSE); gboolean result = notify_notification_show(mNotification, nullptr); return result ? NS_OK : NS_ERROR_FAILURE; }
QScriptValue Notify::show() { #ifdef Q_WS_X11 QScriptValueIterator it(context()->argument(0)); while(it.hasNext()) { it.next(); if(it.name() == "title") mTitle = it.value().toString(); else if(it.name() == "text") mText = it.value().toString(); else if(it.name() == "icon") mIcon = it.value().toString(); else if(it.name() == "timeout") mTimeout = it.value().toInt32(); } if(!mNotification) mNotification = notify_notification_new(mTitle.toUtf8(), mText.toUtf8(), mIcon.toUtf8() #if NOTIFY_CHECK_VERSION (0, 7, 0) ); #else , 0);
void nautilus_application_notify_unmount_show (NautilusApplication *application, const gchar *message) { gchar **strings; strings = g_strsplit (message, "\n", 0); if (!application->priv->unmount_notify) { application->priv->unmount_notify = notify_notification_new (strings[0], strings[1], "media-removable"); notify_notification_set_hint (application->priv->unmount_notify, "desktop-entry", g_variant_new_string ("nautilus")); notify_notification_set_hint (application->priv->unmount_notify, "transient", g_variant_new_boolean (TRUE)); notify_notification_set_urgency (application->priv->unmount_notify, NOTIFY_URGENCY_CRITICAL); } else { notify_notification_update (application->priv->unmount_notify, strings[0], strings[1], "media-removable"); } notify_notification_show (application->priv->unmount_notify, NULL); g_strfreev (strings); }
int main() { char input[MAX_BUF]="\0"; char messageit[MAX_BUF]="\0"; char *title="Sagan Alert"; while (fgets(input, MAX_BUF-1, stdin)) { strncat(messageit, input, MAX_BUF-1-strlen(messageit)); } messageit[MAX_BUF-1] = '\0'; /* Avoid overflow and null terminates */ NotifyNotification *n; notify_init("Sagan"); n = notify_notification_new (title,messageit, NULL, NULL); notify_notification_set_timeout(n, 1000); if (!notify_notification_show (n, NULL)) { g_error("Failed to send notification.\n"); return 1; } g_object_unref(G_OBJECT(n)); return 0; }
/** * Send a notifcation. This is mainly called * from the alsa subsystem whenever we have volume * changes. * * @param level the playback volume level * @param muted whether the playback is muted */ void do_notify(gint level, gboolean muted) { gchar *summary, *icon; GError *error = NULL; if (level < 0) level = 0; if (level > 100) level = 100; if (muted) summary = g_strdup("Volume muted"); else summary = g_strdup_printf("Volume: %d%%\n",level); if (muted) icon = "audio-volume-muted"; else if (level < 33) icon = "audio-volume-low"; else if (level < 66) icon = "audio-volume-medium"; else icon = "audio-volume-high"; if (notification == NULL) notification = notify_notification_new(summary,NULL,icon #if NOTIFY_CHECK_VERSION (0, 7, 0) ); #else ,NULL);
int notification_show(char *title, char *body, char *icon) { GError *error = NULL; NotifyNotification *notify_p; if (title == NULL) return -1; //you should init notify using app's name if(notify_is_initted() == FALSE) if(notify_init("argv[0]") == FALSE){ return -1; } notify_p = notify_notification_new(title, body, icon, NULL); //miliseconds, NOTIFY_EXPIRES_DEFAULT NOTIFY_EXPIRES_NEVER notify_notification_set_timeout(notify_p, 1000); //NOTIFY_URGENCY_LOW,NOTIFY_URGENCY_NORMAL, NOTIFY_URGENCY_CRITICAL, notify_notification_set_urgency (notify_p,NOTIFY_URGENCY_NORMAL); //notify_notification_update(title, body, icon, NULL); //notify_notification_close(notify_p, &error); if (notify_notification_show(notify_p, &error) == FALSE) return -1; //notify_uninit(); return 0; }
static void create_new_gnome_notification(gchar *title, gchar *body, NotifyUrgency urgency, gint timeout) { #if USE_NOTIFY GnomeNotification notif; if (eel_gconf_get_integer(NOTIFY_ALL)) { notify_init("SFLphone"); // Set struct fields notif.notification = notify_notification_new(title, body, NULL); notif.icon = gdk_pixbuf_new_from_file(LOGO_SMALL, NULL); notify_notification_set_urgency(notif.notification, urgency); if (notif.icon != NULL) notify_notification_set_icon_from_pixbuf(notif.notification, notif.icon); else ERROR("notify(), cannot load notification icon"); notify_notification_set_timeout(notif.notification, timeout); if (!notify_notification_show(notif.notification, NULL)) { ERROR("notify(), failed to send notification"); } } g_free(title); g_free(body); #endif }
static void _do_notify_message( const char * const source, const char * const message, int win) { #ifdef HAVE_LIBNOTIFY if (notify_is_initted()) { GString *title = g_string_new(""); g_string_append(title, source); g_string_append_printf(title, " (Profanity %d)", win); NotifyNotification *notification = notify_notification_new(title->str, message, NULL); notify_notification_set_timeout(notification, 3000); notify_notification_set_category(notification, "incoming message"); notify_notification_set_urgency(notification, NOTIFY_URGENCY_NORMAL); GError *error = NULL; gboolean notify_success = notify_notification_show(notification, &error); if (!notify_success) { log_error("Error sending desktop notification:"); log_error(" -> Message : %s", message); log_error(" -> Error : %s", error->message); } g_string_free(title, TRUE); } else { log_error("Libnotify initialisation error."); } #endif }
int main () { NotifyNotification *n; DBusConnection *conn; if (!notify_init ("Default Action Test")) exit (1); conn = dbus_bus_get (DBUS_BUS_SESSION, NULL); loop = g_main_loop_new (NULL, FALSE); dbus_connection_setup_with_g_main (conn, NULL); n = notify_notification_new ("Matt is online", "", NULL, NULL); notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT); notify_notification_add_action (n, "default", "Do Default Action", (NotifyActionCallback) callback, NULL, NULL); notify_notification_set_category (n, "presence.online"); if (!notify_notification_show (n, NULL)) { fprintf (stderr, "failed to send notification\n"); return 1; } g_main_loop_run (loop); return 0; }