gnome canvas and a text view
Jacques Le Normand <[email protected]> Wed, 4 Mar 2009 22:04:52 -0500
| Newsgroups | gmane.comp.lang.ocaml.lib.gtk |
|---|---|
| Message-ID | <[email protected]> |
dear list,
I'm place a text_view in scrolled_window in a gnome canvas. Everytime the
buffer of the text view changes, I want a label to be placed right under the
end of the buffer. I cooked up some code. The code has four problems:
1) the label is not placed in the correct location
2) the label is blocked by the text view
3) the scrolled_window is not placed at the top left corner of the gnome
canvas
4) the scrolled_window does not take the entire gnome canvas (I want the
gnome canvas to hug the scrolled_window)
is it possible to fix these problems?
cheers
--Jacques
let _ =
let source_window = GWindow.window () in
let buffer = GText.buffer () in
let canvas = GnoCanvas.canvas ~show:true ~packing:source_window#add () in
let scrolled_window = GBin.scrolled_window () in
let view =
GText.view ~buffer:buffer ~show:true
~packing:scrolled_window#add_with_viewport () in
let _ =
GnoCanvas.widget ~widget:scrolled_window ~width:200.0 ~height:200.0
canvas#root in
let label = GMisc.label ~text:"you're editing here" () in
let label_as_item = GnoCanvas.widget ~widget:label ~width:150.0
~height:100.0 canvas#root in
let changed_callback _ =
let last_iter = buffer#end_iter in
let rect = view#get_iter_location last_iter in
let x = float_of_int (Gdk.Rectangle.x rect) in
let y = float_of_int (Gdk.Rectangle.y rect) in
label_as_item#move ~x:x ~y:y
in
label_as_item#show ();
ignore(buffer#connect#changed ~callback:changed_callback);
buffer#insert "some text";
source_window#show ();
source_window#maximize ();
GMain.Main.main ()
_______________________________________________
Lablgtk mailing list
[email protected]
http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk