diff options
author | Jasmine Hassan <[email protected]> | 2012-10-17 07:37:20 +0200 |
---|---|---|
committer | Jasmine Hassan <[email protected]> | 2012-10-29 15:23:13 +0200 |
commit | 2a7396735127cf392c93bd74a4e39c2f65bf1ded (patch) | |
tree | 20c93f22c35c0df15f5dcb4baeb2c364066a27fc | |
parent | 40d028e599d8b81f087cf68cb16593e8080d9d17 (diff) | |
download | mate-user-share-2a7396735127cf392c93bd74a4e39c2f65bf1ded.tar.bz2 mate-user-share-2a7396735127cf392c93bd74a4e39c2f65bf1ded.tar.xz |
[bar] Hide the share bar when Bluetooth is disabled
A bar always appears on top of XDG_DOWNLOAD_DIR view in caja even
without a bluetooth adapter present or enabled.
This patch uses BluetoothClient's "default-adapter" property to
detect whether we have an enabled bluetooth adapter, and only if
so, show the bar telling the user they can receive files over
bluetooth into this folder.
Patch adapted for mate-user-share from Baptiste Mille-Mathias'
patch against gnome-user-share, for the same issue.
Origin: https://bugzilla.gnome.org/show_bug.cgi?id=613584
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | src/share-extension.c | 33 |
2 files changed, 33 insertions, 2 deletions
diff --git a/configure.in b/configure.in index c45422a..e96149a 100644 --- a/configure.in +++ b/configure.in @@ -134,7 +134,7 @@ AC_ARG_WITH(cajadir, [ac_with_cajadir=""]) PKG_CHECK_MODULES(EXTENSION, - libcaja-extension) + libcaja-extension mate-bluetooth-1.0) if test "${ac_with_cajadir}" = ""; then ac_with_cajadir=`pkg-config --variable=extensiondir libcaja-extension` fi diff --git a/src/share-extension.c b/src/share-extension.c index 4c44be3..188c559 100644 --- a/src/share-extension.c +++ b/src/share-extension.c @@ -27,6 +27,7 @@ #include <string.h> #include <glib/gi18n-lib.h> #include <gtk/gtk.h> +#include <bluetooth-client.h> #include <libcaja-extension/caja-menu-provider.h> #include <libcaja-extension/caja-location-widget-provider.h> @@ -100,6 +101,27 @@ bar_response_cb (CajaShareBar *bar, } } +static void +downloads_bar_set_from_bluetooth_status (GtkWidget *bar) +{ + BluetoothClient *client; + gboolean bt_powered; + + client = g_object_get_data (G_OBJECT (bar), "bluetooth-client"); + g_object_get (G_OBJECT (client), + "default-adapter-powered", &bt_powered, + NULL); + gtk_widget_set_visible (bar, bt_powered); +} + +static void +default_adapter_powered_cb (GObject *gobject, + GParamSpec *pspec, + GtkWidget *bar) +{ + downloads_bar_set_from_bluetooth_status (bar); +} + static GtkWidget * caja_user_share_get_location_widget (CajaLocationWidgetProvider *iface, const char *uri, @@ -143,14 +165,23 @@ caja_user_share_get_location_widget (CajaLocationWidgetProvider *iface, } else if (is_dir[0] != FALSE) { bar = caja_share_bar_new (_("May be shared over the network or Bluetooth")); } else { + BluetoothClient *client; + bar = caja_share_bar_new (_("May be used to receive files over Bluetooth")); + + gtk_widget_set_no_show_all (bar, TRUE); + client = bluetooth_client_new (); + g_object_set_data_full (G_OBJECT (bar), "bluetooth-client", client, g_object_unref); + g_signal_connect (G_OBJECT (client), "notify::default-adapter-powered", + G_CALLBACK (default_adapter_powered_cb), bar); + downloads_bar_set_from_bluetooth_status (bar); } g_signal_connect (bar, "response", G_CALLBACK (bar_response_cb), window); - gtk_widget_show (bar); + gtk_widget_show_all (bar); g_object_unref (file); |