Patch (bug #3734) by Duarte Henriques to provide a convenient way of integrating libnotify with the glib mainloop. Modifications by me to make it even easier.
This commit is contained in:
parent
56cdbb7087
commit
12f74a149c
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Wed Jul 27 01:08:56 PDT 2005 Christian Hammond <chipx86@chipx86.com>
|
||||
|
||||
* libnotify/notify.c:
|
||||
* libnotify/notify.h:
|
||||
* tests/test-default-action.c:
|
||||
* tests/test-image.c:
|
||||
* tests/test-multi-actions.c:
|
||||
- Patch (bug #3734) by Duarte Henriques to provide a convenient way
|
||||
of integrating libnotify with the glib mainloop. Modifications by
|
||||
me to make it even easier.
|
||||
|
||||
Wed Jul 27 00:51:58 PDT 2005 Christian Hammond <chipx86@chipx86.com>
|
||||
|
||||
* tests/test-animation.c:
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "dbus-compat.h"
|
||||
#include <dbus/dbus.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <dbus/dbus-glib-lowlevel.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -356,6 +357,17 @@ notify_init(const char *app_name)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
notify_glib_init(const char *app_name, GMainContext *context)
|
||||
{
|
||||
if (!notify_init(app_name))
|
||||
return FALSE;
|
||||
|
||||
notify_setup_with_g_main(context);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
notify_uninit(void)
|
||||
{
|
||||
|
@ -386,6 +398,12 @@ notify_is_initted(void)
|
|||
return _initted;
|
||||
}
|
||||
|
||||
void
|
||||
notify_setup_with_g_main(GMainContext *context)
|
||||
{
|
||||
dbus_connection_setup_with_g_main(_dbus_conn, context);
|
||||
}
|
||||
|
||||
void
|
||||
notify_close(NotifyHandle *handle)
|
||||
{
|
||||
|
|
|
@ -61,6 +61,18 @@ typedef void (*NotifyCallback)(NotifyHandle *, guint32, gpointer);
|
|||
*/
|
||||
gboolean notify_init(const char *app_name);
|
||||
|
||||
/**
|
||||
* Initializes the notifications library and sets it up with the
|
||||
* glib mainloop.
|
||||
*
|
||||
* @param app_name The application name.
|
||||
* @param context The mainloop context, or NULL for the default.
|
||||
*
|
||||
* @return TRUE if the library initialized properly and a connection to a
|
||||
* notification server was made.
|
||||
*/
|
||||
gboolean notify_glib_init(const char *app_name, GMainContext *context);
|
||||
|
||||
/**
|
||||
* Uninitializes the notifications library.
|
||||
*
|
||||
|
@ -75,6 +87,16 @@ void notify_uninit(void);
|
|||
*/
|
||||
gboolean notify_is_initted(void);
|
||||
|
||||
/**
|
||||
* Sets up libnotify with the glib mainloop.
|
||||
*
|
||||
* This is usually best done by simply calling notify_glib_init(). However,
|
||||
* there's no harm in calling this yourself.
|
||||
*
|
||||
* @param context the #GMainContext or NULL for default context
|
||||
*/
|
||||
void notify_setup_with_g_main(GMainContext *context);
|
||||
|
||||
/**
|
||||
* Manually closes a notification.
|
||||
*
|
||||
|
|
|
@ -47,12 +47,10 @@ static void callback(NotifyHandle *handle, guint32 uid, void *user_data)
|
|||
int
|
||||
main()
|
||||
{
|
||||
if (!notify_init("Default Action Test")) exit(1);
|
||||
|
||||
DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
|
||||
loop = g_main_loop_new(NULL, FALSE);
|
||||
|
||||
dbus_connection_setup_with_g_main(conn, NULL);
|
||||
if (!notify_glib_init("Default Action Test", NULL))
|
||||
exit(1);
|
||||
|
||||
n = notify_send_notification(NULL, // replaces nothing
|
||||
"presence.online",
|
||||
|
|
|
@ -68,15 +68,18 @@ static void send(char *i, size_t rawlen, char *s, char *b)
|
|||
notify_icon_destroy(icon);
|
||||
}
|
||||
|
||||
int main() {
|
||||
if (!notify_init("Images Test")) exit(1);
|
||||
|
||||
DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
loop = g_main_loop_new(NULL, FALSE);
|
||||
|
||||
dbus_connection_setup_with_g_main(conn, NULL);
|
||||
if (!notify_glib_init("Images Test", NULL))
|
||||
exit(1);
|
||||
|
||||
// these images exist on fedora core 2 workstation profile. might not on yours
|
||||
/*
|
||||
* These images exist on fedora core 2 workstation profile.
|
||||
* Might not on yours
|
||||
*/
|
||||
|
||||
send("gnome-starthere",
|
||||
0,
|
||||
|
|
|
@ -55,13 +55,13 @@ static void callback(NotifyHandle *handle, guint32 uid, void *user_data)
|
|||
g_main_loop_quit(loop);
|
||||
}
|
||||
|
||||
int main() {
|
||||
if (!notify_init("Multi Action Test")) exit(1);
|
||||
|
||||
DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
loop = g_main_loop_new(NULL, FALSE);
|
||||
|
||||
dbus_connection_setup_with_g_main(conn, NULL);
|
||||
if (!notify_glib_init("Multi Action Test", NULL))
|
||||
exit(1);
|
||||
|
||||
n = notify_send_notification(NULL, // replaces nothing
|
||||
"device",
|
||||
|
|
Loading…
Reference in New Issue