5 "# Gdk.Pixbuf missing_thumb_pixbuf" : "",
6 "# Gee.HashMap<string,Gdk.Pixbuf> image_cache" : "null",
7 "# Project.Project selectedProject" : "",
8 "# Xcls_MainWindow win" : "",
9 "# bool is_loaded" : false,
10 "# bool is_loading" : false,
11 "# bool new_window" : false,
13 "Gtk.PositionType position" : "Gtk.PositionType.TOP",
14 "bool active" : false,
15 "bool hexpand" : false,
16 "bool in_onprojectselected" : false,
18 "id" : "PopoverFiles",
19 "int height_request" : 800,
20 "int width_request" : 900,
25 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
30 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
35 "Gtk.ToolbarStyle toolbar_style" : "Gtk.ToolbarStyle.BOTH",
44 " // create a new file in project..",
45 " //Xcls_DialogNewComponent.singleton().show(",
46 " var pe = EditProject.singleton();",
47 " //pe.el.set_transient_for(_this.el);",
48 " pe.el.set_modal(true); ",
50 " var p = pe.show();",
57 " _this.win.windowstate.left_projects.is_loaded = false; ",
58 " _this.win.windowstate.left_projects.load();",
59 " _this.win.windowstate.left_projects.selectProject(p);",
66 "string icon_name" : "folder-new",
67 "string label" : "New Project",
68 "xtype" : "ToolButton"
76 " // should disable the button really.",
77 " if (_this.selectedProject == null) {",
80 "\t_this.win.windowstate.projectPopoverShow(this.el, _this.selectedProject);",
84 "string icon_name" : "emblem-system",
85 "string label" : "Project Properties",
86 "xtype" : "ToolButton"
95 " var cd = DialogConfirm.singleton();",
96 " cd.el.set_transient_for(_this.el);",
97 " cd.el.set_modal(true);",
99 " var project = _this.windowstate.left_projects.getSelectedProject();",
100 " if (project == null) {",
101 " print(\"SKIP - no project\\n\");",
106 " if (Gtk.ResponseType.YES != cd.show(\"Confirm\", ",
107 " \"Are you sure you want to delete project %s\".printf(project.name))) {",
113 " Project.Project.remove(project);",
114 " _this.project = null;",
116 " _this.windowstate.left_projects.is_loaded = false;",
117 " _this.windowstate.left_projects.load();",
118 " _this.windowstate.clutterfiles.clearFiles();",
124 "string icon_name" : "user-trash",
125 "string label" : "Delete Project",
126 "xtype" : "ToolButton"
134 " // create a new file in project..",
135 " print(\"add file selected\\n\");",
137 " if (_this.selectedProject == null) {",
141 " var f = JsRender.JsRender.factory(_this.selectedProject.xtype, _this.selectedProject, \"\");",
142 " _this.win.windowstate.file_details.show( f, this.el, _this.new_window );",
148 "string icon_name" : "document-new",
149 "string label" : "New File",
150 "xtype" : "ToolButton"
161 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
162 "bool homogeneous" : false,
165 "$ shadow_type" : "Gtk.ShadowType.IN",
168 " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
172 "bool expand" : true,
173 "int width_request" : 150,
176 "$ enable_tree_lines" : true,
177 "$ headers_visible" : true,
180 " var description = new Pango.FontDescription();",
181 " description.set_size(9000);",
182 " this.el.override_font(description); ",
184 " var selection = this.el.get_selection();",
185 " selection.set_mode( Gtk.SelectionMode.SINGLE);",
196 "$ columns" : "typeof(string), typeof(Object)",
200 " this.el.set_sort_func(0, (mod,a,b) => {",
201 " GLib.Value ga, gb;",
202 " mod.get_value(a,0, out ga);",
203 " mod.get_value(b,0, out gb);",
205 " if ((string)ga == (string)gb) {",
208 " return (string)ga > (string)gb ? 1 : -1;",
215 "* pack" : "set_model",
218 "xtype" : "ListStore"
224 " this.el.add_attribute(_this.namecol.el , \"markup\", 0 );",
227 "* pack" : "append_column",
231 "* pack" : "pack_start,true",
233 "xtype" : "CellRendererText"
236 "utf8 title" : "Projects",
237 "xtype" : "TreeViewColumn"
243 " if (_this.is_loading) {",
247 " Gtk.TreeIter iter;",
248 " Gtk.TreeModel mod;",
250 " var s = this.el.get_selection();",
251 " if (!s.get_selected(out mod, out iter)) {",
257 " mod.get_value(iter, 1 , out gval);",
258 " var project = (Project.Project)gval.get_object();",
260 " _this.onProjectSelected(project);",
268 "xtype" : "ScrolledWindow"
272 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
273 "bool expand" : true,
275 "int width_request" : 600,
279 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
280 "bool hexpand" : true,
286 "var description = Pango.FontDescription.from_string(\"monospace\");",
287 "\tdescription.set_size(8000);",
288 "\t this.el.override_font(description);",
292 "bool hexpand" : true,
297 "\tGLib.debug(\"Got '%s'\", this.el.text);",
299 "\tif (this.el.text.down() != _this.lastfilter) {",
300 "\t\t_this.loadIconView();",
306 "string placeholder_text" : "type to filter results",
307 "xtype" : "SearchEntry"
315 " this.el.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);",
319 "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN",
320 "bool expand" : true,
322 "int width_request" : 600,
333 "bool has_tooltip" : true,
335 "int item_width" : 100,
336 "int markup_column" : 1,
337 "int pixbuf_column" : 3,
340 "$ columns" : "typeof(Object), typeof(string), typeof(string), typeof(Gdk.Pixbuf), typeof(Gdk.Pixbuf) ",
345 "xtype" : "ListStore"
352 " _this.win.windowstate.project = _this.selectedProject;",
356 " \tGtk.TreeIter iter;",
359 "\tthis.el.model.get_iter(out iter, path);",
363 " this.el.model.get_value(iter, 0 , out gval);",
364 " var file = (JsRender.JsRender)gval;",
367 " _this.win.windowstate.fileViewOpen(file, _this.new_window);",
374 "(x, y, keyboard_tooltip, tooltip) => {",
376 "\tGtk.TreePath path;",
377 "\tGtk.CellRenderer cell;",
378 "\tvar s = _this.iconview.el.get_item_at_pos(x,y + (int) _this.iconscroll.el.vadjustment.value, out path, out cell);",
381 " // GLib.debug(\"Tooltip? %d,%d scroll: %d\",x,y, (int)_this.iconscroll.el.vadjustment.value);",
384 "\tif (path == null) {",
385 "\t\t// GLib.debug(\"Tooltip? - no path\");",
389 "\tGtk.TreeIter iter;",
390 "\t_this.iconmodel.el.get_iter(out iter, path);",
392 "\t_this.iconmodel.el.get_value(iter, 4, out val);",
394 "\ttooltip.set_icon((Gdk.Pixbuf) val.get_object());",
395 "\t _this.iconview.el.set_tooltip_item(tooltip, path);",
404 "xtype" : "ScrolledWindow"
411 "* init" : " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
413 "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN",
414 "bool expand" : true,
415 "bool visible" : false,
416 "id" : "file_container",
417 "int width_request" : 100,
420 "$ enable_tree_lines" : true,
421 "$ headers_visible" : true,
424 " var description = new Pango.FontDescription();",
425 " description.set_size(9000);",
426 " this.el.override_font(description); ",
428 " var selection = this.el.get_selection();",
429 " selection.set_mode( Gtk.SelectionMode.SINGLE);",
437 "bool activate_on_single_click" : false,
438 "bool expand" : true,
442 "$ columns" : "typeof(string), typeof(string)",
446 " this.el.set_sort_func(0, (mod,a,b) => {",
447 " GLib.Value ga, gb;",
448 " mod.get_value(a,0, out ga);",
449 " mod.get_value(b,0, out gb);",
451 " if ((string)ga == (string)gb) {",
454 " return (string)ga > (string)gb ? 1 : -1;",
461 "* pack" : "set_model",
464 "xtype" : "TreeStore"
470 " this.el.add_attribute(_this.filenamecol.el , \"markup\", 0 );",
473 "* pack" : "append_column",
477 "* pack" : "pack_start,true",
478 "id" : "filenamecol",
479 "xtype" : "CellRendererText"
482 "utf8 title" : "File",
483 "xtype" : "TreeViewColumn"
490 " if (_this.is_loading) {",
494 " Gtk.TreeIter iter;",
495 " Gtk.TreeModel mod;",
497 " var s = this.el.get_selection();",
498 " if (!s.get_selected(out mod, out iter)) {",
504 " mod.get_value(iter, 1 , out gval);",
505 " var project = (Project.Project)gval.get_object();",
507 " _this.project_selected(project);",
514 "\tGtk.TreeIter iter;",
517 "\tthis.el.model.get_iter(out iter, path);",
521 " this.el.model.get_value(iter, 1 , out gval);",
522 " var fn = (string)gval;",
523 " if (fn.length < 1) {",
526 " _this.win.windowstate.project = _this.selectedProject;",
529 " var f = JsRender.JsRender.factory(\"PlainFile\", _this.selectedProject, fn);",
532 " _this.win.windowstate.fileViewOpen(f, _this.new_window);",
541 "xtype" : "ScrolledWindow"
555 "\t//if (project != null) {",
556 "//\t\tthis.selectProject(project);",
558 " \tif (_this.win.windowstate.project == null) {",
559 " \t\tthis.el.show();",
564 "string lastfilter" : "\"\"",
570 " if (_this.is_loaded) {",
573 " _this.is_loading = true;",
575 " _this.is_loaded = true;",
577 " Project.Project.loadAll();",
578 " var projects = Project.Project.allProjectsByName();",
580 " Gtk.TreeIter iter;",
581 " var m = this.model.el;",
584 " for (var i = 0; i < projects.size; i++) {",
585 " m.append(out iter);",
586 " m.set(iter, 0,projects.get(i).name );",
588 " var o = GLib.Value(typeof(Object));",
589 " o.set_object((Object)projects.get(i));",
591 " m.set_value(iter, 1, o);",
594 " m.set_sort_column_id(0, Gtk.SortType.ASCENDING);",
595 " _this.is_loading = false; ",
599 "| void loadIconView" : [
602 "\tif (_this.image_cache == null) {",
603 "\t\t_this.image_cache = new Gee.HashMap<string,Gdk.Pixbuf>();",
606 "\t var project = this.selectedProject;",
608 " \t Gdk.Pixbuf pixbuf = null;",
609 " \t Gdk.Pixbuf bigpixbuf = null;",
610 "\t Gtk.TreeIter iter;",
611 " var m = this.iconmodel.el;",
615 " \tvar filter = _this.iconsearch.el.text.down();",
616 " \tthis.lastfilter = filter;",
618 " var fiter = project.sortedFiles().list_iterator();",
622 "\t if (_this.missing_thumb_pixbuf == null) {",
623 "\t var icon_theme = Gtk.IconTheme.get_default ();",
624 "\t _this.missing_thumb_pixbuf = icon_theme.load_icon (\"package-x-generic\", 92, 0);",
625 "\t _this.missing_thumb_pixbuf.ref();",
629 "\t } catch (Error e) {",
635 " while (fiter.next()) {",
637 " var file = fiter.get();",
638 " if (filter != \"\") {",
639 " \tif (!file.name.down().contains(filter)) {",
647 " m.append(out iter);",
649 " m.set(iter, 0,file ); // zero contains the file reference",
650 " m.set(iter, 1,file.nickType() + \"\\n\" + file.nickName()); // marked up title?",
651 " m.set(iter, 2,file.nickType() ); // file type?",
657 "\t\t pixbuf = file.getIcon(92);",
658 "\t\t\tbigpixbuf = file.getIcon(368);",
660 "\t\t} catch (Error e) {",
666 " if (pixbuf == null) {",
667 " \tGLib.debug(\"PIXBUF is null? %s\", file.name);",
668 "\t\t pixbuf = _this.missing_thumb_pixbuf;",
669 " \tbigpixbuf = _this.missing_thumb_pixbuf;",
674 " m.set(iter, 3,pixbuf);",
675 " m.set(iter, 4,bigpixbuf);",
677 " // this needs to add to the iconview?",
679 " //var a = new Xcls_fileitem(this,fiter.get());",
680 " //this.fileitems.add(a);",
682 " //this.filelayout.el.add_child(a.el);",
686 "| void onProjectSelected" : [
687 "(Project.Project project) ",
689 "\tif (this.in_onprojectselected) { ",
692 "\tthis.in_onprojectselected = true;",
695 "\tthis.selectedProject = project;",
696 "\tproject.scanDirs();",
697 "\t//this.clutterfiles.loadProject(proj);",
701 "\t_this.iconsearch.el.text = \"\";",
707 " //this.project_title_name.el.text = pr.name;",
708 " //this.project_title_path.el.text = pr.firstPath();",
710 " // file items contains a reference until we reload ...",
711 " \t this.loadIconView();",
714 " \t GLib.Timeout.add(500, () => {",
715 "\t _this.iconsearch.el.grab_focus();",
719 " this.filemodel.el.clear();",
723 " if (!(project is Project.Gtk)) {",
724 " print (\"not gtk... skipping files\");",
725 " this.file_container.el.hide();",
726 " \tthis.in_onprojectselected = false;",
729 " this.file_container.el.show();",
730 " var gpr = (Project.Gtk)project;",
731 " var def = gpr.compilegroups.get(\"_default_\");",
732 " // not sure why the above is returng null!??",
733 " if (def == null) {",
734 " \t\tdef = new Project.GtkValaSettings(\"_default_\"); ",
735 " \t\tgpr.compilegroups.set(\"_default_\", def);",
737 "\t var items = def.sources;",
739 "\t Gtk.TreeIter citer; // folder iter",
740 "\t Gtk.TreeIter fxiter; // file iter",
741 "\tfor(var i =0 ; i < items.size; i++) {",
742 "\t print (\"cheking folder %s\\n\", items.get(i));",
743 "\t var files = gpr.filesForOpen(items.get(i));",
744 "\t if (files.size < 1) {",
747 "\t\t this.filemodel.el.append(out citer,null);",
748 "\t\t this.filemodel.el.set(citer, 0, GLib.Path.get_basename(items.get(i)));",
749 "\t\t this.filemodel.el.set(citer, 1, null); // parent (empty as it's a folder)",
752 "\t // add the directory... items.get(i);",
753 "\t //var x = new Xcls_folderitem(this,items.get(i));",
754 "\t //this.fileitems.add(x);",
755 "\t //this.filelayout.el.add_child(x.el);",
758 "\t for(var j =0 ; j < files.size; j++) {",
760 "\t\t this.filemodel.el.insert(out fxiter,citer, -1);",
761 "\t \tthis.filemodel.el.set(fxiter, 0, GLib.Path.get_basename(files.get(j))); // filename",
762 "\t\t \tthis.filemodel.el.set(fxiter, 1, files.get(j)); // Folder?",
768 "\t //this.el.set_value(citer, 1, items.get(i) );",
770 " _this.fileview.el.expand_all();",
771 " \tthis.in_onprojectselected = false;",
776 "| void selectProject" : [
777 "(Project.Project project) {",
779 " var sel = _this.view.el.get_selection();",
781 " sel.unselect_all();",
783 " var found = false;",
784 " _this.model.el.foreach((mod, path, iter) => {",
787 " mod.get_value(iter, 1, out val);",
788 " if ( ( (Project.Project)val.get_object()).fn != project.fn) {",
789 " print(\"SKIP %s != %s\\n\", ((Project.Project)val.get_object()).name , project.name);",
790 " return false;//continue",
792 " sel.select_iter(iter);",
793 "\t\tthis.selectedProject = project;",
794 " this.onProjectSelected(project);",
801 "\t print(\"tried to select %s, could not find it\", project.name);",
806 "| void setMainWindow" : [
807 "(Xcls_MainWindow win) {",
814 "(Gtk.Widget on_el, Project.Project? project, bool new_window) {",
815 "\t//this.editor.show( file, node, ptype, key);",
817 "\tthis.new_window = new_window;",
820 "\tthis.el.show_all(); // show first - so we can hide stuff later.\t",
821 "\tif (project != null) {",
823 "\t\tthis.selectProject(project);",
828 " this.win.el.get_size(out w, out h);",
830 " // left tree = 250, editor area = 500?",
833 "\t// max hieght ...",
835 "\tvar ww = on_el.get_allocated_width();",
837 "\t// width = should be max = w-ww , or 600 at best..?",
839 " this.el.set_size_request( w, h); // same as parent...",
842 "\tthis.el.set_modal(true);",
843 "\tthis.el.set_relative_to(on_el);",
853 "name" : "PopoverFiles",
855 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverFiles.bjs",