void entryABCChanged(GtkEntry *entry, gpointer user_data) { const char *entryTextConst; entryTextConst = gtk_entry_get_text(entry); char *newEntryText = malloc(strlen(entryTextConst)+1);; strcpy(newEntryText, entryTextConst); if (checkStringShortFloat(newEntryText) == 1) { gtk_entry_set_text(GTK_ENTRY(entry), newEntryText); calcAll(); } else { notify_init ("Number warning"); NotifyNotification *Hello = notify_notification_new ("Input warning", "This number must be float from -3.402823e+38 to 3.402823e+38 and doesn't contain chars", "dialog-warning"); notify_notification_show (Hello, NULL); g_object_unref(G_OBJECT(Hello)); notify_uninit(); newEntryText[strlen(newEntryText) - 1] = 0; gtk_entry_set_text(GTK_ENTRY (entry), newEntryText); } }
void Stick20ResponseTask::ShowIconMessage (const QString msg) { QString title = QString ("Nitrokey App"); int timeout = 3000; #ifdef HAVE_LIBAPPINDICATOR if (isUnity ()) { if (!notify_init ("example")) return; NotifyNotification* notf; notf = notify_notification_new (title.toUtf8 ().data (), msg.toUtf8 ().data (), NULL); notify_notification_show (notf, NULL); notify_uninit (); } else #endif // HAVE_LIBAPPINDICATOR { if (TRUE == trayIcon->supportsMessages ()) { trayIcon->showMessage (title, msg, QSystemTrayIcon::Information, timeout); } else csApplet->messageBox (msg); } }
void mca_ipnl_display_info (gchar *infostr) { //#ifdef HAVE_NOTIFICATION NotifyNotification* notification; gboolean success = TRUE; GError* error = NULL; notify_init("gtk_mkahawa_client"); /* try the mkahawa-client notification */ notification = notify_notification_new ( "Message from Cyber Admin:", infostr, PACKAGE_DATA_DIR"/pixmaps/mkahawa-icon.png" #if !defined(NOTIFY_VERSION_MINOR) || (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7) , NULL #endif ); notify_notification_set_timeout(notification, ipnl->notify_timeout * 1000); success = notify_notification_show (notification, &error); notify_uninit(); if (!success) { //do nothing yet } DEBUG_PRINT("mca_ipnl_display_info(): %s\n", infostr); }
/* 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; }
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); }
nsresult nsAlertsIconListener::ShowAlert(GdkPixbuf* aPixbuf) { mNotification = notify_notification_new(mAlertTitle.get(), mAlertText.get(), NULL, NULL); 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, NULL); } // 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, NULL); return result ? NS_OK : NS_ERROR_FAILURE; }
static void SendNotification(PianoSong_t *song) { NotifyNotification *songNotification; char coverArtWgetBuffer[512]; char coverArtLocation[256]; char *coverArtURL; int result; // if there is no cover art, download the no album art image // TODO: cache this image coverArtURL = *song->coverArt == '\0' ? "http://www.pandora.com/images/no_album_art.jpg" : song->coverArt; snprintf(coverArtLocation, 256, "/tmp/%llu-coverArt.jpg", (unsigned long long) getpid()); snprintf(coverArtWgetBuffer, 512, "wget --quiet -O %s %s", coverArtLocation, coverArtURL); result = system(coverArtWgetBuffer); songNotification = notify_notification_new(song->artist, song->title, coverArtLocation, NULL); notify_notification_set_timeout(songNotification, 3000); notify_notification_set_urgency(songNotification, NOTIFY_URGENCY_CRITICAL); GError *error = NULL; notify_notification_show(songNotification,&error); g_object_unref(G_OBJECT(songNotification)); free(error); }
/*** received_signal ***/ void received_signal(int signal) { GError * error = NULL; switch (signal) { case SIGINT: case SIGTERM: if (verbose > 0) printf("Received signal %s, preparing exit.\n", strsignal(signal)); doexit++; mpd_send_noidle(conn); break; case SIGHUP: case SIGUSR1: if (verbose > 0) printf("Received signal %s, showing last notification again.\n", strsignal(signal)); if (notify_notification_show(notification, &error) == FALSE) { g_printerr("%s: Error \"%s\" while trying to show notification again.\n", program, error->message); g_error_free(error); } break; default: fprintf(stderr, "Reveived signal %s (%d), no idea what to do...\n", strsignal(signal), signal); } }
int notify(NotifyNotification **notification, int red, int min, int max) { if (*notification == NULL) notifyInit(notification); unsigned int value = 100 * (red - min) / (max - min); if (text[0] != '\0') { if (value > 100) value = 100; sprintf(text, "%3u%% ", value); const unsigned int top = 5 + (sizeof(text) - 5 - 1) * value / 100; for (unsigned int i = 5; i < top; i++) text[i] = '|'; text[top] = '\0'; value = 0; } notify_notification_update(*notification, "Red", text, red == max ? icon_off : icon_on); notify_notification_set_hint_uint32(*notification, "value", value); GError *error = NULL; notify_notification_show(*notification, &error); if (error) { g_printerr("ERROR: %s\n", error->message); g_error_free(error); return -1; } return 0; }
int main() { gboolean status; NotifyNotification *notification; char *fortune; GError *error; status = notify_init("fortuner"); if (!status) { return 1; } fortune = malloc(BUFSIZE + 1); if (!run_fortune(fortune, BUFSIZE)) { notification = notify_notification_new("Today's Fortune", fortune, NULL); error = NULL; status = notify_notification_show(notification, &error); if (!status) { fprintf(stderr, "Could not display notification: %s\n", error->message); } } free(fortune); notify_uninit(); return 0; }
static void show_volume_notification(unsigned int volume_pct, int muted) { const char *icon; if (muted) icon = "audio-volume-muted"; else if (volume_pct == 0) icon = "audio-volume-off"; else if (volume_pct < 33) icon = "audio-volume-low"; else if (volume_pct < 66) icon = "audio-volume-medium"; else icon = "audio-volume-high"; if (notification) { GError *err = NULL; if (!notify_notification_update(notification, APP_NAME, NULL, icon)) { fprintf(stderr, "Invalid parameter passed to notify_notification_update()"); return; } notify_notification_set_hint_int32(notification, "value", (gint)volume_pct); notify_notification_show(notification, &err); if (err) { fprintf(stderr, "notify_notification_show() failed: %s\n", err->message); g_error_free(err); return; } } }
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; } }
static void _auth_request_cb (BluetoothApplet *applet, const char *path, const char *name, const char *long_name, const char *uuid, DawatiBtShell *shell) { DawatiBtShellPrivate *priv = GET_PRIVATE (shell); char *msg = NULL; ClutterActor *w; w = g_hash_table_lookup (priv->requests, path); if (w) { clutter_actor_remove_child (priv->request_box, w); g_hash_table_remove (priv->requests, path); } dawati_bt_shell_add_request (shell, name, path, DAWATI_BT_REQUEST_TYPE_AUTH, uuid); /* TRANSLATORS: Notification * Placeholder 1: Bluetooth device name */ msg = g_strdup_printf (_("%s would like to access a service"), name); notify_notification_update (priv->notification, _("New Bluetooth access request"), msg, icon); notify_notification_show (priv->notification, NULL); g_free (msg); }
static void _confirm_request_cb (BluetoothApplet *applet, const char *path, const char *name, const char *long_name, guint pin, DawatiBtShell *shell) { DawatiBtShellPrivate *priv = GET_PRIVATE (shell); char *msg = NULL; ClutterActor *w; char *pin_str; w = g_hash_table_lookup (priv->requests, path); if (w) { clutter_actor_remove_child (priv->request_box, w); g_hash_table_remove (priv->requests, path); } /* according to BT spec, pin is 6 digits */ pin_str = g_strdup_printf ("%06u", pin); dawati_bt_shell_add_request (shell, name, path, DAWATI_BT_REQUEST_TYPE_CONFIRM, pin_str); g_free (pin_str); /* TRANSLATORS: Notification * Placeholder 1: Bluetooth device name */ msg = g_strdup_printf (_("%s would like to confirm connection"), name); notify_notification_update (priv->notification, _(pairing_title), msg, icon); notify_notification_show (priv->notification, NULL); g_free (msg); }
void push_notification (gchar* title, gchar* body, gchar* icon) { NotifyNotification* notification; gboolean success; GError* error = NULL; /* initial notification */ notification = notify_notification_new (title, body, icon); notify_notification_set_hint_string (notification, "x-canonical-append", "true"); error = NULL; success = notify_notification_show (notification, &error); if (!success) { g_print ("That did not work ... \"%s\".\n", error->message); g_error_free (error); } g_signal_connect (G_OBJECT (notification), "closed", G_CALLBACK (closed_handler), NULL); g_object_unref (G_OBJECT (notification)); sleep (3); /* simulate a user typing */ }
/** \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); }
void notify_user(int uid, char* caption, char* message, char* icon) { int cpid = fork(); if (cpid == 0) { // child ICHECKED(setuid(uid), -1); ICHECKED(notify_init("nginx"), FALSE); NotifyNotification* notification = PCHECKED(notify_notification_new(caption, message, icon)); GError* showError = NULL; notify_notification_show(notification, &showError); if(showError != NULL) { die(showError->message); } g_object_unref(G_OBJECT(notification)); notify_uninit(); exit(0); } else if(cpid > 0) { printf("NOTIFY %d: %s - %s\n", uid, caption, message); return; // nothing to do in the host anymore } else { die("fork()"); } }
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 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; }
void nemo_application_notify_unmount_show (NemoApplication *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, "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); }
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, NULL); notify_notification_attach_to_status_icon(n, sticon); notify_notification_set_timeout(n, 20000); notify_notification_show(n, NULL); free(stext); g_object_unref(G_OBJECT(n)); #endif }
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; }
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; }
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); }
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 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 int show (lua_State * L) { NotifyNotification *notify = (NotifyNotification *) lua_touserdata (L, 1); if (!notify) luaL_argerror(L, 1, "Unknown type"); notify_notification_show (notify, NULL); return 0; }
void main(void){ NotifyNotification *p; notify_init("hello"); p =notify_notification_new("hello", "good boy!", NULL); notify_notification_show(p, NULL); }
void send_notification(uint64 serverConnectionHandlerID, const char* event_name, const char* message) { notify_notification_update(notification, event_name, message, message_icon); if(!notify_notification_show(notification, NULL)) { ts3Functions.logMessage("libnotify error", LogLevel_ERROR, "Plugin", serverConnectionHandlerID); } else { printf("Could not send libnotify notification"); } }