5 "# Gdk.Pixbuf missing_thumb_pixbuf" : "",
6 "# Project.Project selectedProject" : "",
7 "# Xcls_MainWindow win" : "",
8 "# bool is_loaded" : false,
9 "# bool is_loading" : false,
10 "# bool new_window" : false,
12 "Gtk.PositionType position" : "Gtk.PositionType.TOP",
13 "bool active" : false,
14 "bool hexpand" : false,
16 "id" : "PopoverFiles",
17 "int height_request" : 800,
18 "int width_request" : 900,
23 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
28 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
33 "Gtk.ToolbarStyle toolbar_style" : "Gtk.ToolbarStyle.BOTH",
42 " // create a new file in project..",
43 " //Xcls_DialogNewComponent.singleton().show(",
44 " var pe = EditProject.singleton();",
45 " //pe.el.set_transient_for(_this.el);",
46 " pe.el.set_modal(true); ",
48 " var p = pe.show();",
55 " _this.win.windowstate.left_projects.is_loaded = false; ",
56 " _this.win.windowstate.left_projects.load();",
57 " _this.win.windowstate.left_projects.selectProject(p);",
64 "string icon_name" : "folder-new",
65 "string label" : "New Project",
66 "xtype" : "ToolButton"
74 " // should disable the button really.",
75 " if (_this.selectedProject == null) {",
78 "\t_this.win.windowstate.projectPopoverShow(this.el, _this.selectedProject);",
82 "string icon_name" : "emblem-system",
83 "string label" : "Project Properties",
84 "xtype" : "ToolButton"
93 " var cd = DialogConfirm.singleton();",
94 " cd.el.set_transient_for(_this.el);",
95 " cd.el.set_modal(true);",
97 " var project = _this.windowstate.left_projects.getSelectedProject();",
98 " if (project == null) {",
99 " print(\"SKIP - no project\\n\");",
104 " if (Gtk.ResponseType.YES != cd.show(\"Confirm\", ",
105 " \"Are you sure you want to delete project %s\".printf(project.name))) {",
111 " Project.Project.remove(project);",
112 " _this.project = null;",
114 " _this.windowstate.left_projects.is_loaded = false;",
115 " _this.windowstate.left_projects.load();",
116 " _this.windowstate.clutterfiles.clearFiles();",
122 "string icon_name" : "user-trash",
123 "string label" : "Delete Project",
124 "xtype" : "ToolButton"
132 " // create a new file in project..",
133 " print(\"add file selected\\n\");",
135 " if (_this.selectedProject == null) {",
139 " var f = JsRender.JsRender.factory(_this.selectedProject.xtype, _this.selectedProject, \"\");",
140 " _this.win.windowstate.file_details.show( f, this.el, _this.new_window );",
146 "string icon_name" : "document-new",
147 "string label" : "New File",
148 "xtype" : "ToolButton"
159 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
160 "bool homogeneous" : false,
163 "$ shadow_type" : "Gtk.ShadowType.IN",
166 " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
170 "bool expand" : true,
171 "int width_request" : 150,
174 "$ enable_tree_lines" : true,
175 "$ headers_visible" : true,
178 " var description = new Pango.FontDescription();",
179 " description.set_size(9000);",
180 " this.el.override_font(description); ",
182 " var selection = this.el.get_selection();",
183 " selection.set_mode( Gtk.SelectionMode.SINGLE);",
194 "$ columns" : "typeof(string), typeof(Object)",
198 " this.el.set_sort_func(0, (mod,a,b) => {",
199 " GLib.Value ga, gb;",
200 " mod.get_value(a,0, out ga);",
201 " mod.get_value(b,0, out gb);",
203 " if ((string)ga == (string)gb) {",
206 " return (string)ga > (string)gb ? 1 : -1;",
213 "* pack" : "set_model",
216 "xtype" : "ListStore"
222 " this.el.add_attribute(_this.namecol.el , \"markup\", 0 );",
225 "* pack" : "append_column",
229 "* pack" : "pack_start,true",
231 "xtype" : "CellRendererText"
234 "utf8 title" : "Projects",
235 "xtype" : "TreeViewColumn"
241 " if (_this.is_loading) {",
245 " Gtk.TreeIter iter;",
246 " Gtk.TreeModel mod;",
248 " var s = this.el.get_selection();",
249 " if (!s.get_selected(out mod, out iter)) {",
255 " mod.get_value(iter, 1 , out gval);",
256 " var project = (Project.Project)gval.get_object();",
258 " _this.onProjectSelected(project);",
266 "xtype" : "ScrolledWindow"
270 "* init" : " this.el.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);",
272 "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN",
273 "bool expand" : true,
275 "int width_request" : 600,
286 "bool has_tooltip" : true,
288 "int item_width" : 100,
289 "int markup_column" : 1,
290 "int pixbuf_column" : 3,
293 "$ columns" : "typeof(Object), typeof(string), typeof(string), typeof(Gdk.Pixbuf), typeof(Gdk.Pixbuf) ",
298 "xtype" : "ListStore"
305 " _this.win.windowstate.project = _this.selectedProject;",
309 " \tGtk.TreeIter iter;",
312 "\tthis.el.model.get_iter(out iter, path);",
316 " this.el.model.get_value(iter, 0 , out gval);",
317 " var file = (JsRender.JsRender)gval;",
320 " _this.win.windowstate.fileViewOpen(file, _this.new_window);",
327 "(x, y, keyboard_tooltip, tooltip) => {",
329 "\tGtk.TreePath path;",
330 "\tGtk.CellRenderer cell;",
331 "\tvar s = _this.iconview.el.get_item_at_pos(x,y + (int) _this.iconscroll.el.vadjustment.value, out path, out cell);",
334 " // GLib.debug(\"Tooltip? %d,%d scroll: %d\",x,y, (int)_this.iconscroll.el.vadjustment.value);",
337 "\tif (path == null) {",
338 "\t\t// GLib.debug(\"Tooltip? - no path\");",
342 "\tGtk.TreeIter iter;",
343 "\t_this.iconmodel.el.get_iter(out iter, path);",
345 "\t_this.iconmodel.el.get_value(iter, 4, out val);",
347 "\ttooltip.set_icon((Gdk.Pixbuf) val.get_object());",
348 "\t _this.iconview.el.set_tooltip_item(tooltip, path);",
357 "xtype" : "ScrolledWindow"
361 "* init" : " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
363 "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN",
364 "bool expand" : true,
365 "bool visible" : false,
366 "id" : "file_container",
367 "int width_request" : 100,
370 "$ enable_tree_lines" : true,
371 "$ headers_visible" : true,
374 " var description = new Pango.FontDescription();",
375 " description.set_size(9000);",
376 " this.el.override_font(description); ",
378 " var selection = this.el.get_selection();",
379 " selection.set_mode( Gtk.SelectionMode.SINGLE);",
387 "bool activate_on_single_click" : false,
388 "bool expand" : true,
392 "$ columns" : "typeof(string), typeof(string)",
396 " this.el.set_sort_func(0, (mod,a,b) => {",
397 " GLib.Value ga, gb;",
398 " mod.get_value(a,0, out ga);",
399 " mod.get_value(b,0, out gb);",
401 " if ((string)ga == (string)gb) {",
404 " return (string)ga > (string)gb ? 1 : -1;",
411 "* pack" : "set_model",
414 "xtype" : "TreeStore"
420 " this.el.add_attribute(_this.filenamecol.el , \"markup\", 0 );",
423 "* pack" : "append_column",
427 "* pack" : "pack_start,true",
428 "id" : "filenamecol",
429 "xtype" : "CellRendererText"
432 "utf8 title" : "File",
433 "xtype" : "TreeViewColumn"
440 " if (_this.is_loading) {",
444 " Gtk.TreeIter iter;",
445 " Gtk.TreeModel mod;",
447 " var s = this.el.get_selection();",
448 " if (!s.get_selected(out mod, out iter)) {",
454 " mod.get_value(iter, 1 , out gval);",
455 " var project = (Project.Project)gval.get_object();",
457 " _this.project_selected(project);",
464 "\tGtk.TreeIter iter;",
467 "\tthis.el.model.get_iter(out iter, path);",
471 " this.el.model.get_value(iter, 1 , out gval);",
472 " var fn = (string)gval;",
473 " if (fn.length < 1) {",
476 " _this.win.windowstate.project = _this.selectedProject;",
479 " var f = JsRender.JsRender.factory(\"PlainFile\", _this.selectedProject, fn);",
482 " _this.win.windowstate.fileViewOpen(f, _this.new_window);",
491 "xtype" : "ScrolledWindow"
505 "\t//if (project != null) {",
506 "//\t\tthis.selectProject(project);",
508 " \tif (_this.win.windowstate.project == null) {",
509 " \t\tthis.el.show();",
519 " if (_this.is_loaded) {",
522 " _this.is_loading = true;",
524 " _this.is_loaded = true;",
526 " Project.Project.loadAll();",
527 " var projects = Project.Project.allProjectsByName();",
529 " Gtk.TreeIter iter;",
530 " var m = this.model.el;",
533 " for (var i = 0; i < projects.size; i++) {",
534 " m.append(out iter);",
535 " m.set(iter, 0,projects.get(i).name );",
537 " var o = GLib.Value(typeof(Object));",
538 " o.set_object((Object)projects.get(i));",
540 " m.set_value(iter, 1, o);",
543 " m.set_sort_column_id(0, Gtk.SortType.ASCENDING);",
544 " _this.is_loading = false; ",
548 "| void onProjectSelected" : [
549 "(Project.Project project) ",
551 "\tthis.selectedProject = project;",
552 "\tproject.scanDirs();",
553 "\t//this.clutterfiles.loadProject(proj);",
560 " //this.project_title_name.el.text = pr.name;",
561 " //this.project_title_path.el.text = pr.firstPath();",
563 " // file items contains a reference until we reload ...",
564 " \t Gdk.Pixbuf pixbuf = null;",
565 " \tGdk.Pixbuf bigpixbuf = null;",
566 "\t Gtk.TreeIter iter;",
567 " var m = this.iconmodel.el;",
570 " var fiter = project.sortedFiles().list_iterator();",
571 " while (fiter.next()) {",
572 " m.append(out iter);",
573 " var file = fiter.get();",
574 " m.set(iter, 0,file ); // zero contains the file reference",
575 " m.set(iter, 1,file.nickType() + \"\\n\" + file.nickName()); // marked up title?",
576 " m.set(iter, 2,file.nickType() ); // file type?",
579 " var fname = file.getIconFileName(false);",
581 "\t\t if (FileUtils.test(fname, FileTest.EXISTS)) {",
582 "\t\t var npixbuf = new Gdk.Pixbuf.from_file(fname);",
583 "\t\t pixbuf = npixbuf.scale_simple(92, (int) (npixbuf.height * 92.0 /npixbuf.width * 1.0 )",
584 "\t\t\t\t , Gdk.InterpType.NEAREST) ;",
585 "\t\t\t\tbigpixbuf = npixbuf.scale_simple(368, (int) (npixbuf.height * 368.0 /npixbuf.width * 1.0 )",
586 "\t\t\t\t , Gdk.InterpType.NEAREST) ;",
589 "\t\t} catch (Error e) {",
593 " if (pixbuf == null) {",
596 "\t\t if (_this.missing_thumb_pixbuf == null) {",
597 "\t\t var icon_theme = Gtk.IconTheme.get_default ();",
598 "\t\t _this.missing_thumb_pixbuf = icon_theme.load_icon (\"package-x-generic\", 92, 0);",
599 "\t\t _this.missing_thumb_pixbuf.ref();",
601 "\t\t pixbuf = _this.missing_thumb_pixbuf;",
602 "\t\t bigpixbuf = _this.missing_thumb_pixbuf;",
604 "\t\t } catch (Error e) {",
611 " m.set(iter, 3,pixbuf);",
612 " m.set(iter, 4,bigpixbuf);",
614 " // this needs to add to the iconview?",
616 " //var a = new Xcls_fileitem(this,fiter.get());",
617 " //this.fileitems.add(a);",
619 " //this.filelayout.el.add_child(a.el);",
623 " this.filemodel.el.clear();",
627 " if (!(project is Project.Gtk)) {",
628 " print (\"not gtk... skipping files\");",
629 " this.file_container.el.hide();",
632 " this.file_container.el.show();",
633 " var gpr = (Project.Gtk)project;",
634 " var def = gpr.compilegroups.get(\"_default_\");",
635 " // not sure why the above is returng null!??",
636 " if (def == null) {",
637 " \t\tdef = new Project.GtkValaSettings(\"_default_\"); ",
638 " \t\tgpr.compilegroups.set(\"_default_\", def);",
640 "\t var items = def.sources;",
642 "\t Gtk.TreeIter citer; // folder iter",
643 "\t Gtk.TreeIter fxiter; // file iter",
644 "\tfor(var i =0 ; i < items.size; i++) {",
645 "\t print (\"cheking folder %s\\n\", items.get(i));",
646 "\t var files = gpr.filesForOpen(items.get(i));",
647 "\t if (files.size < 1) {",
650 "\t\t this.filemodel.el.append(out citer,null);",
651 "\t\t this.filemodel.el.set(citer, 0, GLib.Path.get_basename(items.get(i)));",
652 "\t\t this.filemodel.el.set(citer, 1, null); // parent (empty as it's a folder)",
655 "\t // add the directory... items.get(i);",
656 "\t //var x = new Xcls_folderitem(this,items.get(i));",
657 "\t //this.fileitems.add(x);",
658 "\t //this.filelayout.el.add_child(x.el);",
661 "\t for(var j =0 ; j < files.size; j++) {",
663 "\t\t this.filemodel.el.insert(out fxiter,citer, -1);",
664 "\t \tthis.filemodel.el.set(fxiter, 0, GLib.Path.get_basename(files.get(j))); // filename",
665 "\t\t \tthis.filemodel.el.set(fxiter, 1, files.get(j)); // Folder?",
671 "\t //this.el.set_value(citer, 1, items.get(i) );",
673 " _this.fileview.el.expand_all();",
679 "| void selectProject" : [
680 "(Project.Project project) {",
682 " var sel = _this.view.el.get_selection();",
684 " sel.unselect_all();",
686 " var found = false;",
687 " _this.model.el.foreach((mod, path, iter) => {",
690 " mod.get_value(iter, 1, out val);",
691 " if ( ( (Project.Project)val.get_object()).fn != project.fn) {",
692 " print(\"SKIP %s != %s\\n\", ((Project.Project)val.get_object()).name , project.name);",
693 " return false;//continue",
695 " sel.select_iter(iter);",
696 "\t\tthis.selectedProject = project;",
697 " this.onProjectSelected(project);",
704 "\t print(\"tried to select %s, could not find it\", project.name);",
709 "| void setMainWindow" : [
710 "(Xcls_MainWindow win) {",
717 "(Gtk.Widget on_el, Project.Project? project, bool new_window) {",
718 "\t//this.editor.show( file, node, ptype, key);",
720 "\tthis.new_window = new_window;",
723 "\tthis.el.show_all(); // show first - so we can hide stuff later.\t",
724 "\tif (project != null) {",
726 "\t\tthis.selectProject(project);",
731 " this.win.el.get_size(out w, out h);",
733 " // left tree = 250, editor area = 500?",
736 "\t// max hieght ...",
738 "\tvar ww = on_el.get_allocated_width();",
740 "\t// width = should be max = w-ww , or 600 at best..?",
742 " this.el.set_size_request( w, h); // same as parent...",
745 "\tthis.el.set_modal(true);",
746 "\tthis.el.set_relative_to(on_el);",
756 "name" : "PopoverFiles",
758 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverFiles.bjs",