wild-bind-indicator 1.0.0.1 → 1.0.0.2
raw patch · 4 files changed
+126/−125 lines, 4 filesdep ~asyncdep ~basedep ~containerssetup-changed
Dependency ranges changed: async, base, containers, gi-gdk, gi-glib, gi-gtk, text, transformers, wild-bind
Files
- ChangeLog.md +5/−0
- Setup.hs +1/−1
- src/WildBind/Indicator.hs +108/−113
- wild-bind-indicator.cabal +12/−11
ChangeLog.md view
@@ -1,5 +1,10 @@ # Revision history for wild-bind-indicator +## 1.0.0.2 -- 2024-09-25++* Update the dependency version bounds, generated by cabal-plan-bounds and GitHub Workflow.+ Now it adds support for some new dependency versions, but drop support for some old versions.+ ## 1.0.0.1 -- 2021-03-25 * Documentation update. Now `wildNumPad` is not necessarily the first function to call.
Setup.hs view
@@ -1,2 +1,2 @@-import Distribution.Simple+import Distribution.Simple main = defaultMain
src/WildBind/Indicator.hs view
@@ -1,109 +1,103 @@-{-# LANGUAGE OverloadedStrings, OverloadedLabels, PatternSynonyms #-}+{-# LANGUAGE OverloadedLabels #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE PatternSynonyms #-} -- | -- Module: WildBind.Indicator -- Description: Graphical indicator for WildBind -- Maintainer: Toshio Ito <debug.ito@gmail.com>--- +-- -- This module exports the 'Indicator', a graphical interface that -- explains the current bindings to the user. The 'Indicator' uses -- 'optBindingHook' in 'Option' to receive the current bindings from -- wild-bind. module WildBind.Indicator- ( -- * Construction- withNumPadIndicator,- -- * Execution- wildBindWithIndicator,- -- * Low-level function- bindingHook,- -- * Indicator type and its actions- Indicator,- updateDescription,- getPresence,- setPresence,- togglePresence,- quit,- -- ** Conversion- adaptIndicator,- -- ** Binding- toggleBinding,- -- * Generalization of number pad types- NumPadPosition(..)- ) where+ ( -- * Construction+ withNumPadIndicator+ -- * Execution+ , wildBindWithIndicator+ -- * Low-level function+ , bindingHook+ -- * Indicator type and its actions+ , Indicator+ , updateDescription+ , getPresence+ , setPresence+ , togglePresence+ , quit+ -- ** Conversion+ , adaptIndicator+ -- ** Binding+ , toggleBinding+ -- * Generalization of number pad types+ , NumPadPosition (..)+ ) where -import Control.Applicative ((<$>))-import Control.Concurrent- (rtsSupportsBoundThreads, newEmptyMVar, putMVar, takeMVar)-import Control.Concurrent.Async (withAsync)-import Control.Exception (throwIO, finally)-import Control.Monad (void, forM_)-import Control.Monad.IO.Class (liftIO)-import Control.Monad.Trans.Reader (ReaderT, runReaderT, ask)-import Data.IORef (newIORef, readIORef)-import qualified Data.Map as M-import Data.Monoid (mconcat, First(First))-import Data.Text (Text, pack)-import Data.Word (Word32)-import System.IO (stderr, hPutStrLn)-import System.Environment (getArgs)+import Control.Applicative ((<$>))+import Control.Concurrent (newEmptyMVar, putMVar, rtsSupportsBoundThreads,+ takeMVar)+import Control.Concurrent.Async (withAsync)+import Control.Exception (finally, throwIO)+import Control.Monad (forM_, void)+import Control.Monad.IO.Class (liftIO)+import Control.Monad.Trans.Reader (ReaderT, ask, runReaderT)+import Data.IORef (newIORef, readIORef)+import qualified Data.Map as M+import Data.Monoid (First (First), mconcat)+import Data.Text (Text, pack)+import Data.Word (Word32)+import System.Environment (getArgs)+import System.IO (hPutStrLn, stderr) -import WildBind ( ActionDescription, Option(optBindingHook),- FrontEnd(frontDefaultDescription), Binding, Binding',- binding, Action(Action),- wildBind', defOption- )-import WildBind.Input.NumPad (NumPadUnlocked(..), NumPadLocked(..))+import WildBind (Action (Action), ActionDescription, Binding,+ Binding', FrontEnd (frontDefaultDescription),+ Option (optBindingHook), binding, defOption,+ wildBind')+import WildBind.Input.NumPad (NumPadLocked (..), NumPadUnlocked (..)) -import Paths_wild_bind_indicator (getDataFileName)+import Paths_wild_bind_indicator (getDataFileName) ---- Imports about Gtk-import GI.Gdk.Functions (threadsAddIdle)-import GI.GLib.Constants (pattern PRIORITY_DEFAULT)-import GI.Gtk - ( -- Data.GI.Base.Attributes- AttrOp((:=))- )-import qualified GI.Gtk as GIAttr (set, get, on)-import GI.Gtk.Enums (WindowType(..), Justification(..))-import qualified GI.Gtk.Functions as GIFunc-import GI.Gtk.Objects.Button (buttonNew, buttonSetAlignment)-import GI.Gtk.Objects.CheckMenuItem (checkMenuItemNewWithMnemonic, checkMenuItemSetActive)-import GI.Gtk.Objects.Container (containerAdd)-import GI.Gtk.Objects.Label (Label, labelNew, labelSetLineWrap, labelSetJustify, labelSetText)-import GI.Gtk.Objects.Menu (Menu, menuNew, menuPopup)-import GI.Gtk.Objects.MenuItem (menuItemNewWithMnemonic)-import GI.Gtk.Objects.Misc (miscSetAlignment)-import GI.Gtk.Objects.StatusIcon (statusIconNewFromFile)-import GI.Gtk.Objects.Table (Table, tableNew, tableAttachDefaults)-import GI.Gtk.Objects.Widget (Widget, widgetSetSizeRequest, widgetShowAll, widgetHide)-import GI.Gtk.Objects.Window- ( Window, windowNew, windowSetKeepAbove, windowSetTitle, windowMove- )+import GI.Gdk.Functions (threadsAddIdle)+import GI.GLib.Constants (pattern PRIORITY_DEFAULT)+import GI.Gtk (AttrOp ((:=)))+import qualified GI.Gtk as GIAttr (get, on, set)+import GI.Gtk.Enums (Justification (..), WindowType (..))+import qualified GI.Gtk.Functions as GIFunc+import GI.Gtk.Objects.Button (buttonNew, buttonSetAlignment)+import GI.Gtk.Objects.CheckMenuItem (checkMenuItemNewWithMnemonic, checkMenuItemSetActive)+import GI.Gtk.Objects.Container (containerAdd)+import GI.Gtk.Objects.Label (Label, labelNew, labelSetJustify, labelSetLineWrap,+ labelSetText)+import GI.Gtk.Objects.Menu (Menu, menuNew, menuPopup)+import GI.Gtk.Objects.MenuItem (menuItemNewWithMnemonic)+import GI.Gtk.Objects.Misc (miscSetAlignment)+import GI.Gtk.Objects.StatusIcon (statusIconNewFromFile)+import GI.Gtk.Objects.Table (Table, tableAttachDefaults, tableNew)+import GI.Gtk.Objects.Widget (Widget, widgetHide, widgetSetSizeRequest,+ widgetShowAll)+import GI.Gtk.Objects.Window (Window, windowMove, windowNew, windowSetKeepAbove,+ windowSetTitle) -- | Indicator interface. @s@ is the front-end state, @i@ is the input -- type.-data Indicator s i =- Indicator- { updateDescription :: i -> ActionDescription -> IO (),- -- ^ Update and show the description for the current binding.- - getPresence :: IO Bool,- - -- ^ Get the current presence of the indicator. Returns 'True' if- -- it's present.- - setPresence :: Bool -> IO (),- -- ^ Set the presence of the indicator.-- quit :: IO (),- -- ^ Destroy the indicator. This usually means quitting the entire- -- application.-- allButtons :: [i]- -- ^ list of all buttons on which the indicator displays- -- descriptions.- }+data Indicator s i+ = Indicator+ { updateDescription :: i -> ActionDescription -> IO ()+ -- ^ Update and show the description for the current binding.+ , getPresence :: IO Bool+ -- ^ Get the current presence of the indicator. Returns 'True' if+ -- it's present.+ , setPresence :: Bool -> IO ()+ -- ^ Set the presence of the indicator.+ , quit :: IO ()+ -- ^ Destroy the indicator. This usually means quitting the entire+ -- application.+ , allButtons :: [i]+ -- ^ list of all buttons on which the indicator displays+ -- descriptions.+ } -- | Toggle the presence of the indicator. togglePresence :: Indicator s i -> IO ()@@ -128,29 +122,30 @@ instance NumPadPosition NumPadUnlocked where toNumPad input = case input of- NumInsert -> NumL0- NumEnd -> NumL1- NumDown -> NumL2+ NumInsert -> NumL0+ NumEnd -> NumL1+ NumDown -> NumL2 NumPageDown -> NumL3- NumLeft -> NumL4- NumCenter -> NumL5- NumRight -> NumL6- NumHome -> NumL7- NumUp -> NumL8- NumPageUp -> NumL9- NumDivide -> NumLDivide- NumMulti -> NumLMulti- NumMinus -> NumLMinus- NumPlus -> NumLPlus- NumEnter -> NumLEnter- NumDelete -> NumLPeriod+ NumLeft -> NumL4+ NumCenter -> NumL5+ NumRight -> NumL6+ NumHome -> NumL7+ NumUp -> NumL8+ NumPageUp -> NumL9+ NumDivide -> NumLDivide+ NumMulti -> NumLMulti+ NumMinus -> NumLMinus+ NumPlus -> NumLPlus+ NumEnter -> NumLEnter+ NumDelete -> NumLPeriod -- | Data type keeping read-only config for NumPadIndicator.-data NumPadConfig =- NumPadConfig { confButtonWidth, confButtonHeight :: Int,- confWindowX, confWindowY :: Int,- confIconPath :: FilePath- }+data NumPadConfig+ = NumPadConfig+ { confButtonWidth, confButtonHeight :: Int+ , confWindowX, confWindowY :: Int+ , confIconPath :: FilePath+ } numPadConfig :: IO NumPadConfig numPadConfig = do@@ -167,7 +162,7 @@ type NumPadContext = ReaderT NumPadConfig IO -- | Initialize the indicator and run the given action.--- +-- -- The executable must be compiled by ghc with __@-threaded@ option enabled.__ -- Otherwise, it aborts. withNumPadIndicator :: (NumPadPosition i, Enum i, Bounded i) => (Indicator s i -> IO ()) -> IO ()@@ -199,7 +194,7 @@ return True -- Do not emit 'destroy' signal return indicator asyncAction indicator =- (action $ transportIndicator indicator) `finally` (postGUIAsync GIFunc.mainQuit) + (action $ transportIndicator indicator) `finally` (postGUIAsync GIFunc.mainQuit) createStatusIcon conf indicator = do status_icon <- statusIconNewFromFile $ confIconPath conf void $ GIAttr.on status_icon #popupMenu $ \button time -> do@@ -219,8 +214,8 @@ bindingHook ind front bind_list = forM_ (allButtons ind) $ \input -> do let desc = M.findWithDefault (frontDefaultDescription front input) input (M.fromList bind_list) updateDescription ind input desc- - ++ newNumPadWindow :: NumPadContext Window newNumPadWindow = do win <- windowNew WindowTypeToplevel@@ -266,7 +261,7 @@ ] let description_updater = \input -> case descript_action_getter $ toNumPad input of First (Just act) -> act- First Nothing -> const $ return ()+ First Nothing -> const $ return () return (tab, description_updater) where getter :: Eq i => i -> NumPadContext Label -> NumPadContext (DescriptActionGetter i)@@ -325,7 +320,7 @@ } where newDesc input = case cmapper input of- Nothing -> const $ return ()+ Nothing -> const $ return () Just orig_input -> updateDescription ind orig_input -- | A binding that toggles presence of the 'Indicator'.
wild-bind-indicator.cabal view
@@ -1,5 +1,5 @@ name: wild-bind-indicator-version: 1.0.0.1+version: 1.0.0.2 author: Toshio Ito <debug.ito@gmail.com> maintainer: Toshio Ito <debug.ito@gmail.com> license: BSD3@@ -7,7 +7,7 @@ synopsis: Graphical indicator for WildBind description: Graphical indicator for WildBind. See <https://github.com/debug-ito/wild-bind> category: UserInterface-cabal-version: >= 1.10+cabal-version: 2.0 build-type: Simple extra-source-files: README.md, ChangeLog.md homepage: https://github.com/debug-ito/wild-bind@@ -22,15 +22,16 @@ other-extensions: OverloadedStrings, OverloadedLabels exposed-modules: WildBind.Indicator other-modules: Paths_wild_bind_indicator- build-depends: base >=4.9 && <5.0,- wild-bind >=0.1.0 && <0.2,- transformers >=0.3.0 && <0.6,- gi-gtk >=3.0.3 && <3.1,- gi-gdk >=3.0.3 && <3.1,- gi-glib >=2.0.3 && <2.1,- async >=2.1.1.1 && <2.3,- text >=1.2.0 && <1.3,- containers >=0.5.0 && <0.7+ autogen-modules: Paths_wild_bind_indicator+ build-depends: base ^>=4.14.3 || ^>=4.15.0 || ^>=4.16.0 || ^>=4.17.0 || ^>=4.18.0 || ^>=4.19.0 || ^>=4.20.0,+ wild-bind ^>=0.1.2,+ transformers ^>=0.5.6 || ^>=0.6.1,+ gi-gtk ^>=3.0.38,+ gi-gdk ^>=3.0.25,+ gi-glib ^>=2.0.26,+ async ^>=2.2.4,+ text ^>=1.2.4 || ^>=2.0.1 || ^>=2.1,+ containers ^>=0.6.4 || ^>=0.7 -- executable wild-bind-indicator -- default-language: Haskell2010