diff options
author | Jason Conti <jason.conti@gmail.com> | 2012-02-25 13:44:13 -0500 |
---|---|---|
committer | Jason Conti <jason.conti@gmail.com> | 2012-02-25 13:44:13 -0500 |
commit | a46ca96ffc7ac5f9560f3e7834974ca3f34df62d (patch) | |
tree | 181a805edefeaa4cad38cfb773e38dd59d2f951d | |
parent | 67121606d72de0fa953f02f481c7b4b37adac0fb (diff) | |
download | ayatana-indicator-notifications-a46ca96ffc7ac5f9560f3e7834974ca3f34df62d.tar.gz ayatana-indicator-notifications-a46ca96ffc7ac5f9560f3e7834974ca3f34df62d.tar.bz2 ayatana-indicator-notifications-a46ca96ffc7ac5f9560f3e7834974ca3f34df62d.zip |
* Add notification_is_empty to catch useless notifications such as
brightness and volume, which are not always properly marked.
-rw-r--r-- | src/indicator-notifications.c | 8 | ||||
-rw-r--r-- | src/notification.c | 10 | ||||
-rw-r--r-- | src/notification.h | 1 |
3 files changed, 13 insertions, 6 deletions
diff --git a/src/indicator-notifications.c b/src/indicator-notifications.c index ef83c73..4cc006c 100644 --- a/src/indicator-notifications.c +++ b/src/indicator-notifications.c @@ -28,12 +28,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. /* GStuff */ #include <glib.h> -/* -#include <glib/gprintf.h> -#include <glib-object.h> -*/ #include <glib/gi18n-lib.h> -/*#include <gio/gio.h> */ #include <gdk-pixbuf/gdk-pixbuf.h> /* Indicator Stuff */ @@ -191,7 +186,8 @@ message_received_cb(DBusSpy *spy, Notification *note, gpointer user_data) IndicatorNotifications *self = INDICATOR_NOTIFICATIONS(user_data); /* Discard volume notifications */ - if(notification_is_volume(note)) return; + if(notification_is_volume(note) || notification_is_empty(note)) + return; GtkWidget *item = new_notification_menuitem(note); g_object_unref(note); diff --git a/src/notification.c b/src/notification.c index c76da87..0788ec2 100644 --- a/src/notification.c +++ b/src/notification.c @@ -188,6 +188,16 @@ notification_is_volume(Notification *self) return self->priv->is_volume; } +/** + * A notification is considered empty if both the summary and body do not + * contain any text. + */ +gboolean +notification_is_empty(Notification *self) +{ + return (self->priv->summary_length == 0) && (self->priv->body_length == 0); +} + void notification_print(Notification *self) { diff --git a/src/notification.h b/src/notification.h index 5fc944a..a1f98f1 100644 --- a/src/notification.h +++ b/src/notification.h @@ -62,6 +62,7 @@ const gchar *notification_get_body(Notification *); gint64 notification_get_timestamp(Notification *); gchar *notification_timestamp_for_locale(Notification *); gboolean notification_is_volume(Notification *); +gboolean notification_is_empty(Notification *); void notification_print(Notification *); G_END_DECLS |