caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Richard Jones <rich@annexia.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] lablgtk newbie question
Date: Tue, 22 Apr 2003 14:28:24 +0100	[thread overview]
Message-ID: <20030422132824.GA12408@redhat.com> (raw)
In-Reply-To: <20030422221215C.garrigue@kurims.kyoto-u.ac.jp>

Thanks everyone. I'm now using:

ocaml -w s -I +lablgtk lablgtk.cma gtkInit.cmo editor.ml

I notice that I can't put

#!/usr/bin/ocaml -w s -I +lablgtk lablgtk.cma gtkInit.cmo

at the beginning of my program. It complains of:

Couldnt get a file descriptor referring to the console
Could not get a file descriptor referring to the console
Couldnt get a file descriptor referring to the console
Could not get a file descriptor referring to the console
Couldnt get a file descriptor referring to the console
Could not get a file descriptor referring to the console
./editor.ml: line 8: let: =: syntax error: operand expected (error token is "=")
./editor.ml: line 9: syntax error near unexpected token `"Unimplemented: "'
./editor.ml: line 9: `  prerr_endline ("Unimplemented: " ^ msg);;'

Strange, but not a show-stopper.

I've also rewritten the program and worked out what the problem was
with ;; and ;. I'm assuming that ';' on its own is just a sequence
point, kind of like the monad stuff in Haskell (?)

And I'm using let ... in  as a short-hand for a local variable (except,
of course, I'm aware that it's not _really_ "variable").

My program looks like this now. Comments on style are welcome.

Rich.

open GMain
open GWindow
open GdkKeysyms

let unimplemented msg =
  prerr_endline ("Unimplemented: " ^ msg);;

let menu_new_blank_page () =
  unimplemented "New blank page function selected";;

let menu_search () =
  unimplemented "Search function selected";;

let menu_cut () =
  unimplemented "Cut function selected";;

let menu_copy () =
  unimplemented "Copy function selected";;

let menu_paste () =
  unimplemented "Paste function selected";;

let main () =
  (* Main window *)
  let window = GWindow.window ~width:500 ~height:300 ~title:"Editor" () in
  let vbox = GPack.vbox ~packing:window#add () in
  window#connect#destroy ~callback: Main.quit;

  (* Menu bar *)
  let menubar = GMenu.menu_bar ~packing:vbox#pack () in
  let factory = new GMenu.factory menubar in
  let accel_group = factory#accel_group in
  let pages_menu = factory#add_submenu "Pages" in
  let edit_menu = factory#add_submenu "Edit" in

  (* Pages menu *)
  let factory = new GMenu.factory pages_menu ~accel_group in
  factory#add_item "New blank page" ~key:_N ~callback: menu_new_blank_page;
  factory#add_item "Search ..." ~key:_S ~callback: menu_search;

  (* Edit menu *)
  let factory = new GMenu.factory edit_menu ~accel_group in
  factory#add_item "Cut" ~key:_X ~callback: menu_cut;
  factory#add_item "Copy" ~key:_C ~callback: menu_copy;
  factory#add_item "Paste" ~key:_V ~callback: menu_paste;

  (* Display the windows and enter Gtk+ main loop *)
  window#show ();
  Main.main ();;

(* Run the main program *)
main ();;


-- 
Richard Jones, Red Hat Inc. (London) and Merjis Ltd. http://www.merjis.com/
http://www.annexia.org/ Freshmeat projects: http://freshmeat.net/users/rwmj
MONOLITH is an advanced framework for writing web applications in C, easier
than using Perl & Java, much faster and smaller, reusable widget-based arch,
database-backed, discussion, chat, calendaring:
http://www.annexia.org/freeware/monolith/

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


      reply	other threads:[~2003-04-22 13:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-22 10:55 Richard Jones
2003-04-22 11:42 ` Richard Jones
2003-04-22 13:01 ` Benjamin Monate
2003-04-22 13:08 ` Eric C. Cooper
2003-04-22 13:12 ` Jacques Garrigue
2003-04-22 13:28   ` Richard Jones [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030422132824.GA12408@redhat.com \
    --to=rich@annexia.org \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).