Added support for sending the status icon XID to the notification daemon. This will allow better position tracking for context notifications. Patch by Colin Walters.

This commit is contained in:
Christian Hammond 2008-09-26 01:12:47 +00:00
parent f4ff83ff20
commit d5addcc1f4
3 changed files with 51 additions and 0 deletions

3
NEWS
View File

@ -3,6 +3,9 @@ version 0.4.5:
Rocha.
* Added support for sending the closed reason in the "closed" signal
handler. (Ticket #139)
* Added support for sending the status icon XID to the notification
daemon. This will allow better position tracking for context
notifications. Patch by Colin Walters.
* Fixed a breakage where we were including gtkversion.h directly.
version 0.4.4 (27-February-2007):

View File

@ -31,6 +31,7 @@
# define HAVE_STATUS_ICON
# include <gtk/gtkstatusicon.h>
#endif
#include <gdk/gdkx.h>
#define CHECK_DBUS_VERSION(major, minor) \
(DBUS_MAJOR_VER > (major) || \
@ -396,6 +397,13 @@ notify_notification_finalize(GObject *object)
G_OBJECT_CLASS(parent_class)->finalize(object);
}
static GtkWidget *
get_internal_tray_icon (GtkStatusIcon *status)
{
/* This function is a temporary hack */
return GTK_WIDGET (*((GtkWidget**)(status->priv)));
}
static void
_notify_notification_update_applet_hints(NotifyNotification *n)
{
@ -407,6 +415,18 @@ _notify_notification_update_applet_hints(NotifyNotification *n)
if (priv->status_icon != NULL)
{
GdkRectangle rect;
GtkWidget *internal_tray = get_internal_tray_icon (priv->status_icon);
GdkWindow *window;
// TODO: this is sort of a hack, but we need a window ID to send along
gtk_widget_realize (internal_tray);
window = internal_tray->window;
if (window != NULL)
{
guint32 xid = GDK_WINDOW_XID (window);
notify_notification_set_hint_uint32(n, "window-xid", xid);
}
if (!gtk_status_icon_get_geometry(priv->status_icon, &screen,
&rect, NULL))
@ -1003,6 +1023,32 @@ notify_notification_set_hint_int32(NotifyNotification *notification,
g_strdup(key), hint_value);
}
/**
* notify_notification_set_hint_uint32:
* @notification: The notification.
* @key: The hint.
* @value: The hint's value.
*
* Sets a hint with an unsigned 32-bit integer value.
*/
void
notify_notification_set_hint_uint32(NotifyNotification *notification,
const gchar *key, guint value)
{
GValue *hint_value;
g_return_if_fail(notification != NULL);
g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification));
g_return_if_fail(key != NULL && *key != '\0');
hint_value = g_new0(GValue, 1);
g_value_init(hint_value, G_TYPE_UINT);
g_value_set_uint(hint_value, value);
g_hash_table_insert(notification->priv->hints,
g_strdup(key), hint_value);
}
/**
* notify_notification_set_hint_double:
* @notification: The notification.

View File

@ -127,6 +127,8 @@ void notify_notification_set_icon_from_pixbuf(NotifyNotification *notification,
void notify_notification_set_hint_int32(NotifyNotification *notification,
const gchar *key, gint value);
void notify_notification_set_hint_uint32(NotifyNotification *notification,
const gchar *key, guint value);
void notify_notification_set_hint_double(NotifyNotification *notification,
const gchar *key, gdouble value);