From 616c4a99ce887e5b48427e71cb60d676fe147446 Mon Sep 17 00:00:00 2001 From: Lincoln de Sousa Date: Sat, 9 Aug 2008 18:03:58 -0300 Subject: [PATCH] Adding some management functions to the focus point list: Added Gzv.remove_fp, Gzv.save_fp_list, changing Gzv.load_project, Project.save_to_file. Setting two signals on glade (remove and save). --- gzv.glade | 4 +++- gzv.py | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/gzv.glade b/gzv.glade index 27a8c01..d426f6d 100644 --- a/gzv.glade +++ b/gzv.glade @@ -1,6 +1,6 @@ - + Gzv @@ -250,6 +250,7 @@ True Remove the selected focus point 0 + True @@ -265,6 +266,7 @@ True Save list of focus points 0 + True diff --git a/gzv.py b/gzv.py index e58ab82..2d5c926 100644 --- a/gzv.py +++ b/gzv.py @@ -83,6 +83,7 @@ class Project(object): cp.set('Project', 'image', self.image) cp.set('Project', 'width', self.width) cp.set('Project', 'height', self.height) + cp.set('Project', 'focus_points', self.focus_points_file) cp.write(open(path, 'w')) @@ -189,6 +190,7 @@ class Gzv(GladeLoader): fc.destroy() def load_project(self, project): + self.project = project self.balls = self.load_balls_from_file(project.focus_points_file) self.image = project.image self.load_balls_to_treeview() @@ -212,6 +214,37 @@ class Gzv(GladeLoader): balls.append(Ball(int(x), int(y), int(radios), name, index)) return balls + def remove_fp(self, *args): + selection = self.treeview.get_selection() + model, path = selection.get_selected() + if path: + position = model[path][0] + for i in self.balls: + if i.position == int(position): + self.balls.remove(i) + del model[path] + + def save_fp_list(self, *args): + assert self.project is not None + + # if the project has no + if self.project and not self.project.focus_points_file: + fc = gtk.FileChooserDialog(_('Save the focus points file'), + 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.focus_points_file = fc.get_filename() + fc.destroy() + else: + fc.destroy() + return + + self.balls.save_to_file(self.project.focus_points_file) + def expose_draw(self, draw, event): if not self.image: return @@ -275,9 +308,9 @@ class Gzv(GladeLoader): self.draw.queue_draw() if event.x > self.last_x: - self.ball_width += 2 + self.ball_width += 3 else: - self.ball_width -= 2 + self.ball_width -= 3 self.last_x = event.x -- 2.20.1