{ "build_module" : "", "gen_extended" : false, "items" : [ { "# Gdk.Pixbuf missing_thumb_pixbuf" : "", "# Gee.HashMap image_cache" : "null", "# Project.Project selectedProject" : "", "# Xcls_MainWindow win" : "", "# bool is_loaded" : false, "# bool is_loading" : false, "# bool new_window" : false, "$ xns" : "Gtk", "Gtk.PositionType position" : "Gtk.PositionType.TOP", "bool active" : false, "bool hexpand" : false, "bool in_onprojectselected" : false, "bool modal" : true, "id" : "PopoverFiles", "int height_request" : 800, "int width_request" : 900, "items" : [ { "$ xns" : "Gtk", "* pack" : "set_child", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "bool hexpand" : true, "bool vexpand" : true, "items" : [ { "$ xns" : "Gtk", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "bool hexpand" : true, "items" : [ { "$ Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", "$ xns" : "Gtk", "items" : [ { "$ xns" : "Gtk", "items" : [ { "$ Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", "$ xns" : "Gtk", "* prop" : "child", "items" : [ { "$ Gtk.IconSize icon_size" : "Gtk.IconSize.NORMAL", "$ xns" : "Gtk", "int margin_end" : 4, "string icon_name" : "folder-new", "xtype" : "Image" }, { "$ xns" : "Gtk", "string label" : "New Project", "xtype" : "Label" } ], "xtype" : "Box" } ], "listeners" : { "clicked" : [ " ( ) => {", " ", " // create a new file in project..", " //Xcls_DialogNewComponent.singleton().show(", " var pe = EditProject.singleton();", " pe.el.application = _this.win.el.application;", " pe.el.set_transient_for( _this.win.el );", " ", " _this.el.hide();", " ", " pe.selected.connect((pr) => {", " \t", "\t _this.is_loaded = false;", "\t _this.show(null, pr, _this.new_window);", "", " });", " ", " pe.canceled.connect((pr) => {", " \t", " ", "\t _this.show(null, null, _this.new_window);", "", " });", " ", " pe.showIt();", " ", "", "}" ] }, "string label" : "New Project", "xtype" : "Button" }, { "$ xns" : "Gtk", "listeners" : { "clicked" : [ " ( ) => {", " // should disable the button really.", " if (_this.selectedProject == null) {", "\t return;", " }", "\t_this.win.windowstate.projectPopoverShow(this.el, _this.selectedProject);", " }" ] }, "string icon_name" : "emblem-system", "string label" : "Project Properties", "xtype" : "Button" }, { "$ xns" : "Gtk", "listeners" : { "clicked" : [ " ( ) => {", " /*", " var cd = DialogConfirm.singleton();", " cd.el.set_transient_for(_this.el);", " cd.el.set_modal(true);", "", " var project = _this.windowstate.left_projects.getSelectedProject();", " if (project == null) {", " print(\"SKIP - no project\\n\");", " return;", " }", " ", " ", " if (Gtk.ResponseType.YES != cd.show(\"Confirm\", ", " \"Are you sure you want to delete project %s\".printf(project.name))) {", " return;", " }", " ", "", " // confirm?", " Project.Project.remove(project);", " _this.project = null;", " ", " _this.windowstate.left_projects.is_loaded = false;", " _this.windowstate.left_projects.load();", " _this.windowstate.clutterfiles.clearFiles();", "*/", "", "}" ] }, "string icon_name" : "user-trash", "string label" : "Delete Project", "xtype" : "Button" }, { "$ xns" : "Gtk", "listeners" : { "clicked" : [ " () => {", " // create a new file in project..", " print(\"add file selected\\n\");", " ", " if (_this.selectedProject == null) {", " \treturn;", " }", " try {", " \tvar f = JsRender.JsRender.factory(_this.selectedProject.xtype, _this.selectedProject, \"\");", " \t_this.win.windowstate.file_details.show( f, this.el, _this.new_window );", " } catch (JsRender.Error e) {}", "", "}" ] }, "string icon_name" : "document-new", "string label" : "New File", "xtype" : "Button" } ], "xtype" : "Box" } ], "xtype" : "Box" }, { "$ xns" : "Gtk", "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", "bool hexpand" : true, "bool homogeneous" : false, "bool vexpand" : true, "items" : [ { "$ xns" : "Gtk", "* init" : [ " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);", " " ], "bool expand" : true, "bool has_frame" : true, "bool hexpand" : true, "bool vexpand" : true, "int width_request" : 150, "items" : [ { "$ enable_tree_lines" : true, "$ headers_visible" : true, "$ xns" : "Gtk", "* init" : [ " ", " ", "this.css = new Gtk.CssProvider();", "try {", "\tthis.css.load_from_data(\"#popover-files-view { font-size: 10px;}\".data);", "} catch (Error e) {}", "this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);", " ", " ", " ", " ", "var selection = this.el.get_selection();", "selection.set_mode( Gtk.SelectionMode.SINGLE);", "", "", " ", " ", " " ], "* pack" : "set_child", "Gtk.CssProvider css" : "", "bool hexpand" : true, "bool vexpand" : true, "id" : "view", "items" : [ { "$ columns" : "typeof(string), typeof(Object)", "$ xns" : "Gtk", "* init" : [ "{", " this.el.set_sort_func(0, (mod,a,b) => {", " GLib.Value ga, gb;", " mod.get_value(a,0, out ga);", " mod.get_value(b,0, out gb);", " ", " if ((string)ga == (string)gb) {", " return 0;", " }", " return (string)ga > (string)gb ? 1 : -1;", " }); ", "", "", "}", "" ], "* pack" : "set_model", "id" : "model", "n_columns" : 2, "xtype" : "ListStore" }, { "$ xns" : "Gtk", "* init" : [ "", " this.el.add_attribute(_this.namecol.el , \"markup\", 0 );", " " ], "* pack" : "append_column", "items" : [ { "$ xns" : "Gtk", "* pack" : "pack_start,true", "id" : "namecol", "xtype" : "CellRendererText" } ], "utf8 title" : "Projects", "xtype" : "TreeViewColumn" } ], "listeners" : { "cursor_changed" : [ " () => {", " if (_this.is_loading) {", " return;", " }", " ", " Gtk.TreeIter iter;", " Gtk.TreeModel mod;", " ", " var s = this.el.get_selection();", " if (!s.get_selected(out mod, out iter)) {", " return;", " }", " ", " GLib.Value gval;", "", " mod.get_value(iter, 1 , out gval);", " var project = (Project.Project)gval.get_object();", " ", " _this.onProjectSelected(project);", " ", "} " ] }, "string name" : "popover-files-view", "xtype" : "TreeView" } ], "xtype" : "ScrolledWindow" }, { "$ xns" : "Gtk", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "bool hexpand" : true, "bool vexpand" : true, "int spacing" : 0, "int width_request" : 600, "items" : [ { "$ xns" : "Gtk", "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", "bool hexpand" : true, "int spacing" : 0, "items" : [ { "$ xns" : "Gtk", "* init" : [ " ", "", "this.css = new Gtk.CssProvider();", "try {", "\tthis.css.load_from_data(\"#popover-files-iconsearch { font: 10px monospace;}\".data);", "} catch (Error e) {}", "this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);", " ", " ", "" ], "Gtk.CssProvider css" : "", "bool hexpand" : true, "id" : "iconsearch", "listeners" : { "changed" : [ "( ) => {", "\tGLib.debug(\"Got '%s'\", this.el.text);", "\t", "\tif (this.el.text.down() != _this.lastfilter) {", "\t\t_this.loadIconView();", "\t\t_this.loadTreeView();", "\t}", "}", "" ] }, "string name" : "popover-files-iconsearch", "string placeholder_text" : "type to filter results", "xtype" : "SearchEntry" } ], "xtype" : "Box" }, { "$ xns" : "Gtk", "* init" : [ " this.el.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);", " " ], "bool has_frame" : true, "bool hexpand" : true, "bool vexpand" : true, "id" : "iconscroll", "int width_request" : 600, "items" : [ { "$ xns" : "Gtk", "* init" : [ "{", " ", "}", "" ], "* pack" : "set_child", "bool has_tooltip" : true, "bool hexpand" : true, "bool vexpand" : true, "id" : "iconview", "int item_width" : 100, "int markup_column" : 1, "int pixbuf_column" : 3, "items" : [ { "$ columns" : "typeof(Object), typeof(string), typeof(string), typeof(Gdk.Pixbuf), typeof(Gdk.Pixbuf) ", "$ xns" : "Gtk", "* prop" : "model", "id" : "iconmodel", "int n_columns" : 4, "xtype" : "ListStore" } ], "listeners" : { "item_activated" : [ "(path) => {", " ", " _this.win.windowstate.project = _this.selectedProject;", " _this.el.hide();", " ", " ", " \tGtk.TreeIter iter;", " ", " ", "\tthis.el.model.get_iter(out iter, path);", " ", " GLib.Value gval;", "", " this.el.model.get_value(iter, 0 , out gval);", " var file = (JsRender.JsRender)gval;", " ", " ", " _this.win.windowstate.fileViewOpen(file, _this.new_window);", "", " ", " ", "}" ], "query_tooltip" : [ "(x, y, keyboard_tooltip, tooltip) => {", "", "\tGtk.TreePath path;", "\tGtk.CellRenderer cell;", "\t_this.iconview.el.get_item_at_pos(x,y + (int) _this.iconscroll.el.vadjustment.value, out path, out cell);", "\t", "\t", " // GLib.debug(\"Tooltip? %d,%d scroll: %d\",x,y, (int)_this.iconscroll.el.vadjustment.value);", "\t ", "\t", "\tif (path == null) {", "\t\t// GLib.debug(\"Tooltip? - no path\");", "\t\treturn false;", "\t}", "\t", "\tGtk.TreeIter iter;", "\t_this.iconmodel.el.get_iter(out iter, path);", "\tGLib.Value val;", "\t_this.iconmodel.el.get_value(iter, 4, out val);", "\t", "\ttooltip.set_icon( Gdk.Texture.for_pixbuf(", "\t\t(Gdk.Pixbuf) val.get_object()", "\t));", "\t _this.iconview.el.set_tooltip_item(tooltip, path);", "\treturn true;", "}", "" ] }, "xtype" : "IconView" } ], "xtype" : "ScrolledWindow" } ], "xtype" : "Box" }, { "$ xns" : "Gtk", "* init" : " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);", "bool has_frame" : true, "bool hexpand" : true, "bool vexpand" : true, "bool visible" : false, "id" : "file_container", "int width_request" : 200, "items" : [ { "$ enable_tree_lines" : true, "$ headers_visible" : true, "$ xns" : "Gtk", "* init" : [ "", "this.css = new Gtk.CssProvider();", "try {", "\tthis.css.load_from_data(\"#popover-files-fileview { font-size: 12px;}\".data);", "} catch (Error e) {}", "this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);", " ", " ", " ", " ", " ", "var selection = this.el.get_selection();", "selection.set_mode( Gtk.SelectionMode.SINGLE);", "", "", "", "", "" ], "* pack" : "set_child", "Gtk.CssProvider css" : "", "bool activate_on_single_click" : false, "bool hexpand" : true, "bool vexpand" : true, "id" : "fileview", "items" : [ { "$ columns" : "typeof(string), typeof(string)", "$ xns" : "Gtk", "* init" : [ "{", " this.el.set_sort_func(0, (mod,a,b) => {", " GLib.Value ga, gb;", " mod.get_value(a,0, out ga);", " mod.get_value(b,0, out gb);", " ", " if ((string)ga == (string)gb) {", " return 0;", " }", " return (string)ga > (string)gb ? 1 : -1;", " }); ", " ", "", "}", "" ], "* pack" : "set_model", "id" : "filemodel", "n_columns" : 2, "xtype" : "TreeStore" }, { "$ xns" : "Gtk", "* init" : [ "", " this.el.add_attribute(_this.filenamecol.el , \"markup\", 0 );", " " ], "* pack" : "append_column", "items" : [ { "$ xns" : "Gtk", "* pack" : "pack_start,true", "id" : "filenamecol", "xtype" : "CellRendererText" } ], "utf8 title" : "File", "xtype" : "TreeViewColumn" } ], "listeners" : { "cursor_changed" : [ " () => {", " /*", " if (_this.is_loading) {", " return;", " }", " ", " Gtk.TreeIter iter;", " Gtk.TreeModel mod;", " ", " var s = this.el.get_selection();", " if (!s.get_selected(out mod, out iter)) {", " return;", " }", " ", " GLib.Value gval;", "", " mod.get_value(iter, 1 , out gval);", " var project = (Project.Project)gval.get_object();", " ", " _this.project_selected(project);", " */", "} " ], "row_activated" : [ "(path, col) => {", "", "\tGtk.TreeIter iter;", " ", " ", "\tthis.el.model.get_iter(out iter, path);", " ", " GLib.Value gval;", "", " this.el.model.get_value(iter, 1 , out gval);", " var fn = (string)gval;", " if (fn.length < 1) {", " \treturn;", "\t}", " _this.win.windowstate.project = _this.selectedProject;", " _this.el.hide();", " try {", "\t\tvar f = JsRender.JsRender.factory(\"PlainFile\", _this.selectedProject, fn);", "\t\t_this.win.windowstate.fileViewOpen(f, _this.new_window);", "\t} catch (JsRender.Error e) {} ", " ", "}" ] }, "string name" : "popover-files-fileview", "xtype" : "TreeView" } ], "xtype" : "ScrolledWindow" } ], "xtype" : "Box" } ], "xtype" : "Box" } ], "listeners" : { "hide" : [ "( ) => {", "\t// save...", "\t//this.load();", "\t//if (project != null) {", "//\t\tthis.selectProject(project);", "//\t}", " \t//if (_this.win.windowstate.project == null) {", " \t//\tthis.el.show();", "\t//}", "}" ] }, "string lastfilter" : "\"\"", "string title" : "Select Project /File", "xtype" : "Window", "| void load" : [ "() {", " // clear list...", " ", " if (_this.is_loaded) {", " return;", " }", " _this.is_loading = true;", " ", " _this.is_loaded = true;", " ", " Project.Project.loadAll();", " var projects = Project.Project.allProjectsByName();", " ", " Gtk.TreeIter iter;", " var m = this.model.el;", " m.clear();", " ", " for (var i = 0; i < projects.size; i++) {", " m.append(out iter);", " m.set(iter, 0,projects.get(i).name );", " ", " var o = GLib.Value(typeof(Object));", " o.set_object((Object)projects.get(i));", " ", " m.set_value(iter, 1, o);", " ", " }", " m.set_sort_column_id(0, Gtk.SortType.ASCENDING);", " _this.is_loading = false; ", "}", "" ], "| void loadIconView" : [ "() {", "\t", "\tif (_this.image_cache == null) {", "\t\t_this.image_cache = new Gee.HashMap();", "\t}", "\t", "\t var project = this.selectedProject;", " ", " \t Gdk.Pixbuf pixbuf = null;", " \t Gdk.Pixbuf bigpixbuf = null;", "\t Gtk.TreeIter iter;", " var m = this.iconmodel.el;", " m.clear();", " ", " ", " \tvar filter = _this.iconsearch.el.text.down();", " \tthis.lastfilter = filter;", " ", " var fiter = project.sortedFiles().list_iterator();", " ", " ", " try {", " if (_this.missing_thumb_pixbuf == null) {", " ", " \tvar icon_theme = Gtk.IconTheme.get_for_display(this.el.get_display());", " \t var icon = icon_theme.lookup_icon (\"package-x-generic\", null, 92,1, ", "\t\t\t\t\t Gtk.TextDirection.NONE, 0);", "\t\t \t_this.missing_thumb_pixbuf = (new Gdk.Pixbuf.from_file (icon.file.get_path())).scale_simple(", "\t\t \t\t92, 92 \t, Gdk.InterpType.NEAREST) ;", " _this.missing_thumb_pixbuf.ref();", " }", "\t ", "", "\t } catch (Error e) {", "\t // noop?", "\t }", " ", "", " ", " while (fiter.next()) {", " ", " var file = fiter.get();", " if (filter != \"\") {", " \tif (!file.name.down().contains(filter)) {", " \t\tcontinue;", " \t\t}", " ", " } ", " \t", " ", " ", " m.append(out iter);", "", " m.set(iter, 0,file ); // zero contains the file reference", " m.set(iter, 1,file.nickType() + \"\\n\" + file.nickName()); // marked up title?", " m.set(iter, 2,file.nickType() ); // file type?", " ", " ", " ", "\t ", "\t pixbuf = file.getIcon(92);", "\t\tbigpixbuf = file.getIcon(368);", "", "\t\t ", " ", " if (pixbuf == null) {", " \tGLib.debug(\"PIXBUF is null? %s\", file.name);", "\t\t pixbuf = _this.missing_thumb_pixbuf;", " \tbigpixbuf = _this.missing_thumb_pixbuf;", "\t\t}", "\t\t", "\t\t", "\t\t", " m.set(iter, 3,pixbuf);", " m.set(iter, 4,bigpixbuf);", " ", " // this needs to add to the iconview?", " ", " //var a = new Xcls_fileitem(this,fiter.get());", " //this.fileitems.add(a);", "", " //this.filelayout.el.add_child(a.el);", " }", "}" ], "| void loadTreeView" : [ "() {", " var project = this.selectedProject;", " ", " this.filemodel.el.clear();", " ", " // folders...", " ", " if (!(project is Project.Gtk)) {", " //print (\"not gtk... skipping files\");", " this.file_container.el.hide();", " return;", " }", " ", " ", " ", " var filter = _this.iconsearch.el.text.down();", " ", " this.file_container.el.show();", " var gpr = (Project.Gtk)project;", " var def = gpr.compilegroups.get(\"_default_\");", " // not sure why the above is returng null!??", " if (def == null) {", " \t\tdef = new Project.GtkValaSettings(\"_default_\"); ", " \t\tgpr.compilegroups.set(\"_default_\", def);", " }", "\t var items = def.sources;", "\t\t ", "\t Gtk.TreeIter citer; // folder iter", "\t Gtk.TreeIter fxiter; // file iter", "\tfor(var i =0 ; i < items.size; i++) {", "\t // print (\"cheking folder %s\\n\", items.get(i));", "\t var files = gpr.filesForOpen(items.get(i));", "\t ", "\t ", "\t ", "\t ", "\t ", "\t if (files.size < 1) {", "\t continue;", "\t }", "\t var nf = 0;", "\t for(var j =0 ; j < files.size; j++) {", "\t ", "\t \tif (filter != \"\") {", "\t \t\tvar ff = GLib.Path.get_basename(files.get(j)).down();", "\t \t\tvar dp = ff.last_index_of(\".\");", "\t\t \tif (!ff.substring(0,dp < 0 ? ff.length :dp ).contains(filter)) {", "\t\t \t\tcontinue;", "\t\t\t\t}", "\t\t ", "\t\t } ", "\t\t nf++;", "\t }", "\t if (nf < 1) {", "\t \tcontinue;", " \t} ", "\t ", "\t\t this.filemodel.el.append(out citer,null);", "\t\t this.filemodel.el.set(citer, 0, GLib.Path.get_basename(items.get(i)));", "\t\t this.filemodel.el.set(citer, 1, null); // parent (empty as it's a folder)", "\t\t", "\t\t", "\t // add the directory... items.get(i);", "\t //var x = new Xcls_folderitem(this,items.get(i));", "\t //this.fileitems.add(x);", "\t //this.filelayout.el.add_child(x.el);", "\t ", "\t ", "\t for(var j =0 ; j < files.size; j++) {", "\t ", "\t \tif (filter != \"\") {", "\t \t\tvar ff = GLib.Path.get_basename(files.get(j)).down();", "\t \t\tvar dp = ff.last_index_of(\".\");", "\t\t \tif (!ff.substring(0,dp < 0 ? ff.length :dp ).contains(filter)) {", "\t\t \t\tcontinue;", "\t\t\t\t}", "\t\t ", "\t\t } ", "\t ", "\t\t this.filemodel.el.insert(out fxiter,citer, -1);", "\t \tthis.filemodel.el.set(fxiter, 0, GLib.Path.get_basename(files.get(j))); // filename", "\t\t \tthis.filemodel.el.set(fxiter, 1, files.get(j)); // Folder?", "\t ", "\t ", "\t }", "\t ", "\t ", "\t //this.el.set_value(citer, 1, items.get(i) );", "\t}", " _this.fileview.el.expand_all();", "}" ], "| void onProjectSelected" : [ "(Project.Project project) ", "{", "\tif (this.in_onprojectselected) { ", "\t\treturn;", "\t}", "\tthis.in_onprojectselected = true;", "\t", "\t", "\tthis.selectedProject = project;", "\tproject.scanDirs();", "\t//this.clutterfiles.loadProject(proj);", "\t", "\t", "\t", "\t_this.iconsearch.el.text = \"\";", "\t", "\t ", "\t", " ", " ", " //this.project_title_name.el.text = pr.name;", " //this.project_title_path.el.text = pr.firstPath();", " ", " // file items contains a reference until we reload ...", " \t this.loadIconView();", " \t ", " \t ", " \t GLib.Timeout.add(500, () => {", "\t _this.iconsearch.el.grab_focus();", "\t return false;", " });", " ", " ", "", "\tthis.loadTreeView();", "\tthis.in_onprojectselected = false;\t", "}", "" ], "| void selectProject" : [ "(Project.Project project) {", " ", " var sel = _this.view.el.get_selection();", " ", " sel.unselect_all();", " ", " var found = false;", " _this.model.el.foreach((mod, path, iter) => {", " GLib.Value val;", " ", " mod.get_value(iter, 1, out val);", " if ( ( (Project.Project)val.get_object()).fn != project.fn) {", " print(\"SKIP %s != %s\\n\", ((Project.Project)val.get_object()).name , project.name);", " return false;//continue", " }", " sel.select_iter(iter);", "\t\tthis.selectedProject = project;", " this.onProjectSelected(project);", " found = true;", " return true;", " ", " ", " });", " if (!found) {", "\t print(\"tried to select %s, could not find it\", project.name);", " }", "}", "" ], "| void setMainWindow" : [ "(Xcls_MainWindow win) {", "\tthis.win = win;", "\tthis.el.set_transient_for(win.el);", "\tthis.el.application = BuilderApplication.singleton({});", "}", "" ], "| void show" : [ "(Gtk.Widget? on_el, Project.Project? project, bool new_window) {", "\t//this.editor.show( file, node, ptype, key);", "\t", "\tthis.new_window = new_window;", "\t\t// save...", "\tthis.load();", "\tif (on_el != null) {", "\t\tthis.el.set_parent(on_el);", "\t}", "\t // show first - so we can hide stuff later.\t", "\tif (project != null) {", "\t", "\t\tthis.selectProject(project);", "\t}", "\t", "\t", " // var win = this.win.el;", " // var w = win.get_width();", " // var h = win.get_height();", "", " // left tree = 250, editor area = 500?", " ", " // min 450?", "\t// max hieght ...", "\t", "\t//var ww = on_el.get_allocated_width();", "\t", "\t// width = should be max = w-ww , or 600 at best..?", "\t ", " //this.el.set_size_request( w - 100, h - 100); // same as parent...", "", "", "\t//this.el.set_autohide(true); // can hide", "\t//Gtk.Allocation rect;", "\t//on_el.get_allocation(out rect);", " // this.el.set_pointing_to(rect);", " //this.el.set_offset(200,0);", " //this.el.set_position(Gtk.PositionType.BOTTOM);", "\tthis.el.show();", "\t ", "}", "" ] } ], "name" : "PopoverFiles", "namespace" : "" }