Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ellipsize the file system type combo box (#1212615) #255

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion pyanaconda/ui/gui/spokes/custom.glade
Expand Up @@ -41,6 +41,12 @@
</row>
</data>
</object>
<object class="GtkListStore" id="fileSystemStore">
<columns>
<!-- column-name fs_type -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="mountPointStore">
<columns>
<!-- column-name path -->
Expand Down Expand Up @@ -714,11 +720,20 @@
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="fileSystemTypeCombo">
<object class="GtkComboBox" id="fileSystemTypeCombo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="model">fileSystemStore</property>
<signal name="changed" handler="on_fs_type_changed" swapped="no"/>
<signal name="changed" handler="on_value_changed" swapped="no"/>
<child>
<object class="GtkCellRendererText" id="fileSystemRenderer">
<property name="ellipsize">end</property>
</object>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="expand">False</property>
Expand Down
31 changes: 22 additions & 9 deletions pyanaconda/ui/gui/spokes/custom.py
Expand Up @@ -140,7 +140,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
builderObjects = ["customStorageWindow", "containerStore", "deviceTypeStore",
"partitionStore", "raidStoreFiltered", "raidLevelStore",
"addImage", "removeImage", "settingsImage",
"mountPointCompletion", "mountPointStore"]
"mountPointCompletion", "mountPointStore", "fileSystemStore"]
mainWidgetName = "customStorageWindow"
uiFile = "spokes/custom.glade"
helpFile = "CustomSpoke.xml"
Expand Down Expand Up @@ -240,6 +240,7 @@ def _grabObjects(self):
# Detailed configuration stuff
self._encryptCheckbox = self.builder.get_object("encryptCheckbox")
self._fsCombo = self.builder.get_object("fileSystemTypeCombo")
self._fsStore = self.builder.get_object("fileSystemStore")
self._labelEntry = self.builder.get_object("labelEntry")
self._mountPointEntry = self.builder.get_object("mountPointEntry")
self._nameEntry = self.builder.get_object("nameEntry")
Expand Down Expand Up @@ -437,6 +438,14 @@ def _clear_current_selector(self):
self._current_selector.set_chosen(False)
self._current_selector = None

def _get_fstype(self, fstypeCombo):
itr = fstypeCombo.get_active_iter()
if not itr:
return None

model = fstypeCombo.get_model()
return model[itr][0]

def _get_autopart_type(self, autopartTypeCombo):
itr = autopartTypeCombo.get_active_iter()
if not itr:
Expand Down Expand Up @@ -1336,9 +1345,9 @@ def _setup_fstype_combo(self, device):
names.sort()

# Add all desired fileystem type names to the box, sorted alphabetically
self._fsCombo.remove_all()
self._fsStore.clear()
for ty in names:
self._fsCombo.append_text(ty)
self._fsStore.append([ty])

# set the active filesystem type
idx = next(i for i, data in enumerate(self._fsCombo.get_model()) if data[0] == type_name)
Expand Down Expand Up @@ -2405,10 +2414,12 @@ def on_fs_type_changed(self, combo):
if not self._initialized:
return

new_type = combo.get_active_text()
if new_type is None:
itr = combo.get_active_iter()
if not itr:
return
log.debug("fs type changed: %s", new_type)

new_type = self._get_fstype(combo)

fmt = getFormat(new_type)
fancy_set_sensitive(self._mountPointEntry, fmt.mountable)

Expand Down Expand Up @@ -2510,12 +2521,14 @@ def _update_fstype_combo(self, device_type):
This method is idempotent, and must remain so.
"""
# Find unique instance of btrfs in fsCombo, if any.
btrfs_idx = next((idx for idx, data in enumerate(self._fsCombo.get_model()) if data[0] == "btrfs"), None)
model = self._fsCombo.get_model()
btrfs_iter = ((idx, row) for idx, row in enumerate(model) if row[0] == "btrfs")
btrfs_idx, btrfs_row = next(btrfs_iter, (None, None))

if device_type == DEVICE_TYPE_BTRFS:
# If no btrfs entry, add one, and select the new entry
if btrfs_idx is None:
self._fsCombo.append_text("btrfs")
self._fsStore.append(["btrfs"])
active_index = len(self._fsCombo.get_model()) - 1
# Otherwise, select the already located btrfs entry
else:
Expand All @@ -2526,7 +2539,7 @@ def _update_fstype_combo(self, device_type):

# If there is a btrfs entry, remove and adjust active_index
if btrfs_idx is not None:
self._fsCombo.remove(btrfs_idx)
self._fsStore.remove(btrfs_row.iter)

# If btrfs previously selected, select default filesystem
if active_index == btrfs_idx:
Expand Down