Clone.bjs
[gitlive] / Clone.vala
1 static Clone  _Clone;
2
3 public class Clone : Object
4 {
5     public Gtk.Popover el;
6     private Clone  _this;
7
8     public static Clone singleton()
9     {
10         if (_Clone == null) {
11             _Clone= new Clone();
12         }
13         return _Clone;
14     }
15
16         // my vars (def)
17     public GitRepo repo;
18
19     // ctor
20     public Clone()
21     {
22         _this = this;
23         this.el = new Gtk.Popover( null );
24
25         // my vars (dec)
26
27         // set gobject values
28         this.el.border_width = 0;
29         this.el.modal = true;
30         this.el.position = Gtk.PositionType.RIGHT;
31         var child_0 = new Xcls_Box2( _this );
32         child_0.ref();
33         this.el.add (  child_0.el  );
34     }
35
36     // user defined functions
37     public void show (Gtk.Widget btn, Gdk.Rectangle rect, GitRepo repo) {
38         _this.repo = repo;
39         // get the active project.
40          var lm = Gtk.SourceLanguageManager.get_default();
41                     
42     //    ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(
43       //      lm.get_language("html")
44      //   );
45       
46         //print (project.fn);
47         //project.runhtml = project.runhtml || '';
48         _this.diff_view.el.get_buffer().set_text(repo.git_diff);
49         _this.status_view.el.get_buffer().set_text(repo.git_status);
50            
51                 //console.log('show all');
52         this.el.set_modal(true);
53         this.el.set_relative_to(btn);
54         this.el.set_pointing_to(rect);
55       
56         //this.el.set_position(Gtk.PositionType.RIGHT);
57     
58         // window + header?
59          GLib.debug("SHOWALL - POPIP\n");
60         this.el.show_all();
61         //this.el.set_size_request(800,500);
62     //  this.diff_view.el.grab_focus();
63         
64         //this.el.show_all();
65     }
66     public class Xcls_Box2 : Object
67     {
68         public Gtk.Box el;
69         private Clone  _this;
70
71
72             // my vars (def)
73
74         // ctor
75         public Xcls_Box2(Clone _owner )
76         {
77             _this = _owner;
78             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
79
80             // my vars (dec)
81
82             // set gobject values
83             this.el.homogeneous = false;
84             this.el.border_width = 5;
85             var child_0 = new Xcls_Box3( _this );
86             child_0.ref();
87             this.el.pack_end (  child_0.el , false,false,0 );
88         }
89
90         // user defined functions
91     }
92     public class Xcls_Box3 : Object
93     {
94         public Gtk.Box el;
95         private Clone  _this;
96
97
98             // my vars (def)
99
100         // ctor
101         public Xcls_Box3(Clone _owner )
102         {
103             _this = _owner;
104             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
105
106             // my vars (dec)
107
108             // set gobject values
109             this.el.homogeneous = true;
110             this.el.expand = false;
111             this.el.vexpand = false;
112             var child_0 = new Xcls_Button4( _this );
113             child_0.ref();
114             this.el.add (  child_0.el  );
115             var child_1 = new Xcls_Button5( _this );
116             child_1.ref();
117             this.el.add (  child_1.el  );
118             var child_2 = new Xcls_Button6( _this );
119             child_2.ref();
120             this.el.add (  child_2.el  );
121             var child_3 = new Xcls_Button7( _this );
122             child_3.ref();
123             this.el.add (  child_3.el  );
124         }
125
126         // user defined functions
127     }
128     public class Xcls_Button4 : Object
129     {
130         public Gtk.Button el;
131         private Clone  _this;
132
133
134             // my vars (def)
135
136         // ctor
137         public Xcls_Button4(Clone _owner )
138         {
139             _this = _owner;
140             this.el = new Gtk.Button();
141
142             // my vars (dec)
143
144             // set gobject values
145             this.el.label = "Stash Changes";
146
147             //listeners
148             this.el.button_press_event.connect( () => {
149               
150                
151                GitMonitor.gitmonitor.stop();
152                _this.repo.git({ "stash" , "--all" });
153                _this.repo.loadStatus();
154                GitMonitor.gitmonitor.start();
155                 _this.diff_view.el.get_buffer().set_text(_this.repo.git_diff);
156                 _this.status_view.el.get_buffer().set_text(_this.repo.git_status);
157                 Clones.singleton().reposStore.load();
158               
159                _this.el.hide();
160                 return false;
161             });
162         }
163
164         // user defined functions
165     }
166
167     public class Xcls_Button5 : Object
168     {
169         public Gtk.Button el;
170         private Clone  _this;
171
172
173             // my vars (def)
174
175         // ctor
176         public Xcls_Button5(Clone _owner )
177         {
178             _this = _owner;
179             this.el = new Gtk.Button();
180
181             // my vars (dec)
182
183             // set gobject values
184             this.el.label = "Commit Changes";
185
186             //listeners
187             this.el.button_press_event.connect( () => {
188                _this.repo.git({ "commit" , "-a" ,"-m", "Uncommited changes synced" });
189                _this.repo.push();
190                _this.repo.loadStatus();
191                
192                 _this.diff_view.el.get_buffer().set_text(_this.repo.git_diff);
193                 _this.status_view.el.get_buffer().set_text(_this.repo.git_status);
194                 
195                _this.el.hide();
196                Clones.singleton().reposStore.load();
197                
198                 return false;
199             });
200         }
201
202         // user defined functions
203     }
204
205     public class Xcls_Button6 : Object
206     {
207         public Gtk.Button el;
208         private Clone  _this;
209
210
211             // my vars (def)
212
213         // ctor
214         public Xcls_Button6(Clone _owner )
215         {
216             _this = _owner;
217             this.el = new Gtk.Button();
218
219             // my vars (dec)
220
221             // set gobject values
222             this.el.label = "Create Branch";
223
224             //listeners
225             this.el.button_press_event.connect( () => {
226                var oldq = new Gee.ArrayList<GitMonitorQueue>();  
227                  
228                 NewBranch.singleton().show(_this.repo, oldq);
229             
230                 return false;
231             });
232         }
233
234         // user defined functions
235     }
236
237     public class Xcls_Button7 : Object
238     {
239         public Gtk.Button el;
240         private Clone  _this;
241
242
243             // my vars (def)
244
245         // ctor
246         public Xcls_Button7(Clone _owner )
247         {
248             _this = _owner;
249             this.el = new Gtk.Button();
250
251             // my vars (dec)
252
253             // set gobject values
254             this.el.label = "Ignore for now";
255
256             //listeners
257             this.el.button_press_event.connect( () => {
258                    _this.el.hide();
259                     return false;
260             });
261         }
262
263         // user defined functions
264     }
265
266
267
268 }