caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Typing problems when using LablGTK
@ 2001-02-03 21:54 Mattias Waldau
  2001-02-04 23:09 ` Maxence
  2001-02-05  3:05 ` Jacques Garrigue
  0 siblings, 2 replies; 5+ messages in thread
From: Mattias Waldau @ 2001-02-03 21:54 UTC (permalink / raw)
  To: caml-list


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 >
# 



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-02-06 16:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-03 21:54 Typing problems when using LablGTK Mattias Waldau
2001-02-04 23:09 ` Maxence
2001-02-05  3:05 ` Jacques Garrigue
2001-02-05 18:18   ` Mattias Waldau
2001-02-06  1:58     ` Jacques Garrigue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).