def insert_new_node(item)
if current = selection.selected
parent = current.parent or return
parent_parent = parent.parent
parent_type = parent.type
if parent_type == 'Array'
selected_index = parent.each_with_index do |c, i|
break i if c == current
end
type, content = ask_for_element(parent)
type or return
iter = model.insert_before(parent, current)
iter.type, iter.content = type, content
toplevel.display_status("Inserted an element to " +
"'#{parent_type}' before index #{selected_index}.")
window.change
else
toplevel.display_status(
"Cannot insert node below '#{parent_type}'!")
end
else
toplevel.display_status("Append a node into the root first!")
end
end