Download The demexp Book - Linux
Transcript
In function setup first half window, we firstly open the main window and attach to it the minimal callbacks to be able to display messages in the status box and to quit properly the application. The delete signal of ui#toplevel window is sent when the user closes a window. fixme: We should initially disable menu entries without call backs. 159a hbrowser.ml 149ai+≡ / 158c 159b . let setup_window_1_over_3 ui = (* to stop application when closing demexp window or choosing menu option *) ignore(ui#toplevel#event#connect#delete ˜callback:quit_callback); ignore(ui#quit1#connect#activate ˜callback:(fun () -> ignore (quit_callback ())) ); ignore(ui#about1#connect#activate ˜callback:about_dialog); (* show main window, so we can display things on its status bar *) ui#toplevel#show () We then connect the “Preferences...” menu item. 159b hbrowser.ml 149ai+≡ / 159a 159c . let setup_window_2_over_3 ui pref connection_param = ignore(ui#preferences1#connect#activate ˜callback:(Pref.ui_preferences pref)); let title = match connection_param with | Some _ -> (* successful connection (hopefully login is correct, as we cannot detect the case when we are connected as Anonymous) *) Printf.sprintf (f_ "demexp (%s, %s) - %s:%d") pref#user_login pref#delegate_login pref#server_name pref#server_port | None -> (* connection failed *) Printf.sprintf (f_ "Connection failed to %s:%d") pref#server_name pref#server_port in ui#toplevel#set_title title Helper function select question search over all questions in the GtkTreeView of questions the one which has the same identifier as q id. 159c hbrowser.ml 149ai+≡ let rec select_question ctx selection q_id iter = let current_q_id = ctx.question_backend#store#get ˜row:iter ˜column:ctx.question_backend#col_id in if current_q_id = q_id then ( (* we have found our question *) selection#select_iter iter; ) else ( if ctx.question_backend#store#iter_next iter then select_question ctx selection q_id iter ) 159 / 159b 160a . FIXME