[gnome-bluetooth] Export arbitrary columns through _get_selected_info()



commit eaae9dc1f15fcb47a66b0c801478d8419f05d459
Author: Bastien Nocera <hadess hadess net>
Date:   Thu May 28 11:30:23 2009 +0100

    Export arbitrary columns through _get_selected_info()
    
    Allows us to get arbitrary data out of the BluetoothClient
    tree model without exposing it in the API.
---
 common/bluetooth-chooser.c |   31 +++++++++++++++++++++++++++++++
 common/bluetooth-chooser.h |    3 +++
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/common/bluetooth-chooser.c b/common/bluetooth-chooser.c
index 3cd4507..3c0bbdc 100644
--- a/common/bluetooth-chooser.c
+++ b/common/bluetooth-chooser.c
@@ -32,6 +32,7 @@
 
 #include "bluetooth-client.h"
 #include "bluetooth-chooser.h"
+#include "gnome-bluetooth-enum-types.h"
 
 enum {
 	SELECTED_DEVICE_CHANGED,
@@ -278,6 +279,36 @@ bluetooth_chooser_get_selected_device_is_connected (BluetoothChooser *self)
 	return connected;
 }
 
+gboolean
+bluetooth_chooser_get_selected_device_info (BluetoothChooser *self,
+					    const char *info,
+					    GValue *value)
+{
+	BluetoothChooserPrivate *priv = BLUETOOTH_CHOOSER_GET_PRIVATE(self);
+	GEnumClass *eclass;
+	GEnumValue *ev;
+	GtkTreeIter iter;
+
+	g_return_val_if_fail (info != NULL, FALSE);
+
+	if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter) == FALSE)
+		return FALSE;
+
+	eclass = g_type_class_ref (BLUETOOTH_TYPE_COLUMN);
+	ev = g_enum_get_value_by_nick (eclass, info);
+	if (ev == NULL) {
+		g_warning ("Unknown info '%s'", info);
+		g_type_class_unref (eclass);
+		return FALSE;
+	}
+
+	gtk_tree_model_get_value (priv->filter, &iter, ev->value, value);
+
+	g_type_class_unref (eclass);
+
+	return TRUE;
+}
+
 /**
  * bluetooth_chooser_set_title:
  * @self: a BluetoothChooser widget
diff --git a/common/bluetooth-chooser.h b/common/bluetooth-chooser.h
index b3aecfb..e58c721 100644
--- a/common/bluetooth-chooser.h
+++ b/common/bluetooth-chooser.h
@@ -62,6 +62,9 @@ GtkWidget *bluetooth_chooser_new (const gchar *title);
 void bluetooth_chooser_set_title (BluetoothChooser  *self, const char *title);
 
 gchar *bluetooth_chooser_get_selected_device (BluetoothChooser *self);
+gboolean bluetooth_chooser_get_selected_device_info (BluetoothChooser *self,
+						     const char *info,
+						     GValue *value);
 gchar *bluetooth_chooser_get_selected_device_name (BluetoothChooser *self);
 gchar * bluetooth_chooser_get_selected_device_icon (BluetoothChooser *self);
 guint bluetooth_chooser_get_selected_device_type (BluetoothChooser *self);



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