Skip to content
Snippets Groups Projects
Commit d2c07786 authored by felix's avatar felix
Browse files

add comboBox helper and updated submit button

parent fa4a4c8c
No related branches found
No related tags found
No related merge requests found
......@@ -11,9 +11,14 @@ module Main (main) where
import qualified GI.Gtk as Gtk
import Data.GI.Base()
import Data.Text (Text)
import Data.Maybe
import LibUniHbMensa as UM
mensaList :: [String]
------ CONST VARS ------------------------------------------------------------
mensaList :: [Text]
mensaList = ["Uni Mensa",
"Mensa NW1",
"Cafeteria GW2",
......@@ -26,14 +31,24 @@ mensaList = ["Uni Mensa",
"Interimsmensa HfK"
]
{- TODO ...
------ HELPER FUNCs ----------------------------------------------------------
comboBoxHelper :: Gtk.ComboBoxText -> [String] -> IO ()
comboBoxHelper :: Gtk.ComboBoxText -> [Text] -> IO ()
comboBoxHelper _ [] = return ()
comboBoxHelper comBox strList = do
Gtk.comboBoxTextAppendText comBox $ head strList
-- TODO comboBoxHelper mit den verbleibenden strings rec aufrufen ...
comboBoxHelper comBox $ tail strList
getMensaIdByText :: Maybe Text -> Int
getMensaIdByText name
| (isJust name) = getMensaIdByTextRec (fromJust name) 0
| otherwise = 0 -- default id = 0 for Uni Mensa
where
getMensaIdByTextRec :: Text -> Int -> Int
getMensaIdByTextRec eman i
| (eman == (mensaList !! i)) = i
| otherwise = getMensaIdByTextRec eman (i + 1)
-}
main :: IO ()
main = do
......@@ -58,37 +73,30 @@ main = do
-- SELECT DINING HALL -----------------------------------------------------
cb <- Gtk.comboBoxTextNew
-- TODO comboBoxHelper cb mensaList
Gtk.comboBoxTextAppendText cb "Uni Mensa"
Gtk.comboBoxTextAppendText cb "Mensa NW1"
Gtk.comboBoxTextAppendText cb "Cafeteria GW2"
Gtk.comboBoxTextAppendText cb "Cafeteria Grazer Straße"
Gtk.comboBoxTextAppendText cb "Mensa Neustadtswall"
Gtk.comboBoxTextAppendText cb "Mensa Werderstraße"
Gtk.comboBoxTextAppendText cb "Mensa Airport"
Gtk.comboBoxTextAppendText cb "Mensa Bremerhaven"
Gtk.comboBoxTextAppendText cb "Cafeteria Bremerhaven"
Gtk.comboBoxTextAppendText cb "Interimsmensa HfK"
comboBoxHelper cb mensaList
Gtk.comboBoxSetActive cb 0
-- SUBMIT BUTTON ----------------------------------------------------------
submit_btn <- Gtk.buttonNewWithLabel "Angebot darstellen" -- VIEW MEAL PLAN
Gtk.buttonSetRelief submit_btn Gtk.ReliefStyleNone
Gtk.widgetSetHexpand submit_btn False
-- TODO show selected meal plan when button is clicked ...
-- on submit_btn #clicked $ do
_ <- Gtk.on submit_btn #clicked $ do
-- TODO ...
-- currentMensaId <- getMensaIdByText $ Gtk.comboBoxTextGetActiveText cb
-- foodPlanPage <- UM.getMensaWebpage currentMensaId -- food plan webpage of selected dining hall
putStrLn "SUBMIT BUTTON CLICKED: " -- ++ foodPlanPage
-- TODO display food plan info
-- PLACE OBJECTS IN A GRID ON THE WINDOW ----------------------------------
grid <- Gtk.gridNew
Gtk.gridSetColumnSpacing grid 1
Gtk.gridSetRowSpacing grid 3
Gtk.gridSetColumnSpacing grid 10
Gtk.gridSetRowSpacing grid 20
Gtk.gridSetColumnHomogeneous grid True
#attach grid heding 0 0 1 1
......
......@@ -39,6 +39,7 @@ library
, haskell-gi-base
, http-client
, http-client-tls
, text
default-language: Haskell2010
executable food-plan-hs-exe
......@@ -56,6 +57,7 @@ executable food-plan-hs-exe
, haskell-gi-base
, http-client
, http-client-tls
, text
default-language: Haskell2010
test-suite food-plan-hs-test
......@@ -74,4 +76,5 @@ test-suite food-plan-hs-test
, haskell-gi-base
, http-client
, http-client-tls
, text
default-language: Haskell2010
......@@ -26,6 +26,7 @@ dependencies:
- haskell-gi-base
- http-client
- http-client-tls
- text
ghc-options:
- -Wall
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment