Skip to content

Commit

Permalink
Add option to invert device selection in adv. partitioning
Browse files Browse the repository at this point in the history
This enables the user to select one device (or a subset of
all existing devices) that should not be selected, e. g.
so that it can be preserved in the partitioning.
  • Loading branch information
jikortus authored and jstodola committed Sep 19, 2023
1 parent cbce975 commit 7d99b56
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from anabot.conditions import is_distro_version, is_distro_version_ge
from anabot.runtime.decorators import handle_action, handle_check, check_action_result
from anabot.runtime.default import default_handler, action_result
from anabot.runtime.functions import get_attr, getnode, getnode_scroll, getnodes, getparent, getsibling, press_key, scrollto, dump
from anabot.runtime.functions import get_attr, get_attr_bool, getnode, getnode_scroll, getnodes, getparent, getsibling, press_key, scrollto, dump
from anabot.runtime.errors import TimeoutError
from anabot.runtime.translate import tr, gtk_tr
from anabot.runtime.installation.common import done_handler
Expand Down Expand Up @@ -125,7 +125,7 @@ def switch_toggle(device):
@handle_act('/select')
def select_handler(element, app_node, local_node):
global _current_selection
def devs(parent, device=None, mountpoint=None):
def devs(parent, device=None, mountpoint=None, invert_match=False):
def dname(icon):
return icon.parent.children[0].name
def mpoint(icon):
Expand All @@ -136,7 +136,8 @@ def check(icon):
matches = fnmatchcase(dname(icon), device)
if matches and mountpoint is not None:
matches = fnmatchcase(mpoint(icon), mountpoint)
return matches
# invert match if invert_match == True
return matches ^ invert_match
try:
return [icon.parent.parent
for icon in getnodes(parent, "icon", visible=None)
Expand All @@ -147,6 +148,7 @@ def devname(device_panel):
return getnode(device_panel, "label", visible=None).name
fndevice = get_attr(element, "device", None)
mountpoint = get_attr(element, "mountpoint", None)
invert_selection = get_attr_bool(element, "invert_selection", False)
devices_node = getnodes(local_node, "scroll pane")[1]
device_required = get_attr(element, "required", "no") == "yes"
processed = [] # remember ATK nodes instead of device names
Expand All @@ -156,7 +158,7 @@ def devname(device_panel):
#__initialize_toggles(devices_node) - this is hopefully no longer needed
while not done:
done = True
for device in devs(devices_node, fndevice, mountpoint):
for device in devs(devices_node, fndevice, mountpoint, invert_selection):
# Get mountpoint name of selected device
device_label = getnodes(device, "label")[2].name
device_group = getparent(device, "toggle button").name
Expand Down

0 comments on commit 7d99b56

Please sign in to comment.