Download The demexp Book - Linux
Transcript
At first, helper function setup window gets the data (list of tags and questions) from the
server, then it connects the tree widgets to their backends and sets needed callbacks.
138a
hclsf.ml 129i+≡
/ 137 138b .
let setup_window ui backends user_msg client cookie cache
reload_tags_and_questions =
(* load data from server *)
let tags_hash = Hashtbl.create 3 in
Cache.update_tags_hash tags_hash client cookie cache;
backends.tags#set_tags_hash tags_hash;
Tags.fill_tag_store backends.tags tags_hash;
fill_question_store backends.questions client cookie cache;
(* list of all tags *)
Tags.connect_tag_view ˜view:ui#treeview_tags14
˜backend:backends.tags ();
(* tags specific to a question *)
Tags.connect_tag_view ˜view:ui#treeview_question_tags22
˜backend:backends.question_tags ();
(* list of tagging_only questions *)
connect_question_view client cookie cache backends user_msg
˜view:ui#treeview_questions15
˜backend:backends.questions;
ui#treeview_questions15#selection#set_select_function
(question_clicked backends user_msg client cookie cache);
(* button callbacks *)
ignore(ui#button_remove40#connect#clicked
˜callback:(remove_callback ui backends user_msg client cookie));
ignore(ui#button_add41#connect#clicked
˜callback:(add_callback ui backends user_msg client cookie));
(* reload the browser when done *)
ignore(ui#toplevel#event#connect#delete
˜callback:(fun _ev ->
reload_tags_and_questions ();
false (*close window*)))
Function ui is called to display the user management window. Parameter reload tags and questions
is defined in code chunk 161.
138b
hclsf.ml 129i+≡
/ 138a
let ui_classification client cookie cache reload_tags_and_questions () =
let ui = new Demexp_gladeui.classification () in
let user_msg =
MiscUI.create_user_msg_fun ui#statusbar3 "classification sb" in
(* we show dialog immediately so we can tell what we are doing in
the status bar *)
ui#toplevel#show ();
try
let backends = { tags = new tag_backend ();
question_tags = new tag_backend ();
questions = new question_backend (); } in
setup_window ui backends user_msg client cookie cache
reload_tags_and_questions
with Failure msg -> user_msg msg
138