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 " \tvar f = JsRender.JsRender.factory(_this.selectedProject.xtype, _this.selectedProject, \"\");",
142 " \t_this.win.windowstate.file_details.show( f, this.el, _this.new_window );",
143 " } catch (JsRender.Error e) {}",
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,
182 "this.css = new Gtk.CssProvider();",
184 "\tthis.css.load_from_data(\"#popover-files-view { font-size: 10px;}\");",
185 "} catch (Error e) {}",
186 "this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);",
191 "var selection = this.el.get_selection();",
192 "selection.set_mode( Gtk.SelectionMode.SINGLE);",
200 "Gtk.CssProvider css" : "",
204 "$ columns" : "typeof(string), typeof(Object)",
208 " this.el.set_sort_func(0, (mod,a,b) => {",
209 " GLib.Value ga, gb;",
210 " mod.get_value(a,0, out ga);",
211 " mod.get_value(b,0, out gb);",
213 " if ((string)ga == (string)gb) {",
216 " return (string)ga > (string)gb ? 1 : -1;",
223 "* pack" : "set_model",
226 "xtype" : "ListStore"
232 " this.el.add_attribute(_this.namecol.el , \"markup\", 0 );",
235 "* pack" : "append_column",
239 "* pack" : "pack_start,true",
241 "xtype" : "CellRendererText"
244 "utf8 title" : "Projects",
245 "xtype" : "TreeViewColumn"
251 " if (_this.is_loading) {",
255 " Gtk.TreeIter iter;",
256 " Gtk.TreeModel mod;",
258 " var s = this.el.get_selection();",
259 " if (!s.get_selected(out mod, out iter)) {",
265 " mod.get_value(iter, 1 , out gval);",
266 " var project = (Project.Project)gval.get_object();",
268 " _this.onProjectSelected(project);",
273 "string name" : "popover-files-view",
277 "xtype" : "ScrolledWindow"
281 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
282 "bool expand" : true,
284 "int width_request" : 600,
288 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
289 "bool hexpand" : true,
297 "this.css = new Gtk.CssProvider();",
299 "\tthis.css.load_from_data(\"#popover-files-iconsearch { font: monospace 10px;}\");",
300 "} catch (Error e) {}",
301 "this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);",
306 "Gtk.CssProvider css" : "",
307 "bool hexpand" : true,
312 "\tGLib.debug(\"Got '%s'\", this.el.text);",
314 "\tif (this.el.text.down() != _this.lastfilter) {",
315 "\t\t_this.loadIconView();",
316 "\t\t_this.loadTreeView();",
322 "string name" : "popover-files-iconsearch",
323 "string placeholder_text" : "type to filter results",
324 "xtype" : "SearchEntry"
332 " this.el.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);",
336 "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN",
337 "bool expand" : true,
339 "int width_request" : 600,
350 "bool has_tooltip" : true,
352 "int item_width" : 100,
353 "int markup_column" : 1,
354 "int pixbuf_column" : 3,
357 "$ columns" : "typeof(Object), typeof(string), typeof(string), typeof(Gdk.Pixbuf), typeof(Gdk.Pixbuf) ",
362 "xtype" : "ListStore"
369 " _this.win.windowstate.project = _this.selectedProject;",
373 " \tGtk.TreeIter iter;",
376 "\tthis.el.model.get_iter(out iter, path);",
380 " this.el.model.get_value(iter, 0 , out gval);",
381 " var file = (JsRender.JsRender)gval;",
384 " _this.win.windowstate.fileViewOpen(file, _this.new_window);",
391 "(x, y, keyboard_tooltip, tooltip) => {",
393 "\tGtk.TreePath path;",
394 "\tGtk.CellRenderer cell;",
395 "\t_this.iconview.el.get_item_at_pos(x,y + (int) _this.iconscroll.el.vadjustment.value, out path, out cell);",
398 " // GLib.debug(\"Tooltip? %d,%d scroll: %d\",x,y, (int)_this.iconscroll.el.vadjustment.value);",
401 "\tif (path == null) {",
402 "\t\t// GLib.debug(\"Tooltip? - no path\");",
406 "\tGtk.TreeIter iter;",
407 "\t_this.iconmodel.el.get_iter(out iter, path);",
409 "\t_this.iconmodel.el.get_value(iter, 4, out val);",
411 "\ttooltip.set_icon((Gdk.Pixbuf) val.get_object());",
412 "\t _this.iconview.el.set_tooltip_item(tooltip, path);",
421 "xtype" : "ScrolledWindow"
428 "* init" : " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
430 "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN",
431 "bool expand" : true,
432 "bool visible" : false,
433 "id" : "file_container",
434 "int width_request" : 100,
437 "$ enable_tree_lines" : true,
438 "$ headers_visible" : true,
442 "this.css = new Gtk.CssProvider();",
444 "\tthis.css.load_from_data(\"#popover-files-fileview { font-size: 12px;}\");",
445 "} catch (Error e) {}",
446 "this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);",
452 "var selection = this.el.get_selection();",
453 "selection.set_mode( Gtk.SelectionMode.SINGLE);",
461 "Gtk.CssProvider css" : "",
462 "bool activate_on_single_click" : false,
463 "bool expand" : true,
467 "$ columns" : "typeof(string), typeof(string)",
471 " this.el.set_sort_func(0, (mod,a,b) => {",
472 " GLib.Value ga, gb;",
473 " mod.get_value(a,0, out ga);",
474 " mod.get_value(b,0, out gb);",
476 " if ((string)ga == (string)gb) {",
479 " return (string)ga > (string)gb ? 1 : -1;",
486 "* pack" : "set_model",
489 "xtype" : "TreeStore"
495 " this.el.add_attribute(_this.filenamecol.el , \"markup\", 0 );",
498 "* pack" : "append_column",
502 "* pack" : "pack_start,true",
503 "id" : "filenamecol",
504 "xtype" : "CellRendererText"
507 "utf8 title" : "File",
508 "xtype" : "TreeViewColumn"
515 " if (_this.is_loading) {",
519 " Gtk.TreeIter iter;",
520 " Gtk.TreeModel mod;",
522 " var s = this.el.get_selection();",
523 " if (!s.get_selected(out mod, out iter)) {",
529 " mod.get_value(iter, 1 , out gval);",
530 " var project = (Project.Project)gval.get_object();",
532 " _this.project_selected(project);",
539 "\tGtk.TreeIter iter;",
542 "\tthis.el.model.get_iter(out iter, path);",
546 " this.el.model.get_value(iter, 1 , out gval);",
547 " var fn = (string)gval;",
548 " if (fn.length < 1) {",
551 " _this.win.windowstate.project = _this.selectedProject;",
554 "\t\tvar f = JsRender.JsRender.factory(\"PlainFile\", _this.selectedProject, fn);",
555 "\t\t_this.win.windowstate.fileViewOpen(f, _this.new_window);",
556 "\t} catch (JsRender.Error e) {} ",
561 "string name" : "popover-files-fileview",
565 "xtype" : "ScrolledWindow"
579 "\t//if (project != null) {",
580 "//\t\tthis.selectProject(project);",
582 " \tif (_this.win.windowstate.project == null) {",
583 " \t\tthis.el.show();",
588 "string lastfilter" : "\"\"",
594 " if (_this.is_loaded) {",
597 " _this.is_loading = true;",
599 " _this.is_loaded = true;",
601 " Project.Project.loadAll();",
602 " var projects = Project.Project.allProjectsByName();",
604 " Gtk.TreeIter iter;",
605 " var m = this.model.el;",
608 " for (var i = 0; i < projects.size; i++) {",
609 " m.append(out iter);",
610 " m.set(iter, 0,projects.get(i).name );",
612 " var o = GLib.Value(typeof(Object));",
613 " o.set_object((Object)projects.get(i));",
615 " m.set_value(iter, 1, o);",
618 " m.set_sort_column_id(0, Gtk.SortType.ASCENDING);",
619 " _this.is_loading = false; ",
623 "| void loadIconView" : [
626 "\tif (_this.image_cache == null) {",
627 "\t\t_this.image_cache = new Gee.HashMap<string,Gdk.Pixbuf>();",
630 "\t var project = this.selectedProject;",
632 " \t Gdk.Pixbuf pixbuf = null;",
633 " \t Gdk.Pixbuf bigpixbuf = null;",
634 "\t Gtk.TreeIter iter;",
635 " var m = this.iconmodel.el;",
639 " \tvar filter = _this.iconsearch.el.text.down();",
640 " \tthis.lastfilter = filter;",
642 " var fiter = project.sortedFiles().list_iterator();",
646 "\t if (_this.missing_thumb_pixbuf == null) {",
647 "\t var icon_theme = Gtk.IconTheme.get_default ();",
648 "\t _this.missing_thumb_pixbuf = icon_theme.load_icon (\"package-x-generic\", 92, 0);",
649 "\t _this.missing_thumb_pixbuf.ref();",
653 "\t } catch (Error e) {",
659 " while (fiter.next()) {",
661 " var file = fiter.get();",
662 " if (filter != \"\") {",
663 " \tif (!file.name.down().contains(filter)) {",
671 " m.append(out iter);",
673 " m.set(iter, 0,file ); // zero contains the file reference",
674 " m.set(iter, 1,file.nickType() + \"\\n\" + file.nickName()); // marked up title?",
675 " m.set(iter, 2,file.nickType() ); // file type?",
680 "\t pixbuf = file.getIcon(92);",
681 "\t\tbigpixbuf = file.getIcon(368);",
685 " if (pixbuf == null) {",
686 " \tGLib.debug(\"PIXBUF is null? %s\", file.name);",
687 "\t\t pixbuf = _this.missing_thumb_pixbuf;",
688 " \tbigpixbuf = _this.missing_thumb_pixbuf;",
693 " m.set(iter, 3,pixbuf);",
694 " m.set(iter, 4,bigpixbuf);",
696 " // this needs to add to the iconview?",
698 " //var a = new Xcls_fileitem(this,fiter.get());",
699 " //this.fileitems.add(a);",
701 " //this.filelayout.el.add_child(a.el);",
705 "| void loadTreeView" : [
707 " var project = this.selectedProject;",
709 " this.filemodel.el.clear();",
713 " if (!(project is Project.Gtk)) {",
714 " //print (\"not gtk... skipping files\");",
715 " this.file_container.el.hide();",
721 " var filter = _this.iconsearch.el.text.down();",
723 " this.file_container.el.show();",
724 " var gpr = (Project.Gtk)project;",
725 " var def = gpr.compilegroups.get(\"_default_\");",
726 " // not sure why the above is returng null!??",
727 " if (def == null) {",
728 " \t\tdef = new Project.GtkValaSettings(\"_default_\"); ",
729 " \t\tgpr.compilegroups.set(\"_default_\", def);",
731 "\t var items = def.sources;",
733 "\t Gtk.TreeIter citer; // folder iter",
734 "\t Gtk.TreeIter fxiter; // file iter",
735 "\tfor(var i =0 ; i < items.size; i++) {",
736 "\t // print (\"cheking folder %s\\n\", items.get(i));",
737 "\t var files = gpr.filesForOpen(items.get(i));",
743 "\t if (files.size < 1) {",
747 "\t for(var j =0 ; j < files.size; j++) {",
749 "\t \tif (filter != \"\") {",
750 "\t \t\tvar ff = GLib.Path.get_basename(files.get(j)).down();",
751 "\t \t\tvar dp = ff.last_index_of(\".\");",
752 "\t\t \tif (!ff.substring(0,dp < 0 ? ff.length :dp ).contains(filter)) {",
753 "\t\t \t\tcontinue;",
763 "\t\t this.filemodel.el.append(out citer,null);",
764 "\t\t this.filemodel.el.set(citer, 0, GLib.Path.get_basename(items.get(i)));",
765 "\t\t this.filemodel.el.set(citer, 1, null); // parent (empty as it's a folder)",
768 "\t // add the directory... items.get(i);",
769 "\t //var x = new Xcls_folderitem(this,items.get(i));",
770 "\t //this.fileitems.add(x);",
771 "\t //this.filelayout.el.add_child(x.el);",
774 "\t for(var j =0 ; j < files.size; j++) {",
776 "\t \tif (filter != \"\") {",
777 "\t \t\tvar ff = GLib.Path.get_basename(files.get(j)).down();",
778 "\t \t\tvar dp = ff.last_index_of(\".\");",
779 "\t\t \tif (!ff.substring(0,dp < 0 ? ff.length :dp ).contains(filter)) {",
780 "\t\t \t\tcontinue;",
785 "\t\t this.filemodel.el.insert(out fxiter,citer, -1);",
786 "\t \tthis.filemodel.el.set(fxiter, 0, GLib.Path.get_basename(files.get(j))); // filename",
787 "\t\t \tthis.filemodel.el.set(fxiter, 1, files.get(j)); // Folder?",
793 "\t //this.el.set_value(citer, 1, items.get(i) );",
795 " _this.fileview.el.expand_all();",
798 "| void onProjectSelected" : [
799 "(Project.Project project) ",
801 "\tif (this.in_onprojectselected) { ",
804 "\tthis.in_onprojectselected = true;",
807 "\tthis.selectedProject = project;",
808 "\tproject.scanDirs();",
809 "\t//this.clutterfiles.loadProject(proj);",
813 "\t_this.iconsearch.el.text = \"\";",
819 " //this.project_title_name.el.text = pr.name;",
820 " //this.project_title_path.el.text = pr.firstPath();",
822 " // file items contains a reference until we reload ...",
823 " \t this.loadIconView();",
826 " \t GLib.Timeout.add(500, () => {",
827 "\t _this.iconsearch.el.grab_focus();",
833 "\tthis.loadTreeView();",
834 "\tthis.in_onprojectselected = false;\t",
838 "| void selectProject" : [
839 "(Project.Project project) {",
841 " var sel = _this.view.el.get_selection();",
843 " sel.unselect_all();",
845 " var found = false;",
846 " _this.model.el.foreach((mod, path, iter) => {",
849 " mod.get_value(iter, 1, out val);",
850 " if ( ( (Project.Project)val.get_object()).fn != project.fn) {",
851 " print(\"SKIP %s != %s\\n\", ((Project.Project)val.get_object()).name , project.name);",
852 " return false;//continue",
854 " sel.select_iter(iter);",
855 "\t\tthis.selectedProject = project;",
856 " this.onProjectSelected(project);",
863 "\t print(\"tried to select %s, could not find it\", project.name);",
868 "| void setMainWindow" : [
869 "(Xcls_MainWindow win) {",
876 "(Gtk.Widget on_el, Project.Project? project, bool new_window) {",
877 "\t//this.editor.show( file, node, ptype, key);",
879 "\tthis.new_window = new_window;",
882 "\tthis.el.show_all(); // show first - so we can hide stuff later.\t",
883 "\tif (project != null) {",
885 "\t\tthis.selectProject(project);",
890 " this.win.el.get_size(out w, out h);",
892 " // left tree = 250, editor area = 500?",
895 "\t// max hieght ...",
897 "\t//var ww = on_el.get_allocated_width();",
899 "\t// width = should be max = w-ww , or 600 at best..?",
901 " this.el.set_size_request( w, h); // same as parent...",
904 "\tthis.el.set_modal(true);",
905 "\tthis.el.set_relative_to(on_el);",
915 "name" : "PopoverFiles",
917 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverFiles.bjs",