コード例 #1
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;
}
コード例 #2
0
ファイル: test-basic.c プロジェクト: Distrotech/libnotify
int
main ()
{
        NotifyNotification *n;

        notify_init ("Basics");

        /* Long summary */
        n = notify_notification_new ("Summary that is very long 8374983278r32j4 rhjjfh dw8f 43jhf 8ds7 ur2389f jdbjkt h8924yf jkdbjkt 892hjfiHER98HEJIF BDSJHF hjdhF JKLH 890YRHEJHFU 89HRJKSHdd dddd ddddd dddd ddddd dddd ddddd dddd dddd ddd ddd dddd Fdd d ddddd dddddddd ddddddddhjkewdkjsjfjk sdhkjf hdkj dadasdadsa adsd asd sd saasd fadskfkhsjf hsdkhfkshfjkhsd kjfhsjdkhfj ksdhfkjshkjfsd sadhfjkhaskd jfhsdajkfhkjs dhfkjsdhfkjs adhjkfhasdkj fhdsakjhfjk asdhkjkfhd akfjshjfsk afhjkasdhf jkhsdaj hf kjsdfahkfh sakjhfksdah kfdashkjf ksdahfj shdjdh",
                                     "Content",
                                     NULL);
        notify_notification_set_timeout (n, 3000);      //3 seconds

        if (!notify_notification_show (n, NULL)) {
                fprintf (stderr, "failed to send notification\n");
                return 1;
        }

        g_object_unref (G_OBJECT (n));

        /* Long message */
        n = notify_notification_new ("Summary",
                                     "Content that is very long 8374983278r32j4 rhjjfh dw8f 43jhf 8ds7 ur2389f jdbjkt h8924yf jkdbjkt 892hjfiHER98HEJIF BDSJHF hjdhF JKLH 890YRHEJHFU 89HRJKSHdd dddd ddddd dddd ddddd dddd ddddd dddd dddd ddd ddd dddd Fdd d ddddd dddddddd ddddddddhjkewdkjsjfjk sdhkjf hdkj dadasdadsa adsd asd sd saasd fadskfkhsjf hsdkhfkshfjkhsd kjfhsjdkhfj ksdhfkjshkjfsd sadhfjkhaskd jfhsdajkfhkjs dhfkjsdhfkjs adhjkfhasdkj fhdsakjhfjk asdhkjkfhd akfjshjfsk afhjkasdhf jkhsdaj hf kjsdfahkfh sakjhfksdah kfdashkjf ksdahfj shdjdh",
                                     NULL);
        notify_notification_set_timeout (n, 3000);      //3 seconds

        if (!notify_notification_show (n, NULL)) {
                fprintf (stderr, "failed to send notification\n");
                return 1;
        }

        g_object_unref (G_OBJECT (n));

        /* Summary only */
        n = notify_notification_new ("Summary only there is no message content",
                                     NULL,
                                     NULL);
        notify_notification_set_timeout (n, NOTIFY_EXPIRES_NEVER);

        if (!notify_notification_show (n, NULL)) {
                fprintf (stderr, "failed to send notification\n");
                return 1;
        }

        g_object_unref (G_OBJECT (n));

        return 0;
}
コード例 #3
0
ファイル: mca_info_panel.c プロジェクト: rbemmanuel/kwama
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);
}
コード例 #4
0
/*
 * Custom code called right after loading the plugin. Returns 0 on success, 1 on failure.
 * If the function returns 1 on failure, the plugin will be unloaded again.
 */
int ts3plugin_init() {
    char appPath[PATH_BUFSIZE];
    char resourcesPath[PATH_BUFSIZE];
    char configPath[PATH_BUFSIZE];
	char pluginPath[PATH_BUFSIZE];

    /* Your plugin init code here */
    printf("PLUGIN: init\n");

    /* Example on how to query application, resources and configuration paths from client */
    /* Note: Console client returns empty string for app and resources path */
    ts3Functions.getAppPath(appPath, PATH_BUFSIZE);
    ts3Functions.getResourcesPath(resourcesPath, PATH_BUFSIZE);
    ts3Functions.getConfigPath(configPath, PATH_BUFSIZE);
	ts3Functions.getPluginPath(pluginPath, PATH_BUFSIZE);

	printf("PLUGIN: App path: %s\nResources path: %s\nConfig path: %s\nPlugin path: %s\n", appPath, resourcesPath, configPath, pluginPath);
	
	if (notify_init("libnotify-ts3plugin")) {
		notification = notify_notification_new("Libnotify ts3plugin", "init", message_icon);
		notify_notification_set_timeout(notification, NOTIFICATION_DURATION);
	}
	else {
		printf("Could not init libnotify");
	}


    return 0;  /* 0 = success, 1 = failure, -2 = failure but client will not show a "failed to load" warning */
	/* -2 is a very special case and should only be used if a plugin displays a dialog (e.g. overlay) asking the user to disable
	 * the plugin again, avoiding the show another dialog by the client telling the user the plugin failed to load.
	 * For normal case, if a plugin really failed to load because of an error, the correct return value is 1. */


}
コード例 #5
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);
}
コード例 #6
0
ファイル: main.c プロジェクト: RsrchBoy/dpkg-dhcpcd-ui
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);
}
コード例 #7
0
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;
    }
}
コード例 #8
0
ファイル: lxmusic-notify.c プロジェクト: nesciens/lxmusic
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 */
}
コード例 #9
0
ファイル: tray.c プロジェクト: arinity/gchat2
void
fe_tray_set_balloon(const char *title, const char *text)
{
#ifndef _WIN32
	char *stext;
	WinStatus ws;
	NotifyNotification *n;

	/* no balloons if the window is focused */
	ws = tray_get_window_status();
	if (ws == WS_FOCUSED)
		return;

	/* bit 1 of flags means "no balloons unless hidden/iconified" */
	if (ws != WS_HIDDEN && (prefs.gui_tray_flags & 2))
		return;

	/* FIXME: this should close the current balloon */
	if (!text)
		return;

	stext = strip_color(text, -1, STRIP_ALL);
	n = notify_notification_new(title, stext, NULL);
    notify_notification_set_icon_from_pixbuf(n, ICON_NORMAL);
	notify_notification_set_timeout(n, 20000);
	notify_notification_show(n, NULL);

	free(stext);
	g_object_unref(G_OBJECT(n));
#endif
}
コード例 #10
0
int
main(int argc, char *argv[])
{
	NotifyNotification *n;
	GtkWidget *window;
	GtkWidget *button;

	gtk_init(&argc, &argv);
	notify_init("Replace Test");

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	g_signal_connect(G_OBJECT(window), "delete_event",
					 G_CALLBACK(gtk_main_quit), NULL);

	button = gtk_button_new_with_label("click here to change notification");
	gtk_container_add(GTK_CONTAINER(window), button);

	gtk_widget_show_all(window);

	n = notify_notification_new("Widget Attachment Test",
								"Button has not been clicked yet",
								NULL,  //no icon
								button); //attach to button

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

	g_signal_connect(G_OBJECT(button), "clicked",
					 G_CALLBACK(on_clicked), n);
	g_signal_connect_after(G_OBJECT(button), "expose-event",
						   G_CALLBACK(on_exposed), n);

	gtk_main();

	return 0;
}
コード例 #11
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
}
コード例 #12
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;
}
コード例 #13
0
ファイル: sagan-notify.c プロジェクト: Sigterm-no/sagan
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;
}
コード例 #14
0
ファイル: trayicon.c プロジェクト: Newterm/florence
/* 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;
}
コード例 #15
0
ファイル: notifier.c プロジェクト: pedroarthur/profanity
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
}
コード例 #16
0
ファイル: main.c プロジェクト: hluk/red
void notifyInit(NotifyNotification **notification)
{
    notify_init("Red");
    *notification = notify_notification_new("Red", NULL, NULL);
    notify_notification_set_timeout(*notification, NOTIFY_TIMEOUT_MSEC);
    notify_notification_set_hint_string(*notification, "x-canonical-private-synchronous", "");
}
コード例 #17
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;
}
コード例 #18
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);
}
コード例 #19
0
ファイル: notifier.c プロジェクト: kzmkv/indi
void notifier_init ()
{
	if (notify_is_initted ())
		return;

	notify_init (Appname);
	Notification = notify_notification_new (Appname, NULL, NULL, NULL);
	notify_notification_set_timeout (Notification, TIMEOUT);
}
コード例 #20
0
ファイル: test-replace.c プロジェクト: GNOME/libnotify
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;
}
コード例 #21
0
ファイル: notify.c プロジェクト: aweltsch/toxic
int box_notify(ToxWindow* self, Notification notif, uint64_t flags, int* id_indicator, const char* title, const char* format, ...)
{
    if (notifications_are_disabled(flags)) {
        tab_notify(self, flags);
        return -1;
    }

#ifdef BOX_NOTIFY

    int id = sound_notify(self, notif, flags, id_indicator);

    control_lock();

#ifdef SOUND_NOTIFY
    if (id == -1) { /* Could not play */

        for (id = 0; id < ACTIVE_NOTIFS_MAX && actives[id].active; id ++);
        if ( id == ACTIVE_NOTIFS_MAX ) {
            control_unlock();
            return -1; /* Full */
        }

        actives[id].active = 1;
        actives[id].id_indicator = id_indicator;
        if (id_indicator) *id_indicator = id;
    }
#else
    if (id == -1)
        return -1;
#endif    /* SOUND_NOTIFY */

    snprintf(actives[id].title, sizeof(actives[id].title), "%s", title);
    if (strlen(title) > 23) strcpy(actives[id].title + 20, "...");

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

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

    actives[id].box = notify_notification_new(actives[id].title, actives[id].messages[0], NULL);
    actives[id].size++;
    actives[id].n_timeout = get_unix_time() + Control.notif_timeout / 1000;

    notify_notification_set_timeout(actives[id].box, Control.notif_timeout);
    notify_notification_set_app_name(actives[id].box, "toxic");
    /*notify_notification_add_action(actives[id].box, "lel", "default", m_notify_action, self, NULL);*/
    notify_notification_show(actives[id].box, NULL);

    control_unlock();
    return id;
#else
    return sound_notify(self, notif, flags, id_indicator);
#endif   /* BOX_NOTIFY */
}
コード例 #22
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);
}
コード例 #23
0
ファイル: notify.c プロジェクト: dardevelin/toxic
int box_silent_notify(ToxWindow* self, uint64_t flags, int* id_indicator, const char* title, 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();
    
    int id;        
    for (id = 0; id < ACTIVE_NOTIFS_MAX && actives[id].active; id ++);
    if ( id == ACTIVE_NOTIFS_MAX ) {
        control_unlock();
        return -1; /* Full */
    }
    
    if (id_indicator) {
        actives[id].id_indicator = id_indicator;
        *id_indicator = id;
    }
    
    strncpy(actives[id].title, title, 24);
    if (strlen(title) > 23) strcpy(actives[id].title + 20, "...");
    
    va_list __ARGS__; va_start (__ARGS__, format);
    vsnprintf (actives[id].messages[0], 127, format, __ARGS__);
    va_end (__ARGS__);
    
    if (strlen(actives[id].messages[0]) > 124) 
        strcpy(actives[id].messages[0] + 124, "...");
    
    actives[id].active = 1;
    actives[id].box = notify_notification_new(actives[id].title, actives[id].messages[0], NULL);
    actives[id].size ++;
    actives[id].n_timeout = time(NULL) + Control.notif_timeout / 1000;
    
    notify_notification_set_timeout(actives[id].box, Control.notif_timeout);
    notify_notification_set_app_name(actives[id].box, "toxic");
    /*notify_notification_add_action(actives[id].box, "lel", "default", m_notify_action, self, NULL);*/
    notify_notification_show(actives[id].box, NULL);
    
    control_unlock();
    return id;
#else
    return -1;
#endif
}
コード例 #24
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);
}
コード例 #25
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;
}
コード例 #26
0
ファイル: notify.c プロジェクト: dardevelin/toxic
int box_notify(ToxWindow* self, Notification notif, uint64_t flags, int* id_indicator, char* title, 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
    
    int id = sound_notify(self, notif, flags, id_indicator);
    
    control_lock();
    
#ifdef _SOUND_NOTIFY
    if (id == -1) { /* Could not play */
        
        for (id = 0; id < ACTIVE_NOTIFS_MAX && actives[id].active; id ++);
        if ( id == ACTIVE_NOTIFS_MAX ) {
            control_unlock();
            return -1; /* Full */
        }
        
        actives[id].active = 1;    
        actives[id].id_indicator = id_indicator;
        if (id_indicator) *id_indicator = id;
    }
#endif
        
    strncpy(actives[id].title, title, 24);
    if (strlen(title) > 23) strcpy(actives[id].title + 20, "...");

    va_list __ARGS__; va_start (__ARGS__, format);
    vsnprintf (actives[id].messages[0], 127, format, __ARGS__);
    va_end (__ARGS__);
    
    if (strlen(actives[id].messages[0]) > 124) 
        strcpy(actives[id].messages[0] + 124, "...");
    
    actives[id].box = notify_notification_new(actives[id].title, actives[id].messages[0], NULL);
    actives[id].size ++;
    actives[id].n_timeout = time(NULL) + Control.notif_timeout / 1000;
    
    notify_notification_set_timeout(actives[id].box, Control.notif_timeout);
    notify_notification_set_app_name(actives[id].box, "toxic");
    /*notify_notification_add_action(actives[id].box, "lel", "default", m_notify_action, self, NULL);*/
    notify_notification_show(actives[id].box, NULL);
    
    control_unlock();
    return id;
#else
    return sound_notify(self, notif, flags, id_indicator);
#endif
}
コード例 #27
0
ファイル: snotify.c プロジェクト: LastAvenger/srain
void snotify_notify(const char *title, const char *msg, const char *icon){
    NotifyNotification *notify;

    notify = notify_notification_new (title, msg, icon);
    /* 3 seconds */
    notify_notification_set_timeout(notify, SNOTIFY_TIMEOUT);

    if (!notify_notification_show(notify, NULL)) {
        ERR_FR("Failed to send notification");
    }

    g_object_unref(G_OBJECT(notify));
}
コード例 #28
0
ファイル: plugin-tray.c プロジェクト: amalmurali47/hexchat
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
}
コード例 #29
0
ファイル: notify.c プロジェクト: hyuni/pnmixer
/**
 * 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);
}
コード例 #30
0
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;
        }
    }
}