Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c6486408cb |
+1
-2
@@ -6,6 +6,5 @@
|
|||||||
{vsn,"0.9.0"},
|
{vsn,"0.9.0"},
|
||||||
{modules,[gajudesk,gd_con,gd_grids,gd_gui,gd_jt,gd_lib,
|
{modules,[gajudesk,gd_con,gd_grids,gd_gui,gd_jt,gd_lib,
|
||||||
gd_m_spend,gd_m_wallet_importer,gd_sophia_editor,
|
gd_m_spend,gd_m_wallet_importer,gd_sophia_editor,
|
||||||
gd_sup,gd_v,gd_v_call,gd_v_devman,gd_v_netman,
|
gd_sup,gd_v,gd_v_devman,gd_v_netman,gd_v_wallman]},
|
||||||
gd_v_wallman]},
|
|
||||||
{mod,{gajudesk,[]}}]}.
|
{mod,{gajudesk,[]}}]}.
|
||||||
|
|||||||
+11
-14
@@ -54,8 +54,7 @@
|
|||||||
-type state() :: #s{}.
|
-type state() :: #s{}.
|
||||||
-type ui_name() :: gd_v_netman
|
-type ui_name() :: gd_v_netman
|
||||||
| gd_v_wallman
|
| gd_v_wallman
|
||||||
| gd_v_doomweaver
|
| gd_v_devman.
|
||||||
| gd_v_express.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -243,8 +242,8 @@ open_contract(ConID) ->
|
|||||||
when ConID :: string(),
|
when ConID :: string(),
|
||||||
DevmanToFront :: boolean().
|
DevmanToFront :: boolean().
|
||||||
%% @doc
|
%% @doc
|
||||||
%% Ask the controller to tell the doomweaver interface to open a deployed contract.
|
%% Ask the controller to tell the devman interface to open a deployed contract.
|
||||||
%% The controller will start the doomweaver if it isn't already on.
|
%% The controller will start the devman if it isn't already on.
|
||||||
|
|
||||||
open_contract(ConID, DevmanToFront) when is_binary(ConID) ->
|
open_contract(ConID, DevmanToFront) when is_binary(ConID) ->
|
||||||
gen_server:cast(?MODULE, {open_contract, ConID, DevmanToFront});
|
gen_server:cast(?MODULE, {open_contract, ConID, DevmanToFront});
|
||||||
@@ -267,9 +266,9 @@ show_call(ConID, Info) ->
|
|||||||
Info :: map(),
|
Info :: map(),
|
||||||
DevmanToFront :: boolean().
|
DevmanToFront :: boolean().
|
||||||
%% @doc
|
%% @doc
|
||||||
%% Ask the controller to tell the doomweaver interface to dislpay the result of a call
|
%% Ask the controller to tell the devman interface to dislpay the result of a call
|
||||||
%% to the indicated contract. Opens the contract in question if it isn't alread open.
|
%% to the indicated contract. Opens the contract in question if it isn't alread open.
|
||||||
%% Starts the doomweaver if it isn't already running.
|
%% Starts the devman if it isn't already running.
|
||||||
|
|
||||||
show_call(ConID, Info, DevmanToFront) when is_binary(ConID) ->
|
show_call(ConID, Info, DevmanToFront) when is_binary(ConID) ->
|
||||||
gen_server:cast(?MODULE, {show_call, ConID, Info, DevmanToFront});
|
gen_server:cast(?MODULE, {show_call, ConID, Info, DevmanToFront});
|
||||||
@@ -660,9 +659,7 @@ task_data(gd_v_netman, #s{wallet = none}) ->
|
|||||||
[];
|
[];
|
||||||
task_data(gd_v_wallman, #s{wallets = Wallets}) ->
|
task_data(gd_v_wallman, #s{wallets = Wallets}) ->
|
||||||
Wallets;
|
Wallets;
|
||||||
task_data(gd_v_doomweaver, #s{}) ->
|
task_data(gd_v_devman, #s{}) ->
|
||||||
[];
|
|
||||||
task_data(gd_v_express, #s{}) ->
|
|
||||||
[].
|
[].
|
||||||
|
|
||||||
|
|
||||||
@@ -1066,15 +1063,15 @@ do_drop_key(ID, State = #s{wallet = W, wallets = Wallets, pass = Pass}) ->
|
|||||||
|
|
||||||
|
|
||||||
do_open_contract(ConID, ToFront, State) ->
|
do_open_contract(ConID, ToFront, State) ->
|
||||||
NewState = do_show_ui(gd_v_doomweaver, ToFront, State),
|
NewState = do_show_ui(gd_v_devman, ToFront, State),
|
||||||
ok = gd_v_doomweaver:open_contract(ConID),
|
ok = gd_v_devman:open_contract(ConID),
|
||||||
NewState.
|
NewState.
|
||||||
|
|
||||||
|
|
||||||
do_show_call(ConID, Info, ToFront, State) ->
|
do_show_call(ConID, Info, ToFront, State) ->
|
||||||
NewState = do_show_ui(gd_v_doomweaver, ToFront, State),
|
NewState = do_show_ui(gd_v_devman, ToFront, State),
|
||||||
ok = gd_v_doomweaver:open_contract(ConID),
|
ok = gd_v_devman:open_contract(ConID),
|
||||||
ok = gd_v_doomweaver:call_result(ConID, Info),
|
ok = gd_v_devman:call_result(ConID, Info),
|
||||||
NewState.
|
NewState.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-19
@@ -19,6 +19,7 @@
|
|||||||
-include("gd.hrl").
|
-include("gd.hrl").
|
||||||
-include("gdl.hrl").
|
-include("gdl.hrl").
|
||||||
|
|
||||||
|
|
||||||
-record(h,
|
-record(h,
|
||||||
{win = none :: none | wx:wx_object(),
|
{win = none :: none | wx:wx_object(),
|
||||||
sz = none :: none | wx:wx_object()}).
|
sz = none :: none | wx:wx_object()}).
|
||||||
@@ -203,7 +204,6 @@ init(Prefs) ->
|
|||||||
ok = gd_v:safe_size(Frame, Prefs),
|
ok = gd_v:safe_size(Frame, Prefs),
|
||||||
|
|
||||||
ok = wxFrame:connect(Frame, command_button_clicked),
|
ok = wxFrame:connect(Frame, command_button_clicked),
|
||||||
ok = wxFrame:connect(Frame, char_hook),
|
|
||||||
ok = wxFrame:connect(Frame, close_window),
|
ok = wxFrame:connect(Frame, close_window),
|
||||||
true = wxFrame:show(Frame),
|
true = wxFrame:show(Frame),
|
||||||
ok = wxListBox:connect(Picker, command_listbox_selected),
|
ok = wxListBox:connect(Picker, command_listbox_selected),
|
||||||
@@ -291,7 +291,7 @@ handle_event(#wx{event = #wxCommand{type = command_button_clicked},
|
|||||||
case lists:keyfind(ID, #w.id, Buttons) of
|
case lists:keyfind(ID, #w.id, Buttons) of
|
||||||
#w{name = wallet} -> wallman(State);
|
#w{name = wallet} -> wallman(State);
|
||||||
#w{name = chain} -> netman(State);
|
#w{name = chain} -> netman(State);
|
||||||
#w{name = dev} -> doomweaver(State);
|
#w{name = dev} -> devman(State);
|
||||||
#w{name = node} -> set_node(State);
|
#w{name = node} -> set_node(State);
|
||||||
#w{name = make_key} -> make_key(State);
|
#w{name = make_key} -> make_key(State);
|
||||||
#w{name = recover} -> recover_key(State);
|
#w{name = recover} -> recover_key(State);
|
||||||
@@ -312,16 +312,6 @@ handle_event(#wx{event = #wxCommand{type = command_listbox_selected,
|
|||||||
State) ->
|
State) ->
|
||||||
NewState = do_selection(Selected, State),
|
NewState = do_selection(Selected, State),
|
||||||
{noreply, NewState};
|
{noreply, NewState};
|
||||||
handle_event(#wx{event = #wxKey{keyCode = Code}}, State) ->
|
|
||||||
NewState =
|
|
||||||
case Code of
|
|
||||||
69 -> express(State);
|
|
||||||
70 -> doomweaver(State);
|
|
||||||
_ ->
|
|
||||||
ok = io:format("Code: ~p", [Code]),
|
|
||||||
State
|
|
||||||
end,
|
|
||||||
{noreply, NewState};
|
|
||||||
handle_event(#wx{event = #wxClose{}}, State = #s{frame = Frame, prefs = Prefs}) ->
|
handle_event(#wx{event = #wxClose{}}, State = #s{frame = Frame, prefs = Prefs}) ->
|
||||||
Geometry =
|
Geometry =
|
||||||
case wxTopLevelWindow:isMaximized(Frame) of
|
case wxTopLevelWindow:isMaximized(Frame) of
|
||||||
@@ -377,13 +367,8 @@ netman(State) ->
|
|||||||
State.
|
State.
|
||||||
|
|
||||||
|
|
||||||
doomweaver(State) ->
|
devman(State) ->
|
||||||
ok = gd_con:show_ui(gd_v_doomweaver),
|
ok = gd_con:show_ui(gd_v_devman),
|
||||||
State.
|
|
||||||
|
|
||||||
|
|
||||||
express(State) ->
|
|
||||||
ok = io:format("GajuExpress~n"),
|
|
||||||
State.
|
State.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -216,7 +216,12 @@ return_sizer(Parent, J, FunIlk, ReturnType) ->
|
|||||||
|
|
||||||
|
|
||||||
call_param_sizer(Frame, J) ->
|
call_param_sizer(Frame, J) ->
|
||||||
{ok, Height} = hz:top_height(),
|
case hz:top_height() of
|
||||||
|
{ok, Height} -> call_param_sizer(Frame, J, Height);
|
||||||
|
Error -> handle_troubling(State, Error)
|
||||||
|
end.
|
||||||
|
|
||||||
|
call_param_sizer(Frame, J, Height) ->
|
||||||
DefTTL = Height + 10000,
|
DefTTL = Height + 10000,
|
||||||
DefGasP = hz:min_gas_price(),
|
DefGasP = hz:min_gas_price(),
|
||||||
DefGas = 5000000,
|
DefGas = 5000000,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
-module(gd_v_doomweaver).
|
-module(gd_v_devman).
|
||||||
-vsn("0.9.0").
|
-vsn("0.9.0").
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
@@ -1,352 +0,0 @@
|
|||||||
%%% @doc
|
|
||||||
%%% The GajuExpress
|
|
||||||
% 0. User opens GajuDesk and selects the key (very top widget)
|
|
||||||
%
|
|
||||||
% Sending...
|
|
||||||
%
|
|
||||||
% 1. The user inputs the public key/ID of the party the data should be sent to
|
|
||||||
% 2. The user picks the file or directory to send
|
|
||||||
% 3. The user decides whether to sign the package or be anonymous
|
|
||||||
% 4. The user sets the package's TTL
|
|
||||||
% 5. GajuDesk packs up and compresses the bundle.
|
|
||||||
% 6. GajuDesk asks GajuExpress for a quote based on size/time
|
|
||||||
% 7. The price is shown
|
|
||||||
% 8. The user agrees or aborts
|
|
||||||
% 9. If the user agrees, a payment window opens and they send a payment to GajuExpress
|
|
||||||
% 10. GajuDesk polls until the payment is included or the user gives up
|
|
||||||
% 11. Once GajuExpress verifies the payment, the upload begins
|
|
||||||
% 12. Progress bar
|
|
||||||
%
|
|
||||||
%
|
|
||||||
% Receiving...
|
|
||||||
%
|
|
||||||
% 1. User clicks "check for deliveries"
|
|
||||||
% 2. GajuExpress issues an ID signature challenge
|
|
||||||
% 3. GajuDesk asks GajuExpress whether there are any packages waiting for Key
|
|
||||||
% 4. If yes, then the pending deliveries are shown in the delivery panel
|
|
||||||
% 5. The user selects + clicks open (or double clicks) a package
|
|
||||||
% 6. User selects where to unpack it in a file dialog
|
|
||||||
% 7. GajuDesk downloads the package from GajuExpress
|
|
||||||
% 8. Progress bar
|
|
||||||
% 9. File is decrypted and optionally signature verified
|
|
||||||
% 10. GajuExpress deletes their copy of the file
|
|
||||||
%%% @end
|
|
||||||
|
|
||||||
|
|
||||||
-module(gd_v_express).
|
|
||||||
-vsn("0.9.0").
|
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
|
||||||
-license("GPL-3.0-or-later").
|
|
||||||
|
|
||||||
-behavior(wx_object).
|
|
||||||
%-behavior(gd_v).
|
|
||||||
-include_lib("wx/include/wx.hrl").
|
|
||||||
-export([to_front/0, to_front/1, trouble/1]).
|
|
||||||
-export([pending/1, accounts/1]).
|
|
||||||
-export([start_link/1]).
|
|
||||||
-export([init/1, terminate/2, code_change/3,
|
|
||||||
handle_call/3, handle_cast/2, handle_info/2, handle_event/2]).
|
|
||||||
-include("$zx_include/zx_logger.hrl").
|
|
||||||
-include("gd.hrl").
|
|
||||||
-include("gdl.hrl").
|
|
||||||
|
|
||||||
|
|
||||||
-record(s,
|
|
||||||
{wx = none :: none | wx:wx_object(),
|
|
||||||
frame = none :: none | wx:wx_object(),
|
|
||||||
lang = en :: en | jp,
|
|
||||||
j = none :: none | fun(),
|
|
||||||
prefs = #{} :: map(),
|
|
||||||
keys = #w{} :: #w{},
|
|
||||||
accs = [] :: [#wr{}],
|
|
||||||
check = #w{} :: #w{},
|
|
||||||
list = #w{} :: #w{},
|
|
||||||
dl = #w{} :: #w{},
|
|
||||||
dest = none :: none | wx:wx_object(),
|
|
||||||
ttl = none :: none | wx:wx_object(),
|
|
||||||
path = none :: none | wx:wx_object(),
|
|
||||||
sign = none :: none | wx:wx_object(),
|
|
||||||
size = none :: none | wx:wx_object(),
|
|
||||||
cost = none :: none | wx:wx_object(),
|
|
||||||
ul = none :: none | wx:wx_object()}).
|
|
||||||
|
|
||||||
-record(mochila,
|
|
||||||
{tar = <<>> :: binary(),
|
|
||||||
sig = none :: none | {Key :: binary(), Sig :: binary()}}).
|
|
||||||
|
|
||||||
|
|
||||||
%%% Interface
|
|
||||||
|
|
||||||
-spec to_front() -> ok.
|
|
||||||
|
|
||||||
to_front() ->
|
|
||||||
wx_object:cast(?MODULE, to_front).
|
|
||||||
|
|
||||||
|
|
||||||
-spec to_front(Win) -> ok
|
|
||||||
when Win :: wx:wx_object().
|
|
||||||
|
|
||||||
to_front(Win) ->
|
|
||||||
wx_object:cast(Win, to_front).
|
|
||||||
|
|
||||||
|
|
||||||
-spec trouble(Info) -> ok
|
|
||||||
when Info :: term().
|
|
||||||
|
|
||||||
trouble(Info) ->
|
|
||||||
wx_object:cast(?MODULE, {trouble, Info}).
|
|
||||||
|
|
||||||
|
|
||||||
-spec pending(Manifest) -> ok
|
|
||||||
when Manifest :: [Transfer],
|
|
||||||
Transfer :: {Name :: string(), Size :: pos_integer()}.
|
|
||||||
|
|
||||||
pending(Manifest) ->
|
|
||||||
wx_object:cast(?MODULE, {pending, Manifest}).
|
|
||||||
|
|
||||||
|
|
||||||
-spec accounts(Manifest) -> ok
|
|
||||||
when Manifest :: [#wr{}].
|
|
||||||
|
|
||||||
accounts(Manifest) ->
|
|
||||||
wx_object:cast(?MODULE, {accounts, Manifest}).
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%%% Startup
|
|
||||||
|
|
||||||
start_link(Args) ->
|
|
||||||
wx_object:start_link({local, ?MODULE}, ?MODULE, Args, []).
|
|
||||||
|
|
||||||
init({Prefs, Selected, Keys}) ->
|
|
||||||
Lang = maps:get(lang, Prefs, en),
|
|
||||||
Trans = gd_jt:read_translations(?MODULE),
|
|
||||||
J = gd_jt:j(Lang, Trans),
|
|
||||||
Wx = wx:new(),
|
|
||||||
Frame = wxFrame:new(Wx, ?wxID_ANY, J("GajuExpress")),
|
|
||||||
Panel = wxWindow:new(Frame, ?wxID_ANY),
|
|
||||||
TopSz = wxBoxSizer:new(?wxVERTICAL),
|
|
||||||
_ = wxBoxSizer:add(TopSz, Panel, zxw:flags(wide)),
|
|
||||||
MainSz = wxBoxSizer:new(?wxVERTICAL),
|
|
||||||
LR_Sz = wxBoxSizer:new(?wxHORIZONTAL),
|
|
||||||
|
|
||||||
KeyP = wxChoice:new(Panel, ?wxID_ANY, [{choices, Keys}]),
|
|
||||||
KP = #w{name = key_picker, id = wxChoice:getId(KeyP), wx = KeyP},
|
|
||||||
ZeroBasedSelected = Selected - 1,
|
|
||||||
ok = wxChoice:setSelection(KeyP, ZeroBasedSelected),
|
|
||||||
_ = wxStaticBoxSizer:add(MainSz, KeyP, zxw:flags({base, 5})),
|
|
||||||
|
|
||||||
DownloadSz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, J("Downloads")}]),
|
|
||||||
DownloadBox = wxStaticBoxSizer:getStaticBox(DownloadSz),
|
|
||||||
CheckB = #w{wx = CheckW} = make_button(DownloadBox, check, J("Check for Downloads")),
|
|
||||||
DownloadP = wxListBox:new(DownloadBox, ?wxID_ANY, [{style, ?wxLC_SINGLE_SEL}]),
|
|
||||||
DL_L = #w{name = list, id = wxListBox:getId(DownloadP), wx = DownloadP},
|
|
||||||
DownloadB = #w{wx = DownloadW} = make_button(DownloadBox, dl, J("Download")),
|
|
||||||
_ = wxButton:disable(DownloadW),
|
|
||||||
_ = wxBoxSizer:add(DownloadSz, CheckW, zxw:flags({base, 5})),
|
|
||||||
_ = wxBoxSizer:add(DownloadSz, DownloadP, zxw:flags({wide, 5})),
|
|
||||||
_ = wxBoxSizer:add(DownloadSz, DownloadW, zxw:flags({base, 5})),
|
|
||||||
|
|
||||||
UploadSz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, J("Uploads")}]),
|
|
||||||
UploadBox = wxStaticBoxSizer:getStaticBox(UploadSz),
|
|
||||||
DestSz = wxStaticBoxSizer:new(?wxHORIZONTAL, UploadBox, [{label, J("Destination ID")}]),
|
|
||||||
DestBox = wxStaticBoxSizer:getStaticBox(DestSz),
|
|
||||||
DestT = wxTextCtrl:new(DestBox, ?wxID_ANY),
|
|
||||||
_ = wxStaticBoxSizer:add(DestSz, DestT),
|
|
||||||
TTL_Sz = wxStaticBoxSizer:new(?wxHORIZONTAL, UploadBox, [{label, J("Transfer Expiration (Days)")}]),
|
|
||||||
TTL_Box = wxStaticBoxSizer:getStaticBox(TTL_Sz),
|
|
||||||
TTL_T = wxTextCtrl:new(TTL_Box, ?wxID_ANY, [{value, "7"}]),
|
|
||||||
_ = wxStaticBoxSizer:add(TTL_Sz, TTL_T),
|
|
||||||
PathSz = wxStaticBoxSizer:new(?wxHORIZONTAL, UploadBox, [{label, J("File or Directory")}]),
|
|
||||||
PathBox = wxStaticBoxSizer:getStaticBox(PathSz),
|
|
||||||
PathP = wxFilePickerCtrl:new(PathBox, ?wxID_ANY),
|
|
||||||
_ = wxStaticBoxSizer:add(PathSz, PathP),
|
|
||||||
SignSz = wxStaticBoxSizer:new(?wxHORIZONTAL, UploadBox, [{label, J("Transfer Signature")}]),
|
|
||||||
SignBox = wxStaticBoxSizer:getStaticBox(SignSz),
|
|
||||||
SignC = wxCheckBox:new(SignBox, ?wxID_ANY, J("Do you want to sign this transfer?")),
|
|
||||||
_ = wxStaticBoxSizer:add(SignSz, SignC),
|
|
||||||
SizeSz = wxStaticBoxSizer:new(?wxHORIZONTAL, UploadBox, [{label, J("Transfer Details")}]),
|
|
||||||
SizeBox = wxStaticBoxSizer:getStaticBox(SizeSz),
|
|
||||||
SizeT = wxStaticText:new(SizeBox, ?wxID_ANY, J("[No File or Directory Selected]")),
|
|
||||||
_ = wxStaticBoxSizer:add(SizeSz, SizeT),
|
|
||||||
CostSz = wxStaticBoxSizer:new(?wxHORIZONTAL, UploadBox, [{label, J("Cost to Transfer")}]),
|
|
||||||
CostBox = wxStaticBoxSizer:getStaticBox(CostSz),
|
|
||||||
CostT = wxStaticText:new(CostBox, ?wxID_ANY, "[N/A]"),
|
|
||||||
_ = wxStaticBoxSizer:add(CostSz, CostT),
|
|
||||||
UploadB = #w{wx = UploadW} = make_button(UploadBox, ul, J("Upload")),
|
|
||||||
_ = wxButton:disable(UploadW),
|
|
||||||
_ = wxStaticBoxSizer:add(UploadSz, UploadW),
|
|
||||||
|
|
||||||
_ = wxBoxSizer:add(MainSz, DownloadSz, zxw:flags({wide, 5})),
|
|
||||||
_ = wxBoxSizer:add(MainSz, UploadSz, zxw:flags({wide, 5})),
|
|
||||||
ok = wxPanel:setSizer(Panel, MainSz),
|
|
||||||
ok = wxFrame:setSizer(Frame, TopSz),
|
|
||||||
ok = wxSizer:layout(TopSz),
|
|
||||||
|
|
||||||
NewPrefs =
|
|
||||||
case maps:is_key(geometry, Prefs) of
|
|
||||||
true ->
|
|
||||||
Prefs;
|
|
||||||
false ->
|
|
||||||
Display = wxDisplay:new(),
|
|
||||||
{_, _, W, H} = wxDisplay:getGeometry(Display),
|
|
||||||
ok = wxDisplay:destroy(Display),
|
|
||||||
WW = 500,
|
|
||||||
WH = 350,
|
|
||||||
X = (W div 2) - (WW div 2),
|
|
||||||
Y = (H div 2) - (WH div 2),
|
|
||||||
Prefs#{geometry => {X, Y, WW, WH}}
|
|
||||||
end,
|
|
||||||
ok = gd_v:safe_size(Frame, NewPrefs),
|
|
||||||
|
|
||||||
ok = wxFrame:connect(Frame, command_button_clicked),
|
|
||||||
ok = wxFrame:connect(Frame, close_window),
|
|
||||||
ok = wxListBox:connect(DownloadP, command_listbox_doubleclicked),
|
|
||||||
State = #s{wx = Wx, frame = Frame, lang = Lang, j = J, prefs = Prefs,
|
|
||||||
keys = KeyP, accs = Keys,
|
|
||||||
check = CheckB, list = DL_L,
|
|
||||||
dl = DownloadB,
|
|
||||||
dest = DestT, ttl = TTL_T, path = PathP, sign = SignC,
|
|
||||||
size = SizeT, cost = CostT,
|
|
||||||
ul = UploadB},
|
|
||||||
{Frame, State}.
|
|
||||||
|
|
||||||
make_button(Parent, Name, Label) ->
|
|
||||||
B = wxButton:new(Parent, ?wxID_ANY, [{label, Label}]),
|
|
||||||
#w{name = Name, id = wxButton:getId(B), wx = B}.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%%% wx_object
|
|
||||||
|
|
||||||
handle_call(Unexpected, From, State) ->
|
|
||||||
ok = log(warning, "Unexpected call from ~tp: ~tp~n", [From, Unexpected]),
|
|
||||||
{noreply, State}.
|
|
||||||
|
|
||||||
handle_cast({pending, Manifest}, State) ->
|
|
||||||
NewState = do_pending(Manifest, State),
|
|
||||||
{noreply, NewState};
|
|
||||||
handle_cast({accounts, Manifest}, State) ->
|
|
||||||
NewState = do_accounts(Manifest, State),
|
|
||||||
{noreply, NewState};
|
|
||||||
handle_cast(to_front, State = #s{frame = Frame}) ->
|
|
||||||
ok = ensure_shown(Frame),
|
|
||||||
ok = wxFrame:raise(Frame),
|
|
||||||
{noreply, State};
|
|
||||||
handle_cast({trouble, Info}, State) ->
|
|
||||||
ok = handle_troubling(State, Info),
|
|
||||||
{noreply, State};
|
|
||||||
handle_cast(Unexpected, State) ->
|
|
||||||
ok = log(warning, "Unexpected cast: ~tp~n", [Unexpected]),
|
|
||||||
{noreply, State}.
|
|
||||||
|
|
||||||
|
|
||||||
handle_info(Unexpected, State) ->
|
|
||||||
ok = log(warning, "Unexpected info: ~tp~n", [Unexpected]),
|
|
||||||
{noreply, State}.
|
|
||||||
|
|
||||||
|
|
||||||
handle_event(#wx{event = #wxCommand{type = command_button_clicked}, id = ID},
|
|
||||||
State = #s{check = #w{id = ID}}) ->
|
|
||||||
NewState = do_check(State),
|
|
||||||
{noreply, NewState};
|
|
||||||
handle_event(#wx{event = #wxCommand{type = command_button_clicked}, id = ID},
|
|
||||||
State = #s{dl = #w{id = ID}}) ->
|
|
||||||
NewState = do_dl(State),
|
|
||||||
{noreply, NewState};
|
|
||||||
handle_event(#wx{event = #wxCommand{type = command_button_clicked}, id = ID},
|
|
||||||
State = #s{ul = #w{id = ID}}) ->
|
|
||||||
NewState = do_ul(State),
|
|
||||||
{noreply, NewState};
|
|
||||||
handle_event(#wx{event = #wxCommand{type = command_listbox_doubleclicked,
|
|
||||||
commandInt = Selected}},
|
|
||||||
State) ->
|
|
||||||
NewState = do_dl(State),
|
|
||||||
{noreply, State};
|
|
||||||
handle_event(#wx{event = #wxClose{}}, State) ->
|
|
||||||
ok = do_close(State),
|
|
||||||
{noreply, State};
|
|
||||||
handle_event(Event, State) ->
|
|
||||||
ok = tell(info, "Unexpected event ~tp State: ~tp~n", [Event, State]),
|
|
||||||
{noreply, State}.
|
|
||||||
|
|
||||||
handle_troubling(#s{frame = Frame}, Info) ->
|
|
||||||
zxw:show_message(Frame, Info).
|
|
||||||
|
|
||||||
|
|
||||||
code_change(_, State, _) ->
|
|
||||||
{ok, State}.
|
|
||||||
|
|
||||||
|
|
||||||
terminate(wx_deleted, _) ->
|
|
||||||
wx:destroy();
|
|
||||||
terminate(Reason, State) ->
|
|
||||||
ok = log(info, "Reason: ~tp, State: ~tp", [Reason, State]),
|
|
||||||
wx:destroy().
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%%% doers
|
|
||||||
|
|
||||||
do_show(Manifest, State = #s{keys = KeyP}) ->
|
|
||||||
Names = [Name || #wr{name = Name} <- Manifest],
|
|
||||||
ok = wxListBox:set(KeyP, Names),
|
|
||||||
State#s{accs = Manifest}.
|
|
||||||
|
|
||||||
|
|
||||||
do_pending(State, Manifest) ->
|
|
||||||
ok = tell(info, "Would do_pending: ~p", [Manifest]),
|
|
||||||
State.
|
|
||||||
|
|
||||||
|
|
||||||
do_accounts(State, Manifest) ->
|
|
||||||
ok = tell(info, "Would do_pending: ~p", [Manifest]),
|
|
||||||
State.
|
|
||||||
|
|
||||||
|
|
||||||
do_check(State) ->
|
|
||||||
ok = tell(info, "Would do_check."),
|
|
||||||
State.
|
|
||||||
|
|
||||||
|
|
||||||
do_dl(State) ->
|
|
||||||
ok = tell(info, "Would do_dl."),
|
|
||||||
State.
|
|
||||||
|
|
||||||
|
|
||||||
do_ul(State) ->
|
|
||||||
ok = tell(info, "Would do_ul."),
|
|
||||||
State.
|
|
||||||
|
|
||||||
|
|
||||||
do_close(#s{frame = Frame, prefs = Prefs}) ->
|
|
||||||
Geometry =
|
|
||||||
case wxTopLevelWindow:isMaximized(Frame) of
|
|
||||||
true ->
|
|
||||||
max;
|
|
||||||
false ->
|
|
||||||
{X, Y} = wxWindow:getPosition(Frame),
|
|
||||||
{W, H} = wxWindow:getSize(Frame),
|
|
||||||
{X, Y, W, H}
|
|
||||||
end,
|
|
||||||
NewPrefs = maps:put(geometry, Geometry, Prefs),
|
|
||||||
ok = gd_con:save(?MODULE, NewPrefs),
|
|
||||||
ok = wxWindow:destroy(Frame).
|
|
||||||
|
|
||||||
|
|
||||||
default_name() ->
|
|
||||||
{{YY, MM, DD}, {Hr, Mn, Sc}} = calendar:local_time(),
|
|
||||||
Form = "~4.10.0B-~2.10.0B-~2.10.0B_~2.10.0B-~2.10.0B-~2.10.0B",
|
|
||||||
Name = io_lib:format(Form, [YY, MM, DD, Hr, Mn, Sc]),
|
|
||||||
unicode:characters_to_list(Name ++ ".gaju").
|
|
||||||
|
|
||||||
|
|
||||||
ensure_shown(Frame) ->
|
|
||||||
case wxWindow:isShown(Frame) of
|
|
||||||
true ->
|
|
||||||
ok;
|
|
||||||
false ->
|
|
||||||
true = wxFrame:show(Frame),
|
|
||||||
ok
|
|
||||||
end.
|
|
||||||
Reference in New Issue
Block a user