aboutsummaryrefslogtreecommitdiffhomepage
path: root/ide/wg_Completion.ml
diff options
context:
space:
mode:
authorGravatar ppedrot <ppedrot@85f007b7-540e-0410-9357-904b9bb8a0f7>2013-02-20 11:15:26 +0000
committerGravatar ppedrot <ppedrot@85f007b7-540e-0410-9357-904b9bb8a0f7>2013-02-20 11:15:26 +0000
commit2d4b9ba3317a11c6af2ad783bfb2a08e7123ac6d (patch)
tree1a210413dce6c41ed86cc40a588099ce38a4e6b8 /ide/wg_Completion.ml
parenta07359f69a6eb4167aeddd1bf2710c09f570ed39 (diff)
Adding scrollbars to CoqIDE autocompletion
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@16224 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'ide/wg_Completion.ml')
-rw-r--r--ide/wg_Completion.ml31
1 files changed, 27 insertions, 4 deletions
diff --git a/ide/wg_Completion.ml b/ide/wg_Completion.ml
index 39c695f21..c34190c8a 100644
--- a/ide/wg_Completion.ml
+++ b/ide/wg_Completion.ml
@@ -109,7 +109,7 @@ object (self)
(* disable autocomplete *)
is_auto_completing <- false
- method store = (filtered_store :> GTree.model)
+ method store = filtered_store
method column = column
@@ -289,10 +289,34 @@ object (self)
let () = model#handle_proposal path in
self#hide ()
+ method private manage_scrollbar () =
+ (** HACK: we don't have access to the treeview size because of the lack of
+ LablGTK binding for certain functions, so we bypass it by approximating
+ it through the size of the proposals *)
+ let height = match model#store#get_iter_first with
+ | None -> -1
+ | Some iter ->
+ let path = model#store#get_path iter in
+ let area = data#get_cell_area ~path ~col () in
+ let height = Gdk.Rectangle.height area in
+ let height = 16 * height in
+ height
+ in
+ let len = ref 0 in
+ let () = model#store#foreach (fun _ _ -> incr len; false) in
+ if !len > 15 then
+ let () = frame#set_vpolicy `ALWAYS in
+ data#misc#set_size_request ~height ()
+ else
+ data#misc#set_size_request ~height:(-1) ()
+
method private refresh () =
- let () = obj#resize 1 1 in
+ let () = frame#set_vpolicy `NEVER in
+(* let () = obj#resize 1 1 in *)
let () = self#select_first () in
- obj#misc#show ()
+ let () = obj#misc#show () in
+ let () = self#manage_scrollbar () in
+ obj#resize 1 1
method private start_callback off =
let (x, y, w, h) = self#coordinates (`OFFSET off) in
@@ -300,7 +324,6 @@ object (self)
()
method private update_callback off word props =
- let () = frame#set_vpolicy `NEVER in
if Proposals.is_empty props then self#hide ()
else if Proposals.mem word props then self#hide ()
else self#refresh ()