Revert "File.js"
[app.Builder.js] / DependTree / Window.js
1 Gtk = imports.gi.Gtk;
2 Gdk = imports.gi.Gdk;
3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
5 Gio = imports.gi.Gio;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
9 Vte = imports.gi.Vte;
10 GtkClutter = imports.gi.GtkClutter;
11 Gdl = imports.gi.Gdl;
12 console = imports.console;
13 XObject = imports.XObject.XObject;
14 Window=new XObject({
15     xtype: Gtk.Window,
16     listeners : {
17         show : function (self) {
18             print("SHOW");
19             var BuildLists = imports['BuildLists.js'].BuildLists;
20             this.data = new BuildLists();
21             print(JSON.stringify(this.data.allmethods, null,4));
22             
23             var ls = this.get('method-list-store');
24             this.data.allmethods.forEach(function(v) {
25                 ls.append( [ v , true, true ]);
26             });
27             
28             var ls = this.get('children-list-store');
29             this.data.allchildren.forEach(function(v) {
30                 ls.append( [ v , true, true ]);
31             });
32             var ls = this.get('class-list-store');
33             var i =0;
34             for (var c in this.data.methods) {
35                 i++;
36                 ls.append( [ c , true ,   true]);
37             };
38             print(JSON.stringify(this.data.methods['Gtk.AccelGroup']));
39             
40             
41             
42         }
43     },
44     default_height : 500,
45     default_width : 600,
46     id : "window",
47     init : function() {
48         XObject.prototype.init.call(this);
49         this.el.show_all();
50     },
51     items : [
52         {
53             xtype: Gtk.VBox,
54             items : [
55                 {
56                     xtype: Gtk.HBox,
57                     pack : "pack_start,false,false",
58                     items : [
59                         {
60                             xtype: Gtk.Button,
61                             label : "Reset"
62                         }
63                     ]
64                 },
65                 {
66                     xtype: Gtk.HBox,
67                     items : [
68                         {
69                             xtype: Gtk.ScrolledWindow,
70                             items : [
71                                 {
72                                     xtype: Gtk.TreeView,
73                                     listeners : {
74                                         cursor_changed : function (self) {
75                                         
76                                             var sel  = this.el.get_selection();
77                                         
78                                             
79                                             var iter = new Gtk.TreeIter();
80                                             sel.get_selected(this.model.el, iter);
81                                             
82                                             var tp = this.model.el.get_path(iter).to_string();
83                                             print(tp);
84                                             // 
85                                             var cls = this.model.getValue(tp, 0);
86                                             print(cls);
87                                             var data = this.get('/window').data;
88                                             
89                                         
90                                             // hide all the rows in the methods list.
91                                             var tp = false; 
92                                             var cstore = this.get('/window.children-list-store');
93                                             var meths = [];
94                                             while (false !== (tp = cstore.nextPath(tp))) {
95                                                 var mname = cstore.getValue(tp, 0);
96                                                 var show = typeof(data.methods[cls][mname]) == 'undefined' ? false :true;
97                                                 if (show) {
98                                                     meths.push.apply(meths, data.methods[cls][mname]);
99                                                 }
100                                                 cstore.setValue(tp, 2, show); // hide..  
101                                         
102                                                 
103                                             }    
104                                             print(JSON.stringify(meths));
105                                         
106                                             tp = false; 
107                                             var mstore = this.get('/window.method-list-store');
108                                             while (false !== (tp = mstore.nextPath(tp))) {
109                                                 var mname = mstore.getValue(tp, 0);
110                                                 var show = meths.indexOf(mname) > -1  ? true :false;
111                                             
112                                                 mstore.setValue(tp, 2, show); // hide..  
113                                             }
114                                             
115                                             
116                                             
117                                         }
118                                     },
119                                     items : [
120                                         {
121                                             xtype: Gtk.TreeModelFilter,
122                                             init : function() {
123                                                 this.items[0].pack = false;
124                                                 this.items[0].init();
125                                                 this.list = this.items[0];
126                                                 this.el = new Gtk.TreeModelFilter.c_new(this.items[0].el, null);
127                                                  this.el.set_visible_column(2);
128                                                 XObject.prototype.init.call(this);
129                                                 this.parent.model = this;
130                                                
131                                             },
132                                             items : [
133                                                 {
134                                                     xtype: Gtk.ListStore,
135                                                     id : "class-list-store",
136                                                     pack : false,
137                                                     init : function() 
138                                                             {
139                                                                 XObject.prototype.init.call(this);
140                                                                 this.el.set_column_types ( 6, [
141                                                                     GObject.TYPE_STRING, 
142                                                                     GObject.TYPE_BOOLEAN, 
143                                                                     GObject.TYPE_BOOLEAN, 
144                                                                     GObject.TYPE_STRING, 
145                                                                     GObject.TYPE_STRING, 
146                                                                     GObject.TYPE_STRING 
147                                                                 ] );
148                                                                 
149                                                             }
150                                                 }
151                                             ]
152                                         },
153                                         {
154                                             xtype: Gtk.TreeViewColumn,
155                                             title : "Class",
156                                             expand : true,
157                                             items : [
158                                                 {
159                                                     xtype: Gtk.CellRendererText
160                                                 }
161                                             ]
162                                         },
163                                         {
164                                             xtype: Gtk.TreeViewColumn,
165                                             title : "Active",
166                                             items : [
167                                                 {
168                                                     xtype: Gtk.CellRendererToggle,
169                                                     listeners : {
170                                                         toggled : function (self, path) {
171                                                             print("TOGGLE");
172                                                             // this.list
173                                                         
174                                                         
175                                                              
176                                                             var old = this.list.getValue(path, 1);
177                                                            // print(JSON.stringify(old));
178                                                             this.list.setValue(path, 1, old ? false : true)
179                                                             
180                                                             
181                                                             
182                                                             
183                                                         }
184                                                     },
185                                                     activatable : true
186                                                 }
187                                             ]
188                                         }
189                                     ]
190                                 }
191                             ]
192                         },
193                         {
194                             xtype: Gtk.ScrolledWindow,
195                             items : [
196                                 {
197                                     xtype: Gtk.TreeView,
198                                     items : [
199                                         {
200                                             xtype: Gtk.TreeModelFilter,
201                                             init : function() {
202                                                 this.items[0].pack = false;
203                                                 this.items[0].init();
204                                                 this.list = this.items[0];
205                                                 this.el = new Gtk.TreeModelFilter.c_new(this.items[0].el, null);
206                                                  this.el.set_visible_column(2);
207                                                 XObject.prototype.init.call(this);
208                                                
209                                             },
210                                             items : [
211                                                 {
212                                                     xtype: Gtk.ListStore,
213                                                     id : "method-list-store",
214                                                     init : function() 
215                                                             {
216                                                                 XObject.prototype.init.call(this);
217                                                                 this.el.set_column_types ( 6, [
218                                                                     GObject.TYPE_STRING, 
219                                                                     GObject.TYPE_BOOLEAN, 
220                                                                     GObject.TYPE_BOOLEAN, 
221                                                                     GObject.TYPE_STRING, 
222                                                                     GObject.TYPE_STRING, 
223                                                                     GObject.TYPE_STRING 
224                                                                 ] );
225                                                                 
226                                                             }
227                                                 }
228                                             ]
229                                         },
230                                         {
231                                             xtype: Gtk.TreeViewColumn,
232                                             title : "Methods",
233                                             expand : true,
234                                             items : [
235                                                 {
236                                                     xtype: Gtk.CellRendererText
237                                                 }
238                                             ]
239                                         },
240                                         {
241                                             xtype: Gtk.TreeViewColumn,
242                                             title : "Active",
243                                             items : [
244                                                 {
245                                                     xtype: Gtk.CellRendererToggle,
246                                                     listeners : {
247                                                         toggled : function (self, path) {
248                                                             print("TOGGLE");
249                                                             // this.list
250                                                         
251                                                         
252                                                              
253                                                             var old = this.list.getValue(path, 1);
254                                                            // print(JSON.stringify(old));
255                                                             this.list.setValue(path, 1, old ? false : true)
256                                                             
257                                                             
258                                                             
259                                                             
260                                                         }
261                                                     },
262                                                     activatable : true
263                                                 }
264                                             ]
265                                         }
266                                     ]
267                                 }
268                             ]
269                         },
270                         {
271                             xtype: Gtk.ScrolledWindow,
272                             items : [
273                                 {
274                                     xtype: Gtk.TreeView,
275                                     items : [
276                                         {
277                                             xtype: Gtk.TreeModelFilter,
278                                             init : function() {
279                                                 this.items[0].pack = false;
280                                                 this.items[0].init();
281                                                 this.list = this.items[0];
282                                                 this.el = new Gtk.TreeModelFilter.c_new(this.items[0].el, null);
283                                                  this.el.set_visible_column(2);
284                                                 XObject.prototype.init.call(this);
285                                                
286                                             },
287                                             items : [
288                                                 {
289                                                     xtype: Gtk.ListStore,
290                                                     id : "children-list-store",
291                                                     pack : false,
292                                                     init : function() 
293                                                             {
294                                                                 XObject.prototype.init.call(this);
295                                                                 this.el.set_column_types ( 6, [
296                                                                     GObject.TYPE_STRING, 
297                                                                     GObject.TYPE_BOOLEAN, 
298                                                                     GObject.TYPE_BOOLEAN, 
299                                                                     GObject.TYPE_STRING, 
300                                                                     GObject.TYPE_STRING, 
301                                                                     GObject.TYPE_STRING 
302                                                                 ] );
303                                                                 
304                                                             }
305                                                 }
306                                             ]
307                                         },
308                                         {
309                                             xtype: Gtk.TreeViewColumn,
310                                             title : "Child classes",
311                                             expand : true,
312                                             items : [
313                                                 {
314                                                     xtype: Gtk.CellRendererText
315                                                 }
316                                             ]
317                                         },
318                                         {
319                                             xtype: Gtk.TreeViewColumn,
320                                             title : "Active",
321                                             items : [
322                                                 {
323                                                     xtype: Gtk.CellRendererToggle,
324                                                     listeners : {
325                                                         toggled : function (self, path) {
326                                                             print("TOGGLE");
327                                                             // this.list
328                                                         
329                                                         
330                                                              
331                                                             var old = this.list.getValue(path, 1);
332                                                            // print(JSON.stringify(old));
333                                                             this.list.setValue(path, 1, old ? false : true)
334                                                             
335                                                             
336                                                             
337                                                             
338                                                         }
339                                                     },
340                                                     activatable : true
341                                                 }
342                                             ]
343                                         }
344                                     ]
345                                 }
346                             ]
347                         }
348                     ]
349                 }
350             ]
351         }
352     ]
353 });
354 Window.init();
355 XObject.cache['/Window'] = Window;