mirror of
https://gitlab.com/sheaf/metabrush.git
synced 2024-11-23 15:34:06 +00:00
use haskell-gi bugfix to improve tab reordering
This commit is contained in:
parent
58ca70c1bd
commit
a5ba7dcd33
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -3,9 +3,10 @@ cabal.project.local
|
|||
|
||||
assets/*.svg
|
||||
assets/*/
|
||||
refs/
|
||||
img/examples
|
||||
files/
|
||||
img/examples
|
||||
math/
|
||||
refs/
|
||||
|
||||
*.txt
|
||||
*.md
|
||||
|
|
|
@ -29,3 +29,9 @@ source-repository-package
|
|||
type: git
|
||||
location: https://github.com/sheaf/waargonaut
|
||||
tag: dc835fb86d2592fa2e55753fa4eb7c59d6124699
|
||||
|
||||
-- haskell-gi: add fix for GValue
|
||||
source-repository-package
|
||||
type: git
|
||||
location: https://github.com/haskell-gi/haskell-gi
|
||||
tag: 6fe7fc271095b5b6115b142f72995ebc11840afb
|
||||
|
|
|
@ -18,6 +18,8 @@ import Control.Monad
|
|||
( join, unless, void )
|
||||
import Data.Foldable
|
||||
( for_, sequenceA_ )
|
||||
import Data.Functor
|
||||
( (<&>) )
|
||||
import Data.Traversable
|
||||
( for )
|
||||
|
||||
|
@ -32,6 +34,10 @@ import qualified GI.Cairo.Render.Connector as Cairo
|
|||
-- gi-gtk
|
||||
import qualified GI.Gtk as GTK
|
||||
|
||||
-- haskell-gi-base
|
||||
import qualified Data.GI.Base.GValue as GI
|
||||
import qualified Data.GI.Base.GType as GI
|
||||
|
||||
-- stm
|
||||
import qualified Control.Concurrent.STM as STM
|
||||
( atomically )
|
||||
|
@ -134,7 +140,7 @@ newFileTab
|
|||
widgetAddClasses closeFileButton [ "fileBarCloseButton" ]
|
||||
GTK.widgetShowAll tab
|
||||
|
||||
-- We've placed the new tab at the end. Now rearrange it if needed.
|
||||
-- We've placed the new tab at the end. Now rearrange it if necessary.
|
||||
case newTabLoc of
|
||||
LastTab -> pure ()
|
||||
AfterCurrentTab -> do
|
||||
|
@ -143,13 +149,10 @@ newFileTab
|
|||
for mbUnique \ docUnique -> do
|
||||
Map.lookup docUnique <$> STM.readTVar fileBarTabsTVar
|
||||
for_ mbActiveTab \ ( activeTab, _ ) -> do
|
||||
children <- GTK.containerGetChildren fileTabsBox
|
||||
for_ ( zip children [0..] ) \ ( childWidget, activeTabIndex ) -> do
|
||||
mbBox <- GTK.castTo GTK.Box childWidget
|
||||
for_ mbBox \ box ->
|
||||
if box == activeTab
|
||||
then GTK.boxReorderChild fileTabsBox tab ( activeTabIndex + 1 )
|
||||
else pure ()
|
||||
gValue <- GI.newGValue GI.gtypeInt
|
||||
GTK.containerChildGetProperty fileTabsBox activeTab "position" gValue
|
||||
( GI.get_int gValue <&> ( +1 ) ) >>= GI.set_int gValue
|
||||
GTK.containerChildSetProperty fileTabsBox tab "position" gValue
|
||||
|
||||
-- Ensure consistency of hover/selection state between the two elements in the tab.
|
||||
for_ @_ @_ @_ @() [ Exists @GTK.IsWidget pgButton, Exists @GTK.IsWidget closeFileButton ] \ ( Exists button ) -> do
|
||||
|
|
Loading…
Reference in a new issue