Patch - Use an alert box when actions aren't supported
The attached patch checks if the notification daemon supports actions, and if it doesn't display an unfocused alert box instead.
For more information:
https://wiki.ubuntu.com/NotificationDevelopmentGuidelines
And the downstream bug report:
https://bugs.launchpad.net/ubuntu/+source/bluez-gnome/+bug/337219
Thanks,
Signature · 2 lines
Ken VanDine Ubuntu - Linux for human beings | www.ubuntu.com
=== modified file 'applet/agent.c'
applet/agent.c +40 -17
@@ -258,7 +258,10 @@gtk_window_set_title (GTK_WINDOW (dialog),_ ("Authentication request" ));gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);gtk_window_set_position (GTK_WINDOW (dialog),GTK_WIN_POS_CENTER ); -gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE); +if (supports_actions ()) +gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE); +else +gtk_window_set_focus_on_map (GTK_WINDOW (dialog), FALSE);gtk_window_set_urgency_hint (GTK_WINDOW (dialog), TRUE);gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); input->dialog = dialog;
@@ -530,13 +533,18 @@gtk_window_present (GTK_WINDOW (input->dialog)); } -static void notification_closed (GObject *object,gpointer user_data) +static void present_notification_dialogs () {g_list_foreach (input_list, show_dialog,NULL );disable_blinking (); } +static void notification_closed (GObject *object,gpointer user_data) +{ +present_notification_dialogs (); +} +#ifndef DBUS_TYPE_G_DICTIONARY #define DBUS_TYPE_G_DICTIONARY \ (dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
@@ -587,9 +595,12 @@g_free (name); -show_notification (_ ("Bluetooth device" ), - line,_ ("Enter PIN code" ),0 , -G_CALLBACK (notification_closed)); +if (supports_actions ()) +show_notification (_ ("Bluetooth device" ), + line,_ ("Enter PIN code" ),0 , +G_CALLBACK (notification_closed)); +else +present_notification_dialogs ();g_free (line);
@@ -634,9 +645,12 @@g_free (name); -show_notification (_ ("Bluetooth device" ), - line,_ ("Enter passkey" ),0 , -G_CALLBACK (notification_closed)); +if (supports_actions ()) +show_notification (_ ("Bluetooth device" ), + line,_ ("Enter passkey" ),0 , +G_CALLBACK (notification_closed)); +else +present_notification_dialogs ();g_free (line);
@@ -684,9 +698,12 @@g_free (name); -show_notification (_ ("Bluetooth device" ), - line,_ ("Enter passkey" ),0 , -G_CALLBACK (notification_closed)); +if (supports_actions ()) +show_notification (_ ("Bluetooth device" ), + line,_ ("Enter passkey" ),0 , +G_CALLBACK (notification_closed)); +else +present_notification_dialogs ();g_free (line);
@@ -733,9 +750,12 @@g_free (name); -show_notification (_ ("Bluetooth device" ), - line,_ ("Confirm passkey" ),0 , -G_CALLBACK (notification_closed)); +if (supports_actions ()) +show_notification (_ ("Bluetooth device" ), + line,_ ("Confirm passkey" ),0 , +G_CALLBACK (notification_closed)); +else +present_notification_dialogs ();g_free (line);
@@ -778,9 +798,12 @@g_free (name); -show_notification (_ ("Bluetooth device" ), - line,_ ("Check authorization" ),0 , -G_CALLBACK (notification_closed)); +if (supports_actions ()) +show_notification (_ ("Bluetooth device" ), + line,_ ("Check authorization" ),0 , +G_CALLBACK (notification_closed)); +else +present_notification_dialogs ();g_free (line);
=== modified file 'applet/notify.c'
applet/notify.c +29 -0
@@ -38,6 +38,35 @@ { } +gboolean +supports_actions () +{ +static gboolean supports_actions = FALSE; +static gboolean have_checked = FALSE; + +if (!have_checked) { +GList *caps =NULL ; +GList *c; + + have_checked = TRUE; + + caps =notify_get_server_caps (); +if (caps !=NULL ) { +for (c = caps; c !=NULL ; c = c->next) { +if (strcmp ((char *)c->data,"actions" ) ==0 ) { + supports_actions = TRUE; +break ; + } + } + +g_list_foreach (caps, (GFunc )g_free,NULL ); +g_list_free (caps); + } + } + +return supports_actions; +} +void show_notification (const gchar *summary,const gchar *message,const gchar *action,gint timeout,GCallback handler) {
=== modified file 'applet/notify.h'
applet/notify.h +1 -0
@@ -25,6 +25,7 @@GtkStatusIcon *init_notification (void );void cleanup_notification (void ); +gboolean supports_actions ();void show_notification (const gchar *summary,const gchar *message,const gchar *action,gint timeout,GCallback handler);void close_notification (void );