let log_window () =
  let window = GWindow.window ~kind: `TOPLEVEL ~show: false
      ~width: 500 ~height: 600 ()
      ~title: "Cameleon log"
  in
  ignore (window#event#connect#delete (fun _ -> window#misc#hide (); true));
  let vbox = GPack.vbox ~packing: window#add () in
  let v = new box () in
  ignore(vbox#pack ~expand: true v#box);
  let wb_close = GButton.button
      ~label: Cam_messages.close
      ~packing: (vbox#pack ~expand: false)
      ()
  in
  ignore (wb_close#connect#clicked window#misc#hide);
  let p_fun f ?(to_utf8=false) s =
    let s =
      (* FIXME: convert from locale or from another charset ?
         The problem is that we can't use Ed_misc from here.
         This problem could be resolved by strongly typing utf8 strings.
         *)

      if to_utf8 then
        try Glib.Convert.locale_to_utf8 s
        with _ -> s
      else
        s
    in
    f s
  in
  Cam_hooks.set_display_message (p_fun (v#print "Black"));
  Cam_hooks.set_warning_message (p_fun (v#print "Orange"));
  Cam_hooks.set_error_message (p_fun (v#print "Red"));
  window