Version française
Home     About     Download     Resources     Contact us    
Browse thread
Typing problems when using LablGTK
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Mattias Waldau <mattias@f...>
Subject: Typing problems when using LablGTK

The first program works fine, but if I take the let button-part and move it to a separate
function called mini, the compilation fails. The type of the method attach is different.

What have I misunderstood?

/mattias

P.s. I learning GNOME using the book "Beginning GTK+/GNOME Programming", and sometimes it is
difficult to map GTK in C to LablGTK. I am on page 111.

Program 1, works.
=================

open GMain

let main () =
  let window = GWindow.window ~border_width:10 ~title:"Fun with tables" ~width:320 ~height:200 () in
  window#connect#destroy ~callback:Main.quit; 
  let table = GPack.table ~rows:10 ~columns:10 ~packing:window#add () in
  let button = GButton.button ~label:"test"
      ~packing:(table#attach ~left:2 ~top:2 ~expand:`BOTH) () in
(*  mini table; *)
  window#show ();
  Main.main ()

let _ = Printexc.print main ()


Program 2, fails
================

open GMain

let mini table : unit =
  GButton.button ~label:"mini"
    ~packing:(table#attach ~left:3 ~top:3 ~expand:`BOTH) ();
  ()

  
let main () =
  let window = GWindow.window ~border_width:10 ~title:"Fun with tables" ~width:320 ~height:200 () in
  window#connect#destroy ~callback:Main.quit; 
  let table = GPack.table ~rows:10 ~columns:10 ~packing:window#add () in
  mini table; 
  window#show ();
  Main.main ()

let _ = Printexc.print main ()



        Objective Caml version 3.00+20 (2000-12-03)

#                                   Characters 366-371:
This expression has type
  GPack.table =
    < add : GObj.widget -> unit; as_widget : Gtk.widget Gtk.obj;
      attach : int ->
               int ->
               ?right:int ->
               ?bottom:int ->
               ?expand:Gtk.Tags.expand_type ->
               ?fill:Gtk.Tags.expand_type ->
               ?shrink:Gtk.Tags.expand_type ->
               ?xpadding:int -> ?ypadding:int -> GObj.widget -> unit;
      children : GObj.widget list; coerce : GObj.widget;
      connect : GContainer.container_signals; destroy : unit -> unit;
      drag : GObj.drag_ops; focus : GContainer.focus; get_id : int;
      misc : GObj.misc_ops; remove : GObj.widget -> unit;
      set_border_width : int -> unit; set_col_spacing : int -> int -> unit;
      set_col_spacings : int -> unit; set_homogeneous : bool -> unit;
      set_row_spacing : int -> int -> unit; set_row_spacings : int -> unit >
but is here used with type
  < add : GObj.widget -> unit; as_widget : Gtk.widget Gtk.obj;
    attach : int -> int -> [> `BOTH] -> GObj.widget -> unit;
    children : GObj.widget list; coerce : GObj.widget;
    connect : GContainer.container_signals; destroy : unit -> unit;
    drag : GObj.drag_ops; focus : GContainer.focus; get_id : int;
    misc : GObj.misc_ops; remove : GObj.widget -> unit;
    set_border_width : int -> unit; set_col_spacing : int -> int -> unit;
    set_col_spacings : int -> unit; set_homogeneous : bool -> unit;
    set_row_spacing : int -> int -> unit; set_row_spacings : int -> unit >
#