Require GTK >= 4.10

This commit is contained in:
sheaf 2024-10-23 14:49:22 +02:00
parent 6ecfebd397
commit 60287fbf7e
3 changed files with 3 additions and 38 deletions

View file

@ -29,13 +29,6 @@ flag asserts
default: False
manual: True
-- Workaround for https://github.com/haskell/cabal/issues/4237
-- See https://github.com/commercialhaskell/stack/issues/2197
flag gtk-410
description: GTK is 4.10 or later
default: True
manual: False
common common
build-depends:
@ -165,13 +158,8 @@ common gtk
, haskell-gi-base
>= 0.26.8 && < 0.27
-- Workaround for https://github.com/haskell/cabal/issues/4237
-- See https://github.com/commercialhaskell/stack/issues/2197
if flag(gtk-410)
pkgconfig-depends: gtk4 >= 4.10
cpp-options: -DMIN_VERSION_GTK_4_10
else
pkgconfig-depends: gtk4 < 4.10
pkgconfig-depends:
gtk4 >= 4.10
library metabrushes

View file

@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-deprecations #-}
@ -94,12 +93,5 @@ getColours
getColours _provider =
for colourNames \ ( ColourName { colourName } ) -> do
widget <- GTK.fixedNew
#if MIN_VERSION_GTK_4_10
GTK.widgetAddCssClass widget colourName
GTK.widgetGetColor widget
#else
style <- GTK.widgetGetStyleContext widget
GTK.styleContextAddProvider style _provider ( fromIntegral GTK.STYLE_PROVIDER_PRIORITY_USER )
GTK.styleContextAddClass style colourName
GTK.styleContextGetColor style
#endif

View file

@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
@ -64,31 +63,17 @@ showRGBA rgba = withRGBA rgba \ r g b a ->
widgetAddClasses :: ( HasCallStack, GTK.IsWidget widget, MonadIO m ) => widget -> [Text] -> m ()
widgetAddClasses widget classNames =
#if MIN_VERSION_GTK_4_10
for_ classNames ( GTK.widgetAddCssClass widget )
#else
do
styleContext <- GTK.widgetGetStyleContext widget
for_ classNames ( GTK.styleContextAddClass styleContext )
#endif
widgetAddClass :: ( HasCallStack, GTK.IsWidget widget, MonadIO m ) => widget -> Text -> m ()
widgetAddClass widget className =
#if MIN_VERSION_GTK_4_10
GTK.widgetAddCssClass widget className
#else
GTK.widgetGetStyleContext widget >>= ( `GTK.styleContextAddClass` className )
#endif
--------------------------------------------------------------------------------
widgetShow :: ( HasCallStack, GTK.IsWidget widget, MonadIO m ) => widget -> m ()
widgetShow widget =
#if MIN_VERSION_GTK_4_10
GTK.widgetSetVisible widget True
#else
GTK.widgetShow widget
#endif
--------------------------------------------------------------------------------