Hi, A key snooper is added to VisualGST, it handles the ctrl + . shortcut and will flush the task queue. It's pretty usefull when your debugger is frozzen (could be extended to stop all the process except the gtk loop, task queue, ... but step by step)
Cheers, Gwen
>From 35062a01319419ed316340dcd362819d5a0d1d4e Mon Sep 17 00:00:00 2001 From: Gwenael Casaccio <[email protected]> Date: Thu, 14 Nov 2013 20:29:04 +0100 Subject: [PATCH] Add KeySnooper handle the ctrl + . and flush the task queue. --- packages/visualgst/ChangeLog | 6 +++ packages/visualgst/GtkLauncher.st | 1 + packages/visualgst/Misc/KeySnooper.st | 91 +++++++++++++++++++++++++++++++++++ packages/visualgst/Misc/TaskQueue.st | 10 ++++ packages/visualgst/package.xml | 1 + 5 files changed, 109 insertions(+) create mode 100644 packages/visualgst/Misc/KeySnooper.st diff --git a/packages/visualgst/ChangeLog b/packages/visualgst/ChangeLog index 1cf67e6..7d8b40b 100644 --- a/packages/visualgst/ChangeLog +++ b/packages/visualgst/ChangeLog @@ -1,3 +1,9 @@ +2013-11-13 Gwenael Casaccio <[email protected]> + + * GtkLauncher.st: Initialize KeySnooper. + * Misc/TaskQueue.st: Flush task queue. + * Misc/KeySnooper.st: Add key snooper and handle the ctrl + . shortcut + 2013-10-21 Gwenael Casaccio <[email protected]> * Debugger/GtkDebugger.st: If stepping while the last context is not selected it finishes the execution diff --git a/packages/visualgst/GtkLauncher.st b/packages/visualgst/GtkLauncher.st index 8b7de66..5383b34 100644 --- a/packages/visualgst/GtkLauncher.st +++ b/packages/visualgst/GtkLauncher.st @@ -299,6 +299,7 @@ GtkVisualGSTTool subclass: GtkLauncher [ imageName := File image asString. systemChangeNotifier := SystemChangeNotifier new. SystemChangeNotifier root add: systemChangeNotifier. + KeySnooper uniqueInstance. self clearGlobalState. super initialize. window maximize. diff --git a/packages/visualgst/Misc/KeySnooper.st b/packages/visualgst/Misc/KeySnooper.st new file mode 100644 index 0000000..7b99a99 --- /dev/null +++ b/packages/visualgst/Misc/KeySnooper.st @@ -0,0 +1,91 @@ +"====================================================================== +| +| KeySnooper class definition +| +======================================================================" + +"====================================================================== +| +| Copyright (c) 2013 +| Gwenael Casaccio <[email protected]>, +| +| +| This file is part of VisualGST. +| +| Permission is hereby granted, free of charge, to any person obtaining +| a copy of this software and associated documentation files (the +| 'Software'), to deal in the Software without restriction, including +| without limitation the rights to use, copy, modify, merge, publish, +| distribute, sublicense, and/or sell copies of the Software, and to +| permit persons to whom the Software is furnished to do so, subject to +| the following conditions: +| +| The above copyright notice and this permission notice shall be +| included in all copies or substantial portions of the Software. +| +| THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +| EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +| CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +| TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +| +======================================================================" + +Object subclass: KeySnooper [ + + KeySnooper class [ | uniqueInstance | ] + + KeySnooper class >> initialize [ + <category: 'initialization'> + + ObjectMemory addDependent: self. + ] + + KeySnooper class >> uniqueInstance [ + <category: 'instance creation'> + + ^ uniqueInstance ifNil: [ uniqueInstance := self new ] + ] + + KeySnooper class >> new [ + <category: 'instance creation'> + + ^ super new + initialize; + yourself + ] + + KeySnooper class >> update: aSymbol [ + <category: 'initialize'> + + aSymbol == #returnFromSnapshot ifTrue: [ uniqueInstance := nil ]. + ] + + | callback | + + initialize [ + <category: 'initialization'> + + callback := CCallbackDescriptor + for: [ :aWidget :aGdkEventKey :aPointer | + self keyHandling: (GTK.GdkEventKey address: aGdkEventKey) ] + returning: #boolean + withArgs: #(#long #long #long). + GTK.Gtk keySnooperInstall: callback funcData: nil. + ] + + keyHandling: aGdkEventKey [ + + ^ ((aGdkEventKey state value bitAnd: 4) = 4 and: [ aGdkEventKey keyval value = GTK.Gdk gdkPeriod ]) + ifTrue: [ VisualGST.TaskQueue uniqueInstance flush. + true ] + ifFalse: [ false ] + ] +] + +Eval [ + KeySnooper initialize. +] + diff --git a/packages/visualgst/Misc/TaskQueue.st b/packages/visualgst/Misc/TaskQueue.st index 5922309..a2cbb2d 100644 --- a/packages/visualgst/Misc/TaskQueue.st +++ b/packages/visualgst/Misc/TaskQueue.st @@ -77,5 +77,15 @@ Object subclass: TaskQueue [ sem wait. currentProcess := nil ] repeat ] fork ] + + flush [ + <category: 'accessing'> + + queueHandler terminate. + currentProcess terminate. + self + initialize; + run. + ] ] diff --git a/packages/visualgst/package.xml b/packages/visualgst/package.xml index 52e7a31..8cd2db1 100644 --- a/packages/visualgst/package.xml +++ b/packages/visualgst/package.xml @@ -72,6 +72,7 @@ <filein>Gtk/GtkEntryBuffer.st</filein> <filein>Extensions.st</filein> <filein>Misc/TaskQueue.st</filein> + <filein>Misc/KeySnooper.st</filein> <filein>Notification/AbstractEvent.st</filein> <filein>Notification/AddedEvent.st</filein> <filein>Notification/CommentedEvent.st</filein> -- 1.8.3.2
_______________________________________________ help-smalltalk mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-smalltalk
