Skip to contentSkip to conversation

bluez-gnome: No GUI way to switch from "off" mode

Bluez-devel Stanislav Brabec 4 participants 5 messages Apr 30, 2007 – May 4, 2007 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hallo.

I am just curious, whether no chance to enable Bluetooth from the GNOME Bluetooth is deliberate or not. I guess, that it is not deliberate.

How to reproduce:
1. apitest SetMode off
2. Run bluetooth-properties.
3. Mode selection is completely shaded out and there is no way to enable Bluetooth.

Proposed change:
- Convert "Mode of operation" radio buttons to checkboxes.
- "Other devices can connect":
Will never be shaded out.
If it is off: Mode is off.
If it is on, than "Visible and connectable for other devices" is
unshaded.
- "Visible and connectable for other devices":
If it is unshaded and off: Mode is connectable
If it is unshaded and on: Mode is discoverable and "Make adapter
invisible after" is unshaded.

Is it more acceptable behavior?

Reference:
Bluetooth in GNOME does not work in default installation
https://bugzilla.novell.com/show_bug.cgi?id=3D226137

-- =

Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o. e-mail: [email protected]
Lihovarsk=E1 1060/12 tel: +420 284 028 966
190 00 Praha 9 fax: +420 284 028 951
Czech Republic http://www.suse.cz/

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#1 lore raw
Quoted 4 lines · On Monday 30 April 2007 17:16:41 Stanislav Brabec wrote:

Hallo.

I am just curious, whether no chance to enable Bluetooth from the GNOME Bluetooth is deliberate or not. I guess, that it is not deliberate.

Not quite sure if this was intended or not ... attachted is the suggested change by Stanislav.

best regards,
Daniel

? properties/.deps
? properties/Makefile
? properties/Makefile.in
? properties/bluetooth-properties
? properties/bluetooth-properties.desktop
Index: properties/main.c
===================================================================
RCS file: /cvsroot/bluez/gnome/properties/main.c,v retrieving revision 1.33

main.c +23 -8
diff -u -p -r1.33 main.c
@@ -757,6 +757,7 @@ struct adapter_data {
 	char *path;
 	int attached;
 	GtkWidget *child;
+	GtkWidget *button_off;
 	GtkWidget *button_connect;
 	GtkWidget *button_visible;
 	GtkWidget *timeout_label;
@@ -817,6 +818,9 @@ static void mode_callback(GtkWidget *but
 	} else if (button == adapter->button_visible) {
 		sensitive = TRUE;
 		mode = "discoverable";
+	} else if (button == adapter->button_off) {
+		sensitive = FALSE;
+		mode = "off";
 	} else
 		return;
 
@@ -981,14 +985,26 @@ static void create_adapter(struct adapte
 	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
 
 	button = gtk_radio_button_new_with_label(group,
-					_("Other devices can connect"));
+					_("Off. No devices can connect"));
 
 	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
 
 	gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
 
 	if (mode && !strcmp(mode, "off"))
-		gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
+		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+
+	adapter->button_off = 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));
+
+	gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
 
 	if (mode && !strcmp(mode, "connectable"))
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
@@ -1005,9 +1021,6 @@ static void create_adapter(struct adapte
 
 	gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
 
-	if (mode && !strcmp(mode, "off"))
-		gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
 	if (mode && !strcmp(mode, "discoverable"))
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
 
@@ -1125,15 +1138,14 @@ static void mode_changed(DBusGProxy *obj
 	if (list && list->data) {
 		struct adapter_data *adapter = list->data;
 		GtkWidget *button = NULL;
-		gboolean sensitive;
+		gboolean sensitive = TRUE;
 
 		if (!adapter->attached)
 			return;
 
-		sensitive = strcmp(mode, "off") ? TRUE : FALSE;
-
 		gtk_widget_set_sensitive(GTK_WIDGET(adapter->button_connect), sensitive);
 		gtk_widget_set_sensitive(GTK_WIDGET(adapter->button_visible), sensitive);
+		gtk_widget_set_sensitive(GTK_WIDGET(adapter->button_off), sensitive);
 
 		if (!strcmp(mode, "connectable")) {
 			sensitive = FALSE;
@@ -1141,6 +1153,9 @@ static void mode_changed(DBusGProxy *obj
 		} else if (!strcmp(mode, "discoverable")) {
 			sensitive = TRUE;
 			button = adapter->button_visible;
+		} else if (!strcmp(mode, "off")) {
+			sensitive = FALSE;
+			button = adapter->button_off;
 		}
 
 		gtk_widget_set_sensitive(GTK_WIDGET(adapter->timeout_label), sensitive);

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#2 lore raw
Quoted 2 lines · Daniel Gollub

Not quite sure if this was intended or not ... attachted is the suggested change by Stanislav.

Here is an alternative patch. The same improvement but different GUI (see attached screenshots). I have changed second checkbox label.

Please decide what looks more intuitive and check-in.

Signature · 9 lines
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                          e-mail: [email protected]
Lihovarská 1060/12                            tel: +420 284 028 966
190 00 Praha 9                                fax: +420 284 028 951
Czech Republic                                http://www.suse.cz/

Index: properties/main.c
===================================================================
RCS file: /cvsroot/bluez/gnome/properties/main.c,v retrieving revision 1.33

main.c +43 -64
diff -u -r1.33 main.c
@@ -757,8 +757,8 @@
 	char *path;
 	int attached;
 	GtkWidget *child;
-	GtkWidget *button_connect;
-	GtkWidget *button_visible;
+	GtkWidget *checkbox_connect;
+	GtkWidget *checkbox_visible;
 	GtkWidget *timeout_label;
 	GtkWidget *timeout_scale;
 	GtkWidget *entry;
@@ -801,33 +801,24 @@
 	return strcmp(adapter->path, path);
 }
 
-static void mode_callback(GtkWidget *button, gpointer user_data)
+static void mode_callback(GtkWidget *checkbox, gpointer user_data)
 {
 	struct adapter_data *adapter = user_data;
 	const char *mode;
 	DBusGProxy *object;
-	gboolean sensitive;
 
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)) == FALSE)
-		return;
-
-	if (button == adapter->button_connect) {
-		sensitive = FALSE;
-		mode = "connectable";
-	} else if (button == adapter->button_visible) {
-		sensitive = TRUE;
+	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(adapter->checkbox_connect)) == FALSE)
+		mode = "off";
+	else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(adapter->checkbox_visible)) == TRUE)
 		mode = "discoverable";
-	} else
-		return;
+	else
+		mode = "connectable";
 
 	object = dbus_g_proxy_new_for_name(conn, "org.bluez",
 					adapter->path, "org.bluez.Adapter");
 
 	dbus_g_proxy_call(object, "SetMode", NULL,
 			G_TYPE_STRING, mode, G_TYPE_INVALID, G_TYPE_INVALID);
-
-	gtk_widget_set_sensitive(GTK_WIDGET(adapter->timeout_label), sensitive);
-	gtk_widget_set_sensitive(GTK_WIDGET(adapter->timeout_scale), sensitive);
 }
 
 static void scale_callback(GtkWidget *scale, gpointer user_data)
@@ -933,13 +924,13 @@
 
 	GtkWidget *vbox;
 	GtkWidget *label;
-	GtkWidget *button;
+	GtkWidget *checkbox;
 	GtkWidget *scale;
 	GtkWidget *entry;
 	GtkWidget *combobox;
-	GSList *group = NULL;
 	gdouble value;
 	gint index;
+	gboolean is_not_off = FALSE, is_discoverable = FALSE;
 
 	object = dbus_g_proxy_new_for_name(conn, "org.bluez",
 					adapter->path, "org.bluez.Adapter");
@@ -978,42 +969,38 @@
 
 	label = create_label(_("Mode of operation"));
 
+	if (!strcmp(mode, "connectable")) {
+		is_not_off = TRUE;
+	} else if (!strcmp(mode, "discoverable")) {
+		is_not_off = TRUE;
+		is_discoverable = TRUE;
+	}
+
 	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
 
-	button = gtk_radio_button_new_with_label(group,
+	checkbox = gtk_check_button_new_with_label(
 					_("Other devices can connect"));
 
-	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
+	gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
 
-	gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), is_not_off);
 
-	if (mode && !strcmp(mode, "off"))
-		gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
+	adapter->checkbox_connect = checkbox;
 
-	if (mode && !strcmp(mode, "connectable"))
-		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
-
-	adapter->button_connect = button;
-
-	g_signal_connect(G_OBJECT(button), "toggled",
+	g_signal_connect(G_OBJECT(checkbox), "toggled",
 					G_CALLBACK(mode_callback), adapter);
 
-	button = gtk_radio_button_new_with_label(group,
-				_("Visible and connectable for other devices"));
-
-	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
+	checkbox = gtk_check_button_new_with_label(
+				_("Visible for other devices"));
 
-	gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
 
-	if (mode && !strcmp(mode, "off"))
-		gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
+	gtk_widget_set_sensitive(GTK_WIDGET(checkbox), is_not_off);
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), is_discoverable);
 
-	if (mode && !strcmp(mode, "discoverable"))
-		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+	adapter->checkbox_visible = checkbox;
 
-	adapter->button_visible = button;
-
-	g_signal_connect(G_OBJECT(button), "toggled",
+	g_signal_connect(G_OBJECT(checkbox), "toggled",
 					G_CALLBACK(mode_callback), adapter);
 
 	label = gtk_label_new(_("Make adapter invisible after:"));
@@ -1053,10 +1040,8 @@
 	g_signal_connect(G_OBJECT(scale), "format-value",
 					G_CALLBACK(format_callback), NULL);
 
-	if (mode && strcmp(mode, "discoverable")) {
-		gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE);
-		gtk_widget_set_sensitive(GTK_WIDGET(scale), FALSE);
-	}
+	gtk_widget_set_sensitive(GTK_WIDGET(label), is_discoverable);
+	gtk_widget_set_sensitive(GTK_WIDGET(scale), is_discoverable);
 
 	label = create_label(_("\nAdapter name"));
 
@@ -1124,32 +1109,26 @@
 	list = g_list_find_custom(adapter_list, path, adapter_compare);
 	if (list && list->data) {
 		struct adapter_data *adapter = list->data;
-		GtkWidget *button = NULL;
-		gboolean sensitive;
+		gboolean is_not_off = FALSE, is_discoverable = FALSE;
 
 		if (!adapter->attached)
 			return;
 
-		sensitive = strcmp(mode, "off") ? TRUE : FALSE;
-
-		gtk_widget_set_sensitive(GTK_WIDGET(adapter->button_connect), sensitive);
-		gtk_widget_set_sensitive(GTK_WIDGET(adapter->button_visible), sensitive);
-
 		if (!strcmp(mode, "connectable")) {
-			sensitive = FALSE;
-			button = adapter->button_connect;
+			is_not_off = TRUE;
+			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(adapter->checkbox_visible), FALSE);
 		} else if (!strcmp(mode, "discoverable")) {
-			sensitive = TRUE;
-			button = adapter->button_visible;
+			is_not_off = TRUE;
+			is_discoverable = TRUE;
+			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(adapter->checkbox_visible), TRUE);
+		} else {
+			/* mode == "off" or unknown */
 		}
 
-		gtk_widget_set_sensitive(GTK_WIDGET(adapter->timeout_label), sensitive);
-		gtk_widget_set_sensitive(GTK_WIDGET(adapter->timeout_scale), sensitive);
-
-		if (!button)
-			return;
-
-		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(adapter->checkbox_connect), is_not_off);
+		gtk_widget_set_sensitive(GTK_WIDGET(adapter->checkbox_visible), is_not_off);
+		gtk_widget_set_sensitive(GTK_WIDGET(adapter->timeout_label), is_discoverable);
+		gtk_widget_set_sensitive(GTK_WIDGET(adapter->timeout_scale), is_discoverable);
 	}
 }
 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#3 lore raw
Quoted 9 lines · Stanislav Brabec
Quoted 2 lines · Daniel Gollub

Not quite sure if this was intended or not ... attachted is the suggested change by Stanislav.

Here is an alternative patch. The same improvement but different GUI (see attached screenshots). I have changed second checkbox label.

Please decide what looks more intuitive and check-in.

This should optionally (ie. if HAL is available at compile and run-time) use the new HAL API that allows to enable/disable builtin Bluetooth devices completely (ie. not just not configured to accept anything, but completely disabled, unplugged, and not consuming one bit of power).

The HAL API is pretty straight forward:
http://people.freedesktop.org/~david/hal-spec/hal-spec.html#device-properties-killswitch
and
http://people.freedesktop.org/~david/hal-spec/hal-spec.html#interface-device-killswitch

It's implemented for Sony and Dell laptops, with another opened RFE for IBM laptops:
http://bugs.freedesktop.org/show_bug.cgi?id=10053

It should be dead-easy to implement for someone with access to an IBM laptop (unlike me).

Signature · 12 lines
Bastien Nocera <[email protected]> 


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
maintainer
#4 lore raw

Hi Bastien,

Quoted 18 lines
Quoted 7 lines
Quoted 2 lines

Not quite sure if this was intended or not ... attachted is the suggested change by Stanislav.

Here is an alternative patch. The same improvement but different GUI (see attached screenshots). I have changed second checkbox label.

Please decide what looks more intuitive and check-in.

This should optionally (ie. if HAL is available at compile and run-time) use the new HAL API that allows to enable/disable builtin Bluetooth devices completely (ie. not just not configured to accept anything, but completely disabled, unplugged, and not consuming one bit of power).

The HAL API is pretty straight forward:
http://people.freedesktop.org/~david/hal-spec/hal-spec.html#device-properties-killswitch
and
http://people.freedesktop.org/~david/hal-spec/hal-spec.html#interface-device-killswitch

Quoted 6 lines

It's implemented for Sony and Dell laptops, with another opened RFE for IBM laptops:
http://bugs.freedesktop.org/show_bug.cgi?id=10053

It should be dead-easy to implement for someone with access to an IBM laptop (unlike me).

the off operation doesn't make any real sense for desktop system. It is mainly there for embedded systems without HAL or where the kernel driver has to put the device into deep-sleep mode.

An integration with HAL's killswitch is the correct way.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel