Skip to content

Commit

Permalink
Fix gi struct code to use get/set (not Read/Write)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishmack committed Jun 12, 2016
1 parent 1484a67 commit 0af9e3c
Show file tree
Hide file tree
Showing 20 changed files with 110 additions and 117 deletions.
4 changes: 4 additions & 0 deletions run-new-build.sh
@@ -0,0 +1,4 @@
#!/bin/sh

leksah_datadir=`pwd` dist-newstyle/build/leksah-0.16.0.0/build/leksah/leksah $@

6 changes: 3 additions & 3 deletions src/IDE/Command.hs
Expand Up @@ -148,7 +148,7 @@ import GI.Gtk.Objects.VBox (vBoxNew)
import Graphics.UI.Editor.Parameters
(boxPackEnd', Packing(..), boxPackStart')
import GI.Gdk.Structs.EventKey
(eventKeyReadState, eventKeyReadKeyval, EventKey(..))
(getEventKeyState, getEventKeyKeyval, EventKey(..))
import GI.Gdk.Functions (keyvalToUnicode, keyvalName)
import GI.Gdk.Flags (ModifierType, ModifierType(..))
import GI.Gtk.Objects.AccelGroup (AccelGroup(..))
Expand Down Expand Up @@ -848,9 +848,9 @@ instrumentSecWindow win = do
--
handleSpecialKeystrokes :: IDERef -> EventKey -> IO Bool
handleSpecialKeystrokes ideR e = do
keyVal <- eventKeyReadKeyval e
keyVal <- getEventKeyKeyval e
name <- fromMaybe "" <$> keyvalName keyVal
mods <- eventKeyReadState e
mods <- getEventKeyState e
char <- toEnum . fromIntegral <$> keyvalToUnicode keyVal
liftIO $ (`reflectIDE` ideR) $ do
prefs' <- readIDE prefs
Expand Down
52 changes: 26 additions & 26 deletions src/IDE/Completion.hs
Expand Up @@ -79,22 +79,22 @@ import GI.Gtk.Objects.Paned
(panedSetPosition, panedGetPosition, panedGetChild2, Paned(..),
panedGetChild1, panedAdd2, panedAdd1)
import GI.Gdk.Structs.EventKey
(eventKeyReadKeyval, eventKeyReadState)
(getEventKeyKeyval, getEventKeyState)
import GI.Gdk.Functions
(pointerUngrab, pointerGrab, keyvalToUnicode, keyvalName)
import GI.Gtk.Interfaces.TreeModel
(treeModelGetPath, treeModelIterNChildren)
import GI.Gdk.Structs.EventButton
(eventButtonReadTime, eventButtonReadY, eventButtonReadX,
eventButtonReadButton)
(getEventButtonTime, getEventButtonY, getEventButtonX,
getEventButtonButton)
import GI.Gdk.Flags (EventMask(..))
import GI.Gdk.Objects.Cursor (noCursor)
import GI.Gdk.Structs.EventMotion
(eventMotionReadY, eventMotionReadX)
(getEventMotionY, getEventMotionX)
import GI.Gtk.Structs.TreePath (treePathGetIndices, TreePath(..))
import Graphics.UI.Frame.Rectangle
(rectangleReadHeight, rectangleReadWidth, rectangleReadY,
rectangleReadX, Rectangle(..))
(getRectangleHeight, getRectangleWidth, getRectangleY,
getRectangleX, Rectangle(..))
import GI.Gdk.Objects.Window (windowGetOrigin)
import qualified GI.Gdk.Objects.Window as Gdk (noWindow)
import GI.Gdk.Objects.Screen
Expand Down Expand Up @@ -235,9 +235,9 @@ addEventHandling window sourceView tree store isWordChar always = do
ideR <- ask
cidsPress <- TE.onKeyPress sourceView $ do
e <- lift ask
keyVal <- eventKeyReadKeyval e
keyVal <- getEventKeyKeyval e
name <- keyvalName keyVal
modifier <- eventKeyReadState e
modifier <- getEventKeyState e
char <- toEnum . fromIntegral <$> keyvalToUnicode keyVal
Just model <- treeViewGetModel tree
selection <- treeViewGetSelection tree
Expand Down Expand Up @@ -292,8 +292,8 @@ addEventHandling window sourceView tree store isWordChar always = do

cidsRelease <- TE.onKeyRelease sourceView $ do
e <- lift ask
name <- eventKeyReadKeyval e >>= keyvalName
modifier <- eventKeyReadState e
name <- getEventKeyKeyval e >>= keyvalName
modifier <- getEventKeyState e
case (name, modifier) of
(Just "BackSpace", _) -> do
liftIDE $ complete sourceView False
Expand All @@ -303,10 +303,10 @@ addEventHandling window sourceView tree store isWordChar always = do
resizeHandler <- liftIO $ newIORef Nothing

idButtonPress <- ConnectC window <$> onWidgetButtonPressEvent window (\e -> do
button <- eventButtonReadButton e
x <- eventButtonReadX e
y <- eventButtonReadY e
time <- eventButtonReadTime e
button <- getEventButtonButton e
x <- getEventButtonX e
y <- getEventButtonY e
time <- getEventButtonTime e

nullToNothing (widgetGetWindow window) >>= \case
Nothing -> return ()
Expand All @@ -330,8 +330,8 @@ addEventHandling window sourceView tree store isWordChar always = do
mbResize <- readIORef resizeHandler
case mbResize of
Just resize -> do
x <- eventMotionReadX e
y <- eventMotionReadY e
x <- getEventMotionX e
y <- getEventMotionY e
resize x y
return True
Nothing -> return False)
Expand All @@ -340,10 +340,10 @@ addEventHandling window sourceView tree store isWordChar always = do
mbResize <- liftIO $ readIORef resizeHandler
case mbResize of
Just resize -> do
x <- eventButtonReadX e
y <- eventButtonReadY e
x <- getEventButtonX e
y <- getEventButtonY e
resize x y
eventButtonReadTime e >>= pointerUngrab
getEventButtonTime e >>= pointerUngrab
liftIO $ writeIORef resizeHandler Nothing
return True
Nothing -> return False)
Expand Down Expand Up @@ -448,10 +448,10 @@ processResults window tree store sourceView wordStart options selectLCP isWordCh
let newOptions = List.filter (T.isPrefixOf newWordStart) options
forM_ (take 200 newOptions) (seqStoreAppend store)
rect <- getIterLocation sourceView start
startx <- rectangleReadX rect
starty <- rectangleReadY rect
width <- rectangleReadWidth rect
height <- rectangleReadHeight rect
startx <- getRectangleX rect
starty <- getRectangleY rect
width <- getRectangleWidth rect
height <- getRectangleHeight rect
(wWindow, hWindow) <- windowGetSize window
(x, y) <- bufferToWindowCoords sourceView (fromIntegral startx, fromIntegral (starty+height))
mbDrawWindow <- getWindow sourceView
Expand All @@ -461,8 +461,8 @@ processResults window tree store sourceView wordStart options selectLCP isWordCh
(_, ox, oy) <- windowGetOrigin drawWindow
Just namesSW <- nullToNothing $ widgetGetParent tree
rNames <- widgetGetAllocation namesSW
wNames <- rectangleReadWidth rNames
hNames <- rectangleReadHeight rNames
wNames <- getRectangleWidth rNames
hNames <- getRectangleHeight rNames
paned <- nullToNothing (widgetGetParent namesSW) >>= liftIO . unsafeCastTo Paned . fromJust
Just first <- nullToNothing $ panedGetChild1 paned
Just second <- nullToNothing $ panedGetChild2 paned
Expand All @@ -476,7 +476,7 @@ processResults window tree store sourceView wordStart options selectLCP isWordCh
top <- if monitorBelow /= monitor || (oy+fromIntegral y+hWindow) > hScreen
then do
sourceSW <- getScrolledWindow sourceView
hSource <- widgetGetAllocation sourceSW >>= rectangleReadHeight
hSource <- widgetGetAllocation sourceSW >>= getRectangleHeight
scrollToIter sourceView end 0.1 (Just (1.0, 1.0 - (fromIntegral hWindow / fromIntegral hSource)))
(_, newy) <- bufferToWindowCoords sourceView (fromIntegral startx, fromIntegral (starty+height))
return (oy+fromIntegral newy)
Expand Down
14 changes: 7 additions & 7 deletions src/IDE/Find.hs
Expand Up @@ -101,7 +101,7 @@ import Data.GI.Gtk.ModelView.CellLayout
import GI.Gtk.Interfaces.Editable
(afterEditableDeleteText, afterEditableInsertText)
import GI.Gdk.Structs.EventKey
(eventKeyReadState, eventKeyReadKeyval)
(getEventKeyState, getEventKeyKeyval)
import GI.Gdk.Functions (keyvalName)
import GI.Gdk.Flags (ModifierType(..))
import Data.GI.Base.GValue (IsGValue(..))
Expand Down Expand Up @@ -363,8 +363,8 @@ constructFindReplace = do
toggleToolButtonSetActive btn $ not old

onWidgetKeyPressEvent entry $ \e -> do
mbName <- eventKeyReadKeyval e >>= keyvalName
mods <- eventKeyReadState e
mbName <- getEventKeyKeyval e >>= keyvalName
mods <- getEventKeyState e
case mbName of
Just "Down" -> doSearch toolbar Forward ideR >> return True
Just "Up" -> doSearch toolbar Backward ideR >> return True
Expand All @@ -378,8 +378,8 @@ constructFindReplace = do
_ -> return False

onWidgetKeyPressEvent rentry $ \e -> do
mbName <- eventKeyReadKeyval e >>= keyvalName
mods <- eventKeyReadState e
mbName <- getEventKeyKeyval e >>= keyvalName
mods <- getEventKeyState e
case mbName of
Just name
| name == "Tab" || name == "ISO_Left_Tab" -> do
Expand All @@ -396,8 +396,8 @@ constructFindReplace = do
return True

onWidgetKeyPressEvent spinL $ \e -> do
mbName <- eventKeyReadKeyval e >>= keyvalName
mods <- eventKeyReadState e
mbName <- getEventKeyKeyval e >>= keyvalName
mods <- getEventKeyState e
case mbName of
Just "Escape" -> getOut ideR >> return True
Just "Tab" -> do
Expand Down
4 changes: 2 additions & 2 deletions src/IDE/NotebookFlipper.hs
Expand Up @@ -54,7 +54,7 @@ import GI.Gtk.Objects.Widget
(widgetShowAll, widgetDestroy, widgetHide, onWidgetKeyReleaseEvent)
import GI.GObject.Functions (signalHandlerDisconnect)
import GI.Gdk.Structs.EventKey
(eventKeyReadKeyval, eventKeyKeyval, EventKey(..))
(getEventKeyKeyval, EventKey(..))
import GI.Gdk.Functions (keyvalName)
import Data.GI.Gtk.ModelView.Types
(treeSelectionGetSelectedRows', treePathGetIndices',
Expand Down Expand Up @@ -187,7 +187,7 @@ initFlipper direction = do

handleKeyRelease :: TreeViewK alpha => alpha -> IDERef -> EventKey -> IO Bool
handleKeyRelease tree ideR e = do
name <- eventKeyReadKeyval e >>= keyvalName
name <- getEventKeyKeyval e >>= keyvalName
case name of
Just ctrl | (ctrl == "Control_L") || (ctrl == "Control_R") -> do
currentState' <- reflectIDE (readIDE currentState) ideR
Expand Down
4 changes: 2 additions & 2 deletions src/IDE/Pane/Grep.hs
Expand Up @@ -92,7 +92,7 @@ import GI.Gtk.Objects.Container (containerAdd)
import GI.Gtk.Objects.Widget
(widgetGrabFocus, onWidgetKeyPressEvent, afterWidgetFocusInEvent,
toWidget)
import GI.Gdk.Structs.EventKey (eventKeyReadKeyval)
import GI.Gdk.Structs.EventKey (getEventKeyKeyval)
import GI.Gdk.Functions (keyvalName)
import Data.GI.Gtk.ModelView.TreeModel
(treeModelGetIter, treeModelIterNChildren)
Expand Down Expand Up @@ -211,7 +211,7 @@ instance RecoverablePane IDEGrep GrepState IDEM where
return True
cid2 <- onIDE onWidgetKeyPressEvent treeView $ do
e <- lift ask
name <- eventKeyReadKeyval e >>= keyvalName
name <- getEventKeyKeyval e >>= keyvalName
liftIDE $
case name of
Just "Return" -> gotoSource True
Expand Down
12 changes: 6 additions & 6 deletions src/IDE/Pane/Log.hs
Expand Up @@ -116,8 +116,8 @@ import GI.Gtk.Enums
(TextWindowType(..), ShadowType(..), PolicyType(..))
import Control.Monad.Trans.Class (MonadTrans(..))
import GI.Gdk.Structs.EventButton
(eventButtonReadY, eventButtonReadX, eventButtonReadButton,
eventButtonReadType)
(getEventButtonY, getEventButtonX, getEventButtonButton,
getEventButtonType)
import GI.Gdk.Enums (EventType(..), EventType)
import Data.Word (Word32)
import GI.Gdk.Constants (pattern BUTTON_PRIMARY)
Expand Down Expand Up @@ -424,10 +424,10 @@ builder' pp nb windows = do
return False
cid2 <- onIDE onWidgetButtonPressEvent tv $ do
e <- lift ask
click <- eventButtonReadType e
button <- eventButtonReadButton e
x <- eventButtonReadX e
y <- eventButtonReadY e
click <- getEventButtonType e
button <- getEventButtonButton e
x <- getEventButtonX e
y <- getEventButtonY e
liftIDE $ clicked click (fromIntegral button) x y buf
return False
cid3 <- ConnectC tv <$> onTextViewPopulatePopup tv (\w ->
Expand Down
6 changes: 3 additions & 3 deletions src/IDE/Pane/Modules.hs
Expand Up @@ -135,7 +135,7 @@ import GI.Gtk.Objects.ScrolledWindow
import GI.Gtk.Objects.Adjustment (noAdjustment)
import GI.Gtk.Objects.Container (containerAdd)
import Graphics.UI.Frame.Rectangle
(rectangleReadY, rectangleReadX, Rectangle(..))
(getRectangleY, getRectangleX, Rectangle(..))
import GI.Gtk.Objects.HButtonBox (hButtonBoxNew)
import GI.Gtk.Objects.Box (boxReorderChild, Box(..), boxSetSpacing)
import GI.Gtk.Objects.ButtonBox (buttonBoxSetLayout)
Expand Down Expand Up @@ -392,8 +392,8 @@ instance RecoverablePane IDEModules ModulesState IDEM where
panedAdd1 pane' sw
panedAdd2 pane' sw2
rect <- widgetGetAllocation nb
x <- rectangleReadX rect
y <- rectangleReadY rect
x <- getRectangleX rect
y <- getRectangleY rect
panedSetPosition pane' (max 200 (x `quot` 2))
box <- hButtonBoxNew
boxSetSpacing box 2
Expand Down
10 changes: 5 additions & 5 deletions src/IDE/Pane/SourceBuffer.hs
Expand Up @@ -149,7 +149,7 @@ import GI.Gtk.Enums
(FileChooserAction(..), WindowPosition(..), ResponseType(..),
ButtonsType(..), MessageType(..), ShadowType(..), PolicyType(..))
import GI.Gdk.Structs.EventKey
(eventKeyReadState, eventKeyReadKeyval)
(getEventKeyState, getEventKeyKeyval)
import GI.Gdk.Functions (keyvalName)
import GI.Gdk.Flags (ModifierType(..))
import GI.Gtk.Flags (TextSearchFlags(..))
Expand All @@ -173,7 +173,7 @@ import Graphics.UI.Editor.Parameters
(dialogRun', dialogSetDefaultResponse', dialogAddButton')
import GI.Gtk.Objects.Clipboard (clipboardGet)
import GI.Gdk.Structs.Atom (atomIntern)
import GI.Gdk.Structs.EventButton (eventButtonReadType)
import GI.Gdk.Structs.EventButton (getEventButtonType)
import GI.Gdk.Enums (EventType(..))

--time :: MonadIO m => String -> m a -> m a
Expand Down Expand Up @@ -621,7 +621,7 @@ builder' bs mbfn ind bn rbn ct prefs fileContents modTime pp nb windows =
ids2 <- onCompletion sv (Completion.complete sv False) Completion.cancel
ids3 <- onButtonPress sv $ do
e <- lift ask
click <- eventButtonReadType e
click <- getEventButtonType e
liftIDE $
case click of
EventType2buttonPress -> do
Expand Down Expand Up @@ -672,9 +672,9 @@ builder' bs mbfn ind bn rbn ct prefs fileContents modTime pp nb windows =

ids6 <- onKeyPress sv $ do
e <- lift ask
keyval <- eventKeyReadKeyval e
keyval <- getEventKeyKeyval e
name <- keyvalName keyval
modifier <- eventKeyReadState e
modifier <- getEventKeyState e
liftIDE $ do
let moveToNextWord iterOp sel = do
sel' <- iterOp sel
Expand Down
6 changes: 3 additions & 3 deletions src/IDE/Pane/WebKit/Documentation.hs
Expand Up @@ -50,7 +50,7 @@ import GI.Gtk.Objects.Widget
import GI.Gtk.Objects.Adjustment (noAdjustment)
import GI.Gtk.Enums (PolicyType(..), ShadowType(..))
import GI.Gtk.Objects.Container (containerAdd)
import GI.Gdk (eventKeyReadState, keyvalName, eventKeyReadKeyval)
import GI.Gdk (getEventKeyState, keyvalName, getEventKeyKeyval)
import GI.Gdk.Flags (ModifierType(..))
import System.Log.Logger (debugM)
import Data.GI.Base.BasicTypes (NullToNothing(..))
Expand Down Expand Up @@ -101,8 +101,8 @@ instance RecoverablePane IDEDocumentation DocumentationState IDEM where
return True)

cid2 <- ConnectC webView <$> onWidgetKeyPressEvent webView (\e -> do
key <- eventKeyReadKeyval e >>= keyvalName
mod <- eventKeyReadState e
key <- getEventKeyKeyval e >>= keyvalName
mod <- getEventKeyState e
case (key, mod) of
(Just "plus", [ModifierTypeShiftMask,ModifierTypeControlMask]) -> webViewZoomIn webView >> return True
(Just "minus",[ModifierTypeControlMask]) -> webViewZoomOut webView >> return True
Expand Down
6 changes: 3 additions & 3 deletions src/IDE/Pane/WebKit/Output.hs
Expand Up @@ -64,7 +64,7 @@ import GI.Gtk.Objects.Adjustment (noAdjustment)
import GI.Gtk.Enums (PolicyType(..), ShadowType(..))
import Graphics.UI.Editor.Parameters (Packing(..), boxPackStart')
import GI.Gtk.Objects.Container (containerAdd)
import GI.Gdk (eventKeyReadState, eventKeyReadKeyval, keyvalName)
import GI.Gdk (getEventKeyState, getEventKeyKeyval, keyvalName)
import GI.Gdk.Flags (ModifierType(..))
import GI.Gtk.Objects.ToggleAction
(setToggleActionActive, toggleActionNew)
Expand Down Expand Up @@ -136,8 +136,8 @@ instance RecoverablePane IDEOutput OutputState IDEM where

-- webView `set` [webViewZoomLevel := 2.0]
cid2 <- ConnectC webView <$> onWidgetKeyPressEvent webView (\e -> do
key <- eventKeyReadKeyval e >>= keyvalName
mod <- eventKeyReadState e
key <- getEventKeyKeyval e >>= keyvalName
mod <- getEventKeyState e
case (key, mod) of
(Just "plus", [ModifierTypeShiftMask,ModifierTypeControlMask]) -> webViewZoomIn webView >> return True
(Just "minus",[ModifierTypeControlMask]) -> webViewZoomOut webView >> return True
Expand Down

5 comments on commit 0af9e3c

@jaccokrijnen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, the bindings do not export these get/setEventbutton functions:

[10 of 66] Compiling IDE.Utils.GUIUtils ( src/IDE/Utils/GUIUtils.hs, /home/jacco/projects/leksah/leksah/dist-newstyle/build/leksah-0.16.0.0/build/IDE/Utils/GUIUtils.o )

src/IDE/Utils/GUIUtils.hs:111:35-52:
    Module ‘GI.Gdk’ does not export ‘getEventButtonType’

src/IDE/Utils/GUIUtils.hs:111:55-69:
    Module ‘GI.Gdk’ does not export ‘getEventButtonY’

src/IDE/Utils/GUIUtils.hs:112:9-23:
    Module ‘GI.Gdk’ does not export ‘getEventButtonX’

src/IDE/Utils/GUIUtils.hs:112:26-43:
    Module ‘GI.Gdk’ does not export ‘getEventButtonTime’

src/IDE/Utils/GUIUtils.hs:112:46-65:
    Module ‘GI.Gdk’ does not export ‘getEventButtonButton’

I guess this is because of gtk 3.14? (This is with the new gi-* from hackage)

@hamishmack
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaccokrijnen try rm -rf dist-newstyle

@hamishmack
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaccokrijnen It looks like it has not picked up the latest haskell-gi code gen. I think the gi- packages do not automatically get rebuilt when haskell-gi changes. But because they depend on haskell-gi and haskell-gi is in dist-newstyle the will be there too. So deleting it should force a rebuild. Also I pushed some fixes for older Gtk+ just now and travis should hopefully pass them soon.

Make sure you have updated the submodules too as there are changes in them too.

@jaccokrijnen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hamishmack Hm, no difference it seems. This is the install plan:

jacco@xw4600:~/projects/leksah/leksah$ rm dist-newstyle/ -rf
jacco@xw4600:~/projects/leksah/leksah$ cabal update
Downloading the latest package list from hackage.haskell.org
jacco@xw4600:~/projects/leksah/leksah$ git pull
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 6 (delta 4), reused 5 (delta 4), pack-reused 0
Unpacking objects: 100% (6/6), done.
From https://github.com/leksah/leksah
   aa8cd91..070041a  master     -> upstream/master
   c2225d1..4f69990  new-build  -> upstream/new-build
Fetching submodule vendor/ltk
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 7 (delta 3), reused 7 (delta 3), pack-reused 0
Unpacking objects: 100% (7/7), done.
From https://github.com/leksah/ltk
   79b4fea..1a118a4  master     -> origin/master
Updating aa8cd91..070041a
Fast-forward
 vendor/ltk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
jacco@xw4600:~/projects/leksah/leksah$ cabal new-build
Resolving dependencies...
In order, the following will be built (use -v for more details):
haskell-gi-base-0.17
haskell-gi-0.17.4
gi-cairo-1.0.5
gi-glib-2.0.5
gi-gobject-2.0.5
gi-atk-2.0.5
gi-gio-2.0.5
gi-gdkpixbuf-2.0.5
gi-javascriptcore-3.0.5
gi-pango-1.0.5
gi-gdk-3.0.5
gi-gtk-3.0.5
gi-gtk-hs-0.3.0.0
gi-gtksource-3.0.5
gi-soup-2.4.5
gi-webkit-3.0.5
jsaddle-0.4.0.2
jsaddle-dom-0.1.0.3
ghcjs-dom-0.3.1.0
ltk-0.16.0.0
leksah-server-0.16.0.0
vcsgui-0.2.0.0
leksah-0.16.0.0

@jaccokrijnen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I forgot to git submodule update, trying again..

Please sign in to comment.