From 47bda76d8a951b095c464931f5e9f81ee04fa2a9 Mon Sep 17 00:00:00 2001 From: Vratislav Podzimek Date: Mon, 24 Aug 2015 13:18:32 +0200 Subject: [PATCH 3/3] Only allow DS and XCCDF ID selection if it makes sense (#1254876) If there's only one DS and a single XCCDF in it, there's no point in showing the combo boxes that allow user to select the DS and XCCDF. Signed-off-by: Vratislav Podzimek --- org_fedora_oscap/gui/spokes/oscap.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/org_fedora_oscap/gui/spokes/oscap.py b/org_fedora_oscap/gui/spokes/oscap.py index af60841..3b8dbd7 100644 --- a/org_fedora_oscap/gui/spokes/oscap.py +++ b/org_fedora_oscap/gui/spokes/oscap.py @@ -418,11 +418,8 @@ class OSCAPSpoke(NormalSpoke): for dstream in self._ds_checklists.iterkeys(): add_ds_ids.add_action(self._add_ds_id, dstream) add_ds_ids.fire() - fire_gtk_action(really_show, self._ids_box) - else: - # hide the labels and comboboxes for datastream-id and xccdf-id - # selection - fire_gtk_action(really_hide, self._ids_box) + + self._update_ids_visibility() # refresh UI elements self.refresh() @@ -487,6 +484,25 @@ class OSCAPSpoke(NormalSpoke): self._ds_store.append([ds_id]) @gtk_action_wait + def _update_ids_visibility(self): + """ + Updates visibility of the combo boxes that are used to select the DS and + XCCDF IDs. + + """ + + if self._using_ds: + # only show the combo boxes if there are multiple data streams or + # multiple xccdfs (IOW if there's something to choose from) + ds_ids = self._ds_checklists.keys() + if len(ds_ids) > 1 or len(self._ds_checklists[ds_ids[0]]) > 1: + really_show(self._ids_box) + return + + # not showing, hide instead + really_hide(self._ids_box) + + @gtk_action_wait def _update_xccdfs_store(self): """ Clears and repopulates the store with XCCDF IDs from the currently @@ -818,8 +834,9 @@ class OSCAPSpoke(NormalSpoke): self._active_profile = self._addon_data.profile_id + self._update_ids_visibility() + if self._using_ds: - fire_gtk_action(really_show, self._ids_box) if self._addon_data.datastream_id: set_combo_selection(self._ds_combo, self._addon_data.datastream_id, @@ -837,7 +854,6 @@ class OSCAPSpoke(NormalSpoke): self._addon_data.xccdf_id, unset_first=True) else: - fire_gtk_action(really_hide, self._ids_box) # no combobox changes --> need to update profiles store manually self._update_profiles_store() -- 2.1.0