packages feed

ltk 0.13.1.0 → 0.13.2.0

raw patch · 3 files changed

+57/−12 lines, 3 files

Files

ltk.cabal view
@@ -1,5 +1,5 @@ name: ltk-version: 0.13.1.0+version: 0.13.2.0 cabal-version: >= 1.8 build-type: Simple license: GPL@@ -14,6 +14,10 @@ category: GUI author: Juergen "jutaro" Nicklisch-Franken tested-with: GHC ==6.10 || ==6.12 || ==7.0++source-repository head+  type:     git+  location: https://github.com/leksah/ltk  Flag gtk3     description: Use Gtk3
src/Graphics/UI/Editor/Composite.hs view
@@ -711,24 +711,18 @@ dependencyEditor :: [PackageIdentifier] -> Editor Dependency dependencyEditor packages para noti = do     (wid,inj,ext) <- pairEditor-        ((eitherOrEditor (comboSelectionEditor ((sort . nub) (map (display . pkgName) packages)) id+        (comboEntryEditor ((sort . nub) (map (display . pkgName) packages))             , paraName <<<- ParaName "Select" $ emptyParams)-            (stringEditor (const True) True, paraName <<<- ParaName "Enter" $ emptyParams)-            "Select from list?"), paraName <<<- ParaName "Name"$ emptyParams)         (versionRangeEditor,paraName <<<- ParaName "Version" $ emptyParams)         (paraDirection <<<- ParaDirection Vertical $ para)         noti-    let pinj (Dependency pn@(PackageName s) v) = if elem s (map (display . pkgName) packages)-                                                    then inj (Left s,v)-                                                    else inj (Right s,v)+    let pinj (Dependency pn@(PackageName s) v) = inj (s,v)     let pext = do         mbp <- ext         case mbp of             Nothing -> return Nothing-            Just (Left "",v) -> return Nothing-            Just (Left s,v) -> return (Just $ Dependency (PackageName s) v)-            Just (Right "",v) -> return Nothing-            Just (Right s,v) -> return (Just $ Dependency (PackageName s) v)+            Just ("",v) -> return Nothing+            Just (s,v) -> return (Just $ Dependency (PackageName s) v)     return (wid,pinj,pext)  dependenciesEditor :: [PackageIdentifier] -> Editor [Dependency]
src/Graphics/UI/Editor/Simple.hs view
@@ -26,6 +26,7 @@ ,   fontEditor ,   colorEditor ,   comboSelectionEditor+,   comboEntryEditor ,   staticListEditor ,   staticListMultiEditor ,   multiselectionEditor@@ -55,6 +56,7 @@         genericGUIEvents, activateEvent, Editor) import Control.Exception as E (catch, IOException) import Control.Monad.IO.Class (MonadIO(..))+import Control.Applicative ((<$>))  -- ------------------------------------------------------------ -- * Simple Editors@@ -379,7 +381,6 @@ -- -- | Editor for the selection of some element from a static list of elements in the -- | form of a combo box- comboSelectionEditor :: Eq beta => [beta] -> (beta -> String) -> Editor beta comboSelectionEditor list showF parameters notifier = do     coreRef <- newIORef Nothing@@ -417,6 +418,52 @@                     case ind of                         (-1)   -> return Nothing                         otherwise  -> return (Just (list !! ind)))+        parameters+        notifier++-- | Like comboSelectionEditor but allows entry of text not in the list+comboEntryEditor :: [String] -> Editor String+comboEntryEditor list parameters notifier = do+    coreRef <- newIORef Nothing+    mkEditor+        (\widget obj -> do+            core <- readIORef coreRef+            case core of+                Nothing  -> do+                    combo <- comboBoxNewWithEntry+                    comboBoxSetModelText combo+                    widgetSetSizeRequest combo 200 (-1)+                    mapM_ (comboBoxAppendText combo) list+                    widgetSetName combo (getParameter paraName parameters)+                    mapM_ (activateEvent (castToWidget combo) notifier Nothing) genericGUIEvents+                    activateEvent (castToWidget combo) notifier+                        (Just (\ w h -> do+                            res     <-  on (castToComboBox w) changed (h >> return ())+                            return (unsafeCoerce res))) MayHaveChanged+                    comboBoxSetActive combo 1+                    containerAdd widget combo+                    let ind = elemIndex obj list+                    case ind of+                        Just i -> comboBoxSetActive combo i+                        Nothing -> do+                            mbEntry <- binGetChild combo+                            case mbEntry of+                                Nothing -> return ()+                                Just entry -> entrySetText (castToEntry entry) obj+                    writeIORef coreRef (Just combo)+                Just combo -> do+                    let ind = elemIndex obj list+                    case ind of+                        Just i -> comboBoxSetActive combo i+                        Nothing -> return ())+        (do core <- readIORef coreRef+            case core of+                Nothing -> return Nothing+                Just combo -> do+                    mbEntry <- binGetChild combo+                    case mbEntry of+                        Nothing -> return Nothing+                        Just entry -> Just <$> entryGetText (castToEntry entry))         parameters         notifier