Hi,

here is a small patch that simplify the GtkTreeModel usage;
it expects an array as root item which simplify a lot the construction
and makes it consitent.

Cheers,
Gwen

>From e7bf6fef452e08c59e9939138531c0efbc727147 Mon Sep 17 00:00:00 2001
From: Gwenael Casaccio <[email protected]>
Date: Fri, 31 May 2013 09:15:29 +0200
Subject: [PATCH 1/2] Make the GtkTreeModel construction more consistent and
 easier to use; migrate the user to the new construction.

---
 packages/visualgst/FakeNamespace.st                | 14 ------
 packages/visualgst/GtkTreeModel.st                 | 50 +++++++++++++++++++---
 .../StBrowser/GtkCategorizedClassWidget.st         | 37 +++++++++++++++-
 .../StBrowser/GtkCategorizedNamespaceWidget.st     | 37 +++++++++++++++-
 .../visualgst/StBrowser/GtkClassHierarchyWidget.st | 38 +++++++++++++++-
 5 files changed, 151 insertions(+), 25 deletions(-)
 delete mode 100644 packages/visualgst/FakeNamespace.st

diff --git a/packages/visualgst/FakeNamespace.st b/packages/visualgst/FakeNamespace.st
deleted file mode 100644
index 59ab946..0000000
--- a/packages/visualgst/FakeNamespace.st
+++ /dev/null
@@ -1,14 +0,0 @@
-Object subclass: FakeNamespace [
-
-    FakeNamespace class >> subspaces [
-	<category: 'accessing'>
-
-	^ {Smalltalk}
-    ]
-
-    FakeNamespace class >> categories [
-	<category: 'accessing'>
-
-	^ ClassCategory new
-    ]
-]
diff --git a/packages/visualgst/GtkTreeModel.st b/packages/visualgst/GtkTreeModel.st
index cca4302..d92ee0c 100644
--- a/packages/visualgst/GtkTreeModel.st
+++ b/packages/visualgst/GtkTreeModel.st
@@ -1,3 +1,38 @@
+"======================================================================
+|
+| GtkTreeModel 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: GtkTreeModel [
 
     GtkTreeModel class >> on: aGtkTreeStore [
@@ -79,9 +114,10 @@ Object subclass: GtkTreeModel [
     append: anItem with: aParentIter [
         <category:' model'>
 
-        | iter |
-        iter := model append: aParentIter item: ((self contentsBlock value: anItem) copyWith: anItem).
-        (self childrenBlock value: anItem) do: [ :each | self append: each with: iter ]
+        anItem do: [ :item |
+            | iter |
+            iter := model append: aParentIter item: ((self contentsBlock value: item) copyWith: item).
+            self append: (self childrenBlock value: item) with: iter ]
     ]
 
     remove: anObject ifAbsent: aBlock [
@@ -105,11 +141,11 @@ Object subclass: GtkTreeModel [
     ]
 
     refresh [
-	<category: 'model'>
+        <category: 'model'>
 
-	self clear.
-	self item ifNil: [ ^ self ].
-	(self childrenBlock value: self item) do: [ :each | self append: each with: nil ]
+        self clear.
+        self item ifNil: [ ^ self ].
+        self append: self item with: nil.
     ]
 
     hasItem: anObject [
diff --git a/packages/visualgst/StBrowser/GtkCategorizedClassWidget.st b/packages/visualgst/StBrowser/GtkCategorizedClassWidget.st
index 270db8c..5cd6b2e 100644
--- a/packages/visualgst/StBrowser/GtkCategorizedClassWidget.st
+++ b/packages/visualgst/StBrowser/GtkCategorizedClassWidget.st
@@ -1,3 +1,38 @@
+"======================================================================
+|
+| GtkCategorizedClassWidget 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.
+|
+======================================================================"
+
 Smalltalk.String extend [
 
     fullname [
@@ -83,7 +118,7 @@ GtkConcreteWidget subclass: GtkCategorizedClassWidget [
     root [
 	<category: 'accessing'>
 
-	^ Class
+	^ Class subclasses
     ]
 
     selectionMode [
diff --git a/packages/visualgst/StBrowser/GtkCategorizedNamespaceWidget.st b/packages/visualgst/StBrowser/GtkCategorizedNamespaceWidget.st
index 62f4ca0..335e7d4 100644
--- a/packages/visualgst/StBrowser/GtkCategorizedNamespaceWidget.st
+++ b/packages/visualgst/StBrowser/GtkCategorizedNamespaceWidget.st
@@ -1,3 +1,38 @@
+"======================================================================
+|
+| GtkCategorizedNamespaceWidget 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.
+|
+======================================================================"
+
 GtkConcreteWidget subclass: GtkCategorizedNamespaceWidget [
     | namespaceTree model |
 
@@ -24,7 +59,7 @@ GtkConcreteWidget subclass: GtkCategorizedNamespaceWidget [
 	namespaceTree connectToWhenPopupMenu: (NamespaceMenus on: self).
 	namespaceTree treeView getSelection setMode: GTK.Gtk gtkSelectionBrowse.
 	(model := GtkTreeModel on: namespaceTree treeView getModel)
-                                        item: FakeNamespace;
+                                        item: { Smalltalk };
                                         childrenBlock: [ :each | (each subspaces asArray sort: [ :a :b | a name <= b name ]), (each categories values sort: [ :a :b | a name <= b name ]) ];
                                         contentsBlock: [ :each | {each icon. each name asString} ];
                                         connectSignal: 'row-has-child-toggled' to: self selector: #'childToggled:path:iter:';
diff --git a/packages/visualgst/StBrowser/GtkClassHierarchyWidget.st b/packages/visualgst/StBrowser/GtkClassHierarchyWidget.st
index 1b85188..277fd0d 100644
--- a/packages/visualgst/StBrowser/GtkClassHierarchyWidget.st
+++ b/packages/visualgst/StBrowser/GtkClassHierarchyWidget.st
@@ -1,3 +1,38 @@
+"======================================================================
+|
+| GtkClassHierarchyWidget 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.
+|
+======================================================================"
+
 GtkConcreteWidget subclass: GtkClassHierarchyWidget [
     | root dic classesTree model classOrMeta |
 
@@ -41,7 +76,7 @@ GtkConcreteWidget subclass: GtkClassHierarchyWidget [
 	dic := Dictionary new.
 	self buildSuperclasses.
 	model 
-	    item: #root;
+	    item: (dic at: #root);
 	    refresh.
 	
 	classesTree 
@@ -69,7 +104,6 @@ GtkConcreteWidget subclass: GtkClassHierarchyWidget [
         classesTree := GTK.GtkTreeView createTreeWithModel: {{GtkColumnTextType title: 'Classes'}}.
         classesTree getSelection setMode: GTK.Gtk gtkSelectionBrowse.
         (model := GtkTreeModel on: classesTree getModel)
-                                        item: #root;
                                         childrenBlock: [ :each |
 					    dic at: each ifAbsent: [ | col |
                                                         col := SortedCollection sortBlock: [ :a :b | a asClass name <= b asClass name ].
-- 
1.8.1.2

>From 774a73aaeff63bb9b22d94355a4c9de4b571770d Mon Sep 17 00:00:00 2001
From: Gwenael Casaccio <[email protected]>
Date: Fri, 31 May 2013 09:16:45 +0200
Subject: [PATCH 2/2] Forget package.xml

---
 packages/visualgst/package.xml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/packages/visualgst/package.xml b/packages/visualgst/package.xml
index 4267d1d..0acf9d1 100644
--- a/packages/visualgst/package.xml
+++ b/packages/visualgst/package.xml
@@ -155,7 +155,6 @@
   <filein>Menus/WorkspaceVariableMenus.st</filein>
   <filein>Menus/SimpleWorkspaceMenus.st</filein>
   <filein>Menus/WorkspaceMenus.st</filein>
-  <filein>FakeNamespace.st</filein>
   <filein>Category/ClassCategory.st</filein>
   <filein>Category/AbstractNamespace.st</filein>
   <filein>Category/Class.st</filein>
@@ -381,7 +380,6 @@
   <file>Menus/WorkspaceVariableMenus.st</file>
   <file>Menus/SimpleWorkspaceMenus.st</file>
   <file>Menus/WorkspaceMenus.st</file>
-  <file>FakeNamespace.st</file>
   <file>Category/ClassCategory.st</file>
   <file>Category/AbstractNamespace.st</file>
   <file>Category/Class.st</file>
-- 
1.8.1.2

_______________________________________________
help-smalltalk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to