[gnome-bluetooth] Bug 584857 - Support notification deamon without actions capabilities
- From: Baptiste Mille-Mathias <baptistem src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-bluetooth] Bug 584857 - Support notification deamon without actions capabilities
- Date: Wed, 10 Jun 2009 12:42:59 -0400 (EDT)
commit 6a9fed3d9d7eb390195a7b6e48f3940a58e55553
Author: Baptiste Mille-Mathias <baptiste millemathias gmail com>
Date: Mon Jun 8 22:26:55 2009 +0200
Bug 584857 - Support notification deamon without actions capabilities
Add Actions to the notification only if the notification daemon can support them.
---
applet/agent.c | 57 ++++++++++++++++++++++++++++++++++++++----------------
applet/notify.c | 15 ++++++++++++++
applet/notify.h | 1 +
3 files changed, 56 insertions(+), 17 deletions(-)
diff --git a/applet/agent.c b/applet/agent.c
index c0a2f61..308b7a9 100644
--- a/applet/agent.c
+++ b/applet/agent.c
@@ -259,7 +259,10 @@ static void passkey_dialog(DBusGProxy *adapter, DBusGProxy *device,
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 (notification_supports_actions () != FALSE)
+ 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;
@@ -531,13 +534,18 @@ static void show_dialog(gpointer data, gpointer user_data)
gtk_window_present(GTK_WINDOW(input->dialog));
}
-static void notification_closed(GObject *object, gpointer user_data)
+static void present_notification_dialogs (void)
{
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))
@@ -588,9 +596,12 @@ static gboolean pincode_request(DBusGMethodInvocation *context,
g_free(name);
- show_notification(_("Bluetooth device"),
- line, _("Enter passkey"), 0,
- G_CALLBACK(notification_closed));
+ if (notification_supports_actions () != FALSE)
+ show_notification(_("Bluetooth device"),
+ line, _("Enter passkey"), 0,
+ G_CALLBACK(notification_closed));
+ else
+ present_notification_dialogs ();
g_free(line);
@@ -635,9 +646,12 @@ static gboolean passkey_request(DBusGMethodInvocation *context,
g_free(name);
- show_notification(_("Bluetooth device"),
- line, _("Enter passkey"), 0,
- G_CALLBACK(notification_closed));
+ if (notification_supports_actions () != FALSE)
+ show_notification(_("Bluetooth device"),
+ line, _("Enter passkey"), 0,
+ G_CALLBACK(notification_closed));
+ else
+ present_notification_dialogs ();
g_free(line);
@@ -685,9 +699,12 @@ static gboolean display_request(DBusGMethodInvocation *context,
g_free(name);
- show_notification(_("Bluetooth device"),
- line, _("Enter passkey"), 0,
- G_CALLBACK(notification_closed));
+ if (notification_supports_actions () != FALSE)
+ show_notification(_("Bluetooth device"),
+ line, _("Enter passkey"), 0,
+ G_CALLBACK(notification_closed));
+ else
+ present_notification_dialogs ();
g_free(line);
@@ -734,9 +751,12 @@ static gboolean confirm_request(DBusGMethodInvocation *context,
g_free(name);
- show_notification(_("Bluetooth device"),
- line, _("Confirm passkey"), 0,
- G_CALLBACK(notification_closed));
+ if (notification_supports_actions () != FALSE)
+ show_notification(_("Bluetooth device"),
+ line, _("Confirm passkey"), 0,
+ G_CALLBACK(notification_closed));
+ else
+ present_notification_dialogs ();
g_free(line);
@@ -779,9 +799,12 @@ static gboolean authorize_request(DBusGMethodInvocation *context,
g_free(name);
- show_notification(_("Bluetooth device"),
- line, _("Check authorization"), 0,
- G_CALLBACK(notification_closed));
+ if (notification_supports_actions () != FALSE)
+ show_notification(_("Bluetooth device"),
+ line, _("Check authorization"), 0,
+ G_CALLBACK(notification_closed));
+ else
+ present_notification_dialogs ();
g_free(line);
diff --git a/applet/notify.c b/applet/notify.c
index 4da9c2e..f4dd3b5 100644
--- a/applet/notify.c
+++ b/applet/notify.c
@@ -41,6 +41,21 @@ static void notify_action(NotifyNotification *notify,
{
}
+gboolean notification_supports_actions (void)
+{
+ gboolean supports_actions = FALSE;
+ GList *caps = NULL;
+
+ caps = notify_get_server_caps ();
+ if (g_list_find_custom(caps, "actions", (GCompareFunc)g_strcmp0) != NULL)
+ supports_actions = TRUE;
+
+ 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)
{
diff --git a/applet/notify.h b/applet/notify.h
index c39add8..9ee5cb8 100644
--- a/applet/notify.h
+++ b/applet/notify.h
@@ -25,6 +25,7 @@
GtkStatusIcon *init_notification(void);
void cleanup_notification(void);
+gboolean notification_supports_actions(void);
void show_notification(const gchar *summary, const gchar *message,
const gchar *action, gint timeout, GCallback handler);
void close_notification(void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]