From: <as...@us...> - 2003-07-09 22:42:51
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/menuComboToolbar In directory sc8-pr-cvs1:/tmp/cvs-serv25460/gtk/menuComboToolbar Modified Files: CheckMenuItem.chs Combo.chs ImageMenuItem.chs Menu.chs MenuBar.chs MenuItem.chs MenuShell.chs OptionMenu.chs RadioMenuItem.chs TearoffMenuItem.chs Toolbar.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: CheckMenuItem.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/menuComboToolbar/CheckMenuItem.chs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- CheckMenuItem.chs 8 Nov 2002 10:39:21 -0000 1.4 +++ CheckMenuItem.chs 9 Jul 2003 22:42:44 -0000 1.5 @@ -40,8 +40,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} @@ -62,7 +62,7 @@ -- with a @ref data Label@ inside. -- checkMenuItemNewWithLabel :: String -> IO CheckMenuItem -checkMenuItemNewWithLabel str = withCString str $ \strPtr -> +checkMenuItemNewWithLabel str = withUTFString str $ \strPtr -> makeNewObject mkCheckMenuItem $ liftM castPtr $ {#call unsafe check_menu_item_new_with_label#} strPtr Index: Combo.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/menuComboToolbar/Combo.chs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Combo.chs 24 May 2002 09:43:25 -0000 1.2 +++ Combo.chs 9 Jul 2003 22:42:44 -0000 1.3 @@ -49,8 +49,8 @@ ) where import Monad (liftM, mapM_) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) import Widget (widgetShow) import Container(containerAdd) @@ -76,7 +76,7 @@ {#call list_clear_items#} list 0 (-1) mapM_ (\str -> do li <- makeNewObject mkWidget $ liftM castPtr $ - withCString str {#call unsafe list_item_new_with_label#} + withUTFString str {#call unsafe list_item_new_with_label#} widgetShow li containerAdd list li) strs Index: ImageMenuItem.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/menuComboToolbar/ImageMenuItem.chs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ImageMenuItem.chs 8 Nov 2002 10:39:21 -0000 1.3 +++ ImageMenuItem.chs 9 Jul 2003 22:42:44 -0000 1.4 @@ -43,8 +43,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} @@ -82,7 +82,7 @@ -- with a stock image. -- imageMenuItemNewFromStock :: String -> IO ImageMenuItem -imageMenuItemNewFromStock str = withCString str $ \strPtr -> +imageMenuItemNewFromStock str = withUTFString str $ \strPtr -> makeNewObject mkImageMenuItem $ liftM castPtr $ {#call unsafe image_menu_item_new_from_stock#} strPtr nullPtr @@ -90,7 +90,7 @@ -- with a label. -- imageMenuItemNewWithLabel :: String -> IO ImageMenuItem -imageMenuItemNewWithLabel str = withCString str $ \strPtr -> +imageMenuItemNewWithLabel str = withUTFString str $ \strPtr -> makeNewObject mkImageMenuItem $ liftM castPtr $ {#call unsafe image_menu_item_new_with_label#} strPtr @@ -98,6 +98,6 @@ -- with a label where underscored indicate the mnemonic. -- imageMenuItemNewWithMnemonic :: String -> IO ImageMenuItem -imageMenuItemNewWithMnemonic str = withCString str $ \strPtr -> +imageMenuItemNewWithMnemonic str = withUTFString str $ \strPtr -> makeNewObject mkImageMenuItem $ liftM castPtr $ {#call unsafe image_menu_item_new_with_mnemonic#} strPtr Index: Menu.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/menuComboToolbar/Menu.chs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Menu.chs 1 Dec 2002 14:09:51 -0000 1.5 +++ Menu.chs 9 Jul 2003 22:42:44 -0000 1.6 @@ -55,13 +55,12 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} -import Events (Event(..)) -import Structs (nullForeignPtr) +import Events (Event(Button), time, button) {# context lib="gtk" prefix="gtk" #} @@ -85,16 +84,16 @@ -- -- menuPopup :: MenuClass m => m -> Event -> IO () -menuPopup m (Button { time=t, button=b }) = {#call menu_popup#} (toMenu m) - (mkWidget nullForeignPtr) (mkWidget nullForeignPtr) nullFunPtr nullPtr - ((fromIntegral.fromEnum) b) (fromIntegral t) +menuPopup m (Events.Button { time=t, button=b }) = {#call menu_popup#} + (toMenu m) (mkWidget nullForeignPtr) (mkWidget nullForeignPtr) nullFunPtr + nullPtr ((fromIntegral.fromEnum) b) (fromIntegral t) menuPopup _ _ = error "menuPopup: Button event expected." -- @method menuSetTitle@ Set the @ref arg title@ of the menu. It is displayed -- if the menu is shown as a tearoff menu. -- menuSetTitle :: MenuClass m => m -> String -> IO () -menuSetTitle m title = withCString title $ \strPtr -> +menuSetTitle m title = withUTFString title $ \strPtr -> {#call unsafe menu_set_title#} (toMenu m) strPtr -- @method menuPopdown@ Remove a context or tearoff menu from the screen. Index: MenuBar.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/menuComboToolbar/MenuBar.chs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- MenuBar.chs 19 Dec 2002 18:13:39 -0000 1.3 +++ MenuBar.chs 9 Jul 2003 22:42:44 -0000 1.4 @@ -35,8 +35,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} Index: MenuItem.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/menuComboToolbar/MenuItem.chs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- MenuItem.chs 5 Aug 2002 16:41:34 -0000 1.3 +++ MenuItem.chs 9 Jul 2003 22:42:44 -0000 1.4 @@ -62,8 +62,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} @@ -83,7 +83,7 @@ -- inside. -- menuItemNewWithLabel :: String -> IO MenuItem -menuItemNewWithLabel label = withCString label $ \strPtr -> +menuItemNewWithLabel label = withUTFString label $ \strPtr -> makeNewObject mkMenuItem $ liftM castPtr $ {#call unsafe menu_item_new_with_label#} strPtr Index: MenuShell.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/menuComboToolbar/MenuShell.chs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- MenuShell.chs 24 May 2002 09:43:25 -0000 1.2 +++ MenuShell.chs 9 Jul 2003 22:42:44 -0000 1.3 @@ -53,8 +53,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} Index: OptionMenu.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/menuComboToolbar/OptionMenu.chs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- OptionMenu.chs 24 May 2002 09:43:25 -0000 1.2 +++ OptionMenu.chs 9 Jul 2003 22:42:44 -0000 1.3 @@ -42,8 +42,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} Index: RadioMenuItem.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/menuComboToolbar/RadioMenuItem.chs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- RadioMenuItem.chs 24 May 2002 09:43:25 -0000 1.2 +++ RadioMenuItem.chs 9 Jul 2003 22:42:44 -0000 1.3 @@ -41,8 +41,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} @@ -61,7 +61,7 @@ -- label in it. -- radioMenuItemNewWithLabel :: String -> IO RadioMenuItem -radioMenuItemNewWithLabel label = withCString label $ \strPtr -> +radioMenuItemNewWithLabel label = withUTFString label $ \strPtr -> makeNewObject mkRadioMenuItem $ liftM castPtr $ {#call unsafe radio_menu_item_new_with_label#} nullPtr strPtr @@ -81,7 +81,7 @@ IO RadioMenuItem radioMenuItemNewJoinGroupWithLabel rmi label = do groupPtr <- {#call unsafe radio_menu_item_get_group#} rmi - withCString label $ \strPtr -> + withUTFString label $ \strPtr -> makeNewObject mkRadioMenuItem $ liftM castPtr $ {#call unsafe radio_menu_item_new_with_label#} groupPtr strPtr Index: TearoffMenuItem.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/menuComboToolbar/TearoffMenuItem.chs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- TearoffMenuItem.chs 24 May 2002 09:43:25 -0000 1.2 +++ TearoffMenuItem.chs 9 Jul 2003 22:42:44 -0000 1.3 @@ -43,8 +43,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} Index: Toolbar.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/menuComboToolbar/Toolbar.chs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Toolbar.chs 24 Mar 2003 23:56:39 -0000 1.5 +++ Toolbar.chs 9 Jul 2003 22:42:44 -0000 1.6 @@ -88,14 +88,14 @@ import Monad (liftM) import Maybe (fromJust, fromMaybe) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} import Enums (Orientation(..), ToolbarStyle(..)) import Structs (toolbarGetSize', toolbarChildButton, toolbarChildToggleButton, - toolbarChildRadioButton, nullForeignPtr, IconSize, + toolbarChildRadioButton, IconSize, iconSizeInvalid, iconSizeSmallToolbar, iconSizeLargeToolbar) import StockItems(stockLookupItem, siLabel, stockMissingImage) import Image (imageNewFromStock) @@ -114,8 +114,8 @@ -- mkToolText :: Maybe (String,String) -> (CString -> CString -> IO a) -> IO a mkToolText Nothing fun = fun nullPtr nullPtr -mkToolText (Just (text,private)) fun = withCString text $ \txtPtr -> - withCString private $ \prvPtr -> fun txtPtr prvPtr +mkToolText (Just (text,private)) fun = withUTFString text $ \txtPtr -> + withUTFString private $ \prvPtr -> fun txtPtr prvPtr -- @method toolbarInsertNewButton@ Insert a new @ref data Button@ into the -- @ref data Toolbar@. @@ -137,7 +137,7 @@ toolbarInsertNewButton :: ToolbarClass tb => tb -> Int -> String -> Maybe (String,String) -> IO Button toolbarInsertNewButton tb pos stockId tooltips = - withCString stockId $ \stockPtr -> + withUTFString stockId $ \stockPtr -> mkToolText tooltips $ \textPtr privPtr -> makeNewObject mkButton $ liftM castPtr $ {#call unsafe toolbar_insert_stock#} (toToolbar tb) stockPtr textPtr privPtr @@ -180,7 +180,7 @@ size <- toolbarGetSize' (toToolbar tb) image <- imageNewFromStock stockId size makeNewObject mkToggleButton $ liftM castPtr $ - withCString label $ \lblPtr -> mkToolText tooltips $ \textPtr privPtr -> + withUTFString label $ \lblPtr -> mkToolText tooltips $ \textPtr privPtr -> {#call unsafe toolbar_insert_element#} (toToolbar tb) toolbarChildToggleButton (mkWidget nullForeignPtr) lblPtr textPtr privPtr (toWidget image) nullFunPtr nullPtr (fromIntegral pos) @@ -234,7 +234,7 @@ size <- toolbarGetSize' (toToolbar tb) image <- imageNewFromStock stockId size makeNewObject mkRadioButton $ liftM castPtr $ - withCString label $ \lblPtr -> mkToolText tooltips $ \textPtr privPtr -> + withUTFString label $ \lblPtr -> mkToolText tooltips $ \textPtr privPtr -> {#call unsafe toolbar_insert_element#} (toToolbar tb) toolbarChildRadioButton (maybe (mkWidget nullForeignPtr) toWidget rb) lblPtr textPtr privPtr (toWidget image) nullFunPtr nullPtr |