Automatically switch on simplified view when there are >= 3 commits

This commit is contained in:
Sebastian Morr 2020-09-30 22:41:28 +02:00
parent aec32e115c
commit e974342693
2 changed files with 18 additions and 13 deletions

View file

@ -19,6 +19,9 @@ var shell = Shell.new()
var objects = {}
var mouse_inside = false
# We use this for a heuristic of when to hide trees and blobs.
var _commit_count = 0
func _ready():
file_browser.shell = shell
@ -118,6 +121,10 @@ func update_objects():
for p in commit_parents(o):
c[p] = ""
n.children = c
_commit_count += 1
if _commit_count >= 3 and not simplified_view:
simplified_view = true
"tag":
n.children = tag_target(o)
@ -263,22 +270,18 @@ func ref_target(ref):
ret = git("show-ref "+ref).split(" ")[0]
return ret
func simplify_view(pressed):
simplified_view = pressed
for o in objects:
var obj = objects[o]
if obj.type == "tree" or obj.type == "blob":
obj.visible = not pressed
if there_is_a_git():
update_objects()
func set_simplified_view(simplify):
simplified_view = simplify
if simplify_checkbox:
simplify_checkbox.pressed = simplify
for o in objects:
var obj = objects[o]
if obj.type == "tree" or obj.type == "blob":
obj.visible = not simplify
if there_is_a_git():
update_objects()
func set_editable_path(editable):
editable_path = editable

View file

@ -93,6 +93,8 @@ __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
mouse_filter = 2
__meta__ = {
"_edit_use_anchors_": false
@ -118,5 +120,5 @@ size_flags_stretch_ratio = 0.16
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
[connection signal="pressed" from="Rows/RepoVis/Button" to="." method="update_everything"]
[connection signal="toggled" from="Rows/RepoVis/SimplifyCheckbox" to="." method="simplify_view"]
[connection signal="toggled" from="Rows/RepoVis/SimplifyCheckbox" to="." method="set_simplified_view"]
[connection signal="text_entered" from="Rows/RepoVis/Path" to="." method="set_path"]