Skip to content
Snippets Groups Projects
Commit b08b28f6 authored by erwan's avatar erwan
Browse files

Les boutons dans une grille faite à la main

parent 12e571b0
No related branches found
No related tags found
1 merge request!14A new rdbgui4sasa with automatic daemons
Pipeline #63323 passed
......@@ -94,25 +94,36 @@ let main () =
let nodes_table = rdbg_nodes_enabled !e in
let nodes_enabled = Hashtbl.to_seq nodes_table in
let n = Hashtbl.length nodes_table in
let m = int_of_float (sqrt (float_of_int n)) in
(* build manually a m x m grid *)
let i = ref 0 in
let container_ref = ref container in
let checkboxes_map = Hashtbl.create n in
Seq.iter (fun (name, enabled) ->
(* cf. classe toggle_button de lablgtk3 *)
let checkbox = GButton.check_button ~label:name ~packing:container#add () in
(* Quand on coche/décoche, met à jour le rdbg_mv_hook *)
ignore(checkbox#connect#toggled ~callback: (fun () ->
update_rdbg_hook name checkbox#active
));
checkbox#set_sensitive enabled; (* désactive la box si le noeud n'est pas activable *)
checkbox#set_active false; (* décoche la case *)
Hashtbl.add checkboxes_map name checkbox
) nodes_enabled;
incr i;
if !i > m then (
i := 0;
let new_container = GPack.hbox ~packing:vbox#add () in
container_ref := new_container
);
(* cf. classe toggle_button de lablgtk3 *)
let checkbox = GButton.check_button ~label:name ~packing:!container_ref#add () in
(* Quand on coche/décoche, met à jour le rdbg_mv_hook *)
ignore(checkbox#connect#toggled ~callback: (fun () ->
update_rdbg_hook name checkbox#active
));
checkbox#set_sensitive enabled; (* désactive la box si le noeud n'est pas activable *)
checkbox#set_active false; (* décoche la case *)
Hashtbl.add checkboxes_map name checkbox
)
nodes_enabled;
let update_checkbox node enabled =
let checkbox = Hashtbl.find checkboxes_map node in
if not enabled then checkbox#set_active false; (* on decoche *)
checkbox#set_sensitive enabled
in
(* Affichage d'informations *)
let scrolled = GBin.scrolled_window ~border_width:10
~shadow_type:`OUT ~height:250 ~packing:vbox#add ()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment