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); }
static void osd_setup (NotifyNotification *notification) { bool_t resident = aud_get_bool ("notify", "resident"); notify_notification_set_hint (notification, "desktop-entry", g_variant_new_string ("audacious")); notify_notification_set_hint (notification, "action-icons", g_variant_new_boolean (TRUE)); notify_notification_set_hint (notification, "resident", g_variant_new_boolean (resident)); notify_notification_set_hint (notification, "transient", g_variant_new_boolean (! resident)); notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW); notify_notification_set_timeout (notification, resident ? NOTIFY_EXPIRES_NEVER : NOTIFY_EXPIRES_DEFAULT); }
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); }
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 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); }
void fe_tray_set_balloon (const char *title, const char *text) { #ifndef WIN32 #if 0 const char *argv[8]; const char *path; char time[16]; #endif WinStatus ws; /* no balloons if the window is focused */ ws = tray_get_window_status (); if ((prefs.hex_away_omit_alerts && hexchat_get_info(ph, "away")) || (prefs.hex_gui_focus_omitalerts && ws == WS_FOCUSED)) return; /* bit 1 of flags means "no balloons unless hidden/iconified" */ if (ws != WS_HIDDEN && prefs.hex_gui_tray_quiet) return; /* FIXME: this should close the current balloon */ if (!text) return; #ifdef USE_LIBNOTIFY NotifyNotification *notification; char *notify_text, *notify_title; if (!notify_is_initted()) notify_init(PACKAGE_NAME); notify_text = strip_color (text, -1, STRIP_ALL|STRIP_ESCMARKUP); notify_title = strip_color (title, -1, STRIP_ALL); notification = XC_NOTIFY_NEW (notify_title, notify_text, HEXCHATSHAREDIR "/icons/hicolor/scalable/apps/hexchat.svg", NULL); #if NOTIFY_CHECK_VERSION(0,7,0) notify_notification_set_hint (notification, "desktop-entry", g_variant_new_string ("hexchat")); #endif g_free ((char *)notify_title); g_free ((char *)notify_text); notify_notification_set_timeout (notification, prefs.hex_input_balloon_time*1000); notify_notification_show (notification, NULL); g_object_unref (notification); #endif #endif }
static void progress_ui_handler_ensure_notification (NautilusProgressUIHandler *self) { NotifyNotification *notify; if (self->priv->progress_notification) { return; } notify = notify_notification_new (_("File Operations"), NULL, NULL); self->priv->progress_notification = notify; notify_notification_set_category (notify, "transfer"); notify_notification_set_hint (notify, "resident", g_variant_new_boolean (TRUE)); notify_notification_add_action (notify, ACTION_DETAILS, _("Show Details"), notification_show_details_cb, self, NULL); }
void nautilus_application_notify_unmount_done (NautilusApplication *application, const gchar *message) { if (application->priv->unmount_notify) { notify_notification_close (application->priv->unmount_notify, NULL); g_clear_object (&application->priv->unmount_notify); } if (message != NULL) { NotifyNotification *unplug; gchar **strings; strings = g_strsplit (message, "\n", 0); unplug = notify_notification_new (strings[0], strings[1], "media-removable"); notify_notification_set_hint (unplug, "desktop-entry", g_variant_new_string ("nautilus")); notify_notification_show (unplug, NULL); g_object_unref (unplug); g_strfreev (strings); } }
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); }
static gboolean ldsm_notify_for_mount (LdsmMountInfo *mount, gboolean multiple_volumes, gboolean other_usable_volumes) { gchar *name, *program; gint64 free_space; gint response; gboolean has_trash; gboolean has_disk_analyzer; gboolean retval = TRUE; gchar *path; /* Don't show a notice if one is already displayed */ if (dialog != NULL || notification != NULL) return retval; name = g_unix_mount_guess_name (mount->mount); free_space = (gint64) mount->buf.f_frsize * (gint64) mount->buf.f_bavail; has_trash = ldsm_mount_has_trash (mount); path = g_strdup (g_unix_mount_get_mount_path (mount->mount)); program = g_find_program_in_path (DISK_SPACE_ANALYZER); has_disk_analyzer = (program != NULL); g_free (program); if (server_has_actions ()) { char *free_space_str; char *summary; char *body; free_space_str = g_format_size (free_space); if (multiple_volumes) { summary = g_strdup_printf (_("Low Disk Space on \"%s\""), name); if (has_trash) { body = g_strdup_printf (_("The volume \"%s\" has only %s disk space remaining. You may free up some space by emptying the trash."), name, free_space_str); } else { body = g_strdup_printf (_("The volume \"%s\" has only %s disk space remaining."), name, free_space_str); } } else { summary = g_strdup (_("Low Disk Space")); if (has_trash) { body = g_strdup_printf (_("This computer has only %s disk space remaining. You may free up some space by emptying the trash."), free_space_str); } else { body = g_strdup_printf (_("This computer has only %s disk space remaining."), free_space_str); } } g_free (free_space_str); notification = notify_notification_new (summary, body, "drive-harddisk-symbolic"); g_free (summary); g_free (body); g_signal_connect (notification, "closed", G_CALLBACK (on_notification_closed), NULL); notify_notification_set_app_name (notification, _("Disk space")); notify_notification_set_hint (notification, "transient", g_variant_new_boolean (TRUE)); notify_notification_set_urgency (notification, NOTIFY_URGENCY_CRITICAL); notify_notification_set_timeout (notification, NOTIFY_EXPIRES_DEFAULT); if (has_disk_analyzer) { notify_notification_add_action (notification, "examine", _("Examine"), (NotifyActionCallback) examine_callback, g_strdup (path), g_free); } if (has_trash) { notify_notification_add_action (notification, "empty-trash", _("Empty Trash"), (NotifyActionCallback) empty_trash_callback, NULL, NULL); } notify_notification_add_action (notification, "ignore", _("Ignore"), (NotifyActionCallback) ignore_callback, NULL, NULL); notify_notification_set_category (notification, "device"); if (!notify_notification_show (notification, NULL)) { g_warning ("failed to send disk space notification\n"); } } else { dialog = csd_ldsm_dialog_new (other_usable_volumes, multiple_volumes, has_disk_analyzer, has_trash, free_space, name, path); g_object_ref (G_OBJECT (dialog)); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (GTK_WIDGET (dialog)); dialog = NULL; switch (response) { case GTK_RESPONSE_CANCEL: retval = FALSE; break; case CSD_LDSM_DIALOG_RESPONSE_ANALYZE: retval = FALSE; ldsm_analyze_path (path); break; case CSD_LDSM_DIALOG_RESPONSE_EMPTY_TRASH: retval = TRUE; csd_ldsm_show_empty_trash (); break; case GTK_RESPONSE_NONE: case GTK_RESPONSE_DELETE_EVENT: retval = TRUE; break; default: g_assert_not_reached (); } } g_free (name); g_free (path); return retval; }
/* * We are adding an idle handler - we do not need to hold the gdk lock * for this. * * We can't just grab the GDK lock and call the real_error function * since this runs a dialog, which has a nested g_main loop - glib * doesn't like haveing main loops active in two threads at one * time. When the idle handler gets run it is from the main thread. * */ void libbalsa_information_varg(GtkWindow *parent, LibBalsaInformationType type, const char *fmt, va_list ap) { struct information_data *data; g_return_if_fail(fmt != NULL); g_assert(libbalsa_real_information_func != NULL); #ifdef HAVE_NOTIFY if (notify_is_initted()) { gchar *msg, *p, *q; GString *escaped; NotifyNotification *note; char *icon_str; switch (type) { case LIBBALSA_INFORMATION_MESSAGE: icon_str = "dialog-information"; break; case LIBBALSA_INFORMATION_WARNING: icon_str = "dialog-warning"; break; case LIBBALSA_INFORMATION_ERROR: icon_str = "dialog-error"; break; default: icon_str = NULL; break; } msg = g_strdup_vprintf(fmt, ap); /* libnotify/DBUS uses HTML markup, so we must replace '<' and * '&' with the corresponding entity in the message string. */ escaped = g_string_new(NULL); for (p = msg; (q = strpbrk(p, "<>&\"")) != NULL; p = ++q) { g_string_append_len(escaped, p, q - p); switch (*q) { case '<': g_string_append(escaped, "<"); break; case '>': g_string_append(escaped, ">"); break; case '&': g_string_append(escaped, "&"); break; case '"': g_string_append(escaped, """); break; default: break; } } g_string_append(escaped, p); g_free(msg); #if HAVE_NOTIFY >= 7 note = notify_notification_new("Balsa", escaped->str, icon_str); notify_notification_set_hint(note, "desktop-entry", g_variant_new_string("balsa")); #else /* prior to 0.7.0 */ note = notify_notification_new("Balsa", escaped->str, icon_str, NULL); #endif g_string_free(escaped, TRUE); notify_notification_set_timeout(note, 7000); /* 7 seconds */ notify_notification_show(note, NULL); if (parent) { /* Close with parent if earlier. */ g_object_weak_ref(G_OBJECT(parent), lbi_notification_parent_weak_notify, note); g_signal_connect(note, "closed", G_CALLBACK(lbi_notification_closed_cb), parent); } else g_object_unref(note); return; } /* Fall through to the ordinary notification scheme */ #endif data = g_new(struct information_data, 1); data->parent = parent; data->message_type = type; /* We format the string here. It must be free()d in the idle * handler We parse the args here because by the time the idle * function runs we will no longer be in this stack frame. */ data->msg = g_strdup_vprintf(fmt, ap); if (parent) g_object_add_weak_pointer(G_OBJECT(parent), (gpointer) & data->parent); g_idle_add((GSourceFunc) libbalsa_information_idle_handler, data); }
static void do_notify (RBNotificationPlugin *plugin, guint timeout, const char *primary, const char *secondary, const char *image_uri, gboolean playback) { GError *error = NULL; NotifyNotification *notification; if (notify_is_initted () == FALSE) { GList *caps; if (notify_init ("Rhythmbox") == FALSE) { g_warning ("libnotify initialization failed"); return; } /* ask the notification server if it supports actions */ caps = notify_get_server_caps (); if (g_list_find_custom (caps, "actions", (GCompareFunc)g_strcmp0) != NULL) { rb_debug ("notification server supports actions"); plugin->notify_supports_actions = TRUE; if (g_list_find_custom (caps, "action-icons", (GCompareFunc)g_strcmp0) != NULL) { rb_debug ("notifiction server supports icon buttons"); plugin->notify_supports_icon_buttons = TRUE; } } else { rb_debug ("notification server does not support actions"); } if (g_list_find_custom (caps, "persistence", (GCompareFunc)g_strcmp0) != NULL) { rb_debug ("notification server supports persistence"); plugin->notify_supports_persistence = TRUE; } else { rb_debug ("notification server does not support persistence"); } rb_list_deep_free (caps); } if (primary == NULL) primary = ""; if (secondary == NULL) secondary = ""; if (playback) { notification = plugin->notification; } else { notification = plugin->misc_notification; } if (notification == NULL) { notification = notify_notification_new (primary, secondary, RB_APP_ICON); g_signal_connect_object (notification, "closed", G_CALLBACK (notification_closed_cb), plugin, 0); if (playback) { plugin->notification = notification; } else { plugin->misc_notification = notification; } } else { notify_notification_clear_hints (notification); notify_notification_update (notification, primary, secondary, RB_APP_ICON); } notify_notification_set_timeout (notification, timeout); if (image_uri != NULL) { notify_notification_clear_hints (notification); notify_notification_set_hint (notification, "image_path", g_variant_new_string (image_uri)); } if (playback) notify_notification_set_category (notification, "x-gnome.music"); notify_notification_set_hint (notification, "desktop-entry", g_variant_new_string ("rhythmbox")); notify_notification_clear_actions (notification); if (playback && plugin->notify_supports_actions) { gboolean rtl; const char *play_icon; rtl = (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL); play_icon = rtl ? "media-playback-start-rtl" : "media-playback-start"; if (plugin->notify_supports_icon_buttons) { gboolean playing = FALSE; rb_shell_player_get_playing (plugin->shell_player, &playing, NULL); notify_notification_add_action (notification, rtl ? "media-skip-backward-rtl" : "media-skip-backward", _("Previous"), (NotifyActionCallback) notification_previous_cb, plugin, NULL); notify_notification_add_action (notification, playing ? "media-playback-pause" : play_icon, playing ? _("Pause") : _("Play"), (NotifyActionCallback) notification_playpause_cb, plugin, NULL); notify_notification_set_hint (notification, "action-icons", g_variant_new_boolean (TRUE)); } notify_notification_add_action (notification, rtl ? "media-skip-forward-rtl" : "media-skip-forward", _("Next"), (NotifyActionCallback) notification_next_cb, plugin, NULL); } if (plugin->notify_supports_persistence) { const char *hint; if (playback) { hint = "resident"; } else { hint = "transient"; } notify_notification_set_hint (notification, hint, g_variant_new_boolean (TRUE)); } if (notify_notification_show (notification, &error) == FALSE) { g_warning ("Failed to send notification (%s): %s", primary, error->message); g_error_free (error); } }