WIP: Need to switch to wxAcceleratorTable
This commit is contained in:
+32
-12
@@ -291,7 +291,7 @@ handle_event(#wx{event = #wxCommand{type = command_button_clicked},
|
||||
case lists:keyfind(ID, #w.id, Buttons) of
|
||||
#w{name = wallet} -> wallman(State);
|
||||
#w{name = chain} -> netman(State);
|
||||
#w{name = dev} -> doomweaver(State);
|
||||
#w{name = dev} -> fateweaver(State);
|
||||
#w{name = node} -> set_node(State);
|
||||
#w{name = make_key} -> make_key(State);
|
||||
#w{name = recover} -> recover_key(State);
|
||||
@@ -312,13 +312,15 @@ handle_event(#wx{event = #wxCommand{type = command_listbox_selected,
|
||||
State) ->
|
||||
NewState = do_selection(Selected, State),
|
||||
{noreply, NewState};
|
||||
handle_event(#wx{event = #wxKey{keyCode = Code}}, State) ->
|
||||
handle_event(#wx{event = Event = #wxKey{keyCode = Code}}, State = #s{frame = Frame}) ->
|
||||
NewState =
|
||||
case Code of
|
||||
69 -> express(State);
|
||||
70 -> doomweaver(State);
|
||||
69 -> express(State); % 'E'
|
||||
70 -> fateweaver(State); % 'F'
|
||||
_ ->
|
||||
ok = io:format("Code: ~p~n", [Code]),
|
||||
ok = tell(info, "Code: ~p", [Code]),
|
||||
ok = tell(info, "Frame ID: ~p", [wxFrame:getId(Frame)]),
|
||||
ok = tell(info, "Event: ~p", [Event]),
|
||||
State
|
||||
end,
|
||||
{noreply, NewState};
|
||||
@@ -377,10 +379,10 @@ netman(State) ->
|
||||
State.
|
||||
|
||||
|
||||
doomweaver(State = #s{accounts = []}) ->
|
||||
fateweaver(State = #s{accounts = []}) ->
|
||||
State;
|
||||
doomweaver(State) ->
|
||||
ok = gd_con:show_ui(gd_v_doomweaver),
|
||||
fateweaver(State) ->
|
||||
ok = gd_con:show_ui(gd_v_fateweaver),
|
||||
State.
|
||||
|
||||
|
||||
@@ -392,6 +394,7 @@ express(State) ->
|
||||
|
||||
|
||||
set_node(State = #s{frame = Frame, j = J}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Set Node")),
|
||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||
|
||||
@@ -443,6 +446,7 @@ set_node(State = #s{frame = Frame, j = J}) ->
|
||||
ok
|
||||
end,
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
ok = wxFrame:connect(Frame, char_hook),
|
||||
State.
|
||||
|
||||
add_node2(Address, PortCtrls) ->
|
||||
@@ -475,6 +479,7 @@ s_to_i(S) ->
|
||||
|
||||
|
||||
make_key(State = #s{frame = Frame, j = J}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("New Key")),
|
||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||
|
||||
@@ -544,10 +549,12 @@ make_key(State = #s{frame = Frame, j = J}) ->
|
||||
ok
|
||||
end,
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
ok = wxFrame:connect(Frame, char_hook),
|
||||
State.
|
||||
|
||||
|
||||
recover_key(State = #s{frame = Frame, j = J}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Mnemonic")),
|
||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||
MnemSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Recovery Phrase")}]),
|
||||
@@ -573,6 +580,7 @@ recover_key(State = #s{frame = Frame, j = J}) ->
|
||||
ok
|
||||
end,
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
ok = wxFrame:connect(Frame, char_hook),
|
||||
State.
|
||||
|
||||
|
||||
@@ -585,6 +593,7 @@ show_mnemonic(State = #s{picker = Picker}) ->
|
||||
end.
|
||||
|
||||
show_mnemonic(Selected, State = #s{frame = Frame, j = J, accounts = Accounts}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
#poa{id = ID} = lists:nth(Selected, Accounts),
|
||||
{ok, Mnemonic} = gd_con:mnemonic(ID),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Mnemonic")),
|
||||
@@ -610,6 +619,7 @@ show_mnemonic(Selected, State = #s{frame = Frame, j = J, accounts = Accounts}) -
|
||||
?wxID_OK -> gd_lib:copy_to_clipboard(Mnemonic)
|
||||
end,
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
ok = wxFrame:connect(Frame, char_hook),
|
||||
State.
|
||||
|
||||
|
||||
@@ -644,6 +654,7 @@ drop_key(State = #s{picker = Picker}) ->
|
||||
end.
|
||||
|
||||
drop_key(Selected, State = #s{frame = Frame, j = J, accounts = Accounts, prefs = Prefs}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
#poa{id = ID, name = Name} = lists:nth(Selected, Accounts),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("New Key"), [{size, {500, 150}}]),
|
||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||
@@ -672,6 +683,7 @@ drop_key(Selected, State = #s{frame = Frame, j = J, accounts = Accounts, prefs =
|
||||
Prefs
|
||||
end,
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
ok = wxFrame:connect(Frame, char_hook),
|
||||
State#s{prefs = NewPrefs}.
|
||||
|
||||
|
||||
@@ -841,6 +853,7 @@ do_chain(ChainID, #node{ip = IP}, #s{buttons = Buttons}) ->
|
||||
|
||||
|
||||
do_ask_password(#s{frame = Frame, prefs = Prefs, j = J}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Password")),
|
||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||
Label = J("Password (leave blank for no password)"),
|
||||
@@ -872,7 +885,8 @@ do_ask_password(#s{frame = Frame, prefs = Prefs, j = J}) ->
|
||||
?wxID_CANCEL ->
|
||||
gd_con:open_wallet(Path, none)
|
||||
end,
|
||||
wxDialog:destroy(Dialog).
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
wxFrame:connect(Frame, char_hook).
|
||||
|
||||
do_grids_mess_sig(_, #s{accounts = []}) ->
|
||||
ok;
|
||||
@@ -901,6 +915,7 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||
"public_id" := ID,
|
||||
"payload" := Message},
|
||||
#s{frame = Frame, j = J}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Message Signature Request")),
|
||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||
Instruction =
|
||||
@@ -936,13 +951,15 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||
?wxID_OK -> gd_con:sign_mess(Request);
|
||||
?wxID_CANCEL -> ok
|
||||
end,
|
||||
wxDialog:destroy(Dialog);
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
wxFrame:connect(Frame, char_hook);
|
||||
do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||
"type" := "binary",
|
||||
"url" := URL,
|
||||
"public_id" := ID,
|
||||
"payload" := Base64},
|
||||
#s{frame = Frame, j = J}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Binary Data Signature Request")),
|
||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||
Instruction =
|
||||
@@ -978,7 +995,8 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||
?wxID_OK -> gd_con:sign_binary(Request);
|
||||
?wxID_CANCEL -> ok
|
||||
end,
|
||||
wxDialog:destroy(Dialog);
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
wxFrame:connect(Frame, char_hook);
|
||||
do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||
"type" := "tx",
|
||||
"url" := URL,
|
||||
@@ -987,6 +1005,7 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||
"public_id" := ID,
|
||||
"payload" := CallData},
|
||||
#s{frame = Frame, j = J}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Message Signature Request")),
|
||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||
|
||||
@@ -1034,6 +1053,7 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||
?wxID_OK -> gd_con:sign_tx(Request);
|
||||
?wxID_CANCEL -> ok
|
||||
end,
|
||||
wxDialog:destroy(Dialog);
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
wxFrame:connect(Frame, char_hook);
|
||||
do_grids_mess_sig2(BadRequest, _) ->
|
||||
tell("Bad request: ~tp", [BadRequest]).
|
||||
|
||||
Reference in New Issue
Block a user