1 static Xcls_WindowLeftProjects _WindowLeftProjects;
3 public class Xcls_WindowLeftProjects : Object
6 private Xcls_WindowLeftProjects _this;
8 public static Xcls_WindowLeftProjects singleton()
10 if (_WindowLeftProjects == null) {
11 _WindowLeftProjects= new Xcls_WindowLeftProjects();
13 return _WindowLeftProjects;
15 public Xcls_view view;
16 public Xcls_model model;
17 public Xcls_namecol namecol;
20 public signal void project_selected (Project.Project project);
21 public bool is_loaded;
22 public bool is_loading;
23 public signal void show_new_project ();
26 public Xcls_WindowLeftProjects()
29 this.el = new Gtk.VBox( false, 0 );
32 this.is_loaded = false;
33 this.is_loading = false;
36 var child_0 = new Xcls_ScrolledWindow2( _this );
38 this.el.pack_end ( child_0.el , true,true,0 );
41 this.el.show.connect( ( ) => {
46 // user defined functions
50 if (_this.is_loaded) {
53 _this.is_loading = true;
55 _this.is_loaded = true;
57 Project.Project.loadAll();
58 var projects = Project.Project.allProjectsByName();
61 var m = this.model.el;
64 for (var i = 0; i < projects.size; i++) {
66 m.set(iter, 0,projects.get(i).name );
68 var o = new GLib.Value(typeof(Object));
69 o.set_object((Object)projects.get(i));
71 m.set_value(iter, 1, o);
74 m.set_sort_column_id(0, Gtk.SortType.ASCENDING);
75 _this.is_loading = false;
77 public Project.Project? getSelectedProject () {
81 var s = this.view.el.get_selection();
82 if (!s.get_selected(out mod, out iter)) {
88 mod.get_value(iter, 1 , out gval);
89 var project = (Project.Project)gval.get_object();
93 public void selectProject (Project.Project project) {
95 var sel = _this.view.el.get_selection();
100 _this.model.el.foreach((mod, path, iter) => {
103 mod.get_value(iter, 1, out val);
104 if ( ( (Project.Project)val.get_object()).fn != project.fn) {
105 print("SKIP %s != %s\n", ((Project.Project)val.get_object()).name , project.name);
106 return false;//continue
108 sel.select_iter(iter);
109 this.project_selected(project);
116 print("tried to select %s, could not find it", project.name);
119 public class Xcls_ScrolledWindow2 : Object
121 public Gtk.ScrolledWindow el;
122 private Xcls_WindowLeftProjects _this;
128 public Xcls_ScrolledWindow2(Xcls_WindowLeftProjects _owner )
131 this.el = new Gtk.ScrolledWindow( null, null );
135 // set gobject values
136 this.el.shadow_type = Gtk.ShadowType.IN;
137 var child_0 = new Xcls_view( _this );
139 this.el.add ( child_0.el );
143 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
146 // user defined functions
148 public class Xcls_view : Object
150 public Gtk.TreeView el;
151 private Xcls_WindowLeftProjects _this;
157 public Xcls_view(Xcls_WindowLeftProjects _owner )
161 this.el = new Gtk.TreeView();
165 // set gobject values
166 this.el.enable_tree_lines = true;
167 this.el.headers_visible = true;
168 var child_0 = new Xcls_model( _this );
170 this.el.set_model ( child_0.el );
171 var child_1 = new Xcls_TreeViewColumn5( _this );
173 this.el.append_column ( child_1.el );
177 var description = new Pango.FontDescription();
178 description.set_size(8000);
179 this.el.modify_font(description);
181 var selection = this.el.get_selection();
182 selection.set_mode( Gtk.SelectionMode.SINGLE);
185 this.el.cursor_changed.connect( () => {
186 if (_this.is_loading) {
193 var s = this.el.get_selection();
194 if (!s.get_selected(out mod, out iter)) {
200 mod.get_value(iter, 1 , out gval);
201 var project = (Project.Project)gval.get_object();
203 _this.project_selected(project);
208 // user defined functions
210 public class Xcls_model : Object
212 public Gtk.ListStore el;
213 private Xcls_WindowLeftProjects _this;
219 public Xcls_model(Xcls_WindowLeftProjects _owner )
223 this.el = new Gtk.ListStore( 2, typeof(string), typeof(Object) );
227 // set gobject values
232 this.el.set_sort_func(0, (mod,a,b) => {
234 mod.get_value(a,0, out ga);
235 mod.get_value(b,0, out gb);
237 if ((string)ga == (string)gb) {
240 return (string)ga > (string)gb ? 1 : -1;
247 // user defined functions
249 public class Xcls_TreeViewColumn5 : Object
251 public Gtk.TreeViewColumn el;
252 private Xcls_WindowLeftProjects _this;
258 public Xcls_TreeViewColumn5(Xcls_WindowLeftProjects _owner )
261 this.el = new Gtk.TreeViewColumn();
265 // set gobject values
266 this.el.title = "Projects";
267 var child_0 = new Xcls_namecol( _this );
269 this.el.pack_start ( child_0.el , true );
273 this.el.add_attribute(_this.namecol.el , "markup", 0 );
276 // user defined functions
278 public class Xcls_namecol : Object
280 public Gtk.CellRendererText el;
281 private Xcls_WindowLeftProjects _this;
287 public Xcls_namecol(Xcls_WindowLeftProjects _owner )
290 _this.namecol = this;
291 this.el = new Gtk.CellRendererText();
295 // set gobject values
298 // user defined functions