Skip to content

Commit 22cda93

Browse files
committed
Hide internal qubes from list modeler by default
1 parent a89069d commit 22cda93

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

qubes_config/global_config/basics_handler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def __init__(
135135
vm_filter: Optional[Callable] = None,
136136
readable_name: Optional[str] = None,
137137
additional_options: Dict[Any | str | None, str] | None = None,
138+
show_internal: bool = False,
138139
):
139140
self.qapp = qapp
140141
self.trait_holder = trait_holder
@@ -149,6 +150,7 @@ def __init__(
149150
current_value=self.get_current_value(),
150151
style_changes=True,
151152
additional_options=additional_options,
153+
show_internal=show_internal,
152154
)
153155

154156
def get_readable_description(self) -> str:

qubes_config/widgets/gtk_widgets.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
import gettext
3737

38+
from ..widgets.utils import get_boolean_feature
39+
3840
t = gettext.translation("desktop-linux-manager", fallback=True)
3941
_ = t.gettext
4042

@@ -234,6 +236,7 @@ def __init__(
234236
current_value: qubesadmin.vm.QubesVM | str | None = None,
235237
style_changes: bool = False,
236238
additional_options: dict[qubesadmin.vm.QubesVM | str | None, str] | None = None,
239+
show_internal: bool = False,
237240
):
238241
"""
239242
:param combobox: target ComboBox object
@@ -254,12 +257,14 @@ def __init__(
254257
applied when combobox value changes
255258
:param additional_options: Dictionary of token: readable name of
256259
additonal options to be added to the combobox
260+
:param show_internal: if True, show qubes with internal feature enabled
257261
"""
258262
self.qapp = qapp
259263
self.combo = combobox
260264
self.entry_box = self.combo.get_child()
261265
self.change_function = event_callback
262266
self.style_changes = style_changes
267+
self.show_internal = show_internal
263268

264269
self._entries: dict[str, dict[str, Any]] = {}
265270

@@ -337,9 +342,23 @@ def _create_entries(
337342
"vm": None,
338343
}
339344

345+
found_current = False
346+
if current_value and current_value in self.qapp.domains:
347+
found_current = True
348+
domain = self.qapp.domains[current_value]
349+
icon = self._get_icon(domain.icon)
350+
vm_name = domain.name
351+
self._entries[vm_name] = {
352+
"api_name": vm_name,
353+
"icon": icon,
354+
"vm": domain,
355+
}
356+
340357
for domain in self.qapp.domains:
341358
if filter_function and not filter_function(domain):
342359
continue
360+
if get_boolean_feature(domain, "internal") and not self.show_internal:
361+
continue
343362
vm_name = domain.name
344363
icon = self._get_icon(domain.icon)
345364
display_name = vm_name
@@ -353,8 +372,7 @@ def _create_entries(
353372
"vm": domain,
354373
}
355374

356-
if current_value:
357-
found_current = False
375+
if current_value and not found_current:
358376
for value in self._entries.values():
359377
if value["api_name"] == current_value:
360378
found_current = True

0 commit comments

Comments
 (0)