# # patch "app.ml" # from [43b61f04329b4a55f1f280fed8a9c8cf54bc3191] # to [66ca42a7682768ef5390ebd179fe17542a32fa69] # # patch "query.ml" # from [b433130eeeeb458c8f6711e2d4f3d43f9b7ec85c] # to [3142c52cfb08b083bef4d35b56007d0a56c17b50] # # patch "ui.ml" # from [ac08a5570e6835f62d32e9db7802dca117fd801b] # to [da402d15b2968165c610a3bce77b3bc79eb626e0] # # patch "ui.mli" # from [9fc86ec4a44065737b468fbe8d2139d7485cec1b] # to [709939bf726569572659c17fa1ac030f89e84c8b] # ======================================================================== --- app.ml 43b61f04329b4a55f1f280fed8a9c8cf54bc3191 +++ app.ml 66ca42a7682768ef5390ebd179fe17542a32fa69 @@ -53,7 +53,7 @@ open Viz_misc class ctrl w ~prefs ~manager ~status ~view : t = - let busy = new Ui.busy_indicator w in + let busy = Ui.Busy.make w in object (self) val mutable db = None val mutable agraph = None @@ -114,10 +114,10 @@ may Database.close_db db method display_certs id = - busy#start ; + Ui.Busy.start busy ; View.Info_Display.fetch_and_display_data view.View.info self id ; - busy#stop + Ui.Busy.stop busy method focus_find_entry () = View.Find.focus_find_entry view.View.find @@ -149,7 +149,7 @@ agraph method private clear = - busy#stop ; + Ui.Busy.stop busy ; View.clear view self ; Ui.clear manager ; may Query.clear query @@ -165,7 +165,7 @@ self#clear ; may (fun db -> - busy#start ; + Ui.Busy.start busy ; let g1 = (self#status "agraph")#with_status "Building ancestry graph" @@ -181,7 +181,7 @@ (self#status "dot") (function | `LAYOUT_ERROR msg -> - busy#stop ; + Ui.Busy.stop busy ; self#error_notice msg | `LAYOUT_DONE -> View.update @@ -212,7 +212,7 @@ may Query.activate query ; method update_end = - busy#stop + Ui.Busy.stop busy method center_on n = View.Canvas.center_on view.View.canvas self n ======================================================================== --- query.ml b433130eeeeb458c8f6711e2d4f3d43f9b7ec85c +++ query.ml 3142c52cfb08b083bef4d35b56007d0a56c17b50 @@ -243,8 +243,8 @@ set_label 0 | `QUERY -> w#set_response_sensitive `QUERY false ; - let busy = new Ui.busy_indicator w in - busy#start ; + let busy = Ui.Busy.make w in + Ui.Busy.start busy ; do_query ~selector:e1#text ~revision_content:e2#text @@ -258,7 +258,7 @@ | `SUB_PROC_ERROR msg -> Ui.error_notice ~parent:w msg end ; - busy#stop ; + Ui.Busy.stop busy ; w#set_response_sensitive `QUERY true))) ; ignore (rv#connect#row_activated (fun path view_col -> ======================================================================== --- ui.ml ac08a5570e6835f62d32e9db7802dca117fd801b +++ ui.ml da402d15b2968165c610a3bce77b3bc79eb626e0 @@ -50,45 +50,50 @@ let add_label ~text ~packing = ignore (GMisc.label ~text ~packing ()) -let busy_cursor = lazy (Gdk.Cursor.create `WATCH) -let normal_cursor = lazy (Gdk.Cursor.create `LEFT_PTR) -let set_busy_cursor w busy = - Gdk.Window.set_cursor w#misc#window - (Lazy.force - (if busy then busy_cursor else normal_cursor)) +module Busy = struct + let busy_cursor = lazy (Gdk.Cursor.create `WATCH) + let normal_cursor = lazy (Gdk.Cursor.create `LEFT_PTR) + let set_busy_cursor w busy = + Gdk.Window.set_cursor w#misc#window + (Lazy.force + (if busy then busy_cursor else normal_cursor)) -class busy_indicator (widget : #GObj.widget) = - object - val mutable depth = 0 - val mutable timer_id = None + type t = { + widget : GObj.widget ; + mutable depth : int ; + mutable timer_id : Glib.Timeout.id option ; + } - method start = - depth <- depth + 1 ; - match timer_id with - | None when depth = 1 -> - let id = - Glib.Timeout.add 500 - (fun () -> - timer_id <- None ; - set_busy_cursor widget true ; - false) in - timer_id <- Some id - | _ -> () + let make w = + { widget = w#coerce ; depth = 0 ; timer_id = None } - method stop = - if depth > 0 then begin - depth <- depth - 1 ; - if depth = 0 then - match timer_id with - | None -> - set_busy_cursor widget false - | Some id -> - Glib.Timeout.remove id ; - timer_id <- None - end - end + let start b = + b.depth <- b.depth + 1 ; + match b.timer_id with + | None when b.depth = 1 -> + let id = + Glib.Timeout.add 500 + (fun () -> + b.timer_id <- None ; + set_busy_cursor b.widget true ; + false) in + b.timer_id <- Some id + | _ -> () + let stop b = + match b.timer_id with + | None when b.depth = 1 -> + set_busy_cursor b.widget false ; + b.depth <- 0 + | Some id when b.depth = 1 -> + Glib.Timeout.remove id ; + b.timer_id <- None ; + b.depth <- 0 + | _ when b.depth > 1 -> + b.depth <- b.depth - 1 + | _ -> () +end let category title packing = ======================================================================== --- ui.mli 9fc86ec4a44065737b468fbe8d2139d7485cec1b +++ ui.mli 709939bf726569572659c17fa1ac030f89e84c8b @@ -10,12 +10,12 @@ val wrap_in_scroll_window : (GObj.widget -> unit) -> GObj.widget -> unit val add_label : text:string -> packing:(GObj.widget -> unit) -> unit -class busy_indicator : - #GObj.widget -> - object - method start : unit - method stop : unit - end +module Busy : sig + type t + val make : #GObj.widget -> t + val start : t -> unit + val stop : t -> unit +end val category : string ->