let db_chooser tables mode =
  let dialog =
    GWindow.dialog
      ~title:"DB Column chooser" ~position:`MOUSE ()
  and db_view = new db_widget mode
  in let view_frame = GBin.frame
                        ~height:300 ~width:300
                        ~label:"Choose one column"
                        ~border_width:5
                        ~packing:dialog#vbox#add
                        ()
  in let scrolled_window = GBin.scrolled_window
                             ~hpolicy:`AUTOMATIC
                             ~vpolicy:`AUTOMATIC
                             ~border_width:5 ~shadow_type: `IN
                             ~packing:view_frame#add
                             ()
  in
    db_view#set_tables tables;
    scrolled_window#add db_view#view.sv_view#coerce;
    dialog#action_area#set_layout `START;
    dialog#add_button_stock `OK     `OK;
    dialog#add_button_stock `CANCEL `CANCEL;
    let rec run_dialog = fun () ->
      match dialog#run () with
        | `OK -> begin
            match db_view#selected_columns with
              | [] ->
                  GToolbox.message_box ~title:"Error"
                    "Please, choose a column in the list";
                  run_dialog ()
              | columns -> columns
          end
        | _   -> []
    in
    let result = run_dialog () in
      dialog#destroy ();
      result