mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-24 11:17:26 -04:00
better gate not responding
This commit is contained in:
parent
262f14caeb
commit
eecf9b31b7
8 changed files with 112 additions and 64 deletions
|
@ -1,7 +1,6 @@
|
|||
extends Node
|
||||
|
||||
@export var gate_events: GateEvents
|
||||
@export var history: History
|
||||
|
||||
@export var go_back: RoundButton
|
||||
@export var go_forw: RoundButton
|
||||
|
@ -10,50 +9,18 @@ extends Node
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
gate_events.open_gate.connect(on_new)
|
||||
gate_events.search.connect(on_new)
|
||||
gate_events.exit_gate.connect(on_new.bind(""))
|
||||
go_back.pressed.connect(Navigation.go_back)
|
||||
go_forw.pressed.connect(Navigation.go_forw)
|
||||
reload.pressed.connect(Navigation.reload)
|
||||
home.pressed.connect(Navigation.home)
|
||||
|
||||
go_back.pressed.connect(on_go_back)
|
||||
go_forw.pressed.connect(on_go_forw)
|
||||
reload.pressed.connect(on_reload)
|
||||
home.pressed.connect(gate_events.exit_gate_emit)
|
||||
|
||||
go_back.disable()
|
||||
go_forw.disable()
|
||||
|
||||
|
||||
func on_new(location: String) -> void:
|
||||
history.add(location)
|
||||
Navigation.updated.connect(update_buttons)
|
||||
update_buttons()
|
||||
|
||||
|
||||
func on_go_back() -> void:
|
||||
open(history.back())
|
||||
update_buttons()
|
||||
|
||||
|
||||
func on_go_forw() -> void:
|
||||
open(history.forw())
|
||||
update_buttons()
|
||||
|
||||
|
||||
func on_reload() -> void:
|
||||
open(history.get_current())
|
||||
|
||||
|
||||
func open(location: String) -> void:
|
||||
if location == "":
|
||||
gate_events.exit_gate_emit()
|
||||
elif Url.is_valid(location):
|
||||
gate_events.open_gate_emit(location)
|
||||
else:
|
||||
gate_events.search_emit(location)
|
||||
|
||||
|
||||
func update_buttons() -> void:
|
||||
if history.can_back(): go_back.enable()
|
||||
if Navigation.can_back(): go_back.enable()
|
||||
else: go_back.disable()
|
||||
|
||||
if history.can_forw(): go_forw.enable()
|
||||
if Navigation.can_forw(): go_forw.enable()
|
||||
else: go_forw.disable()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue