From bbfc3969346db1b11309f60cc72c979258c26bf3 Mon Sep 17 00:00:00 2001 From: Lincoln de Sousa Date: Sun, 10 Aug 2008 12:45:02 -0300 Subject: [PATCH] Making the "Save" feature works. Adding Gzv.save_project, changing Project.save_to_file and setting callbacks in the glade file --- gzv.glade | 21 ++++++++++++--------- gzv.py | 21 +++++++++++++++++++-- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/gzv.glade b/gzv.glade index d426f6d..58ae30b 100644 --- a/gzv.glade +++ b/gzv.glade @@ -1,6 +1,6 @@ - + Gzv @@ -44,14 +44,7 @@ gtk-save True True - - - - - True - gtk-save-as - True - True + @@ -147,6 +140,16 @@ False + + + True + gtk-save + + + + False + + True diff --git a/gzv.py b/gzv.py index 6820f83..081e06a 100644 --- a/gzv.py +++ b/gzv.py @@ -77,10 +77,14 @@ class Project(object): self.focus_points_file = '' def save_to_file(self, path): - bn = os.path.basename(path) - name = os.path.splitext(bn)[0] + if not self.focus_points_file: + bn = os.path.basename(path) + name = os.path.splitext(bn)[0] + self.focus_points_file = \ + os.path.join(os.path.dirname(path), name + '_fpf') cp = ConfigParser() + cp.add_section('Project') cp.set('Project', 'image', self.image) cp.set('Project', 'width', self.width) cp.set('Project', 'height', self.height) @@ -192,6 +196,19 @@ class Gzv(GladeLoader): self.load_project(Project.parse_file(proj_file)) fc.destroy() + def save_project(self, *args): + fc = gtk.FileChooserDialog(_('Save project'), self.window, + action=gtk.FILE_CHOOSER_ACTION_SAVE, + buttons=(gtk.STOCK_CANCEL, + gtk.RESPONSE_CANCEL, + gtk.STOCK_SAVE, + gtk.RESPONSE_OK)) + if fc.run() == gtk.RESPONSE_OK: + self.project.save_to_file(fc.get_filename()) + self.balls.save_to_file(self.project.focus_points_file) + fc.destroy() + + def load_project(self, project): self.project = project self.balls = self.load_balls_from_file(project.focus_points_file) -- 2.20.1