PEP8 edits and minor simplifications

svn: r15272
This commit is contained in:
Gerald Britton 2010-04-22 19:46:50 +00:00
parent 8cecd15dab
commit bb17e00abd

View File

@ -124,10 +124,12 @@ class UndoHistory(ManagedWindow.ManagedWindow):
if path[0] < self.undodb.undoindex+1: if path[0] < self.undodb.undoindex+1:
self.redo_button.set_sensitive(False) self.redo_button.set_sensitive(False)
self.undo_button.set_sensitive(self.undodb.undo_available()) self.undo_button.set_sensitive(self.undodb.undo_available())
if path[0] > self.undodb.undoindex+1:
elif path[0] > self.undodb.undoindex+1:
self.undo_button.set_sensitive(False) self.undo_button.set_sensitive(False)
self.redo_button.set_sensitive(self.undodb.redo_available()) self.redo_button.set_sensitive(self.undodb.redo_available())
if path[0] == self.undodb.undoindex+1:
else: #path[0] == self.undodb.undoindex+1
self.undo_button.set_sensitive(self.undodb.undo_available()) self.undo_button.set_sensitive(self.undodb.undo_available())
self.redo_button.set_sensitive(self.undodb.redo_available()) self.redo_button.set_sensitive(self.undodb.redo_available())
@ -145,26 +147,23 @@ class UndoHistory(ManagedWindow.ManagedWindow):
def _response(self, obj, response_id): def _response(self, obj, response_id):
if response_id == gtk.RESPONSE_CLOSE: if response_id == gtk.RESPONSE_CLOSE:
self.close(obj) self.close(obj)
elif response_id == gtk.RESPONSE_REJECT: elif response_id == gtk.RESPONSE_REJECT:
(model, node) = self.selection.get_selected() (model, node) = self.selection.get_selected()
if not node: if not node:
return return
path = self.model.get_path(node) path = self.model.get_path(node)
nsteps = path[0]-self.undodb.undoindex-1 nsteps = path[0]-self.undodb.undoindex-1
if nsteps == 0: self._move(nsteps or -1)
self._move(-1)
else:
self._move(nsteps)
elif response_id == gtk.RESPONSE_ACCEPT: elif response_id == gtk.RESPONSE_ACCEPT:
(model, node) = self.selection.get_selected() (model, node) = self.selection.get_selected()
if not node: if not node:
return return
path = self.model.get_path(node) path = self.model.get_path(node)
nsteps = path[0]-self.undodb.undoindex-1 nsteps = path[0]-self.undodb.undoindex-1
if nsteps == 0: self._move(nsteps or 1)
self._move(1)
else:
self._move(nsteps)
elif response_id == gtk.RESPONSE_APPLY: elif response_id == gtk.RESPONSE_APPLY:
self._clear_clicked() self._clear_clicked()
elif response_id == gtk.RESPONSE_DELETE_EVENT: elif response_id == gtk.RESPONSE_DELETE_EVENT:
@ -192,10 +191,7 @@ class UndoHistory(ManagedWindow.ManagedWindow):
def _move(self, steps=-1): def _move(self, steps=-1):
if steps == 0 : if steps == 0 :
return return
elif steps < 0: func = self.db.undo if steps < 0 else self.db.redo
func = self.db.undo
elif steps > 0:
func = self.db.redo
for step in range(abs(steps)): for step in range(abs(steps)):
func(False) func(False)
@ -206,7 +202,8 @@ class UndoHistory(ManagedWindow.ManagedWindow):
self.undo_button.set_sensitive(self.undodb.undo_available()) self.undo_button.set_sensitive(self.undodb.undo_available())
self.redo_button.set_sensitive(self.undodb.redo_available()) self.redo_button.set_sensitive(self.undodb.redo_available())
self.clear_button.set_sensitive( self.clear_button.set_sensitive(
self.undodb.undo_available() or self.undodb.redo_available() ) self.undodb.undo_available() or self.undodb.redo_available()
)
def _build_model(self): def _build_model(self):
self.model.clear() self.model.clear()