From: Marius Gedminas <marius@gedmin.as>
| ... | ... |
@@ -722,6 +722,9 @@ class DragAction(object): |
| 722 | 722 |
def stop(self): |
| 723 | 723 |
pass |
| 724 | 724 |
|
| 725 |
+ def abort(self): |
|
| 726 |
+ pass |
|
| 727 |
+ |
|
| 725 | 728 |
|
| 726 | 729 |
class NullAction(DragAction): |
| 727 | 730 |
|
| ... | ... |
@@ -746,6 +749,8 @@ class PanAction(DragAction): |
| 746 | 749 |
def stop(self): |
| 747 | 750 |
self.dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.ARROW)) |
| 748 | 751 |
|
| 752 |
+ abort = stop |
|
| 753 |
+ |
|
| 749 | 754 |
|
| 750 | 755 |
class ZoomAction(DragAction): |
| 751 | 756 |
|
| ... | ... |
@@ -784,6 +789,9 @@ class ZoomAreaAction(DragAction): |
| 784 | 789 |
self.stopmousey) |
| 785 | 790 |
self.dot_widget.zoom_to_area(x1, y1, x2, y2) |
| 786 | 791 |
|
| 792 |
+ def abort(self): |
|
| 793 |
+ self.dot_widget.queue_draw() |
|
| 794 |
+ |
|
| 787 | 795 |
|
| 788 | 796 |
class DotWidget(gtk.DrawingArea): |
| 789 | 797 |
"""PyGTK widget that draws dot graphs.""" |
| ... | ... |
@@ -931,6 +939,10 @@ class DotWidget(gtk.DrawingArea): |
| 931 | 939 |
self.zoom_image(self.zoom_ratio / self.ZOOM_INCREMENT) |
| 932 | 940 |
self.queue_draw() |
| 933 | 941 |
return True |
| 942 |
+ if event.keyval == gtk.keysyms.Escape: |
|
| 943 |
+ self.drag_action.abort() |
|
| 944 |
+ self.drag_action = NullAction(self) |
|
| 945 |
+ return True |
|
| 934 | 946 |
return False |
| 935 | 947 |
|
| 936 | 948 |
def get_drag_action(self, event): |
| ... | ... |
@@ -946,6 +958,7 @@ class DotWidget(gtk.DrawingArea): |
| 946 | 958 |
|
| 947 | 959 |
def on_area_button_press(self, area, event): |
| 948 | 960 |
self.animation.stop() |
| 961 |
+ self.drag_action.abort() |
|
| 949 | 962 |
action_type = self.get_drag_action(event) |
| 950 | 963 |
self.drag_action = action_type(self) |
| 951 | 964 |
self.drag_action.on_button_press(event) |