From 27e05d0f9562a26163493d6cc1d5924b9a4ebf68 Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Fri, 8 Oct 2010 22:47:06 -0400 Subject: [PATCH] Remove the ability to attach notifications to widgets or positions --- docs/reference/tmpl/libnotify-unused.sgml | 43 +++++++ docs/reference/tmpl/notification.sgml | 47 -------- libnotify/notification.c | 130 +--------------------- libnotify/notification.h | 11 +- tests/test-basic.c | 3 - tests/test-default-action.c | 2 +- tests/test-error.c | 2 +- tests/test-gtk3.c | 3 - tests/test-image.c | 7 +- tests/test-markup.c | 1 - tests/test-multi-actions.c | 1 - tests/test-persistence.c | 3 +- tests/test-replace-widget.c | 3 +- tests/test-replace.c | 4 +- tests/test-rtl.c | 1 - tests/test-size-changes.c | 3 - tests/test-urgency.c | 6 +- tests/test-xy-actions.c | 1 - tests/test-xy-stress.c | 2 +- tests/test-xy.c | 1 - tools/notify-send.c | 3 +- 21 files changed, 55 insertions(+), 222 deletions(-) diff --git a/docs/reference/tmpl/libnotify-unused.sgml b/docs/reference/tmpl/libnotify-unused.sgml index e69de29..f3a1e60 100644 --- a/docs/reference/tmpl/libnotify-unused.sgml +++ b/docs/reference/tmpl/libnotify-unused.sgml @@ -0,0 +1,43 @@ + + + + + + + + + + + +@notification: +@status_icon: + + + + + + +@notification: +@attach: + + + + + + +@summary: +@body: +@icon: +@status_icon: +@Returns: + + + + + + +@notification: +@screen: +@x: +@y: + diff --git a/docs/reference/tmpl/notification.sgml b/docs/reference/tmpl/notification.sgml index 62e9a42..0e67dcf 100644 --- a/docs/reference/tmpl/notification.sgml +++ b/docs/reference/tmpl/notification.sgml @@ -79,11 +79,6 @@ not be used directly. Use the accessor functions below. - - - - - @@ -132,19 +127,6 @@ is much like G_CALLBACK(). @summary: @body: @icon: -@attach: -@Returns: - - - - - - - -@summary: -@body: -@icon: -@status_icon: @Returns: @@ -160,35 +142,6 @@ is much like G_CALLBACK(). @Returns: - - - - - -@notification: -@attach: - - - - - - - -@notification: -@status_icon: - - - - - - - -@notification: -@screen: -@x: -@y: - - diff --git a/libnotify/notification.c b/libnotify/notification.c index 3e17bac..bdb69ad 100644 --- a/libnotify/notification.c +++ b/libnotify/notification.c @@ -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 */ diff --git a/libnotify/notification.h b/libnotify/notification.h index 06c5bd9..033720c 100644 --- a/libnotify/notification.h +++ b/libnotify/notification.h @@ -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); diff --git a/tests/test-basic.c b/tests/test-basic.c index 073785b..4088f15 100644 --- a/tests/test-basic.c +++ b/tests/test-basic.c @@ -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); diff --git a/tests/test-default-action.c b/tests/test-default-action.c index fe9c131..4b70623 100644 --- a/tests/test-default-action.c +++ b/tests/test-default-action.c @@ -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", diff --git a/tests/test-error.c b/tests/test-error.c index 3370416..b7b9662 100644 --- a/tests/test-error.c +++ b/tests/test-error.c @@ -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 */ diff --git a/tests/test-gtk3.c b/tests/test-gtk3.c index 8127b9c..1cc8757 100644 --- a/tests/test-gtk3.c +++ b/tests/test-gtk3.c @@ -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 diff --git a/tests/test-image.c b/tests/test-image.c index 9580cce..51b29c4 100644 --- a/tests/test-image.c +++ b/tests/test-image.c @@ -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); /* diff --git a/tests/test-markup.c b/tests/test-markup.c index ccfd6aa..0113dc7 100644 --- a/tests/test-markup.c +++ b/tests/test-markup.c @@ -34,7 +34,6 @@ main () n = notify_notification_new ("Summary", "Some bold, underlined, italic, " "linked text", - NULL, NULL); notify_notification_set_timeout (n, 3000); //3 seconds diff --git a/tests/test-multi-actions.c b/tests/test-multi-actions.c index 7e70ed6..55d78a8 100644 --- a/tests/test-multi-actions.c +++ b/tests/test-multi-actions.c @@ -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); diff --git a/tests/test-persistence.c b/tests/test-persistence.c index 0da4860..0541613 100644 --- a/tests/test-persistence.c +++ b/tests/test-persistence.c @@ -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", diff --git a/tests/test-replace-widget.c b/tests/test-replace-widget.c index 3c03ccc..1e536a4 100644 --- a/tests/test-replace-widget.c +++ b/tests/test-replace-widget.c @@ -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 diff --git a/tests/test-replace.c b/tests/test-replace.c index bf3f980..56b13c5 100644 --- a/tests/test-replace.c +++ b/tests/test-replace.c @@ -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 diff --git a/tests/test-rtl.c b/tests/test-rtl.c index 0e29f38..1ca5405 100644 --- a/tests/test-rtl.c +++ b/tests/test-rtl.c @@ -34,7 +34,6 @@ main () n = notify_notification_new ("اختبار", "يوفر ويكي عربآيز مناخا للنقاش وتبادل الخبرات والمعرفة حول اللغة العربية ولسانياتها ومايتعلّق بدعمها والإرتقاء بها في الحوسبة عموماً والبرمجيات الحرة على وجه الخصوص. هذا الويكي عبارة عن بيئة تعاونية تشاركية مفتوحة للجميع بدون قيود، لغتنا الجميلة بانتظار مساهمتك فلا تبخل عليها ", - NULL, NULL); notify_notification_set_timeout (n, 3000); diff --git a/tests/test-size-changes.c b/tests/test-size-changes.c index fd6460b..a1640c2 100644 --- a/tests/test-size-changes.c +++ b/tests/test-size-changes.c @@ -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); diff --git a/tests/test-urgency.c b/tests/test-urgency.c index 1b2de5a..734b950 100644 --- a/tests/test-urgency.c +++ b/tests/test-urgency.c @@ -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 diff --git a/tests/test-xy-actions.c b/tests/test-xy-actions.c index a6b9008..b6e3548 100644 --- a/tests/test-xy-actions.c +++ b/tests/test-xy-actions.c @@ -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); diff --git a/tests/test-xy-stress.c b/tests/test-xy-stress.c index a306f7b..e873f31 100644 --- a/tests/test-xy-stress.c +++ b/tests/test-xy-stress.c @@ -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); diff --git a/tests/test-xy.c b/tests/test-xy.c index ad4891c..ff53d98 100644 --- a/tests/test-xy.c +++ b/tests/test-xy.c @@ -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); diff --git a/tools/notify-send.c b/tools/notify-send.c index 035e675..fd69459 100644 --- a/tools/notify-send.c +++ b/tools/notify-send.c @@ -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);