Skip to content

Commit

Permalink
Clear selection before clearing list
Browse files Browse the repository at this point in the history
This prevents a crash when 2 or more items are removed
  • Loading branch information
jgoerzen committed Mar 28, 2007
1 parent 5c8571c commit 0746eaf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions Actions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ 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 (newbt b) (record list model macdir xml)
onClicked (removebt b) (remove list model macdir window)

connect list model macdir = do
items <- getSelectedItems list model
let (name, shortcut) = head items
Metacity.bindMacro name "<Ctrl><Alt>t"
loadList model macdir
loadList list model macdir

disconnectMacro list model macdir = do
items <- getSelectedItems list model
mapM_ removebind items
loadList model macdir
loadList list model macdir
where removebind (name, _) = Metacity.removeBinding name

remove list model macdir window = do
Expand All @@ -50,7 +50,7 @@ remove list model macdir window = do
-- disconnectMacro will loadList itself
_ -> return ()
where rmit item = removeFile (macdir ++ "/" ++ item)
record model macdir xml = do
record list model macdir xml = do
recordwin <- xmlGetWidget xml castToWindow "recording"
finishedbt <- xmlGetWidget xml castToButton "recdonebt"

Expand Down Expand Up @@ -83,5 +83,5 @@ record model macdir xml = do
waitForProcess xmacroph

widgetHide recordwin
loadList model macdir
loadList list model macdir

2 changes: 1 addition & 1 deletion MacroList.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ getSelectedItems list model = do
where row2data [i] = MV.listStoreGetValue model i

{- | Load the files into the list -}
loadList model macdir = do
loadList list model macdir = do
dir <- getAppUserDataDirectory "gmacro"
files' <- getDirectoryContents dir
let files = filter (\f -> f /= "." && f /= "..") files'
Expand Down
2 changes: 1 addition & 1 deletion gmacro.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ main = do
buttons <- initButtons xml window

(list, model) <- initList xml buttons
loadList model macdir
loadList list model macdir

initActions buttons list model macdir window xml

Expand Down

0 comments on commit 0746eaf

Please sign in to comment.