3 "gen_extended" : false,
6 "# Gdk.Pixbuf missing_thumb_pixbuf" : "",
7 "# Gee.HashMap<string,Gdk.Pixbuf> image_cache" : "null",
8 "# Project.Project selectedProject" : "",
9 "# Xcls_MainWindow win" : "",
10 "# bool is_loaded" : false,
11 "# bool is_loading" : false,
12 "# bool new_window" : false,
14 "Gtk.PositionType position" : "Gtk.PositionType.TOP",
15 "bool active" : false,
16 "bool hexpand" : false,
17 "bool in_onprojectselected" : false,
19 "id" : "PopoverFiles",
20 "int height_request" : 800,
21 "int width_request" : 900,
25 "* pack" : "set_child",
26 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
27 "bool hexpand" : true,
28 "bool vexpand" : true,
32 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
33 "bool hexpand" : true,
36 "$ Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
43 "$ Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
48 "$ Gtk.IconSize icon_size" : "Gtk.IconSize.NORMAL",
51 "string icon_name" : "folder-new",
56 "string label" : "New Project",
67 " // create a new file in project..",
68 " //Xcls_DialogNewComponent.singleton().show(",
69 " var pe = EditProject.singleton();",
70 " pe.el.application = _this.win.el.application;",
71 " pe.el.set_transient_for( _this.win.el );",
75 " pe.selected.connect((pr) => {",
77 "\t _this.is_loaded = false;",
78 "\t _this.show(null, pr, _this.new_window);",
82 " pe.canceled.connect((pr) => {",
85 "\t _this.show(null, null, _this.new_window);",
95 "string label" : "New Project",
103 " // should disable the button really.",
104 " if (_this.selectedProject == null) {",
107 "\t_this.win.windowstate.projectPopoverShow(this.el, _this.selectedProject);",
111 "string icon_name" : "emblem-system",
112 "string label" : "Project Properties",
121 " var cd = DialogConfirm.singleton();",
122 " cd.el.set_transient_for(_this.el);",
123 " cd.el.set_modal(true);",
125 " var project = _this.windowstate.left_projects.getSelectedProject();",
126 " if (project == null) {",
127 " print(\"SKIP - no project\\n\");",
132 " if (Gtk.ResponseType.YES != cd.show(\"Confirm\", ",
133 " \"Are you sure you want to delete project %s\".printf(project.name))) {",
139 " Project.Project.remove(project);",
140 " _this.project = null;",
142 " _this.windowstate.left_projects.is_loaded = false;",
143 " _this.windowstate.left_projects.load();",
144 " _this.windowstate.clutterfiles.clearFiles();",
150 "string icon_name" : "user-trash",
151 "string label" : "Delete Project",
159 " // create a new file in project..",
160 " print(\"add file selected\\n\");",
162 " if (_this.selectedProject == null) {",
166 " \tvar f = JsRender.JsRender.factory(_this.selectedProject.xtype, _this.selectedProject, \"\");",
167 " \t_this.win.windowstate.file_details.show( f, this.el, _this.new_window );",
168 " } catch (JsRender.Error e) {}",
173 "string icon_name" : "document-new",
174 "string label" : "New File",
185 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
186 "bool hexpand" : true,
187 "bool homogeneous" : false,
188 "bool vexpand" : true,
193 " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
196 "bool expand" : true,
197 "bool has_frame" : true,
198 "bool hexpand" : true,
199 "bool vexpand" : true,
200 "int width_request" : 150,
203 "$ enable_tree_lines" : true,
204 "$ headers_visible" : true,
209 "this.css = new Gtk.CssProvider();",
211 "\tthis.css.load_from_data(\"#popover-files-view { font-size: 10px;}\".data);",
212 "} catch (Error e) {}",
213 "this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);",
218 "var selection = this.el.get_selection();",
219 "selection.set_mode( Gtk.SelectionMode.SINGLE);",
226 "* pack" : "set_child",
227 "Gtk.CssProvider css" : "",
228 "bool hexpand" : true,
229 "bool vexpand" : true,
233 "$ columns" : "typeof(string), typeof(Object)",
237 " this.el.set_sort_func(0, (mod,a,b) => {",
238 " GLib.Value ga, gb;",
239 " mod.get_value(a,0, out ga);",
240 " mod.get_value(b,0, out gb);",
242 " if ((string)ga == (string)gb) {",
245 " return (string)ga > (string)gb ? 1 : -1;",
252 "* pack" : "set_model",
255 "xtype" : "ListStore"
261 " this.el.add_attribute(_this.namecol.el , \"markup\", 0 );",
264 "* pack" : "append_column",
268 "* pack" : "pack_start,true",
270 "xtype" : "CellRendererText"
273 "utf8 title" : "Projects",
274 "xtype" : "TreeViewColumn"
280 " if (_this.is_loading) {",
284 " Gtk.TreeIter iter;",
285 " Gtk.TreeModel mod;",
287 " var s = this.el.get_selection();",
288 " if (!s.get_selected(out mod, out iter)) {",
294 " mod.get_value(iter, 1 , out gval);",
295 " var project = (Project.Project)gval.get_object();",
297 " _this.onProjectSelected(project);",
302 "string name" : "popover-files-view",
306 "xtype" : "ScrolledWindow"
310 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
311 "bool hexpand" : true,
312 "bool vexpand" : true,
314 "int width_request" : 600,
318 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
319 "bool hexpand" : true,
327 "this.css = new Gtk.CssProvider();",
329 "\tthis.css.load_from_data(\"#popover-files-iconsearch { font: 10px monospace;}\".data);",
330 "} catch (Error e) {}",
331 "this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);",
336 "Gtk.CssProvider css" : "",
337 "bool hexpand" : true,
342 "\tGLib.debug(\"Got '%s'\", this.el.text);",
344 "\tif (this.el.text.down() != _this.lastfilter) {",
345 "\t\t_this.loadIconView();",
346 "\t\t_this.loadTreeView();",
352 "string name" : "popover-files-iconsearch",
353 "string placeholder_text" : "type to filter results",
354 "xtype" : "SearchEntry"
362 " this.el.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);",
365 "bool has_frame" : true,
366 "bool hexpand" : true,
367 "bool vexpand" : true,
369 "int width_request" : 600,
379 "* pack" : "set_child",
380 "bool has_tooltip" : true,
381 "bool hexpand" : true,
382 "bool vexpand" : true,
384 "int item_width" : 100,
385 "int markup_column" : 1,
386 "int pixbuf_column" : 3,
389 "$ columns" : "typeof(Object), typeof(string), typeof(string), typeof(Gdk.Pixbuf), typeof(Gdk.Pixbuf) ",
394 "xtype" : "ListStore"
401 " _this.win.windowstate.project = _this.selectedProject;",
405 " \tGtk.TreeIter iter;",
408 "\tthis.el.model.get_iter(out iter, path);",
412 " this.el.model.get_value(iter, 0 , out gval);",
413 " var file = (JsRender.JsRender)gval;",
416 " _this.win.windowstate.fileViewOpen(file, _this.new_window);",
423 "(x, y, keyboard_tooltip, tooltip) => {",
425 "\tGtk.TreePath path;",
426 "\tGtk.CellRenderer cell;",
427 "\t_this.iconview.el.get_item_at_pos(x,y + (int) _this.iconscroll.el.vadjustment.value, out path, out cell);",
430 " // GLib.debug(\"Tooltip? %d,%d scroll: %d\",x,y, (int)_this.iconscroll.el.vadjustment.value);",
433 "\tif (path == null) {",
434 "\t\t// GLib.debug(\"Tooltip? - no path\");",
438 "\tGtk.TreeIter iter;",
439 "\t_this.iconmodel.el.get_iter(out iter, path);",
441 "\t_this.iconmodel.el.get_value(iter, 4, out val);",
443 "\ttooltip.set_icon( Gdk.Texture.for_pixbuf(",
444 "\t\t(Gdk.Pixbuf) val.get_object()",
446 "\t _this.iconview.el.set_tooltip_item(tooltip, path);",
455 "xtype" : "ScrolledWindow"
462 "* init" : " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
463 "bool has_frame" : true,
464 "bool hexpand" : true,
465 "bool vexpand" : true,
466 "bool visible" : false,
467 "id" : "file_container",
468 "int width_request" : 200,
471 "$ enable_tree_lines" : true,
472 "$ headers_visible" : true,
476 "this.css = new Gtk.CssProvider();",
478 "\tthis.css.load_from_data(\"#popover-files-fileview { font-size: 12px;}\".data);",
479 "} catch (Error e) {}",
480 "this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);",
486 "var selection = this.el.get_selection();",
487 "selection.set_mode( Gtk.SelectionMode.SINGLE);",
494 "* pack" : "set_child",
495 "Gtk.CssProvider css" : "",
496 "bool activate_on_single_click" : false,
497 "bool hexpand" : true,
498 "bool vexpand" : true,
502 "$ columns" : "typeof(string), typeof(string)",
506 " this.el.set_sort_func(0, (mod,a,b) => {",
507 " GLib.Value ga, gb;",
508 " mod.get_value(a,0, out ga);",
509 " mod.get_value(b,0, out gb);",
511 " if ((string)ga == (string)gb) {",
514 " return (string)ga > (string)gb ? 1 : -1;",
521 "* pack" : "set_model",
524 "xtype" : "TreeStore"
530 " this.el.add_attribute(_this.filenamecol.el , \"markup\", 0 );",
533 "* pack" : "append_column",
537 "* pack" : "pack_start,true",
538 "id" : "filenamecol",
539 "xtype" : "CellRendererText"
542 "utf8 title" : "File",
543 "xtype" : "TreeViewColumn"
550 " if (_this.is_loading) {",
554 " Gtk.TreeIter iter;",
555 " Gtk.TreeModel mod;",
557 " var s = this.el.get_selection();",
558 " if (!s.get_selected(out mod, out iter)) {",
564 " mod.get_value(iter, 1 , out gval);",
565 " var project = (Project.Project)gval.get_object();",
567 " _this.project_selected(project);",
574 "\tGtk.TreeIter iter;",
577 "\tthis.el.model.get_iter(out iter, path);",
581 " this.el.model.get_value(iter, 1 , out gval);",
582 " var fn = (string)gval;",
583 " if (fn.length < 1) {",
586 " _this.win.windowstate.project = _this.selectedProject;",
589 "\t\tvar f = JsRender.JsRender.factory(\"PlainFile\", _this.selectedProject, fn);",
590 "\t\t_this.win.windowstate.fileViewOpen(f, _this.new_window);",
591 "\t} catch (JsRender.Error e) {} ",
596 "string name" : "popover-files-fileview",
600 "xtype" : "ScrolledWindow"
614 "\t//if (project != null) {",
615 "//\t\tthis.selectProject(project);",
617 " \t//if (_this.win.windowstate.project == null) {",
618 " \t//\tthis.el.show();",
623 "string lastfilter" : "\"\"",
624 "string title" : "Select Project /File",
630 " if (_this.is_loaded) {",
633 " _this.is_loading = true;",
635 " _this.is_loaded = true;",
637 " Project.Project.loadAll();",
638 " var projects = Project.Project.allProjectsByName();",
640 " Gtk.TreeIter iter;",
641 " var m = this.model.el;",
644 " for (var i = 0; i < projects.size; i++) {",
645 " m.append(out iter);",
646 " m.set(iter, 0,projects.get(i).name );",
648 " var o = GLib.Value(typeof(Object));",
649 " o.set_object((Object)projects.get(i));",
651 " m.set_value(iter, 1, o);",
654 " m.set_sort_column_id(0, Gtk.SortType.ASCENDING);",
655 " _this.is_loading = false; ",
659 "| void loadIconView" : [
662 "\tif (_this.image_cache == null) {",
663 "\t\t_this.image_cache = new Gee.HashMap<string,Gdk.Pixbuf>();",
666 "\t var project = this.selectedProject;",
668 " \t Gdk.Pixbuf pixbuf = null;",
669 " \t Gdk.Pixbuf bigpixbuf = null;",
670 "\t Gtk.TreeIter iter;",
671 " var m = this.iconmodel.el;",
675 " \tvar filter = _this.iconsearch.el.text.down();",
676 " \tthis.lastfilter = filter;",
678 " var fiter = project.sortedFiles().list_iterator();",
682 " if (_this.missing_thumb_pixbuf == null) {",
684 " \tvar icon_theme = Gtk.IconTheme.get_for_display(this.el.get_display());",
685 " \t var icon = icon_theme.lookup_icon (\"package-x-generic\", null, 92,1, ",
686 "\t\t\t\t\t Gtk.TextDirection.NONE, 0);",
687 "\t\t \t_this.missing_thumb_pixbuf = (new Gdk.Pixbuf.from_file (icon.file.get_path())).scale_simple(",
688 "\t\t \t\t92, 92 \t, Gdk.InterpType.NEAREST) ;",
689 " _this.missing_thumb_pixbuf.ref();",
693 "\t } catch (Error e) {",
699 " while (fiter.next()) {",
701 " var file = fiter.get();",
702 " if (filter != \"\") {",
703 " \tif (!file.name.down().contains(filter)) {",
711 " m.append(out iter);",
713 " m.set(iter, 0,file ); // zero contains the file reference",
714 " m.set(iter, 1,file.nickType() + \"\\n\" + file.nickName()); // marked up title?",
715 " m.set(iter, 2,file.nickType() ); // file type?",
720 "\t pixbuf = file.getIcon(92);",
721 "\t\tbigpixbuf = file.getIcon(368);",
725 " if (pixbuf == null) {",
726 " \tGLib.debug(\"PIXBUF is null? %s\", file.name);",
727 "\t\t pixbuf = _this.missing_thumb_pixbuf;",
728 " \tbigpixbuf = _this.missing_thumb_pixbuf;",
733 " m.set(iter, 3,pixbuf);",
734 " m.set(iter, 4,bigpixbuf);",
736 " // this needs to add to the iconview?",
738 " //var a = new Xcls_fileitem(this,fiter.get());",
739 " //this.fileitems.add(a);",
741 " //this.filelayout.el.add_child(a.el);",
745 "| void loadTreeView" : [
747 " var project = this.selectedProject;",
749 " this.filemodel.el.clear();",
753 " if (!(project is Project.Gtk)) {",
754 " //print (\"not gtk... skipping files\");",
755 " this.file_container.el.hide();",
761 " var filter = _this.iconsearch.el.text.down();",
763 " this.file_container.el.show();",
764 " var gpr = (Project.Gtk)project;",
765 " var def = gpr.compilegroups.get(\"_default_\");",
766 " // not sure why the above is returng null!??",
767 " if (def == null) {",
768 " \t\tdef = new Project.GtkValaSettings(\"_default_\"); ",
769 " \t\tgpr.compilegroups.set(\"_default_\", def);",
771 "\t var items = def.sources;",
773 "\t Gtk.TreeIter citer; // folder iter",
774 "\t Gtk.TreeIter fxiter; // file iter",
775 "\tfor(var i =0 ; i < items.size; i++) {",
776 "\t // print (\"cheking folder %s\\n\", items.get(i));",
777 "\t var files = gpr.filesForOpen(items.get(i));",
783 "\t if (files.size < 1) {",
787 "\t for(var j =0 ; j < files.size; j++) {",
789 "\t \tif (filter != \"\") {",
790 "\t \t\tvar ff = GLib.Path.get_basename(files.get(j)).down();",
791 "\t \t\tvar dp = ff.last_index_of(\".\");",
792 "\t\t \tif (!ff.substring(0,dp < 0 ? ff.length :dp ).contains(filter)) {",
793 "\t\t \t\tcontinue;",
803 "\t\t this.filemodel.el.append(out citer,null);",
804 "\t\t this.filemodel.el.set(citer, 0, GLib.Path.get_basename(items.get(i)));",
805 "\t\t this.filemodel.el.set(citer, 1, null); // parent (empty as it's a folder)",
808 "\t // add the directory... items.get(i);",
809 "\t //var x = new Xcls_folderitem(this,items.get(i));",
810 "\t //this.fileitems.add(x);",
811 "\t //this.filelayout.el.add_child(x.el);",
814 "\t for(var j =0 ; j < files.size; j++) {",
816 "\t \tif (filter != \"\") {",
817 "\t \t\tvar ff = GLib.Path.get_basename(files.get(j)).down();",
818 "\t \t\tvar dp = ff.last_index_of(\".\");",
819 "\t\t \tif (!ff.substring(0,dp < 0 ? ff.length :dp ).contains(filter)) {",
820 "\t\t \t\tcontinue;",
825 "\t\t this.filemodel.el.insert(out fxiter,citer, -1);",
826 "\t \tthis.filemodel.el.set(fxiter, 0, GLib.Path.get_basename(files.get(j))); // filename",
827 "\t\t \tthis.filemodel.el.set(fxiter, 1, files.get(j)); // Folder?",
833 "\t //this.el.set_value(citer, 1, items.get(i) );",
835 " _this.fileview.el.expand_all();",
838 "| void onProjectSelected" : [
839 "(Project.Project project) ",
841 "\tif (this.in_onprojectselected) { ",
844 "\tthis.in_onprojectselected = true;",
847 "\tthis.selectedProject = project;",
848 "\tproject.scanDirs();",
849 "\t//this.clutterfiles.loadProject(proj);",
853 "\t_this.iconsearch.el.text = \"\";",
859 " //this.project_title_name.el.text = pr.name;",
860 " //this.project_title_path.el.text = pr.firstPath();",
862 " // file items contains a reference until we reload ...",
863 " \t this.loadIconView();",
866 " \t GLib.Timeout.add(500, () => {",
867 "\t _this.iconsearch.el.grab_focus();",
873 "\tthis.loadTreeView();",
874 "\tthis.in_onprojectselected = false;\t",
878 "| void selectProject" : [
879 "(Project.Project project) {",
881 " var sel = _this.view.el.get_selection();",
883 " sel.unselect_all();",
885 " var found = false;",
886 " _this.model.el.foreach((mod, path, iter) => {",
889 " mod.get_value(iter, 1, out val);",
890 " if ( ( (Project.Project)val.get_object()).fn != project.fn) {",
891 " print(\"SKIP %s != %s\\n\", ((Project.Project)val.get_object()).name , project.name);",
892 " return false;//continue",
894 " sel.select_iter(iter);",
895 "\t\tthis.selectedProject = project;",
896 " this.onProjectSelected(project);",
903 "\t print(\"tried to select %s, could not find it\", project.name);",
908 "| void setMainWindow" : [
909 "(Xcls_MainWindow win) {",
911 "\tthis.el.set_transient_for(win.el);",
912 "\tthis.el.application = BuilderApplication.singleton({});",
917 "(Gtk.Widget? on_el, Project.Project? project, bool new_window) {",
918 "\t//this.editor.show( file, node, ptype, key);",
920 "\tthis.new_window = new_window;",
923 "\tif (on_el != null) {",
924 "\t\tthis.el.set_parent(on_el);",
926 "\t // show first - so we can hide stuff later.\t",
927 "\tif (project != null) {",
929 "\t\tthis.selectProject(project);",
933 " // var win = this.win.el;",
934 " // var w = win.get_width();",
935 " // var h = win.get_height();",
937 " // left tree = 250, editor area = 500?",
940 "\t// max hieght ...",
942 "\t//var ww = on_el.get_allocated_width();",
944 "\t// width = should be max = w-ww , or 600 at best..?",
946 " //this.el.set_size_request( w - 100, h - 100); // same as parent...",
949 "\t//this.el.set_autohide(true); // can hide",
950 "\t//Gtk.Allocation rect;",
951 "\t//on_el.get_allocation(out rect);",
952 " // this.el.set_pointing_to(rect);",
953 " //this.el.set_offset(200,0);",
954 " //this.el.set_position(Gtk.PositionType.BOTTOM);",
962 "name" : "PopoverFiles",