mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-20 16:20:18 +01:00
Delete Files via Popup Menue
This commit is contained in:
parent
107d6f8fb1
commit
563f6ba835
3 changed files with 24 additions and 4 deletions
|
@ -48,9 +48,11 @@ func update():
|
||||||
wd_files.pop_back()
|
wd_files.pop_back()
|
||||||
wd_files = helpers.map(wd_files, self, "substr2")
|
wd_files = helpers.map(wd_files, self, "substr2")
|
||||||
|
|
||||||
var deleted_files = Array(shell.run("git status -s | grep '^.D' | sed -r 's/^...//'").split("\n"))
|
var deleted_files = []
|
||||||
deleted_files.pop_back()
|
if shell.run("test -d .git && echo yes || echo no") == "yes\n":
|
||||||
|
deleted_files = Array(shell.run("git status -s | grep '^.D' | sed -r 's/^...//'").split("\n"))
|
||||||
|
deleted_files.pop_back()
|
||||||
|
|
||||||
var files = wd_files + deleted_files
|
var files = wd_files + deleted_files
|
||||||
|
|
||||||
files.sort_custom(self, "very_best_sort")
|
files.sort_custom(self, "very_best_sort")
|
||||||
|
@ -62,7 +64,7 @@ func update():
|
||||||
var item = preload("res://scenes/file_browser_item.tscn").instance()
|
var item = preload("res://scenes/file_browser_item.tscn").instance()
|
||||||
item.label = file_path
|
item.label = file_path
|
||||||
item.connect("clicked", self, "item_clicked")
|
item.connect("clicked", self, "item_clicked")
|
||||||
|
item.connect("deleted", self, "item_deleted")
|
||||||
item.status = get_file_status(file_path, shell, 1)
|
item.status = get_file_status(file_path, shell, 1)
|
||||||
|
|
||||||
grid.add_child(item)
|
grid.add_child(item)
|
||||||
|
@ -133,6 +135,10 @@ func item_clicked(item):
|
||||||
open_file = item.label
|
open_file = item.label
|
||||||
text_edit.show()
|
text_edit.show()
|
||||||
text_edit.grab_focus()
|
text_edit.grab_focus()
|
||||||
|
|
||||||
|
func item_deleted(item):
|
||||||
|
helpers.careful_delete(shell._cwd + item.label)
|
||||||
|
update()
|
||||||
|
|
||||||
func close():
|
func close():
|
||||||
text_edit.hide()
|
text_edit.hide()
|
||||||
|
|
|
@ -2,6 +2,7 @@ class_name FileBrowserItem
|
||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
signal clicked(what)
|
signal clicked(what)
|
||||||
|
signal deleted(what)
|
||||||
|
|
||||||
enum IconStatus {NONE, NEW, REMOVED, CONFLICT, EDIT, UNTRACKED}
|
enum IconStatus {NONE, NEW, REMOVED, CONFLICT, EDIT, UNTRACKED}
|
||||||
export(IconStatus) var status setget _set_status
|
export(IconStatus) var status setget _set_status
|
||||||
|
@ -14,6 +15,7 @@ onready var status_icon = $VBoxContainer/Control/TextureRect/StatusIcon
|
||||||
func _ready():
|
func _ready():
|
||||||
_set_label(label)
|
_set_label(label)
|
||||||
_set_status(status)
|
_set_status(status)
|
||||||
|
$PopupMenu.add_item("Delete File", 0)
|
||||||
|
|
||||||
func _set_label(new_label):
|
func _set_label(new_label):
|
||||||
label = new_label
|
label = new_label
|
||||||
|
@ -23,6 +25,9 @@ func _set_label(new_label):
|
||||||
func _gui_input(event):
|
func _gui_input(event):
|
||||||
if event is InputEventMouseButton and event.is_pressed() and event.button_index == BUTTON_LEFT:
|
if event is InputEventMouseButton and event.is_pressed() and event.button_index == BUTTON_LEFT:
|
||||||
emit_signal("clicked", self)
|
emit_signal("clicked", self)
|
||||||
|
if event is InputEventMouseButton and event.is_pressed() and event.button_index == BUTTON_RIGHT and status != IconStatus.REMOVED:
|
||||||
|
$PopupMenu.set_position(get_global_mouse_position())
|
||||||
|
$PopupMenu.popup()
|
||||||
|
|
||||||
func _set_status(new_status):
|
func _set_status(new_status):
|
||||||
if status_icon:
|
if status_icon:
|
||||||
|
@ -47,3 +52,7 @@ func _set_status(new_status):
|
||||||
|
|
||||||
status = new_status
|
status = new_status
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _popup_menu_pressed(id):
|
||||||
|
emit_signal("deleted", self)
|
||||||
|
|
|
@ -92,3 +92,8 @@ custom_fonts/font = ExtResource( 2 )
|
||||||
text = "filename"
|
text = "filename"
|
||||||
align = 1
|
align = 1
|
||||||
autowrap = true
|
autowrap = true
|
||||||
|
|
||||||
|
[node name="PopupMenu" type="PopupMenu" parent="."]
|
||||||
|
margin_right = 20.0
|
||||||
|
margin_bottom = 20.0
|
||||||
|
[connection signal="id_pressed" from="PopupMenu" to="." method="_popup_menu_pressed"]
|
||||||
|
|
Loading…
Reference in a new issue