From 02f0ee1f9ed3791b132d573ca2c343570b91dc2a Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 16 Jan 2023 08:57:15 -0800 Subject: [PATCH 1/6] Get rid of poppler dep. build fix related to poppler poppler hasn't been working for a while. so we abandon it. --- cabal.project | 2 +- core/hoodle-core.cabal | 2 +- flake.lock | 64 +++++-------- flake.nix | 64 +++++++------ render/hoodle-render.cabal | 2 +- render/src/Graphics/Hoodle/Render.hs | 6 +- .../src/Graphics/Hoodle/Render/Background.hs | 96 ++++++++++--------- render/src/Graphics/Hoodle/Render/Engine.hs | 27 ++++-- render/src/Graphics/Hoodle/Render/Generic.hs | 3 +- .../src/Graphics/Hoodle/Render/Primitive.hs | 2 + .../Graphics/Hoodle/Render/Type/Background.hs | 10 +- .../Graphics/Hoodle/Render/Type/Renderer.hs | 13 +-- .../src/Graphics/Hoodle/Render/Type/Select.hs | 5 +- types/src/Data/Hoodle/BBox.hs | 3 +- types/src/Data/Hoodle/Zipper.hs | 1 + .../src/Text/Xournal/Parse/Conduit.hs | 2 +- xournal-types/src/Data/Xournal/BBox.hs | 3 +- xournal-types/src/Data/Xournal/Select.hs | 1 + 18 files changed, 160 insertions(+), 146 deletions(-) diff --git a/cabal.project b/cabal.project index a35b47fb..fda80685 100644 --- a/cabal.project +++ b/cabal.project @@ -10,4 +10,4 @@ packages: ./publish/hoodle-publish.cabal ./core/hoodle-core.cabal ./hoodle/hoodle.cabal - ./build-tools/hoodle-build-tools.cabal + -- ./build-tools/hoodle-build-tools.cabal diff --git a/core/hoodle-core.cabal b/core/hoodle-core.cabal index b103be0a..5e3e3504 100644 --- a/core/hoodle-core.cabal +++ b/core/hoodle-core.cabal @@ -54,7 +54,7 @@ Library network-uri > 2.6, network-simple >= 0.3, pango > 0.12, - poppler >= 0.12.2.2, + -- poppler >= 0.12.2.2, process >= 1.1, pureMD5, resourcet, diff --git a/flake.lock b/flake.lock index ea20bbfa..d50ce3b1 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,22 @@ { "nodes": { + "TypeCompose": { + "flake": false, + "locked": { + "lastModified": 1650056496, + "narHash": "sha256-ex70Y6xf6uvDei30LMqvMYei9gOO/M8cekTnXRyzqX8=", + "owner": "conal", + "repo": "TypeCompose", + "rev": "daf13efa6e6b37960de98146bab4a061462fc22b", + "type": "github" + }, + "original": { + "owner": "conal", + "ref": "master", + "repo": "TypeCompose", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1652776076, @@ -17,60 +34,25 @@ }, "nixpkgs": { "locked": { - "lastModified": 1653087707, - "narHash": "sha256-zfno3snrzZTWQ2B7K53QHrGZwrjnJLTRPalymrSsziU=", + "lastModified": 1673732096, + "narHash": "sha256-BX9KjMvyN00q5OfaQK80iQsmzCthosBGgkrs3F446q8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "cbd40c72b2603ab54e7208f99f9b35fc158bc009", + "rev": "76fed81234baa4c9be97af53a0a71d1bbcc5400c", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-21.11", + "ref": "master", "repo": "nixpkgs", "type": "github" } }, - "pdf-toolbox": { - "flake": false, - "locked": { - "lastModified": 1653242554, - "narHash": "sha256-FWfsPW5OlOJ+rMYGw6upuI0oeiUNRPbrzlomU2pAnK0=", - "owner": "wavewave", - "repo": "pdf-toolbox", - "rev": "6205c87d2430857d73e68c7f615b2dcae3cecec3", - "type": "github" - }, - "original": { - "owner": "wavewave", - "ref": "for-hoodle", - "repo": "pdf-toolbox", - "type": "github" - } - }, - "poppler": { - "flake": false, - "locked": { - "lastModified": 1653150554, - "narHash": "sha256-zAurDl9tGhOL+MlDAzEi99rITxQTGnqTPXfPA+4HVl8=", - "owner": "wavewave", - "repo": "poppler", - "rev": "4e7fc8364f89a4757f67fa9715471b5e97cd86f0", - "type": "github" - }, - "original": { - "owner": "wavewave", - "repo": "poppler", - "rev": "4e7fc8364f89a4757f67fa9715471b5e97cd86f0", - "type": "github" - } - }, "root": { "inputs": { + "TypeCompose": "TypeCompose", "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "pdf-toolbox": "pdf-toolbox", - "poppler": "poppler" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 906f0984..d182ee62 100644 --- a/flake.nix +++ b/flake.nix @@ -1,41 +1,48 @@ { description = "Hoodle: pen notetaking program"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11"; + nixpkgs.url = "github:NixOS/nixpkgs/master"; flake-utils.url = "github:numtide/flake-utils"; - poppler = { - url = "github:wavewave/poppler/4e7fc8364f89a4757f67fa9715471b5e97cd86f0"; - flake = false; - }; - pdf-toolbox = { - url = "github:wavewave/pdf-toolbox/for-hoodle"; + #poppler = { + # url = "github:wavewave/poppler/4e7fc8364f89a4757f67fa9715471b5e97cd86f0"; + # flake = false; + #}; + #pdf-toolbox = { + # url = "github:wavewave/pdf-toolbox/for-hoodle"; + # flake = false; + #}; + TypeCompose = { + url = "github:conal/TypeCompose/master"; flake = false; }; }; - outputs = { self, nixpkgs, flake-utils, poppler, pdf-toolbox }: + outputs = inputs@{ self, nixpkgs, flake-utils, ... }: flake-utils.lib.eachSystem flake-utils.lib.allSystems (system: let haskellLib = (import nixpkgs { inherit system; }).haskell.lib; overlay_deps = final: prev: { + #poppler_0_61 = + # final.callPackage ./nix/poppler_0_61.nix { lcms = final.lcms2; }; haskellPackages = prev.haskellPackages.override (old: { overrides = final.lib.composeExtensions (old.overrides or (_: _: { })) (self: super: { - "pdf-toolbox-content" = self.callCabal2nix "pdf-toolbox-content" - (pdf-toolbox + "/content") { }; - "pdf-toolbox-core" = - self.callCabal2nix "pdf-toolbox-core" (pdf-toolbox + "/core") - { }; - "pdf-toolbox-document" = - self.callCabal2nix "pdf-toolbox-document" - (pdf-toolbox + "/document") { }; - "poppler" = let - p = self.callCabal2nix "poppler" poppler { }; - p1 = haskellLib.appendConfigureFlags p [ "-fgtk3" ]; - p2 = haskellLib.overrideCabal p1 (drv: { - libraryPkgconfigDepends = [ final.gtk3 final.poppler_0_61 ]; - }); - in haskellLib.disableHardening p2 [ "fortify" ]; + "TypeCompose" = + self.callCabal2nix "TypeCompose" inputs.TypeCompose { }; + #"pdf-toolbox-content" = self.callCabal2nix "pdf-toolbox-content" + # (inputs.pdf-toolbox + "/content") { }; + #"pdf-toolbox-core" = self.callCabal2nix "pdf-toolbox-core" + # (inputs.pdf-toolbox + "/core") { }; + #"pdf-toolbox-document" = + # self.callCabal2nix "pdf-toolbox-document" + # (inputs.pdf-toolbox + "/document") { }; + #"poppler" = let + # p = self.callCabal2nix "poppler" inputs.poppler { }; + # p1 = haskellLib.appendConfigureFlags p [ "-fgtk3" ]; + # p2 = haskellLib.overrideCabal p1 (drv: { + # libraryPkgconfigDepends = [ final.gtk3 final.poppler_0_61 ]; + # }); + #in haskellLib.disableHardening p2 [ "fortify" ]; }); }); }; @@ -103,9 +110,9 @@ # NOTE: GHC 8.10.7 has a problem with poppler (multiple definition of libc functions) # gi-poppler is buildable on nixpkgs without custom overlay up to GHC 9.0.1 - in packagesOnGHC "ghc901" // packagesOnGHC "ghc884"; + in packagesOnGHC "ghc924"; - defaultPackage = packages.ghc884_all; + defaultPackage = packages.ghc924_all; overlays = fullOverlays; @@ -133,10 +140,9 @@ export XDG_DATA_DIRS=${newPkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${newPkgs.gsettings-desktop-schemas.name}:${newPkgs.gtk3}/share/gsettings-schemas/${newPkgs.gtk3.name}:$XDG_ICON_DIRS:$XDG_DATA_DIRS ''; }; - in { - "default" = mkDevShell "ghc884"; - "ghc884" = mkDevShell "ghc884"; - "ghc901" = mkDevShell "ghc901"; + in rec { + "default" = ghc924; + "ghc924" = mkDevShell "ghc924"; }; }); } diff --git a/render/hoodle-render.cabal b/render/hoodle-render.cabal index 46d04d08..007ebced 100644 --- a/render/hoodle-render.cabal +++ b/render/hoodle-render.cabal @@ -32,7 +32,7 @@ Library lens >= 2.5, monad-loops >= 0.3, mtl > 2, - poppler >= 0.14, + -- poppler >= 0.14, stm, strict >= 0.3, svgcairo >= 0.12, diff --git a/render/src/Graphics/Hoodle/Render.hs b/render/src/Graphics/Hoodle/Render.hs index d5252086..77c1644f 100644 --- a/render/src/Graphics/Hoodle/Render.hs +++ b/render/src/Graphics/Hoodle/Render.hs @@ -1,5 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# OPTIONS_GHC -fno-warn-unused-local-binds -fno-warn-unused-imports #-} module Graphics.Hoodle.Render ( -- * xform @@ -101,7 +102,7 @@ import Data.Hoodle.Simple import Data.Hoodle.Zipper (fromNonEmptyList) import Graphics.Hoodle.Render.Background ( cnstrctRBkgStateT, - popplerGetDocFromDataURI, + -- popplerGetDocFromDataURI, renderBackgroundStateT, renderBkg, ) @@ -591,5 +592,6 @@ renderPageStateT pg = do initRenderContext :: Hoodle -> IO Context initRenderContext hdl = do let pdf = view embeddedPdf hdl - mdoc <- join <$> mapM popplerGetDocFromDataURI pdf + -- mdoc <- join <$> mapM popplerGetDocFromDataURI pdf + let mdoc = Nothing return (Context "" "" Nothing mdoc) diff --git a/render/src/Graphics/Hoodle/Render/Background.hs b/render/src/Graphics/Hoodle/Render/Background.hs index 450d5bd9..9c6028f1 100644 --- a/render/src/Graphics/Hoodle/Render/Background.hs +++ b/render/src/Graphics/Hoodle/Render/Background.hs @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} +{-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-unused-matches #-} module Graphics.Hoodle.Render.Background where @@ -46,8 +47,8 @@ import Graphics.Hoodle.Render.Type.Renderer sendPDFCommand, ) import qualified Graphics.Rendering.Cairo as Cairo -import qualified Graphics.UI.Gtk.Poppler.Document as Poppler -import qualified Graphics.UI.Gtk.Poppler.Page as PopplerPage +-- import qualified Graphics.UI.Gtk.Poppler.Document as Poppler +-- import qualified Graphics.UI.Gtk.Poppler.Page as PopplerPage import System.Directory ( getTemporaryDirectory, removeFile, @@ -56,11 +57,11 @@ import System.FilePath ((<.>), ()) import Prelude -- | -popplerGetDocFromFile :: ByteString -> IO (Maybe Poppler.Document) -popplerGetDocFromFile fp = - Poppler.documentNewFromFile - (C.unpack ("file://localhost" `mappend` fp)) - Nothing +-- popplerGetDocFromFile :: ByteString -> IO (Maybe Poppler.Document) +-- popplerGetDocFromFile fp = +-- Poppler.documentNewFromFile +-- (C.unpack ("file://localhost" `mappend` fp)) +-- Nothing -- | getByteStringIfEmbeddedPDF :: ByteString -> Maybe ByteString @@ -71,33 +72,33 @@ getByteStringIfEmbeddedPDF bstr = do either (const Nothing) return (decode dat) -- | -popplerGetDocFromDataURI :: ByteString -> IO (Maybe Poppler.Document) -popplerGetDocFromDataURI dat = do - let mdecoded = getByteStringIfEmbeddedPDF dat - case mdecoded of - Nothing -> return Nothing - Just decoded -> do - uuidstr <- fmap show nextRandom - tmpdir <- getTemporaryDirectory - let tmpfile = tmpdir uuidstr <.> "pdf" - C.writeFile tmpfile decoded - mdoc <- popplerGetDocFromFile (C.pack tmpfile) - removeFile tmpfile - return mdoc +-- popplerGetDocFromDataURI :: ByteString -> IO (Maybe Poppler.Document) +-- popplerGetDocFromDataURI dat = do +-- let mdecoded = getByteStringIfEmbeddedPDF dat +-- case mdecoded of +-- Nothing -> return Nothing +-- Just decoded -> do +-- uuidstr <- fmap show nextRandom +-- tmpdir <- getTemporaryDirectory +-- let tmpfile = tmpdir uuidstr <.> "pdf" +-- C.writeFile tmpfile decoded +-- mdoc <- popplerGetDocFromFile (C.pack tmpfile) +-- removeFile tmpfile +-- return mdoc -- | -popplerGetPageFromDoc :: - Poppler.Document -> - -- | page number - Int -> - IO (Maybe Poppler.Page) -popplerGetPageFromDoc doc pn = do - n <- Poppler.documentGetNPages doc - if pn > n - then return Nothing - else do - pg <- Poppler.documentGetPage doc (pn - 1) - return (Just pg) +-- popplerGetPageFromDoc :: +-- Poppler.Document -> +-- -- | page number +-- Int -> +-- IO (Maybe Poppler.Page) +-- popplerGetPageFromDoc doc pn = do +-- n <- Poppler.documentGetNPages doc +-- if pn > n +-- then return Nothing +-- else do +-- pg <- Poppler.documentGetPage doc (pn - 1) +-- return (Just pg) -- | draw ruling all drawRuling :: Double -> Double -> ByteString -> Cairo.Render () @@ -266,26 +267,33 @@ renderBackgroundStateT dim@(Dim w h) bkg = do r <- runMaybeT $ do case (md, mf) of (Just d, Just f) -> do - doc <- (MaybeT . liftIO . popplerGetDocFromFile) f + -- doc <- (MaybeT . liftIO . popplerGetDocFromFile) f + let doc = () lift . put $ Context d f (Just doc) Nothing - pdfRenderDoc doc pn + -- pdfRenderDoc doc pn + pure () _ -> do Context _oldd _oldf olddoc _ <- lift get doc <- MaybeT . return $ olddoc - pdfRenderDoc doc pn + -- pdfRenderDoc doc pn + pure () maybe (error "renderBackgroundStateT") (const (return ())) r BackgroundEmbedPdf _ pn -> do r <- runMaybeT $ do Context _ _ _ mdoc <- lift get doc <- (MaybeT . return) mdoc - pdfRenderDoc doc pn + -- pdfRenderDoc doc pn + pure () maybe (error "renderBackgroundStateT") (const (return ())) r where - pdfRender pg = do - Cairo.setSourceRGBA 1 1 1 1 - Cairo.rectangle 0 0 w h - Cairo.fill - PopplerPage.pageRender pg - pdfRenderDoc doc pn = - (MaybeT . liftIO) (popplerGetPageFromDoc doc pn) - >>= lift . lift . pdfRender + +{- +pdfRender pg = do + Cairo.setSourceRGBA 1 1 1 1 + Cairo.rectangle 0 0 w h + Cairo.fill + PopplerPage.pageRender pg +pdfRenderDoc doc pn = + (MaybeT . liftIO) (popplerGetPageFromDoc doc pn) + >>= lift . lift . pdfRender +-} diff --git a/render/src/Graphics/Hoodle/Render/Engine.hs b/render/src/Graphics/Hoodle/Render/Engine.hs index 979a6bac..741e3e9e 100644 --- a/render/src/Graphics/Hoodle/Render/Engine.hs +++ b/render/src/Graphics/Hoodle/Render/Engine.hs @@ -1,4 +1,5 @@ {-# LANGUAGE OverloadedStrings #-} +{-# OPTIONS_GHC -fno-warn-unused-matches #-} module Graphics.Hoodle.Render.Engine ( pdfRendererMain, @@ -21,9 +22,9 @@ import Data.Hoodle.Simple (Background (..), Dimension (..)) import Data.Sequence (ViewL (..), viewl) import Graphics.Hoodle.Render (renderRItem) import Graphics.Hoodle.Render.Background - ( popplerGetDocFromDataURI, - popplerGetDocFromFile, - popplerGetPageFromDoc, + ( -- popplerGetDocFromDataURI, + -- popplerGetDocFromFile, + -- popplerGetPageFromDoc, renderBkg, ) import Graphics.Hoodle.Render.Type @@ -49,8 +50,9 @@ import Graphics.Hoodle.Render.Type ), ) import qualified Graphics.Rendering.Cairo as Cairo -import qualified Graphics.UI.Gtk.Poppler.Document as Poppler -import qualified Graphics.UI.Gtk.Poppler.Page as Poppler + +-- import qualified Graphics.UI.Gtk.Poppler.Document as Poppler +-- import qualified Graphics.UI.Gtk.Poppler.Page as Poppler -- | main pdf renderer engine. need to be in a single thread pdfRendererMain :: (RendererEvent -> IO ()) -> PDFCommandQueue -> IO () @@ -66,16 +68,20 @@ pdfRendererMain handler tvar = forever $ do pdfWorker :: (RendererEvent -> IO ()) -> PDFCommand -> IO () pdfWorker _handler (GetDocFromFile fp tmvar) = do - mdoc <- popplerGetDocFromFile fp + -- mdoc <- popplerGetDocFromFile fp + let mdoc = Just () atomically $ putTMVar tmvar mdoc pdfWorker _handler (GetDocFromDataURI str tmvar) = do - mdoc <- popplerGetDocFromDataURI str + -- mdoc <- popplerGetDocFromDataURI str + let mdoc = Just () atomically $ putTMVar tmvar mdoc pdfWorker _handler (GetPageFromDoc doc pn tmvar) = do - mpg <- popplerGetPageFromDoc doc pn + -- mpg <- popplerGetPageFromDoc doc pn + let mpg = Just () atomically $ putTMVar tmvar mpg pdfWorker _handler (GetNPages doc tmvar) = do - n <- Poppler.documentGetNPages doc + -- n <- Poppler.documentGetNPages doc + let n = 0 atomically $ putTMVar tmvar n pdfWorker handler (RenderPageScaled sfcid page (Dim ow _oh) (Dim w h)) = do let s = w / ow @@ -85,7 +91,8 @@ pdfWorker handler (RenderPageScaled sfcid page (Dim ow _oh) (Dim w h)) = do Cairo.rectangle 0 0 w h Cairo.fill Cairo.scale s s - Poppler.pageRender page + -- Poppler.pageRender page + pure () handler (SurfaceUpdate (sfcid, (s, sfc))) -- | generic renderer engine diff --git a/render/src/Graphics/Hoodle/Render/Generic.hs b/render/src/Graphics/Hoodle/Render/Generic.hs index d8bd0be5..57ffb012 100644 --- a/render/src/Graphics/Hoodle/Render/Generic.hs +++ b/render/src/Graphics/Hoodle/Render/Generic.hs @@ -20,6 +20,7 @@ import Data.Hoodle.Simple Dimension, Stroke, ) +import Data.Kind (Type) import Graphics.Hoodle.Render ( Xform4Page, renderBkg, @@ -75,7 +76,7 @@ instance Renderable (RLayer, Dimension, Maybe Xform4Page) where -- | class RenderOptionable a where - type RenderOption a :: * + type RenderOption a :: Type cairoRenderOption :: RenderOption a -> RenderCache -> CanvasId -> a -> Cairo.Render a -- | diff --git a/render/src/Graphics/Hoodle/Render/Primitive.hs b/render/src/Graphics/Hoodle/Render/Primitive.hs index e160bd82..f523468e 100644 --- a/render/src/Graphics/Hoodle/Render/Primitive.hs +++ b/render/src/Graphics/Hoodle/Render/Primitive.hs @@ -1,3 +1,5 @@ +{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} + module Graphics.Hoodle.Render.Primitive ( drawStrokeCurve, drawVWStrokeCurve, diff --git a/render/src/Graphics/Hoodle/Render/Type/Background.hs b/render/src/Graphics/Hoodle/Render/Type/Background.hs index 9216ff9d..39189d88 100644 --- a/render/src/Graphics/Hoodle/Render/Type/Background.hs +++ b/render/src/Graphics/Hoodle/Render/Type/Background.hs @@ -7,7 +7,7 @@ import Data.ByteString (ByteString) import Data.Hoodle.BBox (BBox) import Data.Hoodle.Simple (Background (..)) import Graphics.Hoodle.Render.Type.Renderer (SurfaceID) -import qualified Graphics.UI.Gtk.Poppler.Document as Poppler +-- import qualified Graphics.UI.Gtk.Poppler.Document as Poppler -- import Prelude hiding (mapM_) @@ -15,8 +15,8 @@ import Prelude hiding (mapM_) data Context = Context { ctxt_domain :: ByteString, ctxt_filename :: ByteString, - ctxt_doc :: Maybe Poppler.Document, - ctxt_embeddeddoc :: Maybe Poppler.Document + ctxt_doc :: Maybe (), -- Maybe Poppler.Document, + ctxt_embeddeddoc :: Maybe () -- Poppler.Document } -- | @@ -30,12 +30,12 @@ data RBackground { rbkg_domain :: Maybe ByteString, rbkg_filename :: ByteString, rbkg_pageno :: Int, - rbkg_popplerpage :: Maybe Poppler.Page, + rbkg_popplerpage :: Maybe (), -- Maybe Poppler.Page, rbkg_surfaceid :: SurfaceID -- UUID } | RBkgEmbedPDF { rbkg_pageno :: Int, - rbkg_popplerpage :: Maybe Poppler.Page, + rbkg_popplerpage :: Maybe (), -- Maybe Poppler.Page, rbkg_surfaceid :: SurfaceID -- UUID } diff --git a/render/src/Graphics/Hoodle/Render/Type/Renderer.hs b/render/src/Graphics/Hoodle/Render/Type/Renderer.hs index 132bc732..8603b464 100644 --- a/render/src/Graphics/Hoodle/Render/Type/Renderer.hs +++ b/render/src/Graphics/Hoodle/Render/Type/Renderer.hs @@ -24,16 +24,17 @@ import Data.UUID (UUID) import Data.UUID.V4 (nextRandom) import Graphics.Hoodle.Render.Type.Item (RItem) import qualified Graphics.Rendering.Cairo as Cairo -import qualified Graphics.UI.Gtk.Poppler.Document as Poppler + +-- import qualified Graphics.UI.Gtk.Poppler.Document as Poppler newtype PDFCommandID = PDFCommandID UUID deriving (Show, Eq, Ord) data PDFCommand where - GetDocFromFile :: B.ByteString -> TMVar (Maybe Poppler.Document) -> PDFCommand - GetDocFromDataURI :: B.ByteString -> TMVar (Maybe Poppler.Document) -> PDFCommand - GetPageFromDoc :: Poppler.Document -> !Int -> TMVar (Maybe Poppler.Page) -> PDFCommand - GetNPages :: !Poppler.Document -> TMVar Int -> PDFCommand - RenderPageScaled :: SurfaceID -> Poppler.Page -> Dimension -> Dimension -> PDFCommand + GetDocFromFile :: B.ByteString -> TMVar (Maybe () {- Poppler.Document -}) -> PDFCommand + GetDocFromDataURI :: B.ByteString -> TMVar (Maybe () {- Poppler.Document -}) -> PDFCommand + GetPageFromDoc :: () {- Poppler.Document -} -> !Int -> TMVar (Maybe () {- Poppler.Page -}) -> PDFCommand + GetNPages {- !Poppler.Document -} :: () -> TMVar Int -> PDFCommand + RenderPageScaled :: SurfaceID -> () {- Poppler.Page -} -> Dimension -> Dimension -> PDFCommand instance Show PDFCommand where show _ = "PDFCommand" diff --git a/render/src/Graphics/Hoodle/Render/Type/Select.hs b/render/src/Graphics/Hoodle/Render/Type/Select.hs index 6925e8b9..a4ed28d6 100644 --- a/render/src/Graphics/Hoodle/Render/Type/Select.hs +++ b/render/src/Graphics/Hoodle/Render/Type/Select.hs @@ -15,6 +15,7 @@ import Data.Hoodle.Generic import Data.Hoodle.Select (GSelect) import Data.Hoodle.Zipper (ZipperSelect, current, replace) import Data.IntMap (IntMap) +import Data.Kind (Type) import Graphics.Hoodle.Render.Type.Background (RBackground) import Graphics.Hoodle.Render.Type.HitTest ( Hitted (..), @@ -30,9 +31,9 @@ import Graphics.Hoodle.Render.Type.Item (RItem) type SLayerF a = GLayer (BufOf a) TEitherAlterHitted (ItmOf a) -type family ItmOf a :: * +type family ItmOf a :: Type -type family BufOf a :: * +type family BufOf a :: Type type instance BufOf (GLayer b s a) = b diff --git a/types/src/Data/Hoodle/BBox.hs b/types/src/Data/Hoodle/BBox.hs index 1d8be23c..14c530bd 100644 --- a/types/src/Data/Hoodle/BBox.hs +++ b/types/src/Data/Hoodle/BBox.hs @@ -41,6 +41,7 @@ import Data.Hoodle.Simple Stroke (..), ) import Data.Hoodle.Util (fst3, snd3, trd3) +import Data.Kind (Type) import Data.Strict.Tuple (Pair, fst, snd) import Hoodle.HitTest.Type ( BBox (..), @@ -202,7 +203,7 @@ instance Monoid UnionBBox where -- | class Maybeable a where - type ElemType a :: * + type ElemType a :: Type toMaybe :: a -> Maybe (ElemType a) fromMaybe :: Maybe (ElemType a) -> a diff --git a/types/src/Data/Hoodle/Zipper.hs b/types/src/Data/Hoodle/Zipper.hs index c8baadcc..3642f36d 100644 --- a/types/src/Data/Hoodle/Zipper.hs +++ b/types/src/Data/Hoodle/Zipper.hs @@ -1,6 +1,7 @@ {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE StandaloneDeriving #-} +{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} ----------------------------------------------------------------------------- diff --git a/xournal-parser/src/Text/Xournal/Parse/Conduit.hs b/xournal-parser/src/Text/Xournal/Parse/Conduit.hs index 53ae7d4f..3741ac1c 100644 --- a/xournal-parser/src/Text/Xournal/Parse/Conduit.hs +++ b/xournal-parser/src/Text/Xournal/Parse/Conduit.hs @@ -2,7 +2,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE NoMonomorphismRestriction #-} -{-# OPTIONS_GHC -fno-warn-deprecations #-} +{-# OPTIONS_GHC -fno-warn-deprecations -fno-warn-incomplete-uni-patterns #-} module Text.Xournal.Parse.Conduit where diff --git a/xournal-types/src/Data/Xournal/BBox.hs b/xournal-types/src/Data/Xournal/BBox.hs index 0fbebf03..afe95dde 100644 --- a/xournal-types/src/Data/Xournal/BBox.hs +++ b/xournal-types/src/Data/Xournal/BBox.hs @@ -6,6 +6,7 @@ module Data.Xournal.BBox where import Control.Monad (guard, liftM2) import qualified Data.Foldable as F +import Data.Kind (Type) import Data.Serialize (Serialize, get, put) import Data.Strict.Tuple (Pair, fst, snd) import Data.Xournal.Generic @@ -169,7 +170,7 @@ instance Monoid UnionBBox where -- | class Maybeable a where - type ElemType a :: * + type ElemType a :: Type toMaybe :: a -> Maybe (ElemType a) fromMaybe :: Maybe (ElemType a) -> a diff --git a/xournal-types/src/Data/Xournal/Select.hs b/xournal-types/src/Data/Xournal/Select.hs index 797d31d2..2db05bb3 100644 --- a/xournal-types/src/Data/Xournal/Select.hs +++ b/xournal-types/src/Data/Xournal/Select.hs @@ -5,6 +5,7 @@ {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeSynonymInstances #-} +{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} module Data.Xournal.Select where From 54dded5e1d89a5d0ea46c3cbe66aeb27056ad4dc Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 16 Jan 2023 09:34:52 -0800 Subject: [PATCH 2/6] disable hoodle-publish and handwriting recognition (it was broken as Google disallows anyway) --- core/src/Hoodle/Accessor.hs | 1 + core/src/Hoodle/Coroutine/ContextMenu.hs | 10 +++-- core/src/Hoodle/Coroutine/Default/Menu.hs | 10 ++--- core/src/Hoodle/Coroutine/Dialog.hs | 1 + core/src/Hoodle/Coroutine/File.hs | 11 +++-- .../Coroutine/HandwritingRecognition.hs | 2 + core/src/Hoodle/Coroutine/Minibuffer.hs | 1 + core/src/Hoodle/Coroutine/Page.hs | 1 + core/src/Hoodle/Coroutine/Pen.hs | 1 + core/src/Hoodle/Coroutine/Select.hs | 1 + core/src/Hoodle/Coroutine/Select/Clipboard.hs | 1 + core/src/Hoodle/ModelAction/File.hs | 17 ++++--- core/src/Hoodle/ModelAction/Select.hs | 1 + core/src/Hoodle/ModelAction/Window.hs | 1 + core/src/Hoodle/Type/Alias.hs | 7 +-- core/src/Hoodle/Type/Canvas.hs | 1 + core/src/Hoodle/Type/PageArrangement.hs | 3 +- core/src/Hoodle/View/Draw.hs | 3 +- core/src/Hoodle/Widget/PanZoom.hs | 1 + publish/exe/hoodle-publish.hs | 5 +++ publish/lib/Hoodle/Publish/PDF.hs | 45 ++++++++++--------- 21 files changed, 79 insertions(+), 45 deletions(-) diff --git a/core/src/Hoodle/Accessor.hs b/core/src/Hoodle/Accessor.hs index 30255b63..f9db95ee 100644 --- a/core/src/Hoodle/Accessor.hs +++ b/core/src/Hoodle/Accessor.hs @@ -2,6 +2,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} module Hoodle.Accessor where diff --git a/core/src/Hoodle/Coroutine/ContextMenu.hs b/core/src/Hoodle/Coroutine/ContextMenu.hs index d0bbf2ef..7db137df 100644 --- a/core/src/Hoodle/Coroutine/ContextMenu.hs +++ b/core/src/Hoodle/Coroutine/ContextMenu.hs @@ -2,6 +2,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} module Hoodle.Coroutine.ContextMenu where @@ -83,9 +84,9 @@ import Hoodle.Coroutine.Draw waitSomeEvent, ) import Hoodle.Coroutine.File (fileExtensionInvalid) -import Hoodle.Coroutine.HandwritingRecognition - ( handwritingRecognitionDialog, - ) +-- import Hoodle.Coroutine.HandwritingRecognition +-- ( handwritingRecognitionDialog, +-- ) import Hoodle.Coroutine.Scroll ( adjustScrollbarWithGeometryCvsId, ) @@ -284,7 +285,8 @@ processContextMenu (CMenuLaTeXUpdate (x0, y0) dim key) = void $ runMaybeT (laTeXInputKeyword (x0, y0) (Just dim) key) processContextMenu (CMenuCropImage imgbbox) = cropImage imgbbox processContextMenu (CMenuExportHoodlet itm) = do - res <- handwritingRecognitionDialog + -- res <- handwritingRecognitionDialog + let res = Nothing forM_ res $ \(b, txt) -> do unless b $ liftIO $ do diff --git a/core/src/Hoodle/Coroutine/Default/Menu.hs b/core/src/Hoodle/Coroutine/Default/Menu.hs index f6448190..2667633c 100644 --- a/core/src/Hoodle/Coroutine/Default/Menu.hs +++ b/core/src/Hoodle/Coroutine/Default/Menu.hs @@ -2,18 +2,18 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-incomplete-record-updates #-} module Hoodle.Coroutine.Default.Menu where import Control.Lens (set, view, (.~), _1) import Control.Monad.IO.Class () -import Control.Monad.State (get, gets, liftIO, modify, void, when) +import Control.Monad.State (get, gets, liftIO, modify, void) import Data.Foldable (mapM_) import Data.Hoodle.Generic (gbackground, gpages) import Data.Hoodle.Select (gselAll) import qualified Data.IntMap as M import Data.Monoid () -import qualified Data.Text as T import Graphics.Hoodle.Render.Type ( RBackground (..), isRBkgSmpl, @@ -49,7 +49,7 @@ import Hoodle.Coroutine.File fileShowUUID, fileVersionSave, ) -import Hoodle.Coroutine.HandwritingRecognition (handwritingRecognitionDialog) +-- import Hoodle.Coroutine.HandwritingRecognition (handwritingRecognitionDialog) import Hoodle.Coroutine.LaTeX (laTeXFooter, laTeXHeader) import Hoodle.Coroutine.Layer ( deleteCurrentLayer, @@ -246,8 +246,8 @@ menuEventProcess MenuTogglePanZoomWidget = togglePanZoom . view (unitHoodles . c menuEventProcess MenuToggleLayerWidget = toggleLayer . view (unitHoodles . currentUnit . currentCanvas . _1) =<< get menuEventProcess MenuToggleClockWidget = toggleClock . view (unitHoodles . currentUnit . currentCanvas . _1) =<< get menuEventProcess MenuToggleScrollWidget = toggleScroll . view (unitHoodles . currentUnit . currentCanvas . _1) =<< get -menuEventProcess MenuHandwritingRecognitionDialog = - handwritingRecognitionDialog >>= mapM_ (\(b, txt) -> when b $ embedHoodlet (T.unpack txt)) +menuEventProcess MenuHandwritingRecognitionDialog = pure () +-- handwritingRecognitionDialog >>= mapM_ (\(b, txt) -> when b $ embedHoodlet (T.unpack txt)) menuEventProcess MenuAddTab = addTab (LocalDir Nothing) menuEventProcess MenuCloseTab = closeTab menuEventProcess MenuEditNetEmbedTextSource = editNetEmbeddedTextSource diff --git a/core/src/Hoodle/Coroutine/Dialog.hs b/core/src/Hoodle/Coroutine/Dialog.hs index 380a4a3f..ef3ba05a 100644 --- a/core/src/Hoodle/Coroutine/Dialog.hs +++ b/core/src/Hoodle/Coroutine/Dialog.hs @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE LambdaCase #-} +{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} module Hoodle.Coroutine.Dialog where diff --git a/core/src/Hoodle/Coroutine/File.hs b/core/src/Hoodle/Coroutine/File.hs index 3832e8d2..f3426fdc 100644 --- a/core/src/Hoodle/Coroutine/File.hs +++ b/core/src/Hoodle/Coroutine/File.hs @@ -1,6 +1,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# OPTIONS_GHC -fno-warn-unused-matches -fno-warn-incomplete-uni-patterns #-} module Hoodle.Coroutine.File where @@ -117,7 +118,7 @@ import Hoodle.ModelAction.Page ) import Hoodle.ModelAction.Select (makePageSelectMode) import Hoodle.ModelAction.Window (setTitleFromFileName) -import Hoodle.Publish.PDF (renderHoodleToPDF) +-- import Hoodle.Publish.PDF (renderHoodleToPDF) import qualified Hoodle.Script.Coroutine as S import Hoodle.Script.Hook ( fileNameSuggestionHook, @@ -318,7 +319,8 @@ fileExport = fileChooser Gtk.FileChooserActionSave Nothing >>= maybe (return ()) then fileExtensionInvalid (".pdf", "export") >> fileExport else do hdl <- gets (rHoodle2Hoodle . getHoodle . view (unitHoodles . currentUnit)) - liftIO (renderHoodleToPDF hdl filename) + -- liftIO (renderHoodleToPDF hdl filename) + liftIO $ putStrLn "renderHoodleToPDF is disabled for now." -- | need to be merged with ContextMenuEventSVG exportCurrentPageAsSVG :: MainCoroutine () @@ -645,7 +647,9 @@ mkRevisionHdlFile hdl = do mkRevisionPdfFile :: Hoodle -> String -> IO () mkRevisionPdfFile hdl fname = do - hdir <- getHomeDirectory + putStrLn "mkRevisionPdfFile is disabled for now" + +{- hdir <- getHomeDirectory tempfile <- mkTmpFile "pdf" renderHoodleToPDF hdl tempfile let nfilename = fname <.> "pdf" @@ -653,6 +657,7 @@ mkRevisionPdfFile hdl fname = do b <- doesDirectoryExist vcsdir unless b $ createDirectory vcsdir renameFile tempfile (vcsdir nfilename) +-} -- | fileVersionSave :: MainCoroutine () diff --git a/core/src/Hoodle/Coroutine/HandwritingRecognition.hs b/core/src/Hoodle/Coroutine/HandwritingRecognition.hs index 3c4a1e2a..bfd2ba0c 100644 --- a/core/src/Hoodle/Coroutine/HandwritingRecognition.hs +++ b/core/src/Hoodle/Coroutine/HandwritingRecognition.hs @@ -5,6 +5,7 @@ module Hoodle.Coroutine.HandwritingRecognition where +{- import Control.Error.Util (failWith, hoistEither) import Control.Lens (view, _1, _2) import Control.Monad (guard, when, (<=<)) @@ -190,3 +191,4 @@ mkAesonStroke VWStroke {..} = let xs = map (Number . fromInteger . (floor :: Double -> Integer) . view _1) stroke_vwdata ys = map (Number . fromInteger . (floor :: Double -> Integer) . view _2) stroke_vwdata in Array (fromList [Array (fromList xs), Array (fromList ys)]) +-} diff --git a/core/src/Hoodle/Coroutine/Minibuffer.hs b/core/src/Hoodle/Coroutine/Minibuffer.hs index af21b465..7b806e77 100644 --- a/core/src/Hoodle/Coroutine/Minibuffer.hs +++ b/core/src/Hoodle/Coroutine/Minibuffer.hs @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE LambdaCase #-} +{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} module Hoodle.Coroutine.Minibuffer where diff --git a/core/src/Hoodle/Coroutine/Page.hs b/core/src/Hoodle/Coroutine/Page.hs index 5d1b2a04..9a303f79 100644 --- a/core/src/Hoodle/Coroutine/Page.hs +++ b/core/src/Hoodle/Coroutine/Page.hs @@ -2,6 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} module Hoodle.Coroutine.Page where diff --git a/core/src/Hoodle/Coroutine/Pen.hs b/core/src/Hoodle/Coroutine/Pen.hs index 47be382c..263a5e67 100644 --- a/core/src/Hoodle/Coroutine/Pen.hs +++ b/core/src/Hoodle/Coroutine/Pen.hs @@ -1,6 +1,7 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} module Hoodle.Coroutine.Pen where diff --git a/core/src/Hoodle/Coroutine/Select.hs b/core/src/Hoodle/Coroutine/Select.hs index 7eba8aef..56ececc6 100644 --- a/core/src/Hoodle/Coroutine/Select.hs +++ b/core/src/Hoodle/Coroutine/Select.hs @@ -1,5 +1,6 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiWayIf #-} +{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} module Hoodle.Coroutine.Select where diff --git a/core/src/Hoodle/Coroutine/Select/Clipboard.hs b/core/src/Hoodle/Coroutine/Select/Clipboard.hs index e1a3fb7a..da841fce 100644 --- a/core/src/Hoodle/Coroutine/Select/Clipboard.hs +++ b/core/src/Hoodle/Coroutine/Select/Clipboard.hs @@ -1,4 +1,5 @@ {-# LANGUAGE LambdaCase #-} +{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} module Hoodle.Coroutine.Select.Clipboard where diff --git a/core/src/Hoodle/ModelAction/File.hs b/core/src/Hoodle/ModelAction/File.hs index 8009d707..bee88773 100644 --- a/core/src/Hoodle/ModelAction/File.hs +++ b/core/src/Hoodle/ModelAction/File.hs @@ -1,6 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE OverloadedStrings #-} +{-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-unused-matches #-} -- | -- Module : Hoodle.ModelAction.File @@ -39,10 +40,10 @@ import Graphics.GD.ByteString loadPngFile, savePngByteString, ) -import Graphics.Hoodle.Render.Background (popplerGetDocFromFile) +-- import Graphics.Hoodle.Render.Background (popplerGetDocFromFile) import Graphics.Hoodle.Render.Type.Hoodle (rHoodle2Hoodle) -import qualified Graphics.UI.Gtk.Poppler.Document as Poppler -import qualified Graphics.UI.Gtk.Poppler.Page as PopplerPage +-- import qualified Graphics.UI.Gtk.Poppler.Document as Poppler +-- import qualified Graphics.UI.Gtk.Poppler.Page as PopplerPage import Hoodle.Type.HoodleState ( FileStore (LocalDir, TempDir), UnitHoodle, @@ -191,13 +192,16 @@ makeNewHoodleWithPDF doesembed ofp = do return (nfp', nfname') else return (ocanonicalfp, ofname) - mdoc <- popplerGetDocFromFile nfname + -- mdoc <- popplerGetDocFromFile nfname + let mdoc = Nothing case mdoc of Nothing -> do putStrLn $ "no such file " ++ nfp - return Nothing + pure Nothing Just doc -> do - n <- Poppler.documentGetNPages doc + pure Nothing + +{- n <- Poppler.documentGetNPages doc let createPageAct i = do pg <- Poppler.documentGetPage doc (i - 1) @@ -214,6 +218,7 @@ makeNewHoodleWithPDF doesembed ofp = do return (set embeddedPdf (Just ebdsrc) hdl) else return hdl return (Just nhdl) +-} -- | createPage :: diff --git a/core/src/Hoodle/ModelAction/Select.hs b/core/src/Hoodle/ModelAction/Select.hs index f0abb50e..06f3cca6 100644 --- a/core/src/Hoodle/ModelAction/Select.hs +++ b/core/src/Hoodle/ModelAction/Select.hs @@ -1,5 +1,6 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE TypeFamilies #-} +{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} module Hoodle.ModelAction.Select where diff --git a/core/src/Hoodle/ModelAction/Window.hs b/core/src/Hoodle/ModelAction/Window.hs index 6cc62900..5400044f 100644 --- a/core/src/Hoodle/ModelAction/Window.hs +++ b/core/src/Hoodle/ModelAction/Window.hs @@ -1,6 +1,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} module Hoodle.ModelAction.Window where diff --git a/core/src/Hoodle/Type/Alias.hs b/core/src/Hoodle/Type/Alias.hs index f4a38837..53155890 100644 --- a/core/src/Hoodle/Type/Alias.hs +++ b/core/src/Hoodle/Type/Alias.hs @@ -3,6 +3,7 @@ module Hoodle.Type.Alias where +import Data.Kind (Type) import Graphics.Hoodle.Render.Type ( HHoodle, HPage, @@ -16,11 +17,11 @@ data EditMode = EditMode -- | data SelectMode = SelectMode -type family Hoodle a :: * +type family Hoodle a :: Type -type family Page a :: * +type family Page a :: Type -type family Layer a :: * +type family Layer a :: Type type instance Page EditMode = RPage diff --git a/core/src/Hoodle/Type/Canvas.hs b/core/src/Hoodle/Type/Canvas.hs index 793fb217..d81dd41b 100644 --- a/core/src/Hoodle/Type/Canvas.hs +++ b/core/src/Hoodle/Type/Canvas.hs @@ -5,6 +5,7 @@ {-# LANGUAGE Rank2Types #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# OPTIONS_GHC -fno-warn-incomplete-record-updates #-} module Hoodle.Type.Canvas ( -- * data types diff --git a/core/src/Hoodle/Type/PageArrangement.hs b/core/src/Hoodle/Type/PageArrangement.hs index 69f9ad6e..ef49f877 100644 --- a/core/src/Hoodle/Type/PageArrangement.hs +++ b/core/src/Hoodle/Type/PageArrangement.hs @@ -2,7 +2,8 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE PolyKinds #-} -{-# LANGUAGE NoMonoPatBinds #-} + +-- {-# LANGUAGE NoMonoPatBinds #-} module Hoodle.Type.PageArrangement where diff --git a/core/src/Hoodle/View/Draw.hs b/core/src/Hoodle/View/Draw.hs index 5899bc2d..165e3a7a 100644 --- a/core/src/Hoodle/View/Draw.hs +++ b/core/src/Hoodle/View/Draw.hs @@ -52,6 +52,7 @@ import Data.Hoodle.Select import Data.Hoodle.Simple (Dimension (..), Stroke (..)) import Data.Hoodle.Zipper (currIndex) import qualified Data.IntMap as M +import Data.Kind (Type) import Data.Maybe (mapMaybe) import Data.Sequence (Seq (..), ViewL (..), viewl) import Graphics.Hoodle.Render @@ -163,7 +164,7 @@ import Hoodle.View.Coordinate import Prelude hiding (concatMap, foldr, mapM_) -- | -type family DrawingFunction (v :: ViewMode) :: * -> * +type family DrawingFunction (v :: ViewMode) :: Type -> Type -- | newtype SinglePageDraw a = SinglePageDraw diff --git a/core/src/Hoodle/Widget/PanZoom.hs b/core/src/Hoodle/Widget/PanZoom.hs index 078f698a..73ca9355 100644 --- a/core/src/Hoodle/Widget/PanZoom.hs +++ b/core/src/Hoodle/Widget/PanZoom.hs @@ -1,5 +1,6 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiWayIf #-} +{-# OPTIONS_GHC -fno-warn-overlapping-patterns #-} -- | -- Module : Hoodle.Widget.PanZoom diff --git a/publish/exe/hoodle-publish.hs b/publish/exe/hoodle-publish.hs index 79195200..84227d47 100644 --- a/publish/exe/hoodle-publish.hs +++ b/publish/exe/hoodle-publish.hs @@ -2,6 +2,7 @@ module Main where +{- import Control.Monad (filterM) import Data.Maybe (isNothing, mapMaybe) import qualified Graphics.UI.Gtk as Gtk (initGUI) @@ -71,3 +72,7 @@ main = do mapM_ removeFile willbeerased updatedpairs <- filterM isUpdated pairs mapM_ (createPdf (urlbase params, specialurlbase params) (rootpath params)) updatedpairs +-} + +main :: IO () +main = pure () diff --git a/publish/lib/Hoodle/Publish/PDF.hs b/publish/lib/Hoodle/Publish/PDF.hs index b8774d09..2b1f7961 100644 --- a/publish/lib/Hoodle/Publish/PDF.hs +++ b/publish/lib/Hoodle/Publish/PDF.hs @@ -4,6 +4,7 @@ module Hoodle.Publish.PDF where +{- import Control.Applicative ((<|>)) import Control.Exception (SomeException (..), catch) import Control.Lens (view, _1, _2, _3, _4) @@ -23,9 +24,11 @@ import Data.Attoparsec.ByteString.Char8 ) import qualified Data.ByteString.Char8 as B import qualified Data.ByteString.Lazy as BSL +import Data.Either (isLeft) import Data.Functor (($>)) import qualified Data.Hoodle.Simple as S import Data.Int (Int64) +import Data.Maybe (catMaybes) import Data.UUID (UUID, fromString) import Data.UUID.V4 (nextRandom) import Graphics.Hoodle.Render @@ -40,47 +43,44 @@ import Graphics.Rendering.Cairo ) import Network.HTTP.Base (urlEncode) import Network.URI (unEscapeString) -import Pdf.Toolbox.Core +import Pdf.Core ( Array (..), Dict (..), - Number (..), Object (..), - PdfWriter, + -- PdfWriter, Ref (..), - Str (..), + -- Str (..), Stream (..), - deleteObject, - rawStreamContent, - runPdfWriter, - writeObject, - writePdfHeader, - writeXRefTable, + -- deleteObject, + -- rawStreamContent, + -- runPdfWriter, + -- writeObject, + -- writePdfHeader, + -- writeXRefTable, ) -import Pdf.Toolbox.Document +import Pdf.Document ( Pdf, - catMaybes, catalogPageNode, defaultUserPassword, deref, document, documentCatalog, - fromObject, - getRIS, - intValue, + -- fromObject, + -- getRIS, + -- intValue, isEncrypted, - isLeft, - knownFilters, - lookupDict, + -- knownFilters, + -- lookupDict, lookupObject, - mapObject, + -- mapObject, pageContents, pageNodeNKids, pageNodePageByNum, - runPdfWithHandle, + -- runPdfWithHandle, setUserPassword, - toStream, + -- toStream, ) -import Pdf.Toolbox.Document.Internal.Types (Page (..)) +import Pdf.Document.Internal.Types (Page (..)) import System.Directory ( canonicalizePath, doesDirectoryExist, @@ -501,3 +501,4 @@ createPdf (urlbase, specialurlbase) rootpath (fn, ofn) = catch action (\(e :: So writePdfFile fn dim (urlbase, specialurlbase) (rootpath, currpath) tempfile npglnks muuid writeTrailer removeFile tempfile +-} From 900daf1d704aa94a1112bcebdd5950275342ed31 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 16 Jan 2023 09:37:58 -0800 Subject: [PATCH 3/6] remove HandwritingRecognition module. --- core/hoodle-core.cabal | 1 - core/src/Hoodle/Coroutine/ContextMenu.hs | 3 - core/src/Hoodle/Coroutine/Default/Menu.hs | 1 - .../Coroutine/HandwritingRecognition.hs | 194 ------------------ 4 files changed, 199 deletions(-) delete mode 100644 core/src/Hoodle/Coroutine/HandwritingRecognition.hs diff --git a/core/hoodle-core.cabal b/core/hoodle-core.cabal index 5e3e3504..179f77a2 100644 --- a/core/hoodle-core.cabal +++ b/core/hoodle-core.cabal @@ -93,7 +93,6 @@ Library Hoodle.Coroutine.Draw Hoodle.Coroutine.Eraser Hoodle.Coroutine.File - Hoodle.Coroutine.HandwritingRecognition Hoodle.Coroutine.Highlighter Hoodle.Coroutine.Layer Hoodle.Coroutine.Link diff --git a/core/src/Hoodle/Coroutine/ContextMenu.hs b/core/src/Hoodle/Coroutine/ContextMenu.hs index 7db137df..8efaebb0 100644 --- a/core/src/Hoodle/Coroutine/ContextMenu.hs +++ b/core/src/Hoodle/Coroutine/ContextMenu.hs @@ -84,9 +84,6 @@ import Hoodle.Coroutine.Draw waitSomeEvent, ) import Hoodle.Coroutine.File (fileExtensionInvalid) --- import Hoodle.Coroutine.HandwritingRecognition --- ( handwritingRecognitionDialog, --- ) import Hoodle.Coroutine.Scroll ( adjustScrollbarWithGeometryCvsId, ) diff --git a/core/src/Hoodle/Coroutine/Default/Menu.hs b/core/src/Hoodle/Coroutine/Default/Menu.hs index 2667633c..9007962b 100644 --- a/core/src/Hoodle/Coroutine/Default/Menu.hs +++ b/core/src/Hoodle/Coroutine/Default/Menu.hs @@ -49,7 +49,6 @@ import Hoodle.Coroutine.File fileShowUUID, fileVersionSave, ) --- import Hoodle.Coroutine.HandwritingRecognition (handwritingRecognitionDialog) import Hoodle.Coroutine.LaTeX (laTeXFooter, laTeXHeader) import Hoodle.Coroutine.Layer ( deleteCurrentLayer, diff --git a/core/src/Hoodle/Coroutine/HandwritingRecognition.hs b/core/src/Hoodle/Coroutine/HandwritingRecognition.hs deleted file mode 100644 index bfd2ba0c..00000000 --- a/core/src/Hoodle/Coroutine/HandwritingRecognition.hs +++ /dev/null @@ -1,194 +0,0 @@ -{-# LANGUAGE CPP #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RecordWildCards #-} - -module Hoodle.Coroutine.HandwritingRecognition where - -{- -import Control.Error.Util (failWith, hoistEither) -import Control.Lens (view, _1, _2) -import Control.Monad (guard, when, (<=<)) -import Control.Monad.Trans (liftIO) -import Control.Monad.Trans.Except (ExceptT, runExceptT, throwE) -import Data.Aeson (Value (..), encode, json) -import qualified Data.Attoparsec.ByteString.Char8 as AP -import qualified Data.ByteString.Char8 as B -import qualified Data.ByteString.Lazy.Char8 as LB -import Data.Foldable (mapM_) -import qualified Data.HashMap.Strict as HM -import Data.Hoodle.Simple (Stroke (..)) -import qualified Data.List as L (lookup) -import Data.Maybe (mapMaybe) -import Data.Strict.Tuple (Pair (..), fst, snd, zip) -import qualified Data.Text as T -import Data.Traversable (forM) -import Data.UUID.V4 (nextRandom) -import Data.Vector - ( Vector, - fromList, - toList, - (!?), - ) -import qualified Graphics.UI.Gtk as Gtk -import Hoodle.Coroutine.Draw (waitSomeEvent) -import Hoodle.Coroutine.Minibuffer (minibufDialog) -import Hoodle.Type.Coroutine (MainCoroutine, doIOaction) -import Hoodle.Type.Event - ( AllEvent (UsrEv), - UserEvent (GotRecogResult, OkCancel), - ) -import Hoodle.Util (msgShout) -import System.Directory - ( doesDirectoryExist, - doesFileExist, - getHomeDirectory, - getTemporaryDirectory, - ) -import System.Exit (ExitCode (ExitSuccess)) -import System.FilePath ((<.>), ()) -import System.Process (readProcessWithExitCode) --- -import Prelude hiding (fst, mapM_, snd, zip) - -getArray :: (Monad m) => Value -> ExceptT String m (Vector Value) -getArray (Array v) = pure v -getArray _ = throwE "Not an array" - -getArrayVal :: (Monad m) => Int -> Value -> ExceptT String m Value -getArrayVal n v = - getArray v >>= \vs -> - failWith (show n ++ " is out of array") (vs !? n) - -handwritingRecognitionDialog :: MainCoroutine (Maybe (Bool, T.Text)) -handwritingRecognitionDialog = do - r <- minibufDialog "Write hoodlet here" - case r of - Left err -> liftIO (print err) >> return Nothing - Right strks -> do - uuid <- liftIO nextRandom - tdir <- liftIO getTemporaryDirectory - let bstr = (encode . mkAesonInk) strks - let fp = tdir show uuid <.> "json" - liftIO $ LB.writeFile fp bstr - (excode, gresult, gerror) <- liftIO $ readProcessWithExitCode "curl" ["-X", "POST", "-H", "Content-Type: application/json ", "--data-ascii", "@" ++ fp, "http://inputtools.google.com/request?itc=en-t-i0-handwrit"] "" - case excode of - ExitSuccess -> do - r_parse <- runExceptT $ do - v0 <- hoistEither (AP.parseOnly json (B.pack gresult)) - getArrayVal 0 v0 >>= \succstr -> - guard (succstr == String "SUCCESS") - v4 <- - ( getArray <=< getArrayVal 1 - <=< getArrayVal 0 - <=< getArrayVal 1 - ) - v0 - let f (String v) = Just v - f _ = Nothing - (return . Data.Maybe.mapMaybe f . toList) v4 - - case r_parse of - Left err -> msgShout ("handwritingRecognitionDialog: " ++ err) >> return Nothing - Right lst -> showRecogTextDialog lst - _ -> msgShout ("handwritingRecognitionDialog: " ++ gerror) >> return Nothing - -showRecogTextDialog :: [T.Text] -> MainCoroutine (Maybe (Bool, T.Text)) -showRecogTextDialog txts = - do - doIOaction action - >> waitSomeEvent - ( \case - OkCancel _ -> True - GotRecogResult _ _ -> True - _ -> False - ) - >>= \case - OkCancel _ -> return Nothing - GotRecogResult b txt -> return (Just (b, txt)) - _ -> return Nothing - where - action evhandler = do - dialog <- Gtk.dialogNew - upper <- fmap Gtk.castToContainer (Gtk.dialogGetContentArea dialog) - vbox <- Gtk.vBoxNew False 0 - Gtk.containerAdd upper vbox - let txtlst' = zip [1 ..] txts - txtlst <- forM txtlst' $ \(n :!: txt) -> do - let str = T.unpack txt - homedir <- getHomeDirectory - let hoodled = homedir ".hoodle.d" - hoodletdir = hoodled "hoodlet" - b <- doesDirectoryExist hoodletdir - b2 <- - if not b - then return False - else doesFileExist (hoodletdir str <.> "hdlt") - return (n, (b2, txt)) - mapM_ (addOneTextBox evhandler dialog vbox) txtlst - _btnCancel <- Gtk.dialogAddButton dialog ("Cancel" :: String) Gtk.ResponseCancel - Gtk.widgetShowAll dialog - res <- Gtk.dialogRun dialog - Gtk.widgetDestroy dialog - case res of - Gtk.ResponseUser n -> case L.lookup n txtlst of - Nothing -> return (UsrEv (OkCancel False)) - Just (b, txt) -> return (UsrEv (GotRecogResult b txt)) - _ -> return (UsrEv (OkCancel False)) - -addOneTextBox :: - (AllEvent -> IO ()) -> - Gtk.Dialog -> - Gtk.VBox -> - (Int, (Bool, T.Text)) -> - IO () -addOneTextBox _evhandler dialog vbox (n, (b, txt)) = do - btn <- Gtk.buttonNewWithLabel (T.unpack txt) - when b $ do - Gtk.widgetModifyBg btn Gtk.StateNormal (Gtk.Color 60000 60000 30000) - Gtk.widgetModifyBg btn Gtk.StatePrelight (Gtk.Color 63000 63000 40000) - Gtk.widgetModifyBg btn Gtk.StateActive (Gtk.Color 45000 45000 18000) - _ <- btn `Gtk.on` Gtk.buttonPressEvent $ - Gtk.tryEvent $ do - liftIO $ Gtk.dialogResponse dialog (Gtk.ResponseUser n) - Gtk.boxPackStart vbox btn Gtk.PackNatural 0 - -mkAesonInk :: [Stroke] -> Value -mkAesonInk strks = - let strks_value = (Array . fromList . map mkAesonStroke) strks - hm0 = - HM.insert "writing_area_width" (Number 500) - . HM.insert "writing_area_height" (Number 50) - $ HM.empty - - hm1 = - HM.insert "writing_guide" (Object hm0) - . HM.insert "pre_context" (String "") - . HM.insert "max_num_results" (Number 10) - . HM.insert "max_completions" (Number 0) - . HM.insert "ink" strks_value - $ HM.empty - hm2 = - HM.insert "feedback" (String "∅[deleted]") - . HM.insert "select_type" (String "deleted") - $ HM.empty - hm3 = - HM.insert "app_version" (Number 0.4) - . HM.insert "api_level" (String "537.36") - . HM.insert "device" "hoodle" - . HM.insert "input_type" (Number 0) - . HM.insert "options" (String "enable_pre_space") - . HM.insert "requests" (Array (fromList [Object hm1, Object hm2])) - $ HM.empty - in Object hm3 - -mkAesonStroke :: Stroke -> Value -mkAesonStroke Stroke {..} = - let xs = map (Number . fromInteger . (floor :: Double -> Integer) . fst) stroke_data - ys = map (Number . fromInteger . (floor :: Double -> Integer) . snd) stroke_data - in Array (fromList [Array (fromList xs), Array (fromList ys)]) -mkAesonStroke VWStroke {..} = - let xs = map (Number . fromInteger . (floor :: Double -> Integer) . view _1) stroke_vwdata - ys = map (Number . fromInteger . (floor :: Double -> Integer) . view _2) stroke_vwdata - in Array (fromList [Array (fromList xs), Array (fromList ys)]) --} From 6b77a12ac495732a6b290b83ee4409ebfa0e7a40 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 16 Jan 2023 09:41:31 -0800 Subject: [PATCH 4/6] remove handwriting rec from the menu --- core/src/Hoodle/Coroutine/Default/Menu.hs | 2 -- core/src/Hoodle/GUI/Menu.hs | 2 -- core/src/Hoodle/Type/Event.hs | 1 - 3 files changed, 5 deletions(-) diff --git a/core/src/Hoodle/Coroutine/Default/Menu.hs b/core/src/Hoodle/Coroutine/Default/Menu.hs index 9007962b..4a994cdf 100644 --- a/core/src/Hoodle/Coroutine/Default/Menu.hs +++ b/core/src/Hoodle/Coroutine/Default/Menu.hs @@ -245,8 +245,6 @@ menuEventProcess MenuTogglePanZoomWidget = togglePanZoom . view (unitHoodles . c menuEventProcess MenuToggleLayerWidget = toggleLayer . view (unitHoodles . currentUnit . currentCanvas . _1) =<< get menuEventProcess MenuToggleClockWidget = toggleClock . view (unitHoodles . currentUnit . currentCanvas . _1) =<< get menuEventProcess MenuToggleScrollWidget = toggleScroll . view (unitHoodles . currentUnit . currentCanvas . _1) =<< get -menuEventProcess MenuHandwritingRecognitionDialog = pure () --- handwritingRecognitionDialog >>= mapM_ (\(b, txt) -> when b $ embedHoodlet (T.unpack txt)) menuEventProcess MenuAddTab = addTab (LocalDir Nothing) menuEventProcess MenuCloseTab = closeTab menuEventProcess MenuEditNetEmbedTextSource = editNetEmbeddedTextSource diff --git a/core/src/Hoodle/GUI/Menu.hs b/core/src/Hoodle/GUI/Menu.hs index 633ccf64..76317f98 100644 --- a/core/src/Hoodle/GUI/Menu.hs +++ b/core/src/Hoodle/GUI/Menu.hs @@ -339,7 +339,6 @@ getMenuUI evar = do linka <- actionNewAndRegister "LINKA" "Add Link" (Just "Add Link") (Just Gtk.stockIndex) (justMenu MenuAddLink) anchora <- actionNewAndRegister "ANCHORA" "Add Anchor" (Just "Add Anchor") Nothing (justMenu MenuAddAnchor) listanchora <- actionNewAndRegister "LISTANCHORA" "List Anchors" (Just "List Anchors") Nothing (justMenu MenuListAnchors) - handreca <- actionNewAndRegister "HANDRECA" "Hoodlet load via Handwriting Recognition" (Just "Just a Stub") (Just "myshapes") (justMenu MenuHandwritingRecognitionDialog) clra <- actionNewAndRegister "CLRA" "Color" (Just "Just a Stub") Nothing Nothing clrpcka <- actionNewAndRegister "CLRPCKA" "Color Picker.." (Just "Just a Stub") (Just Gtk.stockSelectColor) (justMenu MenuColorPicker) @@ -484,7 +483,6 @@ getMenuUI evar = do linka, anchora, listanchora, - handreca, clra, clrpcka, penopta, diff --git a/core/src/Hoodle/Type/Event.hs b/core/src/Hoodle/Type/Event.hs index b659725b..5cc4ece6 100644 --- a/core/src/Hoodle/Type/Event.hs +++ b/core/src/Hoodle/Type/Event.hs @@ -207,7 +207,6 @@ data MenuEvent | MenuAddLink | MenuAddAnchor | MenuListAnchors - | MenuHandwritingRecognitionDialog | MenuSelectRegion | MenuSelectRectangle | MenuVerticalSpace From c396e26a99b2f7a4d2d94611f074b6ef8e411299 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 16 Jan 2023 10:01:55 -0800 Subject: [PATCH 5/6] pin ubuntu to 20.04, for hlint ref: https://github.com/rwe/actions-hlint-run/issues/260 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3198e0ef..d8d65ddb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ jobs: # ormolu 0.3.0.1 - uses: mrkkrp/ormolu-action@v4 hlint: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - uses: rwe/actions-hlint-setup@v1 From 2ae0987b103921cb17f39e54963078ac884fb8a3 Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Mon, 16 Jan 2023 10:08:22 -0800 Subject: [PATCH 6/6] HLINT fix --- publish/exe/hoodle-publish.hs | 1 + publish/lib/Hoodle/Publish/PDF.hs | 1 + .../src/Graphics/Hoodle/Render/Background.hs | 18 +++++++++--------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/publish/exe/hoodle-publish.hs b/publish/exe/hoodle-publish.hs index 84227d47..e5dc34e5 100644 --- a/publish/exe/hoodle-publish.hs +++ b/publish/exe/hoodle-publish.hs @@ -1,3 +1,4 @@ +{- HLINT ignore -} {-# LANGUAGE DeriveDataTypeable #-} module Main where diff --git a/publish/lib/Hoodle/Publish/PDF.hs b/publish/lib/Hoodle/Publish/PDF.hs index 2b1f7961..d7e1acc5 100644 --- a/publish/lib/Hoodle/Publish/PDF.hs +++ b/publish/lib/Hoodle/Publish/PDF.hs @@ -1,3 +1,4 @@ +{- HLINT ignore -} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} diff --git a/render/src/Graphics/Hoodle/Render/Background.hs b/render/src/Graphics/Hoodle/Render/Background.hs index 9c6028f1..d6352f08 100644 --- a/render/src/Graphics/Hoodle/Render/Background.hs +++ b/render/src/Graphics/Hoodle/Render/Background.hs @@ -285,15 +285,15 @@ renderBackgroundStateT dim@(Dim w h) bkg = do -- pdfRenderDoc doc pn pure () maybe (error "renderBackgroundStateT") (const (return ())) r - where {- -pdfRender pg = do - Cairo.setSourceRGBA 1 1 1 1 - Cairo.rectangle 0 0 w h - Cairo.fill - PopplerPage.pageRender pg -pdfRenderDoc doc pn = - (MaybeT . liftIO) (popplerGetPageFromDoc doc pn) - >>= lift . lift . pdfRender + where + pdfRender pg = do + Cairo.setSourceRGBA 1 1 1 1 + Cairo.rectangle 0 0 w h + Cairo.fill + PopplerPage.pageRender pg + pdfRenderDoc doc pn = + (MaybeT . liftIO) (popplerGetPageFromDoc doc pn) + >>= lift . lift . pdfRender -}