* [Bluez-devel] [PATCH] Show the trusted icon in the treeview
@ 2007-07-26 14:13 Bastien Nocera
2007-07-26 14:21 ` Bastien Nocera
0 siblings, 1 reply; 4+ messages in thread
From: Bastien Nocera @ 2007-07-26 14:13 UTC (permalink / raw)
To: BlueZ Hackers
[-- Attachment #1: Type: text/plain, Size: 368 bytes --]
I added a property to be able to show/hide a trusted (bonded) icon in
the list view, it's shown by default.
There's also a one-liner to avoid changing the address rather than the
name, when a device doesn't have a name (ie. it still displayed
00:00:00:00:00:00 rather than 00-00-00-00-00-00, but changed the address
to that).
--
Bastien Nocera <hadess@hadess.net>
[-- Attachment #2: bluez-gnome-selection-show-trusted-icon-prop.patch --]
[-- Type: text/x-patch, Size: 4622 bytes --]
Index: bluetooth-device-selection.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/bluetooth-device-selection.c,v
retrieving revision 1.3
diff -u -p -r1.3 bluetooth-device-selection.c
--- bluetooth-device-selection.c 25 Jul 2007 18:01:44 -0000 1.3
+++ bluetooth-device-selection.c 26 Jul 2007 14:09:54 -0000
@@ -52,6 +52,10 @@ struct _BluetoothDeviceSelectionPrivate
GtkTreeSelection *selection;
GtkTreeModel *model;
GtkWidget *label;
+
+ /* Whether the trusted icon is shown */
+ GtkCellRenderer *trusted_cell;
+ guint show_trusted : 1;
};
G_DEFINE_TYPE(BluetoothDeviceSelection, bluetooth_device_selection, GTK_TYPE_VBOX)
@@ -70,7 +74,7 @@ name_to_text (GtkTreeViewColumn *column,
* Bluetooth address, with the ":" replaced by "-" */
if (name == NULL) {
name = g_strdup (address);
- g_strdelimit (address, ":", '-');
+ g_strdelimit (name, ":", '-');
}
g_object_set (cell, "text", name ? name : address, NULL);
@@ -122,6 +126,21 @@ type_to_icon (GtkTreeViewColumn *column,
}
static void
+trusted_to_icon (GtkTreeViewColumn *column, GtkCellRenderer *cell,
+ GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
+{
+ gboolean trusted;
+ char *addr;
+
+ gtk_tree_model_get (model, iter, COLUMN_TRUSTED, &trusted, COLUMN_ADDRESS, &addr, -1);
+
+ if (trusted == FALSE)
+ g_object_set (cell, "stock-id", NULL, NULL);
+ else
+ g_object_set (cell, "stock-id", GTK_STOCK_DIALOG_AUTHENTICATION, NULL);
+}
+
+static void
type_to_text (GtkTreeViewColumn *column, GtkCellRenderer *cell,
GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
@@ -170,6 +189,8 @@ bluetooth_device_selection_init(Bluetoot
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
+ priv->show_trusted = TRUE;
+
gtk_box_set_spacing (GTK_BOX(self), 6);
gtk_box_set_homogeneous (GTK_BOX(self), FALSE);
gtk_container_set_border_width (GTK_CONTAINER(self), 8);
@@ -207,6 +228,7 @@ bluetooth_device_selection_init(Bluetoot
gtk_tree_view_column_set_title (column, _("Device"));
+ /* The type icon */
renderer = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_set_spacing (column, 4);
gtk_tree_view_column_pack_start (column, renderer, FALSE);
@@ -214,12 +236,20 @@ bluetooth_device_selection_init(Bluetoot
gtk_tree_view_column_set_cell_data_func (column, renderer,
type_to_icon, NULL, NULL);
+ /* The device name */
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (column, renderer, TRUE);
gtk_tree_view_column_set_cell_data_func (column, renderer,
name_to_text, NULL, NULL);
+ /* The trusted icon */
+ priv->trusted_cell = gtk_cell_renderer_pixbuf_new ();
+ gtk_tree_view_column_pack_end (column, priv->trusted_cell, FALSE);
+
+ gtk_tree_view_column_set_cell_data_func (column, priv->trusted_cell,
+ trusted_to_icon, NULL, NULL);
+
gtk_tree_view_append_column (GTK_TREE_VIEW(tree), column);
gtk_tree_view_column_set_min_width (GTK_TREE_VIEW_COLUMN(column), 280);
@@ -259,7 +289,8 @@ bluetooth_device_selection_finalize (GOb
enum {
PROP_0,
PROP_TITLE,
- PROP_DEVICE_SELECTED
+ PROP_DEVICE_SELECTED,
+ PROP_SHOW_BONDING
};
static void
@@ -281,6 +312,11 @@ bluetooth_device_selection_set_property
g_free (str);
}
break;
+ case PROP_SHOW_BONDING:
+ priv->show_trusted = g_value_get_boolean (value);
+ if (priv->trusted_cell != NULL)
+ g_object_set (G_OBJECT (priv->trusted_cell), "visible", priv->show_trusted, NULL);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@@ -292,11 +328,15 @@ bluetooth_device_selection_get_property
GValue *value, GParamSpec *pspec)
{
BluetoothDeviceSelection *self = BLUETOOTH_DEVICE_SELECTION(object);
+ BluetoothDeviceSelectionPrivate *priv = BLUETOOTH_DEVICE_SELECTION_GET_PRIVATE(object);
switch (prop_id) {
case PROP_DEVICE_SELECTED:
g_value_set_string (value, bluetooth_device_selection_get_selected_device (self));
break;
+ case PROP_SHOW_BONDING:
+ g_value_set_boolean (value, priv->show_trusted);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@@ -328,6 +368,9 @@ bluetooth_device_selection_class_init (B
g_object_class_install_property (G_OBJECT_CLASS(klass),
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_SHOW_BONDING, g_param_spec_boolean ("show-bonding",
+ NULL, NULL, TRUE, G_PARAM_READWRITE));
}
GtkWidget *
[-- Attachment #3: Type: text/plain, Size: 315 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
[-- Attachment #4: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [Bluez-devel] [PATCH] Show the trusted icon in the treeview 2007-07-26 14:13 [Bluez-devel] [PATCH] Show the trusted icon in the treeview Bastien Nocera @ 2007-07-26 14:21 ` Bastien Nocera 2007-07-26 14:49 ` Bastien Nocera 0 siblings, 1 reply; 4+ messages in thread From: Bastien Nocera @ 2007-07-26 14:21 UTC (permalink / raw) To: BlueZ development On Thu, 2007-07-26 at 15:13 +0100, Bastien Nocera wrote: > I added a property to be able to show/hide a trusted (bonded) icon in > the list view, it's shown by default. > > There's also a one-liner to avoid changing the address rather than the > name, when a device doesn't have a name (ie. it still displayed > 00:00:00:00:00:00 rather than 00-00-00-00-00-00, but changed the address > to that). Johan mentioned that bonded != trusted, and the existing code didn't make the difference. I'll fix that up. -- Bastien Nocera <hadess@hadess.net> ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Bluez-devel] [PATCH] Show the trusted icon in the treeview 2007-07-26 14:21 ` Bastien Nocera @ 2007-07-26 14:49 ` Bastien Nocera 2007-07-26 19:41 ` Marcel Holtmann 0 siblings, 1 reply; 4+ messages in thread From: Bastien Nocera @ 2007-07-26 14:49 UTC (permalink / raw) To: BlueZ development [-- Attachment #1: Type: text/plain, Size: 761 bytes --] On Thu, 2007-07-26 at 15:21 +0100, Bastien Nocera wrote: > On Thu, 2007-07-26 at 15:13 +0100, Bastien Nocera wrote: > > I added a property to be able to show/hide a trusted (bonded) icon in > > the list view, it's shown by default. > > > > There's also a one-liner to avoid changing the address rather than the > > name, when a device doesn't have a name (ie. it still displayed > > 00:00:00:00:00:00 rather than 00-00-00-00-00-00, but changed the address > > to that). > > Johan mentioned that bonded != trusted, and the existing code didn't > make the difference. I'll fix that up. Fixes the above, and renames the COLUMN_TRUSTED to COLUMN_BONDED, as that column includes the bonded status, not the trusted status. -- Bastien Nocera <hadess@hadess.net> [-- Attachment #2: bluez-gnome-selection-show-bonded-icon-prop.patch --] [-- Type: text/x-patch, Size: 7031 bytes --] Index: bluetooth-device-selection.c =================================================================== RCS file: /cvsroot/bluez/gnome/common/bluetooth-device-selection.c,v retrieving revision 1.3 diff -u -p -r1.3 bluetooth-device-selection.c --- bluetooth-device-selection.c 25 Jul 2007 18:01:44 -0000 1.3 +++ bluetooth-device-selection.c 26 Jul 2007 14:47:25 -0000 @@ -52,6 +52,10 @@ struct _BluetoothDeviceSelectionPrivate GtkTreeSelection *selection; GtkTreeModel *model; GtkWidget *label; + + /* Whether the bonded icon is shown */ + GtkCellRenderer *bonded_cell; + guint show_status : 1; }; G_DEFINE_TYPE(BluetoothDeviceSelection, bluetooth_device_selection, GTK_TYPE_VBOX) @@ -70,7 +74,7 @@ name_to_text (GtkTreeViewColumn *column, * Bluetooth address, with the ":" replaced by "-" */ if (name == NULL) { name = g_strdup (address); - g_strdelimit (address, ":", '-'); + g_strdelimit (name, ":", '-'); } g_object_set (cell, "text", name ? name : address, NULL); @@ -122,6 +126,20 @@ type_to_icon (GtkTreeViewColumn *column, } static void +bonded_to_icon (GtkTreeViewColumn *column, GtkCellRenderer *cell, + GtkTreeModel *model, GtkTreeIter *iter, gpointer data) +{ + gboolean bonded; + + gtk_tree_model_get (model, iter, COLUMN_BONDED, &bonded, -1); + + if (bonded == FALSE) + g_object_set (cell, "stock-id", NULL, NULL); + else + g_object_set (cell, "stock-id", GTK_STOCK_DIALOG_AUTHENTICATION, NULL); +} + +static void type_to_text (GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { @@ -170,6 +188,8 @@ bluetooth_device_selection_init(Bluetoot GtkCellRenderer *renderer; GtkTreeViewColumn *column; + priv->show_status = TRUE; + gtk_box_set_spacing (GTK_BOX(self), 6); gtk_box_set_homogeneous (GTK_BOX(self), FALSE); gtk_container_set_border_width (GTK_CONTAINER(self), 8); @@ -207,6 +227,7 @@ bluetooth_device_selection_init(Bluetoot gtk_tree_view_column_set_title (column, _("Device")); + /* The type icon */ renderer = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_set_spacing (column, 4); gtk_tree_view_column_pack_start (column, renderer, FALSE); @@ -214,12 +235,20 @@ bluetooth_device_selection_init(Bluetoot gtk_tree_view_column_set_cell_data_func (column, renderer, type_to_icon, NULL, NULL); + /* The device name */ renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, name_to_text, NULL, NULL); + /* The bonded icon */ + priv->bonded_cell = gtk_cell_renderer_pixbuf_new (); + gtk_tree_view_column_pack_end (column, priv->bonded_cell, FALSE); + + gtk_tree_view_column_set_cell_data_func (column, priv->bonded_cell, + bonded_to_icon, NULL, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW(tree), column); gtk_tree_view_column_set_min_width (GTK_TREE_VIEW_COLUMN(column), 280); @@ -259,7 +288,8 @@ bluetooth_device_selection_finalize (GOb enum { PROP_0, PROP_TITLE, - PROP_DEVICE_SELECTED + PROP_DEVICE_SELECTED, + PROP_SHOW_BONDING }; static void @@ -281,6 +311,11 @@ bluetooth_device_selection_set_property g_free (str); } break; + case PROP_SHOW_BONDING: + priv->show_status = g_value_get_boolean (value); + if (priv->bonded_cell != NULL) + g_object_set (G_OBJECT (priv->bonded_cell), "visible", priv->show_status, NULL); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -292,11 +327,15 @@ bluetooth_device_selection_get_property GValue *value, GParamSpec *pspec) { BluetoothDeviceSelection *self = BLUETOOTH_DEVICE_SELECTION(object); + BluetoothDeviceSelectionPrivate *priv = BLUETOOTH_DEVICE_SELECTION_GET_PRIVATE(object); switch (prop_id) { case PROP_DEVICE_SELECTED: g_value_set_string (value, bluetooth_device_selection_get_selected_device (self)); break; + case PROP_SHOW_BONDING: + g_value_set_boolean (value, priv->show_status); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -328,6 +367,9 @@ bluetooth_device_selection_class_init (B g_object_class_install_property (G_OBJECT_CLASS(klass), 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_SHOW_BONDING, g_param_spec_boolean ("show-bonding", + NULL, NULL, TRUE, G_PARAM_READWRITE)); } GtkWidget * Index: client.c =================================================================== RCS file: /cvsroot/bluez/gnome/common/client.c,v retrieving revision 1.18 diff -u -p -r1.18 client.c --- client.c 25 Jul 2007 07:43:59 -0000 1.18 +++ client.c 26 Jul 2007 14:47:25 -0000 @@ -190,7 +190,7 @@ static void insert_device(DBusGProxy *ob const char *name = NULL; guint type; guint32 class = 0; - gboolean trusted = FALSE, connected = FALSE; + gboolean bonded = FALSE, connected = FALSE; gboolean cont; dbus_g_proxy_call(object, "GetRemoteName", NULL, @@ -203,7 +203,7 @@ static void insert_device(DBusGProxy *ob dbus_g_proxy_call(object, "HasBonding", NULL, G_TYPE_STRING, address, G_TYPE_INVALID, - G_TYPE_BOOLEAN, &trusted, G_TYPE_INVALID); + G_TYPE_BOOLEAN, &bonded, G_TYPE_INVALID); dbus_g_proxy_call(object, "IsConnected", NULL, G_TYPE_STRING, address, G_TYPE_INVALID, @@ -227,7 +227,7 @@ static void insert_device(DBusGProxy *ob COLUMN_RSSI, rssi, COLUMN_NAME, name, COLUMN_TYPE, type, - COLUMN_TRUSTED, trusted, + COLUMN_BONDED, bonded, COLUMN_CONNECTED, connected, -1); return; } @@ -242,7 +242,7 @@ static void insert_device(DBusGProxy *ob COLUMN_RSSI, rssi, COLUMN_NAME, name, COLUMN_TYPE, type, - COLUMN_TRUSTED, trusted, + COLUMN_BONDED, bonded, COLUMN_CONNECTED, connected, -1); } Index: client.h =================================================================== RCS file: /cvsroot/bluez/gnome/common/client.h,v retrieving revision 1.12 diff -u -p -r1.12 client.h --- client.h 24 Jul 2007 21:23:59 -0000 1.12 +++ client.h 26 Jul 2007 14:47:25 -0000 @@ -66,7 +66,7 @@ enum { COLUMN_RSSI, COLUMN_NAME, COLUMN_TYPE, - COLUMN_TRUSTED, + COLUMN_BONDED, COLUMN_CONNECTED, }; Index: test-client.c =================================================================== RCS file: /cvsroot/bluez/gnome/common/test-client.c,v retrieving revision 1.8 diff -u -p -r1.8 test-client.c --- test-client.c 24 Jul 2007 21:21:29 -0000 1.8 +++ test-client.c 26 Jul 2007 14:47:25 -0000 @@ -112,7 +112,7 @@ static void create_window(void) gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tree), -1, "Trusted", gtk_cell_renderer_text_new(), - "text", COLUMN_TRUSTED, NULL); + "text", COLUMN_BONDED, NULL); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tree), -1, "Connected", gtk_cell_renderer_text_new(), [-- Attachment #3: Type: text/plain, Size: 315 bytes --] ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ [-- Attachment #4: Type: text/plain, Size: 164 bytes --] _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Bluez-devel] [PATCH] Show the trusted icon in the treeview 2007-07-26 14:49 ` Bastien Nocera @ 2007-07-26 19:41 ` Marcel Holtmann 0 siblings, 0 replies; 4+ messages in thread From: Marcel Holtmann @ 2007-07-26 19:41 UTC (permalink / raw) To: BlueZ development Hi Bastien, > > > I added a property to be able to show/hide a trusted (bonded) icon in > > > the list view, it's shown by default. > > > > > > There's also a one-liner to avoid changing the address rather than the > > > name, when a device doesn't have a name (ie. it still displayed > > > 00:00:00:00:00:00 rather than 00-00-00-00-00-00, but changed the address > > > to that). > > > > Johan mentioned that bonded != trusted, and the existing code didn't > > make the difference. I'll fix that up. > > Fixes the above, and renames the COLUMN_TRUSTED to COLUMN_BONDED, as > that column includes the bonded status, not the trusted status. patch has been applied. Thanks. Regards Marcel ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-07-26 19:41 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-07-26 14:13 [Bluez-devel] [PATCH] Show the trusted icon in the treeview Bastien Nocera 2007-07-26 14:21 ` Bastien Nocera 2007-07-26 14:49 ` Bastien Nocera 2007-07-26 19:41 ` Marcel Holtmann
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox