forked from bonzini/gst-visualgst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GtkBrowsingTool.st
71 lines (52 loc) · 1.74 KB
/
GtkBrowsingTool.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
GtkVisualGSTTool subclass: GtkBrowsingTool [
<comment: 'I am the base for various browsers of VisualGST.'>
selectedText [
<category: 'command protocols'>
self subclassResponsibility
]
acceptIt [
<category: 'method events'>
self subclassResponsibility
]
browserHasFocus [
<category: 'command protocols'>
^true
]
onDelete: aGtkWidget event: aGdkEvent [
<category: 'window events'>
self saveCodeOr: [ window hideAll ].
^ true
]
saveCodeOr: dropBlock [
<category: 'saving'>
| dialog |
self hasChanged ifFalse: [ dropBlock value. ^self ].
dialog := GTK.GtkMessageDialog
new: window
flags: GTK.Gtk gtkDialogDestroyWithParent
type: GTK.Gtk gtkMessageWarning
buttons: GTK.Gtk gtkButtonsNone
message: 'Accept changes before exiting?'
tip: 'If you choose "drop", your changes to %1 will be lost...' % {self state}.
dialog
addButton: 'Drop' responseId: 0;
addButton: 'Cancel' responseId: 2;
addButton: 'Accept' responseId: 1;
showModalOnAnswer: [ :dlg :res |
res = 1 ifTrue: [ self acceptIt ].
res <= 1 ifTrue: dropBlock.
dlg destroy ].
]
checkCodeWidgetAndUpdate: aBlock [
<category: 'text editing'>
self saveCodeOr: [ aBlock value. self clearUndo ].
]
hasChanged [
<category: 'testing'>
self subclassResponcibility
]
clearUndo [
<category: 'undo'>
self subclassResponcibility
]
]