From 808c922cab7d08e67b7c02fb3dad975ab11b3c6c Mon Sep 17 00:00:00 2001
From: Gwenael Casaccio <mrgwen@gmail.com>
Date: Thu, 12 Sep 2013 17:00:25 +0200
Subject: [PATCH] Add inspector view for contexts

---
 packages/visualgst/ChangeLog                       |  6 +++
 packages/visualgst/Inspector/Extensions.st         |  8 ++-
 .../visualgst/Inspector/GtkContextInspectorView.st | 58 ++++++++++++++++++++++
 packages/visualgst/package.xml                     |  1 +
 4 files changed, 72 insertions(+), 1 deletion(-)
 create mode 100644 packages/visualgst/Inspector/GtkContextInspectorView.st

diff --git a/packages/visualgst/ChangeLog b/packages/visualgst/ChangeLog
index 1185b1d..721c90b 100644
--- a/packages/visualgst/ChangeLog
+++ b/packages/visualgst/ChangeLog
@@ -1,3 +1,9 @@
+2013-08-20  Gwenael Casaccio  <gwenael.casaccio@gmail.com>
+
+	* Inspector/Extensions.st: Add ContextPart view support.
+	* Inspector/GtkContextInspectorView.st: Dedicated view for ContextPart.
+
+
 2013-06-18  Gwenael Casaccio  <gwenael.casaccio@gmail.com>
 
 	* Inspector/Extensions.st: New.
diff --git a/packages/visualgst/Inspector/Extensions.st b/packages/visualgst/Inspector/Extensions.st
index 354fb58..cff8a8a 100644
--- a/packages/visualgst/Inspector/Extensions.st
+++ b/packages/visualgst/Inspector/Extensions.st
@@ -122,10 +122,16 @@ Float extend [
 
 ContextPart extend [
 
+    inspectorView [
+        <category: '*VisualGST'>
+
+        ^ VisualGST.GtkContextInspectorView
+    ]
+
     stackInspectorView [
         <category: '*VisualGST'>
 
-        ^ GtkStackInspectorView
+        ^ VisualGST.GtkStackInspectorView
     ]
 ]
 
diff --git a/packages/visualgst/Inspector/GtkContextInspectorView.st b/packages/visualgst/Inspector/GtkContextInspectorView.st
new file mode 100644
index 0000000..a66e923
--- /dev/null
+++ b/packages/visualgst/Inspector/GtkContextInspectorView.st
@@ -0,0 +1,58 @@
+"======================================================================
+|
+| GtkFloatInspectorView class definition
+|
+======================================================================"
+
+"======================================================================
+|
+| Copyright (c) 2013
+| Gwenael Casaccio <gwenael.casaccio@gmail.com>,
+|
+|
+| 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.
+|
+======================================================================"
+
+GtkObjectInspectorView subclass: GtkContextInspectorView [
+
+    | args temps |
+
+    do: aBlock [
+        <category: 'iterating'>
+
+        args := IdentitySet new.
+        temps := IdentitySet new.
+	super do: aBlock.
+        self object method arguments do: [ :each | aBlock value: (args add: each asString) ].
+        self object method temporaries do: [ :each | aBlock value: (temps add: each asString) ].
+    ]
+
+    selectedValue: aString [
+	<category: 'events'>
+
+        ((args includes: aString) not and: [ (temps includes: aString) not ]) ifTrue: [ ^ super selectedValue: aString ].
+        (args includes: aString) ifTrue: [ ^ (self object at: (self object method arguments indexOf: aString asSymbol)) displayString ].
+        ^ (self object at: self object numArgs + (self object method temporaries indexOf: aString asSymbol)) displayString.
+    ]
+]
+
diff --git a/packages/visualgst/package.xml b/packages/visualgst/package.xml
index 6db32bc..c6d2026 100644
--- a/packages/visualgst/package.xml
+++ b/packages/visualgst/package.xml
@@ -254,6 +254,7 @@
   <filein>Inspector/GtkSetInspectorView.st</filein>
   <filein>Inspector/GtkDictionaryInspectorView.st</filein>
   <filein>Inspector/GtkCharacterInspectorView.st</filein>
+  <filein>Inspector/GtkContextInspectorView.st</filein>
   <filein>Inspector/GtkIntegerInspectorView.st</filein>
   <filein>Inspector/GtkFloatInspectorView.st</filein>
   <filein>Implementors/GtkImageResultsWidget.st</filein>
-- 
1.8.1.2

