gitlive.js
[gitlive] / FixBug.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 FixBug=new XObject({
15     xtype: Gtk.Dialog,
16     listeners : {
17         destroy_event : function (self, event) {
18              this.el.hide();
19                         return false;
20         },
21         response : function (self, id) {
22           // hide
23          if (id < 1) {
24                 this.el.hide();
25                 return;
26             }
27             if (!this.get('bug').getValue().length) {
28                 print("ERROR");
29                     return;
30                 }
31          
32                 this.el.hide();
33                 
34                 var val = this.get('bug').getValue();
35                 Seed.print(val);
36         }
37     },
38     border_width : 3,
39     default_height : 400,
40     default_width : 600,
41     title : "Project Properties",
42     deletable : true,
43     modal : true,
44     show : function(c) {
45         
46         if (!this.el) {
47             this.init();
48         }
49         var _this = this;
50         /*[ 'xtype'  ].forEach(function(k) {
51             _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);
52         });
53         // shouild set path..
54         */
55         this.el.show_all();
56         //this.success = c.success;
57     },
58     items : [
59         {
60             xtype: Gtk.VBox,
61             pack : function(p,e) {
62                         p.el.get_content_area().add(e.el)
63                     },
64             items : [
65                 {
66                     xtype: Gtk.HBox,
67                     pack : "pack_start,false,true,3",
68                     items : [
69                         {
70                             xtype: Gtk.Label,
71                             label : "Select Active Bug:",
72                             pack : "pack_start,false,true,3"
73                         },
74                         {
75                             xtype: Gtk.ComboBox,
76                             listeners : {
77                                 changed : function (self) {
78                                     var d = this.getValue();
79                                     this.get('/view').load(d.description);
80                                 }
81                             },
82                             id : "bug",
83                             pack : "pack_end,true,true,3",
84                             getValue : function() {
85                                  var ix = this.el.get_active();
86                                 if (ix < 0 ) {
87                                     return '';
88                                 }
89                                 return this.get('model').data[ix];
90                             },
91                             init : function() {
92                                 XObject.prototype.init.call(this);
93                               this.el.add_attribute(this.items[0].el , 'markup', 1 );  
94                             },
95                             setValue : function(v)
96                                             {
97                                                 var el = this.el;
98                                                 el.set_active(-1);
99                                                 this.get('model').data.forEach(function(n, ix) {
100                                                     if (v == n.xtype) {
101                                                         el.set_active(ix);
102                                                         return false;
103                                                     }
104                                                 });
105                                             },
106                             items : [
107                                 {
108                                     xtype: Gtk.CellRendererText,
109                                     pack : "pack_start"
110                                 },
111                                 {
112                                     xtype: Gtk.ListStore,
113                                     id : "model",
114                                     pack : "set_model",
115                                     init : function() {
116                                         XObject.prototype.init.call(this);
117                                     
118                                             this.el.set_column_types ( 2, [
119                                                 GObject.TYPE_STRING,  // real key
120                                                 GObject.TYPE_STRING // real type
121                                                 
122                                                 
123                                             ] );
124                                             var Tickets = imports.Tickets.Tickets;
125                                             
126                                             this.data = Tickets.fetchBugs("http://www.roojs.com/mtrack/index.php/Gitlive/web.hex");
127                                     /*        this.data = [
128                                                 { xtype: 'Roo', desc : "Roo Project" },
129                                                 { xtype: 'Gtk', desc : "Gtk Project" },    
130                                                 //{ xtype: 'JS', desc : "Javascript Class" }
131                                             ]
132                                       */      
133                                             this.loadData(this.data);
134                                                                     
135                                     },
136                                     loadData : function (data) {
137                                                                                 
138                                                 var iter = new Gtk.TreeIter();
139                                                 var el = this.el;
140                                                 data.forEach(function(p) {
141                                                     
142                                                     el.append(iter);
143                                                     
144                                                      
145                                                     el.set_value(iter, 0, p.id);
146                                                     el.set_value(iter, 1, '#' + p.id + ' - ' + p.summary );
147                                                     
148                                                 });
149                                                   
150                                                                          
151                                     }
152                                 }
153                             ]
154                         }
155                     ]
156                 },
157                 {
158                     xtype: Gtk.ScrolledWindow,
159                     pack : "add",
160                     id : "RightEditor",
161                     items : [
162                         {
163                             xtype: Gtk.TextView,
164                             editable : false,
165                             id : "view",
166                             indent_width : 4,
167                             pack : "add",
168                             auto_indent : true,
169                             init : function() {
170                                 XObject.prototype.init.call(this);
171                                  var description = Pango.Font.description_from_string("monospace")
172                                 description.set_size(8000);
173                                 this.el.modify_font(description);
174                             
175                             },
176                             load : function(str) {
177                             
178                             // show the help page for the active node..
179                              
180                             
181                             
182                              
183                                 this.el.get_buffer().set_text(str, str.length);
184                              
185                                 
186                                  var buf = this.el.get_buffer();
187                                  
188                                  
189                                 
190                             },
191                             show_line_numbers : true,
192                             items : [
193                                 {
194                                     xtype: GtkSource.Buffer,
195                                     listeners : {
196                                         changed : function (self) {
197                                             /*
198                                             var s = new Gtk.TextIter();
199                                             var e = new Gtk.TextIter();
200                                             this.el.get_start_iter(s);
201                                             this.el.get_end_iter(e);
202                                             var str = this.el.get_text(s,e,true);
203                                             try {
204                                                 Seed.check_syntax('var e = ' + str);
205                                             } catch (e) {
206                                                 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
207                                                     red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
208                                                    }));
209                                                 //print("SYNTAX ERROR IN EDITOR");   
210                                                 //print(e);
211                                                 //console.dump(e);
212                                                 return;
213                                             }
214                                             this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
215                                                     red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
216                                                    }));
217                                             
218                                              this.get('/LeftPanel.model').changed(  str , false);
219                                              */
220                                         }
221                                     },
222                                     pack : "set_buffer"
223                                 }
224                             ]
225                         }
226                     ]
227                 }
228             ]
229         },
230         {
231             xtype: Gtk.Button,
232             pack : "add_action_widget,1",
233             label : "OK"
234         },
235         {
236             xtype: Gtk.Button,
237             pack : "add_action_widget,0",
238             label : "Cancel"
239         }
240     ]
241 });
242 FixBug.init();
243 XObject.cache['/FixBug'] = FixBug;