Skip to content
Browse files

Working on remove

  • Loading branch information...
1 parent 1844cea commit 5c8571c2970073e0e8aaf71fd5e78bedb7d78506 @jgoerzen committed Mar 28, 2007
Showing with 31 additions and 4 deletions.
  1. +20 −2 Actions.hs
  2. +6 −1 MacroList.hs
  3. +5 −1 Metacity.hs
View
22 Actions.hs
@@ -11,14 +11,17 @@ import System.IO
import Control.Concurrent
import Control.Concurrent.MVar
import System.Process
+import System.Directory
import Control.Exception(evaluate)
import Data.List
+import Text.Printf
initActions b list model macdir window xml = do
onClicked (closebt b) (widgetDestroy window)
onClicked (connectbt b) (connect list model macdir)
onClicked (disconnectbt b) (disconnectMacro list model macdir)
onClicked (newbt b) (record model macdir xml)
+ onClicked (removebt b) (remove list model macdir window)
connect list model macdir = do
items <- getSelectedItems list model
@@ -28,10 +31,25 @@ connect list model macdir = do
disconnectMacro list model macdir = do
items <- getSelectedItems list model
- mapM_ remove items
+ mapM_ removebind items
loadList model macdir
- where remove (name, _) = Metacity.removeBinding name
+ where removebind (name, _) = Metacity.removeBinding name
+remove list model macdir window = do
+ items <- getSelectedItems list model
+ let itemstr = concat . intersperse ", " . map fst $ items
+ dlg <- messageDialogNew (Just window) [] MessageQuestion
+ ButtonsYesNo
+ (printf "Are you sure you want to delete macro %s?" itemstr)
+ response <- dialogRun dlg
+ widgetDestroy dlg
+ case response of
+ ResponseYes -> do
+ mapM_ rmit (map fst items)
+ disconnectMacro list model macdir -- Remove bindings
+ -- disconnectMacro will loadList itself
+ _ -> return ()
+ where rmit item = removeFile (macdir ++ "/" ++ item)
record model macdir xml = do
recordwin <- xmlGetWidget xml castToWindow "recording"
finishedbt <- xmlGetWidget xml castToButton "recdonebt"
View
7 MacroList.hs
@@ -76,12 +76,17 @@ loadList model macdir = do
dir <- getAppUserDataDirectory "gmacro"
files' <- getDirectoryContents dir
let files = filter (\f -> f /= "." && f /= "..") files'
+ print "ML79"
bindings <- getMacroBindings
+ print "ML80"
+ treeViewGetSelection list >>= treeSelectionUnselectAll
MV.listStoreClear model
+ print "ML84"
mapM_ (addrow bindings) files
where addrow bindings file =
- MV.listStoreAppend model (file, binding)
+ do print "ML87"
+ MV.listStoreAppend model (file, binding)
where binding = case lookup file bindings of
Nothing -> "none"
Just x -> x
View
6 Metacity.hs
@@ -75,11 +75,15 @@ removeBinding name =
do gc <- gconfGetDefault
putStrLn $ "removeBinding " ++ name
bindings <- getBindings gc
+ print 78
commands <- getCommands gc
+ print 80
let cmd = find ((==) ("gmacroplay " ++ name) . snd) commands
case cmd of
- Nothing -> fail "Couldn't find command to unbind"
+ Nothing -> return () -- No command to unbind
Just (x,_) -> do
+ print 85
gconfSet gc ("/apps/metacity/global_keybindings/run_"
++ x) "disabled"
+ print 88
gconfSet gc ("/apps/metacity/keybinding_commands/" ++ x) ""

0 comments on commit 5c8571c

Please sign in to comment.
Something went wrong with that request. Please try again.