Commits

Ikey Doherty committed fe39bf9

Update SegmentedBar from DiskChooser selection

Comments (0)

Files changed (2)

src/pages/disks/disks.vala

 	return new Installer.Widgets.Color (red, green, blue);
    }
 
-   private void set_bar_from_disk (int which) {
-	unowned Device device = devices.nth_data (which);
-	Disk disk = device.disk;
+   private void set_bar_from_disk (Disk disk) {
+	currentDisk.remove_all ();
+	currentDisk.disk_size = 0;
 	foreach (Partition part in disk.partitions) {
 		if ( ! part.active ) continue;
 		currentDisk.add_segment (part.path, part.size, random_color () );
 		if (devices == null) {
 			devices = DeviceManager.get_all_devices ();
 			if (devices.length () >= 1) {
-				set_bar_from_disk (0);
+				set_bar_from_disk (devices.nth_data(0).disk);
 				foreach (unowned Device d in devices) {
 					//Disk d = devices.nth_data(0).disk;
 					disk_chooser.add_disk (d.disk);
 
 	display = new Gtk.VBox (false, 10);
 	disk_chooser = new DiskChooser ();
+	disk_chooser.disk_selected.connect ( (d) => { set_bar_from_disk (d); } );
 	display.pack_start (disk_chooser, false, false, 10);
 
 	currentDisk = new SegmentedBar ();

src/widgets/diskchooser/diskchooser.vala

 	current_disk_item = new DiskItem(current_disk);
 	holder.add (current_disk_item);
 	holder.show_all ();
+
+	disk_selected (current_disk);
    }
 
    private void check_limits () {
 		forwardBtn.set_sensitive (true);
 	}
    }
+
+   // Emitted when a disk is selected in the UI
+   public signal void disk_selected (Disk disk);
 }