diff options
author | Bastien Nocera <hadess@src.gnome.org> | 2009-04-08 21:36:04 +0000 |
---|---|---|
committer | Bastien Nocera <hadess@src.gnome.org> | 2009-04-08 21:36:04 +0000 |
commit | 581e10144bc1a0e58445c9090547d8e061caeb83 (patch) | |
tree | 50ea0192c7277d09613a1f81c6abe05faf6b450d /applet | |
parent | 2caa42c96c0c59cb86ab71701a0aacabeadd83e3 (diff) | |
download | gnome-bluetooth-581e10144bc1a0e58445c9090547d8e061caeb83.tar.gz |
Avoid underscores in device names transforming the label into one with mnemonics (Closes: #578424)
svn path=/trunk/; revision=588
Diffstat (limited to 'applet')
-rw-r--r-- | applet/main.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/applet/main.c b/applet/main.c index 7bb5f26e..a8150d66 100644 --- a/applet/main.c +++ b/applet/main.c @@ -441,6 +441,21 @@ remove_action_item (GtkAction *action, GtkUIManager *manager) gtk_action_group_remove_action (devices_action_group, action); } +static char * +escape_label_for_action (const char *alias) +{ + char **tokens, *name; + + if (strchr (alias, '_') == NULL) + return g_strdup (alias); + + tokens = g_strsplit (alias, "_", -1); + name = g_strjoinv ("__", tokens); + g_strfreev (tokens); + + return name; +} + static void update_device_list (GtkTreeIter *parent) { @@ -475,7 +490,7 @@ update_device_list (GtkTreeIter *parent) while (cont) { GHashTable *table; DBusGProxy *proxy; - const char *name, *address; + const char *alias, *address; gboolean is_connected; GtkAction *action, *status, *oper; @@ -485,7 +500,7 @@ update_device_list (GtkTreeIter *parent) BLUETOOTH_COLUMN_PROXY, &proxy, BLUETOOTH_COLUMN_ADDRESS, &address, BLUETOOTH_COLUMN_SERVICES, &table, - BLUETOOTH_COLUMN_ALIAS, &name, + BLUETOOTH_COLUMN_ALIAS, &alias, BLUETOOTH_COLUMN_CONNECTED, &is_connected, -1); @@ -506,7 +521,11 @@ update_device_list (GtkTreeIter *parent) } } - if (table != NULL && address != NULL && proxy != NULL) { + if (table != NULL && address != NULL && proxy != NULL && alias != NULL) { + char *name; + + name = escape_label_for_action (alias); + if (action == NULL) { guint menu_merge_id; char *action_name, *action_path; @@ -570,6 +589,8 @@ update_device_list (GtkTreeIter *parent) set_device_status_label (address, is_connected ? CONNECTED : DISCONNECTED); gtk_action_set_label (oper, is_connected ? _("Disconnect") : _("Connect")); } + g_free (name); + g_object_set_data_full (G_OBJECT (oper), "connected", GINT_TO_POINTER (is_connected ? CONNECTED : DISCONNECTED), NULL); g_object_set_data_full (G_OBJECT (oper), |