gnome-bluetooth r538 - trunk/common
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-bluetooth r538 - trunk/common
- Date: Wed, 25 Mar 2009 17:14:36 +0000 (UTC)
Author: hadess
Date: Wed Mar 25 17:14:36 2009
New Revision: 538
URL: http://svn.gnome.org/viewvc/gnome-bluetooth?rev=538&view=rev
Log:
Add the ability to show the connected column, a connected property, and export the proxy for a device internally
Modified:
trunk/common/bluetooth-chooser.c
trunk/common/bluetooth-chooser.h
trunk/common/test-deviceselection.c
Modified: trunk/common/bluetooth-chooser.c
==============================================================================
--- trunk/common/bluetooth-chooser.c (original)
+++ trunk/common/bluetooth-chooser.c Wed Mar 25 17:14:36 2009
@@ -55,6 +55,7 @@
/* Widgets/UI bits that can be shown or hidden */
GtkCellRenderer *bonded_cell;
+ GtkCellRenderer *connected_cell;
GtkWidget *treeview;
GtkWidget *search_button;
GtkWidget *device_type_label, *device_type;
@@ -67,6 +68,7 @@
int device_category_filter;
guint show_paired : 1;
+ guint show_connected : 1;
guint show_search : 1;
guint show_device_type : 1;
guint show_device_category : 1;
@@ -112,6 +114,17 @@
}
static void
+connected_to_icon (GtkTreeViewColumn *column, GtkCellRenderer *cell,
+ GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
+{
+ gboolean connected;
+
+ gtk_tree_model_get (model, iter, BLUETOOTH_COLUMN_CONNECTED, &connected, -1);
+
+ g_object_set (cell, "icon-name", connected ? GTK_STOCK_CONNECT : NULL, NULL);
+}
+
+static void
type_to_text (GtkTreeViewColumn *column, GtkCellRenderer *cell,
GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
@@ -220,6 +233,27 @@
}
/**
+ * bluetooth_chooser_get_selected_device_is_connected:
+ * @self: a #BluetoothChooser widget
+ *
+ * Return value: whether the selected device is conncted to this computer, will be %FALSE if no devices are selected
+ */
+gboolean
+bluetooth_chooser_get_selected_device_is_connected (BluetoothChooser *self)
+{
+ BluetoothChooserPrivate *priv = BLUETOOTH_CHOOSER_GET_PRIVATE(self);
+ GtkTreeIter iter;
+ gboolean selected, connected;
+
+ selected = gtk_tree_selection_get_selected (priv->selection, NULL, &iter);
+ if (selected == FALSE)
+ return 0;
+
+ gtk_tree_model_get (priv->filter, &iter, BLUETOOTH_COLUMN_CONNECTED, &connected, -1);
+ return connected;
+}
+
+/**
* bluetooth_chooser_set_title:
* @self: a BluetoothChooser widget
* @title: the widget header title
@@ -261,6 +295,7 @@
/* Maybe it's the name that changed */
if (name != NULL)
g_object_notify (G_OBJECT (self), "device-selected-name");
+ g_object_notify (G_OBJECT (self), "device-selected-is-connected");
g_free (name);
}
@@ -525,6 +560,14 @@
gtk_tree_view_column_set_attributes (column, renderer,
"text", BLUETOOTH_COLUMN_ALIAS, NULL);
+ /* The connected icon */
+ priv->connected_cell = gtk_cell_renderer_pixbuf_new ();
+ gtk_tree_view_column_pack_start (column, priv->connected_cell, FALSE);
+
+ gtk_tree_view_column_set_cell_data_func (column, priv->connected_cell,
+ connected_to_icon, NULL, NULL);
+ g_object_set (G_OBJECT (priv->connected_cell), "visible", priv->show_connected, NULL);
+
/* The bonded icon */
priv->bonded_cell = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_end (column, priv->bonded_cell, FALSE);
@@ -790,8 +833,10 @@
PROP_DEVICE_SELECTED_ICON,
PROP_DEVICE_SELECTED_NAME,
PROP_DEVICE_SELECTED_TYPE,
+ PROP_DEVICE_SELECTED_IS_CONNECTED,
+ PROP_DEVICE_SELECTED_PROXY,
PROP_SHOW_PAIRING,
- PROP_SHOW_TRUSTED,
+ PROP_SHOW_CONNECTED,
PROP_SHOW_SEARCH,
PROP_SHOW_DEVICE_TYPE,
PROP_SHOW_DEVICE_CATEGORY,
@@ -814,6 +859,11 @@
if (priv->bonded_cell != NULL)
g_object_set (G_OBJECT (priv->bonded_cell), "visible", priv->show_paired, NULL);
break;
+ case PROP_SHOW_CONNECTED:
+ priv->show_connected = g_value_get_boolean (value);
+ if (priv->connected_cell != NULL)
+ g_object_set (G_OBJECT (priv->connected_cell), "visible", priv->show_connected, NULL);
+ break;
case PROP_SHOW_SEARCH:
priv->show_search = g_value_get_boolean (value);
g_object_set (G_OBJECT (priv->search_button), "visible", priv->show_search, NULL);
@@ -870,6 +920,18 @@
case PROP_DEVICE_SELECTED_TYPE:
g_value_set_uint (value, bluetooth_chooser_get_selected_device_type (self));
break;
+ case PROP_DEVICE_SELECTED_IS_CONNECTED:
+ g_value_set_uint (value, bluetooth_chooser_get_selected_device_is_connected (self));
+ break;
+ case PROP_DEVICE_SELECTED_PROXY: {
+ GtkTreeIter iter;
+ GObject *proxy = NULL;
+
+ if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter) != FALSE)
+ gtk_tree_model_get (priv->filter, &iter, BLUETOOTH_COLUMN_PROXY, &proxy);
+ g_value_take_object (value, proxy);
+ break;
+ }
case PROP_SHOW_PAIRING:
g_value_set_boolean (value, priv->show_paired);
break;
@@ -968,6 +1030,18 @@
PROP_DEVICE_SELECTED_TYPE, g_param_spec_uint ("device-selected-type", NULL, NULL,
1, 1 << (_BLUETOOTH_TYPE_NUM_TYPES - 1), 1, G_PARAM_READABLE));
/**
+ * BluetoothChooser:device-selected-is-connected:
+ *
+ * whether the selected device is conncted to this computer, will be %FALSE if no devices are selected
+ **/
+ g_object_class_install_property (G_OBJECT_CLASS(klass),
+ PROP_DEVICE_SELECTED_IS_CONNECTED, g_param_spec_boolean ("device-selected-is-connected", NULL, NULL,
+ FALSE, G_PARAM_READABLE));
+ /* Left blank intentionally */
+ g_object_class_install_property (G_OBJECT_CLASS(klass),
+ PROP_DEVICE_SELECTED_PROXY, g_param_spec_object ("device-selected-proxy", NULL, NULL,
+ G_TYPE_OBJECT, G_PARAM_READABLE));
+ /**
* BluetoothChooser:show-pairing:
*
* Whether to show the pairing column in the tree.
@@ -976,6 +1050,14 @@
PROP_SHOW_PAIRING, g_param_spec_boolean ("show-pairing",
NULL, NULL, FALSE, G_PARAM_READWRITE));
/**
+ * BluetoothChooser:show-connected:
+ *
+ * Whether to show the connected column in the tree.
+ **/
+ g_object_class_install_property (G_OBJECT_CLASS(klass),
+ PROP_SHOW_CONNECTED, g_param_spec_boolean ("show-connected",
+ NULL, NULL, FALSE, G_PARAM_READWRITE));
+ /**
* BluetoothChooser:show-search:
*
* Whether to show the Search button, this is necessary if you want to programmatically
Modified: trunk/common/bluetooth-chooser.h
==============================================================================
--- trunk/common/bluetooth-chooser.h (original)
+++ trunk/common/bluetooth-chooser.h Wed Mar 25 17:14:36 2009
@@ -65,6 +65,7 @@
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);
+gboolean bluetooth_chooser_get_selected_device_is_connected (BluetoothChooser *self);
void bluetooth_chooser_start_discovery (BluetoothChooser *self);
Modified: trunk/common/test-deviceselection.c
==============================================================================
--- trunk/common/test-deviceselection.c (original)
+++ trunk/common/test-deviceselection.c Wed Mar 25 17:14:36 2009
@@ -217,6 +217,7 @@
"show-device-type", FALSE,
"show-device-category", FALSE,
"show-pairing", TRUE,
+ "show-connected", TRUE,
"device-category-filter", BLUETOOTH_CATEGORY_PAIRED_OR_TRUSTED,
NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]