diff options
author | Justin Lewis <jtl1728@rit.edu> | 2009-12-18 20:26:56 (GMT) |
---|---|---|
committer | Justin Lewis <jtl1728@rit.edu> | 2009-12-18 20:48:19 (GMT) |
commit | b0a9f5f3dee8a9178b6151ec5f55129ea7bc33f1 (patch) | |
tree | 241bee986ed05e5e49bead8a71272959abb34cf3 | |
parent | 302093d587ed5438339dad5004304faa24c27605 (diff) |
Activity now asks if it should save files when it closes.
This is done because saving the files takes up the limited hard drive
space with a copy of a file already installed into the journal.
-rw-r--r-- | FileShare.activity/FileShareActivity.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/FileShare.activity/FileShareActivity.py b/FileShare.activity/FileShareActivity.py index e8d7891..44c92c1 100644 --- a/FileShare.activity/FileShareActivity.py +++ b/FileShare.activity/FileShareActivity.py @@ -68,6 +68,9 @@ class FileShareActivity(Activity): # Are we the ones that created the control tube self.initiating = False + # Set to true when closing for keep cleanup + self._close_requested = False + # Build and display gui self._buildGui() @@ -521,9 +524,35 @@ class FileShareActivity(Activity): return bundle.get_metadata() + def can_close( self ): + #TODO: HAVE SERVER CHECK IF IT CAN CLOSE + self._close_requested = True + return True + def write_file(self, file_path): _logger.debug('Writing activity file') + # If no files to save, nothing to do + if len(self.sharedFiles) == 0: + return + + if self._close_requested: + dialog = gtk.MessageDialog(self, gtk.DIALOG_MODAL, + gtk.MESSAGE_INFO, gtk.BUTTONS_YES_NO, + _("Saving files in activity allows the activity to resume with the current file list but takes up more space.") ) + dialog.set_title("Do you wish to save files within activity?") + + response = dialog.run() + dialog.destroy() + + # Return not allowing files to be saved + if response == gtk.RESPONSE_NO: + #hack to empty file if existed before + file = zipfile.ZipFile(file_path, "w") + file.writestr("_filelist.json", simplejson.dumps([])) + file.close() + return + # Create zip of tmp directory file = zipfile.ZipFile(file_path, "w") |