Also show a file browser for the index

This commit is contained in:
Sebastian Morr 2020-10-23 15:19:25 +02:00
parent 6f2700d7fb
commit 0780ebc692
3 changed files with 30 additions and 19 deletions

View file

@ -10,17 +10,20 @@ export(FileBrowserMode) var mode = FileBrowserMode.WORKING_DIRECTORY
var shell
var commit setget _set_commit
var repository
onready var grid = $Panel/Margin/Rows/Scroll/Grid
func _ready():
update()
func clear():
for item in grid.get_children():
item.queue_free()
func update():
if grid:
for item in grid.get_children():
item.queue_free()
clear()
match mode:
FileBrowserMode.WORKING_DIRECTORY:
if shell:
@ -46,7 +49,17 @@ func update():
for file_path in files:
var item = preload("res://file_browser_item.tscn").instance()
item.label = file_path
item.connect("clicked", self, "item_clicked")
#item.connect("clicked", self, "item_clicked")
grid.add_child(item)
FileBrowserMode.INDEX:
if repository:
var files = Array(repository.shell.run("git ls-files -s | cut -f2").split("\n"))
# The last entry is an empty string, remove it.
files.pop_back()
for file_path in files:
var item = preload("res://file_browser_item.tscn").instance()
item.label = file_path
#item.connect("clicked", self, "item_clicked")
grid.add_child(item)
func item_clicked(item):

View file

@ -31,6 +31,7 @@ func _ready():
set_simplified_view(simplified_view)
set_editable_path(editable_path)
set_path(path)
index.repository = self
update_everything()
update_node_positions()
@ -60,7 +61,7 @@ func update_everything():
remove_gone_stuff()
else:
if index:
index.text = ""
index.clear()
for o in objects:
objects[o].queue_free()
objects = {}
@ -86,7 +87,7 @@ func set_label(new_label):
label_node.text = new_label
func update_index():
index.text = git("ls-files -s --abbrev=8").replace("\t", " ")
index.update()
func random_position():
return Vector2(rand_range(0, rect_size.x), rand_range(0, rect_size.y))

View file

@ -43,16 +43,13 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="Index" type="Label" parent="Rows/RepoVis"]
margin_left = 8.64569
margin_top = 63.8375
margin_right = 359.725
margin_bottom = 1027.84
text = "entry1
entry2"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Index" parent="Rows/RepoVis" instance=ExtResource( 4 )]
anchor_bottom = 0.0
margin_left = 22.0
margin_top = 65.0
margin_right = -17.0
margin_bottom = 188.0
mode = 2
[node name="IndexLabel" type="Label" parent="Rows/RepoVis"]
visible = false
@ -93,14 +90,14 @@ __meta__ = {
[node name="Nodes" type="Control" parent="Rows/RepoVis"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = -1.43991
margin_bottom = -1.43994
margin_bottom = -6.10352e-05
mouse_filter = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Path" type="LineEdit" parent="Rows/RepoVis"]
visible = false
margin_left = 23.0
margin_top = 12.0
margin_right = 374.0