I've seen myself opening and closing connection info to see if bitrate
changed, this should fix it. Now the bitrate label will be updated every
2s if the connection info dialog is open.
diff --git a/src/applet-dialogs.c b/src/applet-dialogs.c
index e1dc530..7f3b8e4 100644
--- a/src/applet-dialogs.c
+++ b/src/applet-dialogs.c
@@ -231,6 +231,51 @@ create_info_notebook_label (NMConnection *connection, gboolean is_default)
 	return label;
 }
 
+struct br_info {
+	GtkWidget* label;
+	GtkWidget* dialog;
+	NMDevice *device;
+	uint8_t referenced;
+	guint timeout;
+	gulong tag;
+};
+
+static void stop_bitrate_monitor(GtkWidget* w, gint resp_id, struct br_info* info) {
+	g_object_unref(info->device);
+	g_object_unref(info->label);
+	g_source_remove(info->timeout);
+	g_signal_handler_disconnect(info->dialog, info->tag);
+	g_free(info);
+}
+
+static gboolean
+update_wifi_bitrate_label(struct br_info *info) {
+		guint32 speed = 0;
+		gchar* str = NULL;
+		
+		if(!info->referenced) {
+			g_object_ref(info->device);
+			g_object_ref(info->label);
+			
+			info->dialog = gtk_widget_get_ancestor(info->label, GTK_TYPE_DIALOG);
+			info->tag = g_signal_connect (info->dialog, "response", G_CALLBACK (stop_bitrate_monitor), info);
+			info->referenced = TRUE;
+			return FALSE;
+		} 
+		
+		speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (info->device));
+		speed /= 1000;
+	
+		if (speed)
+			str = g_strdup_printf (_("%u Mb/s"), speed);
+		else
+			str = NULL;
+
+		gtk_label_set_text(GTK_LABEL(info->label), str ? str : _("Unknown"));
+		g_free(str);
+
+		return TRUE;
+}
 static void
 info_dialog_add_page (GtkNotebook *notebook,
 					  NMConnection *connection,
@@ -246,6 +291,9 @@ info_dialog_add_page (GtkNotebook *notebook,
 	NMIP4Address *def_addr;
 	guint32 hostmask, network, bcast, netmask;
 	int row = 0;
+	
+	struct br_info* binfo = NULL;
+	GtkWidget* bitrate_label;
 
 	table = GTK_TABLE (gtk_table_new (12, 2, FALSE));
 	gtk_table_set_col_spacings (table, 12);
@@ -273,7 +321,7 @@ info_dialog_add_page (GtkNotebook *notebook,
 							   1, 2, row, row + 1);
 	g_free (str);
 	row++;
-
+	
 	/* Hardware address */
 	str = NULL;
 	if (NM_IS_DEVICE_ETHERNET (device))
@@ -308,18 +356,29 @@ info_dialog_add_page (GtkNotebook *notebook,
 		/* Wireless speed in Kb/s */
 		speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (device));
 		speed /= 1000;
+		g_object_ref(device);
+		binfo = g_malloc0(sizeof(struct br_info));
+		binfo->device = device;
 	}
 
 	if (speed)
 		str = g_strdup_printf (_("%u Mb/s"), speed);
 	else
 		str = NULL;
+		
+	bitrate_label = create_info_label (str ? str : _("Unknown"), TRUE);
+	
+	if (NM_IS_DEVICE_WIFI (device)) {
+		binfo->label = bitrate_label;
+		binfo->timeout = g_timeout_add_seconds(2, (GSourceFunc)update_wifi_bitrate_label, binfo);
+		g_idle_add((GSourceFunc)update_wifi_bitrate_label, binfo);
+	}
 
 	gtk_table_attach_defaults (table,
 							   create_info_label (_("Speed:"), FALSE),
 							   0, 1, row, row + 1);
 	gtk_table_attach_defaults (table,
-							   create_info_label (str ? str : _("Unknown"), TRUE),
+							   bitrate_label,
 							   1, 2, row, row + 1);
 	g_free (str);
 	row++;
_______________________________________________
NetworkManager-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/networkmanager-list

Reply via email to