Updated to match the spec.
This commit is contained in:
parent
8ee064f00a
commit
f4bce0d062
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
Wed Sep 29 21:53:15 PDT 2004 Christian Hammond <chipx86@gnupdate.org>
|
||||||
|
|
||||||
|
* libnotify/notify.c:
|
||||||
|
* libnotify/notify.h:
|
||||||
|
* tests/test-animation.c:
|
||||||
|
* tests/test-basic.c:
|
||||||
|
* tests/test-default-action.c:
|
||||||
|
* tests/test-error.c:
|
||||||
|
* tests/test-image.c:
|
||||||
|
* tests/test-markup.c:
|
||||||
|
* tests/test-multi-actions.c:
|
||||||
|
* tests/test-replace.c:
|
||||||
|
* tools/notify-send.c:
|
||||||
|
- Updated to match the spec.
|
||||||
|
|
||||||
Sat Sep 25 12:59:26 PDT 2004 Christian Hammond <chipx86@gnupdate.org>
|
Sat Sep 25 12:59:26 PDT 2004 Christian Hammond <chipx86@gnupdate.org>
|
||||||
|
|
||||||
* libnotify/notify.c:
|
* libnotify/notify.c:
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* FIXME: do we want so many arguments in the API? */
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -169,34 +167,6 @@ _notify_dbus_message_iter_append_string_or_nil(DBusMessageIter *iter,
|
||||||
dbus_message_iter_append_string(iter, str);
|
dbus_message_iter_append_string(iter, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
static char *
|
|
||||||
_notify_dbus_message_iter_get_string_or_nil(DBusMessageIter *iter)
|
|
||||||
{
|
|
||||||
int arg_type;
|
|
||||||
|
|
||||||
g_return_val_if_fail(iter != NULL, NULL);
|
|
||||||
|
|
||||||
arg_type = dbus_message_iter_get_arg_type(iter);
|
|
||||||
|
|
||||||
if (arg_type == DBUS_TYPE_STRING)
|
|
||||||
return dbus_message_iter_get_string(iter);
|
|
||||||
|
|
||||||
g_return_val_if_fail(arg_type == DBUS_TYPE_NIL, NULL);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notify_dbus_message_iter_append_app_info(DBusMessageIter *iter)
|
|
||||||
{
|
|
||||||
g_return_if_fail(iter != NULL);
|
|
||||||
|
|
||||||
dbus_message_iter_append_string(iter, _app_name);
|
|
||||||
dbus_message_iter_append_nil(iter); /* App Icon */
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static DBusHandlerResult
|
static DBusHandlerResult
|
||||||
_filter_func(DBusConnection *dbus_conn, DBusMessage *message, void *user_data)
|
_filter_func(DBusConnection *dbus_conn, DBusMessage *message, void *user_data)
|
||||||
{
|
{
|
||||||
|
@ -584,9 +554,10 @@ notify_icon_destroy(NotifyIcon *icon)
|
||||||
* Notifications API
|
* Notifications API
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
NotifyHandle *
|
NotifyHandle *
|
||||||
notify_send_notification(NotifyHandle *replaces, NotifyUrgency urgency, const char *summary,
|
notify_send_notification(NotifyHandle *replaces, const char *type,
|
||||||
const char *detailed, const NotifyIcon *icon,
|
NotifyUrgency urgency, const char *summary,
|
||||||
gboolean expires, time_t expire_time,
|
const char *body, const NotifyIcon *icon,
|
||||||
|
gboolean expires, time_t timeout,
|
||||||
gpointer user_data, size_t action_count, ...)
|
gpointer user_data, size_t action_count, ...)
|
||||||
{
|
{
|
||||||
va_list actions;
|
va_list actions;
|
||||||
|
@ -595,8 +566,9 @@ notify_send_notification(NotifyHandle *replaces, NotifyUrgency urgency, const ch
|
||||||
g_return_val_if_fail(summary != NULL, 0);
|
g_return_val_if_fail(summary != NULL, 0);
|
||||||
|
|
||||||
va_start(actions, action_count);
|
va_start(actions, action_count);
|
||||||
handle = notify_send_notification_varg(replaces, urgency, summary, detailed, icon,
|
handle = notify_send_notification_varg(replaces, type, urgency, summary,
|
||||||
expires, expire_time, user_data,
|
body, icon, expires,
|
||||||
|
timeout, user_data,
|
||||||
action_count, actions);
|
action_count, actions);
|
||||||
va_end(actions);
|
va_end(actions);
|
||||||
|
|
||||||
|
@ -604,9 +576,10 @@ notify_send_notification(NotifyHandle *replaces, NotifyUrgency urgency, const ch
|
||||||
}
|
}
|
||||||
|
|
||||||
NotifyHandle *
|
NotifyHandle *
|
||||||
notify_send_notification_varg(NotifyHandle *replaces, NotifyUrgency urgency, const char *summary,
|
notify_send_notification_varg(NotifyHandle *replaces, const char *type,
|
||||||
const char *detailed, const NotifyIcon *icon,
|
NotifyUrgency urgency, const char *summary,
|
||||||
gboolean expires, time_t expire_time,
|
const char *body, const NotifyIcon *icon,
|
||||||
|
gboolean expires, time_t timeout,
|
||||||
gpointer user_data, size_t action_count,
|
gpointer user_data, size_t action_count,
|
||||||
va_list actions)
|
va_list actions)
|
||||||
{
|
{
|
||||||
|
@ -622,14 +595,14 @@ notify_send_notification_varg(NotifyHandle *replaces, NotifyUrgency urgency, con
|
||||||
|
|
||||||
g_return_val_if_fail(message != NULL, 0);
|
g_return_val_if_fail(message != NULL, 0);
|
||||||
|
|
||||||
#if 0
|
_notify_dbus_message_iter_append_string_or_nil(&iter, _app_name);
|
||||||
_notify_dbus_message_iter_append_app_info(&iter);
|
dbus_message_iter_append_nil(&iter);
|
||||||
#endif
|
dbus_message_iter_append_uint32(&iter,
|
||||||
|
(replaces != NULL ? replaces->id : 0));
|
||||||
dbus_message_iter_append_uint32(&iter, replaces ? replaces->id : 0);
|
_notify_dbus_message_iter_append_string_or_nil(&iter, type);
|
||||||
dbus_message_iter_append_byte(&iter, urgency);
|
dbus_message_iter_append_byte(&iter, urgency);
|
||||||
dbus_message_iter_append_string(&iter, summary);
|
dbus_message_iter_append_string(&iter, summary);
|
||||||
_notify_dbus_message_iter_append_string_or_nil(&iter, detailed);
|
_notify_dbus_message_iter_append_string_or_nil(&iter, body);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE: D-BUS 0.22cvs is the first to allow empty arrays, *I think*.
|
* NOTE: D-BUS 0.22cvs is the first to allow empty arrays, *I think*.
|
||||||
|
@ -671,11 +644,15 @@ notify_send_notification_varg(NotifyHandle *replaces, NotifyUrgency urgency, con
|
||||||
g_hash_table_insert(table, &action->id, action);
|
g_hash_table_insert(table, &action->id, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expires)
|
/* Hints */
|
||||||
dbus_message_iter_append_uint32(&iter, expire_time);
|
|
||||||
else
|
|
||||||
dbus_message_iter_append_nil(&iter);
|
dbus_message_iter_append_nil(&iter);
|
||||||
|
|
||||||
|
/* Expires */
|
||||||
|
dbus_message_iter_append_boolean(&iter, expires);
|
||||||
|
|
||||||
|
/* Expire Timeout */
|
||||||
|
dbus_message_iter_append_uint32(&iter, (expires ? timeout : 0));
|
||||||
|
|
||||||
dbus_error_init(&error);
|
dbus_error_init(&error);
|
||||||
|
|
||||||
reply = dbus_connection_send_with_reply_and_block(_dbus_conn, message,
|
reply = dbus_connection_send_with_reply_and_block(_dbus_conn, message,
|
||||||
|
|
|
@ -31,7 +31,6 @@ typedef enum
|
||||||
{
|
{
|
||||||
NOTIFY_URGENCY_LOW, /**< Low urgency. */
|
NOTIFY_URGENCY_LOW, /**< Low urgency. */
|
||||||
NOTIFY_URGENCY_NORMAL, /**< Normal urgency. */
|
NOTIFY_URGENCY_NORMAL, /**< Normal urgency. */
|
||||||
NOTIFY_URGENCY_HIGH, /**< High urgency. */
|
|
||||||
NOTIFY_URGENCY_CRITICAL, /**< Critical urgency. */
|
NOTIFY_URGENCY_CRITICAL, /**< Critical urgency. */
|
||||||
|
|
||||||
} NotifyUrgency;
|
} NotifyUrgency;
|
||||||
|
@ -152,13 +151,14 @@ void notify_icon_destroy(NotifyIcon *icon);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param replaces The ID of the notification to atomically replace
|
* @param replaces The ID of the notification to atomically replace
|
||||||
|
* @param type The optional notification type.
|
||||||
* @param urgency The urgency level.
|
* @param urgency The urgency level.
|
||||||
* @param summary The summary of the notification.
|
* @param summary The summary of the notification.
|
||||||
* @param detailed The optional detailed information.
|
* @param body The optional body.
|
||||||
* @param icon The optional icon.
|
* @param icon The optional icon.
|
||||||
* @param expires TRUE if the notification should automatically expire,,
|
* @param expires TRUE if the notification should automatically expire,,
|
||||||
* or FALSE to keep it open until manually closed.
|
* or FALSE to keep it open until manually closed.
|
||||||
* @param expire_time The optional time to automatically close the
|
* @param timeout The optional timeout to automatically close the
|
||||||
* notification, or 0 for the daemon's default.
|
* notification, or 0 for the daemon's default.
|
||||||
* @param user_data User-specified data to send to a callback.
|
* @param user_data User-specified data to send to a callback.
|
||||||
* @param action_count The number of actions.
|
* @param action_count The number of actions.
|
||||||
|
@ -167,11 +167,12 @@ void notify_icon_destroy(NotifyIcon *icon);
|
||||||
* @return A unique ID for the notification.
|
* @return A unique ID for the notification.
|
||||||
*/
|
*/
|
||||||
NotifyHandle *notify_send_notification(NotifyHandle *replaces,
|
NotifyHandle *notify_send_notification(NotifyHandle *replaces,
|
||||||
|
const char *type,
|
||||||
NotifyUrgency urgency,
|
NotifyUrgency urgency,
|
||||||
const char *summary,
|
const char *summary,
|
||||||
const char *detailed,
|
const char *detailed,
|
||||||
const NotifyIcon *icon,
|
const NotifyIcon *icon,
|
||||||
gboolean expires, time_t expire_time,
|
gboolean expires, time_t timeout,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
size_t action_count, ...);
|
size_t action_count, ...);
|
||||||
|
|
||||||
|
@ -185,13 +186,14 @@ NotifyHandle *notify_send_notification(NotifyHandle *replaces,
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param replaces The handle of the notification to atomically replace
|
* @param replaces The handle of the notification to atomically replace
|
||||||
|
* @param type The optional notification type.
|
||||||
* @param urgency The urgency level.
|
* @param urgency The urgency level.
|
||||||
* @param summary The summary of the notification.
|
* @param summary The summary of the notification.
|
||||||
* @param detailed The optional detailed information.
|
* @param detailed The optional body.
|
||||||
* @param icon The optional icon.
|
* @param icon The optional icon.
|
||||||
* @param expires TRUE if the notification should automatically expire,
|
* @param expires TRUE if the notification should automatically expire,
|
||||||
* or FALSE to keep it open until manually closed.
|
* or FALSE to keep it open until manually closed.
|
||||||
* @param expire_time The optional time to automatically close the
|
* @param timeout The optional timeout to automatically close the
|
||||||
* notification, or 0 for the daemon's default.
|
* notification, or 0 for the daemon's default.
|
||||||
* @param user_data User-specified data to send to a callback.
|
* @param user_data User-specified data to send to a callback.
|
||||||
* @param action_count The number of actions.
|
* @param action_count The number of actions.
|
||||||
|
@ -200,12 +202,13 @@ NotifyHandle *notify_send_notification(NotifyHandle *replaces,
|
||||||
* @return A unique ID for the notification.
|
* @return A unique ID for the notification.
|
||||||
*/
|
*/
|
||||||
NotifyHandle *notify_send_notification_varg(NotifyHandle *replaces,
|
NotifyHandle *notify_send_notification_varg(NotifyHandle *replaces,
|
||||||
|
const char *type,
|
||||||
NotifyUrgency urgency,
|
NotifyUrgency urgency,
|
||||||
const char *summary,
|
const char *summary,
|
||||||
const char *detailed,
|
const char *detailed,
|
||||||
const NotifyIcon *icon,
|
const NotifyIcon *icon,
|
||||||
gboolean expires,
|
gboolean expires,
|
||||||
time_t expire_time,
|
time_t timeout,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
size_t action_count,
|
size_t action_count,
|
||||||
va_list actions);
|
va_list actions);
|
||||||
|
|
|
@ -70,6 +70,7 @@ int main()
|
||||||
}
|
}
|
||||||
|
|
||||||
NotifyHandle *n = notify_send_notification(NULL, // replaces nothing
|
NotifyHandle *n = notify_send_notification(NULL, // replaces nothing
|
||||||
|
NULL,
|
||||||
NOTIFY_URGENCY_NORMAL,
|
NOTIFY_URGENCY_NORMAL,
|
||||||
"Summary", "Content",
|
"Summary", "Content",
|
||||||
NULL, // no icon
|
NULL, // no icon
|
||||||
|
|
|
@ -27,6 +27,7 @@ int main() {
|
||||||
notify_init("Basics");
|
notify_init("Basics");
|
||||||
|
|
||||||
NotifyHandle *n = notify_send_notification(NULL, // replaces nothing
|
NotifyHandle *n = notify_send_notification(NULL, // replaces nothing
|
||||||
|
NULL,
|
||||||
NOTIFY_URGENCY_NORMAL,
|
NOTIFY_URGENCY_NORMAL,
|
||||||
"Summary", "Content",
|
"Summary", "Content",
|
||||||
NULL, // no icon
|
NULL, // no icon
|
||||||
|
|
|
@ -44,7 +44,9 @@ static void callback(NotifyHandle *handle, guint32 uid, void *user_data)
|
||||||
g_main_loop_quit(loop);
|
g_main_loop_quit(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
if (!notify_init("Default Action Test")) exit(1);
|
if (!notify_init("Default Action Test")) exit(1);
|
||||||
|
|
||||||
DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
|
DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
|
||||||
|
@ -53,6 +55,7 @@ int main() {
|
||||||
dbus_connection_setup_with_g_main(conn, NULL);
|
dbus_connection_setup_with_g_main(conn, NULL);
|
||||||
|
|
||||||
n = notify_send_notification(NULL, // replaces nothing
|
n = notify_send_notification(NULL, // replaces nothing
|
||||||
|
"presence.online",
|
||||||
NOTIFY_URGENCY_NORMAL,
|
NOTIFY_URGENCY_NORMAL,
|
||||||
"Matt is online", NULL,
|
"Matt is online", NULL,
|
||||||
NULL, // no icon
|
NULL, // no icon
|
||||||
|
|
|
@ -29,6 +29,7 @@ int main() {
|
||||||
NotifyIcon *icon = notify_icon_new("/no-such");
|
NotifyIcon *icon = notify_icon_new("/no-such");
|
||||||
|
|
||||||
NotifyHandle *n = notify_send_notification(NULL, // replaces nothing
|
NotifyHandle *n = notify_send_notification(NULL, // replaces nothing
|
||||||
|
NULL,
|
||||||
NOTIFY_URGENCY_NORMAL,
|
NOTIFY_URGENCY_NORMAL,
|
||||||
"Summary", "Content",
|
"Summary", "Content",
|
||||||
icon, // no icon
|
icon, // no icon
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
#include <dbus/dbus-glib.h>
|
#include <dbus/dbus-glib.h>
|
||||||
|
#include <dbus/dbus-glib-lowlevel.h>
|
||||||
|
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
NotifyHandle *n;
|
NotifyHandle *n;
|
||||||
|
@ -50,6 +51,7 @@ static void send(char *i, size_t rawlen, char *s, char *b)
|
||||||
icon = notify_icon_new(i);
|
icon = notify_icon_new(i);
|
||||||
|
|
||||||
n = notify_send_notification(NULL, // replaces nothing
|
n = notify_send_notification(NULL, // replaces nothing
|
||||||
|
NULL,
|
||||||
NOTIFY_URGENCY_NORMAL,
|
NOTIFY_URGENCY_NORMAL,
|
||||||
s, b,
|
s, b,
|
||||||
icon,
|
icon,
|
||||||
|
|
|
@ -26,12 +26,13 @@
|
||||||
int main() {
|
int main() {
|
||||||
notify_init("Markup");
|
notify_init("Markup");
|
||||||
|
|
||||||
NotifyHandle *n = notify_send_notification(NULL, // replaces nothing
|
NotifyHandle *n = notify_send_notification(
|
||||||
|
NULL, // replaces nothing
|
||||||
|
NULL,
|
||||||
NOTIFY_URGENCY_NORMAL,
|
NOTIFY_URGENCY_NORMAL,
|
||||||
"Summary",
|
"Summary",
|
||||||
|
"Some <b>bold</b>, <u>underlined</u>, <i>italic</i>, "
|
||||||
"Some <b>bold</b>, <u>underlined</u>, <i>italic</i>, <a href='google.com'>linked</a> text",
|
"<a href='google.com'>linked</a> text",
|
||||||
|
|
||||||
NULL, // no icon
|
NULL, // no icon
|
||||||
TRUE, time(NULL) + 5,
|
TRUE, time(NULL) + 5,
|
||||||
NULL, // no user data
|
NULL, // no user data
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
#include <dbus/dbus-glib.h>
|
#include <dbus/dbus-glib.h>
|
||||||
|
#include <dbus/dbus-glib-lowlevel.h>
|
||||||
|
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
NotifyHandle *n;
|
NotifyHandle *n;
|
||||||
|
@ -63,12 +64,14 @@ int main() {
|
||||||
dbus_connection_setup_with_g_main(conn, NULL);
|
dbus_connection_setup_with_g_main(conn, NULL);
|
||||||
|
|
||||||
n = notify_send_notification(NULL, // replaces nothing
|
n = notify_send_notification(NULL, // replaces nothing
|
||||||
|
"device",
|
||||||
NOTIFY_URGENCY_NORMAL,
|
NOTIFY_URGENCY_NORMAL,
|
||||||
"Low disk space", "You can free up some disk space by emptying the trash can.",
|
"Low disk space",
|
||||||
|
"You can free up some disk space by "
|
||||||
|
"emptying the trash can.",
|
||||||
NULL, // no icon
|
NULL, // no icon
|
||||||
FALSE, 0, // does not expire
|
FALSE, 0, // does not expire
|
||||||
NULL, // no user data
|
NULL, // no user data
|
||||||
|
|
||||||
3, // 3 actions
|
3, // 3 actions
|
||||||
0, "default", callback,
|
0, "default", callback,
|
||||||
1, "Empty Trash", callback,
|
1, "Empty Trash", callback,
|
||||||
|
|
|
@ -27,6 +27,7 @@ int main() {
|
||||||
notify_init("Replace Test");
|
notify_init("Replace Test");
|
||||||
|
|
||||||
NotifyHandle *n = notify_send_notification(NULL, // replaces nothing
|
NotifyHandle *n = notify_send_notification(NULL, // replaces nothing
|
||||||
|
NULL,
|
||||||
NOTIFY_URGENCY_NORMAL,
|
NOTIFY_URGENCY_NORMAL,
|
||||||
"Summary", "Content",
|
"Summary", "Content",
|
||||||
NULL, // no icon
|
NULL, // no icon
|
||||||
|
@ -42,8 +43,9 @@ int main() {
|
||||||
|
|
||||||
sleep(3);
|
sleep(3);
|
||||||
|
|
||||||
notify_send_notification(n, NOTIFY_URGENCY_NORMAL, "Second Summary", "Second Content",
|
notify_send_notification(n, NULL, NOTIFY_URGENCY_NORMAL,
|
||||||
NULL, TRUE, time(NULL) + 5, NULL, 0);
|
"Second Summary", "Second Content",
|
||||||
|
NULL, TRUE, 5, NULL, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,36 +31,39 @@ int
|
||||||
main(int argc, const char **argv)
|
main(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
const gchar *summary = NULL;
|
const gchar *summary = NULL;
|
||||||
const gchar *description = NULL;
|
const gchar *body = NULL;
|
||||||
|
const gchar *type = NULL;
|
||||||
char *urgency_str = NULL;
|
char *urgency_str = NULL;
|
||||||
gchar *sound = NULL;
|
|
||||||
gchar *icons = NULL;
|
gchar *icons = NULL;
|
||||||
gchar *icon_str = NULL;
|
gchar *icon_str = NULL;
|
||||||
NotifyIcon *icon = NULL;
|
NotifyIcon *icon = NULL;
|
||||||
NotifyUrgency urgency = NOTIFY_URGENCY_NORMAL;
|
NotifyUrgency urgency = NOTIFY_URGENCY_NORMAL;
|
||||||
time_t expire_time = 0;
|
time_t expire_timeout = 0;
|
||||||
char ch;
|
char ch;
|
||||||
poptContext opt_ctx;
|
poptContext opt_ctx;
|
||||||
const char **args;
|
const char **args;
|
||||||
struct poptOption options[] =
|
struct poptOption options[] =
|
||||||
{
|
{
|
||||||
{ "urgency", 'u', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, &urgency_str,
|
{ "urgency", 'u', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, &urgency_str,
|
||||||
0, N_("Specifies the urgency level (low, normal, high, critical)"),
|
0, N_("Specifies the urgency level (low, normal, critical)."),
|
||||||
NULL },
|
NULL },
|
||||||
{ "expire-time", 't', POPT_ARG_INT | POPT_ARGFLAG_STRIP, &expire_time,
|
{ "expire-time", 't', POPT_ARG_INT | POPT_ARGFLAG_STRIP,
|
||||||
0, N_("Specifies the timestamp at which to expire the notification, or if < current time, specifies timeout in seconds from current time"),
|
&expire_timeout, 0,
|
||||||
|
N_("Specifies the timeout in seconds at which to expire the "
|
||||||
|
"notification."),
|
||||||
NULL },
|
NULL },
|
||||||
{ "sound", 's', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, &sound, 0,
|
|
||||||
N_("Specifies a sound file to play on notification."), NULL },
|
|
||||||
{ "icon", 'i', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, &icons, 0,
|
{ "icon", 'i', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, &icons, 0,
|
||||||
N_("Specifies an icon filename or stock icon to display."),
|
N_("Specifies an icon filename or stock icon to display."),
|
||||||
N_("ICON1,ICON2,...") },
|
N_("ICON1,ICON2,...") },
|
||||||
|
{ "type", 't', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, &type, 0,
|
||||||
|
N_("Specifies the notification type."),
|
||||||
|
N_("ICON1,ICON2,...") },
|
||||||
POPT_AUTOHELP
|
POPT_AUTOHELP
|
||||||
POPT_TABLEEND
|
POPT_TABLEEND
|
||||||
};
|
};
|
||||||
|
|
||||||
opt_ctx = poptGetContext("notify-send", argc, argv, options, 0);
|
opt_ctx = poptGetContext("notify-send", argc, argv, options, 0);
|
||||||
poptSetOtherOptionHelp(opt_ctx, "[OPTIONS]* <summary> [description]");
|
poptSetOtherOptionHelp(opt_ctx, "[OPTIONS]* <summary> [body]");
|
||||||
|
|
||||||
while ((ch = poptGetNextOpt(opt_ctx)) >= 0)
|
while ((ch = poptGetNextOpt(opt_ctx)) >= 0)
|
||||||
;
|
;
|
||||||
|
@ -82,7 +85,7 @@ main(int argc, const char **argv)
|
||||||
|
|
||||||
if (args[1] != NULL)
|
if (args[1] != NULL)
|
||||||
{
|
{
|
||||||
description = args[1];
|
body = args[1];
|
||||||
|
|
||||||
if (args[2] != NULL)
|
if (args[2] != NULL)
|
||||||
{
|
{
|
||||||
|
@ -110,8 +113,6 @@ main(int argc, const char **argv)
|
||||||
urgency = NOTIFY_URGENCY_LOW;
|
urgency = NOTIFY_URGENCY_LOW;
|
||||||
else if (!strcasecmp(urgency_str, "normal"))
|
else if (!strcasecmp(urgency_str, "normal"))
|
||||||
urgency = NOTIFY_URGENCY_NORMAL;
|
urgency = NOTIFY_URGENCY_NORMAL;
|
||||||
else if (!strcasecmp(urgency_str, "high"))
|
|
||||||
urgency = NOTIFY_URGENCY_HIGH;
|
|
||||||
else if (!strcasecmp(urgency_str, "critical"))
|
else if (!strcasecmp(urgency_str, "critical"))
|
||||||
urgency = NOTIFY_URGENCY_CRITICAL;
|
urgency = NOTIFY_URGENCY_CRITICAL;
|
||||||
else
|
else
|
||||||
|
@ -123,11 +124,8 @@ main(int argc, const char **argv)
|
||||||
|
|
||||||
if (!notify_init("notify-send")) exit(1);
|
if (!notify_init("notify-send")) exit(1);
|
||||||
|
|
||||||
/* if the given time is < current time, treat it as a timeout in seconds (ie 5 seconds) */
|
notify_send_notification(NULL, type, urgency, summary, body, icon,
|
||||||
if (expire_time && expire_time < time(NULL)) expire_time += time(NULL);
|
TRUE, expire_timeout, NULL, 0);
|
||||||
|
|
||||||
notify_send_notification(NULL, urgency, summary, description, icon,
|
|
||||||
TRUE, expire_time, NULL, 0);
|
|
||||||
|
|
||||||
if (icon != NULL)
|
if (icon != NULL)
|
||||||
notify_icon_destroy(icon);
|
notify_icon_destroy(icon);
|
||||||
|
|
Loading…
Reference in New Issue