From: Ken VanDine <ken.vandine@canonical.com>
To: linux-bluetooth@vger.kernel.org
Subject: Patch - Use an alert box when actions aren't supported
Date: Tue, 07 Apr 2009 09:08:09 -0400 [thread overview]
Message-ID: <1239109689.18555.7.camel@trabajo> (raw)
[-- Attachment #1: Type: text/plain, Size: 383 bytes --]
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,
--
Ken VanDine
Ubuntu - Linux for human beings | www.ubuntu.com
[-- Attachment #2: 11_bluez-notifications.patch --]
[-- Type: text/x-patch, Size: 4783 bytes --]
=== modified file 'applet/agent.c'
--- old/applet/agent.c 2008-10-30 18:07:50 +0000
+++ new/applet/agent.c 2009-03-27 14:45:19 +0000
@@ -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'
--- old/applet/notify.c 2008-10-30 18:07:50 +0000
+++ new/applet/notify.c 2009-03-27 14:42:17 +0000
@@ -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'
--- old/applet/notify.h 2008-10-30 18:07:50 +0000
+++ new/applet/notify.h 2009-03-27 14:42:47 +0000
@@ -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);
reply other threads:[~2009-04-07 13:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1239109689.18555.7.camel@trabajo \
--to=ken.vandine@canonical.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox