From: <as...@us...> - 2003-07-09 22:43:18
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/buttons In directory sc8-pr-cvs1:/tmp/cvs-serv25460/gtk/buttons Modified Files: Button.chs CheckButton.chs RadioButton.chs ToggleButton.chs Log Message: Make compile with GHC 6.00. There are two major changes in the FFI which made me separate everything that has to do with Foreign and Foreign.C into a new file called general/FFI.hs. The file UTFCForeign.hs is now obsolete as its string conversion functions are now in FFI.hs. The nullForeignPtr function is also located here. All files now import FFI instead of Foreign and UTFCForeign. The major changes are: newForeignPtr now takes a pointer to a C function as finalizer. Every destructor function is now defined differently depending on whether the new GHC is used or not. In particular there is now a function called free :: Ptr a -> IO () imported from the Foreign library. In addition to that I defined a function foreignFree which can be used as finalizer to a C data structure. It is equivalent to free if GHC version <=5.04 is used. The second change is that ForeignPtr are no longer accepted as arguments to foreign calls. This change is mainly reflected in c2hs, but also in some files which directly called functions. Index: Button.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/buttons/Button.chs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Button.chs 8 Nov 2002 10:39:21 -0000 1.3 +++ Button.chs 9 Jul 2003 22:42:43 -0000 1.4 @@ -64,8 +64,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} @@ -84,7 +84,7 @@ -- @constructor buttonNewWithLabel@ Create a button with a label in it. -- buttonNewWithLabel :: String -> IO Button -buttonNewWithLabel lbl = withCString lbl (\strPtr -> +buttonNewWithLabel lbl = withUTFString lbl (\strPtr -> makeNewObject mkButton $ liftM castPtr $ {#call unsafe button_new_with_label#} strPtr) @@ -95,14 +95,14 @@ -- shortcut). -- buttonNewWithMnemonic :: String -> IO Button -buttonNewWithMnemonic lbl = withCString lbl (\strPtr -> +buttonNewWithMnemonic lbl = withUTFString lbl (\strPtr -> makeNewObject mkButton $ liftM castPtr $ {#call unsafe button_new_with_mnemonic#} strPtr) -- @constructor buttonNewFromStock@ Create a stock (predefined appearance) button. -- buttonNewFromStock :: String -> IO Button -buttonNewFromStock stockId = withCString stockId (\strPtr -> +buttonNewFromStock stockId = withUTFString stockId (\strPtr -> makeNewObject mkButton $ liftM castPtr $ throwIfNull "buttonNewFromStock: Invalid stock identifier." $ {#call unsafe button_new_from_stock#} strPtr) @@ -150,7 +150,7 @@ -- @method buttonSetLabel@ Set the text of the button. -- buttonSetLabel :: ButtonClass b => b -> String -> IO () -buttonSetLabel b lbl = withCString lbl $ \strPtr -> +buttonSetLabel b lbl = withUTFString lbl $ \strPtr -> {#call button_set_label#} (toButton b) strPtr -- @method buttonGetLabel@ Get the current text on the button. @@ -161,7 +161,7 @@ buttonGetLabel :: ButtonClass b => b -> IO String buttonGetLabel b = do strPtr <- {#call unsafe button_get_label#} (toButton b) - if strPtr==nullPtr then return "" else peekCString strPtr + if strPtr==nullPtr then return "" else peekUTFString strPtr -- @method buttonSetUseStock@ Set if the label is a stock identifier. -- Index: CheckButton.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/buttons/CheckButton.chs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CheckButton.chs 24 May 2002 09:43:24 -0000 1.2 +++ CheckButton.chs 9 Jul 2003 22:42:43 -0000 1.3 @@ -37,8 +37,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} @@ -57,7 +57,7 @@ -- the right of it. -- checkButtonNewWithLabel :: String -> IO CheckButton -checkButtonNewWithLabel lbl = withCString lbl (\strPtr -> +checkButtonNewWithLabel lbl = withUTFString lbl (\strPtr -> makeNewObject mkCheckButton $ liftM castPtr $ {#call unsafe check_button_new_with_label#} strPtr) @@ -68,7 +68,7 @@ -- the label to a underlined character. -- checkButtonNewWithMnemonic :: String -> IO CheckButton -checkButtonNewWithMnemonic lbl = withCString lbl (\strPtr -> +checkButtonNewWithMnemonic lbl = withUTFString lbl (\strPtr -> makeNewObject mkCheckButton $ liftM castPtr $ {#call unsafe check_button_new_with_mnemonic#} strPtr) Index: RadioButton.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/buttons/RadioButton.chs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- RadioButton.chs 5 Aug 2002 16:41:34 -0000 1.3 +++ RadioButton.chs 9 Jul 2003 22:42:43 -0000 1.4 @@ -48,8 +48,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} @@ -69,7 +69,7 @@ -- label to the right of the button. -- radioButtonNewWithLabel :: String -> IO RadioButton -radioButtonNewWithLabel lbl = withCString lbl $ \strPtr -> +radioButtonNewWithLabel lbl = withUTFString lbl $ \strPtr -> makeNewObject mkRadioButton $ liftM castPtr $ {#call unsafe radio_button_new_with_label#} nullPtr strPtr @@ -88,7 +88,7 @@ -- label and group. -- radioButtonNewJoinGroupWithLabel :: RadioButton -> String -> IO RadioButton -radioButtonNewJoinGroupWithLabel rb lbl = withCString lbl $ \strPtr -> +radioButtonNewJoinGroupWithLabel rb lbl = withUTFString lbl $ \strPtr -> makeNewObject mkRadioButton $ liftM castPtr $ {#call radio_button_new_with_label_from_widget#} rb strPtr Index: ToggleButton.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/buttons/ToggleButton.chs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ToggleButton.chs 24 May 2002 09:43:24 -0000 1.2 +++ ToggleButton.chs 9 Jul 2003 22:42:43 -0000 1.3 @@ -46,8 +46,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} @@ -66,7 +66,7 @@ -- @method toggleButtonNewWithLabel@ Create a toggleButton with a label in it. -- toggleButtonNewWithLabel :: String -> IO ToggleButton -toggleButtonNewWithLabel lbl = withCString lbl (\strPtr -> +toggleButtonNewWithLabel lbl = withUTFString lbl (\strPtr -> makeNewObject mkToggleButton $ liftM castPtr $ {#call unsafe toggle_button_new_with_label#} strPtr) |