Virtual desktop underlay for Wayland and X11
git clone https://github.com/m-col/xanadu
Files | Refs | Readme | License

Commit 64d2df5c26ba41d52e9206d21f4604afe16de63e
Parent: 758b84314e9771ca583cb4d3eaf9dbe57fe1e858
Author: mcol <mcol@posteo.net>
Date: 2021-11-02 17:30:38 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2021-11-02 17:30:38 +0000

Move style code into new Style.hs

xanadu.cabal Modified

@@ -17,6 +17,7 @@
   hs-source-dirs:      src
   main-is:             Main.hs
   other-modules:       Icons
+                     , Style
                      , Window
   default-language:    Haskell2010
   build-depends:       base >= 4.7 && < 5

src/Window.hs Modified

@@ -24,7 +24,6 @@
 
     initWayland win
     runMaybeT $ initX11 win
-    addCSS win
     return win
 
 initWayland :: Gtk.ApplicationWindow -> IO ()
@@ -46,12 +45,3 @@
     width <- Gdk.getRectangleWidth rect
     height <- Gdk.getRectangleHeight rect
     Gtk.windowSetDefaultSize win width height
-
-addCSS :: Gtk.ApplicationWindow -> IO ()
-addCSS win = do
-    screen <- Gtk.windowGetScreen win
-    settings <- Gtk.settingsGetForScreen screen
-    Gtk.setSettingsGtkApplicationPreferDarkTheme settings True
-    cssProvider <- Gtk.cssProviderNew
-    Gtk.cssProviderLoadFromData cssProvider "* { background-color: transparent; }"
-    Gtk.styleContextAddProviderForScreen screen cssProvider 800

src/Style.hs Added

@@ -0,0 +1,20 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module Style (
+    initStyle
+) where
+
+import qualified GI.Gtk as Gtk
+
+initStyle :: Gtk.ApplicationWindow -> IO ()
+initStyle win = do
+    addCSS win
+
+addCSS :: Gtk.ApplicationWindow -> IO ()
+addCSS win = do
+    screen <- Gtk.windowGetScreen win
+    settings <- Gtk.settingsGetForScreen screen
+    Gtk.setSettingsGtkApplicationPreferDarkTheme settings True
+    cssProvider <- Gtk.cssProviderNew
+    Gtk.cssProviderLoadFromData cssProvider "* { background-color: transparent; }"
+    Gtk.styleContextAddProviderForScreen screen cssProvider 800

src/Main.hs Modified

@@ -4,6 +4,7 @@
 module Main where
 
 import Icons (initIcons)
+import Style (initStyle)
 import Window (initWindow)
 
 import Data.GI.Base
@@ -23,6 +24,7 @@
 activateApp :: Gtk.Application -> IO ()
 activateApp app = do
     win <- initWindow app
+    initStyle win
     iconView <- initIcons win
     #add win iconView
     #showAll win