Show the trusted icon in the treeview
PATCH 1/1 Show the trusted icon in the treeview
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).
Signature · 1 line
Bastien Nocera <[email protected]>
Index: bluetooth-device-selection.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/bluetooth-device-selection.c,v retrieving revision 1.3
bluetooth-device-selection.c +45 -2
@@ -52,6 +52,10 @@ struct _BluetoothDeviceSelectionPrivateGtkTreeSelection *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(BluetootGtkCellRenderer *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(Bluetootgtk_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(Bluetootgtk_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 (GObenum {PROP_0 ,PROP_TITLE , -PROP_DEVICE_SELECTED +PROP_DEVICE_SELECTED , +PROP_SHOW_BONDING }; static void
@@ -281,6 +312,11 @@ bluetooth_device_selection_set_propertyg_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 (Bg_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 *
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Quoted 7 lines · Bastien Nocera
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.
Signature · 12 lines
Bastien Nocera <[email protected]> ------------------------------------------------------------------------- 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 [email protected] https://lists.sourceforge.net/lists/listinfo/bluez-devel
Quoted 11 lines · Bastien Nocera
Quoted 7 lines · Bastien Nocera
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.
Signature · 1 line
Bastien Nocera <[email protected]>
Index: bluetooth-device-selection.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/bluetooth-device-selection.c,v retrieving revision 1.3
bluetooth-device-selection.c +44 -2
@@ -52,6 +52,10 @@ struct _BluetoothDeviceSelectionPrivateGtkTreeSelection *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(BluetootGtkCellRenderer *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(Bluetootgtk_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(Bluetootgtk_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 (GObenum {PROP_0 ,PROP_TITLE , -PROP_DEVICE_SELECTED +PROP_DEVICE_SELECTED , +PROP_SHOW_BONDING }; static void
@@ -281,6 +311,11 @@ bluetooth_device_selection_set_propertyg_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 (Bg_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
client.c +4 -4
@@ -190,7 +190,7 @@ static void insert_device(DBusGProxy *obconst 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 *obdbus_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 *obCOLUMN_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 *obCOLUMN_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
client.h +1 -1
@@ -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
test-client.c +1 -1
@@ -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(),
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Marcel Holtmann
maintainerHi Bastien,
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
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).
Quoted 5 lines
Quoted 2 lines
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_TRUSTEDtoCOLUMN_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
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel