diff options
author | Dan Gudmundsson <[email protected]> | 2017-03-27 17:03:52 +0200 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2017-03-28 15:49:22 +0200 |
commit | 1f205a59ab61f159920b41d5f17f207299cb7a8c (patch) | |
tree | a25bcbf192d11b77c87d4329c353e6956c089fdd /lib/observer/src/observer_sys_wx.erl | |
parent | 398a47ccf8dc25cdf1bc40a9df1f20e31145ac9d (diff) | |
download | otp-1f205a59ab61f159920b41d5f17f207299cb7a8c.tar.gz otp-1f205a59ab61f159920b41d5f17f207299cb7a8c.tar.bz2 otp-1f205a59ab61f159920b41d5f17f207299cb7a8c.zip |
observer: (re)store config
Store config when exiting app and restore config when starting again.
Diffstat (limited to 'lib/observer/src/observer_sys_wx.erl')
-rw-r--r-- | lib/observer/src/observer_sys_wx.erl | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/observer/src/observer_sys_wx.erl b/lib/observer/src/observer_sys_wx.erl index fa824995f7..2529e79e20 100644 --- a/lib/observer/src/observer_sys_wx.erl +++ b/lib/observer/src/observer_sys_wx.erl @@ -20,7 +20,7 @@ -behaviour(wx_object). --export([start_link/2]). +-export([start_link/3]). %% wx_object callbacks -export([init/1, handle_info/2, terminate/2, code_change/3, handle_call/3, handle_event/2, handle_cast/2]). @@ -41,12 +41,12 @@ fields, timer}). -start_link(Notebook, Parent) -> - wx_object:start_link(?MODULE, [Notebook, Parent], []). +start_link(Notebook, Parent, Config) -> + wx_object:start_link(?MODULE, [Notebook, Parent, Config], []). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -init([Notebook, Parent]) -> +init([Notebook, Parent, Config]) -> SysInfo = observer_backend:sys_info(), {Sys, Mem, Cpu, Stats} = info_fields(), Panel = wxPanel:new(Notebook), @@ -69,7 +69,7 @@ init([Notebook, Parent]) -> wxSizer:add(Sizer, HSizer1, [{flag, ?wxEXPAND bor BorderFlags bor ?wxBOTTOM}, {proportion, 0}, {border, 5}]), wxPanel:setSizer(Panel, Sizer), - Timer = observer_lib:start_timer(10), + Timer = observer_lib:start_timer(Config, 10), {Panel, #sys_wx_state{parent=Parent, parent_notebook=Notebook, panel=Panel, sizer=Sizer, @@ -167,6 +167,9 @@ terminate(_Reason, _State) -> code_change(_, _, State) -> {ok, State}. +handle_call(get_config, _, #sys_wx_state{timer=Timer}=State) -> + {reply, observer_lib:timer_config(Timer), State}; + handle_call(Msg, _From, State) -> io:format("~p~p: Unhandled Call ~p~n",[?MODULE, ?LINE, Msg]), {reply, ok, State}. |