[Yet more work John Goerzen **20080422093124] { hunk ./en/ch24-gui.xml 360 + + + + Long-Running Tasks + + As we think about the buttons available in the main window, + three of them correspond to tasks that could take awhile to + complete: update, download, and fetch. While these operations + take place, we'd like to do two things with our GUI: provide the + user with the status of the operation, and provide the user with + the ability to cancel the operation as it is in progress. + + + Since all three of these things are very similar operations, it + makes sense to provide a generic way to handle this + interaction. We have defined a single status window widget in + the Glade file that will be used by all three of these. In our + Haskell source code, we'll define a generic + statusWindow function that will be used by + all three of these operations as well. + + + statusWindow takes four parameters: the GUI + information, the database information, a &String; giving the + title of the window, and a function that will perform the + operation. This function will itself by passed a function that + it can call to report its progress. Here's the code: + + &PodMain.hs:statusWindow; hunk ./examples/ch24/PodMain.hs 132 +{-- snippet statusWindow --} hunk ./examples/ch24/PodMain.hs 147 + -- Set the title + windowSetTitle (statusWin gui) title + + -- Start the operation hunk ./examples/ch24/PodMain.hs 152 + + -- Define what happens when clicking on Cancel hunk ./examples/ch24/PodMain.hs 178 - +{-- /snippet statusWindow --} + }