From 2a7396735127cf392c93bd74a4e39c2f65bf1ded Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 17 Oct 2012 07:37:20 +0200 Subject: [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 --- src/share-extension.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'src/share-extension.c') 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 #include #include +#include #include #include @@ -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); -- cgit v1.2.1