PEP8 edits and minor simplifications
svn: r15272
This commit is contained in:
parent
8cecd15dab
commit
bb17e00abd
@ -124,10 +124,12 @@ class UndoHistory(ManagedWindow.ManagedWindow):
|
||||
if path[0] < self.undodb.undoindex+1:
|
||||
self.redo_button.set_sensitive(False)
|
||||
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.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.redo_button.set_sensitive(self.undodb.redo_available())
|
||||
|
||||
@ -145,26 +147,23 @@ class UndoHistory(ManagedWindow.ManagedWindow):
|
||||
def _response(self, obj, response_id):
|
||||
if response_id == gtk.RESPONSE_CLOSE:
|
||||
self.close(obj)
|
||||
|
||||
elif response_id == gtk.RESPONSE_REJECT:
|
||||
(model, node) = self.selection.get_selected()
|
||||
if not node:
|
||||
return
|
||||
path = self.model.get_path(node)
|
||||
nsteps = path[0]-self.undodb.undoindex-1
|
||||
if nsteps == 0:
|
||||
self._move(-1)
|
||||
else:
|
||||
self._move(nsteps)
|
||||
self._move(nsteps or -1)
|
||||
|
||||
elif response_id == gtk.RESPONSE_ACCEPT:
|
||||
(model, node) = self.selection.get_selected()
|
||||
if not node:
|
||||
return
|
||||
path = self.model.get_path(node)
|
||||
nsteps = path[0]-self.undodb.undoindex-1
|
||||
if nsteps == 0:
|
||||
self._move(1)
|
||||
else:
|
||||
self._move(nsteps)
|
||||
self._move(nsteps or 1)
|
||||
|
||||
elif response_id == gtk.RESPONSE_APPLY:
|
||||
self._clear_clicked()
|
||||
elif response_id == gtk.RESPONSE_DELETE_EVENT:
|
||||
@ -192,10 +191,7 @@ class UndoHistory(ManagedWindow.ManagedWindow):
|
||||
def _move(self, steps=-1):
|
||||
if steps == 0 :
|
||||
return
|
||||
elif steps < 0:
|
||||
func = self.db.undo
|
||||
elif steps > 0:
|
||||
func = self.db.redo
|
||||
func = self.db.undo if steps < 0 else self.db.redo
|
||||
|
||||
for step in range(abs(steps)):
|
||||
func(False)
|
||||
@ -206,7 +202,8 @@ class UndoHistory(ManagedWindow.ManagedWindow):
|
||||
self.undo_button.set_sensitive(self.undodb.undo_available())
|
||||
self.redo_button.set_sensitive(self.undodb.redo_available())
|
||||
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):
|
||||
self.model.clear()
|
||||
|
Loading…
Reference in New Issue
Block a user