我可以安装不属于 LTS 软件包集的依赖项吗?

问题描述 投票:0回答:1

我正在尝试通过堆栈在Windows10上构建gi-gtk-4.0.8。但最新的LTS版本只有3.0.41。我能够建造。例如,我在 hackage 网站上看到 ArchLinux 版本 4.0.8 可用。我已经安装了 22.18 LTS 版本以及 3.0.41 gi-gtk 软件包。

你能指出我正确的方向吗?我对编程有点陌生,我不知道我做错了什么。谢谢你

我上传了在 Hackage 上找到的 gi-gtk 列出版本的图片。enter image description here

My GHC version is 9.6.4, using Stack 2.13.1

我正在尝试使用 Haskell 语言进行编码。

首先,我尝试修改 package.yaml 文件,在我指定使用的依赖项中 - gi-gtk >= 4.0 && <5 (https://i.stack.imgur.com/tj25w.png)

但是它抛出了错误:

stack build

Error: [S-4804]
       Stack failed to construct a build plan.
       
       While constructing the build plan, Stack encountered the following errors. The 'Stack
       configuration' refers to the set of package versions specified by the snapshot (after any
       dropped packages, or pruned GHC boot packages; if a boot package is replaced, Stack prunes
       all other such packages that depend on it) and any extra-deps:
       
       In the dependencies for gtk-intro-seven-0.1.0.0:
         * gi-gtk must match >=4.0 && <5, but gi-gtk-3.0.41 is in the Stack configuration (latest
           matching version is 4.0.8).
       needed since gtk-intro-seven is a build target.
       
       Some different approaches to resolving some or all of this:
       
         * To ignore all version constraints and build anyway, in
           C:\Users\bu\AppData\Roaming\stack\config.yaml (global configuration) or
           D:\stack-projects\gtk-intro-seven\stack.yaml (project-level configuration), set
           allow-newer: true.
         
         * To ignore certain version constraints and build anyway, also add these package names
           under allow-newer-deps: gtk-intro-seven.
         
         * Recommended action: try adding the following to your extra-deps in
           D:\stack-projects\gtk-intro-seven\stack.yaml (project-level configuration):
           
           - gi-gtk-4.0.8@sha256:6011c2d7880c6f9b1a319a593db6b76e5175b3f020fc4b3ca86707ee70c3a1d8,35759

Compilation exited abnormally with code 1 at Wed Apr 24 15:14:13

然后我尝试修改 stack.yaml 中的额外 deps 添加建议 - gi-gtk-4.0.8@sha256:6011c2d7880c6f9b1a319a593db6b76e5175b3f020fc4b3ca86707ee70c3a1d8,35759

但是它抛出了错误:

stack build

Error: [S-4804]
       Stack failed to construct a build plan.
       
       While constructing the build plan, Stack encountered the following errors. The 'Stack
       configuration' refers to the set of package versions specified by the snapshot (after any
       dropped packages, or pruned GHC boot packages; if a boot package is replaced, Stack prunes
       all other such packages that depend on it) and any extra-deps:
       
       In the dependencies for gi-gtk-4.0.8:
         * gi-gdk must match >=4.0 && <4.1, but gi-gdk-3.0.28 is in the Stack configuration (latest
           matching version is 4.0.7).
         * gi-gsk must match >=4.0 && <4.1, but no version is in the Stack configuration (latest
           matching version is 4.0.7).
       needed due to gtk-intro-seven-0.1.0.0 -> gi-gtk-4.0.8
       
       Some different approaches to resolving some or all of this:
       
         * To ignore certain version constraints and build anyway, in
           C:\Users\bu\AppData\Roaming\stack\config.yaml (global configuration) or
           D:\stack-projects\gtk-intro-seven\stack.yaml (project-level configuration), set
           allow-newer: true and add these package names under allow-newer-deps: gi-gtk.
         
         * Recommended action: try adding the following to your extra-deps in
           D:\stack-projects\gtk-intro-seven\stack.yaml (project-level configuration):
           
           - gi-gdk-4.0.7@sha256:e1915be39e2eebaf445584986dea7b750aef57c00894d1a218a54811da27b381,9025
           - gi-gsk-4.0.7@sha256:1c96f0d0fdc39b1dfa3314cb00e57cb39931bd7f1a125fb0890435fcae624952,7393

Compilation exited abnormally with code 1 at Wed Apr 24 14:56:30

我再次按照建议修改了 stack.yaml 设置allow-newer: true 和allow-newer-deps: gi-gtk

但是它抛出了错误

stack build

Warning: Ignoring gi-gtk's bounds on gi-gdk (>=4.0 && <4.1) and using gi-gdk-3.0.28.
         Reason: gi-gtk is an allow-newer-dep and allow-newer enabled.

Error: [S-4804]
       Stack failed to construct a build plan.
       
       While constructing the build plan, Stack encountered the following errors. The 'Stack
       configuration' refers to the set of package versions specified by the snapshot (after any
       dropped packages, or pruned GHC boot packages; if a boot package is replaced, Stack prunes
       all other such packages that depend on it) and any extra-deps:
       
       In the dependencies for gi-gtk-4.0.8:
         * gi-gsk must match >=4.0 && <4.1, but no version is in the Stack configuration (latest
           matching version is 4.0.7).
       needed due to gtk-intro-seven-0.1.0.0 -> gi-gtk-4.0.8
       
       Some different approaches to resolving some or all of this:
       
         * Recommended action: try adding the following to your extra-deps in
           D:\stack-projects\gtk-intro-seven\stack.yaml (project-level configuration):
           
           - gi-gsk-4.0.7@sha256:1c96f0d0fdc39b1dfa3314cb00e57cb39931bd7f1a125fb0890435fcae624952,7393

Compilation exited abnormally with code 1 at Wed Apr 24 15:02:06

此时,感觉好像在兜圈子,即使在尝试将建议的 - gi-gsk-4.0.7@sha256:1c96f0d0fdc39b1dfa3314cb00e57cb39931bd7f1a125fb0890435fcae624952 添加到 stack.yaml 后,它也会抛出错误

stack build

Warning: Ignoring gi-gtk's bounds on gi-gdk (>=4.0 && <4.1) and using gi-gdk-3.0.28.
         Reason: gi-gtk is an allow-newer-dep and allow-newer enabled.

Warning: Not ignoring gi-gsk's bounds on gi-gdk (>=4.0 && <4.1) and using gi-gdk-3.0.28.
         Reason: gi-gsk is not an allow-newer-dep although allow-newer enabled.

Error: [S-4804]
       Stack failed to construct a build plan.
       
       While constructing the build plan, Stack encountered the following errors. The 'Stack
       configuration' refers to the set of package versions specified by the snapshot (after any
       dropped packages, or pruned GHC boot packages; if a boot package is replaced, Stack prunes
       all other such packages that depend on it) and any extra-deps:
       
       In the dependencies for gi-gsk-4.0.7:
         * gi-gdk must match >=4.0 && <4.1, but gi-gdk-3.0.28 is in the Stack configuration (latest
           matching version is 4.0.7).
       needed due to gtk-intro-seven-0.1.0.0 -> gi-gsk-4.0.7
       
       Some different approaches to resolving some or all of this:
       
         * To ignore all version constraints and build anyway, in
           C:\Users\bu\AppData\Roaming\stack\config.yaml (global configuration) or
           D:\stack-projects\gtk-intro-seven\stack.yaml (project-level configuration), set
           allow-newer: true.
         
         * To ignore certain version constraints and build anyway, also add these package names
           under allow-newer-deps: gi-gsk.
         
         * Recommended action: try adding the following to your extra-deps in
           D:\stack-projects\gtk-intro-seven\stack.yaml (project-level configuration):
           
           - gi-gdk-4.0.7@sha256:e1915be39e2eebaf445584986dea7b750aef57c00894d1a218a54811da27b381,9025

Compilation exited abnormally with code 1 at Wed Apr 24 15:04:43

我尝试在allow-newer-deps中添加gi-gsk,它确实开始编译,但我收到错误消息> [3 of 3] Linking C:\Users(myusername)\AppData\Local\Temp\stack-a9e044207bc0d717\ gi-graphene-1.0.7.stack-work\dist b060f89\setup\setup.exe gi-graphene > 在 ["C:\Program Files\gir-1.0","/opt/homebrew/share/gir-1.0"] 中找不到 Graphene-1.0 的 GI 存储库。

虽然它正在编译并且它说它忽略了 gi-gdk 的界限,但它仍然退回到 gi-gdk-3.0.28 版本。 :(

这是完整的消息

stack build

Warning: Ignoring gi-gtk's bounds on gi-gdk (>=4.0 && <4.1) and using gi-gdk-3.0.28.
         Reason: gi-gtk is an allow-newer-dep and allow-newer enabled.

Warning: Ignoring gi-gsk's bounds on gi-gdk (>=4.0 && <4.1) and using gi-gdk-3.0.28.
         Reason: gi-gsk is an allow-newer-dep and allow-newer enabled.
blaze-builder         > using precompiled package
cabal-doctest         > using precompiled package
colour                > using precompiled package
data-default-class    > using precompiled package
haskell-gi-base       > using precompiled package
haskell-gi-overloading> using precompiled package
haskell-lexer         > using precompiled package
integer-logarithms    > using precompiled package
os-string             > using precompiled package
primitive             > using precompiled package
regex-base            > using precompiled package
happy                 > configure
happy                 > Configuring happy-1.20.1.1...
blaze-markup          > using precompiled package
safe                  > using precompiled package
ansi-terminal-types   > using precompiled package
split                 > using precompiled package
splitmix              > using precompiled package
unliftio-core         > using precompiled package
vector-stream         > using precompiled package
xdg-basedir           > using precompiled package
happy                 > build
hashable              > using precompiled package
happy                 > Preprocessing executable 'happy' for happy-1.20.1.1..
happy                 > Building executable 'happy' for happy-1.20.1.1..
xml-types             > using precompiled package
regex-tdfa            > using precompiled package
blaze-html            > using precompiled package
zlib                  > using precompiled package
ansi-terminal         > using precompiled package
random                > using precompiled package
resourcet             > using precompiled package
vector                > using precompiled package
async                 > using precompiled package
scientific            > using precompiled package
unordered-containers  > using precompiled package
happy                 > [ 1 of 19] Compiling AbsSyn
happy                 > [ 2 of 19] Compiling GenUtils
happy                 > [ 3 of 19] Compiling NameSet
happy                 > [ 4 of 19] Compiling ParamRules
temporary             > using precompiled package
happy                 > [ 5 of 19] Compiling ParseMonad
happy                 > [ 6 of 19] Compiling Lexer
bitvec                > using precompiled package
typed-process         > using precompiled package
attoparsec            > using precompiled package
network               > using precompiled package
happy                 > [ 7 of 19] Compiling AttrGrammar
vector-algorithms     > using precompiled package
happy                 > [ 8 of 19] Compiling AttrGrammarParser
happy                 > [ 9 of 19] Compiling Grammar
streaming-commons     > using precompiled package
mono-traversable      > using precompiled package
conduit               > using precompiled package
happy                 > [10 of 19] Compiling LALR
conduit-extra         > using precompiled package
xml-conduit           > using precompiled package
happy                 > [11 of 19] Compiling First
happy                 > [12 of 19] Compiling Parser
happy                 > [13 of 19] Compiling Paths_happy
happy                 > [14 of 19] Compiling Info
happy                 > [15 of 19] Compiling PrettyGrammar
happy                 > [16 of 19] Compiling ProduceGLRCode
happy                 > [17 of 19] Compiling Target
happy                 > [18 of 19] Compiling ProduceCode
happy                 > [19 of 19] Compiling Main
happy                 > 
happy                 > C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\happy-1.20.1.1\src\Main.lhs:35:3: warning: [-Wunused-imports]
happy                 >     The import of `Foreign.Marshal.Array' is redundant
happy                 >       except perhaps to import instances from `Foreign.Marshal.Array'
happy                 >     To import instances alone, use: import Foreign.Marshal.Array()
happy                 >    |
happy                 > 35 | > import Foreign.Marshal.Array
happy                 >    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
happy                 > 
happy                 > C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\happy-1.20.1.1\src\Main.lhs:36:3: warning: [-Wunused-imports]
happy                 >     The import of `Foreign' is redundant
happy                 >       except perhaps to import instances from `Foreign'
happy                 >     To import instances alone, use: import Foreign()
happy                 >    |
happy                 > 36 | > import Foreign
happy                 >    |   ^^^^^^^^^^^^^^
happy                 > 
happy                 > C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\happy-1.20.1.1\src\Main.lhs:37:3: warning: [-Wunused-imports]
happy                 >     The import of `Foreign.C' is redundant
happy                 >       except perhaps to import instances from `Foreign.C'
happy                 >     To import instances alone, use: import Foreign.C()
happy                 >    |
happy                 > 37 | > import Foreign.C
happy                 >    |   ^^^^^^^^^^^^^^^^
happy                 > [20 of 20] Linking .stack-work\dist\ab060f89\build\happy\happy.exe
happy                 > copy/register
happy                 > Installing executable happy in C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\bin
pretty-show           > configure
pretty-show           > Configuring pretty-show-1.10...
pretty-show           > build
pretty-show           > Preprocessing library for pretty-show-1.10..
pretty-show           > Building library for pretty-show-1.10..
pretty-show           > [1 of 6] Compiling Paths_pretty_show
pretty-show           > [2 of 6] Compiling Text.Show.Value
pretty-show           > 
pretty-show           > C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\pretty-show-1.10\Text\Show\Value.hs:84:27: warning: [GHC-62161] [-Wincomplete-uni-patterns]
pretty-show           >     Pattern match(es) are non-exhaustive
pretty-show           >     In a pattern binding: Patterns of type `[Value]' not matched: []
pretty-show           >    |
pretty-show           > 84 |         | otherwise -> do ~(v1:vs1) <- delMany (v:vs)
pretty-show           >    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
pretty-show           > 
pretty-show           > C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\pretty-show-1.10\Text\Show\Value.hs:93:25: warning: [GHC-62161] [-Wincomplete-uni-patterns]
pretty-show           >     Pattern match(es) are non-exhaustive
pretty-show           >     In a pattern binding:
pretty-show           >         Patterns of type `[Value]' not matched:
pretty-show           >             []
pretty-show           >             [_]
pretty-show           >             (_:_:_:_)
pretty-show           >    |
pretty-show           > 93 |       Ratio v1 v2 -> do ~[a,b] <- delMany [v1,v2]
pretty-show           >    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^
pretty-show           > [3 of 6] Compiling Text.Show.PrettyVal
pretty-show           > [4 of 6] Compiling Text.Show.Parser
pretty-show           > [5 of 6] Compiling Text.Show.Html
pretty-show           > 
pretty-show           > C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\pretty-show-1.10\Text\Show\Html.hs:112:1: warning: [-Wunused-top-binds]
pretty-show           >     Defined but not used: `tallTuple'
pretty-show           >     |
pretty-show           > 112 | tallTuple els = table "tallTuple" $ map (tr . return . td) els
pretty-show           >     | ^^^^^^^^^
pretty-show           > [6 of 6] Compiling Text.Show.Pretty
pretty-show           > 
pretty-show           > C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\pretty-show-1.10\Text\Show\Pretty.hs:52:22: warning: [-Wunused-imports]
pretty-show           >     The import of `Foldable' from module `Data.Foldable' is redundant
pretty-show           >    |
pretty-show           > 52 | import Data.Foldable(Foldable,toList)
pretty-show           >    |                      ^^^^^^^^
pretty-show           > Preprocessing executable 'ppsh' for pretty-show-1.10..
pretty-show           > Building executable 'ppsh' for pretty-show-1.10..
pretty-show           > [1 of 2] Compiling Main
pretty-show           > [2 of 2] Compiling Paths_pretty_show
pretty-show           > [3 of 3] Linking .stack-work\dist\ab060f89\build\ppsh\ppsh.exe
pretty-show           > copy/register
pretty-show           > Installing library in C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\lib\x86_64-windows-ghc-9.6.4\pretty-show-1.10-7QJQR28ntpqAaVVCcnieFO
pretty-show           > Installing executable ppsh in C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\bin
pretty-show           > Registering library for pretty-show-1.10..
haskell-gi            > using precompiled package
gi-cairo              > using precompiled package
gi-freetype2          > using precompiled package
gi-glib               > using precompiled package
gi-gmodule            > using precompiled package
gi-gobject            > using precompiled package
gi-gio                > using precompiled package
gi-harfbuzz           > using precompiled package
gi-atk                > using precompiled package
gi-gdkpixbuf          > using precompiled package
gi-pango              > using precompiled package
gi-gdk                > using precompiled package
gi-graphene           > configure
gi-graphene           > [1 of 3] Compiling Main             ( C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\gi-graphene-1.0.7\Setup.hs, C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\gi-graphene-1.0.7\.stack-work\dist\ab060f89\setup\Main.o )
gi-graphene           > [2 of 3] Compiling StackSetupShim   ( C:\Users\bu\AppData\Roaming\stack\setup-exe-src\setup-shim-9p6GVs8J.hs, C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\gi-graphene-1.0.7\.stack-work\dist\ab060f89\setup\StackSetupShim.o )
gi-graphene           > [3 of 3] Linking C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\gi-graphene-1.0.7\.stack-work\dist\ab060f89\setup\setup.exe
gi-graphene           > Did not find a GI repository for Graphene-1.0 in ["C:\\Program Files\\gir-1.0","/opt/homebrew/share/gir-1.0"].
gi-graphene           > CallStack (from HasCallStack):
gi-graphene           >   error, called at lib\Data\GI\GIR\Repository.hs:94:20 in haskell-gi-0.26.8-BZLvOUaH1kP82JAb00n5xq:Data.GI.GIR.Repository

Error: [S-7282]
       Stack failed to execute the build plan.
       
       While executing the build plan, Stack encountered the error:
       
       [S-7011]
       While building package gi-graphene-1.0.7 (scroll up to its section to see the error) using:
       C:\Users\bu\AppData\Local\Temp\stack-a9e044207bc0d717\gi-graphene-1.0.7\.stack-work\dist\ab060f89\setup\setup --verbose=1 --builddir=.stack-work\dist\ab060f89 configure --with-ghc=C:\Users\bu\AppData\Local\Programs\stack\x86_64-windows\ghc-9.6.4\bin\ghc-9.6.4.exe --with-ghc-pkg=C:\Users\bu\AppData\Local\Programs\stack\x86_64-windows\ghc-9.6.4\bin\ghc-pkg-9.6.4.exe --user --package-db=clear --package-db=global --package-db=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\pkgdb --libdir=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\lib --bindir=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\bin --datadir=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\share --libexecdir=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\libexec --sysconfdir=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\etc --docdir=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\doc\gi-graphene-1.0.7 --htmldir=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\doc\gi-graphene-1.0.7 --haddockdir=C:\Users\bu\AppData\Roaming\stack\snapshots\9d56189b\doc\gi-graphene-1.0.7 --dependency=Cabal=Cabal-3.10.1.0 --dependency=base=base-4.18.2.0 --dependency=bytestring=bytestring-0.11.5.3 --dependency=containers=containers-0.6.7 --dependency=gi-glib=gi-glib-2.0.29-LSlYN00ugpvDuZbItzaRkx --dependency=gi-gobject=gi-gobject-2.0.30-Jg9NCcBQUdtHGMnuLld8Lp --dependency=haskell-gi=haskell-gi-0.26.8-BZLvOUaH1kP82JAb00n5xq --dependency=haskell-gi-base=haskell-gi-base-0.26.4-KnYJdEEMlhpJUcSA5ahpRO --dependency=haskell-gi-overloading=haskell-gi-overloading-1.0-6w3IXGDooXgu3RA2LfTuf --dependency=text=text-2.0.2 --dependency=transformers=transformers-0.6.1.0 --extra-include-dirs=C:\Users\bu\AppData\Local\Programs\stack\x86_64-windows\msys2-20230526\mingw64\include --extra-lib-dirs=C:\Users\bu\AppData\Local\Programs\stack\x86_64-windows\msys2-20230526\mingw64\lib --extra-lib-dirs=C:\Users\bu\AppData\Local\Programs\stack\x86_64-windows\msys2-20230526\mingw64\bin --exact-configuration --ghc-option=-fhide-source-paths
       Process exited with code: ExitFailure 1 

Compilation exited abnormally with code 1 at Wed Apr 24 15:29:16
haskell emacs gtk hackage stackage
1个回答
0
投票

对于紧密耦合的包,如

gi-gtk
gi-gdk
,没有办法让一个包的新版本与另一个包的旧版本一起使用,所以在这种情况下,建议设置
allow-newer
和/或
 allow-newer-deps
是个糟糕的建议。相反,您需要遵循备用建议,并不断向
extra-deps
添加相关软件包的新版本,直到 Stack 停止抱怨。

这可能是一场噩梦,但在这种情况下还不算太糟糕。我能够使用以下 stack.yaml 文件在此处构建并运行

Gtk4 测试程序,该文件使用最新的 LTS 22.18,并且仅覆盖 
gi-gtk
gi-gdk
gi-gsk
 的版本:

resolver: lts-22.18 packages: - . extra-deps: - gi-gtk-4.0.8 - gi-gdk-4.0.7 - gi-gsk-4.0.7
我的阴谋集团文件没什么特别的。除了 

build-depends

 子句之外,它完全是通用的(来自模板)。我为 
gi-gtk
 指定了一些版本要求,尽管这些实际上并不是必需的,因为 Stack 将使用 
gi-gtk
 文件的 
extra-deps
 子句中指定的 
stack.yaml
 版本:

build-depends: base >= 4.7 && < 5 , gi-gtk >= 4.0 && < 5 , haskell-gi-base
(这是在安装了 

gnome-devel

 软件包的 Debian Linux 系统上,以满足所有构建依赖项。)

我使用的全套文件如下:

stack.yaml

resolver: lts-22.18 packages: - . extra-deps: - gi-gtk-4.0.8 - gi-gdk-4.0.7 - gi-gsk-4.0.7

gtk4test.cabal

name: gtk4test version: 0.1.0.0 -- synopsis: -- description: author: maintainer: copyright: category: build-type: Simple cabal-version: >=1.10 executable main main-is: Main.hs default-language: Haskell2010 build-depends: base >= 4.7 && < 5 , gi-gtk >= 4.0 && < 5 , haskell-gi-base ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints

Setup.hs

import Distribution.Simple main = defaultMain{-# LANGUAGE OverloadedStrings, OverloadedLabels, ImplicitParams #-}

Main.hs

参见

https://github.com/haskell-gi/haskell-gi/blob/master/examples/Gtk4/gtk4-example.hs

import Control.Monad (void) import System.Environment (getArgs, getProgName) import Data.Int (Int32) import qualified GI.Gtk as Gtk import Data.GI.Base -- | An example of a signal callback accessing the ?self parameter -- (that is, the object raising the callback). See -- https://github.com/haskell-gi/haskell-gi/issues/346 -- for why this is necessary when dealing with even controllers in gtk4. pressedCB :: (?self :: Gtk.GestureClick) => Int32 -> Double -> Double -> IO () pressedCB nPress x y = do button <- #getCurrentButton ?self putStrLn $ "Button pressed: " <> show nPress <> " " <> show x <> " " <> show y <> " button: " <> show button activate :: Gtk.Application -> IO () activate app = do box <- new Gtk.Box [#orientation := Gtk.OrientationVertical] adjustment <- new Gtk.Adjustment [#value := 50, #lower := 0, #upper := 100, #stepIncrement := 1] slider <- new Gtk.Scale[#adjustment := adjustment, #drawValue := True] #append box slider spinButton <- new Gtk.SpinButton [#adjustment := adjustment] #append box spinButton controller <- new Gtk.GestureClick [After #pressed pressedCB] #addController slider controller window <- new Gtk.ApplicationWindow [#application := app, #title := "Hello", #child := box] #show window main :: IO () main = do app <- new Gtk.Application [#applicationId := "haskell-gi.Gtk4.test", On #activate (activate ?self)] -- If the application does not need to parse command line arguments -- just pass Nothing. args <- getArgs progName <- getProgName void $ #run app (Just $ progName : args)
    
© www.soinside.com 2019 - 2024. All rights reserved.