GTK-Chess
GTK-Chess copied to clipboard
Add PGN copy/paste/save/open feature
Add functions and connect them to appropriate widgets on the UI that would perform following logic:
Copy/paste features
- PGN copy function
- Generate PGN string from the current position
- Send generated PGN string to clipboard
- PGN paste function
- Read clipboard content into string
- Verifiy that it is a valid PGN string (use separate function for it)
- If string is valid PGN, then paste position onto the board which means
- Clear current
state_tree
- Initialize
state_tree
with game obtained from PGN
- Clear current
- Else show error message
Open/Save features
Open and save functions should use Gtk.FileChooserDialog to let user select file.
PGN save feature logic should be implemented as follows
- Generate PGN string from the current position
- If there's currently opened file
- Write PGN to the currently opened file
- Else request file name via
FileChooserDialog
and save PGN into given file
PGN open feature logic should be implemented as follows:
- Click on "Open PGN" button should
- Show Gtk.FileChooserDialog to let user select file
- Then generate Gio.Application::open signal with Gio.Application.open method
- Event handler connected to
open
signal then should- Verify file existence and readability
- Read file contents into string
- Verify it is a valid PGN string
- If string is valid PGN, then paste position onto the board which means
- Clear current
state_tree
- Initialize
state_tree
with game obtained from PGN
- Clear current
- Else show error message