예제 #1
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 */
}
예제 #2
0
파일: main.c 프로젝트: tylerkahn/pianobar
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);
}
예제 #3
0
파일: sflnotify.c 프로젝트: dyfet/sflphone
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
}
예제 #4
0
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);
}
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;
    }
}
예제 #6
0
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);
}
예제 #7
0
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);
}
예제 #8
0
파일: mynotify.c 프로젝트: crazyleen/mylib
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;
}
예제 #9
0
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
}
예제 #10
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);
}
예제 #11
0
void
NotificationScreen::logMessage (const char   *component,
			  	CompLogLevel level,
			  	const char   *message)
{
    NotifyNotification *n;
    char               *logLevel, *homeDir;
    CompString         iconUri;
    int                timeout;
    NotifyUrgency      urgency;

    if (level > optionGetMaxLogLevel ())
    {
	screen->logMessage (component, level, message);
	return;
    }

    homeDir = getenv ("HOME");
    if (!homeDir)
	return;

    /* FIXME: when not installing manually, the image will likely reside
              in $PREFIX/share/compiz, not in the home dir */
    iconUri   = "file://";
    iconUri += homeDir;
    iconUri += "/" IMAGE_DIR "/compiz.png";
    logLevel = (char *) logLevelToString (level);

    n = notify_notification_new (logLevel, message,
				 iconUri.c_str ()
#ifndef HAVE_LIBNOTIFY_0_6_1
				 , NULL
#endif				 
				 );

    timeout = optionGetTimeout ();
    if (timeout > 0)
	timeout *= 1000;

    notify_notification_set_timeout (n, timeout);

    if (level == CompLogLevelFatal || level == CompLogLevelError)
	urgency = NOTIFY_URGENCY_CRITICAL;
    else if (level == CompLogLevelWarn)
	urgency = NOTIFY_URGENCY_NORMAL;
    else
	urgency = NOTIFY_URGENCY_LOW;

    notify_notification_set_urgency (n, urgency);

    notify_notification_show (n, NULL);
    g_object_unref (G_OBJECT (n));

    screen->logMessage (component, level, message);
}
예제 #12
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);
}
예제 #13
0
static int Notify( vlc_object_t *p_this, const char *psz_temp )
{
    NotifyNotification * notification;
    notification = notify_notification_new( _("Now Playing"),
                                            psz_temp,
                                            DATA_PATH "/vlc48x48.png",NULL);
    notify_notification_set_timeout( notification,
                                     config_GetInt(p_this, "notify-timeout") );
    notify_notification_set_urgency( notification, NOTIFY_URGENCY_LOW );
    notify_notification_show( notification, NULL);
    return VLC_SUCCESS;
}
예제 #14
0
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);
}
예제 #15
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);
}
예제 #16
0
void notify (void) {
	NotifyNotification *notify;
	GError *error_notify = NULL;

	entry_text = gtk_entry_get_text (GTK_ENTRY (entry));
	if(g_strcmp0 (entry_text, "Notification text") != 0)
		notify = notify_notification_new (entry_text, NULL, "clocks");
	else
		notify = notify_notification_new (_("Time is up!"), NULL, "clocks");
	notify_notification_set_category (notify, "GTimeUtils");
	notify_notification_set_urgency (notify, NOTIFY_URGENCY_NORMAL);
	notify_notification_show (notify, &error_notify);
	if(error_notify)
		g_fprintf (stderr, "Can not initialize notification: %s\n", error_notify->message);

	ca_context_play(sound, 0, CA_PROP_APPLICATION_NAME, "Gtimer", CA_PROP_EVENT_ID, "complete-copy", CA_PROP_MEDIA_ROLE, "notification",  CA_PROP_APPLICATION_ICON_NAME, "clocks", CA_PROP_CANBERRA_CACHE_CONTROL, "never", NULL);
}
예제 #17
0
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);

}
예제 #18
0
void send_notify (std::string message, int timeout)
{
    NotifyNotification *notification;

    // Create notification and set properties
    notification = notify_notification_new (settings.getTitle ().c_str (),
                                            message.c_str (), NULL);
    notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
    notify_notification_set_timeout (notification, timeout * 1000);

    // Show the notification.
    GError *error = NULL;
    notify_notification_show (notification, &error);

    // Add to the vector.
    notifications.push_back (*notification);
}
static void
_import_clicked_cb (MxButton             *button,
                    MpdStorageDeviceTile *self)
{
  MpdStorageDeviceTilePrivate *priv = GET_PRIVATE (self);
  char const  *program = NULL;
  GError      *error = NULL;

  if (0 == g_strcmp0 ("x-content/image-dcf", priv->mime_type))
  {
    /* Photo devices are handled by GThumb.
     * + gphoto2 devices are launched through gthumb-import.desktop with
     *   its Exec hack for exclusive device access.
     * + others (USB cameras) don't work with that hack, so GThumb is
     *   launched in import mode manually. */
    char *scheme = g_uri_parse_scheme (priv->mount_point);
    program = "gthumb";
    if (0 == g_strcmp0 ("gphoto2", scheme))
      launch_gthumb_import (self, &error);
    else
      launch_import (self, program, "--import-photos", &error);
  } else
  {
    program = "banshee-1";
    launch_import (self, program, "--show-import-media", &error);
  }

  if (error)
  {
    NotifyNotification *note;
    char *message = g_strdup_printf (_("Could not run \"%s\""), program);

    note = notify_notification_new (_("Import error"), message, NULL);
    notify_notification_set_urgency (note, NOTIFY_URGENCY_CRITICAL);

    notify_notification_show (note, NULL);
    g_signal_connect (note, "closed",
                      G_CALLBACK (g_object_unref), NULL);

    g_free (message);
    g_clear_error (&error);
  } else {
    g_signal_emit_by_name (self, "request-hide");
  }
}
예제 #20
0
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);
}
예제 #21
0
파일: gnac-ui.c 프로젝트: GNOME/gnac
static void
gnac_ui_notify(const gchar *msg)
{
#ifdef HAVE_LIBNOTIFY

  NotifyNotification *notification = notify_notification_new(
      PACKAGE_NAME, msg, PACKAGE);

  notify_notification_set_timeout(notification, NOTIFY_EXPIRES_DEFAULT);
  notify_notification_set_urgency(notification, NOTIFY_URGENCY_NORMAL);

  notify_notification_show(notification, NULL);

#else /* HAVE_LIBNOTIFY */

  libgnac_info(msg);

#endif /* !HAVE_LIBNOTIFY */
}
예제 #22
0
bool notify(gpointer user_data)
{
    timeout=false;
    tres* lastres = (tres*)user_data;
    NotifyNotification *n;
    char str[20];
    if (lastres->time>POTIME)
        sprintf(str,"Time's up!(%d)",lastres->time-POTIME);
    else
        sprintf(str,"Time's up!");
    n = notify_notification_new (APPNAME,str, NULL);
    notify_notification_set_urgency(n,NOTIFY_URGENCY_CRITICAL);
    notify_notification_add_action(n,"M", "More",(NotifyActionCallback)timeup,lastres,NULL);
    notify_notification_add_action(n,"G", "Good",(NotifyActionCallback)timeup,lastres,NULL);
    g_signal_connect (n, "closed", G_CALLBACK(quit), NULL);
    notify_notification_set_timeout(n,0); //3 seconds
    notify_notification_show(n,NULL);
    return FALSE;
}
예제 #23
0
void Notification::show()
{
    assert(note == nullptr);
    assert(name.size());

    notify_init(name.c_str());

    note = notify_notification_new(name.c_str(), content.c_str(), icon.c_str());
    notify_notification_set_timeout(note, timeout.count());
    notify_notification_set_category(note, "Testing Notifications");
    notify_notification_set_urgency(note, NOTIFY_URGENCY_NORMAL);

    GError* error = nullptr;
    notify_notification_show(note, &error);

    if (error != nullptr)
    {
        throw std::runtime_error("error during 'notify_notification_show");
    }
}
예제 #24
0
static int Notify( vlc_object_t *p_this, const char *psz_temp, GdkPixbuf *pix,
                   intf_thread_t *p_intf )
{
    intf_sys_t *p_sys = p_intf->p_sys;

    NotifyNotification * notification;

    /* Close previous notification if still active */
    if( p_sys->notification )
    {
        GError *p_error = NULL;
        notify_notification_close( p_sys->notification, &p_error );
        g_object_unref( p_sys->notification );
    }

    notification = notify_notification_new( _("Now Playing"),
                                            psz_temp, NULL, NULL );
    notify_notification_set_timeout( notification,
                                var_InheritInteger(p_this, "notify-timeout") );
    notify_notification_set_urgency( notification, NOTIFY_URGENCY_LOW );
    if( pix )
    {
        notify_notification_set_icon_from_pixbuf( notification, pix );
        gdk_pixbuf_unref( pix );
    }

    /* Adds previous and next buttons in the notification if actions are supported. */
    if( p_sys->b_has_actions )
    {
      notify_notification_add_action( notification, "previous", _("Previous"), Prev,
                                      (gpointer*)p_intf, NULL );
      notify_notification_add_action( notification, "next", _("Next"), Next,
                                      (gpointer*)p_intf, NULL );
    }

    notify_notification_show( notification, NULL);

    /* Stores the notification to be able to close it */
    p_sys->notification = notification;
    return VLC_SUCCESS;
}
예제 #25
0
static void
update_notification (GduSdMonitor        *monitor,
                     GList               *problems,
                     NotifyNotification **notification,
                     const gchar         *title,
                     const gchar         *text,
                     const gchar         *icon_name,
                     const gchar         *action,
                     const gchar         *action_label)
{
  if (g_list_length (problems) > 0)
    {
      /* it could be the notification has already been presented, in that
       * case, don't show another one
       */
      if (*notification == NULL)
        {
          *notification = notify_notification_new (title, text, icon_name);
          notify_notification_set_urgency (*notification, NOTIFY_URGENCY_CRITICAL);
          notify_notification_set_timeout (*notification, NOTIFY_EXPIRES_NEVER);
          notify_notification_set_hint_string (*notification, "desktop-entry", "gnome-disks");
          notify_notification_add_action (*notification,
                                          action,
                                          action_label,
                                          (NotifyActionCallback) on_examine_action_clicked,
                                          monitor,
                                          NULL);
          notify_notification_show (*notification, NULL);
        }
    }
  else
    {
      if (*notification != NULL)
        {
          notify_notification_close (*notification, NULL);
          g_clear_object (notification);
        }
    }
}
예제 #26
0
파일: notification.c 프로젝트: Rocik/memp
NotifyNotification *sendNotify(char *title, char *message, pid_t *p_PID)
{
	NotifyNotification *notification;
	
	notification = notify_notification_new(title, message, iconType);
	
	notify_notification_set_urgency(notification, NOTIFY_URGENCY_CRITICAL);
	notify_notification_set_timeout(notification, NOTIFY_EXPIRES_NEVER);
	
    notify_notification_add_action(notification, "button", "Kill this process",
	   (NotifyActionCallback)killApp, p_PID, NULL
	);

    if (!notify_notification_show(notification, &error)) {
		g_error("Sending notification failed: %s", error->message);
        g_error_free(error);
    }
	
	g_signal_connect(notification, "closed", G_CALLBACK(notifyClosed), NULL);
	
	isNotifyActive = 1;
	return notification;
}
예제 #27
0
파일: notify.c 프로젝트: gabrield/lnotify
static int
set_urgency (lua_State * L)
{
  int l = 0;
  NotifyUrgency level = 0;
  NotifyNotification *notify = (NotifyNotification *) lua_touserdata (L, 1);
  if (!notify) luaL_argerror(L, 1, "Unknown type");

  if (lua_isnumber(L, 2)) {
      l = lua_tointeger(L, 2);
  }
  else {
      const char *lstr = luaL_checkstring(L, 2);
      if      (strcmp(lstr, "low") == 0)      l = 1;
      else if (strcmp(lstr, "normal") == 0)   l = 2;
      else if (strcmp(lstr, "critical") == 0) l = 3;
      else luaL_argerror(L, 2, lstr);
  }

  switch(l) {
    case 1:
      level = NOTIFY_URGENCY_LOW;
      break;
    case 2:
      level = NOTIFY_URGENCY_NORMAL;
      break;
    case 3:
      level = NOTIFY_URGENCY_CRITICAL;
      break;
    default:
      luaL_argerror(L, 2, lua_tolstring(L, 2, NULL)); /* coerce int to string */
  }

  notify_notification_set_urgency (notify, level);
  return 0;
}
예제 #28
0
파일: cbatticon.c 프로젝트: gapan/cbatticon
static void notify_message (NotifyNotification **notification, gchar *summary, gchar *body, gint timeout, NotifyUrgency urgency)
{
    g_return_if_fail (notification != NULL);
    g_return_if_fail (summary != NULL);

    if (configuration.hide_notification == TRUE) {
        return;
    }

    if (*notification == NULL) {
#if NOTIFY_CHECK_VERSION (0, 7, 0)
        *notification = notify_notification_new (summary, body, NULL);
#else
        *notification = notify_notification_new (summary, body, NULL, NULL);
#endif
    } else {
        notify_notification_update (*notification, summary, body, NULL);
    }

    notify_notification_set_timeout (*notification, timeout);
    notify_notification_set_urgency (*notification, urgency);

    notify_notification_show (*notification, NULL);
}
static void
notify (const gchar *title,
		const gchar *body,
		PurpleBuddy *buddy,
		PurpleConversation *conv)
{
	NotifyNotification *notification = NULL;
	GdkPixbuf *icon;
	PurpleBuddyIcon *buddy_icon;
	gchar *tr_body;
	PurpleContact *contact;

	if (buddy)
		contact = purple_buddy_get_contact (buddy);
	else
		contact = NULL;

	if (body)
		tr_body = truncate_escape_string (body, 60);
	else
		tr_body = NULL;

	if (!conv && buddy)
		conv = purple_find_conversation_with_account (PURPLE_CONV_TYPE_ANY, buddy->name, buddy->account);

	if (conv && conv->ui_ops && conv->ui_ops->has_focus) {
	    if (conv->ui_ops->has_focus(conv) == TRUE) {
		/* do not notify if the conversation is currently in focus */
		return;
	    }
	}

	if (contact)
		notification = g_hash_table_lookup (buddy_hash, contact);
	else if (conv)
		notification = g_hash_table_lookup (buddy_hash, conv);
	else
		notification = NULL;

	if (notification != NULL) {
		notify_notification_update (notification, title, tr_body, NULL);
		notify_notification_set_timeout(notification, purple_prefs_get_int("/plugins/gtk/libnotify/timeout"));
		/* this shouldn't be necessary, file a bug */
		notify_notification_show (notification, NULL);

		purple_debug_info (PLUGIN_ID, "notify(), update: "
						 "title: '%s', body: '%s', buddy: '%s'\n",
						 title, tr_body, buddy ? best_name (buddy) : "");

		g_free (tr_body);
		return;
	}
#ifdef LIBNOTIFY_07
	notification = notify_notification_new (title, tr_body, NULL);
#else
	notification = notify_notification_new (title, tr_body, NULL, NULL);
#endif
	purple_debug_info (PLUGIN_ID, "notify(), new: "
					 "title: '%s', body: '%s', buddy: '%s'\n",
					 title, tr_body, buddy ? best_name (buddy) : "");

	g_free (tr_body);

	if (buddy)
		buddy_icon = purple_buddy_get_icon (buddy);
	else
		buddy_icon = NULL;

	if (buddy_icon) {
		icon = pixbuf_from_buddy_icon (buddy_icon);
		purple_debug_info (PLUGIN_ID, "notify(), has a buddy icon.\n");
	} else if (buddy) {
		icon = pidgin_create_prpl_icon (buddy->account, 1);
		purple_debug_info (PLUGIN_ID, "notify(), has a prpl icon.\n");
	} else if (conv) {
		icon = pidgin_create_prpl_icon (conv->account, 1);
		purple_debug_info (PLUGIN_ID, "notify(), has a prpl icon.\n");
	} else {
		icon = NULL;
		purple_debug_info (PLUGIN_ID, "notify(), has no icon.\n");
	}

	if (icon) {
		notify_notification_set_icon_from_pixbuf (notification, icon);
		g_object_unref (icon);
	} else {
		purple_debug_warning (PLUGIN_ID, "notify(), couldn't find any icon!\n");
	}

	if (contact)
		g_hash_table_insert (buddy_hash, contact, notification);
	else if (conv)
		g_hash_table_insert (buddy_hash, conv, notification);

	g_object_set_data (G_OBJECT(notification), "contact", contact);
	g_object_set_data (G_OBJECT(notification), "conv", conv);
	g_object_set_data (G_OBJECT(notification), "buddy", buddy);

	g_signal_connect (notification, "closed", G_CALLBACK(closed_cb), NULL);

	notify_notification_set_urgency (notification, NOTIFY_URGENCY_NORMAL);

	notify_notification_add_action (notification, "show", _("Show"), action_cb, NULL, NULL);

	notify_notification_set_timeout(notification, purple_prefs_get_int("/plugins/gtk/libnotify/timeout"));
	if (!notify_notification_show (notification, NULL)) {
		purple_debug_error (PLUGIN_ID, "notify(), failed to send notification\n");
	}

}
예제 #30
0
static void
_notify(const char * const message, int timeout,
    const char * const category)
{
#ifdef HAVE_LIBNOTIFY

    if (notify_is_initted()) {
        NotifyNotification *notification;
        notification = notify_notification_new("Profanity", message, NULL);
        notify_notification_set_timeout(notification, timeout);
        notify_notification_set_category(notification, category);
        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);
        }
    } else {
        log_error("Libnotify initialisation error.");
    }
#endif
#ifdef PLATFORM_CYGWIN
    NOTIFYICONDATA nid;
    nid.cbSize = sizeof(NOTIFYICONDATA);
    //nid.hWnd = hWnd;
    nid.uID = 100;
    nid.uVersion = NOTIFYICON_VERSION;
    //nid.uCallbackMessage = WM_MYMESSAGE;
    nid.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    strncpy(nid.szTip, "Tray Icon", 10);
    nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
    Shell_NotifyIcon(NIM_ADD, &nid);

    // For a Ballon Tip
    nid.uFlags = NIF_INFO;
    strncpy(nid.szInfoTitle, "Profanity", 10); // Title
    strncpy(nid.szInfo, message, 256); // Copy Tip
    nid.uTimeout = timeout;  // 3 Seconds
    nid.dwInfoFlags = NIIF_INFO;

    Shell_NotifyIcon(NIM_MODIFY, &nid);
#endif
#ifdef HAVE_OSXNOTIFY
    GString *notify_command = g_string_new("terminal-notifier -title 'Profanity' -message '");
    g_string_append(notify_command, message);
    g_string_append(notify_command, "'");

    char *term_name = getenv("TERM_PROGRAM");
    char *app_id = NULL;
    if (g_strcmp0(term_name, "Apple_Terminal") == 0) {
        app_id = "com.apple.Terminal";
    } else if (g_strcmp0(term_name, "iTerm.app") == 0) {
        app_id = "com.googlecode.iterm2";
    }

    if (app_id != NULL) {
        g_string_append(notify_command, " -sender ");
        g_string_append(notify_command, app_id);
    }

    int res = system(notify_command->str);
    if (res == -1) {
        log_error("Could not send desktop notificaion.");
    }

    g_string_free(notify_command, TRUE);
#endif
}