monomer-flatpak-example 0.0.5.0 → 0.0.5.1
raw patch · 4 files changed
+19/−9 lines, 4 files
Files
- app/Desktop/Portal.hs +15/−7
- app/Main.hs +2/−1
- assets/io.github.Dretch.MonomerFlatpakExample.metainfo.xml +1/−0
- monomer-flatpak-example.cabal +1/−1
app/Desktop/Portal.hs view
@@ -13,7 +13,7 @@ import Control.Concurrent.MVar (newEmptyMVar) import Control.Exception (onException, throwIO) import Control.Monad (when)-import DBus (BusName, InterfaceName, MemberName, MethodCall, ObjectPath)+import DBus (BusName, InterfaceName, IsVariant, MemberName, MethodCall, ObjectPath) import DBus qualified import DBus.Client (Client, MatchRule (..)) import DBus.Client qualified as DBus@@ -30,7 +30,7 @@ data GetUserInformationResponse = GetUserInformationResponse { userId :: Text, userName :: Text,- userImage :: Text+ userImage :: Maybe Text } deriving (Eq, Show) @@ -84,10 +84,10 @@ resMap | Just userId <- DBus.fromVariant =<< Map.lookup "id" resMap, Just userName <- DBus.fromVariant =<< Map.lookup "name" resMap,- Just userImage <- DBus.fromVariant =<< Map.lookup "image" resMap ->+ Just userImage <- optionalFromVariant resMap "image" -> pure GetUserInformationResponse {..}- _ ->- throwIO (DBus.clientError "getUserInformation: could not parse response")+ resMap ->+ throwIO . DBus.clientError $ "getUserInformation: could not parse response: " <> show resMap openFile :: OpenFileOptions -> IO (Request [Text]) openFile ofOptions =@@ -100,8 +100,8 @@ resMap | Just (uris :: [Text]) <- DBus.fromVariant =<< Map.lookup "uris" resMap -> pure uris- _ ->- throwIO (DBus.clientError "openFile: could not parse response")+ resMap ->+ throwIO . DBus.clientError $ "openFile: could not parse response: " <> show resMap sendRequest :: InterfaceName ->@@ -181,3 +181,11 @@ where escapeClientName = map (\case '.' -> '_'; c -> c) . drop 1 . DBus.formatBusName++-- | Returns @Just Nothing@ if the field does not exist, @Just (Just x)@ if it does exist and+-- can be turned into the expected type, or @Nothing@ if the field exists with the wrong type.+optionalFromVariant :: forall a. IsVariant a => Map Text Variant -> Text -> Maybe (Maybe a)+optionalFromVariant key variants =+ case Map.lookup variants key of+ Nothing -> Just Nothing+ Just var -> Just <$> DBus.fromVariant var
app/Main.hs view
@@ -1,6 +1,7 @@ module Main (main) where import Data.Default.Class (def)+import Data.Maybe (fromMaybe) import Data.Sequence (Seq) import Data.Sequence qualified as Seq import Data.Text (Text, intercalate, pack, unpack)@@ -133,7 +134,7 @@ [ label "Request successful.", label ("User Id: " <> response.userId), label ("User Name: " <> response.userName),- label ("User Image: " <> response.userImage)+ label ("User Image: " <> fromMaybe "[none]" response.userImage) ] openFileAlertContents files =
assets/io.github.Dretch.MonomerFlatpakExample.metainfo.xml view
@@ -23,6 +23,7 @@ </screenshots> <releases>+ <release version="0.0.5.1" date="2023-04-10"/> <release version="0.0.5.0" date="2023-04-09"/> <release version="0.0.4.0" date="2023-04-07"/> <release version="0.0.3.1" date="2023-03-11"/>
monomer-flatpak-example.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.12 name: monomer-flatpak-example-version: 0.0.5.0+version: 0.0.5.1 license: MIT license-file: LICENSE maintainer: garethdanielsmith@gmail.com