Remove the ability to attach notifications to widgets or positions

This commit is contained in:
William Jon McCann 2010-10-08 22:47:06 -04:00
parent 3f14ad4c71
commit 27e05d0f95
21 changed files with 55 additions and 222 deletions

View File

@ -0,0 +1,43 @@
<!-- ##### ARG NotifyNotification:status-icon ##### -->
<para>
</para>
<!-- ##### FUNCTION notify_notification_attach_to_status_icon ##### -->
<para>
</para>
@notification:
@status_icon:
<!-- ##### FUNCTION notify_notification_attach_to_widget ##### -->
<para>
</para>
@notification:
@attach:
<!-- ##### FUNCTION notify_notification_new_with_status_icon ##### -->
<para>
</para>
@summary:
@body:
@icon:
@status_icon:
@Returns:
<!-- ##### FUNCTION notify_notification_set_geometry_hints ##### -->
<para>
</para>
@notification:
@screen:
@x:
@y:

View File

@ -79,11 +79,6 @@ not be used directly. Use the accessor functions below.
</para>
<!-- ##### ARG NotifyNotification:status-icon ##### -->
<para>
</para>
<!-- ##### ARG NotifyNotification:summary ##### -->
<para>
@ -132,19 +127,6 @@ is much like G_CALLBACK().
@summary:
@body:
@icon:
@attach:
@Returns:
<!-- ##### FUNCTION notify_notification_new_with_status_icon ##### -->
<para>
</para>
@summary:
@body:
@icon:
@status_icon:
@Returns:
@ -160,35 +142,6 @@ is much like G_CALLBACK().
@Returns:
<!-- ##### FUNCTION notify_notification_attach_to_widget ##### -->
<para>
</para>
@notification:
@attach:
<!-- ##### FUNCTION notify_notification_attach_to_status_icon ##### -->
<para>
</para>
@notification:
@status_icon:
<!-- ##### FUNCTION notify_notification_set_geometry_hints ##### -->
<para>
</para>
@notification:
@screen:
@x:
@y:
<!-- ##### FUNCTION notify_notification_show ##### -->
<para>

View File

@ -79,8 +79,6 @@ struct _NotifyNotificationPrivate
GHashTable *action_map;
GHashTable *hints;
GtkWidget *attached_widget;
gboolean has_nondefault_actions;
gboolean updates_pending;
gboolean signals_registered;
@ -101,7 +99,6 @@ enum
PROP_SUMMARY,
PROP_BODY,
PROP_ICON_NAME,
PROP_ATTACH_WIDGET,
PROP_CLOSED_REASON
};
@ -213,18 +210,6 @@ notify_notification_class_init (NotifyNotificationClass *klass)
| G_PARAM_STATIC_NICK
| G_PARAM_STATIC_BLURB));
g_object_class_install_property (object_class,
PROP_ATTACH_WIDGET,
g_param_spec_object ("attach-widget",
"Attach Widget",
"The widget to attach the notification to",
GTK_TYPE_WIDGET,
G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
| G_PARAM_STATIC_NAME
| G_PARAM_STATIC_NICK
| G_PARAM_STATIC_BLURB));
g_object_class_install_property (object_class,
PROP_CLOSED_REASON,
g_param_spec_int ("closed-reason",
@ -274,11 +259,6 @@ notify_notification_set_property (GObject *object,
g_value_get_string (value));
break;
case PROP_ATTACH_WIDGET:
notify_notification_attach_to_widget (notification,
g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -311,10 +291,6 @@ notify_notification_get_property (GObject *object,
g_value_set_string (value, priv->icon_name);
break;
case PROP_ATTACH_WIDGET:
g_value_set_object (value, priv->attached_widget);
break;
case PROP_CLOSED_REASON:
g_value_set_int (value, priv->closed_reason);
break;
@ -400,9 +376,6 @@ notify_notification_finalize (GObject *object)
if (priv->hints != NULL)
g_hash_table_destroy (priv->hints);
if (priv->attached_widget != NULL)
g_object_unref (G_OBJECT (priv->attached_widget));
proxy = _notify_get_g_proxy ();
if (proxy != NULL && priv->signals_registered) {
g_signal_handlers_disconnect_by_func (proxy,
@ -424,42 +397,11 @@ notify_notification_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
_notify_notification_update_applet_hints (NotifyNotification *n)
{
NotifyNotificationPrivate *priv = n->priv;
GdkScreen *screen = NULL;
gint x, y;
if (priv->attached_widget != NULL) {
GtkWidget *widget = priv->attached_widget;
GtkAllocation allocation;
screen = gtk_widget_get_screen (widget);
gdk_window_get_origin (gtk_widget_get_window (widget), &x, &y);
gtk_widget_get_allocation (widget, &allocation);
if (!gtk_widget_get_has_window (widget)) {
x += allocation.x;
y += allocation.y;
}
x += allocation.width / 2;
y += allocation.height / 2;
} else {
return;
}
notify_notification_set_geometry_hints (n, screen, x, y);
}
/**
* notify_notification_new:
* @summary: The required summary text.
* @body: The optional body text.
* @icon: The optional icon theme icon name or filename.
* @attach: The optional widget to attach to.
*
* Creates a new #NotifyNotification. The summary text is required, but
* all other parameters are optional.
@ -469,16 +411,12 @@ _notify_notification_update_applet_hints (NotifyNotification *n)
NotifyNotification *
notify_notification_new (const char *summary,
const char *body,
const char *icon,
GtkWidget *attach)
const char *icon)
{
g_return_val_if_fail (attach == NULL || GTK_IS_WIDGET (attach), NULL);
return g_object_new (NOTIFY_TYPE_NOTIFICATION,
"summary", summary,
"body", body,
"icon-name", icon,
"attach-widget", attach,
NULL);
}
@ -530,69 +468,6 @@ notify_notification_update (NotifyNotification *notification,
return TRUE;
}
/**
* notify_notification_attach_to_widget:
* @notification: The notification.
* @attach: The widget to attach to, or %NULL.
*
* Attaches the notification to a widget. This will set hints on the
* notification requesting that the notification point to the widget's
* location. If @attach is %NULL, the widget will be unset.
*/
void
notify_notification_attach_to_widget (NotifyNotification *notification,
GtkWidget *attach)
{
g_return_if_fail (NOTIFY_IS_NOTIFICATION (notification));
if (notification->priv->attached_widget == attach)
return;
if (notification->priv->attached_widget != NULL)
g_object_unref (notification->priv->attached_widget);
notification->priv->attached_widget =
(attach != NULL ? g_object_ref (attach) : NULL);
g_object_notify (G_OBJECT (notification), "attach-widget");
}
/**
* notify_notification_set_geometry_hints:
* @notification: The notification.
* @screen: The #GdkScreen the notification should appear on.
* @x: The X coordinate to point to.
* @y: The Y coordinate to point to.
*
* Sets the geometry hints on the notification. This sets the screen
* the notification should appear on and the X, Y coordinates it should
* point to, if the particular notification supports X, Y hints.
*
* Since: 0.4.1
*/
void
notify_notification_set_geometry_hints (NotifyNotification *notification,
GdkScreen *screen,
gint x,
gint y)
{
char *display_name;
g_return_if_fail (notification != NULL);
g_return_if_fail (NOTIFY_IS_NOTIFICATION (notification));
g_return_if_fail (screen != NULL);
g_return_if_fail (GDK_IS_SCREEN (screen));
notify_notification_set_hint_int32 (notification, "x", x);
notify_notification_set_hint_int32 (notification, "y", y);
display_name = gdk_screen_make_display_name (screen);
notify_notification_set_hint_string (notification,
"xdisplay",
display_name);
g_free (display_name);
}
static void
_close_signal_handler (DBusGProxy *proxy,
guint32 id,
@ -703,9 +578,6 @@ notify_notification_show (NotifyNotification *notification,
priv->signals_registered = TRUE;
}
/* If attached to a widget, modify x and y in hints */
_notify_notification_update_applet_hints (notification);
action_array = _gslist_to_string_array (priv->actions);
/* TODO: make this nonblocking */

View File

@ -78,22 +78,13 @@ GType notify_notification_get_type (void);
NotifyNotification *notify_notification_new (const char *summary,
const char *body,
const char *icon,
GtkWidget *attach);
const char *icon);
gboolean notify_notification_update (NotifyNotification *notification,
const char *summary,
const char *body,
const char *icon);
void notify_notification_attach_to_widget (NotifyNotification *notification,
GtkWidget *attach);
void notify_notification_set_geometry_hints (NotifyNotification *notification,
GdkScreen *screen,
gint x,
gint y);
gboolean notify_notification_show (NotifyNotification *notification,
GError **error);

View File

@ -34,7 +34,6 @@ main ()
/* 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,
NULL);
notify_notification_set_timeout (n, 3000); //3 seconds
@ -48,7 +47,6 @@ main ()
/* 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,
NULL);
notify_notification_set_timeout (n, 3000); //3 seconds
@ -61,7 +59,6 @@ main ()
/* Summary only */
n = notify_notification_new ("Summary only there is no message content",
NULL,
NULL,
NULL);
notify_notification_set_timeout (n, NOTIFY_EXPIRES_NEVER);

View File

@ -64,7 +64,7 @@ main ()
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);
notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT);
notify_notification_add_action (n,
"default",

View File

@ -33,7 +33,7 @@ main ()
notify_init ("Error Handling");
n = notify_notification_new ("Summary", "Content", NULL, NULL);
n = notify_notification_new ("Summary", "Content", NULL);
notify_notification_set_timeout (n, 3000); //3 seconds
/* TODO: Create an error condition */

View File

@ -34,7 +34,6 @@ main ()
/* 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,
NULL);
notify_notification_set_timeout (n, 3000); //3 seconds
@ -48,7 +47,6 @@ main ()
/* 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,
NULL);
notify_notification_set_timeout (n, 3000); //3 seconds
@ -61,7 +59,6 @@ main ()
/* Summary only */
n = notify_notification_new ("Summary only there is no message content",
NULL,
NULL,
NULL);
notify_notification_set_timeout (n, 3000); //3 seconds

View File

@ -59,8 +59,7 @@ main (int argc, char *argv[])
/* Stock icon */
n = notify_notification_new ("Icon Test",
"Testing stock icon",
"appointment-new",
NULL);
"appointment-new");
if (!notify_notification_show (n, NULL)) {
fprintf (stderr, "failed to send notification\n");
@ -80,8 +79,7 @@ main (int argc, char *argv[])
/* URIs */
n = notify_notification_new ("Alert!",
"Testing URI icons",
uri,
NULL);
uri);
if (!notify_notification_show (n, NULL)) {
fprintf (stderr, "failed to send notification\n");
@ -93,7 +91,6 @@ main (int argc, char *argv[])
/* Raw image */
n = notify_notification_new ("Raw image test",
"Testing sending raw pixbufs",
NULL,
NULL);
/*

View File

@ -34,7 +34,6 @@ main ()
n = notify_notification_new ("Summary",
"Some <b>bold</b>, <u>underlined</u>, <i>italic</i>, "
"<a href='http://www.google.com'>linked</a> text",
NULL,
NULL);
notify_notification_set_timeout (n, 3000); //3 seconds

View File

@ -95,7 +95,6 @@ main (int argc, char **argv)
n = notify_notification_new ("Low disk space",
"You can free up some disk space by "
"emptying the trash can.",
NULL,
NULL);
notify_notification_set_urgency (n, NOTIFY_URGENCY_CRITICAL);
notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT);

View File

@ -67,8 +67,7 @@ main (int argc, char *argv[])
n = notify_notification_new ("Software Updates Available",
"Important updates for your apps are now available.",
"software-update-available",
NULL);
"software-update-available");
notify_notification_add_action (n,
"install",
"Install now",

View File

@ -74,8 +74,7 @@ main (int argc, char *argv[])
n = notify_notification_new ("Widget Attachment Test",
"Button has not been clicked yet",
NULL, //no icon
button); //attach to button
NULL); //no icon
notify_notification_set_timeout (n, 0); //don't timeout

View File

@ -34,9 +34,7 @@ main ()
n = notify_notification_new ("Summary",
"First message",
NULL, //no icon
NULL); //don't attach to widget
NULL); //no icon
notify_notification_set_timeout (n, 0); //don't timeout

View File

@ -34,7 +34,6 @@ main ()
n = notify_notification_new ("اختبار",
"يوفر ويكي عربآيز مناخا للنقاش وتبادل الخبرات والمعرفة حول اللغة العربية ولسانياتها ومايتعلّق بدعمها والإرتقاء بها في الحوسبة عموماً والبرمجيات الحرة على وجه الخصوص. هذا الويكي عبارة عن بيئة تعاونية تشاركية مفتوحة للجميع بدون قيود، لغتنا الجميلة بانتظار مساهمتك فلا تبخل عليها ",
NULL,
NULL);
notify_notification_set_timeout (n, 3000);

View File

@ -33,7 +33,6 @@ main ()
n1 = notify_notification_new ("Notification 1",
"Notification number 1!",
NULL,
NULL);
notify_notification_set_timeout (n1, 7000);
@ -46,7 +45,6 @@ main ()
n2 = notify_notification_new ("Notification 2",
"Notification number 2!",
NULL,
NULL);
notify_notification_set_timeout (n2, 7000);
@ -58,7 +56,6 @@ main ()
n3 = notify_notification_new ("Notification 3",
"Notification number 3!",
NULL,
NULL);
notify_notification_set_timeout (n3, 7000);

View File

@ -32,7 +32,6 @@ main (int argc, char *argv[])
n = notify_notification_new ("Low Urgency",
"Joe signed online.",
NULL,
NULL);
notify_notification_set_urgency (n, NOTIFY_URGENCY_LOW);
if (!notify_notification_show (n, NULL)) {
@ -45,7 +44,6 @@ main (int argc, char *argv[])
n = notify_notification_new ("Normal Urgency",
"You have a meeting in 10 minutes.",
NULL,
NULL);
notify_notification_set_urgency (n, NOTIFY_URGENCY_NORMAL);
if (!notify_notification_show (n, NULL)) {
@ -57,9 +55,7 @@ main (int argc, char *argv[])
n = notify_notification_new ("Critical Urgency",
"This message will self-destruct in 10 "
"seconds.",
NULL,
"This message will self-destruct in 10 seconds.",
NULL);
notify_notification_set_urgency (n, NOTIFY_URGENCY_CRITICAL);
notify_notification_set_timeout (n, 10000); // 10 seconds

View File

@ -56,7 +56,6 @@ main (int argc, char **argv)
n = notify_notification_new ("System update available",
"New system updates are available. It is "
"recommended that you install the updates.",
NULL,
NULL);
notify_notification_set_hint_int32 (n, "x", 600);

View File

@ -42,7 +42,7 @@ emit_notification (int x, int y)
x,
y);
n = notify_notification_new ("X, Y Test", buffer, NULL, NULL);
n = notify_notification_new ("X, Y Test", buffer, NULL);
g_free (buffer);
notify_notification_set_hint_int32 (n, "x", x);

View File

@ -33,7 +33,6 @@ main ()
n = notify_notification_new ("X, Y Test",
"This notification should point to 150, 10",
NULL,
NULL);
notify_notification_set_hint_int32 (n, "x", 150);

View File

@ -221,8 +221,7 @@ main (int argc, char *argv[])
notify = notify_notification_new (summary,
body,
icon_str,
NULL);
icon_str);
notify_notification_set_category (notify, type);
notify_notification_set_urgency (notify, urgency);
notify_notification_set_timeout (notify, expire_timeout);