Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

whitespace

  • Loading branch information...
commit 19ddfd5b31977e704f7c9d6ee5fcfe5dfdfd9b97 1 parent 8a622cf
mats cronqvist authored
View
18 priv/examples/hello/hello.erl
@@ -1,7 +1,7 @@
%%%-------------------------------------------------------------------
%%% File : hello.erl
%%% Author : Mats Cronqvist <locmacr@mwlx084>
-%%% Description :
+%%% Description :
%%%
%%% Created : 27 Nov 2006 by Mats Cronqvist <locmacr@mwlx084>
%%%-------------------------------------------------------------------
@@ -13,20 +13,20 @@
start() ->
gtknode:start(hello),
- Win = ?G('Gtk_window_new',['GTK_WINDOW_TOPLEVEL']),
- But = ?G('Gtk_button_new_with_label',["butt"]),
- ?G('Gtk_container_add',[Win,But]),
- ?G('Gtk_widget_show',[Win]),
- ?G('Gtk_widget_show',[But]),
+ Win = ?G('Gtk_window_new',['GTK_WINDOW_TOPLEVEL']),
+ But = ?G('Gtk_button_new_with_label',["butt"]),
+ ?G('Gtk_container_add',[Win,But]),
+ ?G('Gtk_widget_show',[Win]),
+ ?G('Gtk_widget_show',[But]),
?G('GN_signal_connect',[But,clicked]),
?G('GN_signal_connect',[Win,destroy]),
loop(Win,But).
loop(Win,But) ->
- receive
- {hello,{signal,{But,clicked}}} ->
+ receive
+ {hello,{signal,{But,clicked}}} ->
io:fwrite("~p~n",[clicked]),
loop(Win,But);
- {hello,{signal,{Win,destroy}}} ->
+ {hello,{signal,{Win,destroy}}} ->
gtknode:stop(hello)
end.
View
16 priv/examples/hello_world/hello_world.erl
@@ -9,14 +9,14 @@
-export([start/0,stop/0]).
-import(filename,[dirname/1,join/1]).
-start() ->
+start() ->
case whereis(?MODULE) of
- undefined -> spawn(fun init/0);
- _ -> already_started
+ undefined -> spawn(fun init/0);
+ _ -> already_started
end.
stop() -> ?MODULE ! quit.
-
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
init() ->
gtknode:start(?MODULE),
@@ -26,11 +26,11 @@ init() ->
loop() ->
receive
- {?MODULE,{signal,{button_ok,clicked}}} -> change_text(),loop();
+ {?MODULE,{signal,{button_ok,clicked}}} -> change_text(),loop();
{?MODULE,{signal,{button_quit,'clicked'}}} -> quit();
- {?MODULE,{signal,{window,'delete-event'}}} -> quit();
- quit -> quit();
- X -> io:fwrite("got ~p~n",[X]),loop()
+ {?MODULE,{signal,{window,'delete-event'}}} -> quit();
+ quit -> quit();
+ X -> io:fwrite("got ~p~n",[X]),loop()
end.
change_text() ->
View
30 priv/examples/points/points.erl
@@ -1,7 +1,7 @@
%%%-------------------------------------------------------------------
%%% File : points.erl
%%% Author : Mats Cronqvist <locmacr@mwlx084>
-%%% Description :
+%%% Description :
%%%
%%% Created : 30 Aug 2005 by Mats Cronqvist <locmacr@mwlx084>
%%%-------------------------------------------------------------------
@@ -14,14 +14,14 @@
-define(SIZE,300).
-record(ld, {name,win,gc,pixmap}).
-start() ->
+start() ->
case whereis(?MODULE) of
- undefined -> spawn(fun init/0);
- _ -> already_started
+ undefined -> spawn(fun init/0);
+ _ -> already_started
end.
stop() -> ?MODULE ! quit.
-
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
init() ->
gtknode:start(?MODULE),
@@ -31,14 +31,14 @@ init() ->
loop(LD) ->
receive
- {?MODULE,{signal,{drawingarea,'expose-event'}}}->loop(redraw(LD));
- {?MODULE,{signal,{button_red,'clicked'}}} ->loop(point(LD,red));
- {?MODULE,{signal,{button_green,'clicked'}}} ->loop(point(LD,green));
- {?MODULE,{signal,{button_blue,'clicked'}}} ->loop(point(LD,blue));
- {?MODULE,{signal,{button_quit,'clicked'}}} ->quit();
- {?MODULE,{signal,{window,'delete-event'}}} ->quit();
- quit ->quit();
- X -> io:fwrite("got ~p~n",[X]),loop(LD)
+ {?MODULE,{signal,{drawingarea,'expose-event'}}}->loop(redraw(LD));
+ {?MODULE,{signal,{button_red,'clicked'}}} ->loop(point(LD,red));
+ {?MODULE,{signal,{button_green,'clicked'}}} ->loop(point(LD,green));
+ {?MODULE,{signal,{button_blue,'clicked'}}} ->loop(point(LD,blue));
+ {?MODULE,{signal,{button_quit,'clicked'}}} ->quit();
+ {?MODULE,{signal,{window,'delete-event'}}} ->quit();
+ quit ->quit();
+ X -> io:fwrite("got ~p~n",[X]),loop(LD)
end.
quit() -> gtknode:stop(?MODULE).
@@ -77,6 +77,6 @@ g(Wid,Cmd,Args) -> snd_rec(Cmd,[Wid|Args]).
snd_rec(Cmd, Args) ->
?MODULE ! {self(),[{Cmd,Args}]},
receive
- {?MODULE,{reply,[{ok,Rep}]}} -> Rep;
- {?MODULE,{reply,[{error,Rep}]}} -> erlang:error({Cmd,Args,Rep})
+ {?MODULE,{reply,[{ok,Rep}]}} -> Rep;
+ {?MODULE,{reply,[{error,Rep}]}} -> erlang:error({Cmd,Args,Rep})
end.
View
70 priv/examples/top/top.erl
@@ -1,7 +1,7 @@
%%%-------------------------------------------------------------------
%%% File : top.erl
%%% Author : Mats Cronqvist <locmacr@mwlx084>
-%%% Description :
+%%% Description :
%%%
%%% Created : 9 Aug 2005 by Mats Cronqvist <locmacr@mwlx084>
%%%-------------------------------------------------------------------
@@ -16,14 +16,14 @@
-record(col,{title,attr,data_col,type}).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-start() ->
+start() ->
case whereis(?MODULE) of
- undefined -> spawn(fun init/0);
- _ -> already_started
+ undefined -> spawn(fun init/0);
+ _ -> already_started
end.
stop() -> ?MODULE ! quit.
-
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
init() ->
%% start the c-node and it's port handler
@@ -47,11 +47,11 @@ state_init(St) ->
treeview_init(St) ->
%% the tree view columns
Cols = [#col{title="Proc",attr="text",data_col=0,type=string},
- #col{title="Size",attr="text",data_col=1,type=integer},
- #col{title="Msgq",attr="text",data_col=2,type=integer},
- #col{title="Reds",attr="text",data_col=3,type=integer}],
+ #col{title="Size",attr="text",data_col=1,type=integer},
+ #col{title="Msgq",attr="text",data_col=2,type=integer},
+ #col{title="Reds",attr="text",data_col=3,type=integer}],
lists:foreach(fun(C) -> treeview_column(C) end, Cols),
-
+
%% create the model (a list_store)
LS = ssnd([],'Gtk_list_store_newv',[length(Cols),[C#col.type||C<-Cols]]),
@@ -59,7 +59,7 @@ treeview_init(St) ->
ssnd(treeview1,'Gtk_tree_view_set_model',[LS]),
St#st{treeview=#treeview{cols = Cols,
- store = LS}}.
+ store = LS}}.
treeview_column(#col{title=Title,attr=Attr,data_col=Col}) ->
%% create a tree view column
@@ -75,26 +75,26 @@ treeview_column(#col{title=Title,attr=Attr,data_col=Col}) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
loop(St) ->
receive
- %% user deleted top window
- {?MODULE,{signal,{window1,_}}} -> quit();
- %% user selected quit menu item
- {?MODULE,{signal,{quit1,_}}} -> quit();
- %% user selected connect menu item
- {?MODULE,{signal,{connect,_}}} -> loop(conn(St));
- %% user selected disconnect menu item
- {?MODULE,{signal,{disconnect,_}}} -> loop(disc(St));
- %% user selected about menu item
- {?MODULE,{signal,{about1,_}}} -> loop(show_about(St));
- %% user clicked ok in about dialog
- {?MODULE,{signal,{dialogb,_}}} -> loop(hide_about(St));
- %% user deleted about dialog
- {?MODULE,{signal,{dialog1,_}}} -> loop(hide_about(St));
- %% we got data from the top_top process
- {data,Data} -> loop(update(St,Data));
- %% quit from the erlang shell
- quit -> quit();
- %% log other signals
- X -> io:fwrite("got ~p~n",[X]),loop(St)
+ %% user deleted top window
+ {?MODULE,{signal,{window1,_}}} -> quit();
+ %% user selected quit menu item
+ {?MODULE,{signal,{quit1,_}}} -> quit();
+ %% user selected connect menu item
+ {?MODULE,{signal,{connect,_}}} -> loop(conn(St));
+ %% user selected disconnect menu item
+ {?MODULE,{signal,{disconnect,_}}} -> loop(disc(St));
+ %% user selected about menu item
+ {?MODULE,{signal,{about1,_}}} -> loop(show_about(St));
+ %% user clicked ok in about dialog
+ {?MODULE,{signal,{dialogb,_}}} -> loop(hide_about(St));
+ %% user deleted about dialog
+ {?MODULE,{signal,{dialog1,_}}} -> loop(hide_about(St));
+ %% we got data from the top_top process
+ {data,Data} -> loop(update(St,Data));
+ %% quit from the erlang shell
+ quit -> quit();
+ %% log other signals
+ X -> io:fwrite("got ~p~n",[X]),loop(St)
end.
quit() -> gtknode:stop(?MODULE).
@@ -102,7 +102,7 @@ conn(St) -> do_connect(),state_conn(St).
disc(St) -> do_disconnect(),state_disc(St).
hide_about(St) -> ssnd(dialog1,'Gtk_widget_hide',[]),St.
show_about(St) -> ssnd(dialog1,'Gtk_widget_show',[]),St.
-update(St,Data) ->
+update(St,Data) ->
ssnd(treeview1,'Gtk_widget_freeze_child_notify',[]),
clear(St#st.treeview),
populate(St#st.treeview,Data),
@@ -121,9 +121,9 @@ state_conn(St) ->
do_connect() -> top_top:assert(self()).
do_disconnect() -> top_top:stop().
-
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-clear(#treeview{store=LS}) ->
+clear(#treeview{store=LS}) ->
ssnd(LS,'Gtk_list_store_clear',[]).
populate(_TV,[]) -> ok;
@@ -145,6 +145,6 @@ ssnd(Wid,Cmd,Args) -> snd(Cmd,[Wid|Args]).
snd(Cmd, Args) ->
?MODULE ! {self(),[{Cmd,Args}]},
receive
- {?MODULE,{reply,[{ok,Rep}]}} -> Rep;
- {?MODULE,{reply,[{error,Rep}]}} -> erlang:error({Cmd,Args,Rep})
+ {?MODULE,{reply,[{ok,Rep}]}} -> Rep;
+ {?MODULE,{reply,[{error,Rep}]}} -> erlang:error({Cmd,Args,Rep})
end.
View
26 priv/examples/top/top_top.erl
@@ -1,7 +1,7 @@
%%%-------------------------------------------------------------------
%%% File : top_top.erl
%%% Author : Mats Cronqvist <locmacr@mwlx084>
-%%% Description :
+%%% Description :
%%%
%%% Created : 11 Aug 2005 by Mats Cronqvist <locmacr@mwlx084>
%%%-------------------------------------------------------------------
@@ -11,34 +11,34 @@
-import(lists,[flatten/1,sublist/2,sort/2]).
-record(st, {ref,client,old_data=[],
- rows=20,tick=2000,key=reds,tags=[reg,mem,msgq,reds]}).
+ rows=20,tick=2000,key=reds,tags=[reg,mem,msgq,reds]}).
assert(ClientPid) ->
case whereis(?MODULE) of
- undefined -> spawn_link(fun init/0) ! {start,ClientPid};
- Pid -> Pid ! {start,ClientPid}
+ undefined -> spawn_link(fun init/0) ! {start,ClientPid};
+ Pid -> Pid ! {start,ClientPid}
end.
stop() -> ?MODULE ! stop.
-init() ->
+init() ->
register(?MODULE,self()),
loop(#st{ref=timr(#st{})}).
loop(St) ->
receive
- {timeout,_Ref,{}} -> loop(send_data(St#st{ref=timr(St)}));
- {start,Client}-> loop(St#st{client=Client,ref=timr(St)});
- stop -> loop(St#st{ref=untimr(St)})
+ {timeout,_Ref,{}} -> loop(send_data(St#st{ref=timr(St)}));
+ {start,Client}-> loop(St#st{client=Client,ref=timr(St)});
+ stop -> loop(St#st{ref=untimr(St)})
end.
untimr(St) ->
(catch erlang:cancel_timer(St#st.ref)),[].
timr(St) ->
- case St#st.ref of
- Ref when is_reference(Ref) -> timr(St#st{ref=untimr(St)});
- _ -> erlang:start_timer(St#st.tick,self(),{})
+ case St#st.ref of
+ Ref when is_reference(Ref) -> timr(St#st{ref=untimr(St)});
+ _ -> erlang:start_timer(St#st.tick,self(),{})
end.
send_data(St = #st{old_data=[]}) ->
@@ -58,10 +58,10 @@ pi(P,reg) -> case sin(P,registered_name) of "[]"->sin(P,initial_call); X->X end.
pin(P,Tag,D) -> case (catch process_info(P,Tag)) of {Tag,V} -> V; _ -> D end.
sin(P,Tag) -> to_string(pin(P,Tag,"")).
-
+
to_string(Term) -> flatten(io_lib:format("~p",[Term])).
-sort(Key,Rows,Data,OldData) ->
+sort(Key,Rows,Data,OldData) ->
sublist(sort(fun(A,B)->cmp(Key,A,B) end, diff(Key,Data,OldData)),Rows).
cmp(reds,[_,A,_,X],[_,B,_,X]) -> B<A;
View
20 priv/examples/treeview/treeview.erl
@@ -13,7 +13,7 @@
-import(lists,[flatten/1,foldl/3]).
-record(ld,{col_list1,col_list2,col_tree1,col_tree2,tree_store,list_store}).
-list_data() ->
+list_data() ->
[[1,"one"],
[2,"two"]].
@@ -27,14 +27,14 @@ tree_data() ->
{["two",2],[]}].
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-start() ->
+start() ->
case whereis(?MODULE) of
- undefined -> spawn(fun init/0);
- _ -> already_started
+ undefined -> spawn(fun init/0);
+ _ -> already_started
end.
stop() -> ?MODULE ! quit.
-
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
init() ->
gtknode:start(?MODULE),
@@ -52,10 +52,10 @@ loop(LD) ->
receive
{?MODULE,{signal,{radiobutton_list,toggled}}}-> loop(tree_view(LD));
{?MODULE,{signal,{button_insert,clicked}}} -> loop(insert(LD));
- {?MODULE,{signal,{window,'delete-event'}}} -> quit();
+ {?MODULE,{signal,{window,'delete-event'}}} -> quit();
{?MODULE,{signal,{button_quit,'clicked'}}} -> quit();
- quit -> quit();
- X -> io:fwrite("got ~p~n",[X]),loop(LD)
+ quit -> quit();
+ X -> io:fwrite("got ~p~n",[X]),loop(LD)
end.
quit() -> gtknode:stop(?MODULE).
@@ -100,11 +100,11 @@ init_tree_view_column(DataCol,Title) ->
new_tree_store(Cols)->
g('Gtk_tree_store_newv',[length(Cols),Cols]).
-tree_insert(Store,Rows) ->
+tree_insert(Store,Rows) ->
g(flatten(tree_insert(Store,[0],Rows))).
tree_insert(_Store,_Path,[]) -> [];
-tree_insert(Store,Path,[{Row,SubTree}|T]) ->
+tree_insert(Store,Path,[{Row,SubTree}|T]) ->
[update_iter(Path, Store),
tree_insert_row(Store,0,Row),
tree_insert(Store,[0|Path],SubTree),
Please sign in to comment.
Something went wrong with that request. Please try again.