Next Previous Up Top Contents Index

5.3 Defining the callbacks

5.3.1 Handling files in the task list manager

To begin with, you will define the functions and methods that let you save files to disk and load them back into the task list manager. Once you have added these to your code, you will be able to save and reload your task lists into the application; this type of functionality is essential in even the most trivial application.

There are three methods and two functions necessary for handling files. The methods handle GUI-specific operations involved in loading and saving files. The functions deal with the basic task of saving data structures to disk, and loading them from disk. Add the definitions of the methods to frame.dylan, and the definitions of the functions to task-list.dylan.

Each method is invoked as a callback in the definition of the <task-frame> class:

open-file

This method prompts the user to choose a filename, and then loads that file into the task list manager by calling the function load-task-list. It is used as the activate callback for both open-button (on the application tool bar) and open-menu-button (in the File menu of the application).

save-file

This method saves the task list currently loaded into the application to disk. It is used as the activate callback for both save-button (on the application tool bar) and save-menu-button (in the File menu of the application).

save-as-file

This method saves the task list currently loaded into the application to disk, and prompts the user to supply a name. It is used as the activate callback for save-as-menu-button (in the File menu of the application).

The following functions are called by the methods described above:

save-task-list

This function saves an instance of <task-list> to a named file. It is called by save-as-file.

load-task-list

This function takes the contents of a file on disk and converts it into an instance of <task-list>. It is called by open-as-file.

The following sections present and explain the code for each of these methods and functions in turn.

5.3.1.1 - The open-file method
5.3.1.2 - The save-file method
5.3.1.3 - The save-as-file method
5.3.1.4 - The load-task-list function
5.3.1.5 - The save-task-list function

Building Applications Using DUIM - 26 May 1999

Next Previous Up Top Contents Index