>From e7bf6fef452e08c59e9939138531c0efbc727147 Mon Sep 17 00:00:00 2001
From: Gwenael Casaccio
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 [
-
-
- ^ {Smalltalk}
- ]
-
- FakeNamespace class >> categories [
-
-
- ^ 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 ,
+|
+|
+| 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 [
- | 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 [
-
+
- 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 ,
+|
+|
+| 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 [
- ^ 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 ,
+|
+|
+| 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 ,
+|
+|
+| 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