def fill_partition_list(self): # create tree store 'partition_list_store' for our model if self.partition_list_store != None: self.partition_list_store.clear() # Treeview columns: # disc path or partition path or "free space", # fs_type # label # part_name # formatable_active # formatable_visible # size # used # partition_path # flags self.partition_list_store = Gtk.TreeStore(str, str, str, str, bool, bool, str, str, str, str, int) if self.disks == None: # just call get_devices once self.disks = pm.get_devices() for disk_path in sorted(self.disks): disk = self.disks[disk_path] if disk is None: # maybe disk without a partition table? print(disk_path) row = [disk_path, "", "", "", False, False, "", "", "", "", 0] self.partition_list_store.append(None, row) else: dev = disk.device size_txt = self.get_size(dev.length, dev.sectorSize) row = [dev.path, "", "", "", False, False, size_txt, "", "", "", 0] disk_parent = self.partition_list_store.append(None, row) parent = disk_parent # create list of partitions for this device (/dev/sda for example) partitions = pm.get_partitions(disk) partition_list = pm.order_partitions(partitions) for partition_path in partition_list: p = partitions[partition_path] size_txt = self.get_size(p.geometry.length, dev.sectorSize) label = "" if p.type == pm.PARTITION_EXTENDED: path = p.path mount_point = "" fs_type = _("extended") formatable = False used = "" flags = pm.get_flags(p) # aas# cannot get label from staged partition try: info = fs.get_info(partition_path) except: info = [] if "LABEL" in info: label = info["LABEL"] elif p.type == pm.PARTITION_PRIMARY or p.type == pm.PARTITION_LOGICAL: path = p.path # aas# fix crash if no fs on partition if p.fileSystem: fs_type = p.fileSystem.type else: fs_type = "none" formatable = True used = str(pm.get_used_space(p)) flags = pm.get_flags(p) if pm.check_mounted(p): if "swap" in fs_type: mount_point = "(swap)" else: mount_point = self.get_mount_point(p.path) else: mount_point = "" # aas# we cannot get label of staged partition try: info = fs.get_info(partition_path) except: info = [] if "LABEL" in info: label = info["LABEL"] elif p.type == pm.PARTITION_FREESPACE: path = _("free space") mount_point = "" fs_type = _("not used") formatable = True used = "" flags = "" row = [ path, fs_type, mount_point, label, False, formatable, size_txt, used, partition_path, "", p.type, ] tree_iter = self.partition_list_store.append(parent, row) if p.type == pm.PARTITION_EXTENDED: parent = tree_iter elif p.type == pm.PARTITION_PRIMARY: parent = disk_parent # assign our new model to our treeview self.partition_list.set_model(self.partition_list_store) self.partition_list.expand_all()