packages feed

traypoweroff (empty) → 0.9.0

raw patch · 6 files changed

+158/−0 lines, 6 filesdep +basedep +gtkdep +processsetup-changedbinary-added

Dependencies added: base, gtk, process

Files

+ INSTALL view
@@ -0,0 +1,6 @@+With Cabal:++1-step:+cabal install --prefix=`pwd`/release --user++cabal install --global
+ LICENSE view
@@ -0,0 +1,27 @@+Copyright (c) 2010, Luis José Cabellos Gómez+All rights reserved.++Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are+met:++    Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer.+    Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution.+    The names of its contributors may be used to endorse or promote +products derived from this software without specific prior written +permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.lhs view
@@ -0,0 +1,4 @@+\begin{code}+import Distribution.Simple+main = defaultMain+\end{code}
+ data/icons/icon64.png view

binary file changed (absent → 4061 bytes)

+ src/TrayPowerOff.lhs view
@@ -0,0 +1,98 @@+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+\begin{code}+module Main() where+\end{code}++\begin{code}+import Graphics.UI.Gtk( initGUI, mainGUI, on )+import Graphics.UI.Gtk.Gdk.Events( TimeStamp )+import Graphics.UI.Gtk.General.Enums( MouseButton )+import Graphics.UI.Gtk.Display.StatusIcon+    ( statusIconNewFromFile, statusIconActivate, statusIconPopupMenu )+import Graphics.UI.Gtk.ActionMenuToolbar.Action( actionNew, actionActivated )+import Graphics.UI.Gtk.ActionMenuToolbar.ActionGroup+    ( actionGroupNew, actionGroupAddAction )+import Graphics.UI.Gtk.ActionMenuToolbar.UIManager+    ( uiManagerNew, uiManagerAddUiFromString, uiManagerGetWidget+    , uiManagerInsertActionGroup )+import Graphics.UI.Gtk.MenuComboToolbar.Menu( Menu, castToMenu, menuPopup )+import Paths_traypoweroff( getDataFileName )+import Data.Maybe( fromJust )+import System.Cmd( system )+import System.Exit( ExitCode(..) )+\end{code}++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+\begin{code}+main :: IO()+main = do+  initGUI++  iconfile <- getDataFileName "icons/icon64.png"+  icon <- statusIconNewFromFile iconfile++  aoff <- actionNew "AOFF" "PowerOff" Nothing Nothing+  on aoff actionActivated powerOffAction+  areb <- actionNew "AREB" "Reboot" Nothing Nothing+  on areb actionActivated rebootAction++  group <- actionGroupNew "AGRP"++  actionGroupAddAction group aoff+  actionGroupAddAction group areb++  uiman <- uiManagerNew+  uiManagerAddUiFromString uiman uiDecl+  uiManagerInsertActionGroup uiman group 0++  pop <- fmap (castToMenu . fromJust) $ uiManagerGetWidget uiman "/popup"++  on icon statusIconActivate $ menuActivate pop+  on icon statusIconPopupMenu $ menuPopUp pop+  mainGUI+\end{code}++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+\begin{code}+menuPopUp :: Menu -> Maybe MouseButton -> TimeStamp -> IO ()+menuPopUp menu _ _ = do+  menuPopup menu Nothing+\end{code}++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+\begin{code}+menuActivate :: Menu -> IO ()+menuActivate menu = do+  menuPopup menu Nothing+\end{code}++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+\begin{code}+uiDecl :: [Char]+uiDecl = "<popup>\+\           <menuitem action=\"AOFF\" />\+\           <menuitem action=\"AREB\" />\+\          </popup>"   +\end{code}++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+\begin{code}+powerOffAction :: IO ()+powerOffAction = do+  err <- system "sudo /sbin/poweroff"+  case err of+    ExitFailure n -> putStrLn $ "Error code: " ++ show n+    ExitSuccess -> return ()+\end{code}++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+\begin{code}+rebootAction :: IO ()+rebootAction = do+  err <- system "sudo /sbin/reboot"+  case err of+    ExitFailure n -> putStrLn $ "Error code: " ++ show n+    ExitSuccess -> return ()+\end{code}++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ traypoweroff.cabal view
@@ -0,0 +1,23 @@+name:			traypoweroff+version:		0.9.0+cabal-Version:		>= 1.6+description:		PowerOff Tray Icon+license:		BSD3+license-file:           LICENSE+author:			Luis Cabellos+maintainer:             zhen.sydow@gmail.com+homepage:               http://projects.haskell.org/traypoweroff+synopsis:		Tray Icon application to PowerOff / Reboot computer+category:               application+tested-with:            GHC+build-Type:		Simple+data-dir:               data+data-files:             icons/*.png+extra-source-files:     INSTALL++executable traypoweroff+  main-is:              TrayPowerOff.lhs+  Build-Depends:        base >= 4.0 && < 5.0, gtk >= 0.10.0 && < 0.11, +                        process >= 1.0 && < 2.0+  hs-source-dirs:       src+  ghc-options:          -Wall