diff -uNr gnome-bluetooth.orig/applet/main.c gnome-bluetooth-2.31.90/applet/main.c --- gnome-bluetooth.orig/applet/main.c 2010-09-13 11:48:37.000000000 +0100 +++ gnome-bluetooth-2.31.90/applet/main.c 2010-09-21 14:26:18.000000000 +0100 @@ -31,6 +31,9 @@ #include +#ifdef HAVE_APP_INDICATOR +#include +#endif /* HAVE_APP_INDICATOR */ #include #include #include @@ -515,7 +518,13 @@ if (iter == NULL) { discover_lock = FALSE; +#ifdef HAVE_APP_INDICATOR + gtk_action_set_sensitive (GTK_TOGGLE_ACTION (object), FALSE); + gtk_action_set_visible (GTK_ACTION (object), TRUE); + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (object), FALSE); +#else gtk_action_set_visible (GTK_ACTION (object), FALSE); +#endif return; } @@ -523,7 +532,11 @@ BLUETOOTH_COLUMN_DISCOVERABLE, &discoverable, -1); +#ifndef HAVE_APP_INDICATOR gtk_action_set_visible (GTK_ACTION (object), TRUE); +#else + gtk_action_set_sensitive (GTK_TOGGLE_ACTION (object), TRUE); +#endif gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (object), discoverable); discover_lock = FALSE; @@ -1085,7 +1098,11 @@ int main(int argc, char *argv[]) { UniqueApp *app; +#ifdef HAVE_APP_INDICATOR + AppIndicator *indicator; +#else GtkStatusIcon *statusicon; +#endif /* HAVE_APP_INDICATOR */ GtkWidget *menu; GOptionContext *context; GError *error = NULL; @@ -1120,9 +1137,10 @@ } g_set_application_name(_("Bluetooth Applet")); - + gtk_window_set_default_icon_name("bluetooth"); - + + killswitch = bluetooth_killswitch_new (); g_signal_connect (G_OBJECT (killswitch), "state-changed", G_CALLBACK (killswitch_state_changed), NULL); @@ -1158,14 +1176,21 @@ g_signal_connect (G_OBJECT (settings), "changed::" PREF_SHOW_ICON, G_CALLBACK (show_icon_changed), NULL); +#ifdef HAVE_APP_INDICATOR + indicator = init_notification(); + app_indicator_set_menu(indicator, GTK_MENU(menu)); +#else statusicon = init_notification(); +#endif /* HAVE_APP_INDICATOR */ update_icon_visibility(); +#ifndef HAVE_APP_INDICATOR g_signal_connect(statusicon, "activate", G_CALLBACK(activate_callback), menu); g_signal_connect(statusicon, "popup-menu", G_CALLBACK(popup_callback), menu); +#endif /* HAVE_APP_INDICATOR */ setup_agents(); diff -uNr gnome-bluetooth.orig/applet/Makefile.am gnome-bluetooth-2.31.90/applet/Makefile.am --- gnome-bluetooth.orig/applet/Makefile.am 2009-09-21 17:10:03.000000000 +0100 +++ gnome-bluetooth-2.31.90/applet/Makefile.am 2010-09-21 11:01:43.000000000 +0100 @@ -17,6 +17,13 @@ INCLUDES = -I$(top_srcdir)/lib +if HAVE_APP_INDICATOR +bluetooth_applet_LDADD += $(APP_INDICATOR_LIBS) +test_agentdialog_LDADD += $(APP_INDICATOR_LIBS) +test_icon_LDADD += $(APP_INDICATOR_LIBS) +INCLUDES += -DHAVE_APP_INDICATOR $(APP_INDICATOR_CFLAGS) +endif + man_MANS = bluetooth-applet.1 ui_DATA = popup-menu.ui authorisation-dialogue.ui confirm-dialogue.ui passkey-dialogue.ui diff -uNr gnome-bluetooth.orig/applet/notify.c gnome-bluetooth-2.31.90/applet/notify.c --- gnome-bluetooth.orig/applet/notify.c 2010-09-13 11:48:37.000000000 +0100 +++ gnome-bluetooth-2.31.90/applet/notify.c 2010-09-21 11:01:43.000000000 +0100 @@ -29,9 +29,16 @@ #include #include #include +#ifdef HAVE_APP_INDICATOR +#include +#endif /* HAVE_APP_INDICATOR */ #include "notify.h" +#ifdef HAVE_APP_INDICATOR +static AppIndicator *indicator = NULL; +#else static GtkStatusIcon *statusicon = NULL; +#endif /* HAVE_APP_INDICATOR */ static char *icon_name = NULL; static char *tooltip = NULL; static NotifyNotification *notify = NULL; @@ -75,6 +82,7 @@ notify_notification_set_timeout(notify, timeout); +#ifndef HAVE_APP_INDICATOR if (gtk_status_icon_get_visible(statusicon) == TRUE) { gtk_status_icon_get_geometry(statusicon, &screen, &area, NULL); @@ -83,6 +91,7 @@ notify_notification_set_hint_int32(notify, "y", area.y + area.height / 2); } +#endif /* HAVE_APP_INDICATOR */ notify_notification_set_urgency(notify, NOTIFY_URGENCY_NORMAL); @@ -106,6 +115,21 @@ } } +#ifdef HAVE_APP_INDICATOR +AppIndicator *init_notification(void) +{ + notify_init("bluetooth-manager"); + + indicator = app_indicator_new("bluetooth-manager", + icon_name, + APP_INDICATOR_CATEGORY_HARDWARE); + + /* TODO: Change this to an appropriate icon. */ + app_indicator_set_attention_icon (indicator, "bluetooth-manager"); + + return indicator; +} +#else GtkStatusIcon *init_notification(void) { notify_init("bluetooth-manager"); @@ -121,12 +145,17 @@ return statusicon; } +#endif /* HAVE_APP_INDICATOR */ void cleanup_notification(void) { close_notification(); +#ifdef HAVE_APP_INDICATOR + g_object_unref(indicator); +#else g_object_unref(statusicon); +#endif /* HAVE_APP_INDICATOR */ g_free (icon_name); icon_name = NULL; @@ -138,14 +167,24 @@ void show_icon(void) { +#ifdef HAVE_APP_INDICATOR + if (indicator != NULL) + app_indicator_set_status(indicator, APP_INDICATOR_STATUS_ACTIVE); +#else if (statusicon != NULL) gtk_status_icon_set_visible(statusicon, TRUE); +#endif /* HAVE_APP_INDICATOR */ } void hide_icon(void) { +#ifdef HAVE_APP_INDICATOR + if (indicator != NULL) + app_indicator_set_status(indicator, APP_INDICATOR_STATUS_PASSIVE); +#else if (statusicon != NULL) gtk_status_icon_set_visible(statusicon, FALSE); +#endif /* HAVE_APP_INDICATOR */ } void set_icon(gboolean enabled) @@ -153,17 +192,43 @@ const char *name = (enabled ? "bluetooth-active" : "bluetooth-disabled"); const char *_tooltip = enabled ? _("Bluetooth: Enabled") : _("Bluetooth: Disabled"); +#ifdef HAVE_APP_INDICATOR + if (indicator == NULL) { +#else if (statusicon == NULL) { +#endif /* HAVE_APP_INDICATOR */ g_free (icon_name); g_free (tooltip); icon_name = g_strdup (name); tooltip = g_strdup (_tooltip); } else { +#ifdef HAVE_APP_INDICATOR + app_indicator_set_icon(indicator, name); + /* NOTE: I chose not to use the tooltip info because that information is already displayed in the menu. + See https://wiki.ubuntu.com/CustomStatusMenuDesignGuidelines#What about tooltips? */ +#else gtk_status_icon_set_from_icon_name (statusicon, name); gtk_status_icon_set_tooltip_markup(statusicon, _tooltip); +#endif /* HAVE_APP_INDICATOR */ } } +#ifdef HAVE_APP_INDICATOR +void enable_blinking(void) +{ + app_indicator_set_status (indicator, APP_INDICATOR_STATUS_ATTENTION); +} + +void disable_blinking(void) +{ + app_indicator_set_status (indicator, APP_INDICATOR_STATUS_ACTIVE); +} + +gboolean query_blinking(void) +{ + return (app_indicator_get_status (indicator) == APP_INDICATOR_STATUS_ATTENTION); +} +#else void enable_blinking(void) { gtk_status_icon_set_blinking(statusicon, TRUE); @@ -178,3 +243,4 @@ { return gtk_status_icon_get_blinking(statusicon); } +#endif /* HAVE_APP_INDICATOR */ diff -uNr gnome-bluetooth.orig/applet/notify.h gnome-bluetooth-2.31.90/applet/notify.h --- gnome-bluetooth.orig/applet/notify.h 2009-07-27 23:13:06.000000000 +0100 +++ gnome-bluetooth-2.31.90/applet/notify.h 2010-09-21 11:01:43.000000000 +0100 @@ -22,7 +22,13 @@ * */ +#ifdef HAVE_APP_INDICATOR +#include + +AppIndicator *init_notification(void); +#else GtkStatusIcon *init_notification(void); +#endif /* HAVE_APP_INDICATOR */ void cleanup_notification(void); gboolean notification_supports_actions(void); diff -uNr gnome-bluetooth.orig/applet/test-agentdialog.c gnome-bluetooth-2.31.90/applet/test-agentdialog.c --- gnome-bluetooth.orig/applet/test-agentdialog.c 2010-09-13 11:49:51.000000000 +0100 +++ gnome-bluetooth-2.31.90/applet/test-agentdialog.c 2010-09-21 11:01:43.000000000 +0100 @@ -31,7 +31,11 @@ int main(int argc, char *argv[]) { +#ifdef HAVE_APP_INDICATOR + AppIndicator *indicator; +#else GtkStatusIcon *statusicon; +#endif /* HAVE_APP_INDICATOR */ DBusGConnection *conn; DBusGProxy *adapter, *device; GError *error = NULL; @@ -53,10 +57,14 @@ } set_icon (TRUE); +#ifdef HAVE_APP_INDICATOR + indicator = init_notification(); +#else statusicon = init_notification(); g_signal_connect(statusicon, "activate", G_CALLBACK(activate_callback), NULL); +#endif /* HAVE_APP_INDICATOR */ setup_agents(); diff -uNr gnome-bluetooth.orig/configure.ac gnome-bluetooth-2.31.90/configure.ac --- gnome-bluetooth.orig/configure.ac 2010-09-13 11:58:06.000000000 +0100 +++ gnome-bluetooth-2.31.90/configure.ac 2010-09-21 11:01:43.000000000 +0100 @@ -90,6 +90,31 @@ libnotify >= $NOTIFY_REQUIRED unique-1.0) +dnl Requires for application indicators +APPINDICATOR_REQUIRED=0.0.7 + +AC_ARG_ENABLE(appindicator, + AS_HELP_STRING([--enable-appindicator[=@<:@no/auto/yes@:>@]],[Build support for application indicators ]), + [enable_appindicator=$enableval], + [enable_appindicator="auto"]) + +if test x$enable_appindicator = xauto ; then + PKG_CHECK_EXISTS([appindicator-0.1 >= $APPINDICATOR_REQUIRED], + enable_appindicator="yes", + enable_appindicator="no") +fi + +if test x$enable_appindicator = xyes ; then + PKG_CHECK_EXISTS([appindicator-0.1 >= $APPINDICATOR_REQUIRED],, + AC_MSG_ERROR([appindicator-0.1 is not installed])) + PKG_CHECK_MODULES(APP_INDICATOR, + appindicator-0.1 >= $APPINDICATOR_REQUIRED) + AC_SUBST(APP_INDICATOR_CFLAGS) + AC_SUBST(APP_INDICATOR_LIBS) + AC_DEFINE(HAVE_APP_INDICATOR, 1, [Have AppIndicator]) +fi +AM_CONDITIONAL(HAVE_APP_INDICATOR, test x"$enable_appindicator" = xyes) + dnl Requires for the sendto app PKG_CHECK_MODULES(SENDTO, dbus-glib-1 >= $DBUS_GLIB_REQUIRED @@ -230,5 +255,6 @@ nautilus-sendto plugin......: ${have_nst} Documentation...............: ${enable_gtk_doc} GObject-Introspection.......: ${found_introspection} + Application Indicators......: ${enable_appindicator} "