Use consistent style in the tests
This commit is contained in:
parent
a8524aed6a
commit
5d5a284ca6
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
* @file tests/test-basic.c Unit test: basics
|
* @file tests/test-basic.c Unit test: basics
|
||||||
*
|
*
|
||||||
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
|
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
|
||||||
|
@ -23,22 +24,25 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int main() {
|
int
|
||||||
NotifyNotification *n;
|
main ()
|
||||||
|
{
|
||||||
|
NotifyNotification *n;
|
||||||
|
|
||||||
notify_init("Basics");
|
notify_init ("Basics");
|
||||||
|
|
||||||
n = notify_notification_new ("Summary",
|
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",
|
"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, NULL);
|
NULL,
|
||||||
notify_notification_set_timeout (n, 3000); //3 seconds
|
NULL);
|
||||||
|
notify_notification_set_timeout (n, 3000); //3 seconds
|
||||||
|
|
||||||
if (!notify_notification_show (n, NULL)) {
|
if (!notify_notification_show (n, NULL)) {
|
||||||
fprintf(stderr, "failed to send notification\n");
|
fprintf (stderr, "failed to send notification\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref(G_OBJECT(n));
|
g_object_unref (G_OBJECT (n));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
* @file tests/test-default-action.c Unit test: default action
|
* @file tests/test-default-action.c Unit test: default action
|
||||||
*
|
*
|
||||||
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
|
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
|
||||||
|
@ -35,43 +36,50 @@
|
||||||
|
|
||||||
static GMainLoop *loop;
|
static GMainLoop *loop;
|
||||||
|
|
||||||
static void callback(NotifyNotification *n, const char *action, void *user_data)
|
static void
|
||||||
|
callback (NotifyNotification *n,
|
||||||
|
const char *action,
|
||||||
|
void *user_data)
|
||||||
{
|
{
|
||||||
printf("callback\n");
|
printf ("callback\n");
|
||||||
assert (action != NULL);
|
assert (action != NULL);
|
||||||
assert (strcmp ("default", action) == 0);
|
assert (strcmp ("default", action) == 0);
|
||||||
|
|
||||||
notify_notification_close (n, NULL);
|
notify_notification_close (n, NULL);
|
||||||
|
|
||||||
g_main_loop_quit(loop);
|
g_main_loop_quit (loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main ()
|
||||||
{
|
{
|
||||||
NotifyNotification *n;
|
NotifyNotification *n;
|
||||||
DBusConnection *conn;
|
DBusConnection *conn;
|
||||||
|
|
||||||
if (!notify_init("Default Action Test")) exit(1);
|
if (!notify_init ("Default Action Test"))
|
||||||
|
exit (1);
|
||||||
|
|
||||||
conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
|
conn = dbus_bus_get (DBUS_BUS_SESSION, NULL);
|
||||||
loop = g_main_loop_new(NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
|
||||||
dbus_connection_setup_with_g_main(conn, NULL);
|
dbus_connection_setup_with_g_main (conn, NULL);
|
||||||
|
|
||||||
n = notify_notification_new ("Matt is online", "", NULL, NULL);
|
n = notify_notification_new ("Matt is online", "", NULL, NULL);
|
||||||
notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT);
|
notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT);
|
||||||
notify_notification_add_action (n, "default", "Do Default Action",
|
notify_notification_add_action (n,
|
||||||
(NotifyActionCallback)callback,
|
"default",
|
||||||
NULL, NULL);
|
"Do Default Action",
|
||||||
notify_notification_set_category (n, "presence.online");
|
(NotifyActionCallback) callback,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
notify_notification_set_category (n, "presence.online");
|
||||||
|
|
||||||
if (!notify_notification_show (n, NULL)) {
|
if (!notify_notification_show (n, NULL)) {
|
||||||
fprintf(stderr, "failed to send notification\n");
|
fprintf (stderr, "failed to send notification\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_main_loop_run(loop);
|
g_main_loop_run (loop);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
* @file tests/test-default-action.c Unit test: error handling
|
* @file tests/test-default-action.c Unit test: error handling
|
||||||
*
|
*
|
||||||
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
|
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
|
||||||
|
@ -23,26 +24,26 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int main() {
|
int
|
||||||
NotifyNotification *n;
|
main ()
|
||||||
|
{
|
||||||
|
NotifyNotification *n;
|
||||||
|
|
||||||
g_type_init ();
|
g_type_init ();
|
||||||
|
|
||||||
notify_init("Error Handling");
|
notify_init ("Error Handling");
|
||||||
|
|
||||||
n = notify_notification_new ("Summary",
|
n = notify_notification_new ("Summary", "Content", NULL, NULL);
|
||||||
"Content",
|
notify_notification_set_timeout (n, 3000); //3 seconds
|
||||||
NULL, NULL);
|
|
||||||
notify_notification_set_timeout (n, 3000); //3 seconds
|
|
||||||
|
|
||||||
/* TODO: Create an error condition */
|
/* TODO: Create an error condition */
|
||||||
|
|
||||||
|
|
||||||
if (!notify_notification_show (n, NULL)) {
|
if (!notify_notification_show (n, NULL)) {
|
||||||
fprintf(stderr, "failed to send notification\n");
|
fprintf (stderr, "failed to send notification\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
* @file tests/test-image.c Unit test: images
|
* @file tests/test-image.c Unit test: images
|
||||||
*
|
*
|
||||||
* @Copyright(C) 2004 Mike Hearn <mike@navi.cx>
|
* @Copyright(C) 2004 Mike Hearn <mike@navi.cx>
|
||||||
|
@ -39,77 +40,83 @@
|
||||||
#include <dbus/dbus-glib.h>
|
#include <dbus/dbus-glib.h>
|
||||||
#include <dbus/dbus-glib-lowlevel.h>
|
#include <dbus/dbus-glib-lowlevel.h>
|
||||||
|
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
NotifyNotification *n;
|
NotifyNotification *n;
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *file;
|
char *file;
|
||||||
char *uri;
|
char *uri;
|
||||||
GdkPixbuf *icon;
|
GdkPixbuf *icon;
|
||||||
GtkWidget *helper;
|
GtkWidget *helper;
|
||||||
|
|
||||||
gtk_init(&argc, &argv);
|
gtk_init (&argc, &argv);
|
||||||
|
|
||||||
if (!notify_init("Images Test"))
|
if (!notify_init ("Images Test"))
|
||||||
exit(1);
|
exit (1);
|
||||||
|
|
||||||
/* Stock icon */
|
/* Stock icon */
|
||||||
n = notify_notification_new("Icon Test", "Testing stock icon",
|
n = notify_notification_new ("Icon Test",
|
||||||
"appointment-new", NULL);
|
"Testing stock icon",
|
||||||
|
"appointment-new",
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (!notify_notification_show(n, NULL))
|
if (!notify_notification_show (n, NULL)) {
|
||||||
{
|
fprintf (stderr, "failed to send notification\n");
|
||||||
fprintf(stderr, "failed to send notification\n");
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref(G_OBJECT(n));
|
g_object_unref (G_OBJECT (n));
|
||||||
|
|
||||||
file = g_get_current_dir();
|
file = g_get_current_dir ();
|
||||||
uri = g_strdup_printf("file://%s/%s", file, "applet-critical.png");
|
uri = g_strdup_printf ("file://%s/%s",
|
||||||
|
file,
|
||||||
|
"applet-critical.png");
|
||||||
|
|
||||||
g_free(file);
|
g_free (file);
|
||||||
printf("sending %s\n", uri);
|
printf ("sending %s\n", uri);
|
||||||
|
|
||||||
/* URIs */
|
/* URIs */
|
||||||
n = notify_notification_new("Alert!", "Testing URI icons", uri, NULL);
|
n = notify_notification_new ("Alert!",
|
||||||
|
"Testing URI icons",
|
||||||
|
uri,
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (!notify_notification_show(n, NULL))
|
if (!notify_notification_show (n, NULL)) {
|
||||||
{
|
fprintf (stderr, "failed to send notification\n");
|
||||||
fprintf(stderr, "failed to send notification\n");
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref(G_OBJECT(n));
|
g_object_unref (G_OBJECT (n));
|
||||||
|
|
||||||
/* Raw image */
|
/* Raw image */
|
||||||
n = notify_notification_new("Raw image test",
|
n = notify_notification_new ("Raw image test",
|
||||||
"Testing sending raw pixbufs", NULL, NULL);
|
"Testing sending raw pixbufs",
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is just a hack to get a stock icon's pixbuf in a realworld app
|
* This is just a hack to get a stock icon's pixbuf in a realworld app
|
||||||
* if you were sending bitmapped data you would know the file location
|
* if you were sending bitmapped data you would know the file location
|
||||||
* and open it up with a method that could generate a bmp for you
|
* and open it up with a method that could generate a bmp for you
|
||||||
*/
|
*/
|
||||||
helper = gtk_button_new();
|
helper = gtk_button_new ();
|
||||||
icon = gtk_widget_render_icon(helper,
|
icon = gtk_widget_render_icon (helper,
|
||||||
GTK_STOCK_DIALOG_QUESTION,
|
GTK_STOCK_DIALOG_QUESTION,
|
||||||
GTK_ICON_SIZE_DIALOG,
|
GTK_ICON_SIZE_DIALOG,
|
||||||
NULL);
|
NULL);
|
||||||
gtk_widget_destroy(helper);
|
gtk_widget_destroy (helper);
|
||||||
|
|
||||||
notify_notification_set_icon_from_pixbuf(n, icon);
|
notify_notification_set_icon_from_pixbuf (n, icon);
|
||||||
g_object_unref(G_OBJECT(icon));
|
g_object_unref (G_OBJECT (icon));
|
||||||
|
|
||||||
if (!notify_notification_show(n, NULL))
|
if (!notify_notification_show (n, NULL)) {
|
||||||
{
|
fprintf (stderr, "failed to send notification\n");
|
||||||
fprintf(stderr, "failed to send notification\n");
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref(G_OBJECT(n));
|
g_object_unref (G_OBJECT (n));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
* @file tests/test-markup.c Unit test: markup
|
* @file tests/test-markup.c Unit test: markup
|
||||||
*
|
*
|
||||||
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
|
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
|
||||||
|
@ -23,21 +24,24 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int main() {
|
int
|
||||||
NotifyNotification *n;
|
main ()
|
||||||
|
{
|
||||||
|
NotifyNotification *n;
|
||||||
|
|
||||||
notify_init("Markup");
|
notify_init ("Markup");
|
||||||
|
|
||||||
n = notify_notification_new ("Summary",
|
n = notify_notification_new ("Summary",
|
||||||
"Some <b>bold</b>, <u>underlined</u>, <i>italic</i>, "
|
"Some <b>bold</b>, <u>underlined</u>, <i>italic</i>, "
|
||||||
"<a href='http://www.google.com'>linked</a> text",
|
"<a href='http://www.google.com'>linked</a> text",
|
||||||
NULL, NULL);
|
NULL,
|
||||||
notify_notification_set_timeout (n, 3000); //3 seconds
|
NULL);
|
||||||
|
notify_notification_set_timeout (n, 3000); //3 seconds
|
||||||
|
|
||||||
if (!notify_notification_show (n, NULL)) {
|
if (!notify_notification_show (n, NULL)) {
|
||||||
fprintf(stderr, "failed to send notification\n");
|
fprintf (stderr, "failed to send notification\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
* @file tests/test-multi-actions.c Unit test: multiple actions
|
* @file tests/test-multi-actions.c Unit test: multiple actions
|
||||||
*
|
*
|
||||||
* @Copyright(C) 2004 Mike Hearn <mike@navi.cx>
|
* @Copyright(C) 2004 Mike Hearn <mike@navi.cx>
|
||||||
|
@ -35,83 +36,96 @@
|
||||||
static GMainLoop *loop;
|
static GMainLoop *loop;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
help_callback(NotifyNotification *n, const char *action)
|
help_callback (NotifyNotification *n,
|
||||||
|
const char *action)
|
||||||
{
|
{
|
||||||
g_assert(action != NULL);
|
g_assert (action != NULL);
|
||||||
g_assert(strcmp(action, "help") == 0);
|
g_assert (strcmp (action, "help") == 0);
|
||||||
|
|
||||||
printf("You clicked Help\n");
|
printf ("You clicked Help\n");
|
||||||
|
|
||||||
notify_notification_close(n, NULL);
|
notify_notification_close (n, NULL);
|
||||||
|
|
||||||
g_main_loop_quit(loop);
|
g_main_loop_quit (loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ignore_callback(NotifyNotification *n, const char *action)
|
ignore_callback (NotifyNotification *n,
|
||||||
|
const char *action)
|
||||||
{
|
{
|
||||||
g_assert(action != NULL);
|
g_assert (action != NULL);
|
||||||
g_assert(strcmp(action, "ignore") == 0);
|
g_assert (strcmp (action, "ignore") == 0);
|
||||||
|
|
||||||
printf("You clicked Ignore\n");
|
printf ("You clicked Ignore\n");
|
||||||
|
|
||||||
notify_notification_close(n, NULL);
|
notify_notification_close (n, NULL);
|
||||||
|
|
||||||
g_main_loop_quit(loop);
|
g_main_loop_quit (loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
empty_callback(NotifyNotification *n, const char *action)
|
empty_callback (NotifyNotification *n,
|
||||||
|
const char *action)
|
||||||
{
|
{
|
||||||
g_assert(action != NULL);
|
g_assert (action != NULL);
|
||||||
g_assert(strcmp(action, "empty") == 0);
|
g_assert (strcmp (action, "empty") == 0);
|
||||||
|
|
||||||
printf("You clicked Empty Trash\n");
|
printf ("You clicked Empty Trash\n");
|
||||||
|
|
||||||
notify_notification_close(n, NULL);
|
notify_notification_close (n, NULL);
|
||||||
|
|
||||||
g_main_loop_quit(loop);
|
g_main_loop_quit (loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
NotifyNotification *n;
|
NotifyNotification *n;
|
||||||
DBusConnection *conn;
|
DBusConnection *conn;
|
||||||
|
|
||||||
if (!notify_init("Multi Action Test"))
|
if (!notify_init ("Multi Action Test"))
|
||||||
exit(1);
|
exit (1);
|
||||||
|
|
||||||
conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
|
conn = dbus_bus_get (DBUS_BUS_SESSION, NULL);
|
||||||
loop = g_main_loop_new(NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
|
||||||
dbus_connection_setup_with_g_main(conn, NULL);
|
dbus_connection_setup_with_g_main (conn, NULL);
|
||||||
|
|
||||||
n = notify_notification_new("Low disk space",
|
n = notify_notification_new ("Low disk space",
|
||||||
"You can free up some disk space by "
|
"You can free up some disk space by "
|
||||||
"emptying the trash can.",
|
"emptying the trash can.",
|
||||||
NULL, NULL);
|
NULL,
|
||||||
notify_notification_set_urgency(n, NOTIFY_URGENCY_CRITICAL);
|
NULL);
|
||||||
notify_notification_set_timeout(n, NOTIFY_EXPIRES_DEFAULT);
|
notify_notification_set_urgency (n, NOTIFY_URGENCY_CRITICAL);
|
||||||
notify_notification_add_action(n, "help", "Help",
|
notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT);
|
||||||
(NotifyActionCallback)help_callback,
|
notify_notification_add_action (n,
|
||||||
NULL, NULL);
|
"help",
|
||||||
notify_notification_add_action(n, "ignore", "Ignore",
|
"Help",
|
||||||
(NotifyActionCallback)ignore_callback,
|
(NotifyActionCallback) help_callback,
|
||||||
NULL, NULL);
|
NULL,
|
||||||
notify_notification_add_action(n, "empty", "Empty Trash",
|
NULL);
|
||||||
(NotifyActionCallback)empty_callback,
|
notify_notification_add_action (n,
|
||||||
NULL, NULL);
|
"ignore",
|
||||||
notify_notification_set_category(n, "device");
|
"Ignore",
|
||||||
|
(NotifyActionCallback)
|
||||||
|
ignore_callback,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
notify_notification_add_action (n,
|
||||||
|
"empty",
|
||||||
|
"Empty Trash",
|
||||||
|
(NotifyActionCallback) empty_callback,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
notify_notification_set_category (n, "device");
|
||||||
|
|
||||||
if (!notify_notification_show(n, NULL))
|
if (!notify_notification_show (n, NULL)) {
|
||||||
{
|
fprintf (stderr, "failed to send notification\n");
|
||||||
fprintf(stderr, "failed to send notification\n");
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
g_main_loop_run(loop);
|
g_main_loop_run (loop);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,67 +1,94 @@
|
||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or(at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <libnotify/notify.h>
|
#include <libnotify/notify.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_exposed(GtkWidget *widget, GdkEventExpose *ev, void *user_data)
|
on_exposed (GtkWidget *widget,
|
||||||
|
GdkEventExpose *ev,
|
||||||
|
void *user_data)
|
||||||
{
|
{
|
||||||
NotifyNotification *n = NOTIFY_NOTIFICATION(user_data);
|
NotifyNotification *n = NOTIFY_NOTIFICATION (user_data);
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func(widget, on_exposed, user_data);
|
g_signal_handlers_disconnect_by_func (widget, on_exposed, user_data);
|
||||||
|
|
||||||
notify_notification_show(n, NULL);
|
notify_notification_show (n, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_clicked(GtkButton *button, void *user_data)
|
on_clicked (GtkButton *button,
|
||||||
|
void *user_data)
|
||||||
{
|
{
|
||||||
gchar *buf;
|
gchar *buf;
|
||||||
NotifyNotification *n = NOTIFY_NOTIFICATION(user_data);
|
NotifyNotification *n = NOTIFY_NOTIFICATION (user_data);
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
buf = g_strdup_printf("You clicked the button %i times", count);
|
buf = g_strdup_printf ("You clicked the button %i times", count);
|
||||||
notify_notification_update(n, "Widget Attachment Test", buf, NULL);
|
notify_notification_update (n, "Widget Attachment Test", buf, NULL);
|
||||||
g_free(buf);
|
g_free (buf);
|
||||||
|
|
||||||
notify_notification_show(n, NULL);
|
notify_notification_show (n, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
NotifyNotification *n;
|
NotifyNotification *n;
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
|
|
||||||
gtk_init(&argc, &argv);
|
gtk_init (&argc, &argv);
|
||||||
notify_init("Replace Test");
|
notify_init ("Replace Test");
|
||||||
|
|
||||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||||
g_signal_connect(G_OBJECT(window), "delete_event",
|
g_signal_connect (G_OBJECT (window),
|
||||||
G_CALLBACK(gtk_main_quit), NULL);
|
"delete_event",
|
||||||
|
G_CALLBACK (gtk_main_quit),
|
||||||
|
NULL);
|
||||||
|
|
||||||
button = gtk_button_new_with_label("click here to change notification");
|
button = gtk_button_new_with_label ("click here to change notification");
|
||||||
gtk_container_add(GTK_CONTAINER(window), button);
|
gtk_container_add (GTK_CONTAINER (window), button);
|
||||||
|
|
||||||
gtk_widget_show_all(window);
|
gtk_widget_show_all (window);
|
||||||
|
|
||||||
n = notify_notification_new("Widget Attachment Test",
|
n = notify_notification_new ("Widget Attachment Test",
|
||||||
"Button has not been clicked yet",
|
"Button has not been clicked yet",
|
||||||
NULL, //no icon
|
NULL, //no icon
|
||||||
button); //attach to button
|
button); //attach to button
|
||||||
|
|
||||||
notify_notification_set_timeout(n, 0); //don't timeout
|
notify_notification_set_timeout (n, 0); //don't timeout
|
||||||
|
|
||||||
g_signal_connect(G_OBJECT(button), "clicked",
|
g_signal_connect (G_OBJECT (button),
|
||||||
G_CALLBACK(on_clicked), n);
|
"clicked",
|
||||||
g_signal_connect_after(G_OBJECT(button), "expose-event",
|
G_CALLBACK (on_clicked),
|
||||||
G_CALLBACK(on_exposed), n);
|
n);
|
||||||
|
g_signal_connect_after (G_OBJECT (button),
|
||||||
|
"expose-event",
|
||||||
|
G_CALLBACK (on_exposed),
|
||||||
|
n);
|
||||||
|
|
||||||
gtk_main();
|
gtk_main ();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +1,67 @@
|
||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or(at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <libnotify/notify.h>
|
#include <libnotify/notify.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
int main() {
|
int
|
||||||
NotifyNotification *n;
|
main ()
|
||||||
GError *error;
|
{
|
||||||
error = NULL;
|
NotifyNotification *n;
|
||||||
|
GError *error;
|
||||||
|
error = NULL;
|
||||||
|
|
||||||
g_type_init ();
|
g_type_init ();
|
||||||
|
|
||||||
notify_init("Replace Test");
|
notify_init ("Replace Test");
|
||||||
|
|
||||||
n = notify_notification_new ("Summary", "First message",
|
|
||||||
NULL, //no icon
|
|
||||||
NULL); //don't attach to widget
|
|
||||||
|
|
||||||
|
n = notify_notification_new ("Summary",
|
||||||
notify_notification_set_timeout (n, 0); //don't timeout
|
"First message",
|
||||||
|
NULL, //no icon
|
||||||
if (!notify_notification_show (n, &error)) {
|
NULL); //don't attach to widget
|
||||||
fprintf(stderr, "failed to send notification: %s\n", error->message);
|
|
||||||
g_error_free (error);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
sleep(3);
|
|
||||||
|
|
||||||
notify_notification_update (n, "Second Summary",
|
notify_notification_set_timeout (n, 0); //don't timeout
|
||||||
"First mesage was replaced", NULL);
|
|
||||||
notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT);
|
|
||||||
|
|
||||||
if (!notify_notification_show (n, &error)) {
|
if (!notify_notification_show (n, &error)) {
|
||||||
fprintf(stderr, "failed to send notification: %s\n", error->message);
|
fprintf (stderr, "failed to send notification: %s\n",
|
||||||
g_error_free (error);
|
error->message);
|
||||||
return 1;
|
g_error_free (error);
|
||||||
}
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
* @file tests/test-server-info.c Retrieves the server info and caps
|
* @file tests/test-server-info.c Retrieves the server info and caps
|
||||||
*
|
*
|
||||||
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
|
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
|
||||||
|
@ -24,38 +25,36 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
GList *l, *caps;
|
GList *l, *caps;
|
||||||
char *name, *vendor, *version, *spec_version;
|
char *name, *vendor, *version, *spec_version;
|
||||||
|
|
||||||
notify_init("TestCaps");
|
notify_init ("TestCaps");
|
||||||
|
|
||||||
if (!notify_get_server_info(&name, &vendor, &version, &spec_version))
|
if (!notify_get_server_info (&name, &vendor, &version, &spec_version)) {
|
||||||
{
|
fprintf (stderr, "Failed to receive server info.\n");
|
||||||
fprintf(stderr, "Failed to receive server info.\n");
|
exit (1);
|
||||||
exit(1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
printf("Name: %s\n", name);
|
printf ("Name: %s\n", name);
|
||||||
printf("Vendor: %s\n", vendor);
|
printf ("Vendor: %s\n", vendor);
|
||||||
printf("Version: %s\n", version);
|
printf ("Version: %s\n", version);
|
||||||
printf("Spec Version: %s\n", spec_version);
|
printf ("Spec Version: %s\n", spec_version);
|
||||||
printf("Capabilities:\n");
|
printf ("Capabilities:\n");
|
||||||
|
|
||||||
caps = notify_get_server_caps();
|
caps = notify_get_server_caps ();
|
||||||
|
|
||||||
if (caps == NULL)
|
if (caps == NULL) {
|
||||||
{
|
fprintf (stderr, "Failed to receive server caps.\n");
|
||||||
fprintf(stderr, "Failed to receive server caps.\n");
|
exit (1);
|
||||||
exit(1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (l = caps; l != NULL; l = l->next)
|
for (l = caps; l != NULL; l = l->next)
|
||||||
printf("\t%s\n", (char *)l->data);
|
printf ("\t%s\n", (char *) l->data);
|
||||||
|
|
||||||
g_list_foreach(caps, (GFunc)g_free, NULL);
|
g_list_foreach (caps, (GFunc) g_free, NULL);
|
||||||
g_list_free(caps);
|
g_list_free (caps);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
* @file tests/test-size-changes.c Unit test: Notification size changes
|
* @file tests/test-size-changes.c Unit test: Notification size changes
|
||||||
*
|
*
|
||||||
* @Copyright (C) 2006 Christian Hammond <chipx86@chipx86.com>
|
* @Copyright (C) 2006 Christian Hammond <chipx86@chipx86.com>
|
||||||
|
@ -24,61 +25,63 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main ()
|
||||||
{
|
{
|
||||||
NotifyNotification *n1, *n2, *n3;
|
NotifyNotification *n1, *n2, *n3;
|
||||||
|
|
||||||
notify_init("Size Changes");
|
notify_init ("Size Changes");
|
||||||
|
|
||||||
n1 = notify_notification_new("Notification 1", "Notification number 1!",
|
n1 = notify_notification_new ("Notification 1",
|
||||||
NULL, NULL);
|
"Notification number 1!",
|
||||||
notify_notification_set_timeout(n1, 7000);
|
NULL,
|
||||||
|
NULL);
|
||||||
|
notify_notification_set_timeout (n1, 7000);
|
||||||
|
|
||||||
if (!notify_notification_show(n1, NULL))
|
if (!notify_notification_show (n1, NULL)) {
|
||||||
{
|
fprintf (stderr, "failed to send notification\n");
|
||||||
fprintf(stderr, "failed to send notification\n");
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref(G_OBJECT(n1));
|
g_object_unref (G_OBJECT (n1));
|
||||||
|
|
||||||
n2 = notify_notification_new("Notification 2", "Notification number 2!",
|
n2 = notify_notification_new ("Notification 2",
|
||||||
NULL, NULL);
|
"Notification number 2!",
|
||||||
notify_notification_set_timeout(n2, 7000);
|
NULL,
|
||||||
|
NULL);
|
||||||
|
notify_notification_set_timeout (n2, 7000);
|
||||||
|
|
||||||
if (!notify_notification_show(n2, NULL))
|
if (!notify_notification_show (n2, NULL)) {
|
||||||
{
|
fprintf (stderr, "failed to send notification\n");
|
||||||
fprintf(stderr, "failed to send notification\n");
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
n3 = notify_notification_new("Notification 3", "Notification number 3!",
|
n3 = notify_notification_new ("Notification 3",
|
||||||
NULL, NULL);
|
"Notification number 3!",
|
||||||
notify_notification_set_timeout(n3, 7000);
|
NULL,
|
||||||
|
NULL);
|
||||||
|
notify_notification_set_timeout (n3, 7000);
|
||||||
|
|
||||||
if (!notify_notification_show(n3, NULL))
|
if (!notify_notification_show (n3, NULL)) {
|
||||||
{
|
fprintf (stderr, "failed to send notification\n");
|
||||||
fprintf(stderr, "failed to send notification\n");
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref(G_OBJECT(n3));
|
g_object_unref (G_OBJECT (n3));
|
||||||
|
|
||||||
sleep(2);
|
sleep (2);
|
||||||
|
|
||||||
notify_notification_update(n2, "Longer Notification 2",
|
notify_notification_update (n2,
|
||||||
"This is a much longer notification.\n"
|
"Longer Notification 2",
|
||||||
"Two lines.\n"
|
"This is a much longer notification.\n"
|
||||||
"Well, okay, three.\n"
|
"Two lines.\n"
|
||||||
"Last one.",
|
"Well, okay, three.\n" "Last one.",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (!notify_notification_show(n2, NULL))
|
if (!notify_notification_show (n2, NULL)) {
|
||||||
{
|
fprintf (stderr, "failed to send notification\n");
|
||||||
fprintf(stderr, "failed to send notification\n");
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
* @file tests/test-urgency.c Unit test: urgency levels
|
* @file tests/test-urgency.c Unit test: urgency levels
|
||||||
*
|
*
|
||||||
* @Copyright(C) 2006 Christian Hammond <chipx8@chipx86.com>
|
* @Copyright(C) 2006 Christian Hammond <chipx8@chipx86.com>
|
||||||
|
@ -23,51 +24,52 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
NotifyNotification *n;
|
NotifyNotification *n;
|
||||||
|
|
||||||
notify_init("Urgency");
|
notify_init ("Urgency");
|
||||||
|
|
||||||
n = notify_notification_new("Low Urgency", "Joe signed online.",
|
n = notify_notification_new ("Low Urgency",
|
||||||
NULL, NULL);
|
"Joe signed online.",
|
||||||
notify_notification_set_urgency(n, NOTIFY_URGENCY_LOW);
|
NULL,
|
||||||
if (!notify_notification_show(n, NULL))
|
NULL);
|
||||||
{
|
notify_notification_set_urgency (n, NOTIFY_URGENCY_LOW);
|
||||||
fprintf(stderr, "failed to send notification\n");
|
if (!notify_notification_show (n, NULL)) {
|
||||||
exit(1);
|
fprintf (stderr, "failed to send notification\n");
|
||||||
}
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
g_object_unref(G_OBJECT(n));
|
g_object_unref (G_OBJECT (n));
|
||||||
|
|
||||||
|
|
||||||
n = notify_notification_new("Normal Urgency",
|
n = notify_notification_new ("Normal Urgency",
|
||||||
"You have a meeting in 10 minutes.",
|
"You have a meeting in 10 minutes.",
|
||||||
NULL, NULL);
|
NULL,
|
||||||
notify_notification_set_urgency(n, NOTIFY_URGENCY_NORMAL);
|
NULL);
|
||||||
if (!notify_notification_show(n, NULL))
|
notify_notification_set_urgency (n, NOTIFY_URGENCY_NORMAL);
|
||||||
{
|
if (!notify_notification_show (n, NULL)) {
|
||||||
fprintf(stderr, "failed to send notification\n");
|
fprintf (stderr, "failed to send notification\n");
|
||||||
exit(1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref(G_OBJECT(n));
|
g_object_unref (G_OBJECT (n));
|
||||||
|
|
||||||
|
|
||||||
n = notify_notification_new("Critical Urgency",
|
n = notify_notification_new ("Critical Urgency",
|
||||||
"This message will self-destruct in 10 "
|
"This message will self-destruct in 10 "
|
||||||
"seconds.",
|
"seconds.",
|
||||||
NULL, NULL);
|
NULL,
|
||||||
notify_notification_set_urgency(n, NOTIFY_URGENCY_CRITICAL);
|
NULL);
|
||||||
notify_notification_set_timeout(n, 10000); // 10 seconds
|
notify_notification_set_urgency (n, NOTIFY_URGENCY_CRITICAL);
|
||||||
|
notify_notification_set_timeout (n, 10000); // 10 seconds
|
||||||
|
|
||||||
if (!notify_notification_show(n, NULL))
|
if (!notify_notification_show (n, NULL)) {
|
||||||
{
|
fprintf (stderr, "failed to send notification\n");
|
||||||
fprintf(stderr, "failed to send notification\n");
|
exit (1);
|
||||||
exit(1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref(G_OBJECT(n));
|
g_object_unref (G_OBJECT (n));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
* @file tests/test-xy-actions.c Unit test: X, Y hints and actions
|
* @file tests/test-xy-actions.c Unit test: X, Y hints and actions
|
||||||
*
|
*
|
||||||
* @Copyright (C) 2006 Christian Hammond <chipx86@chipx86.com>
|
* @Copyright (C) 2006 Christian Hammond <chipx86@chipx86.com>
|
||||||
|
@ -31,46 +32,54 @@
|
||||||
static GMainLoop *loop;
|
static GMainLoop *loop;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
action_cb(NotifyNotification *n, const char *action)
|
action_cb (NotifyNotification *n,
|
||||||
|
const char *action)
|
||||||
{
|
{
|
||||||
printf("You clicked '%s'\n", action);
|
printf ("You clicked '%s'\n", action);
|
||||||
|
|
||||||
g_main_loop_quit(loop);
|
g_main_loop_quit (loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
NotifyNotification *n;
|
NotifyNotification *n;
|
||||||
DBusConnection *conn;
|
DBusConnection *conn;
|
||||||
|
|
||||||
notify_init("XY");
|
notify_init ("XY");
|
||||||
|
|
||||||
conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
|
conn = dbus_bus_get (DBUS_BUS_SESSION, NULL);
|
||||||
loop = g_main_loop_new(NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
|
||||||
dbus_connection_setup_with_g_main(conn, NULL);
|
dbus_connection_setup_with_g_main (conn, NULL);
|
||||||
|
|
||||||
n = notify_notification_new("System update available",
|
n = notify_notification_new ("System update available",
|
||||||
"New system updates are available. It is "
|
"New system updates are available. It is "
|
||||||
"recommended that you install the updates.",
|
"recommended that you install the updates.",
|
||||||
NULL, NULL);
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
notify_notification_set_hint_int32(n, "x", 600);
|
notify_notification_set_hint_int32 (n, "x", 600);
|
||||||
notify_notification_set_hint_int32(n, "y", 10);
|
notify_notification_set_hint_int32 (n, "y", 10);
|
||||||
notify_notification_add_action(n, "help", "Help",
|
notify_notification_add_action (n,
|
||||||
(NotifyActionCallback)action_cb,
|
"help",
|
||||||
NULL, NULL);
|
"Help",
|
||||||
notify_notification_add_action(n, "update", "Update",
|
(NotifyActionCallback) action_cb,
|
||||||
(NotifyActionCallback)action_cb,
|
NULL,
|
||||||
NULL, NULL);
|
NULL);
|
||||||
|
notify_notification_add_action (n,
|
||||||
|
"update",
|
||||||
|
"Update",
|
||||||
|
(NotifyActionCallback) action_cb,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (!notify_notification_show(n, NULL)) {
|
if (!notify_notification_show (n, NULL)) {
|
||||||
fprintf(stderr, "failed to send notification\n");
|
fprintf (stderr, "failed to send notification\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_main_loop_run(loop);
|
g_main_loop_run (loop);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
* @file tests/test-xy.c Unit test: X, Y hints
|
* @file tests/test-xy.c Unit test: X, Y hints
|
||||||
*
|
*
|
||||||
* @Copyright(C) 2005 Christian Hammond <chipx86@chipx86.com>
|
* @Copyright(C) 2005 Christian Hammond <chipx86@chipx86.com>
|
||||||
|
@ -10,7 +11,7 @@
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
@ -25,68 +26,71 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_handle_closed(GObject *obj)
|
_handle_closed (GObject * obj)
|
||||||
{
|
{
|
||||||
g_message("closing");
|
g_message ("closing");
|
||||||
g_object_unref(obj);
|
g_object_unref (obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
emit_notification(int x, int y)
|
emit_notification (int x, int y)
|
||||||
{
|
{
|
||||||
char *buffer;
|
char *buffer;
|
||||||
NotifyNotification *n;
|
NotifyNotification *n;
|
||||||
|
|
||||||
buffer = g_strdup_printf("This notification should point to %d, %d.",
|
buffer = g_strdup_printf ("This notification should point to %d, %d.",
|
||||||
x, y);
|
x,
|
||||||
|
y);
|
||||||
|
|
||||||
n = notify_notification_new("X, Y Test", buffer, NULL, NULL);
|
n = notify_notification_new ("X, Y Test", buffer, NULL, NULL);
|
||||||
g_free(buffer);
|
g_free (buffer);
|
||||||
|
|
||||||
notify_notification_set_hint_int32(n, "x", x);
|
notify_notification_set_hint_int32 (n, "x", x);
|
||||||
notify_notification_set_hint_int32(n, "y", y);
|
notify_notification_set_hint_int32 (n, "y", y);
|
||||||
|
|
||||||
g_signal_connect(G_OBJECT(n), "closed",
|
g_signal_connect (G_OBJECT (n),
|
||||||
G_CALLBACK(_handle_closed), NULL);
|
"closed",
|
||||||
|
G_CALLBACK (_handle_closed),
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (!notify_notification_show(n, NULL))
|
if (!notify_notification_show (n, NULL))
|
||||||
fprintf(stderr, "failed to send notification\n");
|
fprintf (stderr, "failed to send notification\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_popup_random_bubble(gpointer unused)
|
_popup_random_bubble (gpointer unused)
|
||||||
{
|
{
|
||||||
GdkDisplay *display;
|
GdkDisplay *display;
|
||||||
GdkScreen *screen;
|
GdkScreen *screen;
|
||||||
|
|
||||||
int screen_x2, screen_y2;
|
int screen_x2, screen_y2;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
display = gdk_display_get_default();
|
display = gdk_display_get_default ();
|
||||||
screen = gdk_display_get_default_screen(display);
|
screen = gdk_display_get_default_screen (display);
|
||||||
screen_x2 = gdk_screen_get_width(screen) - 1;
|
screen_x2 = gdk_screen_get_width (screen) - 1;
|
||||||
screen_y2 = gdk_screen_get_height(screen) - 1;
|
screen_y2 = gdk_screen_get_height (screen) - 1;
|
||||||
|
|
||||||
x = g_random_int_range(0, screen_x2);
|
x = g_random_int_range (0, screen_x2);
|
||||||
y = g_random_int_range(0, screen_y2);
|
y = g_random_int_range (0, screen_y2);
|
||||||
emit_notification(x, y);
|
emit_notification (x, y);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
|
|
||||||
gdk_init(&argc, &argv);
|
gdk_init (&argc, &argv);
|
||||||
|
|
||||||
notify_init("XY");
|
notify_init ("XY");
|
||||||
|
|
||||||
g_timeout_add(1000, _popup_random_bubble, NULL);
|
g_timeout_add (1000, _popup_random_bubble, NULL);
|
||||||
|
|
||||||
loop = g_main_loop_new(NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
g_main_loop_run(loop);
|
g_main_loop_run (loop);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
* @file tests/test-xy.c Unit test: X, Y hints
|
* @file tests/test-xy.c Unit test: X, Y hints
|
||||||
*
|
*
|
||||||
* @Copyright (C) 2005 Christian Hammond <chipx86@chipx86.com>
|
* @Copyright (C) 2005 Christian Hammond <chipx86@chipx86.com>
|
||||||
|
@ -23,22 +24,25 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int main() {
|
int
|
||||||
NotifyNotification *n;
|
main ()
|
||||||
|
{
|
||||||
|
NotifyNotification *n;
|
||||||
|
|
||||||
notify_init("XY");
|
notify_init ("XY");
|
||||||
|
|
||||||
n = notify_notification_new ("X, Y Test",
|
n = notify_notification_new ("X, Y Test",
|
||||||
"This notification should point to 150, 10",
|
"This notification should point to 150, 10",
|
||||||
NULL, NULL);
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
notify_notification_set_hint_int32 (n, "x", 150);
|
notify_notification_set_hint_int32 (n, "x", 150);
|
||||||
notify_notification_set_hint_int32 (n, "y", 10);
|
notify_notification_set_hint_int32 (n, "y", 10);
|
||||||
|
|
||||||
if (!notify_notification_show (n, NULL)) {
|
if (!notify_notification_show (n, NULL)) {
|
||||||
fprintf(stderr, "failed to send notification\n");
|
fprintf (stderr, "failed to send notification\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue