Making library out of bluez-gnome

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello list!

I'm developing a project[1] that needs to provide the user a way to
select[2] a Bluetooth device from a list of discovered devices.

I noticed that gnome-bluez applet has a very nice device selector and
that got me browsing though the code. Unfortunately I discovered that
bluez-gnome creates only a static library libcommon.a that contains the
device selector (common/bluetooth-device-selection.c) for private use.

Now there is two options the way I see it. Either I have a private copy
of bluez-gnome package or bluez-gnome is made to be a shared library.

The first solution would be easiest for everyone because no extra work
would be required. But it's just generally A Bad Idea to have multiple
programs using same code privately and so on..

The second solutions would be optimal. If bluez-gnome provides a shared
library 3rd party software could utilize it in sane way. I'm quite sure
there are many applications that would benefit from common bluetooth
widgets; like CUPS for bluetooth printer setup, Evolution for vCard
sending, <your favorite application that communicates with BT devices>..

Here is the lame part: I'm busy with my project, so someone else should
do all the work :P
OK, maybe not all the work, but I can not promise anything.

What do you think about the idea? Is this something not worth the
trouble and I should just STFU or is this viable?

best regards,
Antti Kaijanmäki

[1] http://live.gnome.org/NetworkManager/MobileBroadband
[2] http://www.kaijanmaki.net/kesakoodi/bt_draft.png


P.S.
Here are some wishes from top of my head regarding the device selector:
 1. remove the caption of the list
    - let the developer provide a caption best suited for
      his application
 2. put the filter in GtkExpander
    - Filters are not used for by the most of the users, thus it's
      convenient to have them hidden by default. 
 3. make the filter completely hidden
   - this combined with the 1. would make the widget appear just
     like GtkTreeView
   - this is already achievable, but there seems to be a bug. If both of
     the filter fields are hidden the caption is still shown.
     See an attached patch.
 4. have alternative filters in right-click pop-up menu
    - very handy for tight places
 5. add property for selected device name. It's always nice to be able
    to show the user a nice name instead of bluetooth address.
    - see an attached patch.
Index: common/bluetooth-device-selection.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/bluetooth-device-selection.c,v
retrieving revision 1.20
diff -u -p -r1.20 bluetooth-device-selection.c
--- common/bluetooth-device-selection.c	12 Mar 2008 21:03:38 -0000	1.20
+++ common/bluetooth-device-selection.c	24 Jun 2008 11:57:01 -0000
@@ -207,6 +207,22 @@ bluetooth_device_selection_get_selected_
 	return address;
 }
 
+gchar *
+bluetooth_device_selection_get_selected_device_name (BluetoothDeviceSelection *self)
+{
+	BluetoothDeviceSelectionPrivate *priv = BLUETOOTH_DEVICE_SELECTION_GET_PRIVATE(self);
+	GtkTreeIter iter;
+	gchar *name;
+	gboolean selected;
+
+	selected = gtk_tree_selection_get_selected (priv->selection, NULL, &iter);
+	if (selected == FALSE)
+		return NULL;
+
+	gtk_tree_model_get (priv->filter, &iter, COLUMN_NAME, &name, -1);
+	return name;
+}
+
 static void
 search_button_clicked (GtkButton *button, gpointer user_data)
 {
@@ -617,6 +633,7 @@ enum {
 	PROP_0,
 	PROP_TITLE,
 	PROP_DEVICE_SELECTED,
+	PROP_DEVICE_SELECTED_NAME,
 	PROP_SHOW_BONDING,
 	PROP_SHOW_SEARCH,
 	PROP_SHOW_DEVICE_TYPE,
@@ -688,6 +705,9 @@ bluetooth_device_selection_get_property 
 	case PROP_DEVICE_SELECTED:
 		g_value_set_string (value, bluetooth_device_selection_get_selected_device (self));
 		break;
+	case PROP_DEVICE_SELECTED_NAME:
+		g_value_set_string (value, bluetooth_device_selection_get_selected_device_name (self));
+		break;
 	case PROP_SHOW_BONDING:
 		g_value_set_boolean (value, priv->show_bonded);
 		break;
@@ -738,6 +758,9 @@ bluetooth_device_selection_class_init (B
 					 PROP_DEVICE_SELECTED, g_param_spec_string ("device-selected",
 										    NULL, NULL, NULL, G_PARAM_READABLE));
 	g_object_class_install_property (G_OBJECT_CLASS(klass),
+					 PROP_DEVICE_SELECTED_NAME, g_param_spec_string ("device-selected-name",
+										    NULL, NULL, NULL, G_PARAM_READABLE));
+	g_object_class_install_property (G_OBJECT_CLASS(klass),
 					 PROP_SHOW_BONDING, g_param_spec_boolean ("show-bonding",
 										  NULL, NULL, FALSE, G_PARAM_READWRITE));
 	g_object_class_install_property (G_OBJECT_CLASS(klass),
Index: common/bluetooth-device-selection.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/bluetooth-device-selection.c,v
retrieving revision 1.20
diff -u -p -r1.20 bluetooth-device-selection.c
--- common/bluetooth-device-selection.c	12 Mar 2008 21:03:38 -0000	1.20
+++ common/bluetooth-device-selection.c	24 Jun 2008 11:50:01 -0000
@@ -62,6 +62,7 @@ struct _BluetoothDeviceSelectionPrivate 
 	GtkWidget *search_button;
 	GtkWidget *device_type_label, *device_type;
 	GtkWidget *device_category_label, *device_category;
+	GtkWidget *filters_vbox;
 
 	/* Current filter */
 	int device_type_filter;
@@ -517,7 +534,8 @@ bluetooth_device_selection_init(Bluetoot
 	vbox = gtk_vbox_new (FALSE, 6);
 	gtk_widget_show (vbox);
 	gtk_box_pack_start (GTK_BOX (self), vbox, FALSE, TRUE, 0);
-
+	priv->filters_vbox = vbox;
+	
 	/* The filters */
 	str = g_strdup_printf ("<b>%s</b>", _("Show Only Bluetooth Devices With..."));
 	label = gtk_label_new (str);
@@ -596,7 +614,13 @@ bluetooth_device_selection_init(Bluetoot
 		gtk_widget_show (priv->device_type_label);
 		gtk_widget_show (priv->device_type);
 	}
-
+	
+	/* if filters are not visible hide the vbox */
+	if (!priv->show_device_type && !priv->show_device_category)
+	{
+		gtk_widget_hide (priv->filters_vbox);
+	}
+	
 	priv->default_adapter_changed_id = g_signal_connect (priv->client, "notify::default-adapter",
 							     G_CALLBACK (default_adapter_changed), self);
 }
@@ -657,11 +682,19 @@ bluetooth_device_selection_set_property 
 		priv->show_device_type = g_value_get_boolean (value);
 		g_object_set (G_OBJECT (priv->device_type_label), "visible", priv->show_device_type, NULL);
 		g_object_set (G_OBJECT (priv->device_type), "visible", priv->show_device_type, NULL);
+		if (priv->show_device_type || priv->show_device_category)
+			g_object_set (G_OBJECT (priv->filters_vbox), "visible", TRUE, NULL);
+		else
+			g_object_set (G_OBJECT (priv->filters_vbox), "visible", FALSE, NULL);
 		break;
 	case PROP_SHOW_DEVICE_CATEGORY:
 		priv->show_device_category = g_value_get_boolean (value);
 		g_object_set (G_OBJECT (priv->device_category_label), "visible", priv->show_device_category, NULL);
 		g_object_set (G_OBJECT (priv->device_category), "visible", priv->show_device_category, NULL);
+		if (priv->show_device_type || priv->show_device_category)
+			g_object_set (G_OBJECT (priv->filters_vbox), "visible", TRUE, NULL);
+		else
+			g_object_set (G_OBJECT (priv->filters_vbox), "visible", FALSE, NULL);
 		break;
 	case PROP_DEVICE_TYPE_FILTER:
 		priv->device_type_filter = g_value_get_int (value);

Attachment: signature.asc
Description: Digitaalisesti allekirjoitettu viestin osa

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/bluez-devel

[Index of Archives]     [Linux Bluetooth Devel]     [Linux USB Devel]     [Network Devel]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux