Example #1
0
int main() {
	char fullpath[100], text[100];
	char *buf = NULL, *sub = NULL, *state = NULL;
	
	conn = mpd_connection_new(NULL, 0, 10000);
	notify = notify_notification_new(NULL, NULL, NULL);
	notify_init("mpdnotify");

	while(mpd_run_idle_mask(conn, MPD_IDLE_PLAYER)) {
		mpd_command_list_begin(conn, true);
		mpd_send_status(conn);
		mpd_send_current_song(conn);
		mpd_command_list_end(conn);

		status = mpd_recv_status(conn);
		if(mpd_status_get_state(status) == MPD_STATE_PLAY)
			state = "Playing:";
		else if(mpd_status_get_state(status) == MPD_STATE_PAUSE)
			state = "Paused:";
		else
			state = "Stopped:";
		mpd_response_next(conn);
		song = mpd_recv_song(conn);

		if(song) {
			artist = mpd_song_get_tag(song, MPD_TAG_ARTIST, 0);
			title = mpd_song_get_tag(song, MPD_TAG_TITLE, 0);
			path = mpd_song_get_uri(song);

			sprintf(text, "%s - %s", artist, title);

			buf = fullpath;
			sub = strrchr(path, '/');
			buf = strcpy(buf, mpdroot);
			buf = strncat(buf, path, strlen(path) - strlen(sub) + 1);
			buf = strcat(buf, albumart);
			icon = gdk_pixbuf_new_from_file(fullpath, NULL);

			if(icon)
				notify_notification_update(notify, state, text, NULL);
			else
				notify_notification_update(notify, state, text, "sound");
			notify_notification_set_icon_from_pixbuf(notify, icon);
			notify_notification_show(notify, &gerror);

			mpd_song_free(song);
		}
		mpd_response_finish(conn);
	}
	mpd_connection_free(conn);
	notify_uninit();
	return 0;
}
Example #2
0
File: mailme.c Project: jku/mailme
static void update_notification (NotifyNotification *note,
                                 const char         *display_name,
                                 guint               unread_count,
                                 guint               last_unread_count)
{
  GError *error = NULL;

  if (unread_count == 0) {
    if (!notify_notification_close (note, &error)) {
      g_printerr ("Failed to close notification: %s", error->message);
      g_error_free (error);
    }
  } else {
    char *msg;

    /* Translators: Notification text */
    msg = g_strdup_printf (ngettext ("One unread mail on %1$s",
                                     "%2$d unread mails on %1$s",
                                     unread_count),
                           display_name, unread_count);
    notify_notification_update (note, msg, NULL, "mail-unread");

    /* FIXME: at least gnome-shell does not update the title unless
     * we _show(), but we don't really want to do that when unread count
     * is going down... */
    if (unread_count > last_unread_count)
      if (!notify_notification_show (note, &error)) {
        g_printerr ("Failed to show notification: %s", error->message);
        g_error_free (error);
      }
    g_free (msg);
  }
}
Example #3
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);
}
Example #4
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);
}
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
_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);
}
Example #7
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;
		}
	}
}
Example #8
0
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);
}
Example #9
0
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);
}
Example #10
0
File: main.c Project: hluk/red
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;
}
Example #11
0
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;
}
Example #12
0
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");
	}
}
Example #13
0
void notify_update(notify_handle_t h, const char* msg, const char* body, const char* icon)
{
    NotifyNotification* n = (NotifyNotification*) h;

    if(!notify_notification_update(n, msg, body, icon))
        g_error("[notify] invalid arguments passed to notify_update()");

    notify_show(n);
}
Example #14
0
LIBNOTIFY_API NotifyNotification* notify_notification_new_with_status_icon(
	const gchar *summary, const gchar *body,
	const gchar *icon, GtkStatusIcon *status_icon)
{
	UNREFERENCED_PARAMETER(status_icon);

	if(notification_data)
		notify_notification_update(notification_data, summary, body, icon);

	return notification_data;
}
Example #15
0
void updateNotify(NotifyNotification *notification, char *title, char *message)
{
	if (notify_notification_update(notification, title, message, iconType) == FALSE) {
		g_error("updateNotify: wrong parameters");
		g_error_free(error);
	}
	
	if (!notify_notification_show(notification, &error)) {
		g_error("Updating notification failed: %s", error->message);
        g_error_free(error);
    }
}
Example #16
0
int box_silent_notify2(ToxWindow* self, uint64_t flags, int id, const char* format, ...)
{
    /* Always do colored notify */
    if (self) {
        if (flags & NT_WNDALERT_0) self->alert = WINDOW_ALERT_0;
        else if ( (flags & NT_WNDALERT_1) && (!self->alert || self->alert > WINDOW_ALERT_0) ) self->alert = WINDOW_ALERT_1;
        else if ( (flags & NT_WNDALERT_2) && (!self->alert || self->alert > WINDOW_ALERT_1) ) self->alert = WINDOW_ALERT_2;
    }
    
    if ((flags & NT_RESTOL && Control.cooldown > time(NULL)) ||
       ((flags & NT_NOFOCUS && Control.this_window == get_focused_window_id()) ))
        return -1;
        
#ifdef _BOX_NOTIFY
    control_lock();
    
    if (id < 0 || id >= ACTIVE_NOTIFS_MAX || !actives[id].box || actives[id].size >= 128 ) {
        control_unlock();
        return -1;
    }
        
    
    va_list __ARGS__; va_start (__ARGS__, format);
    vsnprintf (actives[id].messages[actives[id].size], 127, format, __ARGS__);
    va_end (__ARGS__);
    
    if (strlen(actives[id].messages[actives[id].size]) > 124)
        strcpy(actives[id].messages[actives[id].size] + 124, "...");
    
    actives[id].size ++;
    actives[id].n_timeout = time(NULL) + Control.notif_timeout / 1000;
    
    char formated[128 * 129] = {'\0'};
    
    int i = 0;
    for (; i <actives[id].size; i ++) {
        strcat(formated, actives[id].messages[i]);
        strcat(formated, "\n");
    }
    
    formated[strlen(formated) - 1] = '\0';
    
    notify_notification_update(actives[id].box, actives[id].title, formated, NULL);
    notify_notification_show(actives[id].box, NULL);
    
    control_unlock();
    
    return id;
#else
    return -1;
#endif
}
Example #17
0
static void
on_clicked(GtkButton *button, void *user_data)
{
	gchar *buf;
	NotifyNotification *n = NOTIFY_NOTIFICATION(user_data);

	count++;
	buf = g_strdup_printf("You clicked the button %i times", count);
	notify_notification_update(n, "Widget Attachment Test", buf, NULL);
	g_free(buf);

	notify_notification_show(n, NULL);
}
Example #18
0
void notify (gchar* title, gchar* artist, gchar *album)
{
	if (title && artist && album) {
		notify_notification_update (Notification,
									title,
									g_strconcat ("by <b>", artist, "</b>",
												 "\nfrom ",
												 "<b>", album, "</b>",
												 NULL),
									NULL);
	}
	notify_notification_show (Notification, NULL);
}
Example #19
0
/**
 * Send a volume notification. 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_volume(gint level, gboolean muted)
{
	static NotifyNotification *notification = NULL;
	gchar *summary, *icon, *active_card_name;
	const char *active_channel;
	GError *error = NULL;

	active_card_name = (alsa_get_active_card())->name;
	active_channel = alsa_get_active_channel();

	if (notification == NULL) {
		notification = NOTIFICATION_NEW("", NULL, NULL);
		notify_notification_set_timeout(notification, noti_timeout);
		NOTIFICATION_SET_HINT_STRING(notification,
					     "x-canonical-private-synchronous", "");
	}

	if (level < 0)
		level = 0;
	if (level > 100)
		level = 100;

	if (muted)
		summary = g_strdup("Volume muted");
	else
		summary =
			g_strdup_printf("%s (%s)\nVolume: %d%%\n",
					active_card_name, active_channel, level);

	if (muted)
		icon = "audio-volume-muted";
	else if (level == 0)
		icon = "audio-volume-off";
	else if (level < 33)
		icon = "audio-volume-low";
	else if (level < 66)
		icon = "audio-volume-medium";
	else
		icon = "audio-volume-high";

	notify_notification_update(notification, summary, NULL, icon);
	NOTIFICATION_SET_HINT_INT32(notification, "value", level);

	if (!notify_notification_show(notification, &error)) {
		report_error(_("Could not send notification: %s"), error->message);
		g_error_free(error);
	}

	g_free(summary);
}
Example #20
0
static gboolean notification_trayicon_popup_add_msg(MsgInfo *msginfo,
						    NotificationFolderType nftype)
{
  gchar *summary;
  gchar *utf8_str;
  gboolean retval;
  GdkPixbuf *pixbuf;

  g_return_val_if_fail(msginfo, FALSE);

  if(!popup.notification)
    return notification_trayicon_popup_create(msginfo,nftype);

  /* Count messages */
  notification_trayicon_popup_count_msgs(nftype);

  if(popup.msg_path) {
    g_free(popup.msg_path);
    popup.msg_path = NULL;
  }

  summary  = notification_trayicon_popup_assemble_summary();
  utf8_str = notification_trayicon_popup_assemble_body(msginfo);

  /* make sure we show a logo on many msg arrival */
  pixbuf = notification_pixbuf_get(NOTIFICATION_CM_LOGO_64x64);
  if(pixbuf)
    notify_notification_set_icon_from_pixbuf(popup.notification, pixbuf);

  retval = notify_notification_update(popup.notification, summary,
				      utf8_str, NULL);
  g_free(summary);
  g_free(utf8_str);
  if(!retval) {
    debug_print("Notification Plugin: Failed to update notification.\n");
    return FALSE;
  }
  /* Show the popup */
  notify_notification_set_hint_string(popup.notification, "desktop-entry", "claws-mail");
  if(!notify_notification_show(popup.notification, &(popup.error))) {
    debug_print("Notification Plugin: Failed to send updated notification: "
		"%s\n",	popup.error->message);
    g_clear_error(&(popup.error));
    return FALSE;
  }

  debug_print("Notification Plugin: Popup successfully modified "
	      "with libnotify.\n");

  return TRUE;
}
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;
        }
    }
}
Example #22
0
int box_notify2(ToxWindow* self, Notification notif, uint64_t flags, int id, const char* format, ...)
{
    if (notifications_are_disabled(flags)) {
        tab_notify(self, flags);
        return -1;
    }

#ifdef BOX_NOTIFY

    if (sound_notify2(self, notif, flags, id) == -1)
        return -1;

    control_lock();

    if (!actives[id].box || actives[id].size >= MAX_BOX_MSG_LEN + 1) {
        control_unlock();
        return -1;
    }

    va_list __ARGS__; va_start (__ARGS__, format);
    vsnprintf (actives[id].messages[actives[id].size], MAX_BOX_MSG_LEN, format, __ARGS__);
    va_end (__ARGS__);

    if (strlen(actives[id].messages[actives[id].size]) > MAX_BOX_MSG_LEN - 3)
        strcpy(actives[id].messages[actives[id].size] + MAX_BOX_MSG_LEN - 3, "...");

    actives[id].size++;
    actives[id].n_timeout = get_unix_time() + Control.notif_timeout / 1000;

    char formated[128 * 129] = {'\0'};

    int i = 0;
    for (; i <actives[id].size; i ++) {
        strcat(formated, actives[id].messages[i]);
        strcat(formated, "\n");
    }

    formated[strlen(formated) - 1] = '\0';

    notify_notification_update(actives[id].box, actives[id].title, formated, NULL);
    notify_notification_show(actives[id].box, NULL);

    control_unlock();

    return id;
#else
    return sound_notify2(self, notif, flags, id);
#endif
}
Example #23
0
int box_notify2(ToxWindow* self, Notification notif, uint64_t flags, int id, const char* format, ...)
{
    if ((flags & NT_RESTOL && Control.cooldown > time(NULL)) ||
       ((flags & NT_NOFOCUS && Control.this_window == get_focused_window_id()) ))
        return -1;
        
#ifdef _BOX_NOTIFY
    
    if (sound_notify2(self, notif, flags, id) == -1)
        return -1;
    
    control_lock();
    
    if (!actives[id].box || actives[id].size >= 128 ) {
        control_unlock();
        return -1;
    }
    
    
    va_list __ARGS__; va_start (__ARGS__, format);
    vsnprintf (actives[id].messages[actives[id].size], 127, format, __ARGS__);
    va_end (__ARGS__);
    
    if (strlen(actives[id].messages[actives[id].size]) > 124)
        strcpy(actives[id].messages[actives[id].size] + 124, "...");
    
    actives[id].size ++;
    actives[id].n_timeout = time(NULL) + Control.notif_timeout / 1000;
    
    char formated[128 * 129] = {'\0'};
    
    int i = 0;
    for (; i <actives[id].size; i ++) {
        strcat(formated, actives[id].messages[i]);
        strcat(formated, "\n");
    }
    
    formated[strlen(formated) - 1] = '\0';
    
    notify_notification_update(actives[id].box, actives[id].title, formated, NULL);
    notify_notification_show(actives[id].box, NULL);
    
    control_unlock();
    
    return id;
#else
    return sound_notify2(self, notif, flags, id);
#endif
}
Example #24
0
LIBNOTIFY_API NotifyNotification* notify_notification_new(
	const char *summary, const char *body,
	const char *icon)
{
	if(!notification_thread) return NULL;

	NotifyNotification *notification_data = (NotifyNotification*) malloc(sizeof(NotifyNotification));
	if(notification_data)
	{
		memset(notification_data, 0, sizeof(NotifyNotification));
		notify_notification_update(notification_data, summary, body, icon);
	}

	return notification_data;
}
Example #25
0
/**
 * Send a text notification. 
 *
 * @param summary the notification summary
 * @param _body the notification body
 */
void do_notify_text(const gchar *summary, const gchar *body) {
  static NotifyNotification *notification = NULL;
  GError *error = NULL;

  if (notification == NULL) {
    notification = NOTIFICATION_NEW("", NULL, NULL);
    notify_notification_set_timeout(notification, noti_timeout * 2);
    NOTIFICATION_SET_HINT_STRING(notification,"x-canonical-private-synchronous","");
  }

  notify_notification_update(notification,summary,body,NULL);

  if (!notify_notification_show(notification,&error)) {
    g_warning("Could not send notification: %s",error->message);
    report_error(_("Could not send notification: %s\n"),error->message);
    g_error_free(error);
  }
}
Example #26
0
int
main ()
{
        NotifyNotification *n;
        GError             *error;
        error = NULL;

#if !GLIB_CHECK_VERSION (2, 36, 0)
        g_type_init ();
#endif

        notify_init ("Replace Test");

        n = notify_notification_new ("Summary",
                                     "First message",
                                     NULL);  //no icon

        notify_notification_set_timeout (n, 0); //don't timeout

        if (!notify_notification_show (n, &error)) {
                fprintf (stderr, "failed to send notification: %s\n",
                         error->message);
                g_error_free (error);
                return 1;
        }

        sleep (3);

        notify_notification_update (n,
                                    "Second Summary",
                                    "First mesage was replaced",
                                    NULL);
        notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT);

        if (!notify_notification_show (n, &error)) {
                fprintf (stderr,
                         "failed to send notification: %s\n",
                         error->message);
                g_error_free (error);
                return 1;
        }

        return 0;
}
Example #27
0
void Notification::setMessage(QString summary, QString text, QString icon)
{
	std::string sum, txt, ico;

	sum = summary.toStdString();
	txt = text.toStdString();
	ico = icon.toStdString();

	if (!m_notif)
	{
		m_notif = notify_notification_new(sum.c_str(), txt.c_str(), ico.c_str());
		if (!m_notif)
			throw RuntimeException(tr("Failed to create a notification"));
	}
	else
	{
		if (!notify_notification_update(m_notif, sum.c_str(), txt.c_str(), ico.c_str()))
			throw RuntimeException(tr("Failed to update a notification"));
	}
}
Example #28
0
static void
status_icon_update_notification (EmpathyStatusIcon *icon)
{
	EmpathyStatusIconPriv *priv = GET_PRIV (icon);
	GdkPixbuf *pixbuf = NULL;

	if (!empathy_notification_is_enabled ()) {
		/* always close the notification if this happens */
		notification_close_helper (priv);
		return;
	}

	if (priv->event) {
		pixbuf = empathy_misc_get_pixbuf_for_notification (priv->event->contact,
								   priv->event->icon_name);

		if (priv->notification) {
			notify_notification_update (priv->notification,
						    priv->event->header, priv->event->message,
						    NULL);
		} else {
			priv->notification = notify_notification_new_with_status_icon
				(priv->event->header, priv->event->message, NULL, priv->icon);
			notify_notification_set_timeout (priv->notification,
							 NOTIFY_EXPIRES_DEFAULT);

			g_signal_connect (priv->notification, "closed",
					  G_CALLBACK (status_icon_notification_closed_cb), icon);

 		}
		/* if icon doesn't exist libnotify will crash */
		if (pixbuf != NULL)
			notify_notification_set_icon_from_pixbuf (priv->notification,
							  pixbuf);
		notify_notification_show (priv->notification, NULL);

		g_object_unref (pixbuf);
	} else {
		notification_close_helper (priv);
	}
}
static void
progress_ui_handler_update_notification (NautilusProgressUIHandler *self)
{
	gchar *body;

	progress_ui_handler_ensure_notification (self);

	body = g_strdup_printf (ngettext ("%'d file operation active",
					  "%'d file operations active",
					  self->priv->active_infos),
				self->priv->active_infos);

	notify_notification_update (self->priv->progress_notification,
				    _("File Operations"),
				    body,
				    NULL);

	notify_notification_show (self->priv->progress_notification, NULL);

	g_free (body);
}
Example #30
0
void 
xvd_notify_notification(XvdInstance *Inst, 
						gchar* icon, 
						gint value)
{
	GError* error						= NULL;
	gchar*  title						= NULL;

	if ((icon != NULL) && (g_strcmp0(icon, "audio-volume-muted") == 0)) {
		// TRANSLATORS: this is the body of the ATK interface of the volume notifications. This is the case when volume is muted
		title = g_strdup ("Volume is muted");
	}
	else {
		// TRANSLATORS: %d is the volume displayed as a percent, and %c is replaced by '%'. If it doesn't fit in your locale feel free to file a bug.
		title = g_strdup_printf ("Volume is at %d%c", value, '%');
	}
	
	notify_notification_update (Inst->notification,
				title,
				NULL,
				icon);
	
	g_free (title);
	
	if (Inst->gauge_notifications) {
		notify_notification_set_hint_int32 (Inst->notification,
							"value",
							value);
		notify_notification_set_hint_string (Inst->notification,
							 "x-canonical-private-synchronous",
							 "");
	}
	
	if (!notify_notification_show (Inst->notification, &error))
	{
		g_warning ("Error while sending notification : %s\n", error->message);
		g_error_free (error);
	}
}