Use "Icon" and "Alias" properties
PATCH 1/1 Use "Icon" and "Alias" properties
Rather than doing it ouselves.
Quoted 1 line
From
2fdc9f88921878ca803917d25bfa2c78c9febb71Mon Sep 17 00:00:00 2001
From: Bastien Nocera <[email protected]>
Date: Thu, 25 Sep 2008 20:09:19 -0700
Subject: [PATCH] Add Alias and Icon columns to the Client
This will allow us to clean up the helper code in the UI functions as bluetoothd already does most of the work for us.
--- common/bluetooth-client.c | 31 +++++++++++++++++++++++++++---- common/bluetooth-client.h | 2 ++ 2 files changed, 29 insertions(+), 4 deletions(-)
common/bluetooth-client.c +27 -4
@@ -268,6 +268,16 @@ static void device_changed(DBusGProxy *device, const char *property,gtk_tree_store_set (priv->store, &iter,BLUETOOTH_COLUMN_NAME , name,-1 ); + }else if (g_str_equal (property,"Alias" ) == TRUE) { +const gchar *alias =g_value_get_string (value); + +gtk_tree_store_set (priv->store, &iter, +BLUETOOTH_COLUMN_ALIAS , alias,-1 ); + }else if (g_str_equal (property,"Icon" ) == TRUE) { +const gchar *icon =g_value_get_string (value); + +gtk_tree_store_set (priv->store, &iter, +BLUETOOTH_COLUMN_ICON , icon,-1 ); }else if (g_str_equal (property,"Paired" ) == TRUE) {gboolean paired =g_value_get_boolean (value);
@@ -293,7 +303,7 @@ static void add_device(DBusGProxy *adapter, GtkTreeIter *parent,BluetoothClientPrivate *priv =BLUETOOTH_CLIENT_GET_PRIVATE (client);DBusGProxy *device;GValue *value; -const gchar *address, *name; +const gchar *address, *name, *icon, *alias;gboolean paired, trusted, connected;guint type;gint rssi;
@@ -316,6 +326,9 @@ static void add_device(DBusGProxy *adapter, GtkTreeIter *parent, value =g_hash_table_lookup (hash,"Name" ); name = value ?g_value_get_string (value) :NULL ; + value =g_hash_table_lookup (hash,"Alias" ); + alias = value ?g_value_get_string (value) :NULL ; + value =g_hash_table_lookup (hash,"Class" ); type =class_to_type (g_value_get_uint (value));
@@ -330,9 +343,14 @@ static void add_device(DBusGProxy *adapter, GtkTreeIter *parent, value =g_hash_table_lookup (hash,"Connected" ); connected = value ?g_value_get_boolean (value) : FALSE; + + value =g_hash_table_lookup (hash,"Icon" ); + icon = value ?g_value_get_string (value) :"bluetooth" ; }else { address =NULL ; name =NULL ; + alias =NULL ; + icon =NULL ; type =BLUETOOTH_TYPE_ANY ; rssi =0 ; paired = FALSE;
@@ -353,7 +371,9 @@ static void add_device(DBusGProxy *adapter, GtkTreeIter *parent,gtk_tree_store_set (priv->store, &iter,BLUETOOTH_COLUMN_ADDRESS , address,BLUETOOTH_COLUMN_NAME , name, +BLUETOOTH_COLUMN_ALIAS , alias,BLUETOOTH_COLUMN_TYPE , type, +BLUETOOTH_COLUMN_ICON , icon,BLUETOOTH_COLUMN_RSSI , rssi,-1 );if (device !=NULL ) {
@@ -374,7 +394,9 @@ static void add_device(DBusGProxy *adapter, GtkTreeIter *parent,BLUETOOTH_COLUMN_PROXY , device,BLUETOOTH_COLUMN_ADDRESS , address,BLUETOOTH_COLUMN_NAME , name, +BLUETOOTH_COLUMN_ALIAS , alias,BLUETOOTH_COLUMN_TYPE , type, +BLUETOOTH_COLUMN_ICON , icon,BLUETOOTH_COLUMN_RSSI , rssi,BLUETOOTH_COLUMN_PAIRED , paired, BLUETOOTH_COLUMN_TRUSTED, trusted,
@@ -402,6 +424,7 @@ static void device_found(DBusGProxy *adapter, const char *address,DBG ("client %p address %s" , client, address); +//FIXME what is the name actually used for here? if (hash !=NULL ) { value =g_hash_table_lookup (hash,"Name" ); name = value ?g_value_get_string (value) :NULL ;
@@ -649,9 +672,9 @@ static void bluetooth_client_init(BluetoothClient *client)DBG ("client %p" , client); priv->store =gtk_tree_store_new (_BLUETOOTH_NUM_COLUMNS,G_TYPE_OBJECT , -G_TYPE_STRING ,G_TYPE_STRING ,G_TYPE_UINT ,G_TYPE_INT , -G_TYPE_BOOLEAN ,G_TYPE_BOOLEAN ,G_TYPE_BOOLEAN , -G_TYPE_BOOLEAN ,G_TYPE_BOOLEAN ); +G_TYPE_STRING ,G_TYPE_STRING ,G_TYPE_STRING ,G_TYPE_STRING , +G_TYPE_UINT ,G_TYPE_INT ,G_TYPE_BOOLEAN ,G_TYPE_BOOLEAN , +G_TYPE_BOOLEAN ,G_TYPE_BOOLEAN ,G_TYPE_BOOLEAN ); priv->dbus =dbus_g_proxy_new_for_name (connection,DBUS_SERVICE_DBUS ,DBUS_PATH_DBUS ,DBUS_INTERFACE_DBUS );
common/bluetooth-client.h +2 -0
@@ -89,6 +89,8 @@ enum {BLUETOOTH_COLUMN_PROXY ,BLUETOOTH_COLUMN_ADDRESS ,BLUETOOTH_COLUMN_NAME , +BLUETOOTH_COLUMN_ALIAS , +BLUETOOTH_COLUMN_ICON ,BLUETOOTH_COLUMN_TYPE ,BLUETOOTH_COLUMN_RSSI , BLUETOOTH_COLUMN_DEFAULT,
Signature · 1 line
1.6.0.1
Quoted 1 line
From
e93f7c579707ccbb4918f2590bfdc2d774c906baMon Sep 17 00:00:00 2001
From: Bastien Nocera <[email protected]>
Date: Thu, 25 Sep 2008 20:13:18 -0700
Subject: [PATCH] Remove use of type_to_icon()
Given to use directly in the BLUETOOTH_COLUMN_ICON now
--- common/helper.c | 48 ++---------------------------------------------- 1 files changed, 2 insertions(+), 46 deletions(-)
common/helper.c +2 -46
60 lines not on this page · raw message
Signature · 1 line
1.6.0.1
Quoted 1 line
From
dfc323f48817602d721afb7b9851766f803ce5e8Mon Sep 17 00:00:00 2001
From: Bastien Nocera <[email protected]>
Date: Thu, 25 Sep 2008 20:15:29 -0700
Subject: [PATCH] Remove use of name_to_text()
We use BLUETOOTH_COLUMN_ALIAS now
--- common/helper.c | 23 ++--------------------- 1 files changed, 2 insertions(+), 21 deletions(-)
common/helper.c +2 -21
@@ -30,25 +30,6 @@#include <bluetooth-client.h> -static void name_to_text (GtkTreeViewColumn *column,GtkCellRenderer *cell, -GtkTreeModel *model,GtkTreeIter *iter,gpointer data) -{ -gchar *address, *name; - -gtk_tree_model_get (model, iter,BLUETOOTH_COLUMN_ADDRESS , &address, -BLUETOOTH_COLUMN_NAME , &name,-1 ); - -if (name ==NULL ) { - name =g_strdup (address); -g_strdelimit (name,":" ,'-' ); - } - -g_object_set (cell,"text" , name ? name : address,NULL ); - -g_free (name); -g_free (address); -} -static void connected_to_icon (GtkTreeViewColumn *column,GtkCellRenderer *cell,GtkTreeModel *model,GtkTreeIter *iter,gpointer data) {
@@ -117,8 +98,8 @@ GtkWidget *create_tree(GtkTreeModel *model, gboolean icons) 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 ); +gtk_tree_view_column_add_attribute (column, renderer, +"text" ,BLUETOOTH_COLUMN_ALIAS ); gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(tree), -1, "Connected", gtk_cell_renderer_pixbuf_new(),
Signature · 1 line
1.6.0.1
Marcel Holtmann
maintainerHi Bastien,
Quoted 1 line
Rather than doing it ouselves.
I had similar patches already in my tree. Pushed them out :)
Regards
Marcel