diff --git a/sw/ground_segment/cockpit/papgets.ml b/sw/ground_segment/cockpit/papgets.ml index 55433fafd6..762869fcc9 100644 --- a/sw/ground_segment/cockpit/papgets.ml +++ b/sw/ground_segment/cockpit/papgets.ml @@ -176,6 +176,8 @@ let create = fun canvas_group papget -> match display with "mplayer" -> (new Papget_renderer.canvas_mplayer canvas_group ~config x y :> Papget_renderer.t) + | "plugin" -> + (new Papget_renderer.canvas_plugin canvas_group ~config x y :> Papget_renderer.t) | _ -> failwith (sprintf "Unexpected papget display: %s" display) in let properties = locked papget in diff --git a/sw/lib/ocaml/papget_renderer.ml b/sw/lib/ocaml/papget_renderer.ml index 68c2d193ee..9f8b64aeca 100644 --- a/sw/lib/ocaml/papget_renderer.ml +++ b/sw/lib/ocaml/papget_renderer.ml @@ -344,6 +344,32 @@ class canvas_mplayer = fun ?(config=[]) canvas_group x y -> end +(****************************************************************************) +class canvas_plugin = fun ?(config=[]) canvas_group x y -> + let command = PC.get_prop "command" config "missing_plugin_command" in + let width = float_of_string (PC.get_prop "width" config "320.") + and height = float_of_string (PC.get_prop "height" config "240.") in + let socket = GWindow.socket () in + let group = GnoCanvas.group ~x ~y canvas_group in + let _item = GnoCanvas.widget ~width ~height ~widget:socket group in + + object + method tag = "Plugin" + method item = (group :> movable_item) + method edit = fun (pack:GObj.widget -> unit) -> () + method update = fun (value:string) -> () + method config = fun () -> + [ PC.property "command" command; + PC.float_property "width" width; + PC.float_property "height" height ] + initializer + group#lower_to_bottom (); + let com = sprintf "exec %s0x%lx" command socket#xwindow in + let dev_null = Unix.descr_of_out_channel (open_out "/dev/null") in + ignore (Unix.create_process "/bin/sh" [|"/bin/sh"; "-c"; com|] dev_null dev_null dev_null) + end + + let renderers = [ (new canvas_text :> ?config:Xml.xml list -> #GnoCanvas.group -> float -> float -> t); diff --git a/sw/lib/ocaml/papget_renderer.mli b/sw/lib/ocaml/papget_renderer.mli index c26426bee0..4c576167ea 100644 --- a/sw/lib/ocaml/papget_renderer.mli +++ b/sw/lib/ocaml/papget_renderer.mli @@ -57,6 +57,9 @@ class canvas_button : ?config:Xml.xml list -> #GnoCanvas.group -> float -> float class canvas_mplayer : ?config:Xml.xml list -> #GnoCanvas.group -> float -> float -> t (** [canvas_mplayer config group x y] *) +class canvas_plugin : ?config:Xml.xml list -> #GnoCanvas.group -> float -> float -> t +(** [canvas_plugin config group x y] *) + val lazy_tagged_renderers : (string * (?config:Xml.xml list -> GnoCanvas.group -> float -> float -> t)) list lazy_t