gnome-bluetooth r588 - trunk/applet



Author: hadess
Date: Wed Apr  8 21:36:04 2009
New Revision: 588
URL: http://svn.gnome.org/viewvc/gnome-bluetooth?rev=588&view=rev

Log:
Avoid underscores in device names transforming the label into one with mnemonics (Closes: #578424)


Modified:
   trunk/applet/main.c

Modified: trunk/applet/main.c
==============================================================================
--- trunk/applet/main.c	(original)
+++ trunk/applet/main.c	Wed Apr  8 21:36:04 2009
@@ -441,6 +441,21 @@
 	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 @@
 	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 @@
 				    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 @@
 			}
 		}
 
-		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 @@
 				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),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]