diff options
Diffstat (limited to 'src/share-extension.c')
-rw-r--r-- | src/share-extension.c | 33 |
1 files changed, 32 insertions, 1 deletions
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); |