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.Box( Gtk.Orientation.VERTICAL, 0 );
32 this.is_loaded = false;
33 this.is_loading = false;
36 this.el.homogeneous = false;
37 var child_0 = new Xcls_ScrolledWindow2( _this );
39 this.el.pack_end ( child_0.el , true,true,0 );
42 this.el.show.connect( ( ) => {
47 // user defined functions
51 if (_this.is_loaded) {
54 _this.is_loading = true;
56 _this.is_loaded = true;
58 Project.Project.loadAll();
59 var projects = Project.Project.allProjectsByName();
62 var m = this.model.el;
65 for (var i = 0; i < projects.size; i++) {
67 m.set(iter, 0,projects.get(i).name );
69 var o = GLib.Value(typeof(Object));
70 o.set_object((Object)projects.get(i));
72 m.set_value(iter, 1, o);
75 m.set_sort_column_id(0, Gtk.SortType.ASCENDING);
76 _this.is_loading = false;
78 public Project.Project? getSelectedProject () {
82 var s = this.view.el.get_selection();
83 if (!s.get_selected(out mod, out iter)) {
89 mod.get_value(iter, 1 , out gval);
90 var project = (Project.Project)gval.get_object();
94 public void selectProject (Project.Project project) {
96 var sel = _this.view.el.get_selection();
101 _this.model.el.foreach((mod, path, iter) => {
104 mod.get_value(iter, 1, out val);
105 if ( ( (Project.Project)val.get_object()).fn != project.fn) {
106 print("SKIP %s != %s\n", ((Project.Project)val.get_object()).name , project.name);
107 return false;//continue
109 sel.select_iter(iter);
110 this.project_selected(project);
117 print("tried to select %s, could not find it", project.name);
120 public class Xcls_ScrolledWindow2 : Object
122 public Gtk.ScrolledWindow el;
123 private Xcls_WindowLeftProjects _this;
129 public Xcls_ScrolledWindow2(Xcls_WindowLeftProjects _owner )
132 this.el = new Gtk.ScrolledWindow( null, null );
136 // set gobject values
137 this.el.shadow_type = Gtk.ShadowType.IN;
138 var child_0 = new Xcls_view( _this );
140 this.el.add ( child_0.el );
144 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
147 // user defined functions
149 public class Xcls_view : Object
151 public Gtk.TreeView el;
152 private Xcls_WindowLeftProjects _this;
158 public Xcls_view(Xcls_WindowLeftProjects _owner )
162 this.el = new Gtk.TreeView();
166 // set gobject values
167 this.el.enable_tree_lines = true;
168 this.el.headers_visible = true;
169 var child_0 = new Xcls_model( _this );
171 this.el.set_model ( child_0.el );
172 var child_1 = new Xcls_TreeViewColumn5( _this );
174 this.el.append_column ( child_1.el );
178 var description = new Pango.FontDescription();
179 description.set_size(8000);
180 this.el.override_font(description);
182 var selection = this.el.get_selection();
183 selection.set_mode( Gtk.SelectionMode.SINGLE);
186 this.el.cursor_changed.connect( () => {
187 if (_this.is_loading) {
194 var s = this.el.get_selection();
195 if (!s.get_selected(out mod, out iter)) {
201 mod.get_value(iter, 1 , out gval);
202 var project = (Project.Project)gval.get_object();
204 _this.project_selected(project);
209 // user defined functions
211 public class Xcls_model : Object
213 public Gtk.ListStore el;
214 private Xcls_WindowLeftProjects _this;
220 public Xcls_model(Xcls_WindowLeftProjects _owner )
224 this.el = new Gtk.ListStore( 2, typeof(string), typeof(Object) );
228 // set gobject values
233 this.el.set_sort_func(0, (mod,a,b) => {
235 mod.get_value(a,0, out ga);
236 mod.get_value(b,0, out gb);
238 if ((string)ga == (string)gb) {
241 return (string)ga > (string)gb ? 1 : -1;
248 // user defined functions
251 public class Xcls_TreeViewColumn5 : Object
253 public Gtk.TreeViewColumn el;
254 private Xcls_WindowLeftProjects _this;
260 public Xcls_TreeViewColumn5(Xcls_WindowLeftProjects _owner )
263 this.el = new Gtk.TreeViewColumn();
267 // set gobject values
268 this.el.title = "Projects";
269 var child_0 = new Xcls_namecol( _this );
271 this.el.pack_start ( child_0.el , true );
275 this.el.add_attribute(_this.namecol.el , "markup", 0 );
278 // user defined functions
280 public class Xcls_namecol : Object
282 public Gtk.CellRendererText el;
283 private Xcls_WindowLeftProjects _this;
289 public Xcls_namecol(Xcls_WindowLeftProjects _owner )
292 _this.namecol = this;
293 this.el = new Gtk.CellRendererText();
297 // set gobject values
300 // user defined functions