This commit is contained in:
Craig Everett 2025-01-08 14:49:22 +09:00
parent 95015eb50c
commit bfa8cc91c2
5 changed files with 26 additions and 26 deletions

View File

@ -58,9 +58,11 @@
-record(tx, -record(tx,
{id = none :: none | clutch:id(), {id = none :: none | clutch:id(),
amount = 0 :: non_neg_integer(), amount = 0 :: non_neg_integer(),
type = spend :: spend | atom()}). type = spend :: atom(),
status = submitted :: submitted | mined | rejected | failed,
meta = "" :: string()}).
-record(spend_tx, -record(spend_tx,

View File

@ -1,7 +1,5 @@
%%% @doc %%% @doc
%%% Clutch Controller %%% Clutch Controller
%%%
%%% This process is a in charge of maintaining the program's state.
%%% @end %%% @end
-module(gmc_con). -module(gmc_con).
@ -40,14 +38,15 @@
mon = none :: none | reference()}). mon = none :: none | reference()}).
-record(s, -record(s,
{version = 1 :: integer(), {version = 1 :: integer(),
window = none :: none | wx:wx_object(), window = none :: none | wx:wx_object(),
tasks = [] :: [#ui{}], tasks = [] :: [#ui{}],
picked = 0 :: non_neg_integer(), picked = 0 :: non_neg_integer(),
wallet = none :: none | #wallet{}, wallet = none :: none | #wallet{},
pass = none :: none | binary(), pass = none :: none | binary(),
prefs = #{} :: #{module() := term()}, prefs = #{} :: #{module() := term()},
wallets = [] :: [#wr{}]}). wallets = [] :: [#wr{}],
in_flight = [] :: [#tx{}]}).
-type state() :: #s{}. -type state() :: #s{}.

View File

@ -1,9 +1,5 @@
%%% @doc %%% @doc
%%% Clutch GUI %%% Clutch GUI
%%%
%%% This process is responsible for creating the main GUI frame displayed to the user.
%%%
%%% Reference: http://erlang.org/doc/man/wx_object.html
%%% @end %%% @end
-module(gmc_gui). -module(gmc_gui).

View File

@ -36,11 +36,11 @@ start_link() ->
init([]) -> init([]) ->
RestartStrategy = {one_for_one, 0, 60}, RestartStrategy = {one_for_one, 0, 60},
Clients = {gmc_con, Controller = {gmc_con,
{gmc_con, start_link, []}, {gmc_con, start_link, []},
permanent, permanent,
5000, 5000,
worker, worker,
[gmc_con]}, [gmc_con]},
Children = [Clients], Children = [Controller],
{ok, {RestartStrategy, Children}}. {ok, {RestartStrategy, Children}}.

View File

@ -282,14 +282,17 @@ terminate(Reason, State) ->
clicked(State = #s{book = {Notebook, Pages}}, Name, Button) -> clicked(State = #s{book = {Notebook, Pages}}, Name, Button) ->
case wxNotebook:getSelection(Notebook) of case wxNotebook:getSelection(Notebook) of
?wxNOT_FOUND -> ?wxNOT_FOUND ->
ok = tell("Inconcievable! No notebook page is selected!"), ok = tell(warning, "Inconcievable! No notebook page is selected!"),
State; State;
Index -> Index ->
Page = lists:nth(Index + 1, Pages), Page = lists:nth(Index + 1, Pages),
clicked(State, Page, Name, Button) clicked(State, Page, Name, Button)
end. end.
clicked(State, #p{instances = Is, funs = {_, Funs}, builds = Builds}, {<<"init">>, call}) -> clicked(State,
#p{instances = Is, funs = {_, Funs}, builds = Builds},
{<<"init">>, call},
Button) ->
Label = wxChoice:getStringSelection(Is), Label = wxChoice:getStringSelection(Is),
Build = maps:get(Label, Builds), Build = maps:get(Label, Builds),
#f{args = Args} = lists:keyfind(<<"init">>, #f.name, Funs), #f{args = Args} = lists:keyfind(<<"init">>, #f.name, Funs),