diff --git a/Area.py b/Area.py
index fa841df..b33e3b1 100644
a
|
b
|
class Area(gtk.DrawingArea): |
796 | 796 | logging.debug('Area.undo(self)') |
797 | 797 | width, height = self.window.get_size() |
798 | 798 | |
| 799 | logging.debug('self._undo_list: (%s) %s', |
| 800 | len(self._undo_list), |
| 801 | self._undo_list) |
| 802 | logging.debug('self._undo_index: %s', self._undo_index) |
| 803 | |
799 | 804 | if self.selmove: |
800 | 805 | self.getout(undo=True) |
801 | 806 | |
… |
… |
class Area(gtk.DrawingArea): |
814 | 819 | if self.tool['name'] == 'freeform': |
815 | 820 | self.polygon_start = True # start the polygon again |
816 | 821 | |
| 822 | logging.debug('self._undo_list: (%s) %s', |
| 823 | len(self._undo_list), |
| 824 | self._undo_list) |
| 825 | logging.debug('self._undo_index: %s', self._undo_index) |
| 826 | |
817 | 827 | self.emit('undo') |
818 | 828 | |
819 | 829 | def redo(self): |
… |
… |
class Area(gtk.DrawingArea): |
824 | 834 | logging.debug('Area.redo(self)') |
825 | 835 | width, height = self.window.get_size() |
826 | 836 | |
| 837 | logging.debug('self._undo_list: (%s) %s', |
| 838 | len(self._undo_list), |
| 839 | self._undo_list) |
| 840 | logging.debug('self._undo_index: %s', self._undo_index) |
| 841 | |
827 | 842 | if self.selmove: |
828 | 843 | self.getout() |
829 | 844 | |
830 | 845 | if self._undo_index < len(self._undo_list) - 1: |
| 846 | # if self._undo_index < MAX_UNDO_STEPS: |
831 | 847 | self._undo_index += 1 |
832 | 848 | |
833 | 849 | undo_pix = self._undo_list[self._undo_index] |
834 | 850 | self.pixmap.draw_drawable(self.gc, undo_pix, 0, 0, 0, 0, -1, -1) |
835 | 851 | self.queue_draw() |
836 | 852 | |
| 853 | logging.debug('self._undo_list: (%s) %s', |
| 854 | len(self._undo_list), |
| 855 | self._undo_list) |
| 856 | logging.debug('self._undo_index: %s', self._undo_index) |
| 857 | |
837 | 858 | self.emit('redo') |
838 | 859 | |
839 | 860 | def enableUndo(self, widget, size=None, overrite=False): |
… |
… |
class Area(gtk.DrawingArea): |
845 | 866 | """ |
846 | 867 | #logging.debug('Area.enableUndo(self,widget)') |
847 | 868 | |
| 869 | logging.debug('self._undo_list: (%s) %s', |
| 870 | len(self._undo_list), |
| 871 | self._undo_list) |
| 872 | logging.debug('self._undo_index: %s', self._undo_index) |
| 873 | |
848 | 874 | width, height = self.window.get_size() |
849 | 875 | # We need to pass explicitly the size on set up, because the |
850 | 876 | # window size is not allocated yet. |
… |
… |
class Area(gtk.DrawingArea): |
854 | 880 | if len(self._undo_list) == 0: |
855 | 881 | # first undo pix, start index: |
856 | 882 | self._undo_index = 0 |
| 883 | logging.debug('self._undo_list: empty') |
857 | 884 | elif len(self._undo_list) == MAX_UNDO_STEPS: |
858 | 885 | # drop the oldest undo pix: |
859 | 886 | self._undo_list.pop(0) |
860 | 887 | |
| 888 | logging.debug('self._undo_list: MAX_UNDO_STEPS') |
| 889 | |
861 | 890 | # it could be at the middle of the list (clicked many |
862 | 891 | # times undo) and after that draw anything, so we should |
863 | 892 | # discart the next redos because they are obsolete now. |
864 | 893 | self._undo_list = self._undo_list[:self._undo_index] |
865 | 894 | else: |
866 | 895 | self._undo_index += 1 |
| 896 | |
| 897 | logging.debug('self._undo_list: common case') |
| 898 | |
867 | 899 | # Forget the redos after this one: |
868 | 900 | self._undo_list = self._undo_list[:self._undo_index] |
869 | 901 | |
… |
… |
class Area(gtk.DrawingArea): |
879 | 911 | |
880 | 912 | self._undo_list.append(undo_pix) |
881 | 913 | |
| 914 | logging.debug('self._undo_list: (%s) %s', |
| 915 | len(self._undo_list), |
| 916 | self._undo_list) |
| 917 | logging.debug('self._undo_index: %s', self._undo_index) |
| 918 | |
882 | 919 | self.emit('action-saved') |
883 | 920 | |
| 921 | def spin_undo(self, value): |
| 922 | logging.debug('VALUE: %s', value) |
| 923 | undo_pix = self._undo_list[value] |
| 924 | self.pixmap.draw_drawable(self.gc, undo_pix, 0, 0, 0, 0, -1, -1) |
| 925 | self.queue_draw() |
| 926 | |
884 | 927 | def copy(self): |
885 | 928 | """ Copy Image. |
886 | 929 | When the tool selection is working make the change |
diff --git a/toolbox.py b/toolbox.py
index f781b4a..9069778 100644
a
|
b
|
class DrawEditToolbar(EditToolbar): |
168 | 168 | self._clear_all.set_tooltip(_('Clear')) |
169 | 169 | self._clear_all.show() |
170 | 170 | |
| 171 | self._spin_undo_list = gtk.SpinButton() |
| 172 | adj = gtk.Adjustment(0, 0, 11, 1) |
| 173 | self._spin_undo_list.set_adjustment(adj) |
| 174 | self._spin_undo_list.set_numeric(True) |
| 175 | self._spin_undo_list.connect('notify::value', |
| 176 | self._spin_undo_changed_cb) |
| 177 | self._spin_undo_list.show() |
| 178 | |
| 179 | item = gtk.ToolItem() |
| 180 | item.add(self._spin_undo_list) |
| 181 | item.show() |
| 182 | |
| 183 | self.insert(item, -1) |
| 184 | |
171 | 185 | self.undo.connect('clicked', self._undo_cb) |
172 | 186 | self.redo.connect('clicked', self._redo_cb) |
173 | 187 | |
… |
… |
class DrawEditToolbar(EditToolbar): |
181 | 195 | self._activity.area.connect('action-saved', |
182 | 196 | self._on_signal_action_saved_cb) |
183 | 197 | |
| 198 | def _spin_undo_changed_cb(self, *args, **kwargs): |
| 199 | self._activity.area.spin_undo(self._spin_undo_list.get_value_as_int()) |
| 200 | |
184 | 201 | def _undo_cb(self, widget, data=None): |
185 | 202 | self._activity.area.undo() |
186 | 203 | |