config1.builder
[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     public Xcls_reposel reposel;
16     public Xcls_prcellrenderer prcellrenderer;
17     public Xcls_prmodel prmodel;
18
19         // my vars (def)
20     public GitRepo repo;
21
22     // ctor
23     public Clone()
24     {
25         _this = this;
26         this.el = new Gtk.Popover( null );
27
28         // my vars (dec)
29
30         // set gobject values
31         this.el.border_width = 0;
32         this.el.modal = true;
33         this.el.position = Gtk.PositionType.RIGHT;
34         var child_0 = new Xcls_Box2( _this );
35         child_0.ref();
36         this.el.pack_end (  child_0.el , false,false,0 );
37     }
38
39     // user defined functions
40     public void show (Gtk.Widget btn, GitRepo repo) {
41      
42                 //console.log('show all');
43         this.el.set_modal(true);
44         this.el.set_relative_to(btn);
45       
46         //this.el.set_position(Gtk.PositionType.RIGHT);
47     
48         // window + header?
49          GLib.debug("SHOWALL - POPIP\n");
50         this.el.show_all();
51     ;
52     }
53     public class Xcls_Box2 : Object
54     {
55         public Gtk.Box el;
56         private Clone  _this;
57
58
59             // my vars (def)
60
61         // ctor
62         public Xcls_Box2(Clone _owner )
63         {
64             _this = _owner;
65             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
66
67             // my vars (dec)
68
69             // set gobject values
70             this.el.expand = false;
71             this.el.vexpand = false;
72             var child_0 = new Xcls_reposel( _this );
73             child_0.ref();
74             this.el.attach_defaults (  child_0.el , 0,1,1,2 );
75             var child_1 = new Xcls_Button6( _this );
76             child_1.ref();
77             this.el.add (  child_1.el  );
78         }
79
80         // user defined functions
81     }
82     public class Xcls_reposel : Object
83     {
84         public Gtk.ComboBox el;
85         private Clone  _this;
86
87
88             // my vars (def)
89         public bool loading;
90
91         // ctor
92         public Xcls_reposel(Clone _owner )
93         {
94             _this = _owner;
95             _this.reposel = this;
96             this.el = new Gtk.ComboBox.with_entry();
97
98             // my vars (dec)
99             this.loading = false;
100
101             // set gobject values
102             this.el.hexpand = true;
103             var child_0 = new Xcls_prcellrenderer( _this );
104             child_0.ref();
105             this.el.pack_start (  child_0.el , true );
106             var child_1 = new Xcls_prmodel( _this );
107             child_1.ref();
108             this.el.set_model (  child_1.el  );
109
110             // init method
111
112             this.el.set_entry_text_column(1);
113         }
114
115         // user defined functions
116         public string selectedRepo () {
117                 Gtk.TreeIter iter;
118                 Value val1;
119          
120          
121                 this.el.get_active_iter (out iter);
122                 _this.repomodel.el.get_value (iter, 0, out val1);
123          
124         
125                 return  (string) val1;
126                 
127                 
128                 
129                 
130         }
131     }
132     public class Xcls_prcellrenderer : Object
133     {
134         public Gtk.CellRendererText el;
135         private Clone  _this;
136
137
138             // my vars (def)
139
140         // ctor
141         public Xcls_prcellrenderer(Clone _owner )
142         {
143             _this = _owner;
144             _this.prcellrenderer = this;
145             this.el = new Gtk.CellRendererText();
146
147             // my vars (dec)
148
149             // set gobject values
150         }
151
152         // user defined functions
153     }
154
155     public class Xcls_prmodel : Object
156     {
157         public Gtk.ListStore el;
158         private Clone  _this;
159
160
161             // my vars (def)
162
163         // ctor
164         public Xcls_prmodel(Clone _owner )
165         {
166             _this = _owner;
167             _this.prmodel = this;
168             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
169
170             // my vars (dec)
171
172             // set gobject values
173         }
174
175         // user defined functions
176         public void loadProjects (string id) {
177         
178             var rt = RooTicket.singleton();
179             var gr = GitRepo.singleton();
180             _this.reposel.loading = true;
181         
182             this.el.clear();                                    
183             Gtk.TreeIter iter;
184             var el = this.el;
185             
186             el.append(out iter);
187         
188             
189             el.set_value(iter, 0, "");
190             el.set_value(iter, 1, "-- select a repo --");
191          
192                 _this.reposel.el.set_active_iter(iter);
193             
194             var projects = rt.projects;
195             foreach(var newrepo in rt.repos) {
196                 var has_repo = false;
197                 foreach(var repo in gr.cache.values) {
198                         if (newrepo.name == repo.shortname) {
199                                 has_repo = true;
200                 }
201                 if (has_repo) {
202                         continue;
203                         }
204                 el.append(out iter);
205                 
206                 el.set_value(iter, 0, repo.name);
207                 el.set_value(iter, 1,  "%s : %s".printf(repo.shortname, repo.description) );
208                
209                 
210             }
211             
212             _this.reposel.loading = false;
213              //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          
214                                              
215         }
216     }
217
218
219     public class Xcls_Button6 : Object
220     {
221         public Gtk.Button el;
222         private Clone  _this;
223
224
225             // my vars (def)
226
227         // ctor
228         public Xcls_Button6(Clone _owner )
229         {
230             _this = _owner;
231             this.el = new Gtk.Button();
232
233             // my vars (dec)
234
235             // set gobject values
236             this.el.label = "Checkout";
237
238             //listeners
239             this.el.button_press_event.connect( () => {
240                    _this.el.hide();
241                     return false;
242             });
243         }
244
245         // user defined functions
246     }
247
248
249 }