Skip to content

Commit

Permalink
- avoid passing by reference for MakeNavigationTree
Browse files Browse the repository at this point in the history
  • Loading branch information
aschnell committed Aug 2, 2013
1 parent df6b1ab commit 5a95a61
Showing 1 changed file with 28 additions and 32 deletions.
60 changes: 28 additions & 32 deletions src/include/partitioning/ep-main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ def UpdateMainStatus
end


def MakeNavigationTree(open_items, tree, data)
def MakeNavigationTree(open_items)
open_items = deep_copy(open_items)
# TODO: somehow use AlwaysHideDisk

data.value = {
data = {
:all => {
:create => fun_ref(method(:CreateAllPanel), "void (any)"),
:handle => fun_ref(method(:HandleAllPanel), "void (any, map)")
Expand Down Expand Up @@ -211,8 +211,8 @@ def MakeNavigationTree(open_items, tree, data)
tmp,
Item(Id(part_device), part_displayname, open.call(part_device))
)
data.value = Builtins.add(
data.value,
data = Builtins.add(
data,
part_device,
Builtins.union(a, { :user_data => part_device })
)
Expand All @@ -233,8 +233,8 @@ def MakeNavigationTree(open_items, tree, data)
)
)
)
data.value = Builtins.add(
data.value,
data = Builtins.add(
data,
disk_device,
Builtins.union(b, { :user_data => disk_device })
)
Expand Down Expand Up @@ -368,7 +368,7 @@ def MakeNavigationTree(open_items, tree, data)
short_hostname = Hostname.CurrentHostname

# TODO: same ordering as with IterateTargetMap
tree.value = [
tree = [
Item(
Id(:all),
term(:icon, StorageIcons.all_icon),
Expand Down Expand Up @@ -449,8 +449,8 @@ def MakeNavigationTree(open_items, tree, data)

if UI.HasSpecialWidget(:Graph)
# tree node label
tree.value = Builtins.add(
tree.value,
tree = Builtins.add(
tree,
Item(
Id(:devicegraph),
term(:icon, StorageIcons.graph_icon),
Expand All @@ -459,8 +459,8 @@ def MakeNavigationTree(open_items, tree, data)
)
)
# tree node label
tree.value = Builtins.add(
tree.value,
tree = Builtins.add(
tree,
Item(
Id(:mountgraph),
term(:icon, StorageIcons.graph_icon),
Expand All @@ -472,8 +472,8 @@ def MakeNavigationTree(open_items, tree, data)


# tree node label
tree.value = Builtins.add(
tree.value,
tree = Builtins.add(
tree,
Item(
Id(:summary),
term(:icon, StorageIcons.summary_icon),
Expand All @@ -483,8 +483,8 @@ def MakeNavigationTree(open_items, tree, data)
)

# tree node label
tree.value = Builtins.add(
tree.value,
tree = Builtins.add(
tree,
Item(
Id(:settings),
term(:icon, StorageIcons.settings_icon),
Expand All @@ -495,8 +495,8 @@ def MakeNavigationTree(open_items, tree, data)

if Mode.normal
# tree node label
tree.value = Builtins.add(
tree.value,
tree = Builtins.add(
tree,
Item(
Id(:log),
term(:icon, StorageIcons.log_icon),
Expand All @@ -506,22 +506,24 @@ def MakeNavigationTree(open_items, tree, data)
)
end

nil
return tree, data

end


def UpdateNavigationTree(new_focus)
new_focus = deep_copy(new_focus)
tree = []
data = {}

open_items = Convert.to_map(UI.QueryWidget(Id(:tree), :OpenItems))
tree_ref = arg_ref(tree)
data_ref = arg_ref(data)
MakeNavigationTree(open_items, tree_ref, data_ref)
tree = tree_ref.value
data = data_ref.value

tree, data = MakeNavigationTree(open_items)

TreePanel.Update(data, tree, new_focus)

nil
end


def EpContextMenuDevice(device)
target_map = Storage.GetTargetMap

Expand Down Expand Up @@ -659,13 +661,7 @@ def ExpertPartitioner

Storage.CreateTargetBackup("expert-partitioner")

tree = []
data = {}
tree_ref = arg_ref(tree)
data_ref = arg_ref(data)
MakeNavigationTree({ :all => "ID" }, tree_ref, data_ref)
tree = tree_ref.value
data = data_ref.value
tree, data = MakeNavigationTree({ :all => "ID" })

back_label = Label.BackButton
next_label = Mode.normal ? Label.FinishButton : Label.AcceptButton
Expand Down

0 comments on commit 5a95a61

Please sign in to comment.