{- * Programmer: Piotr Borek * E-mail: piotrborek@op.pl * Copyright 2015 Piotr Borek * * Distributed under the terms of the GPL (GNU Public License) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -} module Coin.UI.Accounts.AccountsWidget ( AccountsWidget, accountsWidgetNew ) where import qualified System.Glib.Types as Gtk import qualified Graphics.UI.Gtk as Gtk import Control.Monad.IO.Class import Coin.UI.MainState import Coin.UI.Builder.GtkUIBuilder import Coin.Locale.Translate import Coin.UI.Accounts.AccountsIncome import Coin.UI.Accounts.AccountsOutcome import Coin.UI.Accounts.AccountsTransfer import Coin.UI.Accounts.AccountsHistory data AccountsWidget = AccountsWidget { accountsContainer :: Gtk.Notebook } instance Gtk.GObjectClass AccountsWidget where toGObject = Gtk.toGObject . accountsContainer unsafeCastGObject = undefined instance Gtk.WidgetClass AccountsWidget accountsWidgetNew :: MainState -> IO AccountsWidget accountsWidgetNew mainState = do incomePageWidget <- accountsIncomeNew mainState outcomePageWidget <- accountsOutcomeNew mainState transferPageWidget <- accountsTransferNew mainState historyPageWidget <- accountsHistoryNew mainState (_, root) <- uiBuildGtk $ do notebook Nothing $ do simplePage (__"Income") $ putWidget incomePageWidget simplePage (__"Outcome") $ do putWidget outcomePageWidget simplePage (__"Transfer") $ do putWidget transferPageWidget simplePage (__"History") $ do putWidget historyPageWidget Gtk.widgetShowAll root let nb = Gtk.castToNotebook root mainStateSavePropertiesAction mainState "Coin.UI.Accounts.AccountsWidget" $ do i <- liftIO $ Gtk.notebookGetCurrentPage nb propertyInsert "i" i mainStateReadPropertiesAction mainState "Coin.UI.Accounts.AccountsWidget" $ do propertyRead "i" $ \i -> liftIO $ Gtk.notebookSetCurrentPage nb i return $ AccountsWidget nb