On 17/06/2013 17:28, Holger Hans Peter Freyther wrote:
On Mon, Jun 17, 2013 at 02:20:01PM +0200, Gwenaël Casaccio wrote:
Here is the new version of it (without the copyright header changes).
Thanks. For renames like these you might also want to help git format-patch
and pass the -M option to it. And the patch starts to be easily reviewable.
You have replaced precondition with valid.. removed the undo.. and renamed
the redo to execute.

diff --git a/packages/visualgst/Commands/SmalltalkMenus/AcceptItCommand.st 
b/packages/visualgst/Commands/SmalltalkMenus/AcceptItCommand.st
index 996669e..f7c06a2 100644
--- a/packages/visualgst/Commands/SmalltalkMenus/AcceptItCommand.st
+++ b/packages/visualgst/Commands/SmalltalkMenus/AcceptItCommand.st
@@ -74,11 +74,11 @@ Command subclass: AcceptItCommand [
        <category: 'command'>
target state hasSelectedCategory ifFalse: [ ^ self acceptClassDefinition ].
-        (AddMethodUndoCommand
+        SysAddMethodCommand
            add: target sourceCode
            classified: target state category
            in: target state classOrMeta
-           browser: target) push
+           browser: target

when/how is this command executed now?

+    execute [
+       <category: 'events'>
+
+       newClass := parentClass subclass: newClassName environment: namespace.
+       namespace at: newClass name put: newClass.
+        newClass category: classCategory fullname.

mixing tabs and spaces?


diff --git a/packages/visualgst/Gtk/GtkEntry.st 
b/packages/visualgst/Gtk/GtkEntry.st
new file mode 100644
index 0000000..fc34fdb
--- /dev/null
+++ b/packages/visualgst/Gtk/GtkEntry.st
@@ -0,0 +1,9 @@
+GTK.GtkEntry extend [
+
+    getText [
+
+        ^ self getBuffer getText
+    ]
+
+]
+
diff --git a/packages/visualgst/Gtk/GtkEntryBuffer.st 
b/packages/visualgst/Gtk/GtkEntryBuffer.st
new file mode 100644
index 0000000..eceb980
--- /dev/null
+++ b/packages/visualgst/Gtk/GtkEntryBuffer.st
@@ -0,0 +1,9 @@
+GTK.GtkEntryBuffer extend [
+
+    getText [
+
+        <cCall: 'gtk_entry_buffer_get_text' returning: #string args: #( #self 
#cObject )>
+    ]
+
+]

I think these belong to another patch?

Ok I've fixed the issue and splitted the patch

Cheers,
Gwen

>From 0bc1601097cfc0b12ec341f87b27152d199bdd16 Mon Sep 17 00:00:00 2001
From: Gwenael Casaccio <mrg...@gmail.com>
Date: Mon, 17 Jun 2013 21:13:04 +0200
Subject: [PATCH 1/2] Refactor some Smalltalk undo commands: make them subclass
 of commands. Smalltalk commands don't works as undoable commands, they could
 only be executed: a simple eval in the workspace could break the undo/redo
 code.

---
 packages/visualgst/ChangeLog                       | 32 +++++++++++++++++++
 .../CategoryMenus/RenameCategoryCommand.st         |  2 +-
 .../Commands/ClassMenus/AddClassCommand.st         |  4 +--
 .../Commands/ClassMenus/DeleteClassCommand.st      |  2 +-
 .../Commands/ClassMenus/RenameClassCommand.st      |  2 +-
 packages/visualgst/Commands/Command.st             | 15 ++++++++-
 .../Commands/MethodMenus/DeleteMethodCommand.st    |  2 +-
 .../Commands/NamespaceMenus/AddNamespaceCommand.st |  2 +-
 .../NamespaceMenus/DeleteNamespaceCommand.st       |  2 +-
 .../NamespaceMenus/RenameNamespaceCommand.st       |  2 +-
 .../Commands/SmalltalkMenus/AcceptItCommand.st     |  4 +--
 .../System/AddClassCommand.st}                     | 33 ++++++--------------
 .../System/AddMethodCommand.st}                    | 26 ++++------------
 .../System/AddNamespaceCommand.st}                 | 16 +++-------
 .../System/DeleteClassCommand.st}                  | 17 +++-------
 .../System/DeleteMethodCommand.st}                 | 20 +++---------
 .../System/DeleteNamespaceCommand.st}              | 14 +++------
 .../System/RenameCategoryCommand.st}               | 21 +++----------
 .../System/RenameClassCommand.st}                  | 17 +++-------
 .../System/RenameNamespaceCommand.st}              | 18 +++--------
 packages/visualgst/package.xml                     | 36 +++++++++++-----------
 21 files changed, 123 insertions(+), 164 deletions(-)
 rename packages/visualgst/{Undo/AddClassUndoCommand.st => Commands/System/AddClassCommand.st} (75%)
 rename packages/visualgst/{Undo/AddMethodUndoCommand.st => Commands/System/AddMethodCommand.st} (85%)
 rename packages/visualgst/{Undo/AddNamespaceUndoCommand.st => Commands/System/AddNamespaceCommand.st} (89%)
 rename packages/visualgst/{Undo/DeleteClassUndoCommand.st => Commands/System/DeleteClassCommand.st} (86%)
 rename packages/visualgst/{Undo/DeleteMethodUndoCommand.st => Commands/System/DeleteMethodCommand.st} (85%)
 rename packages/visualgst/{Undo/DeleteNamespaceUndoCommand.st => Commands/System/DeleteNamespaceCommand.st} (87%)
 rename packages/visualgst/{Undo/RenameCategoryUndoCommand.st => Commands/System/RenameCategoryCommand.st} (83%)
 rename packages/visualgst/{Undo/RenameClassUndoCommand.st => Commands/System/RenameClassCommand.st} (87%)
 rename packages/visualgst/{Undo/RenameNamespaceUndoCommand.st => Commands/System/RenameNamespaceCommand.st} (86%)

diff --git a/packages/visualgst/ChangeLog b/packages/visualgst/ChangeLog
index 9489ea3..36897ca 100644
--- a/packages/visualgst/ChangeLog
+++ b/packages/visualgst/ChangeLog
@@ -1,3 +1,35 @@
+2013-06-17  Gwenael Casaccio  <gwenael.casac...@gmail.com>
+
+        * Commands/System/AddClassCommand.st: New system command
+        * Commands/System/AddMethodCommand.st: New system command
+        * Commands/System/AddNamespaceCommand.st: New system command
+        * Commands/System/DeleteClassCommand.st: New system command
+        * Commands/System/DeleteMethodCommand.st: New system command
+        * Commands/System/DeleteNamespaceCommand.st: New system command
+        * Commands/System/RenameCategoryCommand.st: New system command
+        * Commands/System/RenameClassCommand.st: New system command
+        * Commands/System/RenameNamespaceCommand.st: New system command
+        * Commands/CategoryMenus/RenameCategoryCommand.st: Updated to new system command
+        * Commands/ClassMenus/AddClassCommand.st: Updated to new system command
+        * Commands/ClassMenus/DeleteClassCommand.st: Updated to new system command
+        * Commands/ClassMenus/RenameClassCommand.st: Updated to new system command
+        * Commands/Command.st: Updated to new system command
+        * Commands/MethodMenus/DeleteMethodCommand.st: Updated to new system command
+        * Commands/NamespaceMenus/AddNamespaceCommand.st: Updated to new system command
+        * Commands/NamespaceMenus/DeleteNamespaceCommand.st: Updated to new system command
+        * Commands/NamespaceMenus/RenameNamespaceCommand.st: Updated to new system command
+        * Commands/SmalltalkMenus/AcceptItCommand.st: Updated to new system command
+        * Undo/AddClassUndoCommand.st: Deleted
+        * Undo/AddMethodUndoCommand.st: Deleted
+        * Undo/AddNamespaceUndoCommand.st: Deleted
+        * Undo/DeleteClassUndoCommand.st: Deleted
+        * Undo/DeleteMethodUndoCommand.st: Deleted
+        * Undo/DeleteNamespaceUndoCommand.st: Deleted
+        * Undo/RenameCategoryUndoCommand.st: Deleted
+        * Undo/RenameClassUndoCommand.st: Deleted
+        * Undo/RenameNamespaceUndoCommand.st: Deleted
+        * package.xml: Update
+
 2013-06-17  Gwenael Casaccio  <mrg...@gmail.com>
 
 	* AbstractFinder.st: Add copyright header.
diff --git a/packages/visualgst/Commands/CategoryMenus/RenameCategoryCommand.st b/packages/visualgst/Commands/CategoryMenus/RenameCategoryCommand.st
index 883db28..f7dfc14 100644
--- a/packages/visualgst/Commands/CategoryMenus/RenameCategoryCommand.st
+++ b/packages/visualgst/Commands/CategoryMenus/RenameCategoryCommand.st
@@ -46,7 +46,7 @@ CategoryCommand subclass: RenameCategoryCommand [
 	| dlg |
         dlg := GtkEntryDialog title: 'Rename a category' text: 'Name of the category'.
         dlg hasPressedOk: [
-            (RenameCategoryUndoCommand rename: target state category in: target state classOrMeta as: dlg result onModel: target viewedCategoryModel) push ]
+            (SysRenameCategoryCommand rename: target state category in: target state classOrMeta as: dlg result onModel: target viewedCategoryModel) executeIfValid ]
     ]
 ]
 
diff --git a/packages/visualgst/Commands/ClassMenus/AddClassCommand.st b/packages/visualgst/Commands/ClassMenus/AddClassCommand.st
index 2212fd4..1a6f1db 100644
--- a/packages/visualgst/Commands/ClassMenus/AddClassCommand.st
+++ b/packages/visualgst/Commands/ClassMenus/AddClassCommand.st
@@ -49,11 +49,11 @@ NamespaceCommand subclass: AddClassCommand [
             ifFalse: [ Object ].
         dlg := GtkEntryDialog title: 'Add a class' text: 'Name of the new class'.
         dlg hasPressedOk: [
-            (AddClassUndoCommand
+            (SysAddClassCommand
                 add: dlg result asSymbol
                 to: target state namespace
                 classCategory: target state classCategory
-                withSuperclass: superclass) push ]
+                withSuperclass: superclass) executeIfValid ]
     ]
 ]
 
diff --git a/packages/visualgst/Commands/ClassMenus/DeleteClassCommand.st b/packages/visualgst/Commands/ClassMenus/DeleteClassCommand.st
index 29e37b8..aca4ada 100644
--- a/packages/visualgst/Commands/ClassMenus/DeleteClassCommand.st
+++ b/packages/visualgst/Commands/ClassMenus/DeleteClassCommand.st
@@ -43,6 +43,6 @@ ClassCommand subclass: DeleteClassCommand [
     execute [
 	<category: 'command'>
 
-        (DeleteClassUndoCommand delete: target state classOrMeta) push
+        (SysDeleteClassCommand delete: target state classOrMeta) executeIfValid
     ]
 ]
diff --git a/packages/visualgst/Commands/ClassMenus/RenameClassCommand.st b/packages/visualgst/Commands/ClassMenus/RenameClassCommand.st
index a34a007..3a9553c 100644
--- a/packages/visualgst/Commands/ClassMenus/RenameClassCommand.st
+++ b/packages/visualgst/Commands/ClassMenus/RenameClassCommand.st
@@ -46,7 +46,7 @@ ClassCommand subclass: RenameClassCommand [
 	| dlg |
         dlg := GtkEntryDialog title: 'Rename a class' text: 'Name of the class'.
         dlg hasPressedOk: [
-            (RenameClassUndoCommand rename: target state classOrMeta as: dlg result asSymbol) push ]
+            (SysRenameClassCommand rename: target state classOrMeta as: dlg result asSymbol) executeIfValid ]
     ]
 ]
 
diff --git a/packages/visualgst/Commands/Command.st b/packages/visualgst/Commands/Command.st
index 8cd1ef5..32e826d 100644
--- a/packages/visualgst/Commands/Command.st
+++ b/packages/visualgst/Commands/Command.st
@@ -65,7 +65,7 @@ Object subclass: Command [
             yourself
     ]
 
-    | target |
+    | target error |
     
     target: anObject [
 	<category: 'accessing'>
@@ -85,6 +85,19 @@ Object subclass: Command [
 	^ true
     ]
 
+    preconditionFailed: aString [
+        <category: 'checking'>
+
+        error := aString.
+        ^ false
+    ]
+
+    error [
+        <category: 'checking'>
+
+        ^ error
+    ]
+
     executeIfValid [
 	<category: 'command'>
 
diff --git a/packages/visualgst/Commands/MethodMenus/DeleteMethodCommand.st b/packages/visualgst/Commands/MethodMenus/DeleteMethodCommand.st
index b760541..0a17317 100644
--- a/packages/visualgst/Commands/MethodMenus/DeleteMethodCommand.st
+++ b/packages/visualgst/Commands/MethodMenus/DeleteMethodCommand.st
@@ -43,7 +43,7 @@ MethodCommand subclass: DeleteMethodCommand [
     execute [
 	<category: 'command'>
 
-        (DeleteMethodUndoCommand delete: target state selector in: target state classOrMeta) push
+        (SysDeleteMethodCommand delete: target state selector in: target state classOrMeta) executeIfValid
     ]
 ]
 
diff --git a/packages/visualgst/Commands/NamespaceMenus/AddNamespaceCommand.st b/packages/visualgst/Commands/NamespaceMenus/AddNamespaceCommand.st
index f06c257..45992ca 100644
--- a/packages/visualgst/Commands/NamespaceMenus/AddNamespaceCommand.st
+++ b/packages/visualgst/Commands/NamespaceMenus/AddNamespaceCommand.st
@@ -46,7 +46,7 @@ NamespaceCommand subclass: AddNamespaceCommand [
 	| dlg |
         dlg := GtkEntryDialog title: 'Add a namespace' text: 'Name of the new namespace'.
         dlg hasPressedOk: [ 
-            (AddNamespaceUndoCommand add: dlg result asSymbol to: target state namespace) push ]
+            (SysAddNamespaceCommand add: dlg result asSymbol to: target state namespace) executeIfValid ]
     ]
 ]
 
diff --git a/packages/visualgst/Commands/NamespaceMenus/DeleteNamespaceCommand.st b/packages/visualgst/Commands/NamespaceMenus/DeleteNamespaceCommand.st
index 62983e5..36e3e7c 100644
--- a/packages/visualgst/Commands/NamespaceMenus/DeleteNamespaceCommand.st
+++ b/packages/visualgst/Commands/NamespaceMenus/DeleteNamespaceCommand.st
@@ -46,7 +46,7 @@ NamespaceCommand subclass: DeleteNamespaceCommand [
 	| namespace |
         namespace := target state namespace.
         namespace subspaces isEmpty ifFalse: [ self error: 'Namespace has subspaces' ].
-        (DeleteNamespaceUndoCommand delete: namespace) push
+        (SysDeleteNamespaceCommand delete: namespace) executeIfValid
     ]
 ]
 
diff --git a/packages/visualgst/Commands/NamespaceMenus/RenameNamespaceCommand.st b/packages/visualgst/Commands/NamespaceMenus/RenameNamespaceCommand.st
index d8b489d..76f15a6 100644
--- a/packages/visualgst/Commands/NamespaceMenus/RenameNamespaceCommand.st
+++ b/packages/visualgst/Commands/NamespaceMenus/RenameNamespaceCommand.st
@@ -46,7 +46,7 @@ NamespaceCommand subclass: RenameNamespaceCommand [
 	| dlg |
         dlg := GtkEntryDialog title: 'Rename a namespace' text: 'Name of the new namespace'.
         dlg hasPressedOk: [ 
-            (RenameNamespaceUndoCommand rename: target state namespace as: dlg result asSymbol) push ]
+            (SysRenameNamespaceCommand rename: target state namespace as: dlg result asSymbol) executeIfValid ]
     ]
 ]
 
diff --git a/packages/visualgst/Commands/SmalltalkMenus/AcceptItCommand.st b/packages/visualgst/Commands/SmalltalkMenus/AcceptItCommand.st
index 996669e..f7c06a2 100644
--- a/packages/visualgst/Commands/SmalltalkMenus/AcceptItCommand.st
+++ b/packages/visualgst/Commands/SmalltalkMenus/AcceptItCommand.st
@@ -74,11 +74,11 @@ Command subclass: AcceptItCommand [
 	<category: 'command'>
 
         target state hasSelectedCategory ifFalse: [ ^ self acceptClassDefinition ].
-        (AddMethodUndoCommand
+        (SysAddMethodCommand
 	    add: target sourceCode
 	    classified: target state category 
 	    in: target state classOrMeta
-	    browser: target) push
+	    browser: target) executeIfValid
     ]
 ]
 
diff --git a/packages/visualgst/Undo/AddClassUndoCommand.st b/packages/visualgst/Commands/System/AddClassCommand.st
similarity index 75%
rename from packages/visualgst/Undo/AddClassUndoCommand.st
rename to packages/visualgst/Commands/System/AddClassCommand.st
index 102b56c..55c636f 100644
--- a/packages/visualgst/Undo/AddClassUndoCommand.st
+++ b/packages/visualgst/Commands/System/AddClassCommand.st
@@ -1,6 +1,6 @@
 "======================================================================
 |
-| AddClassUndoCommand class definition
+| SysAddClassCommand class definition
 |
 ======================================================================"
 
@@ -33,23 +33,21 @@
 |
 ======================================================================"
 
-UndoCommand subclass: AddClassUndoCommand [
+Command subclass: SysAddClassCommand [
 
-    | first namespace newClassName parentClass newClass classCategory |
+    | namespace newClassName parentClass newClass classCategory |
 
-    AddClassUndoCommand class >> add: aSymbol to: aNamespace classCategory: aCategory withSuperclass: aClass [
+    SysAddClassCommand class >> add: aSymbol to: aNamespace classCategory: aCategory withSuperclass: aClass [
 	<category: 'instance creation'>
 
 	^ (self new)
 	    add: aSymbol to: aNamespace classCategory: aCategory withSuperclass: aClass;
-	    precondition;
 	    yourself
     ]
 
     add: aSymbol to: aNamespace classCategory: aCategory withSuperclass: aClass [
 	<category: 'initialize'>
 
-	first := true.
 	newClassName := aSymbol.
 	namespace := aNamespace.
 	classCategory := aCategory.
@@ -62,7 +60,7 @@ UndoCommand subclass: AddClassUndoCommand [
 	^ 'Add a class'
     ]
 
-    precondition [
+    valid [
 	<category: 'checking'>
 
 	newClassName = #Smalltalk ifTrue: [ ^ self preconditionFailed: 'class name can''t be the same has a namespace name'  ].
@@ -71,25 +69,12 @@ UndoCommand subclass: AddClassUndoCommand [
 	^ true
     ]
 
-    undo [
+    execute [
 	<category: 'events'>
 
-	parentClass removeSubclass: newClass.
-	namespace removeClass: newClass name
-    ]
-
-    redo [
-	<category: 'events'>
-
-	first 
-	    ifTrue: [
-		newClass := parentClass subclass: newClassName environment: namespace.
-		namespace at: newClass name put: newClass.
-                newClass category: classCategory fullname.
-		first := false ]
-	    ifFalse: [ 
-		parentClass addSubclass: newClass.
-		namespace insertClass: newClass ]
+	newClass := parentClass subclass: newClassName environment: namespace.
+	namespace at: newClass name put: newClass.
+        newClass category: classCategory fullname.
     ]
 ]
 
diff --git a/packages/visualgst/Undo/AddMethodUndoCommand.st b/packages/visualgst/Commands/System/AddMethodCommand.st
similarity index 85%
rename from packages/visualgst/Undo/AddMethodUndoCommand.st
rename to packages/visualgst/Commands/System/AddMethodCommand.st
index 037ac76..bc0621a 100644
--- a/packages/visualgst/Undo/AddMethodUndoCommand.st
+++ b/packages/visualgst/Commands/System/AddMethodCommand.st
@@ -1,6 +1,6 @@
 "======================================================================
 |
-| AddMethodUndoCommand class definition
+| SysAddMethodCommand class definition
 |
 ======================================================================"
 
@@ -33,11 +33,11 @@
 |
 ======================================================================"
 
-UndoCommand subclass: AddMethodUndoCommand [
+Command subclass: SysAddMethodCommand [
 
     | selector method category classOrMeta oldCompiledMethod browserWidget compiledMethod |
 
-    AddMethodUndoCommand class >> add: aString classified: aCategory in: aClass [
+    SysAddMethodCommand class >> add: aString classified: aCategory in: aClass [
 	<category: 'instance creation'>
 
 	^ (self new)
@@ -45,7 +45,7 @@ UndoCommand subclass: AddMethodUndoCommand [
 	    yourself
     ]
 
-    AddMethodUndoCommand class >> add: aString classified: aCategory in: aClass browser: aGtkBrowserWidget [
+    SysAddMethodCommand class >> add: aString classified: aCategory in: aClass browser: aGtkBrowserWidget [
         <category: 'instance creation'>
 
         ^ (self new)
@@ -89,7 +89,7 @@ UndoCommand subclass: AddMethodUndoCommand [
 	^ 'Add a method'
     ]
 
-    precondition [
+    valid [
         <category: 'checking'>
 
 	| parser node |
@@ -109,21 +109,7 @@ UndoCommand subclass: AddMethodUndoCommand [
 	^ true
     ]
 
-    undo [
-	<category: 'events'>
-
-	| selector |
-        browserWidget ifNotNil: [ browserWidget codeSaved ].
-
-	classOrMeta methodDictionary removeMethod: compiledMethod.
-	oldCompiledMethod 
-	    ifNotNil: [
-		classOrMeta methodDictionary insertMethod: oldCompiledMethod.
-		selector := oldCompiledMethod selector ]
-	    ifNil: [ selector := nil ].
-    ]
-
-    redo [
+    execute [
 	<category: 'events'>
 
 	browserWidget ifNotNil: [ browserWidget codeSaved ].
diff --git a/packages/visualgst/Undo/AddNamespaceUndoCommand.st b/packages/visualgst/Commands/System/AddNamespaceCommand.st
similarity index 89%
rename from packages/visualgst/Undo/AddNamespaceUndoCommand.st
rename to packages/visualgst/Commands/System/AddNamespaceCommand.st
index 902fdb8..2eafaec 100644
--- a/packages/visualgst/Undo/AddNamespaceUndoCommand.st
+++ b/packages/visualgst/Commands/System/AddNamespaceCommand.st
@@ -1,6 +1,6 @@
 "======================================================================
 |
-| AddNamespaceUndoCommand class definition
+| SysAddNamespace class definition
 |
 ======================================================================"
 
@@ -33,10 +33,10 @@
 |
 ======================================================================"
 
-UndoCommand subclass: AddNamespaceUndoCommand [
+Command subclass: SysAddNamespaceCommand [
     | parentNamespace namespaceName newNamespace |
 
-    AddNamespaceUndoCommand class >> add: aSymbol to: aNamespace [
+    SysAddNamespaceCommand class >> add: aSymbol to: aNamespace [
 	<category: 'instance creation'>
 
 	^ (self new)
@@ -57,7 +57,7 @@ UndoCommand subclass: AddNamespaceUndoCommand [
 	^ 'Add a namespace'
     ]
 
-    precondition [
+    valid [
         <category: 'checking'>
 
         namespaceName = #Smalltalk ifTrue: [ ^ self preconditionFailed: 'class name can''t be the same has a namespace name' ].
@@ -68,13 +68,7 @@ UndoCommand subclass: AddNamespaceUndoCommand [
 	^ true
     ]
 
-    undo [
-	<category: 'events'>
-
-	parentNamespace removeSubspace: newNamespace name
-    ]
-
-    redo [
+    execute [
 	<category: 'events'>
 
 	parentNamespace insertSubspace: newNamespace
diff --git a/packages/visualgst/Undo/DeleteClassUndoCommand.st b/packages/visualgst/Commands/System/DeleteClassCommand.st
similarity index 86%
rename from packages/visualgst/Undo/DeleteClassUndoCommand.st
rename to packages/visualgst/Commands/System/DeleteClassCommand.st
index 0487399..a3ad7dd 100644
--- a/packages/visualgst/Undo/DeleteClassUndoCommand.st
+++ b/packages/visualgst/Commands/System/DeleteClassCommand.st
@@ -1,6 +1,6 @@
 "======================================================================
 |
-| DeleteClassUndoCommand class definition
+| SysDeleteClassCommand class definition
 |
 ======================================================================"
 
@@ -33,11 +33,11 @@
 |
 ======================================================================"
 
-UndoCommand subclass: DeleteClassUndoCommand [
+Command subclass: SysDeleteClassCommand [
 
     |  class |
 
-    DeleteClassUndoCommand class >> delete: aClass [
+    SysDeleteClassCommand class >> delete: aClass [
 	<category: 'instance creation'>
 
 	^ (self new)
@@ -58,21 +58,14 @@ UndoCommand subclass: DeleteClassUndoCommand [
 	^ 'Delete a class'
     ]
 
-    precondition [
+    valid [
 	<category: 'checking'>
 
         class subclasses isEmpty ifFalse: [ ^ self preconditionFailed: 'class has subclasses' ].
 	^ true
     ]
 
-    undo [
-	<category: 'events'>
-
-	class superclass ifNotNil: [ class superclass addSubclass: class ].
-	class environment insertClass: class
-    ]
-
-    redo [
+    execute [
 	<category: 'events'>
 
 	class superclass ifNotNil: [ class superclass removeSubclass: class ].
diff --git a/packages/visualgst/Undo/DeleteMethodUndoCommand.st b/packages/visualgst/Commands/System/DeleteMethodCommand.st
similarity index 85%
rename from packages/visualgst/Undo/DeleteMethodUndoCommand.st
rename to packages/visualgst/Commands/System/DeleteMethodCommand.st
index 89336ca..f0ad368 100644
--- a/packages/visualgst/Undo/DeleteMethodUndoCommand.st
+++ b/packages/visualgst/Commands/System/DeleteMethodCommand.st
@@ -1,6 +1,6 @@
 "======================================================================
 |
-| DeleteMethodUndoCommand class definition
+| SysDeleteMethodCommand class definition
 |
 ======================================================================"
 
@@ -33,11 +33,11 @@
 |
 ======================================================================"
 
-UndoCommand subclass: DeleteMethodUndoCommand [
+Command subclass: SysDeleteMethodCommand [
 
     | selector classOrMeta compiledMethod |
 
-    DeleteMethodUndoCommand class >> delete: aSymbol in: aClass [
+    SysDeleteMethodCommand class >> delete: aSymbol in: aClass [
 	<category: 'instance creation'>
 
 	^ (self new)
@@ -59,19 +59,7 @@ UndoCommand subclass: DeleteMethodUndoCommand [
 	^ 'Delete a method'
     ]
 
-    precondition [
-        <category: 'checking'>
-
-	^ true
-    ]
-
-    undo [
-	<category: 'events'>
-
-	classOrMeta methodDictionary insertMethod: compiledMethod.
-    ]
-
-    redo [
+    execte [
 	<category: 'events'>
 
 	compiledMethod := classOrMeta >> selector.
diff --git a/packages/visualgst/Undo/DeleteNamespaceUndoCommand.st b/packages/visualgst/Commands/System/DeleteNamespaceCommand.st
similarity index 87%
rename from packages/visualgst/Undo/DeleteNamespaceUndoCommand.st
rename to packages/visualgst/Commands/System/DeleteNamespaceCommand.st
index 8bd2c3b..718bdba 100644
--- a/packages/visualgst/Undo/DeleteNamespaceUndoCommand.st
+++ b/packages/visualgst/Commands/System/DeleteNamespaceCommand.st
@@ -1,6 +1,6 @@
 "======================================================================
 |
-| DeleteNamespaceUndoCommand class definition
+| SysDeleteNamespaceCommand class definition
 |
 ======================================================================"
 
@@ -33,11 +33,11 @@
 |
 ======================================================================"
 
-UndoCommand subclass: DeleteNamespaceUndoCommand [
+Command subclass: SysDeleteNamespaceCommand [
 
     |  namespace treeStore |
 
-    DeleteNamespaceUndoCommand class >> delete: aNamespace [
+    SysDeleteNamespaceCommand class >> delete: aNamespace [
 	<category: 'instance creation'>
 
 	^ (self new)
@@ -57,13 +57,7 @@ UndoCommand subclass: DeleteNamespaceUndoCommand [
 	^ 'Delete a namespace'
     ]
 
-    undo [
-	<category: 'events'>
-
-	namespace superspace insertSubspace: namespace
-    ]
-
-    redo [
+    execute [
 	<category: 'events'>
 
 	namespace superspace removeSubspace: namespace name
diff --git a/packages/visualgst/Undo/RenameCategoryUndoCommand.st b/packages/visualgst/Commands/System/RenameCategoryCommand.st
similarity index 83%
rename from packages/visualgst/Undo/RenameCategoryUndoCommand.st
rename to packages/visualgst/Commands/System/RenameCategoryCommand.st
index 7a29841..3fc0beb 100644
--- a/packages/visualgst/Undo/RenameCategoryUndoCommand.st
+++ b/packages/visualgst/Commands/System/RenameCategoryCommand.st
@@ -1,6 +1,6 @@
 "======================================================================
 |
-| RenameCategoryUndoCommand class definition
+| SysRenameCategorycommand class definition
 |
 ======================================================================"
 
@@ -33,11 +33,11 @@
 |
 ======================================================================"
 
-UndoCommand subclass: RenameCategoryUndoCommand [
+Command subclass: SysRenameCategoryCommand [
 
     | category class newCategory treeStore |
 
-    RenameCategoryUndoCommand class >> rename: aString in: aClass as: aNewName onModel: aGtkTreeStore [
+    SysRenameCategoryCommand class >> rename: aString in: aClass as: aNewName onModel: aGtkTreeStore [
 	<category: 'instance creation'>
 
 	^ (self new)
@@ -61,7 +61,7 @@ UndoCommand subclass: RenameCategoryUndoCommand [
 	^ 'Rename a category'
     ]
 
-    precondition [
+    valid [
         <category: 'checking'>
 
 	newCategory = '*' ifTrue: [ ^ self preconditionFailed: 'Can''t create a * category' ].
@@ -69,18 +69,7 @@ UndoCommand subclass: RenameCategoryUndoCommand [
 	^ true
     ]
 
-    undo [
-	<category: 'events'>
-
-	class methodDictionary do: [ :each |
-	    each methodCategory = newCategory
-		ifTrue: [ each methodCategory: category ] ].
-	treeStore
-	    removeCategory: newCategory;
-	    appendCategory: category
-    ]
-
-    redo [
+    execute [
 	<category: 'events'>
 
 	class methodDictionary do: [ :each |
diff --git a/packages/visualgst/Undo/RenameClassUndoCommand.st b/packages/visualgst/Commands/System/RenameClassCommand.st
similarity index 87%
rename from packages/visualgst/Undo/RenameClassUndoCommand.st
rename to packages/visualgst/Commands/System/RenameClassCommand.st
index 8d9c941..dd3edcc 100644
--- a/packages/visualgst/Undo/RenameClassUndoCommand.st
+++ b/packages/visualgst/Commands/System/RenameClassCommand.st
@@ -1,6 +1,6 @@
 "======================================================================
 |
-| RenameClassUndoCommand class definition
+| SysRenameClassCommand class definition
 |
 ======================================================================"
 
@@ -33,11 +33,11 @@
 |
 ======================================================================"
 
-UndoCommand subclass: RenameClassUndoCommand [
+Command subclass: SysRenameClassCommand [
 
     | class newClassName oldClassName |
 
-    RenameClassUndoCommand class >> rename: aClass as: aSymbol [
+    SysRenameClassCommand class >> rename: aClass as: aSymbol [
 	<category: 'instance creation'>
 
 	^ (self new)
@@ -60,7 +60,7 @@ UndoCommand subclass: RenameClassUndoCommand [
 	^ 'Rename a class'
     ]
 
-    precondition [
+    execute [
         <category: 'checking'>
 
         newClassName = #Smalltalk ifTrue: [ ^ self preconditionFailed: 'class name can''t be the same has a namespace name'  ].
@@ -69,15 +69,8 @@ UndoCommand subclass: RenameClassUndoCommand [
 	^ true
     ]
 
-    undo [
-	<category: 'events'>
-	
-        class environment removeClass: newClassName.
-        class setName: oldClassName.
-	class environment insertClass: class
-    ]
 
-    redo [
+    valid [
 	<category: 'events'>
 
         class environment removeClass: oldClassName.
diff --git a/packages/visualgst/Undo/RenameNamespaceUndoCommand.st b/packages/visualgst/Commands/System/RenameNamespaceCommand.st
similarity index 86%
rename from packages/visualgst/Undo/RenameNamespaceUndoCommand.st
rename to packages/visualgst/Commands/System/RenameNamespaceCommand.st
index 01b5923..80268c6 100644
--- a/packages/visualgst/Undo/RenameNamespaceUndoCommand.st
+++ b/packages/visualgst/Commands/System/RenameNamespaceCommand.st
@@ -1,6 +1,6 @@
 "======================================================================
 |
-| RenameNamespaceUndoCommand class definition
+| SysRenameNamespaceCommand class definition
 |
 ======================================================================"
 
@@ -33,11 +33,11 @@
 |
 ======================================================================"
 
-UndoCommand subclass: RenameNamespaceUndoCommand [
+Command subclass: SysRenameNamespaceCommand [
 
     | namespace oldName newName |
 
-    RenameNamespaceUndoCommand class >> rename: aNamespace as: aSymbol [
+    SysRenameNamespaceCommand class >> rename: aNamespace as: aSymbol [
 	<category: 'instance creation'>
 
 	^ (self new)
@@ -60,7 +60,7 @@ UndoCommand subclass: RenameNamespaceUndoCommand [
 	^ 'Rename a namespace'
     ]
 
-    precondition [
+    execute [
         <category: 'checking'>
 
         newName = #Smalltalk ifTrue: [ ^ self preconditionFailed: 'Namespace name can''t be the same has a namespace name'  ].
@@ -68,15 +68,7 @@ UndoCommand subclass: RenameNamespaceUndoCommand [
 	^ true
     ]
 
-    undo [
-	<category: 'events'>
-
-	namespace superspace removeSubspace: namespace name.
-	namespace name: oldName.
-	namespace superspace insertSubspace: namespace
-    ]
-
-    redo [
+    valid [
 	<category: 'events'>
 
 	namespace superspace removeSubspace: namespace name.
diff --git a/packages/visualgst/package.xml b/packages/visualgst/package.xml
index 4267d1d..45a7a8c 100644
--- a/packages/visualgst/package.xml
+++ b/packages/visualgst/package.xml
@@ -208,9 +208,9 @@
   <filein>HistoryStack.st</filein>
   <filein>Undo/UndoStack.st</filein>
   <filein>Undo/UndoCommand.st</filein>
-  <filein>Undo/AddNamespaceUndoCommand.st</filein>
-  <filein>Undo/RenameNamespaceUndoCommand.st</filein>
-  <filein>Undo/DeleteNamespaceUndoCommand.st</filein>
+  <filein>Commands/System/AddNamespaceCommand.st</filein>
+  <filein>Commands/System/RenameNamespaceCommand.st</filein>
+  <filein>Commands/System/DeleteNamespaceCommand.st</filein>
   <filein>Source/SourceFormatter.st</filein>
   <filein>Source/NamespaceHeaderSource.st</filein>
   <filein>Source/NamespaceSource.st</filein>
@@ -220,9 +220,9 @@
   <filein>Source/MethodSource.st</filein>
   <filein>Source/PackageSource.st</filein>
   <filein>Source/BrowserMethodSource.st</filein>
-  <filein>Undo/AddClassUndoCommand.st</filein>
-  <filein>Undo/RenameClassUndoCommand.st</filein>
-  <filein>Undo/DeleteClassUndoCommand.st</filein>
+  <filein>Commands/System/AddClassCommand.st</filein>
+  <filein>Commands/System/RenameClassCommand.st</filein>
+  <filein>Commands/System/DeleteClassCommand.st</filein>
   <filein>AbstractFinder.st</filein>
   <filein>NamespaceFinder.st</filein>
   <filein>ClassFinder.st</filein>
@@ -230,9 +230,9 @@
   <filein>GtkWebBrowser.st</filein>
   <filein>GtkWebView.st</filein>
   <filein>GtkAssistant.st</filein>
-  <filein>Undo/RenameCategoryUndoCommand.st</filein>
-  <filein>Undo/AddMethodUndoCommand.st</filein>
-  <filein>Undo/DeleteMethodUndoCommand.st</filein>
+  <filein>Commands/System/RenameCategoryCommand.st</filein>
+  <filein>Commands/System/AddMethodCommand.st</filein>
+  <filein>Commands/System/DeleteMethodCommand.st</filein>
   <filein>WorkspaceVariableTracker.st</filein>
   <filein>GtkVariableTrackerWidget.st</filein>
   <filein>SyntaxHighlighter.st</filein>
@@ -434,9 +434,9 @@
   <file>HistoryStack.st</file>
   <file>Undo/UndoStack.st</file>
   <file>Undo/UndoCommand.st</file>
-  <file>Undo/AddNamespaceUndoCommand.st</file>
-  <file>Undo/RenameNamespaceUndoCommand.st</file>
-  <file>Undo/DeleteNamespaceUndoCommand.st</file>
+  <file>Commands/System/AddNamespaceCommand.st</file>
+  <file>Commands/System/RenameNamespaceCommand.st</file>
+  <file>Commands/System/DeleteNamespaceCommand.st</file>
   <file>Source/SourceFormatter.st</file>
   <file>Source/NamespaceHeaderSource.st</file>
   <file>Source/NamespaceSource.st</file>
@@ -446,9 +446,9 @@
   <file>Source/MethodSource.st</file>
   <file>Source/PackageSource.st</file>
   <file>Source/BrowserMethodSource.st</file>
-  <file>Undo/AddClassUndoCommand.st</file>
-  <file>Undo/RenameClassUndoCommand.st</file>
-  <file>Undo/DeleteClassUndoCommand.st</file>
+  <file>Commands/System/AddClassCommand.st</file>
+  <file>Commands/System/RenameClassCommand.st</file>
+  <file>Commands/System/DeleteClassCommand.st</file>
   <file>AbstractFinder.st</file>
   <file>NamespaceFinder.st</file>
   <file>ClassFinder.st</file>
@@ -457,9 +457,9 @@
   <file>GtkWebView.st</file>
   <file>Extensions.st</file>
   <file>GtkAssistant.st</file>
-  <file>Undo/RenameCategoryUndoCommand.st</file>
-  <file>Undo/AddMethodUndoCommand.st</file>
-  <file>Undo/DeleteMethodUndoCommand.st</file>
+  <file>Commands/System/RenameCategoryCommand.st</file>
+  <file>Commands/System/AddMethodCommand.st</file>
+  <file>Commands/System/DeleteMethodCommand.st</file>
   <file>WorkspaceVariableTracker.st</file>
   <file>GtkVariableTrackerWidget.st</file>
   <file>SyntaxHighlighter.st</file>
-- 
1.8.1.2

>From 1df99f30f5306532cb492b8aaf309801f6e9ec74 Mon Sep 17 00:00:00 2001
From: Gwenael Casaccio <mrg...@gmail.com>
Date: Mon, 17 Jun 2013 21:15:24 +0200
Subject: [PATCH 2/2] Add a primitive for retrieving the GtkEntryBuffer text
 and an helper function

---
 packages/visualgst/ChangeLog             | 6 ++++++
 packages/visualgst/Gtk/GtkEntry.st       | 9 +++++++++
 packages/visualgst/Gtk/GtkEntryBuffer.st | 9 +++++++++
 packages/visualgst/package.xml           | 4 ++++
 4 files changed, 28 insertions(+)
 create mode 100644 packages/visualgst/Gtk/GtkEntry.st
 create mode 100644 packages/visualgst/Gtk/GtkEntryBuffer.st

diff --git a/packages/visualgst/ChangeLog b/packages/visualgst/ChangeLog
index 36897ca..18b8c0a 100644
--- a/packages/visualgst/ChangeLog
+++ b/packages/visualgst/ChangeLog
@@ -1,5 +1,11 @@
 2013-06-17  Gwenael Casaccio  <gwenael.casac...@gmail.com>
 
+        * Gtk/GtkEntry.st: GtkEntry support
+        * Gtk/GtkEntryBuffer.st: GtkEntry support
+        * package.xml: Update
+
+2013-06-17  Gwenael Casaccio  <gwenael.casac...@gmail.com>
+
         * Commands/System/AddClassCommand.st: New system command
         * Commands/System/AddMethodCommand.st: New system command
         * Commands/System/AddNamespaceCommand.st: New system command
diff --git a/packages/visualgst/Gtk/GtkEntry.st b/packages/visualgst/Gtk/GtkEntry.st
new file mode 100644
index 0000000..fc34fdb
--- /dev/null
+++ b/packages/visualgst/Gtk/GtkEntry.st
@@ -0,0 +1,9 @@
+GTK.GtkEntry extend [
+
+    getText [
+
+        ^ self getBuffer getText
+    ]
+
+]
+
diff --git a/packages/visualgst/Gtk/GtkEntryBuffer.st b/packages/visualgst/Gtk/GtkEntryBuffer.st
new file mode 100644
index 0000000..eceb980
--- /dev/null
+++ b/packages/visualgst/Gtk/GtkEntryBuffer.st
@@ -0,0 +1,9 @@
+GTK.GtkEntryBuffer extend [
+
+    getText [
+    
+        <cCall: 'gtk_entry_buffer_get_text' returning: #string args: #( #self #cObject )>
+    ]
+
+]
+
diff --git a/packages/visualgst/package.xml b/packages/visualgst/package.xml
index 45a7a8c..b46f4f8 100644
--- a/packages/visualgst/package.xml
+++ b/packages/visualgst/package.xml
@@ -68,6 +68,8 @@
       VisualGST.GtkConcreteWidgetTest
     </sunit>
   </test>
+  <filein>Gtk/GtkEntry.st</filein>
+  <filein>Gtk/GtkEntryBuffer.st</filein>
   <filein>Extensions.st</filein>
   <filein>Notification/AbstractEvent.st</filein>
   <filein>Notification/AddedEvent.st</filein>
@@ -455,6 +457,8 @@
   <file>MethodFinder.st</file>
   <file>GtkWebBrowser.st</file>
   <file>GtkWebView.st</file>
+  <file>Gtk/GtkEntry.st</file>
+  <file>Gtk/GtkEntryBuffer.st</file>
   <file>Extensions.st</file>
   <file>GtkAssistant.st</file>
   <file>Commands/System/RenameCategoryCommand.st</file>
-- 
1.8.1.2

_______________________________________________
help-smalltalk mailing list
help-smalltalk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to