public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] properties: add radio button to turn bluetooth off
@ 2008-07-03 23:02 Felipe Balbi
  0 siblings, 0 replies; only message in thread
From: Felipe Balbi @ 2008-07-03 23:02 UTC (permalink / raw)
  To: bluez-devel; +Cc: Marcel Holtmann, Felipe Balbi

There was no widget to turn bluetooth off. This patch
adds it.

There's actually another missing piece which would be
autosuspend support for hci_usb.c, without it hci_usb
will still be one of the biggest system wake-up source.

Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
 properties/adapter.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/properties/adapter.c b/properties/adapter.c
index 7311068..843188f 100644
--- a/properties/adapter.c
+++ b/properties/adapter.c
@@ -66,6 +66,7 @@ struct adapter_data {
 	char *path;
 	int attached;
 	GtkWidget *child;
+	GtkWidget *button_on;
 	GtkWidget *button_connect;
 	GtkWidget *button_visible;
 	GtkWidget *button_limited;
@@ -125,10 +126,15 @@ static void mode_callback(GtkWidget *button, gpointer user_data)
 	DBusGProxy *object;
 	gboolean sensitive;
 
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)) == FALSE)
+	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)) == FALSE &&
+			button != adapter->button_on)
 		return;
 
-	if (button == adapter->button_connect) {
+	if (button == adapter->button_on) {
+		mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))
+			? "on" : "off";
+		sensitive = FALSE;
+	} else if (button == adapter->button_connect) {
 		sensitive = FALSE;
 		mode = "connectable";
 	} else if (button == adapter->button_visible) {
@@ -585,6 +591,15 @@ static void create_adapter(struct adapter_data *adapter)
 	label = create_label(_("Mode of operation"));
 	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
 
+	button = gtk_check_button_new_with_label(_("Bluetooth on"));
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), 1);
+	gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
+
+	adapter->button_on = button;
+
+	g_signal_connect(G_OBJECT(button), "toggled",
+					G_CALLBACK(mode_callback), adapter);
+
 	button = gtk_radio_button_new_with_label(group,
 					_("Other devices can connect"));
 	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-- 
1.5.6.1.204.g699135

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-07-03 23:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-03 23:02 [PATCH] properties: add radio button to turn bluetooth off Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox