From 51ba030a987ba20ae5e1fbafb29709de4311e17b Mon Sep 17 00:00:00 2001 From: Alan Date: Fri, 19 Jan 2024 15:33:22 +0800 Subject: [PATCH] meson.build.o7QLX02 Attribute changed meson.build.o7QLX02 src/Application.vala.oueOPYm Attribute changed src/Application.vala.oueOPYm src/Builder4/About.bjs.ohhfP9G Attribute changed src/Builder4/About.bjs.ohhfP9G src/Builder4/About.vala.oQqbnk1 Attribute changed src/Builder4/About.vala.oQqbnk1 src/Builder4/DialogFiles.bjs.olqtmul Attribute changed src/Builder4/DialogFiles.bjs.olqtmul src/Builder4/DialogFiles.vala.o4yEZGF Attribute changed src/Builder4/DialogFiles.vala.o4yEZGF src/Builder4/Editor.bjs.o73T50Z Attribute changed src/Builder4/Editor.bjs.o73T50Z src/Lsp.vala.oBBEcSp Attribute changed src/Lsp.vala.oBBEcSp src/Makefile.am.oWZHMmJ Attribute changed src/Makefile.am.oWZHMmJ src/Builder4/Editor.vala.oU2K3jk Attribute changed src/Builder4/Editor.vala.oU2K3jk src/Builder4/GtkView.bjs.oHdUFEE Attribute changed src/Builder4/GtkView.bjs.oHdUFEE src/Builder4/GtkView.vala.oemSKTY Attribute changed src/Builder4/GtkView.vala.oemSKTY src/Builder4/MainWindow.bjs.oRluDaj Attribute changed src/Builder4/MainWindow.bjs.oRluDaj src/Builder4/MainWindow.vala.o6abMqD Attribute changed src/Builder4/MainWindow.vala.o6abMqD src/Builder4/ValaProjectSettingsPopover.bjs.olg2TVX Attribute changed src/Builder4/ValaProjectSettingsPopover.bjs.olg2TVX src/Builder4/ValaProjectSettingsPopover.vala.oSEaYpi Attribute changed src/Builder4/ValaProjectSettingsPopover.vala.oSEaYpi src/Builder4/WindowLeftProps.bjs.o7LyQMC Attribute changed src/Builder4/WindowLeftProps.bjs.o7LyQMC src/Builder4/WindowLeftProps.vala.osUPTcX Attribute changed src/Builder4/WindowLeftProps.vala.osUPTcX src/Builder4/WindowLeftTree.bjs.ozROCGg Attribute changed src/Builder4/WindowLeftTree.bjs.ozROCGg src/Builder4/WindowLeftTree.vala.o6TNZ9z Attribute changed src/Builder4/WindowLeftTree.vala.o6TNZ9z src/Builder4/WindowRooView.bjs.obkwkvT Attribute changed src/Builder4/WindowRooView.bjs.obkwkvT src/Builder4/WindowRooView.vala.oupErTc Attribute changed src/Builder4/WindowRooView.vala.oupErTc src/Builder4/WindowState.vala.opE7lww Attribute changed src/Builder4/WindowState.vala.opE7lww src/Builder4/About.bjs src/Builder4/About.vala src/Builder4/DialogFiles.bjs src/Builder4/DialogFiles.vala src/Builder4/Editor.bjs src/Builder4/Editor.vala src/Builder4/GtkView.bjs src/Builder4/GtkView.vala src/Builder4/MainWindow.bjs src/Builder4/MainWindow.vala src/Builder4/ValaProjectSettingsPopover.bjs src/Builder4/ValaProjectSettingsPopover.vala src/Builder4/WindowLeftProps.bjs src/Builder4/WindowLeftProps.vala src/Builder4/WindowLeftTree.bjs src/Builder4/WindowLeftTree.vala src/Builder4/WindowRooView.bjs src/Builder4/WindowRooView.vala src/Builder4/WindowState.vala src/JsRender/Gtk.vala.o2n1F8P Attribute changed src/JsRender/Gtk.vala.o2n1F8P src/JsRender/JsRender.vala.o7fcEK9 Attribute changed src/JsRender/JsRender.vala.o7fcEK9 src/JsRender/Node.vala.omjE5lt Attribute changed src/JsRender/Node.vala.omjE5lt src/JsRender/NodeToGlade.vala.ov3LSRM Attribute changed src/JsRender/NodeToGlade.vala.ov3LSRM src/JsRender/NodeToVala.vala.ogbyln6 Attribute changed src/JsRender/NodeToVala.vala.ogbyln6 src/JsRender/Gtk.vala src/JsRender/JsRender.vala src/JsRender/Node.vala src/JsRender/NodeToGlade.vala src/JsRender/NodeToVala.vala src/Palete/CompileError.vala.oTJC1U2 Attribute changed src/Palete/CompileError.vala.oTJC1U2 src/Palete/CompletionProvider.vala.ow1Putm Attribute changed src/Palete/CompletionProvider.vala.ow1Putm src/Palete/LanguageClient.vala.ovgsk1F Attribute changed src/Palete/LanguageClient.vala.ovgsk1F src/Palete/LanguageClientDummy.vala.o2EYIxZ Attribute changed src/Palete/LanguageClientDummy.vala.o2EYIxZ src/Palete/LanguageClientVala.vala.oJkVp4i Attribute changed src/Palete/LanguageClientVala.vala.oJkVp4i src/Palete/ValaCompileRequest.vala.os3UTNC Attribute changed src/Palete/ValaCompileRequest.vala.os3UTNC src/Palete/ValaSource.vala.oND2UwW Attribute changed src/Palete/ValaSource.vala.oND2UwW src/Palete/CompileError.vala src/Palete/CompletionProvider.vala src/Palete/LanguageClient.vala src/Palete/LanguageClientDummy.vala src/Palete/LanguageClientVala.vala src/Palete/ValaCompileRequest.vala src/Palete/ValaSource.vala meson.build src/Spawn.vala.oVndLod Attribute changed src/Spawn.vala.oVndLod src/Application.vala src/Lsp.vala src/Makefile.am src/Spawn.vala src/codegen/valaccodecompiler.vala.o2utUax Attribute changed src/codegen/valaccodecompiler.vala.o2utUax src/codegen/valaccodecompiler.vala src/Project/Gtk.vala.o4D83fg Attribute changed src/Project/Gtk.vala.o4D83fg src/Project/GtkValaSettings.vala.oBuRPYz Attribute changed src/Project/GtkValaSettings.vala.oBuRPYz src/Project/Project.vala.o48SLGT Attribute changed src/Project/Project.vala.o48SLGT src/Project/Gtk.vala src/Project/GtkValaSettings.vala src/Project/Project.vala --- meson.build | 1 - src/Application.vala | 135 +- src/Builder4/About.bjs | 7 +- src/Builder4/About.vala | 73 +- src/Builder4/DialogFiles.bjs | 95 +- src/Builder4/DialogFiles.vala | 4555 +++++++++--------- src/Builder4/Editor.bjs | 104 +- src/Builder4/Editor.vala | 2938 +++++------ src/Builder4/GtkView.bjs | 87 +- src/Builder4/GtkView.vala | 2778 +++++------ src/Builder4/MainWindow.bjs | 43 +- src/Builder4/MainWindow.vala | 2841 +++++------ src/Builder4/ValaProjectSettingsPopover.bjs | 18 +- src/Builder4/ValaProjectSettingsPopover.vala | 3615 +++++++------- src/Builder4/WindowLeftProps.bjs | 18 +- src/Builder4/WindowLeftProps.vala | 4268 ++++++++-------- src/Builder4/WindowLeftTree.bjs | 6 +- src/Builder4/WindowLeftTree.vala | 3760 +++++++-------- src/Builder4/WindowRooView.bjs | 188 +- src/Builder4/WindowRooView.vala | 4246 ++++++++-------- src/Builder4/WindowState.vala | 11 +- src/JsRender/Gtk.vala | 2 + src/JsRender/JsRender.vala | 30 +- src/JsRender/Node.vala | 5 +- src/JsRender/NodeToGlade.vala | 2 +- src/JsRender/NodeToVala.vala | 20 +- src/Lsp.vala | 34 +- src/Makefile.am | 1 - src/Palete/CompileError.vala | 4 +- src/Palete/CompletionProvider.vala | 115 +- src/Palete/LanguageClient.vala | 329 +- src/Palete/LanguageClientDummy.vala | 3 + src/Palete/LanguageClientVala.vala | 10 +- src/Palete/ValaCompileRequest.vala | 46 +- src/Palete/ValaSource.vala | 17 +- src/Project/Gtk.vala | 21 +- src/Project/GtkValaSettings.vala | 18 +- src/Project/Project.vala | 17 +- src/Spawn.vala | 2 +- src/codegen/valaccodecompiler.vala | 2 +- 40 files changed, 15614 insertions(+), 14851 deletions(-) diff --git a/meson.build b/meson.build index 9e9887728..471a2b3ed 100644 --- a/meson.build +++ b/meson.build @@ -119,7 +119,6 @@ roobuilder_src = files([ 'src/Palete/Palete.vala', 'src/Palete/Roo.vala', 'src/Palete/ValaSourceCompiler.vala', - 'src/Palete/ValaSource.vala', 'src/Palete/VapiParser.vala', 'src/Builder4/WindowLeftTree.vala', 'src/Builder4/PopoverAddProp.vala', diff --git a/src/Application.vala b/src/Application.vala index 41f1c0ae3..bf402782a 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -400,20 +400,45 @@ var ar = cur_project.sortedFiles(); foreach(var file in ar) { - string oldstr; + + if (file is JsRender.PlainFile) { + continue; + } + file.loadItems(); var oldfn = file.targetName(); - GLib.FileUtils.get_contents(oldfn, out oldstr); + + print("\n\n\n\nFile : %s\n", oldfn); + //GLib.FileUtils.get_contents(oldfn, out oldstr); var outstr = file.toSourceCode(); + var bad = false; + // check line numbers: + var bits = outstr.split("\n"); + var end = bits.length; + for(var i = 0;i < end; i++) { + print("%i : %s\n", i+1 , bits[i]); + if (!bad && bits[i].has_prefix("/*") && !bits[i].has_prefix("/*%d*/".printf(i+1))) { + end = i + 5 > bits.length ? bits.length: (i + 5); + print ("^^^^ mismatch\null"); + bad = true; + } + + + } + if (bad) { + GLib.error("got bad file"); + } + /* if (outstr != oldstr) { GLib.FileUtils.set_contents("/tmp/" + file.name + ".out", outstr); print("meld %s /tmp/%s\n", oldfn, file.name + ".out"); //GLib.Process.exit(Posix.EXIT_SUCCESS); } - print("# Files match %s\n", file.name); +*.* */ + //print("# Files match %s\n", file.name); } } catch (FileError e) { GLib.debug("Got error %s", e.message); @@ -431,10 +456,7 @@ if (file == null) { // then compile them all, and compare them... - - - - + GLib.error("missing file %s in project %s", BuilderApplication.opt_bjs_compile, cur_project.name); } @@ -508,6 +530,11 @@ // it's ready.. ls.document_open(file); + + ls.syntax.begin(file, (obj,res) => { + ls.syntax.end(res); + + }); return false; }); @@ -641,8 +668,33 @@ flutter-project - was try and read flutter data (but desnt work.) } + static int queue_update_compile_countdown = -1; + static uint queue_update_compile_id = 0; + public static void updateCompileResults( ) { + queue_update_compile_countdown = 4; // 1 second after last call. + if (queue_update_compile_id == 0) { + queue_update_compile_id = GLib.Timeout.add(250, () => { + if (queue_update_compile_countdown < 0) { + return true; + } + queue_update_compile_countdown--; + if (queue_update_compile_countdown < 0) { + realUpdateCompileResults(); + } + + return true; + }); + } + } + + + public static void realUpdateCompileResults( ) + { + + + foreach(var ww in BuilderApplication.windows) { if (ww == null || ww.windowstate == null || ww.windowstate.project ==null) { continue; @@ -657,11 +709,74 @@ flutter-project - was try and read flutter data (but desnt work.) } } - public static void showSpinner(bool state) + + public static void showSpinnerLspLog(Palete.LanguageClientAction action, string message) { + + var msg = action.to_string() + " " + message; + switch(action) { + + case Palete.LanguageClientAction.INIT: + case Palete.LanguageClientAction.LAUNCH: + case Palete.LanguageClientAction.ACCEPT: + BuilderApplication.showSpinner( "software-update-available", msg ); + return; + + case Palete.LanguageClientAction.DIAG: + BuilderApplication.showSpinner( "format-justify-fill", msg); + return; + + case Palete.LanguageClientAction.OPEN: + BuilderApplication.showSpinner( "document-open", msg); + return; + case Palete.LanguageClientAction.SAVE: + BuilderApplication.showSpinner( "document-save", msg); + return; + case Palete.LanguageClientAction.CLOSE: + BuilderApplication.showSpinner( "window.close", msg); + return; + case Palete.LanguageClientAction.CHANGE: + BuilderApplication.showSpinner( "format-text-direction-ltr", msg); + return; + case Palete.LanguageClientAction.TERM: + BuilderApplication.showSpinner( "media-playback-stop", msg); + return; + case Palete.LanguageClientAction.COMPLETE: + BuilderApplication.showSpinner( "mail-send-recieve", msg); + return; + + case Palete.LanguageClientAction.COMPLETE_REPLY: + BuilderApplication.showSpinner( "face-cool", msg); + return; + + case Palete.LanguageClientAction.RESTART: + case Palete.LanguageClientAction.ERROR: + case Palete.LanguageClientAction.ERROR_START: + case Palete.LanguageClientAction.ERROR_RPC: + case Palete.LanguageClientAction.ERROR_REPLY: + BuilderApplication.showSpinner( "software-update-urgent", msg ); + return; + + case Palete.LanguageClientAction.EXIT: + BuilderApplication.showSpinner( "face-sick", msg); + return; + + + } + } + + public static void showSpinner(string icon, string tooltip = "") { + + // events: + // doc change send: - spinner - + + + // ?? restart = software-update-urgent - crash? + + foreach (var win in BuilderApplication.windows) { - if (state) { - win.statusbar_compile_spinner.start(); + if (icon != "") { + win.statusbar_compile_spinner.start(icon, tooltip); } else { win.statusbar_compile_spinner.stop(); } diff --git a/src/Builder4/About.bjs b/src/Builder4/About.bjs index 486d44982..8f560d888 100644 --- a/src/Builder4/About.bjs +++ b/src/Builder4/About.bjs @@ -15,8 +15,11 @@ "| void show" : [ "(Gtk.Window parent) {", "\tthis.el.application = parent.application;", - " this.el.set_transient_for(parent);", - " this.el.show();", + "\tthis.el.set_transient_for(parent);", + "\tthis.el.show();", + " ", + "\t ", + "\t", "}" ] } diff --git a/src/Builder4/About.vala b/src/Builder4/About.vala index 864f20684..543b7ac7d 100644 --- a/src/Builder4/About.vala +++ b/src/Builder4/About.vala @@ -1,42 +1,45 @@ - static About _About; +static About _About; - public class About : Object - { - public Gtk.AboutDialog el; - private About _this; +public class About : Object +{ + public Gtk.AboutDialog el; + private About _this; - public static About singleton() - { - if (_About == null) { - _About= new About(); - } - return _About; - } + public static About singleton() + { + if (_About == null) { + _About= new About(); + } + return _About; + } - // my vars (def) + // my vars (def) - // ctor - public About() - { - _this = this; - this.el = new Gtk.AboutDialog(); + // ctor + public About() + { + _this = this; + this.el = new Gtk.AboutDialog(); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.program_name = "roobuilder"; - this.el.license = "LGPL"; - this.el.authors = { "Alan Knowles" }; - this.el.version = "4.4.2"; - this.el.website = "https://github.com/roojs/roobuilder"; - this.el.modal = true; - this.el.copyright = "LGPL"; - } + // set gobject values + this.el.program_name = "roobuilder"; + this.el.license = "LGPL"; + this.el.authors = { "Alan Knowles" }; + this.el.version = "4.4.2"; + this.el.website = "https://github.com/roojs/roobuilder"; + this.el.modal = true; + this.el.copyright = "LGPL"; + } - // user defined functions - public void show (Gtk.Window parent) { - this.el.application = parent.application; - this.el.set_transient_for(parent); - this.el.show(); - } - } + // user defined functions + public void show (Gtk.Window parent) { + this.el.application = parent.application; + this.el.set_transient_for(parent); + this.el.show(); + + + + } +} diff --git a/src/Builder4/DialogFiles.bjs b/src/Builder4/DialogFiles.bjs index 647b18541..ec42b3329 100644 --- a/src/Builder4/DialogFiles.bjs +++ b/src/Builder4/DialogFiles.bjs @@ -64,7 +64,9 @@ " ", "\tthis.css = new Gtk.CssProvider();", " ", - "\tthis.css.load_from_string(\"#project-list { font-size: 12px;}\");", + "\tthis.css.load_from_string(\"", + "\t\t#project-list { font-size: 12px;}", + "\t\");", "", "\tGtk.StyleContext.add_provider_for_display(", "\t\tthis.el.get_display(),", @@ -526,7 +528,15 @@ " ", "\tthis.css = new Gtk.CssProvider();", " ", - "\tthis.css.load_from_string(\"#file-list { font-size: 12px;}\");", + "\tthis.css.load_from_string(\"", + "#file-list { font-size: 12px;}", + "#file-list indent {", + "-gtk-icon-size : 2px;", + "}", + "#file-list indent:nth-last-child(2) {", + "min-width: 24px;", + "}", + "\");", "", "\tGtk.StyleContext.add_provider_for_display(", "\t\tthis.el.get_display(),", @@ -748,43 +758,51 @@ "listeners" : { "bind" : [ "(listitem) => {", - "\t //GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());", - "\t", - "\t", "\t", - "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();", - "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();", - "\t ", + "\t //GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());", + " \t", + " \t", + " \t", + " \t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();", + " \tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();", + " \t ", + " \tvar hbox = (Gtk.Box) expand.child;", " ", - "\tvar lbl = (Gtk.Label) expand.child;", "\t", - "\t if (lbl.label != \"\") { // do not update", - "\t \treturn;", - " \t}", - "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();", - "\t//GLib.debug(\"LR = %s\", lr.get_type().name());", + "\t\tvar img = (Gtk.Image) hbox.get_first_child();", + "\t\tvar lbl = (Gtk.Label) img.get_next_sibling();", "", - "\t", - "\tvar jr =(JsRender.JsRender) lr.get_item();", - "\t//GLib.debug(\"JR = %s\", jr.get_type().name());\t\t", - "\t", - "\t if (jr == null) {", - "\t\t GLib.debug(\"Problem getting item\"); ", - "\t\t return;", - "\t }", - "\t//GLib.debug(\"change %s to %s\", lbl.label, np.name);", - "\tlbl.label = jr.name; // for dir's we could hsow the sub path..", - "\tlbl.tooltip_markup = jr.path;", - "\t ", - " expand.set_hide_expander( jr.xtype != \"Dir\" );", - " \t expand.set_list_row(lr);", " ", - " \t ", - " \t// bind image...", - " \t", - "}", + " \t", + " \t if (lbl.label != \"\") { // do not update", + " \t \treturn;", + " \t}", + " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();", + " \t//GLib.debug(\"LR = %s\", lr.get_type().name());", + " ", + " \t", + " \tvar jr =(JsRender.JsRender) lr.get_item();", + " \t//GLib.debug(\"JR = %s\", jr.get_type().name());\t\t", + " \t", + " \t if (jr == null) {", + " \t\t GLib.debug(\"Problem getting item\"); ", + " \t\t return;", + " \t }", "", + "\t\tjr.bind_property(\"icon\",", + " img, \"gicon\",", + " GLib.BindingFlags.SYNC_CREATE);", "", + " \t//GLib.debug(\"change %s to %s\", lbl.label, np.name);", + " \tlbl.label = jr.name; // for dir's we could hsow the sub path..", + " \tlbl.tooltip_markup = jr.path;", + " \t ", + " expand.set_hide_expander( jr.xtype != \"Dir\" );", + " \t expand.set_list_row(lr);", + " ", + " \t ", + " \t// bind image...", + "}", "" ], "setup" : [ @@ -794,7 +812,9 @@ "\t ", "\texpand.set_indent_for_depth(true);", "\texpand.set_indent_for_icon(true);", - "\t ", + "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);", + "\tvar icon = new Gtk.Image();", + "\ticon.margin_end = 4;", "\tvar lbl = new Gtk.Label(\"\");", "\tlbl.use_markup = true;", "\t", @@ -802,8 +822,9 @@ " \tlbl.justify = Gtk.Justification.LEFT;", " \tlbl.xalign = 0;", "", - " ", - "\texpand.set_child(lbl);", + " \thbox.append(icon);", + "\thbox.append(lbl);", + "\texpand.set_child(hbox);", "\t((Gtk.ListItem)listitem).set_child(expand);", "\t((Gtk.ListItem)listitem).activatable = false;", "}", @@ -1164,10 +1185,10 @@ "() {", " // clear list...", " ", - " ", + " ", " _this.is_loading = true;", " ", - " ", + "", " Project.Project.loadAll();", " _this.project_list.el.set_model(new Gtk.SingleSelection(null));", " Project.Project.loadIntoStore(this.projectmodel.el);", diff --git a/src/Builder4/DialogFiles.vala b/src/Builder4/DialogFiles.vala index 0d3723bf0..862724627 100644 --- a/src/Builder4/DialogFiles.vala +++ b/src/Builder4/DialogFiles.vala @@ -1,1519 +1,1529 @@ - static DialogFiles _DialogFiles; - - public class DialogFiles : Object - { - public Gtk.Window el; - private DialogFiles _this; - - public static DialogFiles singleton() - { - if (_DialogFiles == null) { - _DialogFiles= new DialogFiles(); - } - return _DialogFiles; - } - public Xcls_mainpane mainpane; - public Xcls_projectscroll projectscroll; - public Xcls_project_list project_list; - public Xcls_projectselection projectselection; - public Xcls_projectsort projectsort; - public Xcls_projectmodel projectmodel; - public Xcls_filepane filepane; - public Xcls_searchbox searchbox; - public Xcls_iconscroll iconscroll; - public Xcls_gridview gridview; - public Xcls_iconsel iconsel; - public Xcls_gridsort gridsort; - public Xcls_gridmodel gridmodel; - public Xcls_iconsearch iconsearch; - public Xcls_treescroll treescroll; - public Xcls_treeview treeview; - public Xcls_treeselmodel treeselmodel; - public Xcls_treelistsort treelistsort; - public Xcls_treelistmodel treelistmodel; - public Xcls_treemodel treemodel; - public Xcls_treefilter treefilter; - public Xcls_name name; - public Xcls_btn_newproj btn_newproj; - public Xcls_btn_projprop btn_projprop; - public Xcls_btn_delproj btn_delproj; - public Xcls_btn_addfile btn_addfile; - public Xcls_btn_delfile btn_delfile; - - // my vars (def) - public Xcls_MainWindow win; - public string lastfilter; - public bool in_onprojectselected; - public bool is_loading; - public bool new_window; - public Project.Project selectedProject; - public Gdk.Pixbuf missing_thumb_pixbuf; - public Gee.HashMap image_cache; - - // ctor - public DialogFiles() - { - _this = this; - this.el = new Gtk.Window(); - - // my vars (dec) - this.in_onprojectselected = false; - this.is_loading = false; - this.new_window = false; - - // set gobject values - this.el.title = "Select Project / File"; - this.el.name = "DialogFiles"; - this.el.default_height = 550; - this.el.default_width = 1000; - this.el.modal = true; - var child_1 = new Xcls_Box2( _this ); - this.el.child = child_1.el; - var child_2 = new Xcls_HeaderBar44( _this ); - this.el.titlebar = child_2.el; - } - - // user defined functions - public void onProjectSelected (Project.Project? project) - { - if (this.in_onprojectselected) { - return; - } - this.selectedProject = project; - - if (project == null) { - GLib.debug("Hide project files"); - _this.mainpane.el.set_end_child(null); - _this.filepane.el.hide(); - return; - - } - - GLib.debug("Show project files"); - _this.mainpane.el.set_end_child(_this.filepane.el); - - _this.filepane.el.show(); - this.in_onprojectselected = true; - - - - project.load(); - - - _this.searchbox.el.text = ""; - _this.gridview.el.set_model(new Gtk.SingleSelection(null)); - _this.selectedProject.loadFilesIntoStore(_this.gridmodel.el); - _this.iconsel.el.selected = Gtk.INVALID_LIST_POSITION; - - _this.gridview.el.set_model(_this.iconsel.el); - - - GLib.Timeout.add(500, () => { - _this.iconsel.el.selected = Gtk.INVALID_LIST_POSITION; - _this.treeselmodel.el.selected = Gtk.INVALID_LIST_POSITION; - - _this.searchbox.el.grab_focus(); - return false; - }); - _this.treeview.el.set_model(new Gtk.SingleSelection(null)); - - this.selectedProject.loadDirsIntoStore(_this.treemodel.el); - - _this.treeview.el.set_model(_this.treeselmodel.el); - - _this.treeselmodel.el.selected = Gtk.INVALID_LIST_POSITION; - this.treescroll.el.vadjustment.value = 0; - this.in_onprojectselected = false; - } - public void selectProject (Project.Project? project) { - - - - var sm = this.projectselection.el; - if (project == null) { - sm.selected = Gtk.INVALID_LIST_POSITION; - this.onProjectSelected(null); - return; - } - - - for (var i =0; i < sm.n_items; i++) { - var p = (Project.Project) sm.get_item(i); - if (p.path == project.path) { - GLib.debug("Select Project %s => %d", project.name, i); - sm.selected = i; - break; - } - } - - } - public void show (Project.Project? project, bool new_window) { - - this.new_window = new_window; - - this.projectscroll.el.vadjustment.value = 0; // scroll to top? - - - //var win = this.win.el; - //var w = win.get_width(); - //var h = win.get_height(); - - - this.el.show(); - this.load(); - this.selectProject(project); - this.onProjectSelected(project); //?? twice? - - GLib.Timeout.add(500, () => { - if (project == null) { - _this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION; - this.onProjectSelected(null); - - } - this.el.set_size_request( 800 , 750); // ?? based on default - return false; - }); - - }// - public void load () { - // clear list... - - - _this.is_loading = true; - - - Project.Project.loadAll(); - _this.project_list.el.set_model(new Gtk.SingleSelection(null)); - Project.Project.loadIntoStore(this.projectmodel.el); - - _this.project_list.el.set_model(_this.projectselection.el); - - _this.is_loading = false; - - _this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION; - _this.btn_delfile.el.hide(); - - - } - public class Xcls_Box2 : Object - { - public Gtk.Box el; - private DialogFiles _this; - - - // my vars (def) - public bool expand; - - // ctor - public Xcls_Box2(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - this.expand = true; - - // set gobject values - this.el.homogeneous = false; - this.el.margin_end = 10; - this.el.margin_start = 10; - this.el.margin_bottom = 10; - this.el.margin_top = 10; - var child_1 = new Xcls_Box3( _this ); - child_1.ref(); - this.el.append( child_1.el ); - new Xcls_mainpane( _this ); - this.el.append( _this.mainpane.el ); - } - - // user defined functions - } - public class Xcls_Box3 : Object - { - public Gtk.Box el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Box3(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.hexpand = true; - } - - // user defined functions - } - - public class Xcls_mainpane : Object - { - public Gtk.Paned el; - private DialogFiles _this; - - - // my vars (def) - public bool homogeneous; - public int spacing; - - // ctor - public Xcls_mainpane(DialogFiles _owner ) - { - _this = _owner; - _this.mainpane = this; - this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL ); - - // my vars (dec) - this.homogeneous = false; - this.spacing = 0; - - // set gobject values - this.el.hexpand = true; - this.el.vexpand = true; - this.el.position = 200; - new Xcls_projectscroll( _this ); - this.el.start_child = _this.projectscroll.el; - new Xcls_filepane( _this ); - this.el.end_child = _this.filepane.el; - } - - // user defined functions - } - public class Xcls_projectscroll : Object - { - public Gtk.ScrolledWindow el; - private DialogFiles _this; - - - // my vars (def) - public bool expand; - - // ctor - public Xcls_projectscroll(DialogFiles _owner ) - { - _this = _owner; - _this.projectscroll = this; - this.el = new Gtk.ScrolledWindow(); - - // my vars (dec) - this.expand = true; - - // set gobject values - this.el.width_request = 150; - this.el.has_frame = true; - this.el.hexpand = true; - this.el.vexpand = true; - new Xcls_project_list( _this ); - this.el.child = _this.project_list.el; - - // init method - - this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); - } - - // user defined functions - } - public class Xcls_project_list : Object - { - public Gtk.ColumnView el; - private DialogFiles _this; - - - // my vars (def) - public Gtk.CssProvider css; - - // ctor - public Xcls_project_list(DialogFiles _owner ) - { - _this = _owner; - _this.project_list = this; - new Xcls_projectselection( _this ); - this.el = new Gtk.ColumnView( _this.projectselection.el ); - - // my vars (dec) - - // set gobject values - this.el.name = "project-list"; - var child_2 = new Xcls_ColumnViewColumn12( _this ); - child_2.ref(); - this.el.append_column ( child_2.el ); - - // init method - - { - - this.css = new Gtk.CssProvider(); - - this.css.load_from_string("#project-list { font-size: 12px;}"); - - Gtk.StyleContext.add_provider_for_display( - this.el.get_display(), - this.css, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - ); - - - } - } - - // user defined functions - } - public class Xcls_projectselection : Object - { - public Gtk.SingleSelection el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_projectselection(DialogFiles _owner ) - { - _this = _owner; - _this.projectselection = this; - new Xcls_projectsort( _this ); - this.el = new Gtk.SingleSelection( _this.projectsort.el ); - - // my vars (dec) - - // set gobject values - this.el.can_unselect = true; - - //listeners - this.el.notify["selected"].connect( (position, n_items) => { - - if (_this.is_loading) { - return; - } - - if (this.el.selected == Gtk.INVALID_LIST_POSITION) { - _this.btn_delproj.el.hide(); - _this.btn_projprop.el.hide(); - _this.btn_addfile.el.hide(); - //_this.btn_delfile.el.hide(); - - } else { - _this.btn_delproj.el.show(); - _this.btn_projprop.el.show(); - _this.btn_addfile.el.show(); - //_this.btn_delfile.el.show(); // ?? - } - - - - - - if (_this.is_loading) { - return; - } - - Project.Project project = this.el.selected == Gtk.INVALID_LIST_POSITION ? null : - (Project.Project) _this.projectsort.el.get_item(this.el.selected); - - GLib.debug("selection changed to %s", project == null ? "none" : project.name); - - _this.onProjectSelected(project); - }); - } - - // user defined functions - } - public class Xcls_projectsort : Object - { - public Gtk.SortListModel el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_projectsort(DialogFiles _owner ) - { - _this = _owner; - _this.projectsort = this; - new Xcls_projectmodel( _this ); - var child_2 = new Xcls_StringSorter10( _this ); - child_2.ref(); - this.el = new Gtk.SortListModel( _this.projectmodel.el, child_2.el ); - - // my vars (dec) - - // set gobject values - this.el.incremental = true; - } - - // user defined functions - } - public class Xcls_projectmodel : Object - { - public GLib.ListStore el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_projectmodel(DialogFiles _owner ) - { - _this = _owner; - _this.projectmodel = this; - this.el = new GLib.ListStore( typeof(Project.Project) ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - public void remove (Project.Project p) { - - for (var i =0;i < this.el.n_items; i++ ) { - var pr = (Project.Project) this.el.get_item(i); - if (p.path == pr.path) { - this.el.remove(i); - return; - } - } - - - } - } - - public class Xcls_StringSorter10 : Object - { - public Gtk.StringSorter el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_StringSorter10(DialogFiles _owner ) - { - _this = _owner; - var child_1 = new Xcls_PropertyExpression11( _this ); - child_1.ref(); - this.el = new Gtk.StringSorter( child_1.el ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - public class Xcls_PropertyExpression11 : Object - { - public Gtk.PropertyExpression el; - private DialogFiles _this; - - - // my vars (def) +static DialogFiles _DialogFiles; - // ctor - public Xcls_PropertyExpression11(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.PropertyExpression( typeof(Project.Project), null, "name" ); +public class DialogFiles : Object +{ + public Gtk.Window el; + private DialogFiles _this; - // my vars (dec) + public static DialogFiles singleton() + { + if (_DialogFiles == null) { + _DialogFiles= new DialogFiles(); + } + return _DialogFiles; + } + public Xcls_mainpane mainpane; + public Xcls_projectscroll projectscroll; + public Xcls_project_list project_list; + public Xcls_projectselection projectselection; + public Xcls_projectsort projectsort; + public Xcls_projectmodel projectmodel; + public Xcls_filepane filepane; + public Xcls_searchbox searchbox; + public Xcls_iconscroll iconscroll; + public Xcls_gridview gridview; + public Xcls_iconsel iconsel; + public Xcls_gridsort gridsort; + public Xcls_gridmodel gridmodel; + public Xcls_iconsearch iconsearch; + public Xcls_treescroll treescroll; + public Xcls_treeview treeview; + public Xcls_treeselmodel treeselmodel; + public Xcls_treelistsort treelistsort; + public Xcls_treelistmodel treelistmodel; + public Xcls_treemodel treemodel; + public Xcls_treefilter treefilter; + public Xcls_name name; + public Xcls_btn_newproj btn_newproj; + public Xcls_btn_projprop btn_projprop; + public Xcls_btn_delproj btn_delproj; + public Xcls_btn_addfile btn_addfile; + public Xcls_btn_delfile btn_delfile; + + // my vars (def) + public Xcls_MainWindow win; + public string lastfilter; + public bool in_onprojectselected; + public bool is_loading; + public bool new_window; + public Project.Project selectedProject; + public Gdk.Pixbuf missing_thumb_pixbuf; + public Gee.HashMap image_cache; + + // ctor + public DialogFiles() + { + _this = this; + this.el = new Gtk.Window(); + + // my vars (dec) + this.in_onprojectselected = false; + this.is_loading = false; + this.new_window = false; + + // set gobject values + this.el.title = "Select Project / File"; + this.el.name = "DialogFiles"; + this.el.default_height = 550; + this.el.default_width = 1000; + this.el.modal = true; + var child_1 = new Xcls_Box2( _this ); + this.el.child = child_1.el; + var child_2 = new Xcls_HeaderBar44( _this ); + this.el.titlebar = child_2.el; + } - // set gobject values - } + // user defined functions + public void onProjectSelected (Project.Project? project) + { + if (this.in_onprojectselected) { + return; + } + this.selectedProject = project; + + if (project == null) { + GLib.debug("Hide project files"); + _this.mainpane.el.set_end_child(null); + _this.filepane.el.hide(); + return; + + } + + GLib.debug("Show project files"); + _this.mainpane.el.set_end_child(_this.filepane.el); + + _this.filepane.el.show(); + this.in_onprojectselected = true; + + + + project.load(); + + + _this.searchbox.el.text = ""; + _this.gridview.el.set_model(new Gtk.SingleSelection(null)); + _this.selectedProject.loadFilesIntoStore(_this.gridmodel.el); + _this.iconsel.el.selected = Gtk.INVALID_LIST_POSITION; + + _this.gridview.el.set_model(_this.iconsel.el); + + + GLib.Timeout.add(500, () => { + _this.iconsel.el.selected = Gtk.INVALID_LIST_POSITION; + _this.treeselmodel.el.selected = Gtk.INVALID_LIST_POSITION; + + _this.searchbox.el.grab_focus(); + return false; + }); + _this.treeview.el.set_model(new Gtk.SingleSelection(null)); + + this.selectedProject.loadDirsIntoStore(_this.treemodel.el); + + _this.treeview.el.set_model(_this.treeselmodel.el); + + _this.treeselmodel.el.selected = Gtk.INVALID_LIST_POSITION; + this.treescroll.el.vadjustment.value = 0; + this.in_onprojectselected = false; + } + public void selectProject (Project.Project? project) { + + + + var sm = this.projectselection.el; + if (project == null) { + sm.selected = Gtk.INVALID_LIST_POSITION; + this.onProjectSelected(null); + return; + } + + + for (var i =0; i < sm.n_items; i++) { + var p = (Project.Project) sm.get_item(i); + if (p.path == project.path) { + GLib.debug("Select Project %s => %d", project.name, i); + sm.selected = i; + break; + } + } + + } + public void show (Project.Project? project, bool new_window) { + + this.new_window = new_window; + + this.projectscroll.el.vadjustment.value = 0; // scroll to top? + + + //var win = this.win.el; + //var w = win.get_width(); + //var h = win.get_height(); + + + this.el.show(); + this.load(); + this.selectProject(project); + this.onProjectSelected(project); //?? twice? + + GLib.Timeout.add(500, () => { + if (project == null) { + _this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION; + this.onProjectSelected(null); + + } + this.el.set_size_request( 800 , 750); // ?? based on default + return false; + }); + + }// + public void load () { + // clear list... + + + _this.is_loading = true; + + + Project.Project.loadAll(); + _this.project_list.el.set_model(new Gtk.SingleSelection(null)); + Project.Project.loadIntoStore(this.projectmodel.el); + + _this.project_list.el.set_model(_this.projectselection.el); + + _this.is_loading = false; + + _this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION; + _this.btn_delfile.el.hide(); + + + } + public class Xcls_Box2 : Object + { + public Gtk.Box el; + private DialogFiles _this; + + + // my vars (def) + public bool expand; + + // ctor + public Xcls_Box2(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + this.expand = true; + + // set gobject values + this.el.homogeneous = false; + this.el.margin_end = 10; + this.el.margin_start = 10; + this.el.margin_bottom = 10; + this.el.margin_top = 10; + var child_1 = new Xcls_Box3( _this ); + child_1.ref(); + this.el.append( child_1.el ); + new Xcls_mainpane( _this ); + this.el.append( _this.mainpane.el ); + } - // user defined functions - } + // user defined functions + } + public class Xcls_Box3 : Object + { + public Gtk.Box el; + private DialogFiles _this; + // my vars (def) + // ctor + public Xcls_Box3(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - public class Xcls_ColumnViewColumn12 : Object - { - public Gtk.ColumnViewColumn el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_ColumnViewColumn12(DialogFiles _owner ) - { - _this = _owner; - var child_1 = new Xcls_SignalListItemFactory13( _this ); - child_1.ref(); - this.el = new Gtk.ColumnViewColumn( "Project", child_1.el ); - - // my vars (dec) - - // set gobject values - this.el.expand = true; - } + // my vars (dec) - // user defined functions - } - public class Xcls_SignalListItemFactory13 : Object - { - public Gtk.SignalListItemFactory el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_SignalListItemFactory13(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.SignalListItemFactory(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.setup.connect( (item) => { - //var j = (JsRender.JsRender) item; - var gi = (Gtk.ListItem)item; - - var lbl = new Gtk.Label(""); - lbl.halign = Gtk.Align.START; - gi.set_child(lbl); - - - - }); - this.el.bind.connect( (listitem) => { - - var lbl = (Gtk.Label) ((Gtk.ListItem)listitem).get_child(); - - var item = (Project.Project) ((Gtk.ListItem)listitem).get_item(); - - item.bind_property("name", - lbl, "label", - GLib.BindingFlags.SYNC_CREATE); - - - }); - } + // set gobject values + this.el.hexpand = true; + } - // user defined functions - } + // user defined functions + } + public class Xcls_mainpane : Object + { + public Gtk.Paned el; + private DialogFiles _this; + + + // my vars (def) + public bool homogeneous; + public int spacing; + + // ctor + public Xcls_mainpane(DialogFiles _owner ) + { + _this = _owner; + _this.mainpane = this; + this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL ); + + // my vars (dec) + this.homogeneous = false; + this.spacing = 0; + + // set gobject values + this.el.hexpand = true; + this.el.vexpand = true; + this.el.position = 200; + new Xcls_projectscroll( _this ); + this.el.start_child = _this.projectscroll.el; + new Xcls_filepane( _this ); + this.el.end_child = _this.filepane.el; + } + // user defined functions + } + public class Xcls_projectscroll : Object + { + public Gtk.ScrolledWindow el; + private DialogFiles _this; - public class Xcls_filepane : Object - { - public Gtk.Paned el; - private DialogFiles _this; + // my vars (def) + public bool expand; + // ctor + public Xcls_projectscroll(DialogFiles _owner ) + { + _this = _owner; + _this.projectscroll = this; + this.el = new Gtk.ScrolledWindow(); - // my vars (def) + // my vars (dec) + this.expand = true; - // ctor - public Xcls_filepane(DialogFiles _owner ) - { - _this = _owner; - _this.filepane = this; - this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL ); - - // my vars (dec) - - // set gobject values - this.el.position = 200; - this.el.visible = false; - var child_1 = new Xcls_Box15( _this ); - this.el.end_child = child_1.el; - new Xcls_treescroll( _this ); - this.el.start_child = _this.treescroll.el; - } - - // user defined functions - } - public class Xcls_Box15 : Object - { - public Gtk.Box el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Box15(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.hexpand = true; - this.el.vexpand = true; - var child_1 = new Xcls_Box16( _this ); - child_1.ref(); - this.el.append( child_1.el ); - new Xcls_iconscroll( _this ); - this.el.append( _this.iconscroll.el ); - } - - // user defined functions - } - public class Xcls_Box16 : Object - { - public Gtk.Box el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Box16(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.hexpand = true; - new Xcls_searchbox( _this ); - this.el.append( _this.searchbox.el ); - } - - // user defined functions - } - public class Xcls_searchbox : Object - { - public Gtk.SearchEntry el; - private DialogFiles _this; - - - // my vars (def) - public Gtk.CssProvider css; - - // ctor - public Xcls_searchbox(DialogFiles _owner ) - { - _this = _owner; - _this.searchbox = this; - this.el = new Gtk.SearchEntry(); + // set gobject values + this.el.width_request = 150; + this.el.has_frame = true; + this.el.hexpand = true; + this.el.vexpand = true; + new Xcls_project_list( _this ); + this.el.child = _this.project_list.el; - // my vars (dec) - - // set gobject values - this.el.name = "popover-files-iconsearch"; - this.el.hexpand = true; - this.el.placeholder_text = "type to filter results"; - this.el.search_delay = 1000; - - // init method - - /* - this.css = new Gtk.CssProvider(); - try { - this.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); - - - */ - - //listeners - this.el.search_changed.connect( ( ) => { - - _this.treefilter.el.changed(Gtk.FilterChange.DIFFERENT); - _this.iconsearch.el.set_search(this.el.text); - }); - } - - // user defined functions - } - - - public class Xcls_iconscroll : Object - { - public Gtk.ScrolledWindow el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_iconscroll(DialogFiles _owner ) - { - _this = _owner; - _this.iconscroll = this; - this.el = new Gtk.ScrolledWindow(); - - // my vars (dec) - - // set gobject values - this.el.has_frame = true; - this.el.hexpand = true; - this.el.vexpand = true; - new Xcls_gridview( _this ); - this.el.child = _this.gridview.el; - - // init method - - this.el.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC); - } - - // user defined functions - } - public class Xcls_gridview : Object - { - public Gtk.GridView el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_gridview(DialogFiles _owner ) - { - _this = _owner; - _this.gridview = this; - new Xcls_iconsel( _this ); - var child_2 = new Xcls_SignalListItemFactory29( _this ); - child_2.ref(); - this.el = new Gtk.GridView( _this.iconsel.el, child_2.el ); - - // my vars (dec) - - // set gobject values - var child_3 = new Xcls_GestureClick20( _this ); - child_3.ref(); - this.el.add_controller( child_3.el ); - } - - // user defined functions - } - public class Xcls_GestureClick20 : Object - { - public Gtk.GestureClick el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_GestureClick20(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.GestureClick(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.pressed.connect( (n_press, x, y) => { - if (n_press == 2) { - GLib.debug("double cliced"); - } else { - return; - } - var f = (JsRender.JsRender)_this.iconsel.el.selected_item; - - GLib.debug("Click %s", f.name); - if (f.xtype == "Dir") { - return; - } - - - _this.win.windowstate.fileViewOpen(f, _this.new_window); - _this.el.hide(); - - - - - }); - } - - // user defined functions - } - - public class Xcls_iconsel : Object - { - public Gtk.SingleSelection el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_iconsel(DialogFiles _owner ) - { - _this = _owner; - _this.iconsel = this; - var child_1 = new Xcls_FilterListModel22( _this ); - child_1.ref(); - this.el = new Gtk.SingleSelection( child_1.el ); - - // my vars (dec) - - // set gobject values - this.el.can_unselect = true; - - //listeners - this.el.notify["selected"].connect( () => { - if (this.el.selected == Gtk.INVALID_LIST_POSITION) { - if (_this.treeselmodel.el.selected == Gtk.INVALID_LIST_POSITION) { - _this.btn_delfile.el.hide(); - } - - return; - } - _this.btn_delfile.el.show(); - _this.treeselmodel.el.selected = Gtk.INVALID_LIST_POSITION; - - - }); - } - - // user defined functions - public JsRender.JsRender? selectedFile () { - - if (this.el.selected == Gtk.INVALID_LIST_POSITION) { - return null; - } - return (JsRender.JsRender)this.el.get_item(this.el.selected); - - - } - } - public class Xcls_FilterListModel22 : Object - { - public Gtk.FilterListModel el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_FilterListModel22(DialogFiles _owner ) - { - _this = _owner; - new Xcls_gridsort( _this ); - new Xcls_iconsearch( _this ); - this.el = new Gtk.FilterListModel( _this.gridsort.el, _this.iconsearch.el ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - public class Xcls_gridsort : Object - { - public Gtk.SortListModel el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_gridsort(DialogFiles _owner ) - { - _this = _owner; - _this.gridsort = this; - new Xcls_gridmodel( _this ); - var child_2 = new Xcls_StringSorter25( _this ); - child_2.ref(); - this.el = new Gtk.SortListModel( _this.gridmodel.el, child_2.el ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - public class Xcls_gridmodel : Object - { - public GLib.ListStore el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_gridmodel(DialogFiles _owner ) - { - _this = _owner; - _this.gridmodel = this; - this.el = new GLib.ListStore( typeof(JsRender.JsRender) ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - public void remove (JsRender.JsRender p) { - - for (var i =0;i < this.el.n_items; i++ ) { - var pr = (JsRender.JsRender) this.el.get_item(i); - if (p.path == pr.path) { - this.el.remove(i); - return; - } - } - - } - } + // init method - public class Xcls_StringSorter25 : Object - { - public Gtk.StringSorter el; - private DialogFiles _this; + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + } + // user defined functions + } + public class Xcls_project_list : Object + { + public Gtk.ColumnView el; + private DialogFiles _this; + + + // my vars (def) + public Gtk.CssProvider css; + + // ctor + public Xcls_project_list(DialogFiles _owner ) + { + _this = _owner; + _this.project_list = this; + new Xcls_projectselection( _this ); + this.el = new Gtk.ColumnView( _this.projectselection.el ); + + // my vars (dec) + + // set gobject values + this.el.name = "project-list"; + var child_2 = new Xcls_ColumnViewColumn12( _this ); + child_2.ref(); + this.el.append_column ( child_2.el ); + + // init method + + { + + this.css = new Gtk.CssProvider(); + + this.css.load_from_string(" + #project-list { font-size: 12px;} + "); + + Gtk.StyleContext.add_provider_for_display( + this.el.get_display(), + this.css, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + ); + + + } + } - // my vars (def) + // user defined functions + } + public class Xcls_projectselection : Object + { + public Gtk.SingleSelection el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_projectselection(DialogFiles _owner ) + { + _this = _owner; + _this.projectselection = this; + new Xcls_projectsort( _this ); + this.el = new Gtk.SingleSelection( _this.projectsort.el ); + + // my vars (dec) + + // set gobject values + this.el.can_unselect = true; + + //listeners + this.el.notify["selected"].connect( (position, n_items) => { + + if (_this.is_loading) { + return; + } + + if (this.el.selected == Gtk.INVALID_LIST_POSITION) { + _this.btn_delproj.el.hide(); + _this.btn_projprop.el.hide(); + _this.btn_addfile.el.hide(); + //_this.btn_delfile.el.hide(); + + } else { + _this.btn_delproj.el.show(); + _this.btn_projprop.el.show(); + _this.btn_addfile.el.show(); + //_this.btn_delfile.el.show(); // ?? + } + + + + + + if (_this.is_loading) { + return; + } + + Project.Project project = this.el.selected == Gtk.INVALID_LIST_POSITION ? null : + (Project.Project) _this.projectsort.el.get_item(this.el.selected); + + GLib.debug("selection changed to %s", project == null ? "none" : project.name); + + _this.onProjectSelected(project); + }); + } - // ctor - public Xcls_StringSorter25(DialogFiles _owner ) - { - _this = _owner; - var child_1 = new Xcls_PropertyExpression26( _this ); - child_1.ref(); - this.el = new Gtk.StringSorter( child_1.el ); + // user defined functions + } + public class Xcls_projectsort : Object + { + public Gtk.SortListModel el; + private DialogFiles _this; - // my vars (dec) - // set gobject values - this.el.ignore_case = true; - } + // my vars (def) - // user defined functions - } - public class Xcls_PropertyExpression26 : Object - { - public Gtk.PropertyExpression el; - private DialogFiles _this; + // ctor + public Xcls_projectsort(DialogFiles _owner ) + { + _this = _owner; + _this.projectsort = this; + new Xcls_projectmodel( _this ); + var child_2 = new Xcls_StringSorter10( _this ); + child_2.ref(); + this.el = new Gtk.SortListModel( _this.projectmodel.el, child_2.el ); + // my vars (dec) - // my vars (def) + // set gobject values + this.el.incremental = true; + } + + // user defined functions + } + public class Xcls_projectmodel : Object + { + public GLib.ListStore el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_projectmodel(DialogFiles _owner ) + { + _this = _owner; + _this.projectmodel = this; + this.el = new GLib.ListStore( typeof(Project.Project) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void remove (Project.Project p) { + + for (var i =0;i < this.el.n_items; i++ ) { + var pr = (Project.Project) this.el.get_item(i); + if (p.path == pr.path) { + this.el.remove(i); + return; + } + } + + + } + } + + public class Xcls_StringSorter10 : Object + { + public Gtk.StringSorter el; + private DialogFiles _this; - // ctor - public Xcls_PropertyExpression26(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.PropertyExpression( typeof(JsRender.JsRender), null, "name" ); - // my vars (dec) + // my vars (def) - // set gobject values - } + // ctor + public Xcls_StringSorter10(DialogFiles _owner ) + { + _this = _owner; + var child_1 = new Xcls_PropertyExpression11( _this ); + child_1.ref(); + this.el = new Gtk.StringSorter( child_1.el ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_PropertyExpression11 : Object + { + public Gtk.PropertyExpression el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_PropertyExpression11(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.PropertyExpression( typeof(Project.Project), null, "name" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + + public class Xcls_ColumnViewColumn12 : Object + { + public Gtk.ColumnViewColumn el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_ColumnViewColumn12(DialogFiles _owner ) + { + _this = _owner; + var child_1 = new Xcls_SignalListItemFactory13( _this ); + child_1.ref(); + this.el = new Gtk.ColumnViewColumn( "Project", child_1.el ); + + // my vars (dec) + + // set gobject values + this.el.expand = true; + } + + // user defined functions + } + public class Xcls_SignalListItemFactory13 : Object + { + public Gtk.SignalListItemFactory el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_SignalListItemFactory13(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.SignalListItemFactory(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.setup.connect( (item) => { + //var j = (JsRender.JsRender) item; + var gi = (Gtk.ListItem)item; + + var lbl = new Gtk.Label(""); + lbl.halign = Gtk.Align.START; + gi.set_child(lbl); + + + + }); + this.el.bind.connect( (listitem) => { + + var lbl = (Gtk.Label) ((Gtk.ListItem)listitem).get_child(); + + var item = (Project.Project) ((Gtk.ListItem)listitem).get_item(); + + item.bind_property("name", + lbl, "label", + GLib.BindingFlags.SYNC_CREATE); + + + }); + } + + // user defined functions + } + + + + + public class Xcls_filepane : Object + { + public Gtk.Paned el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_filepane(DialogFiles _owner ) + { + _this = _owner; + _this.filepane = this; + this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL ); + + // my vars (dec) + + // set gobject values + this.el.position = 200; + this.el.visible = false; + var child_1 = new Xcls_Box15( _this ); + this.el.end_child = child_1.el; + new Xcls_treescroll( _this ); + this.el.start_child = _this.treescroll.el; + } + + // user defined functions + } + public class Xcls_Box15 : Object + { + public Gtk.Box el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_Box15(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.hexpand = true; + this.el.vexpand = true; + var child_1 = new Xcls_Box16( _this ); + child_1.ref(); + this.el.append( child_1.el ); + new Xcls_iconscroll( _this ); + this.el.append( _this.iconscroll.el ); + } + + // user defined functions + } + public class Xcls_Box16 : Object + { + public Gtk.Box el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_Box16(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.hexpand = true; + new Xcls_searchbox( _this ); + this.el.append( _this.searchbox.el ); + } + + // user defined functions + } + public class Xcls_searchbox : Object + { + public Gtk.SearchEntry el; + private DialogFiles _this; + + + // my vars (def) + public Gtk.CssProvider css; + + // ctor + public Xcls_searchbox(DialogFiles _owner ) + { + _this = _owner; + _this.searchbox = this; + this.el = new Gtk.SearchEntry(); + + // my vars (dec) + + // set gobject values + this.el.name = "popover-files-iconsearch"; + this.el.hexpand = true; + this.el.placeholder_text = "type to filter results"; + this.el.search_delay = 1000; + + // init method + + /* + this.css = new Gtk.CssProvider(); + try { + this.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); + + + */ + + //listeners + this.el.search_changed.connect( ( ) => { + + _this.treefilter.el.changed(Gtk.FilterChange.DIFFERENT); + _this.iconsearch.el.set_search(this.el.text); + }); + } + + // user defined functions + } + + + public class Xcls_iconscroll : Object + { + public Gtk.ScrolledWindow el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_iconscroll(DialogFiles _owner ) + { + _this = _owner; + _this.iconscroll = this; + this.el = new Gtk.ScrolledWindow(); + + // my vars (dec) + + // set gobject values + this.el.has_frame = true; + this.el.hexpand = true; + this.el.vexpand = true; + new Xcls_gridview( _this ); + this.el.child = _this.gridview.el; + + // init method + + this.el.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC); + } + + // user defined functions + } + public class Xcls_gridview : Object + { + public Gtk.GridView el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_gridview(DialogFiles _owner ) + { + _this = _owner; + _this.gridview = this; + new Xcls_iconsel( _this ); + var child_2 = new Xcls_SignalListItemFactory29( _this ); + child_2.ref(); + this.el = new Gtk.GridView( _this.iconsel.el, child_2.el ); + + // my vars (dec) + + // set gobject values + var child_3 = new Xcls_GestureClick20( _this ); + child_3.ref(); + this.el.add_controller( child_3.el ); + } - // user defined functions - } + // user defined functions + } + public class Xcls_GestureClick20 : Object + { + public Gtk.GestureClick el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_GestureClick20(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.GestureClick(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.pressed.connect( (n_press, x, y) => { + if (n_press == 2) { + GLib.debug("double cliced"); + } else { + return; + } + var f = (JsRender.JsRender)_this.iconsel.el.selected_item; + + GLib.debug("Click %s", f.name); + if (f.xtype == "Dir") { + return; + } + + + _this.win.windowstate.fileViewOpen(f, _this.new_window); + _this.el.hide(); + + + + + }); + } + + // user defined functions + } + + public class Xcls_iconsel : Object + { + public Gtk.SingleSelection el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_iconsel(DialogFiles _owner ) + { + _this = _owner; + _this.iconsel = this; + var child_1 = new Xcls_FilterListModel22( _this ); + child_1.ref(); + this.el = new Gtk.SingleSelection( child_1.el ); + + // my vars (dec) + + // set gobject values + this.el.can_unselect = true; + + //listeners + this.el.notify["selected"].connect( () => { + if (this.el.selected == Gtk.INVALID_LIST_POSITION) { + if (_this.treeselmodel.el.selected == Gtk.INVALID_LIST_POSITION) { + _this.btn_delfile.el.hide(); + } + + return; + } + _this.btn_delfile.el.show(); + _this.treeselmodel.el.selected = Gtk.INVALID_LIST_POSITION; + + + }); + } + + // user defined functions + public JsRender.JsRender? selectedFile () { + + if (this.el.selected == Gtk.INVALID_LIST_POSITION) { + return null; + } + return (JsRender.JsRender)this.el.get_item(this.el.selected); + + + } + } + public class Xcls_FilterListModel22 : Object + { + public Gtk.FilterListModel el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_FilterListModel22(DialogFiles _owner ) + { + _this = _owner; + new Xcls_gridsort( _this ); + new Xcls_iconsearch( _this ); + this.el = new Gtk.FilterListModel( _this.gridsort.el, _this.iconsearch.el ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_gridsort : Object + { + public Gtk.SortListModel el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_gridsort(DialogFiles _owner ) + { + _this = _owner; + _this.gridsort = this; + new Xcls_gridmodel( _this ); + var child_2 = new Xcls_StringSorter25( _this ); + child_2.ref(); + this.el = new Gtk.SortListModel( _this.gridmodel.el, child_2.el ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_gridmodel : Object + { + public GLib.ListStore el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_gridmodel(DialogFiles _owner ) + { + _this = _owner; + _this.gridmodel = this; + this.el = new GLib.ListStore( typeof(JsRender.JsRender) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void remove (JsRender.JsRender p) { + + for (var i =0;i < this.el.n_items; i++ ) { + var pr = (JsRender.JsRender) this.el.get_item(i); + if (p.path == pr.path) { + this.el.remove(i); + return; + } + } + + } + } + + public class Xcls_StringSorter25 : Object + { + public Gtk.StringSorter el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_StringSorter25(DialogFiles _owner ) + { + _this = _owner; + var child_1 = new Xcls_PropertyExpression26( _this ); + child_1.ref(); + this.el = new Gtk.StringSorter( child_1.el ); + + // my vars (dec) + + // set gobject values + this.el.ignore_case = true; + } + + // user defined functions + } + public class Xcls_PropertyExpression26 : Object + { + public Gtk.PropertyExpression el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_PropertyExpression26(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.PropertyExpression( typeof(JsRender.JsRender), null, "name" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + public class Xcls_iconsearch : Object + { + public Gtk.StringFilter el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_iconsearch(DialogFiles _owner ) + { + _this = _owner; + _this.iconsearch = this; + var child_1 = new Xcls_PropertyExpression28( _this ); + child_1.ref(); + this.el = new Gtk.StringFilter( child_1.el ); + + // my vars (dec) + + // set gobject values + this.el.match_mode = Gtk.StringFilterMatchMode.SUBSTRING; + this.el.ignore_case = true; + } + + // user defined functions + } + public class Xcls_PropertyExpression28 : Object + { + public Gtk.PropertyExpression el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_PropertyExpression28(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.PropertyExpression( typeof(JsRender.JsRender), null, "name" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + + public class Xcls_SignalListItemFactory29 : Object + { + public Gtk.SignalListItemFactory el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_SignalListItemFactory29(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.SignalListItemFactory(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.setup.connect( (item) => { + //var j = (JsRender.JsRender) item; + var gi = (Gtk.ListItem)item; + var b = new Gtk.Box(Gtk.Orientation.VERTICAL,4); + var i = new Gtk.Image(); + i.pixel_size = 96; + var t = new Gtk.Label(""); + b.append(i); + b.append(t); + + gi.set_child(b); + b.has_tooltip = true; + b.query_tooltip.connect((x, y, keyboard_tooltip, tooltip) => { + var j = (JsRender.JsRender) gi.get_item(); + + var ti = new Gtk.Image.from_file ( j.getIconFileName()); + ti.pixel_size = 368; + tooltip.set_custom( ti ); + return true; + }); + + + }); + this.el.bind.connect( (listitem) => { + + var box = (Gtk.Box) ((Gtk.ListItem)listitem).get_child(); + + var img = (Gtk.Image) box.get_first_child(); + var lbl = (Gtk.Label)img.get_next_sibling(); + + var item = (JsRender.JsRender) ((Gtk.ListItem)listitem).get_item(); + //GLib.debug("set label name to %s", item.name); + + var ns = item.name.split("."); + if (ns.length < 2) { + lbl.label = item.name; + } else { + lbl.label = + item.name.substring(0, item.name.length - ns[ns.length-1].length) + + "\n"+ ns[ns.length-1]; + } + + /* + item.bind_property("name", + lbl, "label", + GLib.BindingFlags.SYNC_CREATE); + + */ + img.set_from_file(item.getIconFileName()); + + + }); + } + + // user defined functions + } + + + + + public class Xcls_treescroll : Object + { + public Gtk.ScrolledWindow el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_treescroll(DialogFiles _owner ) + { + _this = _owner; + _this.treescroll = this; + this.el = new Gtk.ScrolledWindow(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 200; + this.el.has_frame = true; + this.el.hexpand = true; + this.el.vexpand = true; + this.el.visible = true; + new Xcls_treeview( _this ); + this.el.child = _this.treeview.el; + + // init method + + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + } + + // user defined functions + } + public class Xcls_treeview : Object + { + public Gtk.ColumnView el; + private DialogFiles _this; + + + // my vars (def) + public Gtk.CssProvider css; + + // ctor + public Xcls_treeview(DialogFiles _owner ) + { + _this = _owner; + _this.treeview = this; + new Xcls_treeselmodel( _this ); + this.el = new Gtk.ColumnView( _this.treeselmodel.el ); + + // my vars (dec) + + // set gobject values + this.el.name = "file-list"; + var child_2 = new Xcls_GestureClick32( _this ); + child_2.ref(); + this.el.add_controller( child_2.el ); + new Xcls_name( _this ); + this.el.append_column ( _this.name.el ); + + // init method + + { + + this.css = new Gtk.CssProvider(); + + this.css.load_from_string(" + #file-list { font-size: 12px;} + #file-list indent { + -gtk-icon-size : 2px; + } + #file-list indent:nth-last-child(2) { + min-width: 24px; + } + "); + + Gtk.StyleContext.add_provider_for_display( + this.el.get_display(), + this.css, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + ); + + } + } + + // user defined functions + } + public class Xcls_GestureClick32 : Object + { + public Gtk.GestureClick el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_GestureClick32(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.GestureClick(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.pressed.connect( (n_press, x, y) => { + if (n_press == 2) { + GLib.debug("double cliced"); + } else { + return; + } + var tr = (Gtk.TreeListRow)_this.treeselmodel.el.selected_item; + GLib.debug("SELECTED = %s", tr.item.get_type().name()); + var f = (JsRender.JsRender) tr.item; + GLib.debug("Click %s", f.name); + if (f.xtype == "Dir") { + return; + } + + + _this.win.windowstate.fileViewOpen(f, _this.new_window); + + _this.el.hide(); + + + + }); + } + + // user defined functions + } + + public class Xcls_treeselmodel : Object + { + public Gtk.SingleSelection el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_treeselmodel(DialogFiles _owner ) + { + _this = _owner; + _this.treeselmodel = this; + var child_1 = new Xcls_FilterListModel34( _this ); + child_1.ref(); + this.el = new Gtk.SingleSelection( child_1.el ); + + // my vars (dec) + + // set gobject values + this.el.can_unselect = true; + + //listeners + this.el.notify["selected"].connect( () => { + if (this.el.selected == Gtk.INVALID_LIST_POSITION) { + if (_this.iconsel.el.selected == Gtk.INVALID_LIST_POSITION) { + _this.btn_delfile.el.hide(); + } + return; + } + + var tr = (Gtk.TreeListRow)_this.treeselmodel.el.selected_item; + GLib.debug("SELECTED = %s", tr.item.get_type().name()); + var f = (JsRender.JsRender) tr.item; + if (f.xtype == "Dir") { + _this.btn_delfile.el.hide(); + } else { + _this.btn_delfile.el.show(); + } + + _this.iconsel.el.selected = Gtk.INVALID_LIST_POSITION; + + + }); + } + + // user defined functions + public JsRender.JsRender? selectedFile () { + + if (this.el.selected == Gtk.INVALID_LIST_POSITION) { + return null; + } + var tr = (Gtk.TreeListRow) this.el.selected_item; + + return (JsRender.JsRender) tr.item; + } + } + public class Xcls_FilterListModel34 : Object + { + public Gtk.FilterListModel el; + private DialogFiles _this; - - - public class Xcls_iconsearch : Object - { - public Gtk.StringFilter el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_iconsearch(DialogFiles _owner ) - { - _this = _owner; - _this.iconsearch = this; - var child_1 = new Xcls_PropertyExpression28( _this ); - child_1.ref(); - this.el = new Gtk.StringFilter( child_1.el ); - - // my vars (dec) - - // set gobject values - this.el.match_mode = Gtk.StringFilterMatchMode.SUBSTRING; - this.el.ignore_case = true; - } - - // user defined functions - } - public class Xcls_PropertyExpression28 : Object - { - public Gtk.PropertyExpression el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_PropertyExpression28(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.PropertyExpression( typeof(JsRender.JsRender), null, "name" ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - - - - public class Xcls_SignalListItemFactory29 : Object - { - public Gtk.SignalListItemFactory el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_SignalListItemFactory29(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.SignalListItemFactory(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.setup.connect( (item) => { - //var j = (JsRender.JsRender) item; - var gi = (Gtk.ListItem)item; - var b = new Gtk.Box(Gtk.Orientation.VERTICAL,4); - var i = new Gtk.Image(); - i.pixel_size = 96; - var t = new Gtk.Label(""); - b.append(i); - b.append(t); - - gi.set_child(b); - b.has_tooltip = true; - b.query_tooltip.connect((x, y, keyboard_tooltip, tooltip) => { - var j = (JsRender.JsRender) gi.get_item(); - - var ti = new Gtk.Image.from_file ( j.getIconFileName()); - ti.pixel_size = 368; - tooltip.set_custom( ti ); - return true; - }); - - - }); - this.el.bind.connect( (listitem) => { - - var box = (Gtk.Box) ((Gtk.ListItem)listitem).get_child(); - - var img = (Gtk.Image) box.get_first_child(); - var lbl = (Gtk.Label)img.get_next_sibling(); - - var item = (JsRender.JsRender) ((Gtk.ListItem)listitem).get_item(); - //GLib.debug("set label name to %s", item.name); - - var ns = item.name.split("."); - if (ns.length < 2) { - lbl.label = item.name; - } else { - lbl.label = - item.name.substring(0, item.name.length - ns[ns.length-1].length) - + "\n"+ ns[ns.length-1]; - } - - /* - item.bind_property("name", - lbl, "label", - GLib.BindingFlags.SYNC_CREATE); - - */ - img.set_from_file(item.getIconFileName()); - - - }); - } - - // user defined functions - } - - - - - public class Xcls_treescroll : Object - { - public Gtk.ScrolledWindow el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_treescroll(DialogFiles _owner ) - { - _this = _owner; - _this.treescroll = this; - this.el = new Gtk.ScrolledWindow(); - - // my vars (dec) - - // set gobject values - this.el.width_request = 200; - this.el.has_frame = true; - this.el.hexpand = true; - this.el.vexpand = true; - this.el.visible = true; - new Xcls_treeview( _this ); - this.el.child = _this.treeview.el; - - // init method - - this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); - } - - // user defined functions - } - public class Xcls_treeview : Object - { - public Gtk.ColumnView el; - private DialogFiles _this; - - - // my vars (def) - public Gtk.CssProvider css; - - // ctor - public Xcls_treeview(DialogFiles _owner ) - { - _this = _owner; - _this.treeview = this; - new Xcls_treeselmodel( _this ); - this.el = new Gtk.ColumnView( _this.treeselmodel.el ); - - // my vars (dec) - - // set gobject values - this.el.name = "file-list"; - var child_2 = new Xcls_GestureClick32( _this ); - child_2.ref(); - this.el.add_controller( child_2.el ); - new Xcls_name( _this ); - this.el.append_column ( _this.name.el ); - - // init method - - { - - this.css = new Gtk.CssProvider(); - - this.css.load_from_string("#file-list { font-size: 12px;}"); - - Gtk.StyleContext.add_provider_for_display( - this.el.get_display(), - this.css, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - ); - - } - } - - // user defined functions - } - public class Xcls_GestureClick32 : Object - { - public Gtk.GestureClick el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_GestureClick32(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.GestureClick(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.pressed.connect( (n_press, x, y) => { - if (n_press == 2) { - GLib.debug("double cliced"); - } else { - return; - } - var tr = (Gtk.TreeListRow)_this.treeselmodel.el.selected_item; - GLib.debug("SELECTED = %s", tr.item.get_type().name()); - var f = (JsRender.JsRender) tr.item; - GLib.debug("Click %s", f.name); - if (f.xtype == "Dir") { - return; - } - - - _this.win.windowstate.fileViewOpen(f, _this.new_window); - - _this.el.hide(); - - - - }); - } - - // user defined functions - } - - public class Xcls_treeselmodel : Object - { - public Gtk.SingleSelection el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_treeselmodel(DialogFiles _owner ) - { - _this = _owner; - _this.treeselmodel = this; - var child_1 = new Xcls_FilterListModel34( _this ); - child_1.ref(); - this.el = new Gtk.SingleSelection( child_1.el ); - - // my vars (dec) - - // set gobject values - this.el.can_unselect = true; - - //listeners - this.el.notify["selected"].connect( () => { - if (this.el.selected == Gtk.INVALID_LIST_POSITION) { - if (_this.iconsel.el.selected == Gtk.INVALID_LIST_POSITION) { - _this.btn_delfile.el.hide(); - } - return; - } - - var tr = (Gtk.TreeListRow)_this.treeselmodel.el.selected_item; - GLib.debug("SELECTED = %s", tr.item.get_type().name()); - var f = (JsRender.JsRender) tr.item; - if (f.xtype == "Dir") { - _this.btn_delfile.el.hide(); - } else { - _this.btn_delfile.el.show(); - } - - _this.iconsel.el.selected = Gtk.INVALID_LIST_POSITION; - - - }); - } - - // user defined functions - public JsRender.JsRender? selectedFile () { - - if (this.el.selected == Gtk.INVALID_LIST_POSITION) { - return null; - } - var tr = (Gtk.TreeListRow) this.el.selected_item; - - return (JsRender.JsRender) tr.item; - } - } - public class Xcls_FilterListModel34 : Object - { - public Gtk.FilterListModel el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_FilterListModel34(DialogFiles _owner ) - { - _this = _owner; - new Xcls_treelistsort( _this ); - new Xcls_treefilter( _this ); - this.el = new Gtk.FilterListModel( _this.treelistsort.el, _this.treefilter.el ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - public class Xcls_treelistsort : Object - { - public Gtk.SortListModel el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_treelistsort(DialogFiles _owner ) - { - _this = _owner; - _this.treelistsort = this; - new Xcls_treelistmodel( _this ); - var child_2 = new Xcls_TreeListRowSorter38( _this ); - child_2.ref(); - this.el = new Gtk.SortListModel( _this.treelistmodel.el, child_2.el ); - - // my vars (dec) - - // set gobject values - this.el.incremental = true; - } - - // user defined functions - } - public class Xcls_treelistmodel : Object - { - public Gtk.TreeListModel el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_treelistmodel(DialogFiles _owner ) - { - _this = _owner; - _this.treelistmodel = this; - new Xcls_treemodel( _this ); - this.el = new Gtk.TreeListModel( _this.treemodel.el, false, true, (item) => { + + // my vars (def) + + // ctor + public Xcls_FilterListModel34(DialogFiles _owner ) + { + _this = _owner; + new Xcls_treelistsort( _this ); + new Xcls_treefilter( _this ); + this.el = new Gtk.FilterListModel( _this.treelistsort.el, _this.treefilter.el ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_treelistsort : Object + { + public Gtk.SortListModel el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_treelistsort(DialogFiles _owner ) + { + _this = _owner; + _this.treelistsort = this; + new Xcls_treelistmodel( _this ); + var child_2 = new Xcls_TreeListRowSorter38( _this ); + child_2.ref(); + this.el = new Gtk.SortListModel( _this.treelistmodel.el, child_2.el ); + + // my vars (dec) + + // set gobject values + this.el.incremental = true; + } + + // user defined functions + } + public class Xcls_treelistmodel : Object + { + public Gtk.TreeListModel el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_treelistmodel(DialogFiles _owner ) + { + _this = _owner; + _this.treelistmodel = this; + new Xcls_treemodel( _this ); + this.el = new Gtk.TreeListModel( _this.treemodel.el, false, true, (item) => { //GLib.debug("liststore got %s", item.get_type().name()); return ((JsRender.JsRender)item).childfiles; } ); - // my vars (dec) + // my vars (dec) - // set gobject values - } + // set gobject values + } - // user defined functions - } - public class Xcls_treemodel : Object - { - public GLib.ListStore el; - private DialogFiles _this; + // user defined functions + } + public class Xcls_treemodel : Object + { + public GLib.ListStore el; + private DialogFiles _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_treemodel(DialogFiles _owner ) - { - _this = _owner; - _this.treemodel = this; - this.el = new GLib.ListStore( typeof(JsRender.JsRender) ); + // ctor + public Xcls_treemodel(DialogFiles _owner ) + { + _this = _owner; + _this.treemodel = this; + this.el = new GLib.ListStore( typeof(JsRender.JsRender) ); - // my vars (dec) + // my vars (dec) - // set gobject values - } + // set gobject values + } - // user defined functions - } + // user defined functions + } - public class Xcls_TreeListRowSorter38 : Object - { - public Gtk.TreeListRowSorter el; - private DialogFiles _this; + public class Xcls_TreeListRowSorter38 : Object + { + public Gtk.TreeListRowSorter el; + private DialogFiles _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_TreeListRowSorter38(DialogFiles _owner ) - { - _this = _owner; - var child_1 = new Xcls_StringSorter39( _this ); - child_1.ref(); - this.el = new Gtk.TreeListRowSorter( child_1.el ); + // ctor + public Xcls_TreeListRowSorter38(DialogFiles _owner ) + { + _this = _owner; + var child_1 = new Xcls_StringSorter39( _this ); + child_1.ref(); + this.el = new Gtk.TreeListRowSorter( child_1.el ); - // my vars (dec) + // my vars (dec) - // set gobject values - } + // set gobject values + } - // user defined functions - } - public class Xcls_StringSorter39 : Object - { - public Gtk.StringSorter el; - private DialogFiles _this; + // user defined functions + } + public class Xcls_StringSorter39 : Object + { + public Gtk.StringSorter el; + private DialogFiles _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_StringSorter39(DialogFiles _owner ) - { - _this = _owner; - var child_1 = new Xcls_PropertyExpression40( _this ); - child_1.ref(); - this.el = new Gtk.StringSorter( child_1.el ); + // ctor + public Xcls_StringSorter39(DialogFiles _owner ) + { + _this = _owner; + var child_1 = new Xcls_PropertyExpression40( _this ); + child_1.ref(); + this.el = new Gtk.StringSorter( child_1.el ); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.ignore_case = true; - } + // set gobject values + this.el.ignore_case = true; + } - // user defined functions - } - public class Xcls_PropertyExpression40 : Object - { - public Gtk.PropertyExpression el; - private DialogFiles _this; + // user defined functions + } + public class Xcls_PropertyExpression40 : Object + { + public Gtk.PropertyExpression el; + private DialogFiles _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_PropertyExpression40(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.PropertyExpression( typeof(JsRender.JsRender) , null, "name" ); + // ctor + public Xcls_PropertyExpression40(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.PropertyExpression( typeof(JsRender.JsRender) , null, "name" ); - // my vars (dec) + // my vars (dec) - // set gobject values - } + // set gobject values + } - // user defined functions - } + // user defined functions + } - public class Xcls_treefilter : Object - { - public Gtk.CustomFilter el; - private DialogFiles _this; + public class Xcls_treefilter : Object + { + public Gtk.CustomFilter el; + private DialogFiles _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_treefilter(DialogFiles _owner ) - { - _this = _owner; - _this.treefilter = this; - this.el = new Gtk.CustomFilter( (item) => { + // ctor + public Xcls_treefilter(DialogFiles _owner ) + { + _this = _owner; + _this.treefilter = this; + this.el = new Gtk.CustomFilter( (item) => { var tr = ((Gtk.TreeListRow)item).get_item(); //GLib.debug("filter %s", tr.get_type().name()); var j = (JsRender.JsRender) tr; @@ -1551,845 +1561,858 @@ } ); - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - - - public class Xcls_name : Object - { - public Gtk.ColumnViewColumn el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_name(DialogFiles _owner ) - { - _this = _owner; - _this.name = this; - var child_1 = new Xcls_SignalListItemFactory43( _this ); - child_1.ref(); - this.el = new Gtk.ColumnViewColumn( "General Files", child_1.el ); - - // my vars (dec) - - // set gobject values - this.el.id = "name"; - this.el.expand = true; - this.el.resizable = true; - - // init method - - { - // this.el.set_sorter( new Gtk.StringSorter( - // new Gtk.PropertyExpression(typeof(JsRender.NodeProp), null, "name") - // )); - - } - } - - // user defined functions - } - public class Xcls_SignalListItemFactory43 : Object - { - public Gtk.SignalListItemFactory el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_SignalListItemFactory43(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.SignalListItemFactory(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.setup.connect( (listitem) => { - - var expand = new Gtk.TreeExpander(); - - expand.set_indent_for_depth(true); - expand.set_indent_for_icon(true); - - var lbl = new Gtk.Label(""); - lbl.use_markup = true; - - - lbl.justify = Gtk.Justification.LEFT; - lbl.xalign = 0; - - - expand.set_child(lbl); - ((Gtk.ListItem)listitem).set_child(expand); - ((Gtk.ListItem)listitem).activatable = false; - }); - this.el.bind.connect( (listitem) => { - //GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name()); - - - - //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); - var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); - - - var lbl = (Gtk.Label) expand.child; - - if (lbl.label != "") { // do not update - return; - } - var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item(); - //GLib.debug("LR = %s", lr.get_type().name()); - - - var jr =(JsRender.JsRender) lr.get_item(); - //GLib.debug("JR = %s", jr.get_type().name()); - - if (jr == null) { - GLib.debug("Problem getting item"); - return; - } - //GLib.debug("change %s to %s", lbl.label, np.name); - lbl.label = jr.name; // for dir's we could hsow the sub path.. - lbl.tooltip_markup = jr.path; - - expand.set_hide_expander( jr.xtype != "Dir" ); - expand.set_list_row(lr); - - - // bind image... - - }); - } - - // user defined functions - } - - - - - - - - public class Xcls_HeaderBar44 : Object - { - public Gtk.HeaderBar el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_HeaderBar44(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.HeaderBar(); - - // my vars (dec) - - // set gobject values - this.el.show_title_buttons = false; - var child_1 = new Xcls_Button45( _this ); - child_1.ref(); - this.el.pack_end ( child_1.el ); - new Xcls_btn_newproj( _this ); - this.el.pack_start ( _this.btn_newproj.el ); - new Xcls_btn_projprop( _this ); - this.el.pack_start ( _this.btn_projprop.el ); - new Xcls_btn_delproj( _this ); - this.el.pack_start ( _this.btn_delproj.el ); - new Xcls_btn_addfile( _this ); - this.el.pack_start ( _this.btn_addfile.el ); - new Xcls_btn_delfile( _this ); - this.el.pack_start ( _this.btn_delfile.el ); - } - - // user defined functions - } - public class Xcls_Button45 : Object - { - public Gtk.Button el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Button45(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.label = "Close / Cancel"; - - //listeners - this.el.clicked.connect( ( ) => { - if (BuilderApplication.windows.size < 2 && - _this.win.windowstate.file == null - ) { - BuilderApplication.singleton(null).quit(); - return; - } - - _this.el.hide(); - - if (_this.win.windowstate.file == null) { - BuilderApplication.removeWindow(_this.win); - - - - } - - }); - } - - // user defined functions - } - - public class Xcls_btn_newproj : Object - { - public Gtk.Button el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_btn_newproj(DialogFiles _owner ) - { - _this = _owner; - _this.btn_newproj = this; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - var child_1 = new Xcls_Box47( _this ); - this.el.child = child_1.el; - - //listeners - this.el.clicked.connect( ( ) => { - - // create a new file in project.. - //Xcls_DialogNewComponent.singleton().show( - var pe = EditProject.singleton(); - pe.windowstate = _this.win.windowstate; - - pe.el.application = _this.win.el.application; - pe.el.set_transient_for( _this.el ); - - var cb = new Project.Callback(); - cb.call.connect((pr) => { - _this.show( pr , _this.new_window); - }); - - pe.show( cb); - - - }); - } - - // user defined functions - public void onCreated () { - var pe = EditProject.singleton(); - - _this.show( pe.result , _this.new_window); - } - } - public class Xcls_Box47 : Object - { - public Gtk.Box el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Box47(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - - // my vars (dec) - - // set gobject values - var child_1 = new Xcls_Image48( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_Label49( _this ); - child_2.ref(); - this.el.append( child_2.el ); - } - - // user defined functions - } - public class Xcls_Image48 : Object - { - public Gtk.Image el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Image48(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Image(); - - // my vars (dec) - - // set gobject values - this.el.icon_name = "folder-new"; - this.el.margin_end = 4; - this.el.icon_size = Gtk.IconSize.NORMAL; - } - - // user defined functions - } - - public class Xcls_Label49 : Object - { - public Gtk.Label el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Label49(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Label( "New Project" ); - - // my vars (dec) - - // set gobject values - this.el.halign = Gtk.Align.START; - } - - // user defined functions - } - - - - public class Xcls_btn_projprop : Object - { - public Gtk.Button el; - private DialogFiles _this; - + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + public class Xcls_name : Object + { + public Gtk.ColumnViewColumn el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_name(DialogFiles _owner ) + { + _this = _owner; + _this.name = this; + var child_1 = new Xcls_SignalListItemFactory43( _this ); + child_1.ref(); + this.el = new Gtk.ColumnViewColumn( "General Files", child_1.el ); + + // my vars (dec) + + // set gobject values + this.el.id = "name"; + this.el.expand = true; + this.el.resizable = true; + + // init method + + { + // this.el.set_sorter( new Gtk.StringSorter( + // new Gtk.PropertyExpression(typeof(JsRender.NodeProp), null, "name") + // )); + + } + } + + // user defined functions + } + public class Xcls_SignalListItemFactory43 : Object + { + public Gtk.SignalListItemFactory el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_SignalListItemFactory43(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.SignalListItemFactory(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.setup.connect( (listitem) => { + + var expand = new Gtk.TreeExpander(); + + expand.set_indent_for_depth(true); + expand.set_indent_for_icon(true); + var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0); + var icon = new Gtk.Image(); + icon.margin_end = 4; + var lbl = new Gtk.Label(""); + lbl.use_markup = true; + + + lbl.justify = Gtk.Justification.LEFT; + lbl.xalign = 0; + + hbox.append(icon); + hbox.append(lbl); + expand.set_child(hbox); + ((Gtk.ListItem)listitem).set_child(expand); + ((Gtk.ListItem)listitem).activatable = false; + }); + this.el.bind.connect( (listitem) => { + + //GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name()); + + + + //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); + var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); + + var hbox = (Gtk.Box) expand.child; + + + var img = (Gtk.Image) hbox.get_first_child(); + var lbl = (Gtk.Label) img.get_next_sibling(); + + + + if (lbl.label != "") { // do not update + return; + } + var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item(); + //GLib.debug("LR = %s", lr.get_type().name()); + + + var jr =(JsRender.JsRender) lr.get_item(); + //GLib.debug("JR = %s", jr.get_type().name()); + + if (jr == null) { + GLib.debug("Problem getting item"); + return; + } + + jr.bind_property("icon", + img, "gicon", + GLib.BindingFlags.SYNC_CREATE); + + //GLib.debug("change %s to %s", lbl.label, np.name); + lbl.label = jr.name; // for dir's we could hsow the sub path.. + lbl.tooltip_markup = jr.path; + + expand.set_hide_expander( jr.xtype != "Dir" ); + expand.set_list_row(lr); + + + // bind image... + }); + } + + // user defined functions + } + + + + + + + + public class Xcls_HeaderBar44 : Object + { + public Gtk.HeaderBar el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_HeaderBar44(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.HeaderBar(); + + // my vars (dec) + + // set gobject values + this.el.show_title_buttons = false; + var child_1 = new Xcls_Button45( _this ); + child_1.ref(); + this.el.pack_end ( child_1.el ); + new Xcls_btn_newproj( _this ); + this.el.pack_start ( _this.btn_newproj.el ); + new Xcls_btn_projprop( _this ); + this.el.pack_start ( _this.btn_projprop.el ); + new Xcls_btn_delproj( _this ); + this.el.pack_start ( _this.btn_delproj.el ); + new Xcls_btn_addfile( _this ); + this.el.pack_start ( _this.btn_addfile.el ); + new Xcls_btn_delfile( _this ); + this.el.pack_start ( _this.btn_delfile.el ); + } + + // user defined functions + } + public class Xcls_Button45 : Object + { + public Gtk.Button el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_Button45(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Close / Cancel"; + + //listeners + this.el.clicked.connect( ( ) => { + if (BuilderApplication.windows.size < 2 && + _this.win.windowstate.file == null + ) { + BuilderApplication.singleton(null).quit(); + return; + } + + _this.el.hide(); + + if (_this.win.windowstate.file == null) { + BuilderApplication.removeWindow(_this.win); + + + + } + + }); + } + + // user defined functions + } + + public class Xcls_btn_newproj : Object + { + public Gtk.Button el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_btn_newproj(DialogFiles _owner ) + { + _this = _owner; + _this.btn_newproj = this; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Box47( _this ); + this.el.child = child_1.el; + + //listeners + this.el.clicked.connect( ( ) => { + + // create a new file in project.. + //Xcls_DialogNewComponent.singleton().show( + var pe = EditProject.singleton(); + pe.windowstate = _this.win.windowstate; + + pe.el.application = _this.win.el.application; + pe.el.set_transient_for( _this.el ); + + var cb = new Project.Callback(); + cb.call.connect((pr) => { + _this.show( pr , _this.new_window); + }); + + pe.show( cb); + + + }); + } + + // user defined functions + public void onCreated () { + var pe = EditProject.singleton(); + + _this.show( pe.result , _this.new_window); + } + } + public class Xcls_Box47 : Object + { + public Gtk.Box el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_Box47(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Image48( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_Label49( _this ); + child_2.ref(); + this.el.append( child_2.el ); + } + + // user defined functions + } + public class Xcls_Image48 : Object + { + public Gtk.Image el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_Image48(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "folder-new"; + this.el.margin_end = 4; + this.el.icon_size = Gtk.IconSize.NORMAL; + } + + // user defined functions + } + + public class Xcls_Label49 : Object + { + public Gtk.Label el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_Label49(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "New Project" ); + + // my vars (dec) + + // set gobject values + this.el.halign = Gtk.Align.START; + } + + // user defined functions + } + + + + public class Xcls_btn_projprop : Object + { + public Gtk.Button el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_btn_projprop(DialogFiles _owner ) + { + _this = _owner; + _this.btn_projprop = this; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Box51( _this ); + this.el.child = child_1.el; + + //listeners + this.el.clicked.connect( ( ) => { + // should disable the button really. + if (_this.selectedProject == null) { + return; + } + _this.win.windowstate.projectPopoverShow(_this.el, _this.selectedProject, null); + }); + } + + // user defined functions + } + public class Xcls_Box51 : Object + { + public Gtk.Box el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_Box51(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Image52( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_Label53( _this ); + child_2.ref(); + this.el.append( child_2.el ); + } + + // user defined functions + } + public class Xcls_Image52 : Object + { + public Gtk.Image el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_Image52(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "emblem-system"; + this.el.margin_end = 4; + } + + // user defined functions + } + + public class Xcls_Label53 : Object + { + public Gtk.Label el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_Label53(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Project Properties" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + public class Xcls_btn_delproj : Object + { + public Gtk.Button el; + private DialogFiles _this; + + + // my vars (def) + public DialogConfirm confirm; + + // ctor + public Xcls_btn_delproj(DialogFiles _owner ) + { + _this = _owner; + _this.btn_delproj = this; + this.el = new Gtk.Button(); + + // my vars (dec) + this.confirm = null; + + // set gobject values + var child_1 = new Xcls_Box55( _this ); + this.el.child = child_1.el; + + //listeners + this.el.clicked.connect( ( ) => { + + + if (this.confirm == null) { + this.confirm = new DialogConfirm(); + this.confirm.el.set_transient_for(_this.el); + } + + var project = (Project.Project) _this.projectsort.el.get_item( + _this.projectselection.el.selected + ); + + this.confirm.el.response.connect((res) => { + this.confirm.el.hide(); + if (res == Gtk.ResponseType.CANCEL) { + return; + } + project = (Project.Project) _this.projectsort.el.get_item( + _this.projectselection.el.selected + ); + Project.Project.remove(project); + _this.projectmodel.remove(project); + _this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION; + + }); + this.confirm.showIt("Confirm Delete Project", "Are you sure you want to delete this project?"); + }); + } + + // user defined functions + } + public class Xcls_Box55 : Object + { + public Gtk.Box el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_Box55(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Image56( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_Label57( _this ); + child_2.ref(); + this.el.append( child_2.el ); + } + + // user defined functions + } + public class Xcls_Image56 : Object + { + public Gtk.Image el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_Image56(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "user-trash"; + } + + // user defined functions + } + + public class Xcls_Label57 : Object + { + public Gtk.Label el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_Label57(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Delete Project" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + public class Xcls_btn_addfile : Object + { + public Gtk.Button el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_btn_addfile(DialogFiles _owner ) + { + _this = _owner; + _this.btn_addfile = this; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Box59( _this ); + this.el.child = child_1.el; + + //listeners + this.el.clicked.connect( () => { + // create a new file in project.. + print("add file selected\n"); + + if (_this.selectedProject == null) { + return; + } + try { + var f = JsRender.JsRender.factory(_this.selectedProject.xtype, _this.selectedProject, ""); + _this.win.windowstate.file_details.show( f, _this.el, _this.new_window ); + } catch (JsRender.Error e) {} + + }); + } + + // user defined functions + } + public class Xcls_Box59 : Object + { + public Gtk.Box el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_Box59(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Image60( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_Label61( _this ); + child_2.ref(); + this.el.append( child_2.el ); + } + + // user defined functions + } + public class Xcls_Image60 : Object + { + public Gtk.Image el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_Image60(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) - // my vars (def) + // set gobject values + this.el.icon_name = "document-new"; + this.el.margin_end = 4; + } + + // user defined functions + } + + public class Xcls_Label61 : Object + { + public Gtk.Label el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_Label61(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "New File" ); - // ctor - public Xcls_btn_projprop(DialogFiles _owner ) - { - _this = _owner; - _this.btn_projprop = this; - this.el = new Gtk.Button(); + // my vars (dec) - // my vars (dec) + // set gobject values + } - // set gobject values - var child_1 = new Xcls_Box51( _this ); - this.el.child = child_1.el; + // user defined functions + } - //listeners - this.el.clicked.connect( ( ) => { - // should disable the button really. - if (_this.selectedProject == null) { - return; - } - _this.win.windowstate.projectPopoverShow(_this.el, _this.selectedProject, null); - }); - } - // user defined functions - } - public class Xcls_Box51 : Object - { - public Gtk.Box el; - private DialogFiles _this; + public class Xcls_btn_delfile : Object + { + public Gtk.Button el; + private DialogFiles _this; + + + // my vars (def) + public DialogConfirm confirm; + + // ctor + public Xcls_btn_delfile(DialogFiles _owner ) + { + _this = _owner; + _this.btn_delfile = this; + this.el = new Gtk.Button(); + + // my vars (dec) + this.confirm = null; + + // set gobject values + var child_1 = new Xcls_Box63( _this ); + this.el.child = child_1.el; + + //listeners + this.el.clicked.connect( ( ) => { + + if (this.confirm == null) { + this.confirm = new DialogConfirm(); + this.confirm.el.set_transient_for(_this.el); + + } + GLib.debug("DELETE"); + var is_icon = true; + var isel = _this.iconsel.selectedFile(); + + if (isel == null) { + GLib.debug("DELETE - no icons selected"); + is_icon = false; + isel = _this.treeselmodel.selectedFile(); + } + if (isel == null) { + GLib.debug("DELETE - no tree item selected"); + return; // should nto happen.. + } + + GLib.debug("DELETE - calling confirm."); + this.confirm.el.response.connect((res) => { + this.confirm.el.hide(); + if (res == Gtk.ResponseType.CANCEL) { + return; + } + is_icon = true; + isel = _this.iconsel.selectedFile(); + if (isel == null) { + is_icon = false; + isel = _this.treeselmodel.selectedFile(); + } + if (isel == null) { + return; // should nto happen.. + } + + if (is_icon) { + isel.project.deleteFile(isel); + _this.gridmodel.remove(isel); + return; + } + isel.project.deleteFile(isel); + + }); + this.confirm.showIt("Confirm Delete File", + "Are you sure you want to delete this file?"); + + + + }); + } - // my vars (def) + // user defined functions + } + public class Xcls_Box63 : Object + { + public Gtk.Box el; + private DialogFiles _this; - // ctor - public Xcls_Box51(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - // my vars (dec) + // my vars (def) - // set gobject values - var child_1 = new Xcls_Image52( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_Label53( _this ); - child_2.ref(); - this.el.append( child_2.el ); - } - - // user defined functions - } - public class Xcls_Image52 : Object - { - public Gtk.Image el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Image52(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Image(); - - // my vars (dec) - - // set gobject values - this.el.icon_name = "emblem-system"; - this.el.margin_end = 4; - } - - // user defined functions - } - - public class Xcls_Label53 : Object - { - public Gtk.Label el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Label53(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Label( "Project Properties" ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - - - public class Xcls_btn_delproj : Object - { - public Gtk.Button el; - private DialogFiles _this; - - - // my vars (def) - public DialogConfirm confirm; - - // ctor - public Xcls_btn_delproj(DialogFiles _owner ) - { - _this = _owner; - _this.btn_delproj = this; - this.el = new Gtk.Button(); - - // my vars (dec) - this.confirm = null; - - // set gobject values - var child_1 = new Xcls_Box55( _this ); - this.el.child = child_1.el; - - //listeners - this.el.clicked.connect( ( ) => { - - - if (this.confirm == null) { - this.confirm = new DialogConfirm(); - this.confirm.el.set_transient_for(_this.el); - } - - var project = (Project.Project) _this.projectsort.el.get_item( - _this.projectselection.el.selected - ); - - this.confirm.el.response.connect((res) => { - this.confirm.el.hide(); - if (res == Gtk.ResponseType.CANCEL) { - return; - } - project = (Project.Project) _this.projectsort.el.get_item( - _this.projectselection.el.selected - ); - Project.Project.remove(project); - _this.projectmodel.remove(project); - _this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION; - - }); - this.confirm.showIt("Confirm Delete Project", "Are you sure you want to delete this project?"); - }); - } + // ctor + public Xcls_Box63(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - // user defined functions - } - public class Xcls_Box55 : Object - { - public Gtk.Box el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Box55(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - - // my vars (dec) - - // set gobject values - var child_1 = new Xcls_Image56( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_Label57( _this ); - child_2.ref(); - this.el.append( child_2.el ); - } - - // user defined functions - } - public class Xcls_Image56 : Object - { - public Gtk.Image el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Image56(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Image(); - - // my vars (dec) - - // set gobject values - this.el.icon_name = "user-trash"; - } - - // user defined functions - } - - public class Xcls_Label57 : Object - { - public Gtk.Label el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Label57(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Label( "Delete Project" ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - - - public class Xcls_btn_addfile : Object - { - public Gtk.Button el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_btn_addfile(DialogFiles _owner ) - { - _this = _owner; - _this.btn_addfile = this; - this.el = new Gtk.Button(); + // my vars (dec) - // my vars (dec) + // set gobject values + var child_1 = new Xcls_Image64( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_Label65( _this ); + child_2.ref(); + this.el.append( child_2.el ); + } + + // user defined functions + } + public class Xcls_Image64 : Object + { + public Gtk.Image el; + private DialogFiles _this; - // set gobject values - var child_1 = new Xcls_Box59( _this ); - this.el.child = child_1.el; - //listeners - this.el.clicked.connect( () => { - // create a new file in project.. - print("add file selected\n"); - - if (_this.selectedProject == null) { - return; - } - try { - var f = JsRender.JsRender.factory(_this.selectedProject.xtype, _this.selectedProject, ""); - _this.win.windowstate.file_details.show( f, _this.el, _this.new_window ); - } catch (JsRender.Error e) {} - - }); - } + // my vars (def) - // user defined functions - } - public class Xcls_Box59 : Object - { - public Gtk.Box el; - private DialogFiles _this; + // ctor + public Xcls_Image64(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + // my vars (dec) + + // set gobject values + this.el.icon_name = "user-trash"; + } + + // user defined functions + } + + public class Xcls_Label65 : Object + { + public Gtk.Label el; + private DialogFiles _this; + + + // my vars (def) + + // ctor + public Xcls_Label65(DialogFiles _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Delete File" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } - // my vars (def) - // ctor - public Xcls_Box59(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - // my vars (dec) - // set gobject values - var child_1 = new Xcls_Image60( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_Label61( _this ); - child_2.ref(); - this.el.append( child_2.el ); - } - - // user defined functions - } - public class Xcls_Image60 : Object - { - public Gtk.Image el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Image60(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Image(); - - // my vars (dec) - - // set gobject values - this.el.icon_name = "document-new"; - this.el.margin_end = 4; - } - - // user defined functions - } - - public class Xcls_Label61 : Object - { - public Gtk.Label el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Label61(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Label( "New File" ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - - - public class Xcls_btn_delfile : Object - { - public Gtk.Button el; - private DialogFiles _this; - - - // my vars (def) - public DialogConfirm confirm; - - // ctor - public Xcls_btn_delfile(DialogFiles _owner ) - { - _this = _owner; - _this.btn_delfile = this; - this.el = new Gtk.Button(); - - // my vars (dec) - this.confirm = null; - - // set gobject values - var child_1 = new Xcls_Box63( _this ); - this.el.child = child_1.el; - - //listeners - this.el.clicked.connect( ( ) => { - - if (this.confirm == null) { - this.confirm = new DialogConfirm(); - this.confirm.el.set_transient_for(_this.el); - - } - GLib.debug("DELETE"); - var is_icon = true; - var isel = _this.iconsel.selectedFile(); - - if (isel == null) { - GLib.debug("DELETE - no icons selected"); - is_icon = false; - isel = _this.treeselmodel.selectedFile(); - } - if (isel == null) { - GLib.debug("DELETE - no tree item selected"); - return; // should nto happen.. - } - - GLib.debug("DELETE - calling confirm."); - this.confirm.el.response.connect((res) => { - this.confirm.el.hide(); - if (res == Gtk.ResponseType.CANCEL) { - return; - } - is_icon = true; - isel = _this.iconsel.selectedFile(); - if (isel == null) { - is_icon = false; - isel = _this.treeselmodel.selectedFile(); - } - if (isel == null) { - return; // should nto happen.. - } - - if (is_icon) { - isel.project.deleteFile(isel); - _this.gridmodel.remove(isel); - return; - } - isel.project.deleteFile(isel); - - }); - this.confirm.showIt("Confirm Delete File", - "Are you sure you want to delete this file?"); - - - - }); - } - - // user defined functions - } - public class Xcls_Box63 : Object - { - public Gtk.Box el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Box63(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - - // my vars (dec) - - // set gobject values - var child_1 = new Xcls_Image64( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_Label65( _this ); - child_2.ref(); - this.el.append( child_2.el ); - } - - // user defined functions - } - public class Xcls_Image64 : Object - { - public Gtk.Image el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Image64(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Image(); - - // my vars (dec) - - // set gobject values - this.el.icon_name = "user-trash"; - } - - // user defined functions - } - - public class Xcls_Label65 : Object - { - public Gtk.Label el; - private DialogFiles _this; - - - // my vars (def) - - // ctor - public Xcls_Label65(DialogFiles _owner ) - { - _this = _owner; - this.el = new Gtk.Label( "Delete File" ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - - - - } +} diff --git a/src/Builder4/Editor.bjs b/src/Builder4/Editor.bjs index 038d0a778..b1a00f997 100644 --- a/src/Builder4/Editor.bjs +++ b/src/Builder4/Editor.bjs @@ -1,5 +1,6 @@ { "build_module" : "builder", + "gen_extended" : false, "items" : [ { "# GtkSource.SearchContext searchcontext" : "null", @@ -203,12 +204,7 @@ "\tGtkSource.SpaceTypeFlags.ALL", ");", "this.el.get_space_drawer().set_enable_matrix(true);", - "/*", - "Gtk.SourceDrawSpacesFlags.LEADING + ", - "Gtk.SourceDrawSpacesFlags.TRAILING + ", - "Gtk.SourceDrawSpacesFlags.TAB + ", - "Gtk.SourceDrawSpacesFlags.SPACE", - "*/" + "" ], "* prop" : "child", "bool has_tooltip" : true, @@ -225,9 +221,26 @@ "$ Gee.HashMap? xmarks" : "null", "$ xns" : "GtkSource", "$ xtype" : "Buffer", + "* init" : [ + "{", + "\tvar buf = this.el;", + "\tbuf.create_tag (\"bold\", \"weight\", Pango.Weight.BOLD);", + " buf.create_tag (\"type\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#204a87\");", + " buf.create_tag (\"keyword\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#a40000\");", + " buf.create_tag (\"text\", \"weight\", Pango.Weight.NORMAL, \"foreground\", \"#729fcf\");", + " buf.create_tag (\"number\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#ad7fa8\");", + " buf.create_tag (\"method\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#729fcf\");", + " buf.create_tag (\"property\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#BC1F51\");", + " buf.create_tag (\"variable\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#A518B5\");", + "", + "}", + "" + ], "* prop" : "buffer", "bool check_queued" : false, "bool enable_undo" : true, + "bool highlight_matching_brackets" : true, + "bool highlight_syntax" : true, "id" : "buffer", "int error_line" : "-1", "listeners" : { @@ -273,6 +286,7 @@ " var oldcode =_this.file.toSource();", " _this.file.setSource(str);", " _this.file.getLanguageServer().document_change(_this.file);", + "\t BuilderApplication.showSpinner(\"appointment soon\",\"document change pending\");", " _this.file.setSource(oldcode);", " ", "\t\t ", @@ -479,10 +493,28 @@ "\tif (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", "\t GLib.debug(\"SAVE: ctrl-f pressed\");", "\t\t_this.search_entry.el.grab_focus();", + "\t\t_this.search_entry.el.select_region(0,-1);", "\t return;", "\t}", + "\tif (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", + "\t\t_this.view.el.show_completion();", + "\t}", + "\t", + "\tGtk.TextIter iter;", + "\t_this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position); ", + "\tvar line = iter.get_line();", + "\tvar offset = iter.get_line_offset();", + "\tGLib.debug(\"line %d off %d\", line ,offset);", + "\tif (_this.prop != null) {", + "\t\tline += _this.prop.start_line + 1; // i think..", + "\t\toffset += 12; // should probably be 8 without namespaced ", + "\t\tGLib.debug(\"guess line %d off %d\", line ,offset);", + "\t} ", " //_this.view.el.show_completion();", " // print(event.key.keyval)", + " ", + " ", + " ", " ", " return;", " ", @@ -893,6 +925,36 @@ "}", "" ], + "| string tempFileContents" : [ + "() {", + " ", + " ", + " if (_this.file == null) {", + " return \"\";", + " }", + "\tvar str= this.buffer.toString();", + "\tif (_this.file.xtype == \"PlainFile\") {", + " ", + " \treturn str;", + " ", + " }", + " ", + " ", + " ", + " GLib.debug(\"calling validate\"); ", + " // clear the buttons.", + " \tif (_this.prop.name == \"xns\" || _this.prop.name == \"xtype\") {", + "\t\treturn this.file.toSource(); ;", + "\t}", + "\t", + "\tvar oldcode = _this.prop.val;", + "\t_this.prop.val = str;", + " var ret = _this.file.toSource();", + " _this.prop.val = oldcode;", + " return ret;", + " ", + "}" + ], "| void backSearch" : [ "(bool change_focus) {", "", @@ -924,7 +986,7 @@ "\tif (this.searchcontext == null) {", "\t\treturn;", "\t} ", - "\t", + "", "\tGtk.TextIter beg, st,en;", "\t bool has_wrapped_around;", "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end);", @@ -1011,7 +1073,7 @@ "", "\tbuf.remove_source_marks (start, end, category);", " ", - "\tGLib.debug(\"highlight errors\");\t\t ", + "\t//GLib.debug(\"highlight errors\");\t\t ", "", "\t // we should highlight other types of errors..", "", @@ -1019,7 +1081,7 @@ "\t\t&&", "\t\t_this.window.windowstate.state != WindowState.State.CODE", "\t\t) {", - "\t\tGLib.debug(\"windowstate != CODEONLY?\");", + "\t\t//GLib.debug(\"windowstate != CODEONLY?\");", "\t\t", "\t\treturn;", "\t} ", @@ -1032,7 +1094,7 @@ "\t}", "\tvar ar = this.file.getErrors(category);", "\tif (ar == null || ar.get_n_items() < 1) {", - "\t\tGLib.debug(\"highlight %s : %s has no errors\", this.file.relpath, category);", + "\t\t//GLib.debug(\"highlight %s : %s has no errors\", this.file.relpath, category);", "\t\treturn;", "\t}", " ", @@ -1045,10 +1107,11 @@ "\tvar tlines = buf.get_line_count () +1;", "\t", "\tif (_this.prop != null) {", - "\t", - "\t\ttlines = _this.prop.end_line + 1;", - "\t\toffset = _this.prop.start_line + 1;", - "\t", + "\t\t// this still seems flaky...", + "\t\t", + "\t\ttlines = _this.prop.end_line;", + "\t\toffset = _this.prop.start_line;", + "\t\t ", "\t}", "\t ", "\tfor (var i = 0; i < ar.get_n_items();i++) {", @@ -1057,8 +1120,8 @@ "\t Gtk.TextIter iter;", "// print(\"get inter\\n\");", "\t var eline = err.line - offset;", - "\t GLib.debug(\"GOT ERROR on line %d -- converted to %d (offset = %d)\",", - "\t \terr.line ,eline, offset);", + "\t //GLib.debug(\"GOT ERROR on line %d -- converted to %d (offset = %d)\",", + "\t //\terr.line ,eline, offset);", "\t ", "\t ", "\t if (eline > tlines || eline < 0) {", @@ -1071,7 +1134,7 @@ "\t ", "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, err.category, err.msg);", "\t buf.create_source_mark( msg, err.category, iter);", - "\t GLib.debug(\"set line %d to %s\", eline, msg);", + "\t // GLib.debug(\"set line %d to %s\", eline, msg);", "\t //this.marks.set(eline, msg);", "\t}", "\treturn ;", @@ -1084,10 +1147,5 @@ ] } ], - "modOrder" : "", - "name" : "Editor", - "parent" : "", - "path" : "/home/alan/gitlive/roobuilder/src/Builder4/Editor.bjs", - "permname" : "", - "title" : "" + "name" : "Editor" } \ No newline at end of file diff --git a/src/Builder4/Editor.vala b/src/Builder4/Editor.vala index c1cca4bcb..845175e2d 100644 --- a/src/Builder4/Editor.vala +++ b/src/Builder4/Editor.vala @@ -2,1492 +2,1536 @@ static Editor _Editor; public class Editor : Object { - public Gtk.Box el; - private Editor _this; - - public static Editor singleton() - { - if (_Editor == null) { - _Editor= new Editor(); - } - return _Editor; - } - public Xcls_save_button save_button; - public Xcls_close_btn close_btn; - public Xcls_RightEditor RightEditor; - public Xcls_view view; - public Xcls_buffer buffer; - public Xcls_search_entry search_entry; - public Xcls_search_results search_results; - public Xcls_nextBtn nextBtn; - public Xcls_backBtn backBtn; - public Xcls_search_settings search_settings; - public Xcls_case_sensitive case_sensitive; - public Xcls_regex regex; - public Xcls_multiline multiline; - - // my vars (def) - public int pos_root_x; - public Xcls_MainWindow window; - public bool dirty; - public int pos_root_y; - public bool pos; - public GtkSource.SearchContext searchcontext; - public int last_search_end; - public signal void save (); - public JsRender.JsRender? file; - public JsRender.Node node; - public JsRender.NodeProp? prop; - public string activeEditor; - - // ctor - public Editor() - { - _this = this; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - this.window = null; - this.dirty = false; - this.pos = false; - this.searchcontext = null; - this.last_search_end = 0; - this.file = null; - this.node = null; - this.prop = null; - this.activeEditor = ""; - - // set gobject values - this.el.homogeneous = false; - this.el.hexpand = true; - this.el.vexpand = true; - var child_1 = new Xcls_Box2( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_RightEditor( _this ); - child_2.ref(); - this.el.append( child_2.el ); - var child_3 = new Xcls_Box12( _this ); - child_3.ref(); - this.el.append ( child_3.el ); - } - - // user defined functions - public bool saveContents () { - - - if (_this.file == null) { - return true; - } - - - - var str = _this.buffer.toString(); - - _this.buffer.checkSyntax(); - - - - // LeftPanel.model.changed( str , false); - _this.dirty = false; - _this.save_button.el.sensitive = false; - - // find the text for the node.. - if (_this.file.xtype != "PlainFile") { - // in theory these properties have to exist!?! - this.prop.val = str; - //this.window.windowstate.left_props.reload(); - } else { - _this.file.setSource( str ); - } - - // call the signal.. - this.save(); - - return true; - - } - public void forwardSearch (bool change_focus) { - - if (this.searchcontext == null) { - return; - } - - Gtk.TextIter beg, st,en; - bool has_wrapped_around; - this.buffer.el.get_iter_at_offset(out beg, this.last_search_end); - if (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) { - - this.last_search_end = 0; // not sure if this should happen - } else { - if (has_wrapped_around) { - return; - } - - this.last_search_end = en.get_offset(); - if (change_focus) { - this.view.el.grab_focus(); - } - this.buffer.el.place_cursor(st); - this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f); - } - - } - public void show (JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop) - { - this.reset(); - this.file = file; - - if (file.xtype != "PlainFile") { - this.prop = prop; - this.node = node; - - // find the text for the node.. - this.view.load( prop.val ); - - - this.close_btn.el.show(); - - } else { - this.view.load( file.toSource() ); - this.close_btn.el.hide(); - } - - } - public void backSearch (bool change_focus) { - - if (this.searchcontext == null) { - return; - } - - Gtk.TextIter beg, st,en; - bool has_wrapped_around; - this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 ); - - if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) { - this.last_search_end = 0; - } else { - this.last_search_end = en.get_offset(); - if (change_focus) { - this.view.el.grab_focus(); - } - this.buffer.el.place_cursor(st); - this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f); - } - - } - public void reset () { - this.file = null; - - this.node = null; - this.prop = null; - this.searchcontext = null; - - } - public int search (string in_txt) { - - var s = new GtkSource.SearchSettings(); - s.case_sensitive = _this.case_sensitive.el.active; - s.regex_enabled = _this.regex.el.active; - s.wrap_around = false; - - this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s); - this.searchcontext.set_highlight(true); - var txt = in_txt; - - if (_this.multiline.el.active) { - txt = in_txt.replace("\\n", "\n"); - } - - s.set_search_text(txt); - Gtk.TextIter beg, st,en; - - this.buffer.el.get_start_iter(out beg); - bool has_wrapped_around; - this.searchcontext.forward(beg, out st, out en, out has_wrapped_around); - this.last_search_end = 0; - - return this.searchcontext.get_occurrences_count(); - - - - - } - public void updateErrorMarks (string category) { - - - - var buf = _this.buffer.el; - Gtk.TextIter start; - Gtk.TextIter end; - buf.get_bounds (out start, out end); - - buf.remove_source_marks (start, end, category); - - GLib.debug("highlight errors"); - - // we should highlight other types of errors.. - - if (_this.window.windowstate.state != WindowState.State.CODEONLY - && - _this.window.windowstate.state != WindowState.State.CODE - ) { - GLib.debug("windowstate != CODEONLY?"); - - return; - } - - - if (_this.file == null) { - GLib.debug("file is null?"); - return; - - } - var ar = this.file.getErrors(category); - if (ar == null || ar.get_n_items() < 1) { - GLib.debug("highlight %s : %s has no errors", this.file.relpath, category); - return; - } - - - - - var offset = 0; - - - var tlines = buf.get_line_count () +1; - - if (_this.prop != null) { - - tlines = _this.prop.end_line + 1; - offset = _this.prop.start_line + 1; - - } - - for (var i = 0; i < ar.get_n_items();i++) { - var err = (Palete.CompileError) ar.get_item(i); - - Gtk.TextIter iter; - // print("get inter\n"); - var eline = err.line - offset; - GLib.debug("GOT ERROR on line %d -- converted to %d (offset = %d)", - err.line ,eline, offset); - - - if (eline > tlines || eline < 0) { - return; - } - - - buf.get_iter_at_line( out iter, eline); - - - var msg = "Line: %d %s : %s".printf(eline+1, err.category, err.msg); - buf.create_source_mark( msg, err.category, iter); - GLib.debug("set line %d to %s", eline, msg); - //this.marks.set(eline, msg); - } - return ; - - - - - - } - public void scroll_to_line (int line) { - - GLib.Timeout.add(500, () => { - - var buf = this.view.el.get_buffer(); - - var sbuf = (GtkSource.Buffer) buf; - - - Gtk.TextIter iter; - sbuf.get_iter_at_line(out iter, line); - this.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); - return false; - }); - } - public class Xcls_Box2 : Object - { - public Gtk.Box el; - private Editor _this; - - - // my vars (def) - - // ctor - public Xcls_Box2(Editor _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.homogeneous = false; - this.el.hexpand = true; - var child_1 = new Xcls_save_button( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_Label4( _this ); - child_2.ref(); - this.el.append( child_2.el ); - var child_3 = new Xcls_Scale5( _this ); - child_3.ref(); - this.el.append( child_3.el ); - var child_4 = new Xcls_close_btn( _this ); - child_4.ref(); - this.el.append( child_4.el ); - } - - // user defined functions - } - public class Xcls_save_button : Object - { - public Gtk.Button el; - private Editor _this; - - - // my vars (def) - - // ctor - public Xcls_save_button(Editor _owner ) - { - _this = _owner; - _this.save_button = this; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.label = "Save"; - - //listeners - this.el.clicked.connect( () => { - _this.saveContents(); - }); - } - - // user defined functions - } - - public class Xcls_Label4 : Object - { - public Gtk.Label el; - private Editor _this; - - - // my vars (def) - - // ctor - public Xcls_Label4(Editor _owner ) - { - _this = _owner; - this.el = new Gtk.Label( null ); - - // my vars (dec) - - // set gobject values - this.el.hexpand = true; - } - - // user defined functions - } - - public class Xcls_Scale5 : Object - { - public Gtk.Scale el; - private Editor _this; - - - // my vars (def) - - // ctor - public Xcls_Scale5(Editor _owner ) - { - _this = _owner; - this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1); + public Gtk.Box el; + private Editor _this; + + public static Editor singleton() + { + if (_Editor == null) { + _Editor= new Editor(); + } + return _Editor; + } + public Xcls_save_button save_button; + public Xcls_close_btn close_btn; + public Xcls_RightEditor RightEditor; + public Xcls_view view; + public Xcls_buffer buffer; + public Xcls_search_entry search_entry; + public Xcls_search_results search_results; + public Xcls_nextBtn nextBtn; + public Xcls_backBtn backBtn; + public Xcls_search_settings search_settings; + public Xcls_case_sensitive case_sensitive; + public Xcls_regex regex; + public Xcls_multiline multiline; + + // my vars (def) + public int pos_root_x; + public Xcls_MainWindow window; + public bool dirty; + public int pos_root_y; + public bool pos; + public GtkSource.SearchContext searchcontext; + public int last_search_end; + public signal void save (); + public JsRender.JsRender? file; + public JsRender.Node node; + public JsRender.NodeProp? prop; + public string activeEditor; + + // ctor + public Editor() + { + _this = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + this.window = null; + this.dirty = false; + this.pos = false; + this.searchcontext = null; + this.last_search_end = 0; + this.file = null; + this.node = null; + this.prop = null; + this.activeEditor = ""; + + // set gobject values + this.el.homogeneous = false; + this.el.hexpand = true; + this.el.vexpand = true; + var child_1 = new Xcls_Box2( _this ); + child_1.ref(); + this.el.append( child_1.el ); + new Xcls_RightEditor( _this ); + this.el.append( _this.RightEditor.el ); + var child_3 = new Xcls_Box12( _this ); + child_3.ref(); + this.el.append ( child_3.el ); + } + + // user defined functions + public bool saveContents () { + + + if (_this.file == null) { + return true; + } + + + + var str = _this.buffer.toString(); + + _this.buffer.checkSyntax(); + + + + // LeftPanel.model.changed( str , false); + _this.dirty = false; + _this.save_button.el.sensitive = false; + + // find the text for the node.. + if (_this.file.xtype != "PlainFile") { + // in theory these properties have to exist!?! + this.prop.val = str; + //this.window.windowstate.left_props.reload(); + } else { + _this.file.setSource( str ); + } + + // call the signal.. + this.save(); + + return true; + + } + public void forwardSearch (bool change_focus) { + + if (this.searchcontext == null) { + return; + } + + Gtk.TextIter beg, st,en; + bool has_wrapped_around; + this.buffer.el.get_iter_at_offset(out beg, this.last_search_end); + if (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) { + + this.last_search_end = 0; // not sure if this should happen + } else { + if (has_wrapped_around) { + return; + } + + this.last_search_end = en.get_offset(); + if (change_focus) { + this.view.el.grab_focus(); + } + this.buffer.el.place_cursor(st); + this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f); + } + + } + public void show (JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop) + { + this.reset(); + this.file = file; + + if (file.xtype != "PlainFile") { + this.prop = prop; + this.node = node; + + // find the text for the node.. + this.view.load( prop.val ); + + + this.close_btn.el.show(); + + } else { + this.view.load( file.toSource() ); + this.close_btn.el.hide(); + } + + } + public void backSearch (bool change_focus) { + + if (this.searchcontext == null) { + return; + } + + Gtk.TextIter beg, st,en; + bool has_wrapped_around; + this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 ); + + if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) { + this.last_search_end = 0; + } else { + this.last_search_end = en.get_offset(); + if (change_focus) { + this.view.el.grab_focus(); + } + this.buffer.el.place_cursor(st); + this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f); + } + + } + public string tempFileContents () { + + + if (_this.file == null) { + return ""; + } + var str= this.buffer.toString(); + if (_this.file.xtype == "PlainFile") { + + return str; + + } + + + + GLib.debug("calling validate"); + // clear the buttons. + if (_this.prop.name == "xns" || _this.prop.name == "xtype") { + return this.file.toSource(); ; + } + + var oldcode = _this.prop.val; + _this.prop.val = str; + var ret = _this.file.toSource(); + _this.prop.val = oldcode; + return ret; + + } + public void reset () { + this.file = null; + + this.node = null; + this.prop = null; + this.searchcontext = null; + + } + public int search (string in_txt) { + + var s = new GtkSource.SearchSettings(); + s.case_sensitive = _this.case_sensitive.el.active; + s.regex_enabled = _this.regex.el.active; + s.wrap_around = false; + + this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s); + this.searchcontext.set_highlight(true); + var txt = in_txt; + + if (_this.multiline.el.active) { + txt = in_txt.replace("\\n", "\n"); + } + + s.set_search_text(txt); + Gtk.TextIter beg, st,en; + + this.buffer.el.get_start_iter(out beg); + bool has_wrapped_around; + this.searchcontext.forward(beg, out st, out en, out has_wrapped_around); + this.last_search_end = 0; + + return this.searchcontext.get_occurrences_count(); + + + + + } + public void updateErrorMarks (string category) { + + + + var buf = _this.buffer.el; + Gtk.TextIter start; + Gtk.TextIter end; + buf.get_bounds (out start, out end); + + buf.remove_source_marks (start, end, category); + + //GLib.debug("highlight errors"); + + // we should highlight other types of errors.. + + if (_this.window.windowstate.state != WindowState.State.CODEONLY + && + _this.window.windowstate.state != WindowState.State.CODE + ) { + //GLib.debug("windowstate != CODEONLY?"); + + return; + } + + + if (_this.file == null) { + GLib.debug("file is null?"); + return; + + } + var ar = this.file.getErrors(category); + if (ar == null || ar.get_n_items() < 1) { + //GLib.debug("highlight %s : %s has no errors", this.file.relpath, category); + return; + } + + + + + var offset = 0; + + + var tlines = buf.get_line_count () +1; + + if (_this.prop != null) { + // this still seems flaky... + + tlines = _this.prop.end_line; + offset = _this.prop.start_line; + + } + + for (var i = 0; i < ar.get_n_items();i++) { + var err = (Palete.CompileError) ar.get_item(i); + + Gtk.TextIter iter; + // print("get inter\n"); + var eline = err.line - offset; + //GLib.debug("GOT ERROR on line %d -- converted to %d (offset = %d)", + // err.line ,eline, offset); + + + if (eline > tlines || eline < 0) { + return; + } + + + buf.get_iter_at_line( out iter, eline); + + + var msg = "Line: %d %s : %s".printf(eline+1, err.category, err.msg); + buf.create_source_mark( msg, err.category, iter); + // GLib.debug("set line %d to %s", eline, msg); + //this.marks.set(eline, msg); + } + return ; + + + + + + } + public void scroll_to_line (int line) { + + GLib.Timeout.add(500, () => { + + var buf = this.view.el.get_buffer(); + + var sbuf = (GtkSource.Buffer) buf; + + + Gtk.TextIter iter; + sbuf.get_iter_at_line(out iter, line); + this.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); + return false; + }); + } + public class Xcls_Box2 : Object + { + public Gtk.Box el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_Box2(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + this.el.hexpand = true; + new Xcls_save_button( _this ); + this.el.append( _this.save_button.el ); + var child_2 = new Xcls_Label4( _this ); + child_2.ref(); + this.el.append( child_2.el ); + var child_3 = new Xcls_Scale5( _this ); + child_3.ref(); + this.el.append( child_3.el ); + new Xcls_close_btn( _this ); + this.el.append( _this.close_btn.el ); + } + + // user defined functions + } + public class Xcls_save_button : Object + { + public Gtk.Button el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_save_button(Editor _owner ) + { + _this = _owner; + _this.save_button = this; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Save"; + + //listeners + this.el.clicked.connect( () => { + _this.saveContents(); + }); + } + + // user defined functions + } + + public class Xcls_Label4 : Object + { + public Gtk.Label el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_Label4(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.Label( null ); + + // my vars (dec) + + // set gobject values + this.el.hexpand = true; + } + + // user defined functions + } + + public class Xcls_Scale5 : Object + { + public Gtk.Scale el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_Scale5(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.width_request = 200; - this.el.has_origin = true; - this.el.draw_value = false; - this.el.digits = 0; - this.el.sensitive = true; - - // init method - - { - this.el.set_range(6,30); - this.el.set_value(8); - } - - //listeners - this.el.change_value.connect( (st, val ) => { - - - _this.view.css.load_from_string( - "#editor-view { font: %dpx monospace; }".printf((int)val) - ); - - return false; - }); - } + // set gobject values + this.el.width_request = 200; + this.el.has_origin = true; + this.el.draw_value = false; + this.el.digits = 0; + this.el.sensitive = true; - // user defined functions - } + // init method + + { + this.el.set_range(6,30); + this.el.set_value(8); + } + + //listeners + this.el.change_value.connect( (st, val ) => { + + + _this.view.css.load_from_string( + "#editor-view { font: %dpx monospace; }".printf((int)val) + ); + + return false; + }); + } - public class Xcls_close_btn : Object - { - public Gtk.Button el; - private Editor _this; + // user defined functions + } + public class Xcls_close_btn : Object + { + public Gtk.Button el; + private Editor _this; - // my vars (def) - // ctor - public Xcls_close_btn(Editor _owner ) - { - _this = _owner; - _this.close_btn = this; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.icon_name = "window-close"; - var child_1 = new Xcls_Image7( _this ); - child_1.ref(); - this.el.child = child_1.el; - - //listeners - this.el.clicked.connect( () => { - _this.saveContents(); - _this.window.windowstate.switchState(WindowState.State.PREVIEW); - }); - } - - // user defined functions - } - public class Xcls_Image7 : Object - { - public Gtk.Image el; - private Editor _this; - - - // my vars (def) - - // ctor - public Xcls_Image7(Editor _owner ) - { - _this = _owner; - this.el = new Gtk.Image(); - - // my vars (dec) - - // set gobject values - this.el.icon_name = "window-close"; - this.el.icon_size = Gtk.IconSize.NORMAL; - } - - // user defined functions - } - - - - public class Xcls_RightEditor : Object - { - public Gtk.ScrolledWindow el; - private Editor _this; - - - // my vars (def) - - // ctor - public Xcls_RightEditor(Editor _owner ) - { - _this = _owner; - _this.RightEditor = this; - this.el = new Gtk.ScrolledWindow(); - - // my vars (dec) - - // set gobject values - this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC; - this.el.vexpand = true; - this.el.overlay_scrolling = false; - this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC; - var child_1 = new Xcls_view( _this ); - child_1.ref(); - this.el.child = child_1.el; - } - - // user defined functions - } - public class Xcls_view : Object - { - public GtkSource.View el; - private Editor _this; - - - // my vars (def) - public Gtk.CssProvider css; - - // ctor - public Xcls_view(Editor _owner ) - { - _this = _owner; - _this.view = this; - this.el = new GtkSource.View(); - - // my vars (dec) - this.css = null; - - // set gobject values - this.el.auto_indent = true; - this.el.indent_width = 4; - this.el.name = "editor-view"; - this.el.show_line_marks = true; - this.el.insert_spaces_instead_of_tabs = true; - this.el.show_line_numbers = true; - this.el.hexpand = true; - this.el.vexpand = true; - this.el.has_tooltip = true; - this.el.tab_width = 4; - this.el.highlight_current_line = true; - var child_1 = new Xcls_buffer( _this ); - child_1.ref(); - this.el.buffer = child_1.el; - var child_2 = new Xcls_EventControllerKey11( _this ); - child_2.ref(); - this.el.add_controller( child_2.el ); - - // init method - - this.css = new Gtk.CssProvider(); - - this.css.load_from_string( - "#editor-view { font: 12px monospace;}" - ); - - Gtk.StyleContext.add_provider_for_display( - this.el.get_display(), - this.css, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - ); - - - - /* - this is pretty flakey - triggers Gtk with < 0 d - var cp = new GtkSource.CompletionWords("test"); - cp.minimum_word_size = 3; - //cp.priority = 100; //?? does this do anything - cp.proposals_batch_size = 10; - cp.scan_batch_size = 1000; - - cp.register(_this.buffer.el); - this.el.completion.add_provider(cp); - */ - this.el.completion.add_provider(new Palete.CompletionProvider(_this)); - - //this.el.completion.unblock_interactive(); - this.el.completion.select_on_show = true; // select - //this.el.completion.remember_info_visibility = true; - - - var attrs = new GtkSource.MarkAttributes(); - var pink = Gdk.RGBA(); - pink.parse ( "pink"); - attrs.set_background ( pink); - attrs.set_icon_name ( "process-stop"); - attrs.query_tooltip_text.connect(( mark) => { - GLib.debug("tooltip query? %s", mark.name); - return strdup( mark.name); - }); - attrs.query_tooltip_markup.connect(( mark) => { - GLib.debug("tooltip query? %s", mark.name); - return strdup( mark.name); - }); - this.el.set_mark_attributes ("ERR", attrs, 1); - attrs.ref(); - var wattrs = new GtkSource.MarkAttributes(); - var blue = Gdk.RGBA(); - blue.parse ( "#ABF4EB"); - wattrs.set_background ( blue); - wattrs.set_icon_name ( "process-stop"); - wattrs.query_tooltip_text.connect(( mark) => { - GLib.debug("tooltip query? %s", mark.name); - return strdup(mark.name); - }); - wattrs.query_tooltip_markup.connect(( mark) => { - GLib.debug("tooltip query? %s", mark.name); - return strdup(mark.name); - }); - this.el.set_mark_attributes ("WARN", wattrs, 1); - wattrs.ref(); - - - var dattrs = new GtkSource.MarkAttributes(); - var purple = Gdk.RGBA(); - purple.parse ( "#EEA9FF"); - dattrs.set_background ( purple); - dattrs.set_icon_name ( "process-stop"); - dattrs.query_tooltip_text.connect(( mark) => { - GLib.debug("tooltip query? %s", mark.name); - return strdup(mark.name); - }); - dattrs.query_tooltip_markup.connect(( mark) => { - GLib.debug("tooltip query? %s", mark.name); - return strdup(mark.name); - }); - this.el.set_mark_attributes ("DEPR", dattrs, 1); - dattrs.ref(); - - this.el.get_space_drawer().set_matrix(null); - this.el.get_space_drawer().set_types_for_locations( - GtkSource.SpaceLocationFlags.ALL, - GtkSource.SpaceTypeFlags.ALL - ); - this.el.get_space_drawer().set_enable_matrix(true); - /* - Gtk.SourceDrawSpacesFlags.LEADING + - Gtk.SourceDrawSpacesFlags.TRAILING + - Gtk.SourceDrawSpacesFlags.TAB + - Gtk.SourceDrawSpacesFlags.SPACE - */ - - //listeners - this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => { - - //GLib.debug("query tooltip"); - Gtk.TextIter iter; - int trailing; - - var yoff = (int) _this.RightEditor.el.vadjustment.value; - - // I think this is problematic - if it's compliing / updating at same time as query. - - //if (_this.window.statusbar_compile_spinner.el.spinning) { - // return false; - //} - - this.el.get_iter_at_position (out iter, out trailing, x, y + yoff); - - var l = iter.get_line(); - - - - // GLib.debug("query tooltip line %d", (int) l); - if (l < 0) { - - return false; - } - /* - if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) { - GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l)); - tooltip.set_text(_this.buffer.marks.get(l).dup()); - return true; - } - - return false; - */ - - - // this crashes?? - not sure why. - var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR"); - if (marks.is_empty()) { - marks = _this.buffer.el.get_source_marks_at_line(l, "WARN"); - } - if (marks.is_empty()) { - marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR"); - } - - // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length()); - var str = ""; - marks.@foreach((m) => { - //GLib.debug("got mark %s", m.name); - str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name; - }); - // true if there is a mark.. - if (str.length > 0 ) { - tooltip.set_text( str ); - } - return str.length > 0 ? true : false; - - }); - } - - // user defined functions - public void load (string str) { - - // show the help page for the active node.. - //this.get('/Help').show(); - - // this.get('/BottomPane').el.set_current_page(0); - GLib.debug("load called - Reset undo buffer"); - - var buf = (GtkSource.Buffer)this.el.get_buffer(); - buf.begin_irreversible_action(); - buf.set_text(str, str.length); - buf.end_irreversible_action(); - - var lm = GtkSource.LanguageManager.get_default(); - var lang = "vala"; - if (_this.file != null) { - lang = _this.file.language; - } - print("lang=%s, content_type = %s\n", lang, _this.file.content_type); - var lg = _this.file.content_type.length > 0 ? - lm.guess_language(_this.file.path, _this.file.content_type) : - lm.get_language(lang); - - - ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg); - - this.el.insert_spaces_instead_of_tabs = true; - if (lg != null) { - print("sourcelanguage = %s\n", lg.name); - if (lg.name == "Vala") { - this.el.insert_spaces_instead_of_tabs = false; - } - } - _this.dirty = false; - this.el.grab_focus(); - _this.save_button.el.sensitive = false; - } - } - public class Xcls_buffer : Object - { - public GtkSource.Buffer el; - private Editor _this; - - - // my vars (def) - public int error_line; - public Gee.HashMap? xmarks; - public bool check_queued; - - // ctor - public Xcls_buffer(Editor _owner ) - { - _this = _owner; - _this.buffer = this; - this.el = new GtkSource.Buffer( null ); - - // my vars (dec) - this.error_line = -1; - this.xmarks = null; - this.check_queued = false; - - // set gobject values - this.el.enable_undo = true; - - //listeners - this.el.changed.connect( () => { - // check syntax?? - // ??needed..?? - _this.save_button.el.sensitive = true; - print("EDITOR CHANGED"); - this.checkSyntax(); - - _this.dirty = true; - - // this.get('/LeftPanel.model').changed( str , false); - return ; - }); - } - - // user defined functions - public bool checkSyntax () { - - - var str = this.toString(); - - // needed??? - if (this.error_line > 0) { - Gtk.TextIter start; - Gtk.TextIter end; - this.el.get_bounds (out start, out end); - - this.el.remove_source_marks (start, end, null); - } - if (str.length < 1) { - print("checkSyntax - empty string?\n"); - return true; - } - - // bit presumptiona - if (_this.file.xtype == "PlainFile") { - - // assume it's gtk... - var oldcode =_this.file.toSource(); - _this.file.setSource(str); - _this.file.getLanguageServer().document_change(_this.file); - _this.file.setSource(oldcode); - - - return true; - - } - if (_this.file == null) { - return true; - } - - - - - - GLib.debug("calling validate"); - // clear the buttons. - if (_this.prop.name == "xns" || _this.prop.name == "xtype") { - return true ; - } - var oldcode = _this.prop.val; - - _this.prop.val = str; - _this.file.getLanguageServer().document_change(_this.file); - _this.prop.val = oldcode; - - - //print("done mark line\n"); - - return true; // at present allow saving - even if it's invalid.. - } - public bool highlightErrorsJson (string type, Json.Object obj) { - Gtk.TextIter start; - Gtk.TextIter end; - this.el.get_bounds (out start, out end); - - this.el.remove_source_marks (start, end, type); - GLib.debug("highlight errors"); - - // we should highlight other types of errors.. - - if (!obj.has_member(type)) { - GLib.debug("Return has no errors\n"); - return true; - } - - if (_this.window.windowstate.state != WindowState.State.CODEONLY - && - _this.window.windowstate.state != WindowState.State.CODE - ) { - GLib.debug("windowstate != CODEONLY?"); - - return true; - } - - //this.marks = new Gee.HashMap(); - var err = obj.get_object_member(type); - - if (_this.file == null) { - GLib.debug("file is null?"); - return true; - - } - var valafn = _this.file.path; - - if (_this.file.xtype != "PlainFile") { - - valafn = ""; - try { - var regex = new Regex("\\.bjs$"); - // should not happen - valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala"); - } catch (GLib.RegexError e) { - return true; - } - - - - } - if (!err.has_member(valafn)) { - GLib.debug("File path has no errors"); - return true; - } - - var lines = err.get_object_member(valafn); - - var offset = 1; - if (obj.has_member("line_offset")) { // ?? why?? - offset = (int)obj.get_int_member("line_offset") + 1; - } - - - var tlines = this.el.get_line_count () +1; - - if (_this.prop != null) { - - tlines = _this.prop.end_line + 1; - offset = _this.prop.start_line + 1; - - } - - - - lines.foreach_member((obj, line, node) => { - - Gtk.TextIter iter; - // print("get inter\n"); - var eline = int.parse(line) - offset; - GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset); - - - if (eline > tlines || eline < 0) { - return; - } - - - this.el.get_iter_at_line( out iter, eline); - //print("mark line\n"); - var msg = ""; - var ar = lines.get_array_member(line); - for (var i = 0 ; i < ar.get_length(); i++) { - if (ar.get_string_element(i) == "Success") { - continue; - } - msg += (msg.length > 0) ? "\n" : ""; - msg += ar.get_string_element(i); - } - if (msg == "") { - return; - } - msg = "Line: %d".printf(eline+1) + " " + msg; - this.el.create_source_mark(msg, type, iter); - GLib.debug("set line %d to %m", eline, msg); - // this.marks.set(eline, msg); - } ); - return false; - - - - - - } - public bool highlightErrors ( Gee.HashMap validate_res) { - - this.error_line = validate_res.size; - - if (this.error_line < 1) { - return true; - } - var tlines = this.el.get_line_count (); - Gtk.TextIter iter; - var valiter = validate_res.map_iterator(); - while (valiter.next()) { - - // print("get inter\n"); - var eline = valiter.get_key(); - if (eline > tlines) { - continue; - } - this.el.get_iter_at_line( out iter, eline); - //print("mark line\n"); - this.el.create_source_mark(valiter.get_value(), "ERR", iter); - } - return false; - } - public string toString () { - - Gtk.TextIter s; - Gtk.TextIter e; - this.el.get_start_iter(out s); - this.el.get_end_iter(out e); - var ret = this.el.get_text(s,e,true); - //print("TO STRING? " + ret); - return ret; - } - } - - public class Xcls_EventControllerKey11 : Object - { - public Gtk.EventControllerKey el; - private Editor _this; - - - // my vars (def) - - // ctor - public Xcls_EventControllerKey11(Editor _owner ) - { - _this = _owner; - this.el = new Gtk.EventControllerKey(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.key_released.connect( (keyval, keycode, state) => { - - - if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { - GLib.debug("SAVE: ctrl-S pressed"); - _this.saveContents(); - return; - } - - if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { - GLib.debug("SAVE: ctrl-g pressed"); - _this.forwardSearch(true); - return; - } - if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { - GLib.debug("SAVE: ctrl-f pressed"); - _this.search_entry.el.grab_focus(); - return; - } - //_this.view.el.show_completion(); - // print(event.key.keyval) - - return; - - - }); - } - - // user defined functions - } - - - - public class Xcls_Box12 : Object - { - public Gtk.Box el; - private Editor _this; - - - // my vars (def) - - // ctor - public Xcls_Box12(Editor _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.homogeneous = false; - this.el.vexpand = false; - var child_1 = new Xcls_search_entry( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_search_results( _this ); - child_2.ref(); - this.el.append( child_2.el ); - var child_3 = new Xcls_nextBtn( _this ); - child_3.ref(); - this.el.append( child_3.el ); - var child_4 = new Xcls_backBtn( _this ); - child_4.ref(); - this.el.append( child_4.el ); - var child_5 = new Xcls_MenuButton18( _this ); - child_5.ref(); - this.el.append( child_5.el ); - } - - // user defined functions - } - public class Xcls_search_entry : Object - { - public Gtk.SearchEntry el; - private Editor _this; - - - // my vars (def) - public Gtk.CssProvider css; - - // ctor - public Xcls_search_entry(Editor _owner ) - { - _this = _owner; - _this.search_entry = this; - this.el = new Gtk.SearchEntry(); - - // my vars (dec) - - // set gobject values - this.el.name = "editor-search-entry"; - this.el.hexpand = true; - this.el.placeholder_text = "Press enter to search"; - this.el.search_delay = 3; - var child_1 = new Xcls_EventControllerKey14( _this ); - child_1.ref(); - this.el.add_controller( child_1.el ); - - //listeners - this.el.search_changed.connect( ( ) => { - - _this.search(_this.search_entry.el.text); - _this.search_results.updateResults(); - - GLib.Timeout.add_seconds(1,() => { - _this.search_results.updateResults(); - return false; - }); - }); - } - - // user defined functions - public void forwardSearch (bool change_focus) { - - - _this.forwardSearch(change_focus); - - /* - - switch(_this.windowstate.state) { - case WindowState.State.CODEONLY: - //case WindowState.State.CODE: - // search the code being edited.. - _this.windowstate.code_editor_tab.forwardSearch(change_focus); - - break; - case WindowState.State.PREVIEW: - if (_this.windowstate.file.xtype == "Gtk") { - _this.windowstate.window_gladeview.forwardSearch(change_focus); - } else { - _this.windowstate.window_rooview.forwardSearch(change_focus); - } - - break; - } - */ - - } - } - public class Xcls_EventControllerKey14 : Object - { - public Gtk.EventControllerKey el; - private Editor _this; - - - // my vars (def) - - // ctor - public Xcls_EventControllerKey14(Editor _owner ) - { - _this = _owner; - this.el = new Gtk.EventControllerKey(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.key_pressed.connect( (keyval, keycode, state) => { - - if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { - GLib.debug("SAVE: ctrl-g pressed"); - _this.forwardSearch(true); - return true; - } - - - if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) { - _this.forwardSearch(true); - - - return true; - - } - // print(event.key.keyval) - - return false; - }); - } - - // user defined functions - } - - - public class Xcls_search_results : Object - { - public Gtk.Label el; - private Editor _this; - - - // my vars (def) - - // ctor - public Xcls_search_results(Editor _owner ) - { - _this = _owner; - _this.search_results = this; - this.el = new Gtk.Label( "No Results" ); - - // my vars (dec) - - // set gobject values - this.el.margin_end = 4; - this.el.margin_start = 4; - } - - // user defined functions - public void updateResults () { - this.el.visible = true; - - var res = _this.searchcontext.get_occurrences_count(); - if (res < 0) { - _this.search_results.el.label = "??? Matches"; - return; - } - - _this.nextBtn.el.sensitive = false; - _this.backBtn.el.sensitive = false; - - if (res > 0) { - _this.search_results.el.label = "%d Matches".printf(res); - _this.nextBtn.el.sensitive = true; - _this.backBtn.el.sensitive = true; - return; - } - _this.search_results.el.label = "No Matches"; - - } - } - - public class Xcls_nextBtn : Object - { - public Gtk.Button el; - private Editor _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_nextBtn(Editor _owner ) - { - _this = _owner; - _this.nextBtn = this; - this.el = new Gtk.Button(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.icon_name = "go-down"; - this.el.sensitive = false; - - //listeners - this.el.clicked.connect( (event) => { - - _this.forwardSearch(true); - - - }); - } - - // user defined functions - } - - public class Xcls_backBtn : Object - { - public Gtk.Button el; - private Editor _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_backBtn(Editor _owner ) - { - _this = _owner; - _this.backBtn = this; - this.el = new Gtk.Button(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.icon_name = "go-up"; - this.el.sensitive = false; - - //listeners - this.el.clicked.connect( (event) => { - - _this.backSearch(true); - - }); - } - - // user defined functions - } - - public class Xcls_MenuButton18 : Object - { - public Gtk.MenuButton el; - private Editor _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_MenuButton18(Editor _owner ) - { - _this = _owner; - this.el = new Gtk.MenuButton(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.icon_name = "emblem-system"; - this.el.always_show_arrow = true; - var child_1 = new Xcls_search_settings( _this ); - child_1.ref(); - this.el.popover = child_1.el; - } - - // user defined functions - } - public class Xcls_search_settings : Object - { - public Gtk.Popover el; - private Editor _this; - - - // my vars (def) + // my vars (def) - // ctor - public Xcls_search_settings(Editor _owner ) - { - _this = _owner; - _this.search_settings = this; - this.el = new Gtk.Popover(); - - // my vars (dec) - - // set gobject values - var child_1 = new Xcls_Box20( _this ); - child_1.ref(); - this.el.child = child_1.el; - } + // ctor + public Xcls_close_btn(Editor _owner ) + { + _this = _owner; + _this.close_btn = this; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "window-close"; + var child_1 = new Xcls_Image7( _this ); + this.el.child = child_1.el; + + //listeners + this.el.clicked.connect( () => { + _this.saveContents(); + _this.window.windowstate.switchState(WindowState.State.PREVIEW); + }); + } + + // user defined functions + } + public class Xcls_Image7 : Object + { + public Gtk.Image el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_Image7(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "window-close"; + this.el.icon_size = Gtk.IconSize.NORMAL; + } + + // user defined functions + } + + + + public class Xcls_RightEditor : Object + { + public Gtk.ScrolledWindow el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_RightEditor(Editor _owner ) + { + _this = _owner; + _this.RightEditor = this; + this.el = new Gtk.ScrolledWindow(); + + // my vars (dec) + + // set gobject values + this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC; + this.el.vexpand = true; + this.el.overlay_scrolling = false; + this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC; + new Xcls_view( _this ); + this.el.child = _this.view.el; + } + + // user defined functions + } + public class Xcls_view : Object + { + public GtkSource.View el; + private Editor _this; + + + // my vars (def) + public Gtk.CssProvider css; + + // ctor + public Xcls_view(Editor _owner ) + { + _this = _owner; + _this.view = this; + this.el = new GtkSource.View(); + + // my vars (dec) + this.css = null; + + // set gobject values + this.el.auto_indent = true; + this.el.indent_width = 4; + this.el.name = "editor-view"; + this.el.show_line_marks = true; + this.el.insert_spaces_instead_of_tabs = true; + this.el.show_line_numbers = true; + this.el.hexpand = true; + this.el.vexpand = true; + this.el.has_tooltip = true; + this.el.tab_width = 4; + this.el.highlight_current_line = true; + new Xcls_buffer( _this ); + this.el.buffer = _this.buffer.el; + var child_2 = new Xcls_EventControllerKey11( _this ); + child_2.ref(); + this.el.add_controller( child_2.el ); + + // init method + + this.css = new Gtk.CssProvider(); + + this.css.load_from_string( + "#editor-view { font: 12px monospace;}" + ); + + Gtk.StyleContext.add_provider_for_display( + this.el.get_display(), + this.css, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + ); + + + + /* + this is pretty flakey - triggers Gtk with < 0 d + var cp = new GtkSource.CompletionWords("test"); + cp.minimum_word_size = 3; + //cp.priority = 100; //?? does this do anything + cp.proposals_batch_size = 10; + cp.scan_batch_size = 1000; + + cp.register(_this.buffer.el); + this.el.completion.add_provider(cp); + */ + this.el.completion.add_provider(new Palete.CompletionProvider(_this)); + + //this.el.completion.unblock_interactive(); + this.el.completion.select_on_show = true; // select + //this.el.completion.remember_info_visibility = true; + + + var attrs = new GtkSource.MarkAttributes(); + var pink = Gdk.RGBA(); + pink.parse ( "pink"); + attrs.set_background ( pink); + attrs.set_icon_name ( "process-stop"); + attrs.query_tooltip_text.connect(( mark) => { + GLib.debug("tooltip query? %s", mark.name); + return strdup( mark.name); + }); + attrs.query_tooltip_markup.connect(( mark) => { + GLib.debug("tooltip query? %s", mark.name); + return strdup( mark.name); + }); + this.el.set_mark_attributes ("ERR", attrs, 1); + attrs.ref(); + var wattrs = new GtkSource.MarkAttributes(); + var blue = Gdk.RGBA(); + blue.parse ( "#ABF4EB"); + wattrs.set_background ( blue); + wattrs.set_icon_name ( "process-stop"); + wattrs.query_tooltip_text.connect(( mark) => { + GLib.debug("tooltip query? %s", mark.name); + return strdup(mark.name); + }); + wattrs.query_tooltip_markup.connect(( mark) => { + GLib.debug("tooltip query? %s", mark.name); + return strdup(mark.name); + }); + this.el.set_mark_attributes ("WARN", wattrs, 1); + wattrs.ref(); + + + var dattrs = new GtkSource.MarkAttributes(); + var purple = Gdk.RGBA(); + purple.parse ( "#EEA9FF"); + dattrs.set_background ( purple); + dattrs.set_icon_name ( "process-stop"); + dattrs.query_tooltip_text.connect(( mark) => { + GLib.debug("tooltip query? %s", mark.name); + return strdup(mark.name); + }); + dattrs.query_tooltip_markup.connect(( mark) => { + GLib.debug("tooltip query? %s", mark.name); + return strdup(mark.name); + }); + this.el.set_mark_attributes ("DEPR", dattrs, 1); + dattrs.ref(); + + this.el.get_space_drawer().set_matrix(null); + this.el.get_space_drawer().set_types_for_locations( + GtkSource.SpaceLocationFlags.ALL, + GtkSource.SpaceTypeFlags.ALL + ); + this.el.get_space_drawer().set_enable_matrix(true); + + //listeners + this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => { + + //GLib.debug("query tooltip"); + Gtk.TextIter iter; + int trailing; + + var yoff = (int) _this.RightEditor.el.vadjustment.value; + + // I think this is problematic - if it's compliing / updating at same time as query. + + //if (_this.window.statusbar_compile_spinner.el.spinning) { + // return false; + //} + + this.el.get_iter_at_position (out iter, out trailing, x, y + yoff); + + var l = iter.get_line(); + + + + // GLib.debug("query tooltip line %d", (int) l); + if (l < 0) { + + return false; + } + /* + if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) { + GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l)); + tooltip.set_text(_this.buffer.marks.get(l).dup()); + return true; + } + + return false; + */ + + + // this crashes?? - not sure why. + var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR"); + if (marks.is_empty()) { + marks = _this.buffer.el.get_source_marks_at_line(l, "WARN"); + } + if (marks.is_empty()) { + marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR"); + } + + // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length()); + var str = ""; + marks.@foreach((m) => { + //GLib.debug("got mark %s", m.name); + str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name; + }); + // true if there is a mark.. + if (str.length > 0 ) { + tooltip.set_text( str ); + } + return str.length > 0 ? true : false; + + }); + } + + // user defined functions + public void load (string str) { + + // show the help page for the active node.. + //this.get('/Help').show(); + + // this.get('/BottomPane').el.set_current_page(0); + GLib.debug("load called - Reset undo buffer"); + + var buf = (GtkSource.Buffer)this.el.get_buffer(); + buf.begin_irreversible_action(); + buf.set_text(str, str.length); + buf.end_irreversible_action(); + + var lm = GtkSource.LanguageManager.get_default(); + var lang = "vala"; + if (_this.file != null) { + lang = _this.file.language; + } + print("lang=%s, content_type = %s\n", lang, _this.file.content_type); + var lg = _this.file.content_type.length > 0 ? + lm.guess_language(_this.file.path, _this.file.content_type) : + lm.get_language(lang); + + + ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg); + + this.el.insert_spaces_instead_of_tabs = true; + if (lg != null) { + print("sourcelanguage = %s\n", lg.name); + if (lg.name == "Vala") { + this.el.insert_spaces_instead_of_tabs = false; + } + } + _this.dirty = false; + this.el.grab_focus(); + _this.save_button.el.sensitive = false; + } + } + public class Xcls_buffer : Object + { + public GtkSource.Buffer el; + private Editor _this; + + + // my vars (def) + public int error_line; + public Gee.HashMap? xmarks; + public bool check_queued; + + // ctor + public Xcls_buffer(Editor _owner ) + { + _this = _owner; + _this.buffer = this; + this.el = new GtkSource.Buffer( null ); + + // my vars (dec) + this.error_line = -1; + this.xmarks = null; + this.check_queued = false; + + // set gobject values + this.el.highlight_syntax = true; + this.el.highlight_matching_brackets = true; + this.el.enable_undo = true; + + // init method + + { + var buf = this.el; + buf.create_tag ("bold", "weight", Pango.Weight.BOLD); + buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87"); + buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000"); + buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf"); + buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8"); + buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf"); + buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51"); + buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5"); + + } + + //listeners + this.el.changed.connect( () => { + // check syntax?? + // ??needed..?? + _this.save_button.el.sensitive = true; + print("EDITOR CHANGED"); + this.checkSyntax(); + + _this.dirty = true; + + // this.get('/LeftPanel.model').changed( str , false); + return ; + }); + } + + // user defined functions + public bool checkSyntax () { + + + var str = this.toString(); + + // needed??? + if (this.error_line > 0) { + Gtk.TextIter start; + Gtk.TextIter end; + this.el.get_bounds (out start, out end); + + this.el.remove_source_marks (start, end, null); + } + if (str.length < 1) { + print("checkSyntax - empty string?\n"); + return true; + } + + // bit presumptiona + if (_this.file.xtype == "PlainFile") { + + // assume it's gtk... + var oldcode =_this.file.toSource(); + _this.file.setSource(str); + _this.file.getLanguageServer().document_change(_this.file); + BuilderApplication.showSpinner("appointment soon","document change pending"); + _this.file.setSource(oldcode); + + + return true; + + } + if (_this.file == null) { + return true; + } + + + + + + GLib.debug("calling validate"); + // clear the buttons. + if (_this.prop.name == "xns" || _this.prop.name == "xtype") { + return true ; + } + var oldcode = _this.prop.val; + + _this.prop.val = str; + _this.file.getLanguageServer().document_change(_this.file); + _this.prop.val = oldcode; + + + //print("done mark line\n"); + + return true; // at present allow saving - even if it's invalid.. + } + public bool highlightErrorsJson (string type, Json.Object obj) { + Gtk.TextIter start; + Gtk.TextIter end; + this.el.get_bounds (out start, out end); + + this.el.remove_source_marks (start, end, type); + GLib.debug("highlight errors"); + + // we should highlight other types of errors.. + + if (!obj.has_member(type)) { + GLib.debug("Return has no errors\n"); + return true; + } + + if (_this.window.windowstate.state != WindowState.State.CODEONLY + && + _this.window.windowstate.state != WindowState.State.CODE + ) { + GLib.debug("windowstate != CODEONLY?"); + + return true; + } + + //this.marks = new Gee.HashMap(); + var err = obj.get_object_member(type); + + if (_this.file == null) { + GLib.debug("file is null?"); + return true; + + } + var valafn = _this.file.path; + + if (_this.file.xtype != "PlainFile") { + + valafn = ""; + try { + var regex = new Regex("\\.bjs$"); + // should not happen + valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala"); + } catch (GLib.RegexError e) { + return true; + } + + + + } + if (!err.has_member(valafn)) { + GLib.debug("File path has no errors"); + return true; + } + + var lines = err.get_object_member(valafn); + + var offset = 1; + if (obj.has_member("line_offset")) { // ?? why?? + offset = (int)obj.get_int_member("line_offset") + 1; + } + + + var tlines = this.el.get_line_count () +1; + + if (_this.prop != null) { + + tlines = _this.prop.end_line + 1; + offset = _this.prop.start_line + 1; + + } + + + + lines.foreach_member((obj, line, node) => { + + Gtk.TextIter iter; + // print("get inter\n"); + var eline = int.parse(line) - offset; + GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset); + + + if (eline > tlines || eline < 0) { + return; + } + + + this.el.get_iter_at_line( out iter, eline); + //print("mark line\n"); + var msg = ""; + var ar = lines.get_array_member(line); + for (var i = 0 ; i < ar.get_length(); i++) { + if (ar.get_string_element(i) == "Success") { + continue; + } + msg += (msg.length > 0) ? "\n" : ""; + msg += ar.get_string_element(i); + } + if (msg == "") { + return; + } + msg = "Line: %d".printf(eline+1) + " " + msg; + this.el.create_source_mark(msg, type, iter); + GLib.debug("set line %d to %m", eline, msg); + // this.marks.set(eline, msg); + } ); + return false; + + + + + + } + public bool highlightErrors ( Gee.HashMap validate_res) { + + this.error_line = validate_res.size; + + if (this.error_line < 1) { + return true; + } + var tlines = this.el.get_line_count (); + Gtk.TextIter iter; + var valiter = validate_res.map_iterator(); + while (valiter.next()) { + + // print("get inter\n"); + var eline = valiter.get_key(); + if (eline > tlines) { + continue; + } + this.el.get_iter_at_line( out iter, eline); + //print("mark line\n"); + this.el.create_source_mark(valiter.get_value(), "ERR", iter); + } + return false; + } + public string toString () { + + Gtk.TextIter s; + Gtk.TextIter e; + this.el.get_start_iter(out s); + this.el.get_end_iter(out e); + var ret = this.el.get_text(s,e,true); + //print("TO STRING? " + ret); + return ret; + } + } + + public class Xcls_EventControllerKey11 : Object + { + public Gtk.EventControllerKey el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_EventControllerKey11(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.EventControllerKey(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.key_released.connect( (keyval, keycode, state) => { + + + if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-S pressed"); + _this.saveContents(); + return; + } + + if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-g pressed"); + _this.forwardSearch(true); + return; + } + if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-f pressed"); + _this.search_entry.el.grab_focus(); + _this.search_entry.el.select_region(0,-1); + return; + } + if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + _this.view.el.show_completion(); + } + + Gtk.TextIter iter; + _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position); + var line = iter.get_line(); + var offset = iter.get_line_offset(); + GLib.debug("line %d off %d", line ,offset); + if (_this.prop != null) { + line += _this.prop.start_line + 1; // i think.. + offset += 12; // should probably be 8 without namespaced + GLib.debug("guess line %d off %d", line ,offset); + } + //_this.view.el.show_completion(); + // print(event.key.keyval) + + + + + return; + + + }); + } + + // user defined functions + } + + + + public class Xcls_Box12 : Object + { + public Gtk.Box el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_Box12(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + this.el.vexpand = false; + new Xcls_search_entry( _this ); + this.el.append( _this.search_entry.el ); + new Xcls_search_results( _this ); + this.el.append( _this.search_results.el ); + new Xcls_nextBtn( _this ); + this.el.append( _this.nextBtn.el ); + new Xcls_backBtn( _this ); + this.el.append( _this.backBtn.el ); + var child_5 = new Xcls_MenuButton18( _this ); + child_5.ref(); + this.el.append( child_5.el ); + } + + // user defined functions + } + public class Xcls_search_entry : Object + { + public Gtk.SearchEntry el; + private Editor _this; + + + // my vars (def) + public Gtk.CssProvider css; + + // ctor + public Xcls_search_entry(Editor _owner ) + { + _this = _owner; + _this.search_entry = this; + this.el = new Gtk.SearchEntry(); + + // my vars (dec) + + // set gobject values + this.el.name = "editor-search-entry"; + this.el.hexpand = true; + this.el.placeholder_text = "Press enter to search"; + this.el.search_delay = 3; + var child_1 = new Xcls_EventControllerKey14( _this ); + child_1.ref(); + this.el.add_controller( child_1.el ); + + //listeners + this.el.search_changed.connect( ( ) => { + + _this.search(_this.search_entry.el.text); + _this.search_results.updateResults(); + + GLib.Timeout.add_seconds(1,() => { + _this.search_results.updateResults(); + return false; + }); + }); + } + + // user defined functions + public void forwardSearch (bool change_focus) { + + + _this.forwardSearch(change_focus); + + /* + + switch(_this.windowstate.state) { + case WindowState.State.CODEONLY: + //case WindowState.State.CODE: + // search the code being edited.. + _this.windowstate.code_editor_tab.forwardSearch(change_focus); + + break; + case WindowState.State.PREVIEW: + if (_this.windowstate.file.xtype == "Gtk") { + _this.windowstate.window_gladeview.forwardSearch(change_focus); + } else { + _this.windowstate.window_rooview.forwardSearch(change_focus); + } + + break; + } + */ + + } + } + public class Xcls_EventControllerKey14 : Object + { + public Gtk.EventControllerKey el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_EventControllerKey14(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.EventControllerKey(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.key_pressed.connect( (keyval, keycode, state) => { + + if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-g pressed"); + _this.forwardSearch(true); + return true; + } + + + if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) { + _this.forwardSearch(true); + + + return true; + + } + // print(event.key.keyval) + + return false; + }); + } + + // user defined functions + } + + + public class Xcls_search_results : Object + { + public Gtk.Label el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_search_results(Editor _owner ) + { + _this = _owner; + _this.search_results = this; + this.el = new Gtk.Label( "No Results" ); + + // my vars (dec) + + // set gobject values + this.el.margin_end = 4; + this.el.margin_start = 4; + } + + // user defined functions + public void updateResults () { + this.el.visible = true; + + var res = _this.searchcontext.get_occurrences_count(); + if (res < 0) { + _this.search_results.el.label = "??? Matches"; + return; + } + + _this.nextBtn.el.sensitive = false; + _this.backBtn.el.sensitive = false; + + if (res > 0) { + _this.search_results.el.label = "%d Matches".printf(res); + _this.nextBtn.el.sensitive = true; + _this.backBtn.el.sensitive = true; + return; + } + _this.search_results.el.label = "No Matches"; + + } + } + + public class Xcls_nextBtn : Object + { + public Gtk.Button el; + private Editor _this; + + + // my vars (def) + public bool always_show_image; + + // ctor + public Xcls_nextBtn(Editor _owner ) + { + _this = _owner; + _this.nextBtn = this; + this.el = new Gtk.Button(); + + // my vars (dec) + this.always_show_image = true; + + // set gobject values + this.el.icon_name = "go-down"; + this.el.sensitive = false; + + //listeners + this.el.clicked.connect( (event) => { + + _this.forwardSearch(true); + + + }); + } + + // user defined functions + } + + public class Xcls_backBtn : Object + { + public Gtk.Button el; + private Editor _this; + + + // my vars (def) + public bool always_show_image; + + // ctor + public Xcls_backBtn(Editor _owner ) + { + _this = _owner; + _this.backBtn = this; + this.el = new Gtk.Button(); + + // my vars (dec) + this.always_show_image = true; + + // set gobject values + this.el.icon_name = "go-up"; + this.el.sensitive = false; + + //listeners + this.el.clicked.connect( (event) => { + + _this.backSearch(true); + + }); + } + + // user defined functions + } + + public class Xcls_MenuButton18 : Object + { + public Gtk.MenuButton el; + private Editor _this; + + + // my vars (def) + public bool always_show_image; + + // ctor + public Xcls_MenuButton18(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.MenuButton(); + + // my vars (dec) + this.always_show_image = true; + + // set gobject values + this.el.icon_name = "emblem-system"; + this.el.always_show_arrow = true; + new Xcls_search_settings( _this ); + this.el.popover = _this.search_settings.el; + } + + // user defined functions + } + public class Xcls_search_settings : Object + { + public Gtk.Popover el; + private Editor _this; - // user defined functions - } - public class Xcls_Box20 : Object - { - public Gtk.Box el; - private Editor _this; + // my vars (def) - // my vars (def) + // ctor + public Xcls_search_settings(Editor _owner ) + { + _this = _owner; + _this.search_settings = this; + this.el = new Gtk.Popover(); + + // my vars (dec) - // ctor - public Xcls_Box20(Editor _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + // set gobject values + var child_1 = new Xcls_Box20( _this ); + this.el.child = child_1.el; + } - // my vars (dec) + // user defined functions + } + public class Xcls_Box20 : Object + { + public Gtk.Box el; + private Editor _this; - // set gobject values - var child_1 = new Xcls_case_sensitive( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_regex( _this ); - child_2.ref(); - this.el.append( child_2.el ); - var child_3 = new Xcls_multiline( _this ); - child_3.ref(); - this.el.append( child_3.el ); - } - // user defined functions - } - public class Xcls_case_sensitive : Object - { - public Gtk.CheckButton el; - private Editor _this; + // my vars (def) + // ctor + public Xcls_Box20(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - // my vars (def) + // my vars (dec) - // ctor - public Xcls_case_sensitive(Editor _owner ) - { - _this = _owner; - _this.case_sensitive = this; - this.el = new Gtk.CheckButton(); + // set gobject values + new Xcls_case_sensitive( _this ); + this.el.append( _this.case_sensitive.el ); + new Xcls_regex( _this ); + this.el.append( _this.regex.el ); + new Xcls_multiline( _this ); + this.el.append( _this.multiline.el ); + } - // my vars (dec) + // user defined functions + } + public class Xcls_case_sensitive : Object + { + public Gtk.CheckButton el; + private Editor _this; - // set gobject values - this.el.label = "Case Sensitive"; - // init method + // my vars (def) - { - this.el.show(); - } - } + // ctor + public Xcls_case_sensitive(Editor _owner ) + { + _this = _owner; + _this.case_sensitive = this; + this.el = new Gtk.CheckButton(); - // user defined functions - } + // my vars (dec) - public class Xcls_regex : Object - { - public Gtk.CheckButton el; - private Editor _this; + // set gobject values + this.el.label = "Case Sensitive"; + // init method - // my vars (def) + { + this.el.show(); + } + } - // ctor - public Xcls_regex(Editor _owner ) - { - _this = _owner; - _this.regex = this; - this.el = new Gtk.CheckButton(); + // user defined functions + } - // my vars (dec) + public class Xcls_regex : Object + { + public Gtk.CheckButton el; + private Editor _this; - // set gobject values - this.el.label = "Regex"; - // init method + // my vars (def) - { - this.el.show(); - } - } + // ctor + public Xcls_regex(Editor _owner ) + { + _this = _owner; + _this.regex = this; + this.el = new Gtk.CheckButton(); - // user defined functions - } + // my vars (dec) - public class Xcls_multiline : Object - { - public Gtk.CheckButton el; - private Editor _this; + // set gobject values + this.el.label = "Regex"; + // init method - // my vars (def) + { + this.el.show(); + } + } - // ctor - public Xcls_multiline(Editor _owner ) - { - _this = _owner; - _this.multiline = this; - this.el = new Gtk.CheckButton(); + // user defined functions + } - // my vars (dec) + public class Xcls_multiline : Object + { + public Gtk.CheckButton el; + private Editor _this; - // set gobject values - this.el.label = "Multi-line (add \\n)"; - } - // user defined functions - } + // my vars (def) + + // ctor + public Xcls_multiline(Editor _owner ) + { + _this = _owner; + _this.multiline = this; + this.el = new Gtk.CheckButton(); + + // my vars (dec) + + // set gobject values + this.el.label = "Multi-line (add \\n)"; + } + + // user defined functions + } diff --git a/src/Builder4/GtkView.bjs b/src/Builder4/GtkView.bjs index 5d6304423..9ec00016c 100644 --- a/src/Builder4/GtkView.bjs +++ b/src/Builder4/GtkView.bjs @@ -167,8 +167,8 @@ ], "* pack" : "set_child", "Gtk.CssProvider css" : "", - "bool allow_node_scroll" : true, - "bool loading" : true, + "bool loading" : false, + "bool zallow_node_scroll" : true, "gboolean editable" : false, "gboolean show_line_marks" : true, "gboolean show_line_numbers" : true, @@ -178,14 +178,18 @@ "$ xns" : "GtkSource", "* pack" : "set_buffer", "bool dirty" : false, + "bool in_cursor_change" : false, "id" : "buffer", "int error_line" : "-1", + "int last_line" : "-1", "listeners" : { - "notify[\"cursor_position\"]" : [ - "() => {", + "cursor_moved" : [ + "( ) => {", + "GLib.debug(\"cursor moved called\");", "", "", - " if (_this.sourceview.loading) {", + " \tif (this.in_cursor_change ) {", + " GLib.debug(\"cursor changed : %d [ignoring nested call)\", this.el.cursor_position);", " return;", " }", " ", @@ -194,35 +198,22 @@ " this.el.get_iter_at_offset(out cpos, this.el.cursor_position);", " ", " var ln = cpos.get_line();", - "", + " if (this.last_line == ln ){", + " \treturn;", + "\t}", + "\tthis.last_line = ln;", " var node = _this.file.lineToNode(ln);", "", " if (node == null) {", " print(\"can not find node\\n\");", " return;", " }", - " _this.sourceview.loading = true;", + " this.in_cursor_change = true;", " var ltree = _this.main_window.windowstate.left_tree;", " ltree.model.selectNode(node);", - " _this.sourceview.loading = false;", - " ", - " //print(\"got tree path %s\\n\", tp);", - " //if (tp != \"\") {", - " // this.allow_node_scroll = false; ", - " // print(\"changing cursor on tree..\\n\");", - " //ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);", - " // scrolling is disabled... as node selection calls scroll 10ms after it changes.", - " ///GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {", - " // this.allow_node_scroll = true;", - " // return false;", - " // });", - " // }", - " ", - " // highlight the node..", - " ", - " ", - "", - " }" + " this.in_cursor_change = false;", + "}", + "" ] }, "xtype" : "Buffer" @@ -292,6 +283,7 @@ ] }, "string name" : "gtkview-view", + "uint tab_width" : 4, "xtype" : "View", "| string toString" : [ "() {", @@ -311,8 +303,10 @@ " var buf = this.el.get_buffer();", " buf.set_text(\"\",0);", " var sbuf = (GtkSource.Buffer) buf;", - "", + "\tvar cpos = buf.cursor_position;", " ", + " \tprint(\"BEFORE LOAD cursor = %d\\n\", cpos);", + " var vadj_pos = this.el.get_vadjustment().get_value();", "", " if (_this.file == null || _this.file.xtype != \"Gtk\") {", " print(\"xtype != Gtk\");", @@ -357,7 +351,23 @@ " ", " ", " _this.main_window.windowstate.updateErrorMarksAll(); ", - " ", + " // restore the cursor position?", + " // after reloading the contents.", + " GLib.Timeout.add(500, () => {", + "\t\t_this.buffer.in_cursor_change = true;", + " print(\"RESORTING cursor to = %d\\n\", cpos);", + "\t\tGtk.TextIter cpos_iter;", + "\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);", + "\t\tbuf.place_cursor(cpos_iter); ", + "\t\t", + "\t\tthis.el.get_vadjustment().set_value(vadj_pos);;", + "\t\t_this.buffer.in_cursor_change = false;", + " ", + "\t\t", + "\t\t", + "\t\t//_this.buffer.checkSyntax();", + "\t\treturn false;", + "\t});", " ", " ", " this.loading = false; ", @@ -378,9 +388,7 @@ " var sbuf = (GtkSource.Buffer) buf;", "", " ", - " // while(Gtk.events_pending()) {", - " // Gtk.main_iteration();", - " // }", + " ", " ", " ", " // clear all the marks..", @@ -402,14 +410,11 @@ " Gtk.TextIter cur_iter;", " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);", " ", - " //var cur_line = cur_iter.get_line();", - " //if (cur_line > sel.line_start && cur_line < sel.line_end) {", " ", - " //} else {", - " if (this.allow_node_scroll) {", - "\t\t ", + " if (!_this.buffer.in_cursor_change) {", + "", " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);", - "\t}", + "\t} ", " ", " ", " ", @@ -992,8 +997,6 @@ " ", "", " ", - "\t", - "\tvar offset = 0;", "\t ", "", "\tvar tlines = buf.get_line_count () +1;", @@ -1005,9 +1008,9 @@ "\t\t", "\t Gtk.TextIter iter;", "// print(\"get inter\\n\");", - "\t var eline = err.line - offset;", - "\t GLib.debug(\"GOT ERROR on line %d -- converted to %d (offset = %d)\",", - "\t \terr.line ,eline, offset);", + "\t var eline = err.line + 1;", + "\t GLib.debug(\"GOT ERROR on line %d -- converted to %d \",", + "\t \terr.line ,eline);", "\t ", "\t ", "\t if (eline > tlines || eline < 0) {", diff --git a/src/Builder4/GtkView.vala b/src/Builder4/GtkView.vala index 830bd0178..a56758564 100644 --- a/src/Builder4/GtkView.vala +++ b/src/Builder4/GtkView.vala @@ -1,1437 +1,1441 @@ - static Xcls_GtkView _GtkView; - - public class Xcls_GtkView : Object - { - public Gtk.Box el; - private Xcls_GtkView _this; - - public static Xcls_GtkView singleton() - { - if (_GtkView == null) { - _GtkView= new Xcls_GtkView(); - } - return _GtkView; - } - public Xcls_notebook notebook; - public Xcls_label_preview label_preview; - public Xcls_label_code label_code; - public Xcls_view_layout view_layout; - public Xcls_container container; - public Xcls_sourceviewscroll sourceviewscroll; - public Xcls_sourceview sourceview; - public Xcls_buffer buffer; - public Xcls_search_entry search_entry; - public Xcls_search_results search_results; - public Xcls_nextBtn nextBtn; - public Xcls_backBtn backBtn; - public Xcls_search_settings search_settings; - public Xcls_case_sensitive case_sensitive; - public Xcls_regex regex; - public Xcls_multiline multiline; - - // my vars (def) - public Gtk.Widget lastObj; - public Gtk.CssProvider css; - public Xcls_MainWindow main_window; - public GtkSource.SearchContext searchcontext; - public int last_search_end; - public JsRender.JsRender file; - - // ctor - public Xcls_GtkView() - { - _this = this; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - this.lastObj = null; - this.last_search_end = 0; - this.file = null; - - // set gobject values - this.el.hexpand = true; - this.el.vexpand = true; - new Xcls_notebook( _this ); - this.el.append( _this.notebook.el ); - - // init method - - { - - this.css = new Gtk.CssProvider(); - - this.css.load_from_string( - "#gtkview-view-layout { background-color: #ccc; }" - ); - - Gtk.StyleContext.add_provider_for_display( - this.el.get_display(), - this.css, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - ); - - - } - } - - // user defined functions - public void loadFile (JsRender.JsRender file) - { - this.file = null; - - if (file.tree == null) { - return; - } - this.notebook.el.page = 0;// gtk preview - - - - this.file = file; - this.sourceview.loadFile(); - this.searchcontext = null; - - - if (this.lastObj != null) { - this.container.el.remove(this.lastObj); - } - - // hide the compile view at present.. - - - var w = this.el.get_width(); - var h = this.el.get_height(); - - print("ALLOC SET SIZES %d, %d\n", w,h); - - // set the container size min to 500/500 or 20 px less than max.. - w = int.max (w-20, 500); - h = int.max (h-20, 500); - - print("SET SIZES %d, %d\n", w,h); - _this.container.el.set_size_request(w,h); - - _this.view_layout.el.set_size_request(w,h); - // should be baded on calc.. -- see update_scrolled. - - var fc = this.container.el.get_first_child(); - if (fc != null) { - this.container.el.remove(fc); - } - - var xmlstr = JsRender.NodeToGlade.mungeFile( file); - var builder = new Gtk.Builder.from_string (xmlstr, xmlstr.length); - var obj = (Gtk.Widget) builder.get_object("w"+ file.tree.oid.to_string()); - this.container.el.append(obj); - obj.show(); - this.createThumb(); - - - return;/* - var x = new JsRender.NodeToGtk((Project.Gtk) file.project, file.tree); - var obj = x.munge() as Gtk.Widget; - this.lastObj = null; - if (obj == null) { - return; - } - this.lastObj = obj; - - this.container.el.append(obj); - obj.show(); - - */ - - } - public void highlightNodeAtLine (int ln) { - - // this is done from clicking on the editor.. - - // highlight node... - - - var node = _this.file.lineToNode(ln+1); - - if (node == null) { - //print("can not find node\n"); - return; - } - var prop = node.lineToProp(ln+1); - print("prop : %s", prop == null ? "???" : prop.name); - - - // ---------- this selects the tree's node... - - var ltree = _this.main_window.windowstate.left_tree; - ltree.model.selectNode(node); - //var tp = ltree.model.treePathFromNode(node); - - //print("got tree path %s\n", tp); - //if (tp == "") { - // return; - //} - //_this.sourceview.allow_node_scroll = false; /// block node scrolling.. - - - //print("changing cursor on tree..\n"); - - - - // let's try allowing editing on the methods. - // a little klunky at present.. - _this.sourceview.prop_selected = ""; - /* - if (prop != null) { - //see if we can find it.. - var kv = prop.split(":"); - if (kv[0] == "p") { - - //var k = prop.get_key(kv[1]); - // fixme -- need to determine if it's an editable property... - _this.sourceview.prop_selected = prop; - - } else if (kv[0] == "l") { - _this.sourceview.prop_selected = prop; - - } - } - */ - //ltree.view.setCursor(tp, "editor"); - // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); - _this.sourceview.nodeSelected(node,false); - - // scrolling is disabled... as node selection calls scroll 10ms after it changes. - // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => { - // this.allow_node_scroll = true; - // return false; - // }); - // } - - - - - - - - - - - - } - public void forwardSearch (bool change_focus) { - - if (this.searchcontext == null) { - return; - } - this.notebook.el.page = 1; - Gtk.TextIter beg, st,en; - bool has_wrapped_around; - var buf = this.sourceview.el.get_buffer(); - buf.get_iter_at_offset(out beg, this.last_search_end); - if (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) { - this.last_search_end = 0; - return; - } - this.last_search_end = en.get_offset(); - if (change_focus) { - this.sourceview.el.grab_focus(); - } - buf.place_cursor(st); - - - - this.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f); - - - var ln = st.get_line(); - - this.highlightNodeAtLine(ln); - } - public void backSearch (bool change_focus) { - - if (this.searchcontext == null) { - return; - } - - Gtk.TextIter beg, st,en; - bool has_wrapped_around; - this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 ); - - if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) { - - this.last_search_end = 0; - return; - } - this.last_search_end = en.get_offset(); - if (change_focus) { - this.sourceview.el.grab_focus(); - } - this.buffer.el.place_cursor(st); - this.sourceview.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f); - var ln = st.get_line(); - this.highlightNodeAtLine(ln); - - } - public int search (string in_txt) { - this.notebook.el.page = 1; - - - - var s = new GtkSource.SearchSettings(); - s.case_sensitive = _this.case_sensitive.el.active; - s.regex_enabled = _this.regex.el.active; - s.wrap_around = false; - - this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s); - this.searchcontext.set_highlight(true); - var txt = in_txt; - - if (_this.multiline.el.active) { - txt = in_txt.replace("\\n", "\n"); - } - - s.set_search_text(txt); - Gtk.TextIter beg, st,en; - bool has_wrapped_around; - this.buffer.el.get_start_iter(out beg); - this.searchcontext.forward(beg, out st, out en, out has_wrapped_around); - this.last_search_end = 0; - - return this.searchcontext.get_occurrences_count(); - - - - - } - public void createThumb () { - - - if (this.file == null) { - return; - } - // only screenshot the gtk preview.. - if (this.notebook.el.page > 0 ) { - return; - } - - - this.file.widgetToIcon(this.container.el); - - - return; - - - - - - // should we hold until it's printed... - - - - - } - public void updateErrorMarks (string category) { - - - - var buf = _this.buffer.el; - Gtk.TextIter start; - Gtk.TextIter end; - buf.get_bounds (out start, out end); - - buf.remove_source_marks (start, end, category); - - GLib.debug("highlight errors"); - - // we should highlight other types of errors.. - - - - - if (_this.file == null) { - GLib.debug("file is null?"); - return; - - } - var ar = this.file.getErrors(category); - if (ar == null || ar.get_n_items() < 1) { - GLib.debug("higjlight %s has no errors", category); - return; - } - - - - - var offset = 0; - - - var tlines = buf.get_line_count () +1; - - - - for (var i = 0; i < ar.get_n_items();i++) { - var err = (Palete.CompileError) ar.get_item(i); - - Gtk.TextIter iter; - // print("get inter\n"); - var eline = err.line - offset; - GLib.debug("GOT ERROR on line %d -- converted to %d (offset = %d)", - err.line ,eline, offset); - - - if (eline > tlines || eline < 0) { - return; - } - - - buf.get_iter_at_line( out iter, eline); - - - var msg = "Line: %d %s : %s".printf(eline+1, err.category, err.msg); - buf.create_source_mark( msg, err.category, iter); - GLib.debug("set line %d to %s", eline, msg); - //this.marks.set(eline, msg); - } - return ; - - - - - - } - public void scroll_to_line (int line) { - // code preview... - - GLib.Timeout.add(100, () => { - - - this.notebook.el.set_current_page(1); - - var buf = this.sourceview.el.get_buffer(); - - var sbuf = (GtkSource.Buffer) buf; - - - Gtk.TextIter iter; - sbuf.get_iter_at_line(out iter, line); - this.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); - return false; - }); - - - } - public class Xcls_notebook : Object - { - public Gtk.Notebook el; - private Xcls_GtkView _this; - - - // my vars (def) - - // ctor - public Xcls_notebook(Xcls_GtkView _owner ) - { - _this = _owner; - _this.notebook = this; - this.el = new Gtk.Notebook(); - - // my vars (dec) - - // set gobject values - this.el.overflow = Gtk.Overflow.VISIBLE; - new Xcls_label_preview( _this ); - new Xcls_label_code( _this ); - var child_3 = new Xcls_ScrolledWindow5( _this ); - child_3.ref(); - this.el.append_page ( child_3.el , _this.label_preview.el ); - var child_4 = new Xcls_Box8( _this ); - child_4.ref(); - this.el.append_page ( child_4.el , _this.label_code.el ); - } - - // user defined functions - } - public class Xcls_label_preview : Object - { - public Gtk.Label el; - private Xcls_GtkView _this; - - - // my vars (def) - - // ctor - public Xcls_label_preview(Xcls_GtkView _owner ) - { - _this = _owner; - _this.label_preview = this; - this.el = new Gtk.Label( "Preview" ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - public class Xcls_label_code : Object - { - public Gtk.Label el; - private Xcls_GtkView _this; - - - // my vars (def) - - // ctor - public Xcls_label_code(Xcls_GtkView _owner ) - { - _this = _owner; - _this.label_code = this; - this.el = new Gtk.Label( "Preview Generated Code" ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - public class Xcls_ScrolledWindow5 : Object - { - public Gtk.ScrolledWindow el; - private Xcls_GtkView _this; - - - // my vars (def) +static Xcls_GtkView _GtkView; + +public class Xcls_GtkView : Object +{ + public Gtk.Box el; + private Xcls_GtkView _this; + + public static Xcls_GtkView singleton() + { + if (_GtkView == null) { + _GtkView= new Xcls_GtkView(); + } + return _GtkView; + } + public Xcls_notebook notebook; + public Xcls_label_preview label_preview; + public Xcls_label_code label_code; + public Xcls_view_layout view_layout; + public Xcls_container container; + public Xcls_sourceviewscroll sourceviewscroll; + public Xcls_sourceview sourceview; + public Xcls_buffer buffer; + public Xcls_search_entry search_entry; + public Xcls_search_results search_results; + public Xcls_nextBtn nextBtn; + public Xcls_backBtn backBtn; + public Xcls_search_settings search_settings; + public Xcls_case_sensitive case_sensitive; + public Xcls_regex regex; + public Xcls_multiline multiline; + + // my vars (def) + public Gtk.Widget lastObj; + public Gtk.CssProvider css; + public Xcls_MainWindow main_window; + public GtkSource.SearchContext searchcontext; + public int last_search_end; + public JsRender.JsRender file; + + // ctor + public Xcls_GtkView() + { + _this = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + this.lastObj = null; + this.last_search_end = 0; + this.file = null; + + // set gobject values + this.el.hexpand = true; + this.el.vexpand = true; + new Xcls_notebook( _this ); + this.el.append( _this.notebook.el ); + + // init method + + { + + this.css = new Gtk.CssProvider(); + + this.css.load_from_string( + "#gtkview-view-layout { background-color: #ccc; }" + ); + + Gtk.StyleContext.add_provider_for_display( + this.el.get_display(), + this.css, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + ); + + + } + } + + // user defined functions + public void loadFile (JsRender.JsRender file) + { + this.file = null; + + if (file.tree == null) { + return; + } + this.notebook.el.page = 0;// gtk preview + + + + this.file = file; + this.sourceview.loadFile(); + this.searchcontext = null; + + + if (this.lastObj != null) { + this.container.el.remove(this.lastObj); + } + + // hide the compile view at present.. + + + var w = this.el.get_width(); + var h = this.el.get_height(); + + print("ALLOC SET SIZES %d, %d\n", w,h); + + // set the container size min to 500/500 or 20 px less than max.. + w = int.max (w-20, 500); + h = int.max (h-20, 500); + + print("SET SIZES %d, %d\n", w,h); + _this.container.el.set_size_request(w,h); + + _this.view_layout.el.set_size_request(w,h); + // should be baded on calc.. -- see update_scrolled. + + var fc = this.container.el.get_first_child(); + if (fc != null) { + this.container.el.remove(fc); + } + + var xmlstr = JsRender.NodeToGlade.mungeFile( file); + var builder = new Gtk.Builder.from_string (xmlstr, xmlstr.length); + var obj = (Gtk.Widget) builder.get_object("w"+ file.tree.oid.to_string()); + this.container.el.append(obj); + obj.show(); + this.createThumb(); + + + return;/* + var x = new JsRender.NodeToGtk((Project.Gtk) file.project, file.tree); + var obj = x.munge() as Gtk.Widget; + this.lastObj = null; + if (obj == null) { + return; + } + this.lastObj = obj; + + this.container.el.append(obj); + obj.show(); + + */ + + } + public void highlightNodeAtLine (int ln) { + + // this is done from clicking on the editor.. + + // highlight node... + + + var node = _this.file.lineToNode(ln+1); + + if (node == null) { + //print("can not find node\n"); + return; + } + var prop = node.lineToProp(ln+1); + print("prop : %s", prop == null ? "???" : prop.name); + + + // ---------- this selects the tree's node... + + var ltree = _this.main_window.windowstate.left_tree; + ltree.model.selectNode(node); + //var tp = ltree.model.treePathFromNode(node); + + //print("got tree path %s\n", tp); + //if (tp == "") { + // return; + //} + //_this.sourceview.allow_node_scroll = false; /// block node scrolling.. + + + //print("changing cursor on tree..\n"); + + + + // let's try allowing editing on the methods. + // a little klunky at present.. + _this.sourceview.prop_selected = ""; + /* + if (prop != null) { + //see if we can find it.. + var kv = prop.split(":"); + if (kv[0] == "p") { + + //var k = prop.get_key(kv[1]); + // fixme -- need to determine if it's an editable property... + _this.sourceview.prop_selected = prop; + + } else if (kv[0] == "l") { + _this.sourceview.prop_selected = prop; + + } + } + */ + //ltree.view.setCursor(tp, "editor"); + // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); + _this.sourceview.nodeSelected(node,false); + + // scrolling is disabled... as node selection calls scroll 10ms after it changes. + // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => { + // this.allow_node_scroll = true; + // return false; + // }); + // } + + + + + + + + + + + + } + public void forwardSearch (bool change_focus) { + + if (this.searchcontext == null) { + return; + } + this.notebook.el.page = 1; + Gtk.TextIter beg, st,en; + bool has_wrapped_around; + var buf = this.sourceview.el.get_buffer(); + buf.get_iter_at_offset(out beg, this.last_search_end); + if (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) { + this.last_search_end = 0; + return; + } + this.last_search_end = en.get_offset(); + if (change_focus) { + this.sourceview.el.grab_focus(); + } + buf.place_cursor(st); + + + + this.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f); + + + var ln = st.get_line(); + + this.highlightNodeAtLine(ln); + } + public void backSearch (bool change_focus) { + + if (this.searchcontext == null) { + return; + } + + Gtk.TextIter beg, st,en; + bool has_wrapped_around; + this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 ); + + if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) { + + this.last_search_end = 0; + return; + } + this.last_search_end = en.get_offset(); + if (change_focus) { + this.sourceview.el.grab_focus(); + } + this.buffer.el.place_cursor(st); + this.sourceview.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f); + var ln = st.get_line(); + this.highlightNodeAtLine(ln); + + } + public int search (string in_txt) { + this.notebook.el.page = 1; + + + + var s = new GtkSource.SearchSettings(); + s.case_sensitive = _this.case_sensitive.el.active; + s.regex_enabled = _this.regex.el.active; + s.wrap_around = false; + + this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s); + this.searchcontext.set_highlight(true); + var txt = in_txt; + + if (_this.multiline.el.active) { + txt = in_txt.replace("\\n", "\n"); + } + + s.set_search_text(txt); + Gtk.TextIter beg, st,en; + bool has_wrapped_around; + this.buffer.el.get_start_iter(out beg); + this.searchcontext.forward(beg, out st, out en, out has_wrapped_around); + this.last_search_end = 0; + + return this.searchcontext.get_occurrences_count(); + + + + + } + public void createThumb () { + + + if (this.file == null) { + return; + } + // only screenshot the gtk preview.. + if (this.notebook.el.page > 0 ) { + return; + } + + + this.file.widgetToIcon(this.container.el); + + + return; + + + + + + // should we hold until it's printed... + + + + + } + public void updateErrorMarks (string category) { + + + + var buf = _this.buffer.el; + Gtk.TextIter start; + Gtk.TextIter end; + buf.get_bounds (out start, out end); + + buf.remove_source_marks (start, end, category); + + GLib.debug("highlight errors"); + + // we should highlight other types of errors.. + + + + + if (_this.file == null) { + GLib.debug("file is null?"); + return; + + } + var ar = this.file.getErrors(category); + if (ar == null || ar.get_n_items() < 1) { + GLib.debug("higjlight %s has no errors", category); + return; + } + + + + + + var tlines = buf.get_line_count () +1; + + + + for (var i = 0; i < ar.get_n_items();i++) { + var err = (Palete.CompileError) ar.get_item(i); + + Gtk.TextIter iter; + // print("get inter\n"); + var eline = err.line + 1; + GLib.debug("GOT ERROR on line %d -- converted to %d ", + err.line ,eline); + + + if (eline > tlines || eline < 0) { + return; + } + + + buf.get_iter_at_line( out iter, eline); + + + var msg = "Line: %d %s : %s".printf(eline+1, err.category, err.msg); + buf.create_source_mark( msg, err.category, iter); + GLib.debug("set line %d to %s", eline, msg); + //this.marks.set(eline, msg); + } + return ; + + + + + + } + public void scroll_to_line (int line) { + // code preview... + + GLib.Timeout.add(100, () => { + + + this.notebook.el.set_current_page(1); + + var buf = this.sourceview.el.get_buffer(); + + var sbuf = (GtkSource.Buffer) buf; + + + Gtk.TextIter iter; + sbuf.get_iter_at_line(out iter, line); + this.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); + return false; + }); + + + } + public class Xcls_notebook : Object + { + public Gtk.Notebook el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_notebook(Xcls_GtkView _owner ) + { + _this = _owner; + _this.notebook = this; + this.el = new Gtk.Notebook(); + + // my vars (dec) + + // set gobject values + this.el.overflow = Gtk.Overflow.VISIBLE; + new Xcls_label_preview( _this ); + new Xcls_label_code( _this ); + var child_3 = new Xcls_ScrolledWindow5( _this ); + child_3.ref(); + this.el.append_page ( child_3.el , _this.label_preview.el ); + var child_4 = new Xcls_Box8( _this ); + child_4.ref(); + this.el.append_page ( child_4.el , _this.label_code.el ); + } + + // user defined functions + } + public class Xcls_label_preview : Object + { + public Gtk.Label el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_label_preview(Xcls_GtkView _owner ) + { + _this = _owner; + _this.label_preview = this; + this.el = new Gtk.Label( "Preview" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_label_code : Object + { + public Gtk.Label el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_label_code(Xcls_GtkView _owner ) + { + _this = _owner; + _this.label_code = this; + this.el = new Gtk.Label( "Preview Generated Code" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_ScrolledWindow5 : Object + { + public Gtk.ScrolledWindow el; + private Xcls_GtkView _this; + + + // my vars (def) - // ctor - public Xcls_ScrolledWindow5(Xcls_GtkView _owner ) - { - _this = _owner; - this.el = new Gtk.ScrolledWindow(); + // ctor + public Xcls_ScrolledWindow5(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow(); - // my vars (dec) + // my vars (dec) - // set gobject values - new Xcls_view_layout( _this ); - this.el.set_child ( _this.view_layout.el ); - } + // set gobject values + new Xcls_view_layout( _this ); + this.el.set_child ( _this.view_layout.el ); + } - // user defined functions - } - public class Xcls_view_layout : Object - { - public Gtk.Fixed el; - private Xcls_GtkView _this; + // user defined functions + } + public class Xcls_view_layout : Object + { + public Gtk.Fixed el; + private Xcls_GtkView _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_view_layout(Xcls_GtkView _owner ) - { - _this = _owner; - _this.view_layout = this; - this.el = new Gtk.Fixed(); + // ctor + public Xcls_view_layout(Xcls_GtkView _owner ) + { + _this = _owner; + _this.view_layout = this; + this.el = new Gtk.Fixed(); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.name = "gtkview-view-layout"; - new Xcls_container( _this ); - this.el.put ( _this.container.el , 10,10 ); - } + // set gobject values + this.el.name = "gtkview-view-layout"; + new Xcls_container( _this ); + this.el.put ( _this.container.el , 10,10 ); + } - // user defined functions - } - public class Xcls_container : Object - { - public Gtk.Box el; - private Xcls_GtkView _this; + // user defined functions + } + public class Xcls_container : Object + { + public Gtk.Box el; + private Xcls_GtkView _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_container(Xcls_GtkView _owner ) - { - _this = _owner; - _this.container = this; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + // ctor + public Xcls_container(Xcls_GtkView _owner ) + { + _this = _owner; + _this.container = this; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - // my vars (dec) + // my vars (dec) - // set gobject values - } + // set gobject values + } - // user defined functions - } + // user defined functions + } - public class Xcls_Box8 : Object - { - public Gtk.Box el; - private Xcls_GtkView _this; - - - // my vars (def) - - // ctor - public Xcls_Box8(Xcls_GtkView _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - new Xcls_sourceviewscroll( _this ); - this.el.append( _this.sourceviewscroll.el ); - var child_2 = new Xcls_Box13( _this ); - child_2.ref(); - this.el.append( child_2.el ); - } - - // user defined functions - } - public class Xcls_sourceviewscroll : Object - { - public Gtk.ScrolledWindow el; - private Xcls_GtkView _this; - - - // my vars (def) - - // ctor - public Xcls_sourceviewscroll(Xcls_GtkView _owner ) - { - _this = _owner; - _this.sourceviewscroll = this; - this.el = new Gtk.ScrolledWindow(); - - // my vars (dec) - - // set gobject values - this.el.vexpand = true; - new Xcls_sourceview( _this ); - this.el.set_child ( _this.sourceview.el ); - } - - // user defined functions - } - public class Xcls_sourceview : Object - { - public GtkSource.View el; - private Xcls_GtkView _this; - - - // my vars (def) - public bool loading; - public string prop_selected; - public bool allow_node_scroll; - public Gtk.CssProvider css; - public JsRender.Node? node_selected; - - // ctor - public Xcls_sourceview(Xcls_GtkView _owner ) - { - _this = _owner; - _this.sourceview = this; - this.el = new GtkSource.View(); - - // my vars (dec) - this.loading = true; - this.prop_selected = ""; - this.allow_node_scroll = true; - - // set gobject values - this.el.name = "gtkview-view"; - this.el.editable = false; - this.el.show_line_marks = true; - this.el.show_line_numbers = true; - new Xcls_buffer( _this ); - this.el.set_buffer ( _this.buffer.el ); - var child_2 = new Xcls_EventControllerKey12( _this ); - child_2.ref(); - this.el.add_controller( child_2.el ); - - // init method - - { - - - this.css = new Gtk.CssProvider(); - - this.css.load_from_string("#gtkview-view { font: 10px monospace ;}"); - - Gtk.StyleContext.add_provider_for_display( - this.el.get_display(), - this.css, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - ); - - - this.loading = true; - - - - var attrs = new GtkSource.MarkAttributes(); - var pink = Gdk.RGBA(); - pink.parse ( "pink"); - attrs.set_background ( pink); - attrs.set_icon_name ( "process-stop"); - attrs.query_tooltip_text.connect(( mark) => { - //print("tooltip query? %s\n", mark.name); - return mark.name; - }); - - this.el.set_mark_attributes ("ERR", attrs, 1); - - var wattrs = new GtkSource.MarkAttributes(); - var blue = Gdk.RGBA(); - blue.parse ( "#ABF4EB"); - wattrs.set_background ( blue); - wattrs.set_icon_name ( "process-stop"); - wattrs.query_tooltip_text.connect(( mark) => { - //print("tooltip query? %s\n", mark.name); - return mark.name; - }); - - this.el.set_mark_attributes ("WARN", wattrs, 1); - - - - var dattrs = new GtkSource.MarkAttributes(); - var purple = Gdk.RGBA(); - purple.parse ( "#EEA9FF"); - dattrs.set_background ( purple); - dattrs.set_icon_name ( "process-stop"); - dattrs.query_tooltip_text.connect(( mark) => { - //print("tooltip query? %s\n", mark.name); - return mark.name; - }); - - this.el.set_mark_attributes ("DEPR", dattrs, 1); - - - var gattrs = new GtkSource.MarkAttributes(); - var grey = Gdk.RGBA(); - grey.parse ( "#ccc"); - gattrs.set_background ( grey); - - - this.el.set_mark_attributes ("grey", gattrs, 1); - - - - - - - } - - //listeners - this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => { - - //GLib.debug("query tooltip"); - Gtk.TextIter iter; - int trailing; - - var yoff = (int) _this.sourceviewscroll.el.vadjustment.value; - - this.el.get_iter_at_position (out iter, out trailing, x, y + yoff); - - var l = iter.get_line(); - // GLib.debug("query tooltip line %d", (int) l); - var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR"); - if (marks.is_empty()) { - marks = _this.buffer.el.get_source_marks_at_line(l, "WARN"); - } - if (marks.is_empty()) { - marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR"); - } - - // GLib.debug("query tooltip line marks %d", (int) marks.length()); - var str = ""; - marks.@foreach((m) => { - //GLib.debug("got mark %s", m.name); - str += (str.length > 0 ? "\n" : "") + m.name; - }); - - // true if there is a mark.. - tooltip.set_text( str); - return str.length > 0 ? true : false; - - }); - } - - // user defined functions - public void loadFile ( ) { - this.loading = true; - var buf = this.el.get_buffer(); - buf.set_text("",0); - var sbuf = (GtkSource.Buffer) buf; - - - - if (_this.file == null || _this.file.xtype != "Gtk") { - print("xtype != Gtk"); - this.loading = false; - return; - } - - var valafn = ""; - try { - var regex = new Regex("\\.bjs$"); - - - valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala"); - } catch (GLib.RegexError e) { - this.loading = false; - return; - } - - - if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) { - print("File path has no errors\n"); - this.loading = false; - return ; - } - - string str; - try { - - GLib.FileUtils.get_contents (valafn, out str); - } catch (Error e) { - this.loading = false; - return ; - } - - // print("setting str %d\n", str.length); - buf.set_text(str, str.length); - var lm = GtkSource.LanguageManager.get_default(); - - //?? is javascript going to work as js? - - ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language)); - - - _this.main_window.windowstate.updateErrorMarksAll(); - - - - this.loading = false; - } - public void nodeSelected (JsRender.Node? sel, bool scroll) { - - - if (this.loading) { - return; - } - // this is connected in widnowstate - print("Roo-view - node selected\n"); - var buf = this.el.get_buffer(); - - var sbuf = (GtkSource.Buffer) buf; - - - // while(Gtk.events_pending()) { - // Gtk.main_iteration(); - // } - - - // clear all the marks.. - Gtk.TextIter start; - Gtk.TextIter end; - - sbuf.get_bounds (out start, out end); - sbuf.remove_source_marks (start, end, "grey"); - - this.node_selected = sel; - if (sel == null) { - // no highlighting.. - return; - } - Gtk.TextIter iter; - sbuf.get_iter_at_line(out iter, sel.line_start); - - - Gtk.TextIter cur_iter; - sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position); - - //var cur_line = cur_iter.get_line(); - //if (cur_line > sel.line_start && cur_line < sel.line_end) { - - //} else { - if (this.allow_node_scroll) { - - this.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); - } - - - - for (var i = 0; i < buf.get_line_count();i++) { - if (i < sel.line_start || i > sel.line_end) { - - sbuf.get_iter_at_line(out iter, i); - sbuf.create_source_mark(null, "grey", iter); - - } - - } - - - } - public string toString () { - Gtk.TextIter s; - Gtk.TextIter e; - this.el.get_buffer().get_start_iter(out s); - this.el.get_buffer().get_end_iter(out e); - var ret = this.el.get_buffer().get_text(s,e,true); - //print("TO STRING? " + ret); - return ret; - } - } - public class Xcls_buffer : Object - { - public GtkSource.Buffer el; - private Xcls_GtkView _this; - - - // my vars (def) - public int error_line; - public bool dirty; - - // ctor - public Xcls_buffer(Xcls_GtkView _owner ) - { - _this = _owner; - _this.buffer = this; - this.el = new GtkSource.Buffer( null ); - - // my vars (dec) - this.error_line = -1; - this.dirty = false; - - // set gobject values - - //listeners - this.el.notify["cursor_position"].connect( () => { - - - if (_this.sourceview.loading) { - return; - } - - GLib.debug("cursor changed : %d", this.el.cursor_position); - Gtk.TextIter cpos; - this.el.get_iter_at_offset(out cpos, this.el.cursor_position); - - var ln = cpos.get_line(); - - var node = _this.file.lineToNode(ln); - - if (node == null) { - print("can not find node\n"); - return; - } - _this.sourceview.loading = true; - var ltree = _this.main_window.windowstate.left_tree; - ltree.model.selectNode(node); - _this.sourceview.loading = false; - - //print("got tree path %s\n", tp); - //if (tp != "") { - // this.allow_node_scroll = false; - // print("changing cursor on tree..\n"); - //ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); - // scrolling is disabled... as node selection calls scroll 10ms after it changes. - ///GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => { - // this.allow_node_scroll = true; - // return false; - // }); - // } - - // highlight the node.. - - - - }); - } - - // user defined functions - } - - public class Xcls_EventControllerKey12 : Object - { - public Gtk.EventControllerKey el; - private Xcls_GtkView _this; - - - // my vars (def) - - // ctor - public Xcls_EventControllerKey12(Xcls_GtkView _owner ) - { - _this = _owner; - this.el = new Gtk.EventControllerKey(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.key_pressed.connect( (keyval, keycode, state) => { - - - - if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { - GLib.debug("SAVE: ctrl-g pressed"); - _this.forwardSearch(true); - return true; - } - if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { - GLib.debug("SAVE: ctrl-f pressed"); - _this.search_entry.el.grab_focus(); - return true; - } - - return false; - }); - } - - // user defined functions - } - - - - public class Xcls_Box13 : Object - { - public Gtk.Box el; - private Xcls_GtkView _this; - - - // my vars (def) - - // ctor - public Xcls_Box13(Xcls_GtkView _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.homogeneous = false; - this.el.vexpand = false; - new Xcls_search_entry( _this ); - this.el.append( _this.search_entry.el ); - new Xcls_search_results( _this ); - this.el.append( _this.search_results.el ); - new Xcls_nextBtn( _this ); - this.el.append( _this.nextBtn.el ); - new Xcls_backBtn( _this ); - this.el.append( _this.backBtn.el ); - var child_5 = new Xcls_MenuButton19( _this ); - child_5.ref(); - this.el.append( child_5.el ); - } - - // user defined functions - } - public class Xcls_search_entry : Object - { - public Gtk.SearchEntry el; - private Xcls_GtkView _this; - - - // my vars (def) - public Gtk.CssProvider css; - - // ctor - public Xcls_search_entry(Xcls_GtkView _owner ) - { - _this = _owner; - _this.search_entry = this; - this.el = new Gtk.SearchEntry(); - - // my vars (dec) - - // set gobject values - this.el.name = "gtkview-search-entry"; - this.el.hexpand = true; - this.el.placeholder_text = "Press enter to search"; - this.el.search_delay = 3; - var child_1 = new Xcls_EventControllerKey15( _this ); - child_1.ref(); - this.el.add_controller( child_1.el ); - - // init method - - this.css = new Gtk.CssProvider(); - - this.css.load_from_string(" - #gtkview-search-entry { font: 10px monospace ;}" - ); - - Gtk.StyleContext.add_provider_for_display( - this.el.get_display(), - this.css, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - ); - - //listeners - this.el.search_changed.connect( () => { - - _this.search(_this.search_entry.el.text); - _this.search_results.updateResults(); - - GLib.Timeout.add_seconds(1,() => { - _this.search_results.updateResults(); - return false; - }); - - - - }); - } - - // user defined functions - public void forwardSearch (bool change_focus) { - - - _this.forwardSearch(change_focus); - - /* - - switch(_this.windowstate.state) { - case WindowState.State.CODEONLY: - //case WindowState.State.CODE: - // search the code being edited.. - _this.windowstate.code_editor_tab.forwardSearch(change_focus); - - break; - case WindowState.State.PREVIEW: - if (_this.windowstate.file.xtype == "Gtk") { - _this.windowstate.window_gladeview.forwardSearch(change_focus); - } else { - _this.windowstate.window_rooview.forwardSearch(change_focus); - } - - break; - } - */ - - } - } - public class Xcls_EventControllerKey15 : Object - { - public Gtk.EventControllerKey el; - private Xcls_GtkView _this; - - - // my vars (def) - - // ctor - public Xcls_EventControllerKey15(Xcls_GtkView _owner ) - { - _this = _owner; - this.el = new Gtk.EventControllerKey(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.key_pressed.connect( (keyval, keycode, state) => { - - if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { - GLib.debug("SAVE: ctrl-g pressed"); - _this.forwardSearch(true); - return true; - } - - - if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) { - _this.forwardSearch(true); - - - return true; - - } - // print(event.key.keyval) - - return false; - }); - } - - // user defined functions - } - - - public class Xcls_search_results : Object - { - public Gtk.Label el; - private Xcls_GtkView _this; - - - // my vars (def) - - // ctor - public Xcls_search_results(Xcls_GtkView _owner ) - { - _this = _owner; - _this.search_results = this; - this.el = new Gtk.Label( "No Results" ); - - // my vars (dec) - - // set gobject values - this.el.margin_end = 4; - this.el.margin_start = 4; - } - - // user defined functions - public void updateResults () { - this.el.visible = true; - - var res = _this.searchcontext.get_occurrences_count(); - if (res < 0) { - _this.search_results.el.label = "??? Matches"; - return; - } - - _this.nextBtn.el.sensitive = false; - _this.backBtn.el.sensitive = false; - - if (res > 0) { - _this.search_results.el.label = "%d Matches".printf(res); - _this.nextBtn.el.sensitive = true; - _this.backBtn.el.sensitive = true; - return; - } - _this.search_results.el.label = "No Matches"; - - } - } - - public class Xcls_nextBtn : Object - { - public Gtk.Button el; - private Xcls_GtkView _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_nextBtn(Xcls_GtkView _owner ) - { - _this = _owner; - _this.nextBtn = this; - this.el = new Gtk.Button(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.icon_name = "go-down"; - this.el.sensitive = false; - - //listeners - this.el.clicked.connect( ( ) => { - _this.forwardSearch(true); - - - }); - } - - // user defined functions - } - - public class Xcls_backBtn : Object - { - public Gtk.Button el; - private Xcls_GtkView _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_backBtn(Xcls_GtkView _owner ) - { - _this = _owner; - _this.backBtn = this; - this.el = new Gtk.Button(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.icon_name = "go-up"; - this.el.sensitive = false; - - //listeners - this.el.clicked.connect( ( ) => { - - _this.backSearch(true); - - }); - } - - // user defined functions - } - - public class Xcls_MenuButton19 : Object - { - public Gtk.MenuButton el; - private Xcls_GtkView _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_MenuButton19(Xcls_GtkView _owner ) - { - _this = _owner; - this.el = new Gtk.MenuButton(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.icon_name = "emblem-system"; - this.el.always_show_arrow = true; - new Xcls_search_settings( _this ); - this.el.popover = _this.search_settings.el; - } - - // user defined functions - } - public class Xcls_search_settings : Object - { - public Gtk.PopoverMenu el; - private Xcls_GtkView _this; - - - // my vars (def) + public class Xcls_Box8 : Object + { + public Gtk.Box el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_Box8(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + new Xcls_sourceviewscroll( _this ); + this.el.append( _this.sourceviewscroll.el ); + var child_2 = new Xcls_Box13( _this ); + child_2.ref(); + this.el.append( child_2.el ); + } + + // user defined functions + } + public class Xcls_sourceviewscroll : Object + { + public Gtk.ScrolledWindow el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_sourceviewscroll(Xcls_GtkView _owner ) + { + _this = _owner; + _this.sourceviewscroll = this; + this.el = new Gtk.ScrolledWindow(); + + // my vars (dec) + + // set gobject values + this.el.vexpand = true; + new Xcls_sourceview( _this ); + this.el.set_child ( _this.sourceview.el ); + } + + // user defined functions + } + public class Xcls_sourceview : Object + { + public GtkSource.View el; + private Xcls_GtkView _this; + + + // my vars (def) + public bool loading; + public bool zallow_node_scroll; + public string prop_selected; + public Gtk.CssProvider css; + public JsRender.Node? node_selected; + + // ctor + public Xcls_sourceview(Xcls_GtkView _owner ) + { + _this = _owner; + _this.sourceview = this; + this.el = new GtkSource.View(); + + // my vars (dec) + this.loading = false; + this.zallow_node_scroll = true; + this.prop_selected = ""; + + // set gobject values + this.el.name = "gtkview-view"; + this.el.editable = false; + this.el.show_line_marks = true; + this.el.show_line_numbers = true; + this.el.tab_width = 4; + new Xcls_buffer( _this ); + this.el.set_buffer ( _this.buffer.el ); + var child_2 = new Xcls_EventControllerKey12( _this ); + child_2.ref(); + this.el.add_controller( child_2.el ); + + // init method + + { + + + this.css = new Gtk.CssProvider(); + + this.css.load_from_string("#gtkview-view { font: 10px monospace ;}"); + + Gtk.StyleContext.add_provider_for_display( + this.el.get_display(), + this.css, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + ); + + + this.loading = true; + + + + var attrs = new GtkSource.MarkAttributes(); + var pink = Gdk.RGBA(); + pink.parse ( "pink"); + attrs.set_background ( pink); + attrs.set_icon_name ( "process-stop"); + attrs.query_tooltip_text.connect(( mark) => { + //print("tooltip query? %s\n", mark.name); + return mark.name; + }); + + this.el.set_mark_attributes ("ERR", attrs, 1); + + var wattrs = new GtkSource.MarkAttributes(); + var blue = Gdk.RGBA(); + blue.parse ( "#ABF4EB"); + wattrs.set_background ( blue); + wattrs.set_icon_name ( "process-stop"); + wattrs.query_tooltip_text.connect(( mark) => { + //print("tooltip query? %s\n", mark.name); + return mark.name; + }); + + this.el.set_mark_attributes ("WARN", wattrs, 1); + + + + var dattrs = new GtkSource.MarkAttributes(); + var purple = Gdk.RGBA(); + purple.parse ( "#EEA9FF"); + dattrs.set_background ( purple); + dattrs.set_icon_name ( "process-stop"); + dattrs.query_tooltip_text.connect(( mark) => { + //print("tooltip query? %s\n", mark.name); + return mark.name; + }); + + this.el.set_mark_attributes ("DEPR", dattrs, 1); + + + var gattrs = new GtkSource.MarkAttributes(); + var grey = Gdk.RGBA(); + grey.parse ( "#ccc"); + gattrs.set_background ( grey); + + + this.el.set_mark_attributes ("grey", gattrs, 1); + + + + + + + } + + //listeners + this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => { + + //GLib.debug("query tooltip"); + Gtk.TextIter iter; + int trailing; + + var yoff = (int) _this.sourceviewscroll.el.vadjustment.value; + + this.el.get_iter_at_position (out iter, out trailing, x, y + yoff); + + var l = iter.get_line(); + // GLib.debug("query tooltip line %d", (int) l); + var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR"); + if (marks.is_empty()) { + marks = _this.buffer.el.get_source_marks_at_line(l, "WARN"); + } + if (marks.is_empty()) { + marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR"); + } + + // GLib.debug("query tooltip line marks %d", (int) marks.length()); + var str = ""; + marks.@foreach((m) => { + //GLib.debug("got mark %s", m.name); + str += (str.length > 0 ? "\n" : "") + m.name; + }); + + // true if there is a mark.. + tooltip.set_text( str); + return str.length > 0 ? true : false; + + }); + } + + // user defined functions + public void loadFile ( ) { + this.loading = true; + var buf = this.el.get_buffer(); + buf.set_text("",0); + var sbuf = (GtkSource.Buffer) buf; + var cpos = buf.cursor_position; + + print("BEFORE LOAD cursor = %d\n", cpos); + var vadj_pos = this.el.get_vadjustment().get_value(); + + if (_this.file == null || _this.file.xtype != "Gtk") { + print("xtype != Gtk"); + this.loading = false; + return; + } + + var valafn = ""; + try { + var regex = new Regex("\\.bjs$"); + + + valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala"); + } catch (GLib.RegexError e) { + this.loading = false; + return; + } + + + if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) { + print("File path has no errors\n"); + this.loading = false; + return ; + } + + string str; + try { + + GLib.FileUtils.get_contents (valafn, out str); + } catch (Error e) { + this.loading = false; + return ; + } + + // print("setting str %d\n", str.length); + buf.set_text(str, str.length); + var lm = GtkSource.LanguageManager.get_default(); + + //?? is javascript going to work as js? + + ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language)); + + + _this.main_window.windowstate.updateErrorMarksAll(); + // restore the cursor position? + // after reloading the contents. + GLib.Timeout.add(500, () => { + _this.buffer.in_cursor_change = true; + print("RESORTING cursor to = %d\n", cpos); + Gtk.TextIter cpos_iter; + buf.get_iter_at_offset(out cpos_iter, cpos); + buf.place_cursor(cpos_iter); + + this.el.get_vadjustment().set_value(vadj_pos);; + _this.buffer.in_cursor_change = false; + + + + //_this.buffer.checkSyntax(); + return false; + }); + + + this.loading = false; + } + public void nodeSelected (JsRender.Node? sel, bool scroll) { + + + if (this.loading) { + return; + } + // this is connected in widnowstate + print("Roo-view - node selected\n"); + var buf = this.el.get_buffer(); + + var sbuf = (GtkSource.Buffer) buf; + + + + + + // clear all the marks.. + Gtk.TextIter start; + Gtk.TextIter end; + + sbuf.get_bounds (out start, out end); + sbuf.remove_source_marks (start, end, "grey"); + + this.node_selected = sel; + if (sel == null) { + // no highlighting.. + return; + } + Gtk.TextIter iter; + sbuf.get_iter_at_line(out iter, sel.line_start); + + + Gtk.TextIter cur_iter; + sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position); + + + if (!_this.buffer.in_cursor_change) { + + this.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); + } + + + + for (var i = 0; i < buf.get_line_count();i++) { + if (i < sel.line_start || i > sel.line_end) { + + sbuf.get_iter_at_line(out iter, i); + sbuf.create_source_mark(null, "grey", iter); + + } + + } + + + } + public string toString () { + Gtk.TextIter s; + Gtk.TextIter e; + this.el.get_buffer().get_start_iter(out s); + this.el.get_buffer().get_end_iter(out e); + var ret = this.el.get_buffer().get_text(s,e,true); + //print("TO STRING? " + ret); + return ret; + } + } + public class Xcls_buffer : Object + { + public GtkSource.Buffer el; + private Xcls_GtkView _this; + + + // my vars (def) + public int error_line; + public bool in_cursor_change; + public bool dirty; + public int last_line; + + // ctor + public Xcls_buffer(Xcls_GtkView _owner ) + { + _this = _owner; + _this.buffer = this; + this.el = new GtkSource.Buffer( null ); + + // my vars (dec) + this.error_line = -1; + this.in_cursor_change = false; + this.dirty = false; + this.last_line = -1; + + // set gobject values + + //listeners + this.el.cursor_moved.connect( ( ) => { + GLib.debug("cursor moved called"); + + + if (this.in_cursor_change ) { + GLib.debug("cursor changed : %d [ignoring nested call)", this.el.cursor_position); + return; + } + + GLib.debug("cursor changed : %d", this.el.cursor_position); + Gtk.TextIter cpos; + this.el.get_iter_at_offset(out cpos, this.el.cursor_position); + + var ln = cpos.get_line(); + if (this.last_line == ln ){ + return; + } + this.last_line = ln; + var node = _this.file.lineToNode(ln); + + if (node == null) { + print("can not find node\n"); + return; + } + this.in_cursor_change = true; + var ltree = _this.main_window.windowstate.left_tree; + ltree.model.selectNode(node); + this.in_cursor_change = false; + }); + } + + // user defined functions + } + + public class Xcls_EventControllerKey12 : Object + { + public Gtk.EventControllerKey el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_EventControllerKey12(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.EventControllerKey(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.key_pressed.connect( (keyval, keycode, state) => { + + + + if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-g pressed"); + _this.forwardSearch(true); + return true; + } + if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-f pressed"); + _this.search_entry.el.grab_focus(); + return true; + } + + return false; + }); + } + + // user defined functions + } + + + + public class Xcls_Box13 : Object + { + public Gtk.Box el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_Box13(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + this.el.vexpand = false; + new Xcls_search_entry( _this ); + this.el.append( _this.search_entry.el ); + new Xcls_search_results( _this ); + this.el.append( _this.search_results.el ); + new Xcls_nextBtn( _this ); + this.el.append( _this.nextBtn.el ); + new Xcls_backBtn( _this ); + this.el.append( _this.backBtn.el ); + var child_5 = new Xcls_MenuButton19( _this ); + child_5.ref(); + this.el.append( child_5.el ); + } + + // user defined functions + } + public class Xcls_search_entry : Object + { + public Gtk.SearchEntry el; + private Xcls_GtkView _this; + + + // my vars (def) + public Gtk.CssProvider css; + + // ctor + public Xcls_search_entry(Xcls_GtkView _owner ) + { + _this = _owner; + _this.search_entry = this; + this.el = new Gtk.SearchEntry(); + + // my vars (dec) + + // set gobject values + this.el.name = "gtkview-search-entry"; + this.el.hexpand = true; + this.el.placeholder_text = "Press enter to search"; + this.el.search_delay = 3; + var child_1 = new Xcls_EventControllerKey15( _this ); + child_1.ref(); + this.el.add_controller( child_1.el ); + + // init method + + this.css = new Gtk.CssProvider(); + + this.css.load_from_string(" + #gtkview-search-entry { font: 10px monospace ;}" + ); + + Gtk.StyleContext.add_provider_for_display( + this.el.get_display(), + this.css, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + ); + + //listeners + this.el.search_changed.connect( () => { + + _this.search(_this.search_entry.el.text); + _this.search_results.updateResults(); + + GLib.Timeout.add_seconds(1,() => { + _this.search_results.updateResults(); + return false; + }); + + + + }); + } + + // user defined functions + public void forwardSearch (bool change_focus) { + + + _this.forwardSearch(change_focus); + + /* + + switch(_this.windowstate.state) { + case WindowState.State.CODEONLY: + //case WindowState.State.CODE: + // search the code being edited.. + _this.windowstate.code_editor_tab.forwardSearch(change_focus); + + break; + case WindowState.State.PREVIEW: + if (_this.windowstate.file.xtype == "Gtk") { + _this.windowstate.window_gladeview.forwardSearch(change_focus); + } else { + _this.windowstate.window_rooview.forwardSearch(change_focus); + } + + break; + } + */ + + } + } + public class Xcls_EventControllerKey15 : Object + { + public Gtk.EventControllerKey el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_EventControllerKey15(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.EventControllerKey(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.key_pressed.connect( (keyval, keycode, state) => { + + if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-g pressed"); + _this.forwardSearch(true); + return true; + } + + + if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) { + _this.forwardSearch(true); + + + return true; + + } + // print(event.key.keyval) + + return false; + }); + } + + // user defined functions + } + + + public class Xcls_search_results : Object + { + public Gtk.Label el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_search_results(Xcls_GtkView _owner ) + { + _this = _owner; + _this.search_results = this; + this.el = new Gtk.Label( "No Results" ); + + // my vars (dec) + + // set gobject values + this.el.margin_end = 4; + this.el.margin_start = 4; + } + + // user defined functions + public void updateResults () { + this.el.visible = true; + + var res = _this.searchcontext.get_occurrences_count(); + if (res < 0) { + _this.search_results.el.label = "??? Matches"; + return; + } + + _this.nextBtn.el.sensitive = false; + _this.backBtn.el.sensitive = false; + + if (res > 0) { + _this.search_results.el.label = "%d Matches".printf(res); + _this.nextBtn.el.sensitive = true; + _this.backBtn.el.sensitive = true; + return; + } + _this.search_results.el.label = "No Matches"; + + } + } + + public class Xcls_nextBtn : Object + { + public Gtk.Button el; + private Xcls_GtkView _this; + + + // my vars (def) + public bool always_show_image; + + // ctor + public Xcls_nextBtn(Xcls_GtkView _owner ) + { + _this = _owner; + _this.nextBtn = this; + this.el = new Gtk.Button(); + + // my vars (dec) + this.always_show_image = true; + + // set gobject values + this.el.icon_name = "go-down"; + this.el.sensitive = false; + + //listeners + this.el.clicked.connect( ( ) => { + _this.forwardSearch(true); + + + }); + } + + // user defined functions + } + + public class Xcls_backBtn : Object + { + public Gtk.Button el; + private Xcls_GtkView _this; + + + // my vars (def) + public bool always_show_image; + + // ctor + public Xcls_backBtn(Xcls_GtkView _owner ) + { + _this = _owner; + _this.backBtn = this; + this.el = new Gtk.Button(); + + // my vars (dec) + this.always_show_image = true; + + // set gobject values + this.el.icon_name = "go-up"; + this.el.sensitive = false; + + //listeners + this.el.clicked.connect( ( ) => { + + _this.backSearch(true); + + }); + } + + // user defined functions + } + + public class Xcls_MenuButton19 : Object + { + public Gtk.MenuButton el; + private Xcls_GtkView _this; + + + // my vars (def) + public bool always_show_image; + + // ctor + public Xcls_MenuButton19(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.MenuButton(); + + // my vars (dec) + this.always_show_image = true; + + // set gobject values + this.el.icon_name = "emblem-system"; + this.el.always_show_arrow = true; + new Xcls_search_settings( _this ); + this.el.popover = _this.search_settings.el; + } + + // user defined functions + } + public class Xcls_search_settings : Object + { + public Gtk.PopoverMenu el; + private Xcls_GtkView _this; + + + // my vars (def) - // ctor - public Xcls_search_settings(Xcls_GtkView _owner ) - { - _this = _owner; - _this.search_settings = this; - this.el = new Gtk.PopoverMenu.from_model(null); - - // my vars (dec) + // ctor + public Xcls_search_settings(Xcls_GtkView _owner ) + { + _this = _owner; + _this.search_settings = this; + this.el = new Gtk.PopoverMenu.from_model(null); + + // my vars (dec) - // set gobject values - var child_1 = new Xcls_Box21( _this ); - child_1.ref(); - this.el.set_child ( child_1.el ); - } + // set gobject values + var child_1 = new Xcls_Box21( _this ); + child_1.ref(); + this.el.set_child ( child_1.el ); + } - // user defined functions - } - public class Xcls_Box21 : Object - { - public Gtk.Box el; - private Xcls_GtkView _this; + // user defined functions + } + public class Xcls_Box21 : Object + { + public Gtk.Box el; + private Xcls_GtkView _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_Box21(Xcls_GtkView _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + // ctor + public Xcls_Box21(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - // my vars (dec) + // my vars (dec) - // set gobject values - new Xcls_case_sensitive( _this ); - this.el.append( _this.case_sensitive.el ); - new Xcls_regex( _this ); - this.el.append( _this.regex.el ); - new Xcls_multiline( _this ); - this.el.append( _this.multiline.el ); - } + // set gobject values + new Xcls_case_sensitive( _this ); + this.el.append( _this.case_sensitive.el ); + new Xcls_regex( _this ); + this.el.append( _this.regex.el ); + new Xcls_multiline( _this ); + this.el.append( _this.multiline.el ); + } - // user defined functions - } - public class Xcls_case_sensitive : Object - { - public Gtk.CheckButton el; - private Xcls_GtkView _this; + // user defined functions + } + public class Xcls_case_sensitive : Object + { + public Gtk.CheckButton el; + private Xcls_GtkView _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_case_sensitive(Xcls_GtkView _owner ) - { - _this = _owner; - _this.case_sensitive = this; - this.el = new Gtk.CheckButton(); + // ctor + public Xcls_case_sensitive(Xcls_GtkView _owner ) + { + _this = _owner; + _this.case_sensitive = this; + this.el = new Gtk.CheckButton(); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.label = "Case Sensitive"; - } + // set gobject values + this.el.label = "Case Sensitive"; + } - // user defined functions - } + // user defined functions + } - public class Xcls_regex : Object - { - public Gtk.CheckButton el; - private Xcls_GtkView _this; + public class Xcls_regex : Object + { + public Gtk.CheckButton el; + private Xcls_GtkView _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_regex(Xcls_GtkView _owner ) - { - _this = _owner; - _this.regex = this; - this.el = new Gtk.CheckButton(); + // ctor + public Xcls_regex(Xcls_GtkView _owner ) + { + _this = _owner; + _this.regex = this; + this.el = new Gtk.CheckButton(); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.label = "Regex"; - } + // set gobject values + this.el.label = "Regex"; + } - // user defined functions - } + // user defined functions + } - public class Xcls_multiline : Object - { - public Gtk.CheckButton el; - private Xcls_GtkView _this; + public class Xcls_multiline : Object + { + public Gtk.CheckButton el; + private Xcls_GtkView _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_multiline(Xcls_GtkView _owner ) - { - _this = _owner; - _this.multiline = this; - this.el = new Gtk.CheckButton(); + // ctor + public Xcls_multiline(Xcls_GtkView _owner ) + { + _this = _owner; + _this.multiline = this; + this.el = new Gtk.CheckButton(); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.label = "Multi-line (add \\n)"; - } + // set gobject values + this.el.label = "Multi-line (add \\n)"; + } - // user defined functions - } + // user defined functions + } @@ -1439,4 +1443,4 @@ - } +} diff --git a/src/Builder4/MainWindow.bjs b/src/Builder4/MainWindow.bjs index d43dd8f14..705b18bf6 100644 --- a/src/Builder4/MainWindow.bjs +++ b/src/Builder4/MainWindow.bjs @@ -517,7 +517,7 @@ "xtype" : "Button", "| void setNotices" : [ "(GLib.ListStore nots, GLib.ListStore fe ) {", - " ", + " BuilderApplication.showSpinner(\"\");", " if (nots.get_n_items() < 1 ) {", " \tthis.el.hide();", " \tif (this.popup != null) {", @@ -537,6 +537,7 @@ " // this.popup.el.set_transient_for( _this.el );", " this.popup.el.set_parent(this.el);", " }", + " ", "\tthis.popup.updateNotices(nots);", "\t ", "}", @@ -643,7 +644,9 @@ }, { "$ xns" : "Gtk", + "Palete.ValaCompileRequest? last_request" : "null", "Xcls_ValaCompileErrors popup" : "", + "bool visible" : false, "id" : "statusbar_run", "listeners" : { "clicked" : [ @@ -658,14 +661,21 @@ " \treturn;", "\t}", "\t", - "\tvar req = new Palete.ValaCompileRequest(", + "\tif (this.last_request != null) {", + "\t\tthis.last_request.cancel();", + "\t\tif (this.last_request.terminal_pid > 0) {", + "\t\t\tthis.last_request.killChildren(this.last_request.terminal_pid);", + "\t\t}", + "\t}", + "\t", + "\tthis.last_request= new Palete.ValaCompileRequest(", "\t\tPalete.ValaCompileRequestType.RUN,", "\t\t_this.windowstate.file,", "\t\tnull,", "\t\tnull,", "\t\t\"\"", "\t);", - "\treq.run();", + "\tthis.last_request.run();", "\t ", "\t_this.windowstate.compile_results.el.set_parent(this.el);", "\t_this.windowstate.compile_results.show(this.el,true);", @@ -688,9 +698,20 @@ "string tooltip_text" : "Compiling", "xtype" : "Spinner", "| void start" : [ - "() {", - " this.el.show();", - " this.el.start(); ", + "(string icon, string tooltip) {", + "", + "\tif (icon == \"spinner\") {", + "\t this.el.show();", + "\t this.el.start(); ", + "\t this.el.tooltip_text = tooltip;", + "\t _this.statusbar_compile_icon.el.hide();", + " } else {", + "\t this.el.hide();", + "\t// GLib.debug(\"set status icon %s, %s\", icon, tooltip);", + "\t _this.statusbar_compile_icon.el.tooltip_text = tooltip;", + "\t _this.statusbar_compile_icon.el.icon_name = icon;", + "\t _this.statusbar_compile_icon.el.show();\t ", + " }", " ", "\t ", "}", @@ -700,10 +721,18 @@ "() {", " this.el.stop();", " this.el.hide();", - " ", + " _this.statusbar_compile_icon.el.hide(); ", "}", "" ] + }, + { + "$ xns" : "Gtk", + "Gtk.IconSize icon_size" : "Gtk.IconSize.NORMAL", + "id" : "statusbar_compile_icon", + "int margin_end" : 4, + "int margin_start" : 4, + "xtype" : "Image" } ], "xtype" : "Box" diff --git a/src/Builder4/MainWindow.vala b/src/Builder4/MainWindow.vala index 65636a63e..71de0b269 100644 --- a/src/Builder4/MainWindow.vala +++ b/src/Builder4/MainWindow.vala @@ -1,1519 +1,1570 @@ - static Xcls_MainWindow _MainWindow; - - public class Xcls_MainWindow : Object - { - public Gtk.ApplicationWindow el; - private Xcls_MainWindow _this; - - public static Xcls_MainWindow singleton() - { - if (_MainWindow == null) { - _MainWindow= new Xcls_MainWindow(); - } - return _MainWindow; - } - public Xcls_headerbar headerbar; - public Xcls_windowbtn windowbtn; - public Xcls_windowspopup windowspopup; - public Xcls_popover_menu popover_menu; - public Xcls_open_projects_btn open_projects_btn; - public Xcls_vbox vbox; - public Xcls_mainpane mainpane; - public Xcls_leftpane leftpane; - public Xcls_editpane editpane; - public Xcls_tree tree; - public Xcls_props props; - public Xcls_rooviewbox rooviewbox; - public Xcls_codeeditviewbox codeeditviewbox; - public Xcls_topbarmenu topbarmenu; - public Xcls_statusbar statusbar; - public Xcls_statusbar_compilestatus_label statusbar_compilestatus_label; - public Xcls_statusbar_errors statusbar_errors; - public Xcls_statusbar_warnings statusbar_warnings; - public Xcls_statusbar_depricated statusbar_depricated; - public Xcls_statusbar_run statusbar_run; - public Xcls_statusbar_compile_spinner statusbar_compile_spinner; - - // my vars (def) - public WindowState windowstate; - public Project.Project project; - - // ctor - public Xcls_MainWindow() - { - _this = this; - this.el = new Gtk.ApplicationWindow(BuilderApplication.singleton({})); - - // my vars (dec) - this.project = null; - - // set gobject values - this.el.title = "Roo Application Builder"; - this.el.default_height = 850; - this.el.default_width = 1200; - new Xcls_headerbar( _this ); - this.el.set_titlebar ( _this.headerbar.el ); - new Xcls_vbox( _this ); - this.el.set_child ( _this.vbox.el ); - - // init method - - this.el.set_icon_name("roobuilder"); - - //listeners - this.el.close_request.connect( ( ) => { - Resources.singleton().disconnect(_this.statusbar.handler_id); - - - this.windowstate.file.getLanguageServer().document_close( - this.windowstate.file - ); - - BuilderApplication.removeWindow(this); - - if (BuilderApplication.windows.size < 1) { - this.windowstate.file.getLanguageServer().exit(); - BuilderApplication.singleton( null ).quit(); - } - return true; - }); - this.el.show.connect( ( ) => { - // hide the file editing.. - - //this.hideViewEditing(); - // this is updated by windowstate - we try and fill it in.. - _this.statusbar.el.hide(); - //_this.statusbar_errors.el.hide(); - //_this.statusbar_warnings.el.hide(); - //_this.statusbar_depricated.el.hide(); - _this.statusbar_compile_spinner.el.hide(); - - Resources.singleton().checkResources(); - - - - }); - this.el.hide.connect( () => { - - - - }); - } - - // user defined functions - public void updateErrors () { - - - GLib.debug("updateErrors"); - - var pr = this.windowstate.project.getErrors("ERR"); - - this.statusbar_errors.setNotices( - pr, - this.windowstate.file.getErrors("ERR") - ); - - this.statusbar_warnings.setNotices( - this.windowstate.project.getErrors("WARN"), - this.windowstate.file.getErrors("WARN") - ); - this.statusbar_depricated.setNotices( - this.windowstate.project.getErrors("DEPR"), - this.windowstate.file.getErrors("DEPR") - ); - - _this.statusbar_run.el.hide(); - - if (pr.get_n_items() < 1) { - _this.statusbar_run.el.show(); - } - - } - public void initChildren () { - // this needs putting in a better place.. - this.windowstate = new WindowState(this); - - - - - - - - - } - public void show () { - - this.el.show(); - if (this.windowstate.file == null) { - this.windowstate.showPopoverFiles(this.open_projects_btn.el, null, false); - } - } - public void setTitle () { - if (_this.windowstate.project == null || - _this.windowstate.file == null - ) { - this.el.set_title("Select File"); - return; - } - _this.el.set_title( - _this.windowstate.project.name + - " - " + - _this.windowstate.file.relpath); - } - public void openNewWindow () { - - var w = new Xcls_MainWindow(); - w.ref(); - BuilderApplication.addWindow(w); - w.el.show(); - w.initChildren(); - w.windowstate.showPopoverFiles(w.open_projects_btn.el, _this.project, false); - - } - public class Xcls_headerbar : Object - { - public Gtk.HeaderBar el; - private Xcls_MainWindow _this; - - - // my vars (def) - public bool show_close_button; - public string title; - - // ctor - public Xcls_headerbar(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.headerbar = this; - this.el = new Gtk.HeaderBar(); - - // my vars (dec) - this.show_close_button = true; - this.title = "Application Builder"; - - // set gobject values - var child_1 = new Xcls_Box3( _this ); - child_1.ref(); - this.el.pack_start ( child_1.el ); - } - - // user defined functions - } - public class Xcls_Box3 : Object - { - public Gtk.Box el; - private Xcls_MainWindow _this; - - - // my vars (def) - - // ctor - public Xcls_Box3(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - - // my vars (dec) - - // set gobject values - new Xcls_windowbtn( _this ); - this.el.append( _this.windowbtn.el ); - new Xcls_open_projects_btn( _this ); - this.el.append ( _this.open_projects_btn.el ); - } - - // user defined functions - } - public class Xcls_windowbtn : Object - { - public Gtk.Button el; - private Xcls_MainWindow _this; - - - // my vars (def) - public Gee.ArrayList mitems; - - // ctor - public Xcls_windowbtn(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.windowbtn = this; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.margin_end = 4; - this.el.halign = Gtk.Align.START; - new Xcls_windowspopup( _this ); - var child_2 = new Xcls_Box10( _this ); - this.el.child = child_2.el; - - // init method - - { - this.mitems = new Gee.ArrayList(); - } - - //listeners - this.el.clicked.connect( ( ) => { - this.updateMenu(); - - _this.windowspopup.el.set_parent(this.el); - - _this.windowspopup.el.set_position(Gtk.PositionType.BOTTOM); - _this.windowspopup.el.popup(); - }); - } - - // user defined functions - public void updateMenu () { - foreach(var m in this.mitems) { - _this.popover_menu.el.remove(m); - } - this.mitems.clear(); - - BuilderApplication.windows.sort((a,b) => { - if (a.windowstate == null || - a.windowstate.file == null || - b.windowstate == null || - b.windowstate.file == null - ) { - return 0; - } - - var ap = a.windowstate.file.project.name; - var bp = b.windowstate.file.project.name; - - - - if (ap != bp) { - return ap.collate(bp); - } - var af = a.windowstate.file == null ? "" : a.windowstate.file.getTitle(); - var bf = b.windowstate.file == null ? "" : b.windowstate.file.getTitle(); - return af.collate(bf); - - }); - - var p = ""; - foreach(var w in BuilderApplication.windows) { - var wid = BuilderApplication.windows.index_of(w); - // fixme find a better way to display this. - if (w.windowstate == null || - w.windowstate.file == null || - _this.windowstate == null || - _this.windowstate.file == null - ) { - continue; - } - // should not happen... - if (w.windowstate.file.path == _this.windowstate.file.path) { - continue; - } - if (w.windowstate.file.project.name != p || p != "") { - var ms = new Gtk.Separator(Gtk.Orientation.HORIZONTAL); - _this.popover_menu.el.append(ms); - ms.show(); - this.mitems.add(ms); - } - - p = w.windowstate.file.project.name; - - - GLib.debug("add menuitem %s", w.windowstate.file.path); - - - - var m = new Gtk.Button.with_label( - w.windowstate.file.project.name + " : " + w.windowstate.file.relpath - ); - m.halign = Gtk.Align.START; - - - //w.windowstate.file.path); - m.clicked.connect(() => { - _this.windowspopup.el.hide(); - BuilderApplication.windows.get(wid).el.present(); - }); - _this.popover_menu.el.append(m); - //m.show(); - this.mitems.add(m); - } - } - } - public class Xcls_windowspopup : Object - { - public Gtk.Popover el; - private Xcls_MainWindow _this; - - - // my vars (def) - - // ctor - public Xcls_windowspopup(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.windowspopup = this; - this.el = new Gtk.Popover(); - - // my vars (dec) - - // set gobject values - new Xcls_popover_menu( _this ); - this.el.set_child ( _this.popover_menu.el ); - } - - // user defined functions - } - public class Xcls_popover_menu : Object - { - public Gtk.Box el; - private Xcls_MainWindow _this; - - - // my vars (def) - - // ctor - public Xcls_popover_menu(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.popover_menu = this; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - var child_1 = new Xcls_Button7( _this ); - child_1.ref(); - this.el.append ( child_1.el ); - var child_2 = new Xcls_Separator9( _this ); - child_2.ref(); - this.el.append ( child_2.el ); - } - - // user defined functions - } - public class Xcls_Button7 : Object - { - public Gtk.Button el; - private Xcls_MainWindow _this; - - - // my vars (def) - - // ctor - public Xcls_Button7(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.label = "New Window"; - var child_1 = new Xcls_ShortcutController8( _this ); - child_1.ref(); - this.el.add_controller( child_1.el ); - - //listeners - this.el.clicked.connect( ( ) => { - _this.windowspopup.el.hide(); - _this.windowstate.showPopoverFiles(_this.windowbtn.el, _this.project, true); - }); - } - - // user defined functions - } - public class Xcls_ShortcutController8 : Object - { - public Gtk.ShortcutController el; - private Xcls_MainWindow _this; - - - // my vars (def) +static Xcls_MainWindow _MainWindow; + +public class Xcls_MainWindow : Object +{ + public Gtk.ApplicationWindow el; + private Xcls_MainWindow _this; + + public static Xcls_MainWindow singleton() + { + if (_MainWindow == null) { + _MainWindow= new Xcls_MainWindow(); + } + return _MainWindow; + } + public Xcls_headerbar headerbar; + public Xcls_windowbtn windowbtn; + public Xcls_windowspopup windowspopup; + public Xcls_popover_menu popover_menu; + public Xcls_open_projects_btn open_projects_btn; + public Xcls_vbox vbox; + public Xcls_mainpane mainpane; + public Xcls_leftpane leftpane; + public Xcls_editpane editpane; + public Xcls_tree tree; + public Xcls_props props; + public Xcls_rooviewbox rooviewbox; + public Xcls_codeeditviewbox codeeditviewbox; + public Xcls_topbarmenu topbarmenu; + public Xcls_statusbar statusbar; + public Xcls_statusbar_compilestatus_label statusbar_compilestatus_label; + public Xcls_statusbar_errors statusbar_errors; + public Xcls_statusbar_warnings statusbar_warnings; + public Xcls_statusbar_depricated statusbar_depricated; + public Xcls_statusbar_run statusbar_run; + public Xcls_statusbar_compile_spinner statusbar_compile_spinner; + public Xcls_statusbar_compile_icon statusbar_compile_icon; + + // my vars (def) + public WindowState windowstate; + public Project.Project project; + + // ctor + public Xcls_MainWindow() + { + _this = this; + this.el = new Gtk.ApplicationWindow(BuilderApplication.singleton({})); + + // my vars (dec) + this.project = null; + + // set gobject values + this.el.title = "Roo Application Builder"; + this.el.default_height = 850; + this.el.default_width = 1200; + new Xcls_headerbar( _this ); + this.el.set_titlebar ( _this.headerbar.el ); + new Xcls_vbox( _this ); + this.el.set_child ( _this.vbox.el ); + + // init method + + this.el.set_icon_name("roobuilder"); + + //listeners + this.el.close_request.connect( ( ) => { + Resources.singleton().disconnect(_this.statusbar.handler_id); + + + this.windowstate.file.getLanguageServer().document_close( + this.windowstate.file + ); + + BuilderApplication.removeWindow(this); + + if (BuilderApplication.windows.size < 1) { + this.windowstate.file.getLanguageServer().exit(); + BuilderApplication.singleton( null ).quit(); + } + return true; + }); + this.el.show.connect( ( ) => { + // hide the file editing.. + + //this.hideViewEditing(); + // this is updated by windowstate - we try and fill it in.. + _this.statusbar.el.hide(); + //_this.statusbar_errors.el.hide(); + //_this.statusbar_warnings.el.hide(); + //_this.statusbar_depricated.el.hide(); + _this.statusbar_compile_spinner.el.hide(); + + Resources.singleton().checkResources(); + + + + }); + this.el.hide.connect( () => { + + + + }); + } + + // user defined functions + public void updateErrors () { + + + GLib.debug("updateErrors"); + + var pr = this.windowstate.project.getErrors("ERR"); + + this.statusbar_errors.setNotices( + pr, + this.windowstate.file.getErrors("ERR") + ); + + this.statusbar_warnings.setNotices( + this.windowstate.project.getErrors("WARN"), + this.windowstate.file.getErrors("WARN") + ); + this.statusbar_depricated.setNotices( + this.windowstate.project.getErrors("DEPR"), + this.windowstate.file.getErrors("DEPR") + ); + + _this.statusbar_run.el.hide(); + + if (pr.get_n_items() < 1) { + _this.statusbar_run.el.show(); + } + + } + public void initChildren () { + // this needs putting in a better place.. + this.windowstate = new WindowState(this); + + + + + + + + + } + public void show () { + + this.el.show(); + if (this.windowstate.file == null) { + this.windowstate.showPopoverFiles(this.open_projects_btn.el, null, false); + } + } + public void setTitle () { + if (_this.windowstate.project == null || + _this.windowstate.file == null + ) { + this.el.set_title("Select File"); + return; + } + _this.el.set_title( + _this.windowstate.project.name + + " - " + + _this.windowstate.file.relpath); + } + public void openNewWindow () { + + var w = new Xcls_MainWindow(); + w.ref(); + BuilderApplication.addWindow(w); + w.el.show(); + w.initChildren(); + w.windowstate.showPopoverFiles(w.open_projects_btn.el, _this.project, false); + + } + public class Xcls_headerbar : Object + { + public Gtk.HeaderBar el; + private Xcls_MainWindow _this; + + + // my vars (def) + public bool show_close_button; + public string title; + + // ctor + public Xcls_headerbar(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.headerbar = this; + this.el = new Gtk.HeaderBar(); + + // my vars (dec) + this.show_close_button = true; + this.title = "Application Builder"; + + // set gobject values + var child_1 = new Xcls_Box3( _this ); + child_1.ref(); + this.el.pack_start ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Box3 : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Box3(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + new Xcls_windowbtn( _this ); + this.el.append( _this.windowbtn.el ); + new Xcls_open_projects_btn( _this ); + this.el.append ( _this.open_projects_btn.el ); + } + + // user defined functions + } + public class Xcls_windowbtn : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + public Gee.ArrayList mitems; + + // ctor + public Xcls_windowbtn(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.windowbtn = this; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.margin_end = 4; + this.el.halign = Gtk.Align.START; + new Xcls_windowspopup( _this ); + var child_2 = new Xcls_Box10( _this ); + this.el.child = child_2.el; + + // init method + + { + this.mitems = new Gee.ArrayList(); + } + + //listeners + this.el.clicked.connect( ( ) => { + this.updateMenu(); + + _this.windowspopup.el.set_parent(this.el); + + _this.windowspopup.el.set_position(Gtk.PositionType.BOTTOM); + _this.windowspopup.el.popup(); + }); + } + + // user defined functions + public void updateMenu () { + foreach(var m in this.mitems) { + _this.popover_menu.el.remove(m); + } + this.mitems.clear(); + + BuilderApplication.windows.sort((a,b) => { + if (a.windowstate == null || + a.windowstate.file == null || + b.windowstate == null || + b.windowstate.file == null + ) { + return 0; + } + + var ap = a.windowstate.file.project.name; + var bp = b.windowstate.file.project.name; + + + + if (ap != bp) { + return ap.collate(bp); + } + var af = a.windowstate.file == null ? "" : a.windowstate.file.getTitle(); + var bf = b.windowstate.file == null ? "" : b.windowstate.file.getTitle(); + return af.collate(bf); + + }); + + var p = ""; + foreach(var w in BuilderApplication.windows) { + var wid = BuilderApplication.windows.index_of(w); + // fixme find a better way to display this. + if (w.windowstate == null || + w.windowstate.file == null || + _this.windowstate == null || + _this.windowstate.file == null + ) { + continue; + } + // should not happen... + if (w.windowstate.file.path == _this.windowstate.file.path) { + continue; + } + if (w.windowstate.file.project.name != p || p != "") { + var ms = new Gtk.Separator(Gtk.Orientation.HORIZONTAL); + _this.popover_menu.el.append(ms); + ms.show(); + this.mitems.add(ms); + } + + p = w.windowstate.file.project.name; + + + GLib.debug("add menuitem %s", w.windowstate.file.path); + + + + var m = new Gtk.Button.with_label( + w.windowstate.file.project.name + " : " + w.windowstate.file.relpath + ); + m.halign = Gtk.Align.START; + + + //w.windowstate.file.path); + m.clicked.connect(() => { + _this.windowspopup.el.hide(); + BuilderApplication.windows.get(wid).el.present(); + }); + _this.popover_menu.el.append(m); + //m.show(); + this.mitems.add(m); + } + } + } + public class Xcls_windowspopup : Object + { + public Gtk.Popover el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_windowspopup(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.windowspopup = this; + this.el = new Gtk.Popover(); + + // my vars (dec) + + // set gobject values + new Xcls_popover_menu( _this ); + this.el.set_child ( _this.popover_menu.el ); + } + + // user defined functions + } + public class Xcls_popover_menu : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_popover_menu(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.popover_menu = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Button7( _this ); + child_1.ref(); + this.el.append ( child_1.el ); + var child_2 = new Xcls_Separator9( _this ); + child_2.ref(); + this.el.append ( child_2.el ); + } + + // user defined functions + } + public class Xcls_Button7 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button7(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "New Window"; + var child_1 = new Xcls_ShortcutController8( _this ); + child_1.ref(); + this.el.add_controller( child_1.el ); + + //listeners + this.el.clicked.connect( ( ) => { + _this.windowspopup.el.hide(); + _this.windowstate.showPopoverFiles(_this.windowbtn.el, _this.project, true); + }); + } + + // user defined functions + } + public class Xcls_ShortcutController8 : Object + { + public Gtk.ShortcutController el; + private Xcls_MainWindow _this; + + + // my vars (def) - // ctor - public Xcls_ShortcutController8(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.ShortcutController(); + // ctor + public Xcls_ShortcutController8(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.ShortcutController(); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.scope = Gtk.ShortcutScope.GLOBAL; + // set gobject values + this.el.scope = Gtk.ShortcutScope.GLOBAL; - // init method + // init method - { - this.el.add_shortcut( - new Gtk.Shortcut( - new Gtk.KeyvalTrigger(Gdk.Key.N,Gdk.ModifierType.CONTROL_MASK), - new Gtk.SignalAction("clicked") - ) - ); - } - } + { + this.el.add_shortcut( + new Gtk.Shortcut( + new Gtk.KeyvalTrigger(Gdk.Key.N,Gdk.ModifierType.CONTROL_MASK), + new Gtk.SignalAction("clicked") + ) + ); + } + } - // user defined functions - } + // user defined functions + } - public class Xcls_Separator9 : Object - { - public Gtk.Separator el; - private Xcls_MainWindow _this; + public class Xcls_Separator9 : Object + { + public Gtk.Separator el; + private Xcls_MainWindow _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_Separator9(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL ); + // ctor + public Xcls_Separator9(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL ); - // my vars (dec) + // my vars (dec) - // set gobject values - } + // set gobject values + } - // user defined functions - } + // user defined functions + } - public class Xcls_Box10 : Object - { - public Gtk.Box el; - private Xcls_MainWindow _this; + public class Xcls_Box10 : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_Box10(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + // ctor + public Xcls_Box10(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - // my vars (dec) + // my vars (dec) - // set gobject values - var child_1 = new Xcls_Image11( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_Label12( _this ); - child_2.ref(); - this.el.append( child_2.el ); - } + // set gobject values + var child_1 = new Xcls_Image11( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_Label12( _this ); + child_2.ref(); + this.el.append( child_2.el ); + } - // user defined functions - } - public class Xcls_Image11 : Object - { - public Gtk.Image el; - private Xcls_MainWindow _this; + // user defined functions + } + public class Xcls_Image11 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_Image11(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.Image(); + // ctor + public Xcls_Image11(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.icon_name = "window-new"; - this.el.margin_start = 4; - } + // set gobject values + this.el.icon_name = "window-new"; + this.el.margin_start = 4; + } - // user defined functions - } + // user defined functions + } - public class Xcls_Label12 : Object - { - public Gtk.Label el; - private Xcls_MainWindow _this; + public class Xcls_Label12 : Object + { + public Gtk.Label el; + private Xcls_MainWindow _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_Label12(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.Label( "Windows (Add/List)" ); + // ctor + public Xcls_Label12(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Windows (Add/List)" ); - // my vars (dec) + // my vars (dec) - // set gobject values - } + // set gobject values + } - // user defined functions - } + // user defined functions + } - public class Xcls_open_projects_btn : Object - { - public Gtk.Button el; - private Xcls_MainWindow _this; + public class Xcls_open_projects_btn : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; - // my vars (def) - public bool always_show_image; + // my vars (def) + public bool always_show_image; - // ctor - public Xcls_open_projects_btn(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.open_projects_btn = this; - this.el = new Gtk.Button(); + // ctor + public Xcls_open_projects_btn(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.open_projects_btn = this; + this.el = new Gtk.Button(); - // my vars (dec) - this.always_show_image = true; + // my vars (dec) + this.always_show_image = true; - // set gobject values - this.el.icon_name = "system-file-manager"; - this.el.label = "Files / Projects"; + // set gobject values + this.el.icon_name = "system-file-manager"; + this.el.label = "Files / Projects"; - //listeners - this.el.clicked.connect( ( ) => { - _this.windowstate.showPopoverFiles(this.el, _this.project, false); - }); - } + //listeners + this.el.clicked.connect( ( ) => { + _this.windowstate.showPopoverFiles(this.el, _this.project, false); + }); + } - // user defined functions - } + // user defined functions + } - public class Xcls_vbox : Object - { - public Gtk.Box el; - private Xcls_MainWindow _this; + public class Xcls_vbox : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_vbox(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.vbox = this; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + // ctor + public Xcls_vbox(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.vbox = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.homogeneous = false; - this.el.vexpand = true; - new Xcls_mainpane( _this ); - this.el.append( _this.mainpane.el ); - var child_2 = new Xcls_Box23( _this ); - child_2.ref(); - this.el.append( child_2.el ); - } - - // user defined functions - } - public class Xcls_mainpane : Object - { - public Gtk.Paned el; - private Xcls_MainWindow _this; + // set gobject values + this.el.homogeneous = false; + this.el.vexpand = true; + new Xcls_mainpane( _this ); + this.el.append( _this.mainpane.el ); + var child_2 = new Xcls_Box23( _this ); + child_2.ref(); + this.el.append( child_2.el ); + } + + // user defined functions + } + public class Xcls_mainpane : Object + { + public Gtk.Paned el; + private Xcls_MainWindow _this; - // my vars (def) - public int lastWidth; - - // ctor - public Xcls_mainpane(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.mainpane = this; - this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL ); + // my vars (def) + public int lastWidth; + + // ctor + public Xcls_mainpane(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.mainpane = this; + this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL ); - // my vars (dec) - this.lastWidth = 0; - - // set gobject values - this.el.hexpand = true; - this.el.vexpand = true; - this.el.position = 400; - new Xcls_leftpane( _this ); - this.el.start_child = _this.leftpane.el; - var child_2 = new Xcls_Box20( _this ); - this.el.end_child = child_2.el; - - //listeners - this.el.accept_position.connect( ( ) => { - _this.windowstate.left_tree.onresize(); - return true; - }); - } - - // user defined functions - } - public class Xcls_leftpane : Object - { - public Gtk.Box el; - private Xcls_MainWindow _this; - - - // my vars (def) - - // ctor - public Xcls_leftpane(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.leftpane = this; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.hexpand = true; - this.el.vexpand = true; - new Xcls_editpane( _this ); - this.el.append( _this.editpane.el ); - } - - // user defined functions - } - public class Xcls_editpane : Object - { - public Gtk.Paned el; - private Xcls_MainWindow _this; + // my vars (dec) + this.lastWidth = 0; + + // set gobject values + this.el.hexpand = true; + this.el.vexpand = true; + this.el.position = 400; + new Xcls_leftpane( _this ); + this.el.start_child = _this.leftpane.el; + var child_2 = new Xcls_Box20( _this ); + this.el.end_child = child_2.el; + + //listeners + this.el.accept_position.connect( ( ) => { + _this.windowstate.left_tree.onresize(); + return true; + }); + } + + // user defined functions + } + public class Xcls_leftpane : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_leftpane(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.leftpane = this; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.hexpand = true; + this.el.vexpand = true; + new Xcls_editpane( _this ); + this.el.append( _this.editpane.el ); + } + + // user defined functions + } + public class Xcls_editpane : Object + { + public Gtk.Paned el; + private Xcls_MainWindow _this; - // my vars (def) - - // ctor - public Xcls_editpane(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.editpane = this; - this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL ); - - // my vars (dec) - - // set gobject values - new Xcls_tree( _this ); - this.el.start_child = _this.tree.el; - new Xcls_props( _this ); - this.el.end_child = _this.props.el; - - //listeners - this.el.accept_position.connect( ( ) => { - _this.windowstate.left_tree.onresize(); - return true; - }); - this.el.move_handle.connect( (scroll) => { - GLib.debug("Move handle"); - return true; - }); - } - - // user defined functions - } - public class Xcls_tree : Object - { - public Gtk.Box el; - private Xcls_MainWindow _this; - - - // my vars (def) - - // ctor - public Xcls_tree(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.tree = this; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.hexpand = true; - this.el.vexpand = true; - } - - // user defined functions - } - - public class Xcls_props : Object - { - public Gtk.Box el; - private Xcls_MainWindow _this; + // my vars (def) + + // ctor + public Xcls_editpane(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.editpane = this; + this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL ); + + // my vars (dec) + + // set gobject values + new Xcls_tree( _this ); + this.el.start_child = _this.tree.el; + new Xcls_props( _this ); + this.el.end_child = _this.props.el; + + //listeners + this.el.accept_position.connect( ( ) => { + _this.windowstate.left_tree.onresize(); + return true; + }); + this.el.move_handle.connect( (scroll) => { + GLib.debug("Move handle"); + return true; + }); + } + + // user defined functions + } + public class Xcls_tree : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_tree(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.tree = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.hexpand = true; + this.el.vexpand = true; + } + + // user defined functions + } + + public class Xcls_props : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_props(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.props = this; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + // ctor + public Xcls_props(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.props = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.hexpand = true; - this.el.vexpand = true; - } + // set gobject values + this.el.hexpand = true; + this.el.vexpand = true; + } - // user defined functions - } + // user defined functions + } - public class Xcls_Box20 : Object - { - public Gtk.Box el; - private Xcls_MainWindow _this; + public class Xcls_Box20 : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_Box20(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + // ctor + public Xcls_Box20(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.hexpand = true; - this.el.vexpand = true; - new Xcls_rooviewbox( _this ); - this.el.append( _this.rooviewbox.el ); - new Xcls_codeeditviewbox( _this ); - this.el.append( _this.codeeditviewbox.el ); - } - - // user defined functions - } - public class Xcls_rooviewbox : Object - { - public Gtk.Box el; - private Xcls_MainWindow _this; - - - // my vars (def) - - // ctor - public Xcls_rooviewbox(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.rooviewbox = this; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + // set gobject values + this.el.hexpand = true; + this.el.vexpand = true; + new Xcls_rooviewbox( _this ); + this.el.append( _this.rooviewbox.el ); + new Xcls_codeeditviewbox( _this ); + this.el.append( _this.codeeditviewbox.el ); + } + + // user defined functions + } + public class Xcls_rooviewbox : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_rooviewbox(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.rooviewbox = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.hexpand = true; - this.el.vexpand = true; - } + // set gobject values + this.el.hexpand = true; + this.el.vexpand = true; + } - // user defined functions - } + // user defined functions + } - public class Xcls_codeeditviewbox : Object - { - public Gtk.Box el; - private Xcls_MainWindow _this; - - - // my vars (def) - - // ctor - public Xcls_codeeditviewbox(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.codeeditviewbox = this; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + public class Xcls_codeeditviewbox : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_codeeditviewbox(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.codeeditviewbox = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.hexpand = true; - this.el.vexpand = true; - } + // set gobject values + this.el.hexpand = true; + this.el.vexpand = true; + } + + // user defined functions + } - // user defined functions - } + public class Xcls_Box23 : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Box23(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + this.el.vexpand = false; + var child_1 = new Xcls_Button24( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_Button25( _this ); + child_2.ref(); + this.el.append( child_2.el ); + var child_3 = new Xcls_MenuButton26( _this ); + child_3.ref(); + this.el.append( child_3.el ); + var child_4 = new Xcls_Label31( _this ); + child_4.ref(); + this.el.append( child_4.el ); + new Xcls_statusbar( _this ); + this.el.append( _this.statusbar.el ); + var child_6 = new Xcls_Box33( _this ); + child_6.ref(); + this.el.append( child_6.el ); + new Xcls_statusbar_compile_spinner( _this ); + this.el.append( _this.statusbar_compile_spinner.el ); + new Xcls_statusbar_compile_icon( _this ); + this.el.append( _this.statusbar_compile_icon.el ); + } + + // user defined functions + } + public class Xcls_Button24 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + public bool always_show_image; + + // ctor + public Xcls_Button24(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + this.always_show_image = true; + + // set gobject values + this.el.icon_name = "emblem-system"; + this.el.tooltip_text = "Project Details"; + this.el.label = "Edit Project Settings"; + + //listeners + this.el.clicked.connect( ( ) => { + + _this.windowstate.projectPopoverShow(_this.el, null, null); + + + }); + } + + // user defined functions + } + + public class Xcls_Button25 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + public bool always_show_image; + + // ctor + public Xcls_Button25(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + this.always_show_image = true; + + // set gobject values + this.el.icon_name = "document-properties"; + this.el.tooltip_text = "File Details"; + this.el.label = "Edit File Properties"; + + //listeners + this.el.clicked.connect( ( ) => { + + // create a new file in project.. + if (_this.project == null || _this.windowstate.file == null) { + return ; + } + _this.windowstate.file_details.show( + _this.windowstate.file, _this.el, false + ); + + return ; + + + }); + } + + // user defined functions + } + + public class Xcls_MenuButton26 : Object + { + public Gtk.MenuButton el; + private Xcls_MainWindow _this; + + + // my vars (def) + public bool always_show_image; + + // ctor + public Xcls_MenuButton26(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.MenuButton(); + + // my vars (dec) + this.always_show_image = true; + + // set gobject values + this.el.icon_name = "dialog-information"; + this.el.label = "About"; + new Xcls_topbarmenu( _this ); + this.el.popover = _this.topbarmenu.el; + } + + // user defined functions + } + public class Xcls_topbarmenu : Object + { + public Gtk.PopoverMenu el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_topbarmenu(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.topbarmenu = this; + this.el = new Gtk.PopoverMenu.from_model(null); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Box28( _this ); + child_1.ref(); + this.el.set_child ( child_1.el ); - public class Xcls_Box23 : Object - { - public Gtk.Box el; - private Xcls_MainWindow _this; - - - // my vars (def) - - // ctor - public Xcls_Box23(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.homogeneous = false; - this.el.vexpand = false; - var child_1 = new Xcls_Button24( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_Button25( _this ); - child_2.ref(); - this.el.append( child_2.el ); - var child_3 = new Xcls_MenuButton26( _this ); - child_3.ref(); - this.el.append( child_3.el ); - var child_4 = new Xcls_Label31( _this ); - child_4.ref(); - this.el.append( child_4.el ); - new Xcls_statusbar( _this ); - this.el.append( _this.statusbar.el ); - var child_6 = new Xcls_Box33( _this ); - child_6.ref(); - this.el.append( child_6.el ); - new Xcls_statusbar_compile_spinner( _this ); - this.el.append( _this.statusbar_compile_spinner.el ); - } - - // user defined functions - } - public class Xcls_Button24 : Object - { - public Gtk.Button el; - private Xcls_MainWindow _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_Button24(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.icon_name = "emblem-system"; - this.el.tooltip_text = "Project Details"; - this.el.label = "Edit Project Settings"; - - //listeners - this.el.clicked.connect( ( ) => { - - _this.windowstate.projectPopoverShow(_this.el, null, null); - - - }); - } - - // user defined functions - } - - public class Xcls_Button25 : Object - { - public Gtk.Button el; - private Xcls_MainWindow _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_Button25(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.icon_name = "document-properties"; - this.el.tooltip_text = "File Details"; - this.el.label = "Edit File Properties"; - - //listeners - this.el.clicked.connect( ( ) => { - - // create a new file in project.. - if (_this.project == null || _this.windowstate.file == null) { - return ; - } - _this.windowstate.file_details.show( - _this.windowstate.file, _this.el, false - ); - - return ; - - - }); - } - - // user defined functions - } - - public class Xcls_MenuButton26 : Object - { - public Gtk.MenuButton el; - private Xcls_MainWindow _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_MenuButton26(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.MenuButton(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.icon_name = "dialog-information"; - this.el.label = "About"; - new Xcls_topbarmenu( _this ); - this.el.popover = _this.topbarmenu.el; - } - - // user defined functions - } - public class Xcls_topbarmenu : Object - { - public Gtk.PopoverMenu el; - private Xcls_MainWindow _this; - - - // my vars (def) - - // ctor - public Xcls_topbarmenu(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.topbarmenu = this; - this.el = new Gtk.PopoverMenu.from_model(null); - - // my vars (dec) + // init method - // set gobject values - var child_1 = new Xcls_Box28( _this ); - child_1.ref(); - this.el.set_child ( child_1.el ); + { + // this.el.show(); + } + } - // init method + // user defined functions + } + public class Xcls_Box28 : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; - { - // this.el.show(); - } - } - // user defined functions - } - public class Xcls_Box28 : Object - { - public Gtk.Box el; - private Xcls_MainWindow _this; + // my vars (def) + // ctor + public Xcls_Box28(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - // my vars (def) + // my vars (dec) - // ctor - public Xcls_Box28(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + // set gobject values + var child_1 = new Xcls_Button29( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_Button30( _this ); + child_2.ref(); + this.el.append( child_2.el ); + } - // my vars (dec) + // user defined functions + } + public class Xcls_Button29 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; - // set gobject values - var child_1 = new Xcls_Button29( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_Button30( _this ); - child_2.ref(); - this.el.append( child_2.el ); - } - // user defined functions - } - public class Xcls_Button29 : Object - { - public Gtk.Button el; - private Xcls_MainWindow _this; + // my vars (def) + // ctor + public Xcls_Button29(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); - // my vars (def) + // my vars (dec) - // ctor - public Xcls_Button29(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); + // set gobject values + this.el.label = "Download updated Resources"; - // my vars (dec) + //listeners + this.el.activate.connect( ( ) => { + Resources.singleton().fetchStart(); + }); + } - // set gobject values - this.el.label = "Download updated Resources"; + // user defined functions + } - //listeners - this.el.activate.connect( ( ) => { - Resources.singleton().fetchStart(); - }); - } + public class Xcls_Button30 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; - // user defined functions - } - public class Xcls_Button30 : Object - { - public Gtk.Button el; - private Xcls_MainWindow _this; + // my vars (def) + // ctor + public Xcls_Button30(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); - // my vars (def) + // my vars (dec) - // ctor - public Xcls_Button30(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); + // set gobject values + this.el.label = "About the Builder"; - // my vars (dec) + //listeners + this.el.clicked.connect( () => { + About.singleton().el.show(); + }); + } - // set gobject values - this.el.label = "About the Builder"; + // user defined functions + } - //listeners - this.el.clicked.connect( () => { - About.singleton().el.show(); - }); - } - // user defined functions - } + public class Xcls_Label31 : Object + { + public Gtk.Label el; + private Xcls_MainWindow _this; - public class Xcls_Label31 : Object - { - public Gtk.Label el; - private Xcls_MainWindow _this; + // my vars (def) + // ctor + public Xcls_Label31(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Label( " " ); - // my vars (def) + // my vars (dec) - // ctor - public Xcls_Label31(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.Label( " " ); + // set gobject values + this.el.hexpand = true; + } - // my vars (dec) + // user defined functions + } - // set gobject values - this.el.hexpand = true; - } + public class Xcls_statusbar : Object + { + public Gtk.ProgressBar el; + private Xcls_MainWindow _this; - // user defined functions - } - public class Xcls_statusbar : Object - { - public Gtk.ProgressBar el; - private Xcls_MainWindow _this; + // my vars (def) + public ulong handler_id; + // ctor + public Xcls_statusbar(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.statusbar = this; + this.el = new Gtk.ProgressBar(); - // my vars (def) - public ulong handler_id; + // my vars (dec) + this.handler_id = -1; - // ctor - public Xcls_statusbar(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.statusbar = this; - this.el = new Gtk.ProgressBar(); + // set gobject values + this.el.show_text = true; - // my vars (dec) - this.handler_id = -1; + // init method - // set gobject values - this.el.show_text = true; - - // init method - - { - this.handler_id = Resources.singleton().updateProgress.connect((pos,total) => { - if (pos < 1) { - this.el.hide(); - _this.mainpane.el.set_sensitive(true); - - return; - } - _this.mainpane.el.set_sensitive(false); - this.el.show(); - this.el.set_fraction ((1.0f * pos) / (1.0f * total)); - this.el.set_text("Fetching Resource : %s/%s".printf(pos.to_string(), total.to_string())); - - }); - } - } - - // user defined functions - } - - public class Xcls_Box33 : Object - { - public Gtk.Box el; - private Xcls_MainWindow _this; - - - // my vars (def) - - // ctor - public Xcls_Box33(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - - // my vars (dec) - - // set gobject values - new Xcls_statusbar_compilestatus_label( _this ); - this.el.append( _this.statusbar_compilestatus_label.el ); - new Xcls_statusbar_errors( _this ); - this.el.append( _this.statusbar_errors.el ); - new Xcls_statusbar_warnings( _this ); - this.el.append( _this.statusbar_warnings.el ); - new Xcls_statusbar_depricated( _this ); - this.el.append( _this.statusbar_depricated.el ); - new Xcls_statusbar_run( _this ); - this.el.append( _this.statusbar_run.el ); - } - - // user defined functions - } - public class Xcls_statusbar_compilestatus_label : Object - { - public Gtk.Label el; - private Xcls_MainWindow _this; - - - // my vars (def) - - // ctor - public Xcls_statusbar_compilestatus_label(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.statusbar_compilestatus_label = this; - this.el = new Gtk.Label( "Compile Status:" ); - - // my vars (dec) - - // set gobject values - this.el.margin_end = 4; - this.el.margin_start = 4; - } - - // user defined functions - } - - public class Xcls_statusbar_errors : Object - { - public Gtk.Button el; - private Xcls_MainWindow _this; - - - // my vars (def) - public Xcls_ValaCompileErrors popup; - - // ctor - public Xcls_statusbar_errors(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.statusbar_errors = this; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.icon_name = "dialog-error"; - this.el.label = "0 Errors"; - - //listeners - this.el.clicked.connect( () => { - - if (this.popup == null) { - return; - } - - this.popup.show(); - - }); - } - - // user defined functions - public void setNotices (GLib.ListStore nots, GLib.ListStore fe ) { - - if (nots.get_n_items() < 1 ) { - this.el.hide(); - if (this.popup != null) { - this.popup.el.hide(); - } - return; - } - - this.el.show(); - this.el.label = "%d/%d Errors".printf((int)fe.get_n_items(),(int)nots.get_n_items()); - - - - if (this.popup == null) { - this.popup = new Xcls_ValaCompileErrors(); - this.popup.window = _this; - // this.popup.el.set_transient_for( _this.el ); - this.popup.el.set_parent(this.el); - } - this.popup.updateNotices(nots); - - } - } - - public class Xcls_statusbar_warnings : Object - { - public Gtk.Button el; - private Xcls_MainWindow _this; - - - // my vars (def) - public Xcls_ValaCompileErrors popup; - - // ctor - public Xcls_statusbar_warnings(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.statusbar_warnings = this; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.icon_name = "dialog-warning"; - this.el.label = "0 Warnings"; - - //listeners - this.el.clicked.connect( () => { - - if (this.popup == null) { - return; - } - - this.popup.show(); - return; - }); - } - - // user defined functions - public void setNotices (GLib.ListStore nots, GLib.ListStore fe ) { - - if (nots.get_n_items() < 1 ) { - this.el.hide(); - if (this.popup != null) { - this.popup.el.hide(); - } - return; - } - - this.el.show(); - this.el.label = "%d/%d Warnings".printf((int)fe.get_n_items(),(int)nots.get_n_items()); - - - - if (this.popup == null) { - this.popup = new Xcls_ValaCompileErrors(); - this.popup.window = _this; - // this.popup.el.set_transient_for( _this.el ); - this.popup.el.set_parent(this.el); - } - this.popup.updateNotices(nots); - - } - } - - public class Xcls_statusbar_depricated : Object - { - public Gtk.Button el; - private Xcls_MainWindow _this; - - - // my vars (def) - public Xcls_ValaCompileErrors popup; - public GLib.ListStore notices; - - // ctor - public Xcls_statusbar_depricated(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.statusbar_depricated = this; - this.el = new Gtk.Button(); - - // my vars (dec) - this.notices = null; - - // set gobject values - this.el.icon_name = "dialog-information"; - this.el.label = "0 Depricated"; - - //listeners - this.el.clicked.connect( () => { - - if (this.popup == null) { - return; - } - - this.popup.show(); - - }); - } - - // user defined functions - public void setNotices (GLib.ListStore nots, GLib.ListStore fe ) { - - if (nots.get_n_items() < 1 ) { - this.el.hide(); - if (this.popup != null) { - this.popup.el.hide(); - } - return; - } - - this.el.show(); - this.el.label = "%d/%d Depricated".printf((int)fe.get_n_items(),(int)nots.get_n_items()); - - - - if (this.popup == null) { - this.popup = new Xcls_ValaCompileErrors(); - this.popup.window = _this; - // this.popup.el.set_transient_for( _this.el ); - this.popup.el.set_parent(this.el); - } - this.popup.updateNotices(nots); - - } - } - - public class Xcls_statusbar_run : Object - { - public Gtk.Button el; - private Xcls_MainWindow _this; - - - // my vars (def) - public Xcls_ValaCompileErrors popup; - - // ctor - public Xcls_statusbar_run(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.statusbar_run = this; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.icon_name = "media-playback-start"; - this.el.label = "Run"; - - //listeners - this.el.clicked.connect( () => { - - if (_this.windowstate.file == null) { - return; - } - if (_this.statusbar_compile_spinner.el.spinning) { - _this.windowstate.compile_results.el.set_parent(this.el); - _this.windowstate.compile_results.el.show(); // show currently running. - return; - } - - var req = new Palete.ValaCompileRequest( - Palete.ValaCompileRequestType.RUN, - _this.windowstate.file, - null, - null, - "" - ); - req.run(); - - _this.windowstate.compile_results.el.set_parent(this.el); - _this.windowstate.compile_results.show(this.el,true); - - }); - } - - // user defined functions - } - - - public class Xcls_statusbar_compile_spinner : Object - { - public Gtk.Spinner el; - private Xcls_MainWindow _this; - - - // my vars (def) - - // ctor - public Xcls_statusbar_compile_spinner(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.statusbar_compile_spinner = this; - this.el = new Gtk.Spinner(); - - // my vars (dec) - - // set gobject values - this.el.margin_end = 4; - this.el.margin_start = 4; - this.el.tooltip_text = "Compiling"; - } - - // user defined functions - public void start () { - this.el.show(); - this.el.start(); - - - } - public void stop () { - this.el.stop(); - this.el.hide(); - - } - } - - - - } + { + this.handler_id = Resources.singleton().updateProgress.connect((pos,total) => { + if (pos < 1) { + this.el.hide(); + _this.mainpane.el.set_sensitive(true); + + return; + } + _this.mainpane.el.set_sensitive(false); + this.el.show(); + this.el.set_fraction ((1.0f * pos) / (1.0f * total)); + this.el.set_text("Fetching Resource : %s/%s".printf(pos.to_string(), total.to_string())); + + }); + } + } + + // user defined functions + } + + public class Xcls_Box33 : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Box33(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + new Xcls_statusbar_compilestatus_label( _this ); + this.el.append( _this.statusbar_compilestatus_label.el ); + new Xcls_statusbar_errors( _this ); + this.el.append( _this.statusbar_errors.el ); + new Xcls_statusbar_warnings( _this ); + this.el.append( _this.statusbar_warnings.el ); + new Xcls_statusbar_depricated( _this ); + this.el.append( _this.statusbar_depricated.el ); + new Xcls_statusbar_run( _this ); + this.el.append( _this.statusbar_run.el ); + } + + // user defined functions + } + public class Xcls_statusbar_compilestatus_label : Object + { + public Gtk.Label el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_statusbar_compilestatus_label(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.statusbar_compilestatus_label = this; + this.el = new Gtk.Label( "Compile Status:" ); + + // my vars (dec) + + // set gobject values + this.el.margin_end = 4; + this.el.margin_start = 4; + } + + // user defined functions + } + + public class Xcls_statusbar_errors : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + public Xcls_ValaCompileErrors popup; + + // ctor + public Xcls_statusbar_errors(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.statusbar_errors = this; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "dialog-error"; + this.el.label = "0 Errors"; + + //listeners + this.el.clicked.connect( () => { + + if (this.popup == null) { + return; + } + + this.popup.show(); + + }); + } + + // user defined functions + public void setNotices (GLib.ListStore nots, GLib.ListStore fe ) { + BuilderApplication.showSpinner(""); + if (nots.get_n_items() < 1 ) { + this.el.hide(); + if (this.popup != null) { + this.popup.el.hide(); + } + return; + } + + this.el.show(); + this.el.label = "%d/%d Errors".printf((int)fe.get_n_items(),(int)nots.get_n_items()); + + + + if (this.popup == null) { + this.popup = new Xcls_ValaCompileErrors(); + this.popup.window = _this; + // this.popup.el.set_transient_for( _this.el ); + this.popup.el.set_parent(this.el); + } + + this.popup.updateNotices(nots); + + } + } + + public class Xcls_statusbar_warnings : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + public Xcls_ValaCompileErrors popup; + + // ctor + public Xcls_statusbar_warnings(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.statusbar_warnings = this; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "dialog-warning"; + this.el.label = "0 Warnings"; + + //listeners + this.el.clicked.connect( () => { + + if (this.popup == null) { + return; + } + + this.popup.show(); + return; + }); + } + + // user defined functions + public void setNotices (GLib.ListStore nots, GLib.ListStore fe ) { + + if (nots.get_n_items() < 1 ) { + this.el.hide(); + if (this.popup != null) { + this.popup.el.hide(); + } + return; + } + + this.el.show(); + this.el.label = "%d/%d Warnings".printf((int)fe.get_n_items(),(int)nots.get_n_items()); + + + + if (this.popup == null) { + this.popup = new Xcls_ValaCompileErrors(); + this.popup.window = _this; + // this.popup.el.set_transient_for( _this.el ); + this.popup.el.set_parent(this.el); + } + this.popup.updateNotices(nots); + + } + } + + public class Xcls_statusbar_depricated : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + public Xcls_ValaCompileErrors popup; + public GLib.ListStore notices; + + // ctor + public Xcls_statusbar_depricated(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.statusbar_depricated = this; + this.el = new Gtk.Button(); + + // my vars (dec) + this.notices = null; + + // set gobject values + this.el.icon_name = "dialog-information"; + this.el.label = "0 Depricated"; + + //listeners + this.el.clicked.connect( () => { + + if (this.popup == null) { + return; + } + + this.popup.show(); + + }); + } + + // user defined functions + public void setNotices (GLib.ListStore nots, GLib.ListStore fe ) { + + if (nots.get_n_items() < 1 ) { + this.el.hide(); + if (this.popup != null) { + this.popup.el.hide(); + } + return; + } + + this.el.show(); + this.el.label = "%d/%d Depricated".printf((int)fe.get_n_items(),(int)nots.get_n_items()); + + + + if (this.popup == null) { + this.popup = new Xcls_ValaCompileErrors(); + this.popup.window = _this; + // this.popup.el.set_transient_for( _this.el ); + this.popup.el.set_parent(this.el); + } + this.popup.updateNotices(nots); + + } + } + + public class Xcls_statusbar_run : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + public Xcls_ValaCompileErrors popup; + public Palete.ValaCompileRequest? last_request; + + // ctor + public Xcls_statusbar_run(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.statusbar_run = this; + this.el = new Gtk.Button(); + + // my vars (dec) + this.last_request = null; + + // set gobject values + this.el.icon_name = "media-playback-start"; + this.el.label = "Run"; + this.el.visible = false; + + //listeners + this.el.clicked.connect( () => { + + if (_this.windowstate.file == null) { + return; + } + if (_this.statusbar_compile_spinner.el.spinning) { + _this.windowstate.compile_results.el.set_parent(this.el); + _this.windowstate.compile_results.el.show(); // show currently running. + return; + } + + if (this.last_request != null) { + this.last_request.cancel(); + if (this.last_request.terminal_pid > 0) { + this.last_request.killChildren(this.last_request.terminal_pid); + } + } + + this.last_request= new Palete.ValaCompileRequest( + Palete.ValaCompileRequestType.RUN, + _this.windowstate.file, + null, + null, + "" + ); + this.last_request.run(); + + _this.windowstate.compile_results.el.set_parent(this.el); + _this.windowstate.compile_results.show(this.el,true); + + }); + } + + // user defined functions + } + + + public class Xcls_statusbar_compile_spinner : Object + { + public Gtk.Spinner el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_statusbar_compile_spinner(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.statusbar_compile_spinner = this; + this.el = new Gtk.Spinner(); + + // my vars (dec) + + // set gobject values + this.el.margin_end = 4; + this.el.margin_start = 4; + this.el.tooltip_text = "Compiling"; + } + + // user defined functions + public void start (string icon, string tooltip) { + + if (icon == "spinner") { + this.el.show(); + this.el.start(); + this.el.tooltip_text = tooltip; + _this.statusbar_compile_icon.el.hide(); + } else { + this.el.hide(); + // GLib.debug("set status icon %s, %s", icon, tooltip); + _this.statusbar_compile_icon.el.tooltip_text = tooltip; + _this.statusbar_compile_icon.el.icon_name = icon; + _this.statusbar_compile_icon.el.show(); + } + + + } + public void stop () { + this.el.stop(); + this.el.hide(); + _this.statusbar_compile_icon.el.hide(); + } + } + + public class Xcls_statusbar_compile_icon : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_statusbar_compile_icon(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.statusbar_compile_icon = this; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.margin_end = 4; + this.el.margin_start = 4; + this.el.icon_size = Gtk.IconSize.NORMAL; + } + + // user defined functions + } + + + +} diff --git a/src/Builder4/ValaProjectSettingsPopover.bjs b/src/Builder4/ValaProjectSettingsPopover.bjs index 923c38020..d6e46327f 100644 --- a/src/Builder4/ValaProjectSettingsPopover.bjs +++ b/src/Builder4/ValaProjectSettingsPopover.bjs @@ -8,6 +8,7 @@ "Project.Gtk project" : "null", "Project.GtkValaSettings? selected_target" : "null", "Xcls_MainWindow window" : "null", + "bool cg_loading" : false, "bool done" : false, "bool modal" : true, "items" : [ @@ -163,7 +164,7 @@ "bind" : [ "(listitem) => {", " ", - "\tvar lbl = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();", + "\tvar lbl = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();", "\t ", "\tvar item = (Project.VapiSelection) ((Gtk.ListItem)listitem).get_item();", "", @@ -508,11 +509,11 @@ "\tvar jr = (JsRender.JsRender) lr.get_item();", "\t//GLib.debug(\"change %s to %s\", lbl.label, np.name);", "", - "\t", + "\t//btn.active = jr.compile_group_selected;", "\t ", " \tjr.bind_property(\"compile_group_selected\",", " btn, \"active\",", - " GLib.BindingFlags.SYNC_CREATE); ", + " GLib.BindingFlags.BIDIRECTIONAL); ", " \t// bind image...", " \t", "}" @@ -526,7 +527,9 @@ "\t((Gtk.ListItem)listitem).set_child(btn);", "\t", "\tbtn.toggled.connect(() => {", - "\t ", + "\t \tif (_this.cg_loading) {", + "\t \t\treturn;", + " \t\t}", "\t\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();", "\t\tvar jr = (JsRender.JsRender) lr.get_item();", "\t\tjr.compile_group_selected = btn.active;", @@ -700,20 +703,21 @@ "\t ", "\t GLib.debug(\"loading dirs into project list\");", "\t cg.loading_ui = true;", - "\t ", + "\t _this.cg_loading = true;", "", "\t _this.treeview.el.set_model(new Gtk.SingleSelection(null));", "\t _this.project.loadDirsIntoStore(_this.treemodel.el);", " \t _this.treeview.el.set_model(_this.treeselmodel.el);", "\t ", "\t cg.loading_ui = false;", + "\t ", + "\t _this.cg_loading = false;", "\t GLib.debug(\"Set name to %s\", cg.name);", "\t ", " \t_this.build_name.el.buffer.set_text(cg.name.data);", " ", " ", "\t_this.build_execute_args.el.buffer.set_text( cg.execute_args.data );", - "", " ", "}", "" @@ -731,7 +735,7 @@ "bind" : [ "(listitem) => {", " ", - "\tvar lbl = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();", + "\tvar lbl = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();", "\t ", "\tvar item = (Project.GtkValaSettings) ((Gtk.ListItem)listitem).get_item();", "", diff --git a/src/Builder4/ValaProjectSettingsPopover.vala b/src/Builder4/ValaProjectSettingsPopover.vala index 1cbe87a90..a3b6dadad 100644 --- a/src/Builder4/ValaProjectSettingsPopover.vala +++ b/src/Builder4/ValaProjectSettingsPopover.vala @@ -1,1116 +1,1118 @@ - static ValaProjectSettingsPopover _ValaProjectSettingsPopover; - - public class ValaProjectSettingsPopover : Object - { - public Gtk.Window el; - private ValaProjectSettingsPopover _this; - - public static ValaProjectSettingsPopover singleton() - { - if (_ValaProjectSettingsPopover == null) { - _ValaProjectSettingsPopover= new ValaProjectSettingsPopover(); - } - return _ValaProjectSettingsPopover; - } - public Xcls_notebook notebook; - public Xcls_label_global label_global; - public Xcls_label_targets label_targets; - public Xcls_compile_flags compile_flags; - public Xcls_vapi_scroll vapi_scroll; - public Xcls_vapimodel vapimodel; - public Xcls_vapi_filter vapi_filter; - public Xcls_vapi_search vapi_search; - public Xcls_set_vbox set_vbox; - public Xcls_treeview treeview; - public Xcls_treeselmodel treeselmodel; - public Xcls_treelistsort treelistsort; - public Xcls_treelistmodel treelistmodel; - public Xcls_treemodel treemodel; - public Xcls_name name; - public Xcls_target_sel target_sel; - public Xcls_target_model target_model; - public Xcls_set_vboxb set_vboxb; - public Xcls_build_name build_name; - public Xcls_build_execute_args build_execute_args; - public Xcls_save_btn save_btn; - - // my vars (def) - public Project.Callback doneObj; - public Xcls_MainWindow window; - public Project.GtkValaSettings? selected_target; - public uint border_width; - public bool done; - public Project.Gtk project; - - // ctor - public ValaProjectSettingsPopover() - { - _this = this; - this.el = new Gtk.Window(); - - // my vars (dec) - this.doneObj = null; - this.window = null; - this.selected_target = null; - this.border_width = 0; - this.done = false; - this.project = null; - - // set gobject values - this.el.modal = true; - var child_1 = new Xcls_HeaderBar2( _this ); - this.el.titlebar = child_1.el; - var child_2 = new Xcls_Box4( _this ); - child_2.ref(); - this.el.set_child ( child_2.el ); - - //listeners - this.el.close_request.connect( ( ) => { - if (!this.done) { - return true; - } - return false; - }); - this.el.hide.connect( () => { - if (!this.done) { - _this.el.show(); - - } - }); - } - - // user defined functions - public void show (Gtk.Window pwin, Project.Gtk project, Project.Callback? doneObj) { - - //print("ValaProjectSettings show\n"); - this.doneObj = doneObj; - this.project= project; - - this.compile_flags.el.buffer.set_text( - project.compile_flags.data - ); - - project.loadVapiIntoStore(_this.vapimodel.el); - GLib.Timeout.add(500, () => { - this.vapi_scroll.el.vadjustment.value = 0; - return false; - }); - - - - project.loadTargetsIntoStore(this.target_model.el); - - _this.target_sel.el.selected = Gtk.INVALID_LIST_POSITION; - _this.target_sel.selectTarget(null); - // Gtk.Allocation rect; - //btn.get_allocation(out rect); - // this.el.set_pointing_to(rect); - this.el.application = pwin.application; // ??? make it modal? - this.el.set_transient_for(pwin); - - // window + header? - // print("SHOWALL - POPIP\n"); - this.el.set_size_request(800,800); - this.el.show(); - this.notebook.el.page = 0; // first page. - - //this.view.el.grab_focus(); - - } - public void save () { - this.project.save(); - } - public class Xcls_HeaderBar2 : Object - { - public Gtk.HeaderBar el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_HeaderBar2(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.HeaderBar(); - - // my vars (dec) - - // set gobject values - var child_1 = new Xcls_Label3( _this ); - this.el.title_widget = child_1.el; - } - - // user defined functions - } - public class Xcls_Label3 : Object - { - public Gtk.Label el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_Label3(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.Label( "Change Vala Compile settings" ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - - public class Xcls_Box4 : Object - { - public Gtk.Box el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_Box4(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.hexpand = true; - this.el.vexpand = true; - new Xcls_notebook( _this ); - this.el.append( _this.notebook.el ); - var child_2 = new Xcls_Box58( _this ); - child_2.ref(); - this.el.append( child_2.el ); - } - - // user defined functions - } - public class Xcls_notebook : Object - { - public Gtk.Notebook el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_notebook(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.notebook = this; - this.el = new Gtk.Notebook(); - - // my vars (dec) - - // set gobject values - this.el.vexpand = true; - new Xcls_label_global( _this ); - new Xcls_label_targets( _this ); - var child_3 = new Xcls_Box8( _this ); - child_3.ref(); - this.el.append_page ( child_3.el , _this.label_global.el ); - var child_4 = new Xcls_Paned26( _this ); - child_4.ref(); - this.el.append_page ( child_4.el , _this.label_targets.el ); - } +static ValaProjectSettingsPopover _ValaProjectSettingsPopover; - // user defined functions - } - public class Xcls_label_global : Object - { - public Gtk.Label el; - private ValaProjectSettingsPopover _this; +public class ValaProjectSettingsPopover : Object +{ + public Gtk.Window el; + private ValaProjectSettingsPopover _this; + public static ValaProjectSettingsPopover singleton() + { + if (_ValaProjectSettingsPopover == null) { + _ValaProjectSettingsPopover= new ValaProjectSettingsPopover(); + } + return _ValaProjectSettingsPopover; + } + public Xcls_notebook notebook; + public Xcls_label_global label_global; + public Xcls_label_targets label_targets; + public Xcls_compile_flags compile_flags; + public Xcls_vapi_scroll vapi_scroll; + public Xcls_vapimodel vapimodel; + public Xcls_vapi_filter vapi_filter; + public Xcls_vapi_search vapi_search; + public Xcls_set_vbox set_vbox; + public Xcls_treeview treeview; + public Xcls_treeselmodel treeselmodel; + public Xcls_treelistsort treelistsort; + public Xcls_treelistmodel treelistmodel; + public Xcls_treemodel treemodel; + public Xcls_name name; + public Xcls_target_sel target_sel; + public Xcls_target_model target_model; + public Xcls_set_vboxb set_vboxb; + public Xcls_build_name build_name; + public Xcls_build_execute_args build_execute_args; + public Xcls_save_btn save_btn; + + // my vars (def) + public Project.Callback doneObj; + public bool cg_loading; + public Xcls_MainWindow window; + public Project.GtkValaSettings? selected_target; + public uint border_width; + public bool done; + public Project.Gtk project; + + // ctor + public ValaProjectSettingsPopover() + { + _this = this; + this.el = new Gtk.Window(); + + // my vars (dec) + this.doneObj = null; + this.cg_loading = false; + this.window = null; + this.selected_target = null; + this.border_width = 0; + this.done = false; + this.project = null; + + // set gobject values + this.el.modal = true; + var child_1 = new Xcls_HeaderBar2( _this ); + this.el.titlebar = child_1.el; + var child_2 = new Xcls_Box4( _this ); + child_2.ref(); + this.el.set_child ( child_2.el ); + + //listeners + this.el.close_request.connect( ( ) => { + if (!this.done) { + return true; + } + return false; + }); + this.el.hide.connect( () => { + if (!this.done) { + _this.el.show(); + + } + }); + } - // my vars (def) + // user defined functions + public void show (Gtk.Window pwin, Project.Gtk project, Project.Callback? doneObj) { + + //print("ValaProjectSettings show\n"); + this.doneObj = doneObj; + this.project= project; + + this.compile_flags.el.buffer.set_text( + project.compile_flags.data + ); + + project.loadVapiIntoStore(_this.vapimodel.el); + GLib.Timeout.add(500, () => { + this.vapi_scroll.el.vadjustment.value = 0; + return false; + }); + + + + project.loadTargetsIntoStore(this.target_model.el); + + _this.target_sel.el.selected = Gtk.INVALID_LIST_POSITION; + _this.target_sel.selectTarget(null); + // Gtk.Allocation rect; + //btn.get_allocation(out rect); + // this.el.set_pointing_to(rect); + this.el.application = pwin.application; // ??? make it modal? + this.el.set_transient_for(pwin); + + // window + header? + // print("SHOWALL - POPIP\n"); + this.el.set_size_request(800,800); + this.el.show(); + this.notebook.el.page = 0; // first page. + + //this.view.el.grab_focus(); + + } + public void save () { + this.project.save(); + } + public class Xcls_HeaderBar2 : Object + { + public Gtk.HeaderBar el; + private ValaProjectSettingsPopover _this; - // ctor - public Xcls_label_global(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.label_global = this; - this.el = new Gtk.Label( "Global" ); - // my vars (dec) + // my vars (def) - // set gobject values - } + // ctor + public Xcls_HeaderBar2(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.HeaderBar(); - // user defined functions - } + // my vars (dec) - public class Xcls_label_targets : Object - { - public Gtk.Label el; - private ValaProjectSettingsPopover _this; + // set gobject values + var child_1 = new Xcls_Label3( _this ); + this.el.title_widget = child_1.el; + } + // user defined functions + } + public class Xcls_Label3 : Object + { + public Gtk.Label el; + private ValaProjectSettingsPopover _this; - // my vars (def) - // ctor - public Xcls_label_targets(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.label_targets = this; - this.el = new Gtk.Label( "Targets" ); - - // my vars (dec) + // my vars (def) - // set gobject values - } + // ctor + public Xcls_Label3(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Change Vala Compile settings" ); - // user defined functions - } + // my vars (dec) - public class Xcls_Box8 : Object - { - public Gtk.Box el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_Box8(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.homogeneous = false; - var child_1 = new Xcls_Label9( _this ); - child_1.ref(); - this.el.append( child_1.el ); - new Xcls_compile_flags( _this ); - this.el.append( _this.compile_flags.el ); - new Xcls_vapi_scroll( _this ); - this.el.append( _this.vapi_scroll.el ); - new Xcls_vapi_search( _this ); - this.el.append( _this.vapi_search.el ); - } - - // user defined functions - } - public class Xcls_Label9 : Object - { - public Gtk.Label el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_Label9(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.Label( "compile flags" ); - - // my vars (dec) - - // set gobject values - this.el.halign = Gtk.Align.START; - this.el.hexpand = true; - } + // set gobject values + } - // user defined functions - } + // user defined functions + } - public class Xcls_compile_flags : Object - { - public Gtk.Entry el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_compile_flags(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.compile_flags = this; - this.el = new Gtk.Entry(); - - // my vars (dec) - - // set gobject values - this.el.placeholder_text = "eg. -g --valasrc $BASEDIR "; - - //listeners - this.el.changed.connect( () => { - - _this.project.compile_flags = this.el.buffer.text; - _this.project.save(); - // _this.project.save(); - - }); - } - - // user defined functions - } - - public class Xcls_vapi_scroll : Object - { - public Gtk.ScrolledWindow el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_vapi_scroll(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.vapi_scroll = this; - this.el = new Gtk.ScrolledWindow(); - - // my vars (dec) - - // set gobject values - this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC; - this.el.has_frame = true; - this.el.hexpand = true; - this.el.vexpand = true; - this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC; - var child_1 = new Xcls_ColumnView12( _this ); - this.el.child = child_1.el; - } - - // user defined functions - } - public class Xcls_ColumnView12 : Object - { - public Gtk.ColumnView el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_ColumnView12(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - var child_1 = new Xcls_NoSelection13( _this ); - child_1.ref(); - this.el = new Gtk.ColumnView( child_1.el ); - - // my vars (dec) - // set gobject values - var child_2 = new Xcls_ColumnViewColumn21( _this ); - child_2.ref(); - this.el.append_column ( child_2.el ); - var child_3 = new Xcls_ColumnViewColumn23( _this ); - child_3.ref(); - this.el.append_column ( child_3.el ); - } - - // user defined functions - } - public class Xcls_NoSelection13 : Object - { - public Gtk.NoSelection el; - private ValaProjectSettingsPopover _this; + public class Xcls_Box4 : Object + { + public Gtk.Box el; + private ValaProjectSettingsPopover _this; - // my vars (def) - - // ctor - public Xcls_NoSelection13(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - var child_1 = new Xcls_FilterListModel14( _this ); - child_1.ref(); - this.el = new Gtk.NoSelection( child_1.el ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - public class Xcls_FilterListModel14 : Object - { - public Gtk.FilterListModel el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_FilterListModel14(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - var child_1 = new Xcls_SortListModel15( _this ); - child_1.ref(); - new Xcls_vapi_filter( _this ); - this.el = new Gtk.FilterListModel( child_1.el, _this.vapi_filter.el ); + // my vars (def) - // my vars (dec) + // ctor + public Xcls_Box4(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - // set gobject values - } + // my vars (dec) - // user defined functions - } - public class Xcls_SortListModel15 : Object - { - public Gtk.SortListModel el; - private ValaProjectSettingsPopover _this; + // set gobject values + this.el.hexpand = true; + this.el.vexpand = true; + new Xcls_notebook( _this ); + this.el.append( _this.notebook.el ); + var child_2 = new Xcls_Box58( _this ); + child_2.ref(); + this.el.append( child_2.el ); + } + // user defined functions + } + public class Xcls_notebook : Object + { + public Gtk.Notebook el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_notebook(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.notebook = this; + this.el = new Gtk.Notebook(); + + // my vars (dec) + + // set gobject values + this.el.vexpand = true; + new Xcls_label_global( _this ); + new Xcls_label_targets( _this ); + var child_3 = new Xcls_Box8( _this ); + child_3.ref(); + this.el.append_page ( child_3.el , _this.label_global.el ); + var child_4 = new Xcls_Paned26( _this ); + child_4.ref(); + this.el.append_page ( child_4.el , _this.label_targets.el ); + } - // my vars (def) + // user defined functions + } + public class Xcls_label_global : Object + { + public Gtk.Label el; + private ValaProjectSettingsPopover _this; - // ctor - public Xcls_SortListModel15(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - new Xcls_vapimodel( _this ); - var child_2 = new Xcls_StringSorter17( _this ); - child_2.ref(); - this.el = new Gtk.SortListModel( _this.vapimodel.el, child_2.el ); - // my vars (dec) + // my vars (def) - // set gobject values - } + // ctor + public Xcls_label_global(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.label_global = this; + this.el = new Gtk.Label( "Global" ); - // user defined functions - } - public class Xcls_vapimodel : Object - { - public GLib.ListStore el; - private ValaProjectSettingsPopover _this; + // my vars (dec) + // set gobject values + } - // my vars (def) + // user defined functions + } - // ctor - public Xcls_vapimodel(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.vapimodel = this; - this.el = new GLib.ListStore( typeof(Project.VapiSelection) ); + public class Xcls_label_targets : Object + { + public Gtk.Label el; + private ValaProjectSettingsPopover _this; - // my vars (dec) - // set gobject values - } + // my vars (def) - // user defined functions - } + // ctor + public Xcls_label_targets(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.label_targets = this; + this.el = new Gtk.Label( "Targets" ); - public class Xcls_StringSorter17 : Object - { - public Gtk.StringSorter el; - private ValaProjectSettingsPopover _this; + // my vars (dec) + // set gobject values + } - // my vars (def) + // user defined functions + } - // ctor - public Xcls_StringSorter17(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - var child_1 = new Xcls_PropertyExpression18( _this ); - child_1.ref(); - this.el = new Gtk.StringSorter( child_1.el ); + public class Xcls_Box8 : Object + { + public Gtk.Box el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_Box8(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + var child_1 = new Xcls_Label9( _this ); + child_1.ref(); + this.el.append( child_1.el ); + new Xcls_compile_flags( _this ); + this.el.append( _this.compile_flags.el ); + new Xcls_vapi_scroll( _this ); + this.el.append( _this.vapi_scroll.el ); + new Xcls_vapi_search( _this ); + this.el.append( _this.vapi_search.el ); + } - // my vars (dec) + // user defined functions + } + public class Xcls_Label9 : Object + { + public Gtk.Label el; + private ValaProjectSettingsPopover _this; - // set gobject values - } - // user defined functions - } - public class Xcls_PropertyExpression18 : Object - { - public Gtk.PropertyExpression el; - private ValaProjectSettingsPopover _this; + // my vars (def) + // ctor + public Xcls_Label9(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "compile flags" ); - // my vars (def) + // my vars (dec) - // ctor - public Xcls_PropertyExpression18(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.PropertyExpression( typeof(Project.VapiSelection), null, "sortkey" ); + // set gobject values + this.el.halign = Gtk.Align.START; + this.el.hexpand = true; + } - // my vars (dec) + // user defined functions + } - // set gobject values - } + public class Xcls_compile_flags : Object + { + public Gtk.Entry el; + private ValaProjectSettingsPopover _this; - // user defined functions - } + // my vars (def) + // ctor + public Xcls_compile_flags(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.compile_flags = this; + this.el = new Gtk.Entry(); - public class Xcls_vapi_filter : Object - { - public Gtk.StringFilter el; - private ValaProjectSettingsPopover _this; + // my vars (dec) + // set gobject values + this.el.placeholder_text = "eg. -g --valasrc $BASEDIR "; - // my vars (def) + //listeners + this.el.changed.connect( () => { + + _this.project.compile_flags = this.el.buffer.text; + _this.project.save(); + // _this.project.save(); + + }); + } - // ctor - public Xcls_vapi_filter(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.vapi_filter = this; - var child_1 = new Xcls_PropertyExpression20( _this ); - child_1.ref(); - this.el = new Gtk.StringFilter( child_1.el ); + // user defined functions + } - // my vars (dec) + public class Xcls_vapi_scroll : Object + { + public Gtk.ScrolledWindow el; + private ValaProjectSettingsPopover _this; - // set gobject values - } - // user defined functions - } - public class Xcls_PropertyExpression20 : Object - { - public Gtk.PropertyExpression el; - private ValaProjectSettingsPopover _this; + // my vars (def) + // ctor + public Xcls_vapi_scroll(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.vapi_scroll = this; + this.el = new Gtk.ScrolledWindow(); - // my vars (def) + // my vars (dec) - // ctor - public Xcls_PropertyExpression20(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.PropertyExpression( typeof(Project.VapiSelection), null, "sortkey" ); + // set gobject values + this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC; + this.el.has_frame = true; + this.el.hexpand = true; + this.el.vexpand = true; + this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC; + var child_1 = new Xcls_ColumnView12( _this ); + this.el.child = child_1.el; + } - // my vars (dec) + // user defined functions + } + public class Xcls_ColumnView12 : Object + { + public Gtk.ColumnView el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_ColumnView12(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + var child_1 = new Xcls_NoSelection13( _this ); + child_1.ref(); + this.el = new Gtk.ColumnView( child_1.el ); + + // my vars (dec) + + // set gobject values + var child_2 = new Xcls_ColumnViewColumn21( _this ); + child_2.ref(); + this.el.append_column ( child_2.el ); + var child_3 = new Xcls_ColumnViewColumn23( _this ); + child_3.ref(); + this.el.append_column ( child_3.el ); + } - // set gobject values - } + // user defined functions + } + public class Xcls_NoSelection13 : Object + { + public Gtk.NoSelection el; + private ValaProjectSettingsPopover _this; - // user defined functions - } + // my vars (def) + // ctor + public Xcls_NoSelection13(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + var child_1 = new Xcls_FilterListModel14( _this ); + child_1.ref(); + this.el = new Gtk.NoSelection( child_1.el ); + // my vars (dec) - public class Xcls_ColumnViewColumn21 : Object - { - public Gtk.ColumnViewColumn el; - private ValaProjectSettingsPopover _this; + // set gobject values + } + // user defined functions + } + public class Xcls_FilterListModel14 : Object + { + public Gtk.FilterListModel el; + private ValaProjectSettingsPopover _this; - // my vars (def) - // ctor - public Xcls_ColumnViewColumn21(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - var child_1 = new Xcls_SignalListItemFactory22( _this ); - child_1.ref(); - this.el = new Gtk.ColumnViewColumn( "Vapi Package", child_1.el ); + // my vars (def) - // my vars (dec) + // ctor + public Xcls_FilterListModel14(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + var child_1 = new Xcls_SortListModel15( _this ); + child_1.ref(); + new Xcls_vapi_filter( _this ); + this.el = new Gtk.FilterListModel( child_1.el, _this.vapi_filter.el ); - // set gobject values - this.el.expand = true; - } + // my vars (dec) - // user defined functions - } - public class Xcls_SignalListItemFactory22 : Object - { - public Gtk.SignalListItemFactory el; - private ValaProjectSettingsPopover _this; + // set gobject values + } + // user defined functions + } + public class Xcls_SortListModel15 : Object + { + public Gtk.SortListModel el; + private ValaProjectSettingsPopover _this; - // my vars (def) - // ctor - public Xcls_SignalListItemFactory22(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.SignalListItemFactory(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.setup.connect( (item) => { - //var j = (JsRender.JsRender) item; - var gi = (Gtk.ListItem)item; - - var lbl = new Gtk.Label(""); - lbl.halign = Gtk.Align.START; - gi.set_child(lbl); - - - - }); - this.el.bind.connect( (listitem) => { - - var lbl = (Gtk.Box) ((Gtk.ListItem)listitem).get_child(); - - var item = (Project.VapiSelection) ((Gtk.ListItem)listitem).get_item(); - - item.bind_property("name", - lbl, "label", - GLib.BindingFlags.SYNC_CREATE); - - - }); - } - - // user defined functions - } - - - public class Xcls_ColumnViewColumn23 : Object - { - public Gtk.ColumnViewColumn el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_ColumnViewColumn23(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - var child_1 = new Xcls_SignalListItemFactory24( _this ); - child_1.ref(); - this.el = new Gtk.ColumnViewColumn( "use", child_1.el ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - public class Xcls_SignalListItemFactory24 : Object - { - public Gtk.SignalListItemFactory el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_SignalListItemFactory24(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.SignalListItemFactory(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.setup.connect( (listitem) => { - - var btn = new Gtk.CheckButton(); - - ((Gtk.ListItem)listitem).set_child(btn); - - btn.toggled.connect(() => { - - var jr = (Project.VapiSelection) ((Gtk.ListItem)listitem).get_item(); - jr.selected = btn.active; - }); - }); - this.el.bind.connect( (listitem) => { - //GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name()); - - - - //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); - var btn = (Gtk.CheckButton) ((Gtk.ListItem)listitem).get_child(); - - - var vs = (Project.VapiSelection)((Gtk.ListItem)listitem).get_item(); - - //GLib.debug("change %s to %s", lbl.label, np.name); - - btn.active = vs.selected; - - vs.btn = btn; - // bind image... - - }); - } - - // user defined functions - } - - - - - public class Xcls_vapi_search : Object - { - public Gtk.SearchEntry el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_vapi_search(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.vapi_search = this; - this.el = new Gtk.SearchEntry(); - - // my vars (dec) - - // set gobject values - this.el.placeholder_text = "Search Libraries (Vapi)"; - this.el.search_delay = 500; - - //listeners - this.el.search_changed.connect( ( ) => { - - _this.vapi_filter.el.set_search(this.el.get_text()); - - }); - } - - // user defined functions - } - - - public class Xcls_Paned26 : Object - { - public Gtk.Paned el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_Paned26(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL ); - - // my vars (dec) - - // set gobject values - this.el.vexpand = true; - this.el.position = 300; - new Xcls_set_vbox( _this ); - this.el.set_end_child ( _this.set_vbox.el ); - var child_2 = new Xcls_Box43( _this ); - this.el.start_child = child_2.el; - } - - // user defined functions - } - public class Xcls_set_vbox : Object - { - public Gtk.Box el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_set_vbox(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.set_vbox = this; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.homogeneous = false; - var child_1 = new Xcls_ScrolledWindow28( _this ); - child_1.ref(); - this.el.append( child_1.el ); - } + // my vars (def) - // user defined functions - } - public class Xcls_ScrolledWindow28 : Object - { - public Gtk.ScrolledWindow el; - private ValaProjectSettingsPopover _this; + // ctor + public Xcls_SortListModel15(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + new Xcls_vapimodel( _this ); + var child_2 = new Xcls_StringSorter17( _this ); + child_2.ref(); + this.el = new Gtk.SortListModel( _this.vapimodel.el, child_2.el ); + // my vars (dec) - // my vars (def) + // set gobject values + } + + // user defined functions + } + public class Xcls_vapimodel : Object + { + public GLib.ListStore el; + private ValaProjectSettingsPopover _this; - // ctor - public Xcls_ScrolledWindow28(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.ScrolledWindow(); - - // my vars (dec) - - // set gobject values - this.el.vexpand = true; - new Xcls_treeview( _this ); - this.el.child = _this.treeview.el; - } - - // user defined functions - } - public class Xcls_treeview : Object - { - public Gtk.ColumnView el; - private ValaProjectSettingsPopover _this; + // my vars (def) + + // ctor + public Xcls_vapimodel(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.vapimodel = this; + this.el = new GLib.ListStore( typeof(Project.VapiSelection) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_StringSorter17 : Object + { + public Gtk.StringSorter el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_StringSorter17(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + var child_1 = new Xcls_PropertyExpression18( _this ); + child_1.ref(); + this.el = new Gtk.StringSorter( child_1.el ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_PropertyExpression18 : Object + { + public Gtk.PropertyExpression el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_PropertyExpression18(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.PropertyExpression( typeof(Project.VapiSelection), null, "sortkey" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + public class Xcls_vapi_filter : Object + { + public Gtk.StringFilter el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_vapi_filter(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.vapi_filter = this; + var child_1 = new Xcls_PropertyExpression20( _this ); + child_1.ref(); + this.el = new Gtk.StringFilter( child_1.el ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_PropertyExpression20 : Object + { + public Gtk.PropertyExpression el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_PropertyExpression20(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.PropertyExpression( typeof(Project.VapiSelection), null, "sortkey" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } - // my vars (def) - - // ctor - public Xcls_treeview(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.treeview = this; - new Xcls_treeselmodel( _this ); - this.el = new Gtk.ColumnView( _this.treeselmodel.el ); - - // my vars (dec) - // set gobject values - new Xcls_name( _this ); - this.el.append_column ( _this.name.el ); - var child_3 = new Xcls_ColumnViewColumn41( _this ); - child_3.ref(); - this.el.append_column ( child_3.el ); - } - - // user defined functions - } - public class Xcls_treeselmodel : Object - { - public Gtk.SingleSelection el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_treeselmodel(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.treeselmodel = this; - var child_1 = new Xcls_FilterListModel31( _this ); - child_1.ref(); - this.el = new Gtk.SingleSelection( child_1.el ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - public class Xcls_FilterListModel31 : Object - { - public Gtk.FilterListModel el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_FilterListModel31(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - new Xcls_treelistsort( _this ); - var child_2 = new Xcls_CustomFilter38( _this ); - child_2.ref(); - this.el = new Gtk.FilterListModel( _this.treelistsort.el, child_2.el ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - public class Xcls_treelistsort : Object - { - public Gtk.SortListModel el; - private ValaProjectSettingsPopover _this; - // my vars (def) - - // ctor - public Xcls_treelistsort(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.treelistsort = this; - new Xcls_treelistmodel( _this ); - var child_2 = new Xcls_TreeListRowSorter35( _this ); - child_2.ref(); - this.el = new Gtk.SortListModel( _this.treelistmodel.el, child_2.el ); - - // my vars (dec) - - // set gobject values - - // init method - - { - //this.el.set_sorter(new Gtk.TreeListRowSorter(_this.treeview.el.sorter)); - } - } - - // user defined functions - } - public class Xcls_treelistmodel : Object - { - public Gtk.TreeListModel el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_treelistmodel(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.treelistmodel = this; - new Xcls_treemodel( _this ); - this.el = new Gtk.TreeListModel( _this.treemodel.el, false, true, (item) => { + public class Xcls_ColumnViewColumn21 : Object + { + public Gtk.ColumnViewColumn el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_ColumnViewColumn21(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + var child_1 = new Xcls_SignalListItemFactory22( _this ); + child_1.ref(); + this.el = new Gtk.ColumnViewColumn( "Vapi Package", child_1.el ); + + // my vars (dec) + + // set gobject values + this.el.expand = true; + } + + // user defined functions + } + public class Xcls_SignalListItemFactory22 : Object + { + public Gtk.SignalListItemFactory el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_SignalListItemFactory22(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.SignalListItemFactory(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.setup.connect( (item) => { + //var j = (JsRender.JsRender) item; + var gi = (Gtk.ListItem)item; + + var lbl = new Gtk.Label(""); + lbl.halign = Gtk.Align.START; + gi.set_child(lbl); + + + + }); + this.el.bind.connect( (listitem) => { + + var lbl = (Gtk.Label) ((Gtk.ListItem)listitem).get_child(); + + var item = (Project.VapiSelection) ((Gtk.ListItem)listitem).get_item(); + + item.bind_property("name", + lbl, "label", + GLib.BindingFlags.SYNC_CREATE); + + + }); + } + + // user defined functions + } + + + public class Xcls_ColumnViewColumn23 : Object + { + public Gtk.ColumnViewColumn el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_ColumnViewColumn23(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + var child_1 = new Xcls_SignalListItemFactory24( _this ); + child_1.ref(); + this.el = new Gtk.ColumnViewColumn( "use", child_1.el ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_SignalListItemFactory24 : Object + { + public Gtk.SignalListItemFactory el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_SignalListItemFactory24(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.SignalListItemFactory(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.setup.connect( (listitem) => { + + var btn = new Gtk.CheckButton(); + + ((Gtk.ListItem)listitem).set_child(btn); + + btn.toggled.connect(() => { + + var jr = (Project.VapiSelection) ((Gtk.ListItem)listitem).get_item(); + jr.selected = btn.active; + }); + }); + this.el.bind.connect( (listitem) => { + //GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name()); + + + + //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); + var btn = (Gtk.CheckButton) ((Gtk.ListItem)listitem).get_child(); + + + var vs = (Project.VapiSelection)((Gtk.ListItem)listitem).get_item(); + + //GLib.debug("change %s to %s", lbl.label, np.name); + + btn.active = vs.selected; + + vs.btn = btn; + // bind image... + + }); + } + + // user defined functions + } + + + + + public class Xcls_vapi_search : Object + { + public Gtk.SearchEntry el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_vapi_search(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.vapi_search = this; + this.el = new Gtk.SearchEntry(); + + // my vars (dec) + + // set gobject values + this.el.placeholder_text = "Search Libraries (Vapi)"; + this.el.search_delay = 500; + + //listeners + this.el.search_changed.connect( ( ) => { + + _this.vapi_filter.el.set_search(this.el.get_text()); + + }); + } + + // user defined functions + } + + + public class Xcls_Paned26 : Object + { + public Gtk.Paned el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_Paned26(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL ); + + // my vars (dec) + + // set gobject values + this.el.vexpand = true; + this.el.position = 300; + new Xcls_set_vbox( _this ); + this.el.set_end_child ( _this.set_vbox.el ); + var child_2 = new Xcls_Box43( _this ); + this.el.start_child = child_2.el; + } + + // user defined functions + } + public class Xcls_set_vbox : Object + { + public Gtk.Box el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_set_vbox(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.set_vbox = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + var child_1 = new Xcls_ScrolledWindow28( _this ); + child_1.ref(); + this.el.append( child_1.el ); + } + + // user defined functions + } + public class Xcls_ScrolledWindow28 : Object + { + public Gtk.ScrolledWindow el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow28(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow(); + + // my vars (dec) + + // set gobject values + this.el.vexpand = true; + new Xcls_treeview( _this ); + this.el.child = _this.treeview.el; + } + + // user defined functions + } + public class Xcls_treeview : Object + { + public Gtk.ColumnView el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_treeview(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.treeview = this; + new Xcls_treeselmodel( _this ); + this.el = new Gtk.ColumnView( _this.treeselmodel.el ); + + // my vars (dec) + + // set gobject values + new Xcls_name( _this ); + this.el.append_column ( _this.name.el ); + var child_3 = new Xcls_ColumnViewColumn41( _this ); + child_3.ref(); + this.el.append_column ( child_3.el ); + } + + // user defined functions + } + public class Xcls_treeselmodel : Object + { + public Gtk.SingleSelection el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_treeselmodel(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.treeselmodel = this; + var child_1 = new Xcls_FilterListModel31( _this ); + child_1.ref(); + this.el = new Gtk.SingleSelection( child_1.el ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_FilterListModel31 : Object + { + public Gtk.FilterListModel el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_FilterListModel31(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + new Xcls_treelistsort( _this ); + var child_2 = new Xcls_CustomFilter38( _this ); + child_2.ref(); + this.el = new Gtk.FilterListModel( _this.treelistsort.el, child_2.el ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_treelistsort : Object + { + public Gtk.SortListModel el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_treelistsort(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.treelistsort = this; + new Xcls_treelistmodel( _this ); + var child_2 = new Xcls_TreeListRowSorter35( _this ); + child_2.ref(); + this.el = new Gtk.SortListModel( _this.treelistmodel.el, child_2.el ); + + // my vars (dec) + + // set gobject values + + // init method + + { + //this.el.set_sorter(new Gtk.TreeListRowSorter(_this.treeview.el.sorter)); + } + } + + // user defined functions + } + public class Xcls_treelistmodel : Object + { + public Gtk.TreeListModel el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_treelistmodel(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.treelistmodel = this; + new Xcls_treemodel( _this ); + this.el = new Gtk.TreeListModel( _this.treemodel.el, false, true, (item) => { //GLib.debug("liststore got %s", item.get_type().name()); return ((JsRender.JsRender)item).childfiles; } ); - // my vars (dec) + // my vars (dec) - // set gobject values - } + // set gobject values + } - // user defined functions - } - public class Xcls_treemodel : Object - { - public GLib.ListStore el; - private ValaProjectSettingsPopover _this; + // user defined functions + } + public class Xcls_treemodel : Object + { + public GLib.ListStore el; + private ValaProjectSettingsPopover _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_treemodel(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.treemodel = this; - this.el = new GLib.ListStore( typeof(JsRender.JsRender) ); + // ctor + public Xcls_treemodel(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.treemodel = this; + this.el = new GLib.ListStore( typeof(JsRender.JsRender) ); - // my vars (dec) + // my vars (dec) - // set gobject values - } + // set gobject values + } - // user defined functions - } + // user defined functions + } - public class Xcls_TreeListRowSorter35 : Object - { - public Gtk.TreeListRowSorter el; - private ValaProjectSettingsPopover _this; + public class Xcls_TreeListRowSorter35 : Object + { + public Gtk.TreeListRowSorter el; + private ValaProjectSettingsPopover _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_TreeListRowSorter35(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - var child_1 = new Xcls_StringSorter36( _this ); - child_1.ref(); - this.el = new Gtk.TreeListRowSorter( child_1.el ); + // ctor + public Xcls_TreeListRowSorter35(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + var child_1 = new Xcls_StringSorter36( _this ); + child_1.ref(); + this.el = new Gtk.TreeListRowSorter( child_1.el ); - // my vars (dec) + // my vars (dec) - // set gobject values - } + // set gobject values + } - // user defined functions - } - public class Xcls_StringSorter36 : Object - { - public Gtk.StringSorter el; - private ValaProjectSettingsPopover _this; + // user defined functions + } + public class Xcls_StringSorter36 : Object + { + public Gtk.StringSorter el; + private ValaProjectSettingsPopover _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_StringSorter36(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - var child_1 = new Xcls_PropertyExpression37( _this ); - child_1.ref(); - this.el = new Gtk.StringSorter( child_1.el ); + // ctor + public Xcls_StringSorter36(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + var child_1 = new Xcls_PropertyExpression37( _this ); + child_1.ref(); + this.el = new Gtk.StringSorter( child_1.el ); - // my vars (dec) + // my vars (dec) - // set gobject values - } + // set gobject values + } - // user defined functions - } - public class Xcls_PropertyExpression37 : Object - { - public Gtk.PropertyExpression el; - private ValaProjectSettingsPopover _this; + // user defined functions + } + public class Xcls_PropertyExpression37 : Object + { + public Gtk.PropertyExpression el; + private ValaProjectSettingsPopover _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_PropertyExpression37(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.PropertyExpression( typeof(JsRender.JsRender), null, "name" ); + // ctor + public Xcls_PropertyExpression37(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.PropertyExpression( typeof(JsRender.JsRender), null, "name" ); - // my vars (dec) + // my vars (dec) - // set gobject values - } + // set gobject values + } - // user defined functions - } + // user defined functions + } - public class Xcls_CustomFilter38 : Object - { - public Gtk.CustomFilter el; - private ValaProjectSettingsPopover _this; + public class Xcls_CustomFilter38 : Object + { + public Gtk.CustomFilter el; + private ValaProjectSettingsPopover _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_CustomFilter38(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.CustomFilter( (item) => { + // ctor + public Xcls_CustomFilter38(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.CustomFilter( (item) => { var tr = ((Gtk.TreeListRow)item).get_item(); //GLib.debug("filter %s", tr.get_type().name()); @@ -1136,877 +1138,880 @@ } ); - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - - - public class Xcls_name : Object - { - public Gtk.ColumnViewColumn el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_name(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.name = this; - var child_1 = new Xcls_SignalListItemFactory40( _this ); - child_1.ref(); - this.el = new Gtk.ColumnViewColumn( "Other Files", child_1.el ); - - // my vars (dec) - - // set gobject values - this.el.id = "name"; - this.el.expand = true; - this.el.resizable = true; - - // init method - - { - this.el.set_sorter( new Gtk.StringSorter( - new Gtk.PropertyExpression(typeof(JsRender.JsRender), null, "name") - )); - ; - - } - } - - // user defined functions - } - public class Xcls_SignalListItemFactory40 : Object - { - public Gtk.SignalListItemFactory el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_SignalListItemFactory40(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.SignalListItemFactory(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.setup.connect( (listitem) => { - - var expand = new Gtk.TreeExpander(); - - expand.set_indent_for_depth(true); - expand.set_indent_for_icon(true); - - var lbl = new Gtk.Label(""); - lbl.use_markup = true; - - - lbl.justify = Gtk.Justification.LEFT; - lbl.xalign = 0; - - - expand.set_child(lbl); - ((Gtk.ListItem)listitem).set_child(expand); - ((Gtk.ListItem)listitem).activatable = false; - }); - this.el.bind.connect( (listitem) => { - //GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name()); - - - - //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); - var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); - - - var lbl = (Gtk.Label) expand.child; - - if (lbl.label != "") { // do not update - return; - } - - - var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item(); - var jr = (JsRender.JsRender) lr.get_item(); - //GLib.debug("change %s to %s", lbl.label, np.name); - lbl.label = jr.name; // for dir's we could hsow the sub path.. - lbl.tooltip_markup = jr.path; - - expand.set_hide_expander( jr.childfiles.n_items < 1); - expand.set_list_row(lr); - - expand.set_hide_expander( jr.xtype != "Dir" ); - expand.set_list_row(lr); - - // bind image... - - }); - } - - // user defined functions - } - - - public class Xcls_ColumnViewColumn41 : Object - { - public Gtk.ColumnViewColumn el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_ColumnViewColumn41(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - var child_1 = new Xcls_SignalListItemFactory42( _this ); - child_1.ref(); - this.el = new Gtk.ColumnViewColumn( "use", child_1.el ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - public class Xcls_SignalListItemFactory42 : Object - { - public Gtk.SignalListItemFactory el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_SignalListItemFactory42(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.SignalListItemFactory(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.setup.connect( (listitem) => { - - var btn = new Gtk.CheckButton(); - - ((Gtk.ListItem)listitem).set_child(btn); - - btn.toggled.connect(() => { - - var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item(); - var jr = (JsRender.JsRender) lr.get_item(); - jr.compile_group_selected = btn.active; - - - }); - }); - this.el.bind.connect( (listitem) => { - //GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name()); - - - - //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); - var btn = (Gtk.CheckButton) ((Gtk.ListItem)listitem).get_child(); - - - var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item(); - var jr = (JsRender.JsRender) lr.get_item(); - //GLib.debug("change %s to %s", lbl.label, np.name); - - - - jr.bind_property("compile_group_selected", - btn, "active", - GLib.BindingFlags.SYNC_CREATE); - // bind image... - - }); - } - - // user defined functions - } - - - - - - public class Xcls_Box43 : Object - { - public Gtk.Box el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_Box43(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - var child_1 = new Xcls_Box44( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_ScrolledWindow47( _this ); - child_2.ref(); - this.el.append( child_2.el ); - new Xcls_set_vboxb( _this ); - this.el.append( _this.set_vboxb.el ); - } - - // user defined functions - } - public class Xcls_Box44 : Object - { - public Gtk.Box el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_Box44(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.hexpand = true; - var child_1 = new Xcls_Button45( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_Button46( _this ); - child_2.ref(); - this.el.append( child_2.el ); - } - - // user defined functions - } - public class Xcls_Button45 : Object - { - public Gtk.Button el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_Button45(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.hexpand = true; - this.el.label = "Add Compile Target"; - - //listeners - this.el.clicked.connect( () => { - - if (_this.project.compilegroups.has_key("NEW GROUP")) { - return; - } - var cg = new Project.GtkValaSettings(_this.project, "NEW GROUP"); - _this.project.compilegroups.set(cg.name, cg); - _this.project.loadTargetsIntoStore(_this.target_model.el); - // select it.. ?? should load it?? - for(var i =0;i < _this.target_model.el.n_items; i++) { - var ncg = (Project.GtkValaSettings) _this.target_model.el.get_item(i); - if (ncg.name == cg.name) { - _this.target_sel.el.selected = i; - _this.target_sel.selectTarget(cg); - break; - } - } - - - - }); - } - - // user defined functions - } - - public class Xcls_Button46 : Object - { - public Gtk.Button el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_Button46(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.hexpand = true; - this.el.label = "Remove Target"; - - //listeners - this.el.clicked.connect( () => { - // load the new values. - if (_this.target_sel.el.selected == Gtk.INVALID_LIST_POSITION) { - GLib.debug("nothing selected"); - return; - } - - - // add the directory.. - var cg = (Project.GtkValaSettings) _this.target_model.el.get_item(_this.target_sel.el.selected); - - - GLib.debug("remove: %s\n", cg.name); - if (!_this.project.compilegroups.unset(cg.name)) { - GLib.debug("remove failed"); - } - _this.project.loadTargetsIntoStore(_this.target_model.el); - }); - } - - // user defined functions - } - - - public class Xcls_ScrolledWindow47 : Object - { - public Gtk.ScrolledWindow el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_ScrolledWindow47(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.ScrolledWindow(); - - // my vars (dec) - - // set gobject values - this.el.vexpand = true; - var child_1 = new Xcls_ColumnView48( _this ); - this.el.child = child_1.el; - - // init method - - { - this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); - - } - } - - // user defined functions - } - public class Xcls_ColumnView48 : Object - { - public Gtk.ColumnView el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_ColumnView48(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - new Xcls_target_sel( _this ); - this.el = new Gtk.ColumnView( _this.target_sel.el ); - - // my vars (dec) - - // set gobject values - var child_2 = new Xcls_ColumnViewColumn51( _this ); - child_2.ref(); - this.el.append_column ( child_2.el ); - } - - // user defined functions - } - public class Xcls_target_sel : Object - { - public Gtk.SingleSelection el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_target_sel(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.target_sel = this; - new Xcls_target_model( _this ); - this.el = new Gtk.SingleSelection( _this.target_model.el ); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.selection_changed.connect( (position, n_items) => { - - - // load the new values. - if (this.el.selected == Gtk.INVALID_LIST_POSITION) { - this.selectTarget(null); - return; - } - this.selectTarget(null); - - - - // add the directory.. - var cg = (Project.GtkValaSettings) _this.target_model.el.get_item(this.el.selected); - - this.selectTarget(cg); - - }); - } - - // user defined functions - public void selectTarget (Project.GtkValaSettings? cg) { - // load the new values - _this.selected_target = cg; - _this.project.active_cg = cg; - - - if (cg == null) { - - _this.set_vbox.el.hide(); - _this.set_vboxb.el.hide(); - return; - } - - - _this.set_vbox.el.show(); - _this.set_vboxb.el.show(); - // add the directory.. - - - GLib.debug("loading dirs into project list"); - cg.loading_ui = true; - - - _this.treeview.el.set_model(new Gtk.SingleSelection(null)); - _this.project.loadDirsIntoStore(_this.treemodel.el); - _this.treeview.el.set_model(_this.treeselmodel.el); - - cg.loading_ui = false; - GLib.debug("Set name to %s", cg.name); - - _this.build_name.el.buffer.set_text(cg.name.data); - - - _this.build_execute_args.el.buffer.set_text( cg.execute_args.data ); - - - } - } - public class Xcls_target_model : Object - { - public GLib.ListStore el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_target_model(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.target_model = this; - this.el = new GLib.ListStore( typeof(Project.GtkValaSettings) ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - - public class Xcls_ColumnViewColumn51 : Object - { - public Gtk.ColumnViewColumn el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_ColumnViewColumn51(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - var child_1 = new Xcls_SignalListItemFactory52( _this ); - child_1.ref(); - this.el = new Gtk.ColumnViewColumn( "Build Target", child_1.el ); - - // my vars (dec) - - // set gobject values - this.el.expand = true; - } - - // user defined functions - } - public class Xcls_SignalListItemFactory52 : Object - { - public Gtk.SignalListItemFactory el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_SignalListItemFactory52(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.SignalListItemFactory(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.setup.connect( (item) => { - //var j = (JsRender.JsRender) item; - var gi = (Gtk.ListItem)item; - - var lbl = new Gtk.Label(""); - lbl.halign = Gtk.Align.START; - gi.set_child(lbl); - - - - }); - this.el.bind.connect( (listitem) => { - - var lbl = (Gtk.Box) ((Gtk.ListItem)listitem).get_child(); - - var item = (Project.GtkValaSettings) ((Gtk.ListItem)listitem).get_item(); - - item.bind_property("name", - lbl, "label", - GLib.BindingFlags.SYNC_CREATE); - - - }); - } - - // user defined functions - } - - - - - public class Xcls_set_vboxb : Object - { - public Gtk.Box el; - private ValaProjectSettingsPopover _this; - + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + public class Xcls_name : Object + { + public Gtk.ColumnViewColumn el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_name(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.name = this; + var child_1 = new Xcls_SignalListItemFactory40( _this ); + child_1.ref(); + this.el = new Gtk.ColumnViewColumn( "Other Files", child_1.el ); + + // my vars (dec) + + // set gobject values + this.el.id = "name"; + this.el.expand = true; + this.el.resizable = true; + + // init method + + { + this.el.set_sorter( new Gtk.StringSorter( + new Gtk.PropertyExpression(typeof(JsRender.JsRender), null, "name") + )); + ; + + } + } + + // user defined functions + } + public class Xcls_SignalListItemFactory40 : Object + { + public Gtk.SignalListItemFactory el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_SignalListItemFactory40(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.SignalListItemFactory(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.setup.connect( (listitem) => { + + var expand = new Gtk.TreeExpander(); + + expand.set_indent_for_depth(true); + expand.set_indent_for_icon(true); + + var lbl = new Gtk.Label(""); + lbl.use_markup = true; + + + lbl.justify = Gtk.Justification.LEFT; + lbl.xalign = 0; + + + expand.set_child(lbl); + ((Gtk.ListItem)listitem).set_child(expand); + ((Gtk.ListItem)listitem).activatable = false; + }); + this.el.bind.connect( (listitem) => { + //GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name()); + + + + //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); + var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); + + + var lbl = (Gtk.Label) expand.child; + + if (lbl.label != "") { // do not update + return; + } + + + var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item(); + var jr = (JsRender.JsRender) lr.get_item(); + //GLib.debug("change %s to %s", lbl.label, np.name); + lbl.label = jr.name; // for dir's we could hsow the sub path.. + lbl.tooltip_markup = jr.path; + + expand.set_hide_expander( jr.childfiles.n_items < 1); + expand.set_list_row(lr); + + expand.set_hide_expander( jr.xtype != "Dir" ); + expand.set_list_row(lr); + + // bind image... + + }); + } + + // user defined functions + } + + + public class Xcls_ColumnViewColumn41 : Object + { + public Gtk.ColumnViewColumn el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_ColumnViewColumn41(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + var child_1 = new Xcls_SignalListItemFactory42( _this ); + child_1.ref(); + this.el = new Gtk.ColumnViewColumn( "use", child_1.el ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_SignalListItemFactory42 : Object + { + public Gtk.SignalListItemFactory el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_SignalListItemFactory42(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.SignalListItemFactory(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.setup.connect( (listitem) => { + + var btn = new Gtk.CheckButton(); + + ((Gtk.ListItem)listitem).set_child(btn); + + btn.toggled.connect(() => { + if (_this.cg_loading) { + return; + } + var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item(); + var jr = (JsRender.JsRender) lr.get_item(); + jr.compile_group_selected = btn.active; + + + }); + }); + this.el.bind.connect( (listitem) => { + //GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name()); + + + + //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); + var btn = (Gtk.CheckButton) ((Gtk.ListItem)listitem).get_child(); + + + var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item(); + var jr = (JsRender.JsRender) lr.get_item(); + //GLib.debug("change %s to %s", lbl.label, np.name); + + //btn.active = jr.compile_group_selected; + + jr.bind_property("compile_group_selected", + btn, "active", + GLib.BindingFlags.BIDIRECTIONAL); + // bind image... + + }); + } + + // user defined functions + } + + + + + + public class Xcls_Box43 : Object + { + public Gtk.Box el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_Box43(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Box44( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_ScrolledWindow47( _this ); + child_2.ref(); + this.el.append( child_2.el ); + new Xcls_set_vboxb( _this ); + this.el.append( _this.set_vboxb.el ); + } + + // user defined functions + } + public class Xcls_Box44 : Object + { + public Gtk.Box el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_Box44(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.hexpand = true; + var child_1 = new Xcls_Button45( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_Button46( _this ); + child_2.ref(); + this.el.append( child_2.el ); + } + + // user defined functions + } + public class Xcls_Button45 : Object + { + public Gtk.Button el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_Button45(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.hexpand = true; + this.el.label = "Add Compile Target"; + + //listeners + this.el.clicked.connect( () => { + + if (_this.project.compilegroups.has_key("NEW GROUP")) { + return; + } + var cg = new Project.GtkValaSettings(_this.project, "NEW GROUP"); + _this.project.compilegroups.set(cg.name, cg); + _this.project.loadTargetsIntoStore(_this.target_model.el); + // select it.. ?? should load it?? + for(var i =0;i < _this.target_model.el.n_items; i++) { + var ncg = (Project.GtkValaSettings) _this.target_model.el.get_item(i); + if (ncg.name == cg.name) { + _this.target_sel.el.selected = i; + _this.target_sel.selectTarget(cg); + break; + } + } + + + + }); + } + + // user defined functions + } + + public class Xcls_Button46 : Object + { + public Gtk.Button el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_Button46(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.hexpand = true; + this.el.label = "Remove Target"; + + //listeners + this.el.clicked.connect( () => { + // load the new values. + if (_this.target_sel.el.selected == Gtk.INVALID_LIST_POSITION) { + GLib.debug("nothing selected"); + return; + } + + + // add the directory.. + var cg = (Project.GtkValaSettings) _this.target_model.el.get_item(_this.target_sel.el.selected); + + + GLib.debug("remove: %s\n", cg.name); + if (!_this.project.compilegroups.unset(cg.name)) { + GLib.debug("remove failed"); + } + _this.project.loadTargetsIntoStore(_this.target_model.el); + }); + } + + // user defined functions + } + + + public class Xcls_ScrolledWindow47 : Object + { + public Gtk.ScrolledWindow el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow47(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow(); + + // my vars (dec) + + // set gobject values + this.el.vexpand = true; + var child_1 = new Xcls_ColumnView48( _this ); + this.el.child = child_1.el; + + // init method + + { + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + + } + } + + // user defined functions + } + public class Xcls_ColumnView48 : Object + { + public Gtk.ColumnView el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_ColumnView48(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + new Xcls_target_sel( _this ); + this.el = new Gtk.ColumnView( _this.target_sel.el ); + + // my vars (dec) + + // set gobject values + var child_2 = new Xcls_ColumnViewColumn51( _this ); + child_2.ref(); + this.el.append_column ( child_2.el ); + } + + // user defined functions + } + public class Xcls_target_sel : Object + { + public Gtk.SingleSelection el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_target_sel(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.target_sel = this; + new Xcls_target_model( _this ); + this.el = new Gtk.SingleSelection( _this.target_model.el ); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.selection_changed.connect( (position, n_items) => { + + + // load the new values. + if (this.el.selected == Gtk.INVALID_LIST_POSITION) { + this.selectTarget(null); + return; + } + this.selectTarget(null); + + + + // add the directory.. + var cg = (Project.GtkValaSettings) _this.target_model.el.get_item(this.el.selected); + + this.selectTarget(cg); + + }); + } + + // user defined functions + public void selectTarget (Project.GtkValaSettings? cg) { + // load the new values + _this.selected_target = cg; + _this.project.active_cg = cg; + + + if (cg == null) { + + _this.set_vbox.el.hide(); + _this.set_vboxb.el.hide(); + return; + } + + + _this.set_vbox.el.show(); + _this.set_vboxb.el.show(); + // add the directory.. + + + GLib.debug("loading dirs into project list"); + cg.loading_ui = true; + _this.cg_loading = true; + + _this.treeview.el.set_model(new Gtk.SingleSelection(null)); + _this.project.loadDirsIntoStore(_this.treemodel.el); + _this.treeview.el.set_model(_this.treeselmodel.el); + + cg.loading_ui = false; + + _this.cg_loading = false; + GLib.debug("Set name to %s", cg.name); + + _this.build_name.el.buffer.set_text(cg.name.data); + + + _this.build_execute_args.el.buffer.set_text( cg.execute_args.data ); + + } + } + public class Xcls_target_model : Object + { + public GLib.ListStore el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_target_model(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.target_model = this; + this.el = new GLib.ListStore( typeof(Project.GtkValaSettings) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + public class Xcls_ColumnViewColumn51 : Object + { + public Gtk.ColumnViewColumn el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_ColumnViewColumn51(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + var child_1 = new Xcls_SignalListItemFactory52( _this ); + child_1.ref(); + this.el = new Gtk.ColumnViewColumn( "Build Target", child_1.el ); + + // my vars (dec) + + // set gobject values + this.el.expand = true; + } + + // user defined functions + } + public class Xcls_SignalListItemFactory52 : Object + { + public Gtk.SignalListItemFactory el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_SignalListItemFactory52(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.SignalListItemFactory(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.setup.connect( (item) => { + //var j = (JsRender.JsRender) item; + var gi = (Gtk.ListItem)item; + + var lbl = new Gtk.Label(""); + lbl.halign = Gtk.Align.START; + gi.set_child(lbl); + + + + }); + this.el.bind.connect( (listitem) => { + + var lbl = (Gtk.Label) ((Gtk.ListItem)listitem).get_child(); + + var item = (Project.GtkValaSettings) ((Gtk.ListItem)listitem).get_item(); + + item.bind_property("name", + lbl, "label", + GLib.BindingFlags.SYNC_CREATE); + + + }); + } + + // user defined functions + } + + + - // my vars (def) + public class Xcls_set_vboxb : Object + { + public Gtk.Box el; + private ValaProjectSettingsPopover _this; - // ctor - public Xcls_set_vboxb(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.set_vboxb = this; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - // my vars (dec) + // my vars (def) - // set gobject values - var child_1 = new Xcls_Label54( _this ); - child_1.ref(); - this.el.append( child_1.el ); - new Xcls_build_name( _this ); - this.el.append( _this.build_name.el ); - var child_3 = new Xcls_Label56( _this ); - child_3.ref(); - this.el.append( child_3.el ); - new Xcls_build_execute_args( _this ); - this.el.append( _this.build_execute_args.el ); - } - - // user defined functions - } - public class Xcls_Label54 : Object - { - public Gtk.Label el; - private ValaProjectSettingsPopover _this; - - - // my vars (def) - - // ctor - public Xcls_Label54(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.Label( "Build Name (executable name)" ); - - // my vars (dec) - - // set gobject values - } + // ctor + public Xcls_set_vboxb(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.set_vboxb = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - // user defined functions - } + // my vars (dec) - public class Xcls_build_name : Object - { - public Gtk.Entry el; - private ValaProjectSettingsPopover _this; + // set gobject values + var child_1 = new Xcls_Label54( _this ); + child_1.ref(); + this.el.append( child_1.el ); + new Xcls_build_name( _this ); + this.el.append( _this.build_name.el ); + var child_3 = new Xcls_Label56( _this ); + child_3.ref(); + this.el.append( child_3.el ); + new Xcls_build_execute_args( _this ); + this.el.append( _this.build_execute_args.el ); + } + // user defined functions + } + public class Xcls_Label54 : Object + { + public Gtk.Label el; + private ValaProjectSettingsPopover _this; - // my vars (def) - // ctor - public Xcls_build_name(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.build_name = this; - this.el = new Gtk.Entry(); + // my vars (def) - // my vars (dec) + // ctor + public Xcls_Label54(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Build Name (executable name)" ); - // set gobject values + // my vars (dec) - //listeners - this.el.changed.connect( () => { - if (_this.selected_target == null) { - return; - } - var name = this.el.text; - // name ischanging.. probably always.. - if (_this.selected_target.name != name) { - _this.project.compilegroups.unset(_this.selected_target.name); - _this.project.compilegroups.set(name, _this.selected_target); - } - - _this.selected_target.name = this.el.buffer.text; - }); - } + // set gobject values + } - // user defined functions - } + // user defined functions + } - public class Xcls_Label56 : Object - { - public Gtk.Label el; - private ValaProjectSettingsPopover _this; + public class Xcls_build_name : Object + { + public Gtk.Entry el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_build_name(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.build_name = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.changed.connect( () => { + if (_this.selected_target == null) { + return; + } + var name = this.el.text; + // name ischanging.. probably always.. + if (_this.selected_target.name != name) { + _this.project.compilegroups.unset(_this.selected_target.name); + _this.project.compilegroups.set(name, _this.selected_target); + } + + _this.selected_target.name = this.el.buffer.text; + }); + } + // user defined functions + } - // my vars (def) + public class Xcls_Label56 : Object + { + public Gtk.Label el; + private ValaProjectSettingsPopover _this; - // ctor - public Xcls_Label56(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.Label( "test argments - when run after a build" ); - // my vars (dec) + // my vars (def) - // set gobject values - } - - // user defined functions - } - - public class Xcls_build_execute_args : Object - { - public Gtk.Entry el; - private ValaProjectSettingsPopover _this; + // ctor + public Xcls_Label56(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "test argments - when run after a build" ); + // my vars (dec) - // my vars (def) + // set gobject values + } - // ctor - public Xcls_build_execute_args(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.build_execute_args = this; - this.el = new Gtk.Entry(); + // user defined functions + } - // my vars (dec) + public class Xcls_build_execute_args : Object + { + public Gtk.Entry el; + private ValaProjectSettingsPopover _this; - // set gobject values - this.el.placeholder_text = "eg. -f somefile -g "; - //listeners - this.el.changed.connect( () => { - if (_this.selected_target == null) { - return; - } - _this.selected_target.execute_args = this.el.buffer.text; - - }); - } + // my vars (def) - // user defined functions - } + // ctor + public Xcls_build_execute_args(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.build_execute_args = this; + this.el = new Gtk.Entry(); + // my vars (dec) + // set gobject values + this.el.placeholder_text = "eg. -f somefile -g "; + //listeners + this.el.changed.connect( () => { + if (_this.selected_target == null) { + return; + } + _this.selected_target.execute_args = this.el.buffer.text; + + }); + } + // user defined functions + } - public class Xcls_Box58 : Object - { - public Gtk.Box el; - private ValaProjectSettingsPopover _this; - // my vars (def) - // ctor - public Xcls_Box58(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - // my vars (dec) + public class Xcls_Box58 : Object + { + public Gtk.Box el; + private ValaProjectSettingsPopover _this; - // set gobject values - this.el.margin_end = 4; - this.el.margin_start = 4; - this.el.hexpand = true; - this.el.margin_bottom = 4; - this.el.margin_top = 4; - var child_1 = new Xcls_Button59( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_Label60( _this ); - child_2.ref(); - this.el.append( child_2.el ); - new Xcls_save_btn( _this ); - this.el.append( _this.save_btn.el ); - } - // user defined functions - } - public class Xcls_Button59 : Object - { - public Gtk.Button el; - private ValaProjectSettingsPopover _this; + // my vars (def) + // ctor + public Xcls_Box58(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - // my vars (def) + // my vars (dec) - // ctor - public Xcls_Button59(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); + // set gobject values + this.el.margin_end = 4; + this.el.margin_start = 4; + this.el.hexpand = true; + this.el.margin_bottom = 4; + this.el.margin_top = 4; + var child_1 = new Xcls_Button59( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_Label60( _this ); + child_2.ref(); + this.el.append( child_2.el ); + new Xcls_save_btn( _this ); + this.el.append( _this.save_btn.el ); + } - // my vars (dec) + // user defined functions + } + public class Xcls_Button59 : Object + { + public Gtk.Button el; + private ValaProjectSettingsPopover _this; - // set gobject values - this.el.label = "Cancel"; - //listeners - this.el.clicked.connect( () => { - - _this.done = true; - _this.el.hide(); - }); - } + // my vars (def) - // user defined functions - } + // ctor + public Xcls_Button59(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); - public class Xcls_Label60 : Object - { - public Gtk.Label el; - private ValaProjectSettingsPopover _this; + // my vars (dec) + // set gobject values + this.el.label = "Cancel"; - // my vars (def) + //listeners + this.el.clicked.connect( () => { + + _this.done = true; + _this.el.hide(); + }); + } - // ctor - public Xcls_Label60(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - this.el = new Gtk.Label( "" ); + // user defined functions + } - // my vars (dec) + public class Xcls_Label60 : Object + { + public Gtk.Label el; + private ValaProjectSettingsPopover _this; - // set gobject values - this.el.hexpand = true; - } - // user defined functions - } + // my vars (def) - public class Xcls_save_btn : Object - { - public Gtk.Button el; - private ValaProjectSettingsPopover _this; + // ctor + public Xcls_Label60(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "" ); + // my vars (dec) - // my vars (def) + // set gobject values + this.el.hexpand = true; + } - // ctor - public Xcls_save_btn(ValaProjectSettingsPopover _owner ) - { - _this = _owner; - _this.save_btn = this; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.css_classes = { "suggested-action" }; - this.el.label = "Save"; - - //listeners - this.el.clicked.connect( ( ) => { - - - _this.project.save(); - - // what about .js ? - _this.done = true; - _this.el.hide(); - if (_this.doneObj != null) { - _this.doneObj.call(_this.project); - } - - - }); - } + // user defined functions + } + + public class Xcls_save_btn : Object + { + public Gtk.Button el; + private ValaProjectSettingsPopover _this; + + + // my vars (def) + + // ctor + public Xcls_save_btn(ValaProjectSettingsPopover _owner ) + { + _this = _owner; + _this.save_btn = this; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.css_classes = { "suggested-action" }; + this.el.label = "Save"; + + //listeners + this.el.clicked.connect( ( ) => { + + + _this.project.save(); + + // what about .js ? + _this.done = true; + _this.el.hide(); + if (_this.doneObj != null) { + _this.doneObj.call(_this.project); + } + + + }); + } - // user defined functions - } + // user defined functions + } - } +} diff --git a/src/Builder4/WindowLeftProps.bjs b/src/Builder4/WindowLeftProps.bjs index 31620d454..369cd6ae2 100644 --- a/src/Builder4/WindowLeftProps.bjs +++ b/src/Builder4/WindowLeftProps.bjs @@ -444,8 +444,9 @@ " ", " //\tGtk.Allocation rect;", "\t//this.el.get_allocation(out rect);", - "", - "\t p.el.set_parent(this.el);", + "\tif (p.el.parent == null) {", + "\t\t p.el.set_parent(this.el);", + "\t }", " //p.el.set_pointing_to(rect);", "\tp.el.show();", "\tp.el.set_position(Gtk.PositionType.BOTTOM);", @@ -628,7 +629,9 @@ "\t", "\tGLib.debug(\"Prssed %d\", (int) this.el.get_current_button());", "\t//_this.deletemenu.el.set_parent(_this.view.el);", - "\t_this.deletemenu.el.set_parent(_this.main_window.el);", + "\tif (_this.deletemenu.el.parent == null) {", + "\t\t_this.deletemenu.el.set_parent(_this.main_window.el);", + "\t}", "\t", "\t", "\t ", @@ -1169,14 +1172,19 @@ "\t\tvar ll = (Gtk.Label)ca.get_first_child();", "\t\tvar cb = ca.get_next_sibling();", "\t\tvar b = cb.get_first_child();", - "\t\tvar e = (Gtk.Entry) b.get_first_child();", + "\t\tvar e = (Gtk.EditableLabel) b.get_first_child();", "\t\tvar l = (Gtk.Label) e.get_next_sibling();", "\t\tvar d = (Gtk.DropDown) l.get_next_sibling();", "\t\t", "\t\tGLib.debug(\"row key = %s\", ll.label);", "\t\tif (e.get_visible()) {", "\t\t\t_this.stop_editor();", - "\t\t\te.grab_focus_without_selecting();", + "\t\t\te.start_editing();", + "\t\t\t//GLib.Timeout.add_once(500, () => {", + "\t\t\t//\tvar st = (Gtk.Stack) e.get_first_child();", + "\t\t\t//\tvar ed = (Gtk.Entry) st.get_visible_child();", + "\t\t\t//\ted.grab_focus_without_selecting();", + "\t\t\t//});", "\t\t\treturn;", "\t\t}", "\t\tif (d.get_visible()) {", diff --git a/src/Builder4/WindowLeftProps.vala b/src/Builder4/WindowLeftProps.vala index f7a0b534a..5da1a3f4d 100644 --- a/src/Builder4/WindowLeftProps.vala +++ b/src/Builder4/WindowLeftProps.vala @@ -1,2140 +1,2148 @@ - static Xcls_LeftProps _LeftProps; - - public class Xcls_LeftProps : Object - { - public Gtk.Box el; - private Xcls_LeftProps _this; - - public static Xcls_LeftProps singleton() - { - if (_LeftProps == null) { - _LeftProps= new Xcls_LeftProps(); - } - return _LeftProps; - } - public Xcls_AddPropertyPopup AddPropertyPopup; - public Xcls_EditProps EditProps; - public Xcls_view view; - public Xcls_deletemenu deletemenu; - public Xcls_selmodel selmodel; - public Xcls_model model; - public Xcls_keycol keycol; - public Xcls_valcol valcol; - public Xcls_ContextMenu ContextMenu; - - // my vars (def) - public bool loading; - public bool allow_edit; - public signal void show_add_props (string type); - public signal bool stop_editor (); - public Xcls_MainWindow main_window; - public signal void changed (); - public JsRender.JsRender file; - public JsRender.Node node; - public signal void show_editor (JsRender.JsRender file, JsRender.Node node, JsRender.NodeProp prop); - - // ctor - public Xcls_LeftProps() - { - _this = this; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - this.loading = false; - this.allow_edit = false; - this.main_window = null; - - // set gobject values - this.el.homogeneous = false ; - this.el.hexpand = true; - this.el.vexpand = true; - var child_1 = new Xcls_Box2( _this ); - child_1.ref(); - this.el.append( child_1.el ); - new Xcls_EditProps( _this ); - this.el.append( _this.EditProps.el ); - } - - // user defined functions - public string keySortFormat (string key) { - // listeners first - with 0 - // specials - if (key[0] == '*') { - return "1 " + key; - } - // functions - - var bits = key.split(" "); - - if (key[0] == '|') { - return "2 " + bits[bits.length -1]; - } - // signals - if (key[0] == '@') { - return "3 " + bits[bits.length -1]; - } - - // props - if (key[0] == '#') { - return "4 " + bits[bits.length -1]; - } - // the rest.. - return "5 " + bits[bits.length -1]; - - - - } - public string keyFormat (string val, string type) { - - // Glib.markup_escape_text(val); - - if (type == "listener") { - return "" + - GLib.Markup.escape_text(val) + - ""; - } - // property.. - if (val.length < 1) { - return "--empty--"; - } - - //@ = signal - //$ = property with - //# - object properties - //* = special - // all of these... - display value is last element.. - var ar = val.strip().split(" "); - - - var dval = GLib.Markup.escape_text(ar[ar.length-1]); - - - - - switch(val[0]) { - case '@': // signal // just bold balck? - if (dval[0] == '@') { - dval = dval.substring(1); - } - - return @"@ $dval"; - case '#': // object properties? - if (dval[0] == '#') { - dval = dval.substring(1); - } - return @"$dval"; - case '*': // special - if (dval[0] == '*') { - dval = dval.substring(1); - } - return @"$dval"; - case '$': - if (dval[0] == '$') { - dval = dval.substring(1); - } - return @"$dval"; - case '|': // user defined methods - if (dval[0] == '|') { - dval = dval.substring(1); - } - return @"$dval"; - - - - default: - return dval; - } - - - - } - public void deleteSelected () { - - return; - /* - - Gtk.TreeIter iter; - Gtk.TreeModel mod; - - var s = this.view.el.get_selection(); - s.get_selected(out mod, out iter); - - - GLib.Value gval; - mod.get_value(iter, 0 , out gval); - var prop = (JsRender.NodeProp)gval; - if (prop == null) { - this.load(this.file, this.node); - return; - } - // stop editor after fetching property - otherwise prop is null. - this.stop_editor(); - - - switch(prop.ptype) { - case JsRender.NodePropType.LISTENER: - this.node.listeners.unset(prop.to_index_key()); - break; - - default: - this.node.props.unset(prop.to_index_key()); - break; - } - this.load(this.file, this.node); - - _this.changed(); - */ - } - public void a_addProp (JsRender.NodeProp prop) { - // info includes key, val, skel, etype.. - //console.dump(info); - //type = info.type.toLowerCase(); - //var data = this.toJS(); - - - if (prop.ptype == JsRender.NodePropType.LISTENER) { - if (this.node.listeners.has_key(prop.name)) { - return; - } - this.node.listeners.set(prop.name,prop); - } else { - assert(this.node != null); - assert(this.node.props != null); - if (this.node.props.has_key(prop.to_index_key())) { - return; - } - this.node.props.set(prop.to_index_key(),prop); - } - - - // add a row??? - this.load(this.file, this.node); - - - - - GLib.debug("trying to find new iter"); - - - - } - public void load (JsRender.JsRender file, JsRender.Node? node) - { - // not sure when to initialize this - we should do it on setting main window really. - - this.loading = true; - if (this.view.popover == null) { - this.view.popover = new Xcls_PopoverProperty(); - this.view.popover.mainwindow = _this.main_window; - } - - - if (this.node != null) { - this.node.dupeProps(); // ensures removeall will not do somethign silly - - } - - GLib.debug("load leftprops\n"); - - this.node = node; - this.file = file; - - - this.model.el.remove_all(); - - //this.get('/RightEditor').el.hide(); - if (node ==null) { - return ; - } - node.loadProps(this.model.el); - - - //GLib.debug("clear selection\n"); - - this.loading = false; - this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION); - // clear selection? - //this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key.. - - // this.view.el.get_selection().unselect_all(); - - // _this.keycol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2); - // _this.valcol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2); - - } - public class Xcls_Box2 : Object - { - public Gtk.Box el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Box2(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.hexpand = true; - var child_1 = new Xcls_Label3( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_Button4( _this ); - child_2.ref(); - this.el.append( child_2.el ); - var child_3 = new Xcls_Button5( _this ); - child_3.ref(); - this.el.append( child_3.el ); - var child_4 = new Xcls_Button6( _this ); - child_4.ref(); - this.el.append( child_4.el ); - } - - // user defined functions - } - public class Xcls_Label3 : Object - { - public Gtk.Label el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Label3(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Label( "Add:" ); - - // my vars (dec) - - // set gobject values - this.el.margin_end = 5; - this.el.margin_start = 5; - } - - // user defined functions - } - - public class Xcls_Button4 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_Button4(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.icon_name = "format-justify-left"; - this.el.hexpand = true; - this.el.tooltip_text = "Add Property"; - this.el.label = "Property"; - - //listeners - this.el.clicked.connect( ( ) => { - - _this.main_window.windowstate.showProps( - _this.view.el, - JsRender.NodePropType.PROP - ); - - }); - } - - // user defined functions - } - - public class Xcls_Button5 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_Button5(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.icon_name = "appointment-new"; - this.el.hexpand = true; - this.el.tooltip_text = "Add Event Code"; - this.el.label = "Event"; - - //listeners - this.el.clicked.connect( ( ) => { - - - _this.main_window.windowstate.showProps( - _this.view.el, - JsRender.NodePropType.LISTENER - ); - - - }); - } - - // user defined functions - } - - public class Xcls_Button6 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_Button6(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.icon_name = "list-add"; - this.el.hexpand = true; - this.el.label = "Other"; - new Xcls_AddPropertyPopup( _this ); - - //listeners - this.el.clicked.connect( ( ) => { - //_this.before_edit(); - - - var p = _this.AddPropertyPopup; - - // Gtk.Allocation rect; - //this.el.get_allocation(out rect); - - p.el.set_parent(this.el); - //p.el.set_pointing_to(rect); - p.el.show(); - p.el.set_position(Gtk.PositionType.BOTTOM); - p.el.autohide = true; - return; - - }); - } - - // user defined functions - } - public class Xcls_AddPropertyPopup : Object - { - public Gtk.Popover el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_AddPropertyPopup(Xcls_LeftProps _owner ) - { - _this = _owner; - _this.AddPropertyPopup = this; - this.el = new Gtk.Popover(); - - // my vars (dec) - - // set gobject values - this.el.autohide = true; - var child_1 = new Xcls_Box8( _this ); - this.el.child = child_1.el; - } - - // user defined functions - } - public class Xcls_Box8 : Object - { - public Gtk.Box el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Box8(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - var child_1 = new Xcls_Button9( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_Button10( _this ); - child_2.ref(); - this.el.append( child_2.el ); - var child_3 = new Xcls_Button11( _this ); - child_3.ref(); - this.el.append( child_3.el ); - var child_4 = new Xcls_Button12( _this ); - child_4.ref(); - this.el.append( child_4.el ); - var child_5 = new Xcls_Button13( _this ); - child_5.ref(); - this.el.append( child_5.el ); - var child_6 = new Xcls_Separator14( _this ); - child_6.ref(); - this.el.append( child_6.el ); - var child_7 = new Xcls_Button15( _this ); - child_7.ref(); - this.el.append( child_7.el ); - var child_8 = new Xcls_Button16( _this ); - child_8.ref(); - this.el.append( child_8.el ); - var child_9 = new Xcls_Button17( _this ); - child_9.ref(); - this.el.append( child_9.el ); - var child_10 = new Xcls_Separator18( _this ); - child_10.ref(); - this.el.append( child_10.el ); - var child_11 = new Xcls_Button19( _this ); - child_11.ref(); - this.el.append( child_11.el ); - var child_12 = new Xcls_Button20( _this ); - child_12.ref(); - this.el.append( child_12.el ); - var child_13 = new Xcls_Button21( _this ); - child_13.ref(); - this.el.append( child_13.el ); - var child_14 = new Xcls_Separator22( _this ); - child_14.ref(); - this.el.append( child_14.el ); - var child_15 = new Xcls_Button23( _this ); - child_15.ref(); - this.el.append( child_15.el ); - var child_16 = new Xcls_Button24( _this ); - child_16.ref(); - this.el.append( child_16.el ); - var child_17 = new Xcls_Button25( _this ); - child_17.ref(); - this.el.append( child_17.el ); - } - - // user defined functions - } - public class Xcls_Button9 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Button9(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.tooltip_markup = "Using _this.{ID} will map to this element"; - this.el.label = "id: _this.{ID} (Vala)"; - - //listeners - this.el.clicked.connect( () => { - _this.AddPropertyPopup.el.hide(); - // is this userdef or special?? - var add = new JsRender.NodeProp.prop("id"); - if (_this.node.has_prop_key(add)) { - return; - } - - _this.node.add_prop( add ); - - _this.view.editProp( add ); - - - }); - } - - // user defined functions - } - - public class Xcls_Button10 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Button10(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.tooltip_markup = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element"; - this.el.label = "pack: Pack method (Vala)"; - - //listeners - this.el.clicked.connect( ( ) => { - - - _this.AddPropertyPopup.el.hide(); - // is this userdef or special?? - var add = new JsRender.NodeProp.special("pack", "add"); - if (_this.node.has_prop_key(add)) { - return; - } - - _this.node.add_prop( add ); - - _this.view.editProp( add ); - - - }); - } - - // user defined functions - } - - public class Xcls_Button11 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Button11(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.tooltip_markup = "eg. \n\nnew Clutter.Image.from_file(.....)"; - this.el.label = "ctor: Alterative to default contructor (Vala)"; - - //listeners - this.el.clicked.connect( ( ) => { - - _this.AddPropertyPopup.el.hide(); - // is this userdef or special?? - var add = new JsRender.NodeProp.special("ctor"); - if (_this.node.has_prop_key(add)) { - return; - } - - _this.node.add_prop( add ); - - _this.view.editProp( add ); - - }); - } - - // user defined functions - } - - public class Xcls_Button12 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Button12(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.tooltip_markup = "This code is called after the ctor"; - this.el.label = "init: initialziation code (vala)"; - - //listeners - this.el.clicked.connect( ( ) => { - - _this.AddPropertyPopup.el.hide(); - // is this userdef or special?? - var add = new JsRender.NodeProp.special("init","{\n\n}\n" ) ; - if (_this.node.has_prop_key(add)) { - return; - } - - _this.node.add_prop( add ); - - _this.view.editProp( add ); - }); - } - - // user defined functions - } - - public class Xcls_Button13 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Button13(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.tooltip_markup = "set the cms-id for this element, when converted to javascript, the html value will be wrapped with Pman.Cms.content({cms-id},{original-html})\n"; - this.el.label = "cms-id: (Roo JS/Pman library)"; - - //listeners - this.el.clicked.connect( () => { - - _this.AddPropertyPopup.el.hide(); - // is this userdef or special?? - var add = new JsRender.NodeProp.prop("cms-id","string", "" ) ; - if (_this.node.has_prop_key(add)) { - return; - } - - _this.node.add_prop( add ); - - _this.view.editProp( add ); - - }); - } - - // user defined functions - } - - public class Xcls_Separator14 : Object - { - public Gtk.Separator el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Separator14(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - public class Xcls_Button15 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Button15(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.tooltip_markup = "Add a user defined string property"; - this.el.label = "String"; - - //listeners - this.el.clicked.connect( (self) => { - _this.AddPropertyPopup.el.hide(); - _this.view.popover.show( - _this.view.el, - _this.node, - new JsRender.NodeProp.prop("", "string", "") , - -1, - true - ); - - }); - } - - // user defined functions - } - - public class Xcls_Button16 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Button16(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.tooltip_markup = "Add a user defined number property"; - this.el.label = "Number"; - - //listeners - this.el.clicked.connect( ( ) =>{ - _this.AddPropertyPopup.el.hide(); - - _this.view.popover.show( - _this.view.el, - _this.node, - new JsRender.NodeProp.prop("", "int", "0") , - -1, - true - ); - - }); - } - - // user defined functions - } - - public class Xcls_Button17 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Button17(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.tooltip_markup = "Add a user defined boolean property"; - this.el.label = "Boolean"; - - //listeners - this.el.clicked.connect( ( ) =>{ - - _this.AddPropertyPopup.el.hide(); - _this.view.popover.show( - _this.view.el, - _this.node, - new JsRender.NodeProp.prop("", "bool", "true") , - -1, - true - ); - - }); - } - - // user defined functions - } - - public class Xcls_Separator18 : Object - { - public Gtk.Separator el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Separator18(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - public class Xcls_Button19 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Button19(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.tooltip_markup = "Add a user function boolean property"; - this.el.label = "Javascript Function"; - - //listeners - this.el.clicked.connect( ( ) =>{ - _this.AddPropertyPopup.el.hide(); - _this.view.popover.show( - _this.view.el, - _this.node, - new JsRender.NodeProp.jsmethod("") , - -1, - true - ); - - - }); - } - - // user defined functions - } - - public class Xcls_Button20 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Button20(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.tooltip_markup = "Add a user function boolean property"; - this.el.label = "Vala Method"; - - //listeners - this.el.clicked.connect( ( ) =>{ - _this.AddPropertyPopup.el.hide(); - _this.view.popover.show( - _this.view.el, - _this.node, - new JsRender.NodeProp.valamethod("") , - -1, - true - ); - }); - } - - // user defined functions - } - - public class Xcls_Button21 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Button21(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.tooltip_markup = "Add a vala signal"; - this.el.label = "Vala Signal"; - - //listeners - this.el.clicked.connect( ( ) =>{ - _this.AddPropertyPopup.el.hide(); - _this.view.popover.show( - _this.view.el, - _this.node, - new JsRender.NodeProp.sig("" ) , - -1, - true - ); - }); - } - - // user defined functions - } - - public class Xcls_Separator22 : Object - { - public Gtk.Separator el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Separator22(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - public class Xcls_Button23 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Button23(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.tooltip_markup = "Add a flexy if (for HTML templates)"; - this.el.label = "Flexy - If"; - - //listeners - this.el.clicked.connect( ( ) =>{ - _this.AddPropertyPopup.el.hide(); - _this.view.popover.show( - _this.view.el, - _this.node, - new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") , - -1, - true - ); - - - }); - } - - // user defined functions - } - - public class Xcls_Button24 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; +static Xcls_LeftProps _LeftProps; + +public class Xcls_LeftProps : Object +{ + public Gtk.Box el; + private Xcls_LeftProps _this; + + public static Xcls_LeftProps singleton() + { + if (_LeftProps == null) { + _LeftProps= new Xcls_LeftProps(); + } + return _LeftProps; + } + public Xcls_AddPropertyPopup AddPropertyPopup; + public Xcls_EditProps EditProps; + public Xcls_view view; + public Xcls_deletemenu deletemenu; + public Xcls_selmodel selmodel; + public Xcls_model model; + public Xcls_keycol keycol; + public Xcls_valcol valcol; + public Xcls_ContextMenu ContextMenu; + + // my vars (def) + public bool loading; + public bool allow_edit; + public signal void show_add_props (string type); + public signal bool stop_editor (); + public Xcls_MainWindow main_window; + public signal void changed (); + public JsRender.JsRender file; + public JsRender.Node node; + public signal void show_editor (JsRender.JsRender file, JsRender.Node node, JsRender.NodeProp prop); + + // ctor + public Xcls_LeftProps() + { + _this = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + this.loading = false; + this.allow_edit = false; + this.main_window = null; + + // set gobject values + this.el.homogeneous = false ; + this.el.hexpand = true; + this.el.vexpand = true; + var child_1 = new Xcls_Box2( _this ); + child_1.ref(); + this.el.append( child_1.el ); + new Xcls_EditProps( _this ); + this.el.append( _this.EditProps.el ); + } + + // user defined functions + public string keySortFormat (string key) { + // listeners first - with 0 + // specials + if (key[0] == '*') { + return "1 " + key; + } + // functions + + var bits = key.split(" "); + + if (key[0] == '|') { + return "2 " + bits[bits.length -1]; + } + // signals + if (key[0] == '@') { + return "3 " + bits[bits.length -1]; + } + + // props + if (key[0] == '#') { + return "4 " + bits[bits.length -1]; + } + // the rest.. + return "5 " + bits[bits.length -1]; + + + + } + public string keyFormat (string val, string type) { + + // Glib.markup_escape_text(val); + + if (type == "listener") { + return "" + + GLib.Markup.escape_text(val) + + ""; + } + // property.. + if (val.length < 1) { + return "--empty--"; + } + + //@ = signal + //$ = property with + //# - object properties + //* = special + // all of these... - display value is last element.. + var ar = val.strip().split(" "); + + + var dval = GLib.Markup.escape_text(ar[ar.length-1]); + + + + + switch(val[0]) { + case '@': // signal // just bold balck? + if (dval[0] == '@') { + dval = dval.substring(1); + } + + return @"@ $dval"; + case '#': // object properties? + if (dval[0] == '#') { + dval = dval.substring(1); + } + return @"$dval"; + case '*': // special + if (dval[0] == '*') { + dval = dval.substring(1); + } + return @"$dval"; + case '$': + if (dval[0] == '$') { + dval = dval.substring(1); + } + return @"$dval"; + case '|': // user defined methods + if (dval[0] == '|') { + dval = dval.substring(1); + } + return @"$dval"; + + + + default: + return dval; + } + + + + } + public void deleteSelected () { + + return; + /* + + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + var s = this.view.el.get_selection(); + s.get_selected(out mod, out iter); + + + GLib.Value gval; + mod.get_value(iter, 0 , out gval); + var prop = (JsRender.NodeProp)gval; + if (prop == null) { + this.load(this.file, this.node); + return; + } + // stop editor after fetching property - otherwise prop is null. + this.stop_editor(); + + + switch(prop.ptype) { + case JsRender.NodePropType.LISTENER: + this.node.listeners.unset(prop.to_index_key()); + break; + + default: + this.node.props.unset(prop.to_index_key()); + break; + } + this.load(this.file, this.node); + + _this.changed(); + */ + } + public void a_addProp (JsRender.NodeProp prop) { + // info includes key, val, skel, etype.. + //console.dump(info); + //type = info.type.toLowerCase(); + //var data = this.toJS(); + + + if (prop.ptype == JsRender.NodePropType.LISTENER) { + if (this.node.listeners.has_key(prop.name)) { + return; + } + this.node.listeners.set(prop.name,prop); + } else { + assert(this.node != null); + assert(this.node.props != null); + if (this.node.props.has_key(prop.to_index_key())) { + return; + } + this.node.props.set(prop.to_index_key(),prop); + } + + + // add a row??? + this.load(this.file, this.node); + + + + + GLib.debug("trying to find new iter"); + + + + } + public void load (JsRender.JsRender file, JsRender.Node? node) + { + // not sure when to initialize this - we should do it on setting main window really. + + this.loading = true; + if (this.view.popover == null) { + this.view.popover = new Xcls_PopoverProperty(); + this.view.popover.mainwindow = _this.main_window; + } + + + if (this.node != null) { + this.node.dupeProps(); // ensures removeall will not do somethign silly + + } + + GLib.debug("load leftprops\n"); + + this.node = node; + this.file = file; + + + this.model.el.remove_all(); + + //this.get('/RightEditor').el.hide(); + if (node ==null) { + return ; + } + node.loadProps(this.model.el); + + + //GLib.debug("clear selection\n"); + + this.loading = false; + this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION); + // clear selection? + //this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key.. + + // this.view.el.get_selection().unselect_all(); + + // _this.keycol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2); + // _this.valcol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2); + + } + public class Xcls_Box2 : Object + { + public Gtk.Box el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Box2(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.hexpand = true; + var child_1 = new Xcls_Label3( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_Button4( _this ); + child_2.ref(); + this.el.append( child_2.el ); + var child_3 = new Xcls_Button5( _this ); + child_3.ref(); + this.el.append( child_3.el ); + var child_4 = new Xcls_Button6( _this ); + child_4.ref(); + this.el.append( child_4.el ); + } + + // user defined functions + } + public class Xcls_Label3 : Object + { + public Gtk.Label el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Label3(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Add:" ); + + // my vars (dec) + + // set gobject values + this.el.margin_end = 5; + this.el.margin_start = 5; + } + + // user defined functions + } + + public class Xcls_Button4 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + public bool always_show_image; + + // ctor + public Xcls_Button4(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + this.always_show_image = true; + + // set gobject values + this.el.icon_name = "format-justify-left"; + this.el.hexpand = true; + this.el.tooltip_text = "Add Property"; + this.el.label = "Property"; + + //listeners + this.el.clicked.connect( ( ) => { + + _this.main_window.windowstate.showProps( + _this.view.el, + JsRender.NodePropType.PROP + ); + + }); + } + + // user defined functions + } + + public class Xcls_Button5 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + public bool always_show_image; + + // ctor + public Xcls_Button5(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + this.always_show_image = true; + + // set gobject values + this.el.icon_name = "appointment-new"; + this.el.hexpand = true; + this.el.tooltip_text = "Add Event Code"; + this.el.label = "Event"; + + //listeners + this.el.clicked.connect( ( ) => { + + + _this.main_window.windowstate.showProps( + _this.view.el, + JsRender.NodePropType.LISTENER + ); + + + }); + } + + // user defined functions + } + + public class Xcls_Button6 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + public bool always_show_image; + + // ctor + public Xcls_Button6(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + this.always_show_image = true; + + // set gobject values + this.el.icon_name = "list-add"; + this.el.hexpand = true; + this.el.label = "Other"; + new Xcls_AddPropertyPopup( _this ); + + //listeners + this.el.clicked.connect( ( ) => { + //_this.before_edit(); + + + var p = _this.AddPropertyPopup; + + // Gtk.Allocation rect; + //this.el.get_allocation(out rect); + if (p.el.parent == null) { + p.el.set_parent(this.el); + } + //p.el.set_pointing_to(rect); + p.el.show(); + p.el.set_position(Gtk.PositionType.BOTTOM); + p.el.autohide = true; + return; + + }); + } + + // user defined functions + } + public class Xcls_AddPropertyPopup : Object + { + public Gtk.Popover el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_AddPropertyPopup(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.AddPropertyPopup = this; + this.el = new Gtk.Popover(); + + // my vars (dec) + + // set gobject values + this.el.autohide = true; + var child_1 = new Xcls_Box8( _this ); + this.el.child = child_1.el; + } + + // user defined functions + } + public class Xcls_Box8 : Object + { + public Gtk.Box el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Box8(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Button9( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_Button10( _this ); + child_2.ref(); + this.el.append( child_2.el ); + var child_3 = new Xcls_Button11( _this ); + child_3.ref(); + this.el.append( child_3.el ); + var child_4 = new Xcls_Button12( _this ); + child_4.ref(); + this.el.append( child_4.el ); + var child_5 = new Xcls_Button13( _this ); + child_5.ref(); + this.el.append( child_5.el ); + var child_6 = new Xcls_Separator14( _this ); + child_6.ref(); + this.el.append( child_6.el ); + var child_7 = new Xcls_Button15( _this ); + child_7.ref(); + this.el.append( child_7.el ); + var child_8 = new Xcls_Button16( _this ); + child_8.ref(); + this.el.append( child_8.el ); + var child_9 = new Xcls_Button17( _this ); + child_9.ref(); + this.el.append( child_9.el ); + var child_10 = new Xcls_Separator18( _this ); + child_10.ref(); + this.el.append( child_10.el ); + var child_11 = new Xcls_Button19( _this ); + child_11.ref(); + this.el.append( child_11.el ); + var child_12 = new Xcls_Button20( _this ); + child_12.ref(); + this.el.append( child_12.el ); + var child_13 = new Xcls_Button21( _this ); + child_13.ref(); + this.el.append( child_13.el ); + var child_14 = new Xcls_Separator22( _this ); + child_14.ref(); + this.el.append( child_14.el ); + var child_15 = new Xcls_Button23( _this ); + child_15.ref(); + this.el.append( child_15.el ); + var child_16 = new Xcls_Button24( _this ); + child_16.ref(); + this.el.append( child_16.el ); + var child_17 = new Xcls_Button25( _this ); + child_17.ref(); + this.el.append( child_17.el ); + } + + // user defined functions + } + public class Xcls_Button9 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button9(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Using _this.{ID} will map to this element"; + this.el.label = "id: _this.{ID} (Vala)"; + + //listeners + this.el.clicked.connect( () => { + _this.AddPropertyPopup.el.hide(); + // is this userdef or special?? + var add = new JsRender.NodeProp.prop("id"); + if (_this.node.has_prop_key(add)) { + return; + } + + _this.node.add_prop( add ); + + _this.view.editProp( add ); + + + }); + } + + // user defined functions + } + + public class Xcls_Button10 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button10(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element"; + this.el.label = "pack: Pack method (Vala)"; + + //listeners + this.el.clicked.connect( ( ) => { + + + _this.AddPropertyPopup.el.hide(); + // is this userdef or special?? + var add = new JsRender.NodeProp.special("pack", "add"); + if (_this.node.has_prop_key(add)) { + return; + } + + _this.node.add_prop( add ); + + _this.view.editProp( add ); + + + }); + } + + // user defined functions + } + + public class Xcls_Button11 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button11(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "eg. \n\nnew Clutter.Image.from_file(.....)"; + this.el.label = "ctor: Alterative to default contructor (Vala)"; + + //listeners + this.el.clicked.connect( ( ) => { + + _this.AddPropertyPopup.el.hide(); + // is this userdef or special?? + var add = new JsRender.NodeProp.special("ctor"); + if (_this.node.has_prop_key(add)) { + return; + } + + _this.node.add_prop( add ); + + _this.view.editProp( add ); + + }); + } + + // user defined functions + } + + public class Xcls_Button12 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button12(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "This code is called after the ctor"; + this.el.label = "init: initialziation code (vala)"; + + //listeners + this.el.clicked.connect( ( ) => { + + _this.AddPropertyPopup.el.hide(); + // is this userdef or special?? + var add = new JsRender.NodeProp.special("init","{\n\n}\n" ) ; + if (_this.node.has_prop_key(add)) { + return; + } + + _this.node.add_prop( add ); + + _this.view.editProp( add ); + }); + } + + // user defined functions + } + + public class Xcls_Button13 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button13(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "set the cms-id for this element, when converted to javascript, the html value will be wrapped with Pman.Cms.content({cms-id},{original-html})\n"; + this.el.label = "cms-id: (Roo JS/Pman library)"; + + //listeners + this.el.clicked.connect( () => { + + _this.AddPropertyPopup.el.hide(); + // is this userdef or special?? + var add = new JsRender.NodeProp.prop("cms-id","string", "" ) ; + if (_this.node.has_prop_key(add)) { + return; + } + + _this.node.add_prop( add ); + + _this.view.editProp( add ); + + }); + } + + // user defined functions + } + + public class Xcls_Separator14 : Object + { + public Gtk.Separator el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Separator14(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_Button15 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button15(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a user defined string property"; + this.el.label = "String"; + + //listeners + this.el.clicked.connect( (self) => { + _this.AddPropertyPopup.el.hide(); + _this.view.popover.show( + _this.view.el, + _this.node, + new JsRender.NodeProp.prop("", "string", "") , + -1, + true + ); + + }); + } + + // user defined functions + } + + public class Xcls_Button16 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button16(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a user defined number property"; + this.el.label = "Number"; + + //listeners + this.el.clicked.connect( ( ) =>{ + _this.AddPropertyPopup.el.hide(); + + _this.view.popover.show( + _this.view.el, + _this.node, + new JsRender.NodeProp.prop("", "int", "0") , + -1, + true + ); + + }); + } + + // user defined functions + } + + public class Xcls_Button17 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button17(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a user defined boolean property"; + this.el.label = "Boolean"; + + //listeners + this.el.clicked.connect( ( ) =>{ + + _this.AddPropertyPopup.el.hide(); + _this.view.popover.show( + _this.view.el, + _this.node, + new JsRender.NodeProp.prop("", "bool", "true") , + -1, + true + ); + + }); + } + + // user defined functions + } + + public class Xcls_Separator18 : Object + { + public Gtk.Separator el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Separator18(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_Button19 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button19(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a user function boolean property"; + this.el.label = "Javascript Function"; + + //listeners + this.el.clicked.connect( ( ) =>{ + _this.AddPropertyPopup.el.hide(); + _this.view.popover.show( + _this.view.el, + _this.node, + new JsRender.NodeProp.jsmethod("") , + -1, + true + ); + + + }); + } + + // user defined functions + } + + public class Xcls_Button20 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button20(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a user function boolean property"; + this.el.label = "Vala Method"; + + //listeners + this.el.clicked.connect( ( ) =>{ + _this.AddPropertyPopup.el.hide(); + _this.view.popover.show( + _this.view.el, + _this.node, + new JsRender.NodeProp.valamethod("") , + -1, + true + ); + }); + } + + // user defined functions + } + + public class Xcls_Button21 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button21(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a vala signal"; + this.el.label = "Vala Signal"; + + //listeners + this.el.clicked.connect( ( ) =>{ + _this.AddPropertyPopup.el.hide(); + _this.view.popover.show( + _this.view.el, + _this.node, + new JsRender.NodeProp.sig("" ) , + -1, + true + ); + }); + } + + // user defined functions + } + + public class Xcls_Separator22 : Object + { + public Gtk.Separator el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Separator22(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_Button23 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button23(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a flexy if (for HTML templates)"; + this.el.label = "Flexy - If"; + + //listeners + this.el.clicked.connect( ( ) =>{ + _this.AddPropertyPopup.el.hide(); + _this.view.popover.show( + _this.view.el, + _this.node, + new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") , + -1, + true + ); + + + }); + } + + // user defined functions + } + + public class Xcls_Button24 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_Button24(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.tooltip_markup = "Add a flexy include (for HTML templates)"; - this.el.label = "Flexy - Include"; - - //listeners - this.el.clicked.connect( ( ) =>{ - _this.AddPropertyPopup.el.hide(); - _this.view.popover.show( - _this.view.el, - _this.node, - new JsRender.NodeProp.prop("flexy:include", "string", "name_of_file.html") , - -1, - true - ); - - - }); - } + // ctor + public Xcls_Button24(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a flexy include (for HTML templates)"; + this.el.label = "Flexy - Include"; + + //listeners + this.el.clicked.connect( ( ) =>{ + _this.AddPropertyPopup.el.hide(); + _this.view.popover.show( + _this.view.el, + _this.node, + new JsRender.NodeProp.prop("flexy:include", "string", "name_of_file.html") , + -1, + true + ); + + + }); + } - // user defined functions - } - - public class Xcls_Button25 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Button25(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.tooltip_markup = "Add a flexy include (for HTML templates)"; - this.el.label = "Flexy - Foreach"; - - //listeners - this.el.clicked.connect( ( ) =>{ - _this.AddPropertyPopup.el.hide(); - _this.view.popover.show( - _this.view.el, - _this.node, - new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") , - -1, - true - ); - - }); - } - - // user defined functions - } - - - - - - public class Xcls_EditProps : Object - { - public Gtk.ScrolledWindow el; - private Xcls_LeftProps _this; - - - // my vars (def) - public bool editing; - - // ctor - public Xcls_EditProps(Xcls_LeftProps _owner ) - { - _this = _owner; - _this.EditProps = this; - this.el = new Gtk.ScrolledWindow(); - - // my vars (dec) - this.editing = false; - - // set gobject values - this.el.hexpand = true; - this.el.vexpand = true; - new Xcls_view( _this ); - this.el.set_child ( _this.view.el ); - - // init method - - { - - this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); - } - } - - // user defined functions - } - public class Xcls_view : Object - { - public Gtk.ColumnView el; - private Xcls_LeftProps _this; - - - // my vars (def) - public Gtk.CssProvider css; - public Xcls_PopoverProperty popover; - - // ctor - public Xcls_view(Xcls_LeftProps _owner ) - { - _this = _owner; - _this.view = this; - new Xcls_selmodel( _this ); - this.el = new Gtk.ColumnView( _this.selmodel.el ); - - // my vars (dec) - this.popover = null; - - // set gobject values - this.el.name = "leftprops-view"; - this.el.single_click_activate = false; - this.el.hexpand = true; - this.el.vexpand = true; - this.el.show_row_separators = true; - new Xcls_deletemenu( _this ); - var child_3 = new Xcls_GestureClick31( _this ); - child_3.ref(); - this.el.add_controller( child_3.el ); - var child_4 = new Xcls_GestureClick32( _this ); - child_4.ref(); - this.el.add_controller( child_4.el ); - new Xcls_keycol( _this ); - this.el.append_column ( _this.keycol.el ); - new Xcls_valcol( _this ); - this.el.append_column ( _this.valcol.el ); - new Xcls_ContextMenu( _this ); - - // init method - - { - - this.css = new Gtk.CssProvider(); - - this.css.load_from_string(" - #leftprops-view { font-size: 12px;} - - #leftprops-view dropdown button { - min-height: 16px; - outline-offset : 0; - } - #leftprops-view cell dropdown label { - padding-top:0px; - padding-bottom:0px; - } - #leftprops-view cell { - padding-top:2px; - padding-bottom:2px; - } - #leftprops-view cell label, #leftprops-view cell editablelable { - padding-top:4px; - padding-bottom:4px; - }"); - - Gtk.StyleContext.add_provider_for_display( - this.el.get_display(), - this.css, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - ); - - - } - } - - // user defined functions - public Gtk.Widget? getWidgetAtRow (uint row) { - /* - - from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 - var colview = gesture.widget; - var line_no = check_list_widget(colview, x,y); - if (line_no > -1) { - var item = colview.model.get_item(line_no); - - } - */ - GLib.debug("Get Widget At Row %d", (int)row); - var child = this.el.get_first_child(); - var line_no = -1; - var reading_header = true; - - while (child != null) { - GLib.debug("Got %s", child.get_type().name()); - if (reading_header) { - - - if (child.get_type().name() != "GtkColumnListView") { - child = child.get_next_sibling(); - continue; - } - child = child.get_first_child(); - reading_header = false; - } - if (child.get_type().name() != "GtkColumnViewRowWidget") { - child = child.get_next_sibling(); - continue; - } - line_no++; - if (line_no == row) { - GLib.debug("Returning widget %s", child.get_type().name()); - return (Gtk.Widget)child; - } - child = child.get_next_sibling(); - } - GLib.debug("Rturning null"); - return null; - - } - public void editProp (JsRender.NodeProp prop) - { - var sm = _this.selmodel.el; - - var sr = -1; - GLib.debug("finding node"); - _this.selmodel.selectProp(prop); - - for (var i = 0 ; i < sm.n_items; i++) { - var r = (JsRender.NodeProp)sm.get_item(i); - if (r.equals(prop)) { - sr = i; - break; - } - } - if (sr < 0) { - GLib.debug("finding node - cant find it"); - - return; - } - var r = this.getWidgetAtRow(sr); - GLib.debug("r = %s", r.get_type().name()); - var ca = r.get_first_child(); - var ll = (Gtk.Label)ca.get_first_child(); - var cb = ca.get_next_sibling(); - var b = cb.get_first_child(); - var e = (Gtk.Entry) b.get_first_child(); - var l = (Gtk.Label) e.get_next_sibling(); - var d = (Gtk.DropDown) l.get_next_sibling(); - - GLib.debug("row key = %s", ll.label); - if (e.get_visible()) { - _this.stop_editor(); - e.grab_focus_without_selecting(); - return; - } - if (d.get_visible()) { - _this.stop_editor(); - d.activate(); - return; - } - if (l.get_visible()) { - _this.stop_editor(); - _this.show_editor(_this.file, prop.parent, prop); - - } - - - - //gtkcolumnviewrowwidget - // cell widet - // cell widget - // box - // entry / label / dropdown - - - } - public int getColAt (double x, double y) { - /* - - from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 - - */ - //Gtk.Allocation alloc = { 0, 0, 0, 0 }; - var child = this.el.get_first_child(); - - var col = 0; - var offx = 0; - while (child != null) { - GLib.debug("Got %s", child.get_type().name()); - - if (child.get_type().name() == "GtkColumnViewRowWidget") { - child = child.get_first_child(); - continue; - } - - //child.get_allocation(out alloc); - if (x < (child.get_width() + offx)) { - return col; - } - offx += child.get_width(); - col++; - child = child.get_next_sibling(); - } - - - return -1; - - } - public int getRowAt (double x, double in_y, out string pos) { - - - - - /* - - from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 - var colview = gesture.widget; - var line_no = check_list_widget(colview, x,y); - if (line_no > -1) { - var item = colview.model.get_item(line_no); - - } - */ - - - //GLib.debug("offset = %d y = %d", (int) voff, (int) in_y); - var y = in_y + _this.EditProps.el.vadjustment.value; - var child = this.el.get_first_child(); - //Gtk.Allocation alloc = { 0, 0, 0, 0 }; - var line_no = -1; - var reading_header = true; - var real_y = 0; - var header_height = 0; - pos = "none"; - var h = 0; - while (child != null) { - //GLib.debug("Got %s", child.get_type().name()); - if (reading_header) { - - - if (child.get_type().name() != "GtkColumnListView") { - h += child.get_height(); - child = child.get_next_sibling(); - continue; - } - // should be columnlistview - child = child.get_first_child(); - GLib.debug("header height=%d", h); - header_height = h; - - reading_header = false; - - } - - if (child.get_type().name() != "GtkColumnViewRowWidget") { - child = child.get_next_sibling(); - continue; - } - - if (y < header_height) { - return -1; - } - - line_no++; - var hh = child.get_height(); - //child.get_allocation(out alloc); - //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height); - //GLib.debug("row %d y= %d %s", line_no, (int) (header_height + alloc.y), - - // child.visible ? "VIS" : "hidden"); - - if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) { - if (y > ( header_height + real_y + (hh * 0.8))) { - pos = "below"; - } else if (y > ( header_height + real_y + (hh * 0.2))) { - pos = "over"; - } else { - pos = "above"; - } - GLib.debug("getRowAt return : %d, %s", line_no, pos); - return line_no; - } - - - if (real_y + hh > y) { - return -1; - } - real_y += hh; - child = child.get_next_sibling(); - } - return -1; - - } - } - public class Xcls_deletemenu : Object - { - public Gtk.Popover el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_deletemenu(Xcls_LeftProps _owner ) - { - _this = _owner; - _this.deletemenu = this; - this.el = new Gtk.Popover(); - - // my vars (dec) - - // set gobject values - var child_1 = new Xcls_Box29( _this ); - this.el.child = child_1.el; - } - - // user defined functions - } - public class Xcls_Box29 : Object - { - public Gtk.Box el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Box29(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - var child_1 = new Xcls_Button30( _this ); - child_1.ref(); - this.el.append( child_1.el ); - } - - // user defined functions - } - public class Xcls_Button30 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Button30(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.label = "Delete"; - - //listeners - this.el.clicked.connect( ( ) => { - - - var n = (JsRender.NodeProp) _this.selmodel.el.selected_item; - - _this.deletemenu.el.hide(); - _this.node.remove_prop(n); - }); - } - - // user defined functions - } - - - - public class Xcls_GestureClick31 : Object - { - public Gtk.GestureClick el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_GestureClick31(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.GestureClick(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.pressed.connect( (n_press, in_x, in_y) => { - - GLib.debug("Prssed %d", (int) this.el.get_current_button()); - - var col = _this.view.getColAt(in_x, in_y); - if (col != 0) { - return; - } - string pos; - var row = _this.view.getRowAt(in_x, in_y, out pos); - - if (row < 0) { - return; - - } - GLib.debug("hit row %d", row); - var prop = _this.selmodel.getPropAt(row); - _this.selmodel.selectProp(prop); - - //var point_at = _this.view.getWidgetAtRow(row); - - // need to shift down, as ev.y does not inclucde header apparently.. - // or popover might be trying to do a central? - // _this.view.editPropertyDetails(prop, (int) in_y + 12); - _this.stop_editor(); - _this.view.popover.show( - _this.view.el, - _this.node, prop, - (int)in_y); - - - - }); - } - - // user defined functions - } - - public class Xcls_GestureClick32 : Object - { - public Gtk.GestureClick el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_GestureClick32(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.GestureClick(); - - // my vars (dec) - - // set gobject values - this.el.button = 3; - - //listeners - this.el.pressed.connect( (n_press, in_x, in_y) => { - - - - string pos; - var row = _this.view.getRowAt(in_x, in_y, out pos); - - if (row < 0) { - return; - - } - - _this.stop_editor(); - GLib.debug("hit row %d", row); - var prop = _this.selmodel.getPropAt(row); - _this.selmodel.selectProp(prop); - - - - GLib.debug("Prssed %d", (int) this.el.get_current_button()); - //_this.deletemenu.el.set_parent(_this.view.el); - _this.deletemenu.el.set_parent(_this.main_window.el); - - - - _this.deletemenu.el.set_offset( - (int)in_x - _this.view.el.get_width() , - (int)in_y - _this.view.el.get_height() - ); - _this.deletemenu.el.set_position(Gtk.PositionType.BOTTOM); - _this.deletemenu.el.popup(); - - }); - } - - // user defined functions - } - - public class Xcls_selmodel : Object - { - public Gtk.SingleSelection el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_selmodel(Xcls_LeftProps _owner ) - { - _this = _owner; - _this.selmodel = this; - new Xcls_model( _this ); - this.el = new Gtk.SingleSelection( _this.model.el ); - - // my vars (dec) - - // set gobject values - this.el.can_unselect = true; - } - - // user defined functions - public void startEditing (JsRender.NodeProp prop) { - // should we call select?? - caller does int (from windowstate) - - } - public void selectProp (JsRender.NodeProp prop) { - for (var i = 0 ; i < this.el.n_items; i++) { - var r = (JsRender.NodeProp)this.el.get_item(i); - if (r.equals(prop)) { - this.el.selected = i; - return; - } - } - - } - public JsRender.NodeProp getPropAt (uint row) { - - return (JsRender.NodeProp) this.el.get_item(row); - - - } - } - public class Xcls_model : Object - { - public GLib.ListStore el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_model(Xcls_LeftProps _owner ) - { - _this = _owner; - _this.model = this; - this.el = new GLib.ListStore(typeof(JsRender.NodeProp)); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - - public class Xcls_keycol : Object - { - public Gtk.ColumnViewColumn el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_keycol(Xcls_LeftProps _owner ) - { - _this = _owner; - _this.keycol = this; - var child_1 = new Xcls_SignalListItemFactory36( _this ); - child_1.ref(); - this.el = new Gtk.ColumnViewColumn( "Property", child_1.el ); - - // my vars (dec) - - // set gobject values - this.el.id = "keycol"; - this.el.expand = true; - this.el.resizable = true; - } - - // user defined functions - } - public class Xcls_SignalListItemFactory36 : Object - { - public Gtk.SignalListItemFactory el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_SignalListItemFactory36(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.SignalListItemFactory(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.setup.connect( (listitem) => { - var lbl = new Gtk.Label(""); - ((Gtk.ListItem)listitem).set_child(lbl); - lbl.justify = Gtk.Justification.LEFT; - lbl.xalign = 1; - lbl.use_markup = true; - lbl.ellipsize = Pango.EllipsizeMode.START; - /*lbl.changed.connect(() => { - // notify and save the changed value... - //var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem.get_item()); - - //prop.val = lbl.text; - //_this.updateIter(iter,prop); - _this.changed(); - }); - */ - ((Gtk.ListItem)listitem).activatable = true; - }); - this.el.bind.connect( (listitem) => { - var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child(); - var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item(); - - - item.bind_property("to_display_name_prop", - lb, "label", - GLib.BindingFlags.SYNC_CREATE); - item.bind_property("to_tooltip_name_prop", - lb, "tooltip_markup", - GLib.BindingFlags.SYNC_CREATE); - // was item (1) in old layout - - - }); - } - - // user defined functions - } - - - public class Xcls_valcol : Object - { - public Gtk.ColumnViewColumn el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_valcol(Xcls_LeftProps _owner ) - { - _this = _owner; - _this.valcol = this; - var child_1 = new Xcls_SignalListItemFactory38( _this ); - child_1.ref(); - this.el = new Gtk.ColumnViewColumn( "Value", child_1.el ); - - // my vars (dec) - - // set gobject values - this.el.id = "valcol"; - this.el.expand = true; - this.el.resizable = true; - } - - // user defined functions - } - public class Xcls_SignalListItemFactory38 : Object - { - public Gtk.SignalListItemFactory el; - private Xcls_LeftProps _this; - - - // my vars (def) - public bool is_setting; - - // ctor - public Xcls_SignalListItemFactory38(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.SignalListItemFactory(); - - // my vars (dec) - this.is_setting = false; - - // set gobject values - - //listeners - this.el.setup.connect( (listitem) => { - var hb = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0); - var elbl = new Gtk.EditableLabel(""); - elbl.hexpand = true; - hb.append(elbl); - var lbl = new Gtk.Label(""); - hb.append(lbl); - lbl.hexpand = true; - lbl.use_markup = true; - lbl.xalign =0; - lbl.ellipsize = Pango.EllipsizeMode.END; - var cb = new Gtk.DropDown(new Gtk.StringList({}), null); - cb.hexpand = true; - - hb.append(cb); - ((Gtk.ListItem)listitem).set_child(hb); - - var ef = new Gtk.EventControllerFocus(); - ef.enter.connect(() => { - _this.stop_editor(); - var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item(); - _this.selmodel.selectProp(prop); - }); - elbl.add_controller(ef); - - - // dropdown??? - stop editing, and highliht node - var tb = (Gtk.ToggleButton) cb.get_first_child(); - tb.clicked.connect(() => { - var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item(); - - _this.stop_editor(); - _this.selmodel.selectProp(prop); - - }); - elbl.changed.connect(() => { - // notify and save the changed value... - - //_this.updateIter(iter,prop); - // this should happen automatically - - if (!_this.loading && !this.is_setting) { - var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item(); - - - prop.val = elbl.text; - GLib.debug("calling changed"); - _this.changed(); - - } - - }); - - - cb.notify["selected"].connect(() => { - // dropdown selection changed. - - - - //_this.updateIter(iter,prop); - if (!_this.loading && !this.is_setting) { - var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item(); - var model = (Gtk.StringList)cb.model; - prop.val = model.get_string(cb.selected); - GLib.debug("property set to %s", prop.val); - GLib.debug("calling changed"); - _this.changed(); - - } - - - }); - var gc = new Gtk.GestureClick(); - lbl.add_controller(gc); - gc.pressed.connect(() => { - var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item(); - _this.stop_editor(); - _this.show_editor(_this.file, prop.parent, prop); - }); - - - - }); - this.el.bind.connect( (listitem) => { - this.is_setting = true; - - - var bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child(); - - - - - var elbl = (Gtk.EditableLabel)bx.get_first_child(); - var lbl = (Gtk.Label) elbl.get_next_sibling(); - var cb = (Gtk.DropDown) lbl.get_next_sibling(); - // decide if it's a combo or editable text.. - var model = (Gtk.StringList) cb.model; - - elbl.hide(); - lbl.hide(); - cb.hide(); - - var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item(); - //GLib.debug("prop = %s", prop.get_type().name()); - //GLib.debug("prop.val = %s", prop.val); - //GLib.debug("prop.key = %s", prop.to_display_name()); - - var use_textarea = prop.useTextArea(); - - - var pal = _this.file.project.palete; - - string[] opts; - var has_opts = pal.typeOptions(_this.node.fqn(), prop.name, prop.rtype, out opts); - - if (!has_opts && prop.ptype == JsRender.NodePropType.RAW) { - use_textarea = true; - } - - - if (use_textarea) { - prop.bind_property("val_short", - lbl, "label", - GLib.BindingFlags.SYNC_CREATE); - prop.bind_property("val_tooltip", - lbl, "tooltip_markup", - GLib.BindingFlags.SYNC_CREATE); - lbl.show(); - this.is_setting = false; - return; - - } - - - - - - // others... - fill in options for true/false? - // GLib.debug (ktype.up()); - if (has_opts) { - - while(model.get_n_items() > 0) { - model.remove(0); - } - cb.show(); - // can not remove - hopefully always empty. - var sel = -1; - for(var i = 0; i < opts.length; i ++) { - model.append( opts[i]); - // not sure this is a great idea... - if (opts[i].down() == prop.val.down()) { - sel = i; - } - } - GLib.debug("Set selected item to %d", sel); - cb.set_selected(sel > -1 ? sel : Gtk.INVALID_LIST_POSITION); - this.is_setting = false; - return ; - } - - // see if type is a Enum. - // triggers a changed event - - elbl.set_text(prop.val); - - elbl.show(); - this.is_setting = false; - - - - - - }); - } - - // user defined functions - } - - - public class Xcls_ContextMenu : Object - { - public Gtk.Popover el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_ContextMenu(Xcls_LeftProps _owner ) - { - _this = _owner; - _this.ContextMenu = this; - this.el = new Gtk.Popover(); - - // my vars (dec) - - // set gobject values - var child_1 = new Xcls_Box40( _this ); - this.el.child = child_1.el; - } - - // user defined functions - } - public class Xcls_Box40 : Object - { - public Gtk.Box el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Box40(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - var child_1 = new Xcls_Button41( _this ); - child_1.ref(); - this.el.append( child_1.el ); - } - - // user defined functions - } - public class Xcls_Button41 : Object - { - public Gtk.Button el; - private Xcls_LeftProps _this; - - - // my vars (def) - - // ctor - public Xcls_Button41(Xcls_LeftProps _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.label = "Delete"; - - //listeners - this.el.activate.connect( ( ) =>{ - _this.deleteSelected(); - - }); - } + // user defined functions + } + + public class Xcls_Button25 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button25(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a flexy include (for HTML templates)"; + this.el.label = "Flexy - Foreach"; + + //listeners + this.el.clicked.connect( ( ) =>{ + _this.AddPropertyPopup.el.hide(); + _this.view.popover.show( + _this.view.el, + _this.node, + new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") , + -1, + true + ); + + }); + } + + // user defined functions + } + + + + + + public class Xcls_EditProps : Object + { + public Gtk.ScrolledWindow el; + private Xcls_LeftProps _this; + + + // my vars (def) + public bool editing; + + // ctor + public Xcls_EditProps(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.EditProps = this; + this.el = new Gtk.ScrolledWindow(); + + // my vars (dec) + this.editing = false; + + // set gobject values + this.el.hexpand = true; + this.el.vexpand = true; + new Xcls_view( _this ); + this.el.set_child ( _this.view.el ); + + // init method + + { + + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + } + } + + // user defined functions + } + public class Xcls_view : Object + { + public Gtk.ColumnView el; + private Xcls_LeftProps _this; + + + // my vars (def) + public Gtk.CssProvider css; + public Xcls_PopoverProperty popover; + + // ctor + public Xcls_view(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.view = this; + new Xcls_selmodel( _this ); + this.el = new Gtk.ColumnView( _this.selmodel.el ); + + // my vars (dec) + this.popover = null; + + // set gobject values + this.el.name = "leftprops-view"; + this.el.single_click_activate = false; + this.el.hexpand = true; + this.el.vexpand = true; + this.el.show_row_separators = true; + new Xcls_deletemenu( _this ); + var child_3 = new Xcls_GestureClick31( _this ); + child_3.ref(); + this.el.add_controller( child_3.el ); + var child_4 = new Xcls_GestureClick32( _this ); + child_4.ref(); + this.el.add_controller( child_4.el ); + new Xcls_keycol( _this ); + this.el.append_column ( _this.keycol.el ); + new Xcls_valcol( _this ); + this.el.append_column ( _this.valcol.el ); + new Xcls_ContextMenu( _this ); + + // init method + + { + + this.css = new Gtk.CssProvider(); + + this.css.load_from_string(" + #leftprops-view { font-size: 12px;} + + #leftprops-view dropdown button { + min-height: 16px; + outline-offset : 0; + } + #leftprops-view cell dropdown label { + padding-top:0px; + padding-bottom:0px; + } + #leftprops-view cell { + padding-top:2px; + padding-bottom:2px; + } + #leftprops-view cell label, #leftprops-view cell editablelable { + padding-top:4px; + padding-bottom:4px; + }"); + + Gtk.StyleContext.add_provider_for_display( + this.el.get_display(), + this.css, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + ); + + + } + } + + // user defined functions + public Gtk.Widget? getWidgetAtRow (uint row) { + /* + + from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 + var colview = gesture.widget; + var line_no = check_list_widget(colview, x,y); + if (line_no > -1) { + var item = colview.model.get_item(line_no); + + } + */ + GLib.debug("Get Widget At Row %d", (int)row); + var child = this.el.get_first_child(); + var line_no = -1; + var reading_header = true; + + while (child != null) { + GLib.debug("Got %s", child.get_type().name()); + if (reading_header) { + + + if (child.get_type().name() != "GtkColumnListView") { + child = child.get_next_sibling(); + continue; + } + child = child.get_first_child(); + reading_header = false; + } + if (child.get_type().name() != "GtkColumnViewRowWidget") { + child = child.get_next_sibling(); + continue; + } + line_no++; + if (line_no == row) { + GLib.debug("Returning widget %s", child.get_type().name()); + return (Gtk.Widget)child; + } + child = child.get_next_sibling(); + } + GLib.debug("Rturning null"); + return null; + + } + public void editProp (JsRender.NodeProp prop) + { + var sm = _this.selmodel.el; + + var sr = -1; + GLib.debug("finding node"); + _this.selmodel.selectProp(prop); + + for (var i = 0 ; i < sm.n_items; i++) { + var r = (JsRender.NodeProp)sm.get_item(i); + if (r.equals(prop)) { + sr = i; + break; + } + } + if (sr < 0) { + GLib.debug("finding node - cant find it"); + + return; + } + var r = this.getWidgetAtRow(sr); + GLib.debug("r = %s", r.get_type().name()); + var ca = r.get_first_child(); + var ll = (Gtk.Label)ca.get_first_child(); + var cb = ca.get_next_sibling(); + var b = cb.get_first_child(); + var e = (Gtk.EditableLabel) b.get_first_child(); + var l = (Gtk.Label) e.get_next_sibling(); + var d = (Gtk.DropDown) l.get_next_sibling(); + + GLib.debug("row key = %s", ll.label); + if (e.get_visible()) { + _this.stop_editor(); + e.start_editing(); + //GLib.Timeout.add_once(500, () => { + // var st = (Gtk.Stack) e.get_first_child(); + // var ed = (Gtk.Entry) st.get_visible_child(); + // ed.grab_focus_without_selecting(); + //}); + return; + } + if (d.get_visible()) { + _this.stop_editor(); + d.activate(); + return; + } + if (l.get_visible()) { + _this.stop_editor(); + _this.show_editor(_this.file, prop.parent, prop); + + } + + + + //gtkcolumnviewrowwidget + // cell widet + // cell widget + // box + // entry / label / dropdown + + + } + public int getColAt (double x, double y) { + /* + + from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 + + */ + //Gtk.Allocation alloc = { 0, 0, 0, 0 }; + var child = this.el.get_first_child(); + + var col = 0; + var offx = 0; + while (child != null) { + GLib.debug("Got %s", child.get_type().name()); + + if (child.get_type().name() == "GtkColumnViewRowWidget") { + child = child.get_first_child(); + continue; + } + + //child.get_allocation(out alloc); + if (x < (child.get_width() + offx)) { + return col; + } + offx += child.get_width(); + col++; + child = child.get_next_sibling(); + } + + + return -1; + + } + public int getRowAt (double x, double in_y, out string pos) { + + + + + /* + + from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 + var colview = gesture.widget; + var line_no = check_list_widget(colview, x,y); + if (line_no > -1) { + var item = colview.model.get_item(line_no); + + } + */ + + + //GLib.debug("offset = %d y = %d", (int) voff, (int) in_y); + var y = in_y + _this.EditProps.el.vadjustment.value; + var child = this.el.get_first_child(); + //Gtk.Allocation alloc = { 0, 0, 0, 0 }; + var line_no = -1; + var reading_header = true; + var real_y = 0; + var header_height = 0; + pos = "none"; + var h = 0; + while (child != null) { + //GLib.debug("Got %s", child.get_type().name()); + if (reading_header) { + + + if (child.get_type().name() != "GtkColumnListView") { + h += child.get_height(); + child = child.get_next_sibling(); + continue; + } + // should be columnlistview + child = child.get_first_child(); + GLib.debug("header height=%d", h); + header_height = h; + + reading_header = false; + + } + + if (child.get_type().name() != "GtkColumnViewRowWidget") { + child = child.get_next_sibling(); + continue; + } + + if (y < header_height) { + return -1; + } + + line_no++; + var hh = child.get_height(); + //child.get_allocation(out alloc); + //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height); + //GLib.debug("row %d y= %d %s", line_no, (int) (header_height + alloc.y), + + // child.visible ? "VIS" : "hidden"); + + if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) { + if (y > ( header_height + real_y + (hh * 0.8))) { + pos = "below"; + } else if (y > ( header_height + real_y + (hh * 0.2))) { + pos = "over"; + } else { + pos = "above"; + } + GLib.debug("getRowAt return : %d, %s", line_no, pos); + return line_no; + } + + + if (real_y + hh > y) { + return -1; + } + real_y += hh; + child = child.get_next_sibling(); + } + return -1; + + } + } + public class Xcls_deletemenu : Object + { + public Gtk.Popover el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_deletemenu(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.deletemenu = this; + this.el = new Gtk.Popover(); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Box29( _this ); + this.el.child = child_1.el; + } + + // user defined functions + } + public class Xcls_Box29 : Object + { + public Gtk.Box el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Box29(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Button30( _this ); + child_1.ref(); + this.el.append( child_1.el ); + } + + // user defined functions + } + public class Xcls_Button30 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button30(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Delete"; + + //listeners + this.el.clicked.connect( ( ) => { + + + var n = (JsRender.NodeProp) _this.selmodel.el.selected_item; + + _this.deletemenu.el.hide(); + _this.node.remove_prop(n); + }); + } + + // user defined functions + } + + + + public class Xcls_GestureClick31 : Object + { + public Gtk.GestureClick el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_GestureClick31(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.GestureClick(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.pressed.connect( (n_press, in_x, in_y) => { + + GLib.debug("Prssed %d", (int) this.el.get_current_button()); + + var col = _this.view.getColAt(in_x, in_y); + if (col != 0) { + return; + } + string pos; + var row = _this.view.getRowAt(in_x, in_y, out pos); + + if (row < 0) { + return; + + } + GLib.debug("hit row %d", row); + var prop = _this.selmodel.getPropAt(row); + _this.selmodel.selectProp(prop); + + //var point_at = _this.view.getWidgetAtRow(row); + + // need to shift down, as ev.y does not inclucde header apparently.. + // or popover might be trying to do a central? + // _this.view.editPropertyDetails(prop, (int) in_y + 12); + _this.stop_editor(); + _this.view.popover.show( + _this.view.el, + _this.node, prop, + (int)in_y); + + + + }); + } + + // user defined functions + } + + public class Xcls_GestureClick32 : Object + { + public Gtk.GestureClick el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_GestureClick32(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.GestureClick(); + + // my vars (dec) + + // set gobject values + this.el.button = 3; + + //listeners + this.el.pressed.connect( (n_press, in_x, in_y) => { + + + + string pos; + var row = _this.view.getRowAt(in_x, in_y, out pos); + + if (row < 0) { + return; + + } + + _this.stop_editor(); + GLib.debug("hit row %d", row); + var prop = _this.selmodel.getPropAt(row); + _this.selmodel.selectProp(prop); + + + + GLib.debug("Prssed %d", (int) this.el.get_current_button()); + //_this.deletemenu.el.set_parent(_this.view.el); + if (_this.deletemenu.el.parent == null) { + _this.deletemenu.el.set_parent(_this.main_window.el); + } + + + + _this.deletemenu.el.set_offset( + (int)in_x - _this.view.el.get_width() , + (int)in_y - _this.view.el.get_height() + ); + _this.deletemenu.el.set_position(Gtk.PositionType.BOTTOM); + _this.deletemenu.el.popup(); + + }); + } + + // user defined functions + } + + public class Xcls_selmodel : Object + { + public Gtk.SingleSelection el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_selmodel(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.selmodel = this; + new Xcls_model( _this ); + this.el = new Gtk.SingleSelection( _this.model.el ); + + // my vars (dec) + + // set gobject values + this.el.can_unselect = true; + } + + // user defined functions + public void startEditing (JsRender.NodeProp prop) { + // should we call select?? - caller does int (from windowstate) + + } + public void selectProp (JsRender.NodeProp prop) { + for (var i = 0 ; i < this.el.n_items; i++) { + var r = (JsRender.NodeProp)this.el.get_item(i); + if (r.equals(prop)) { + this.el.selected = i; + return; + } + } + + } + public JsRender.NodeProp getPropAt (uint row) { + + return (JsRender.NodeProp) this.el.get_item(row); + + + } + } + public class Xcls_model : Object + { + public GLib.ListStore el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_model(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.model = this; + this.el = new GLib.ListStore(typeof(JsRender.NodeProp)); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + public class Xcls_keycol : Object + { + public Gtk.ColumnViewColumn el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_keycol(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.keycol = this; + var child_1 = new Xcls_SignalListItemFactory36( _this ); + child_1.ref(); + this.el = new Gtk.ColumnViewColumn( "Property", child_1.el ); + + // my vars (dec) + + // set gobject values + this.el.id = "keycol"; + this.el.expand = true; + this.el.resizable = true; + } + + // user defined functions + } + public class Xcls_SignalListItemFactory36 : Object + { + public Gtk.SignalListItemFactory el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_SignalListItemFactory36(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.SignalListItemFactory(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.setup.connect( (listitem) => { + var lbl = new Gtk.Label(""); + ((Gtk.ListItem)listitem).set_child(lbl); + lbl.justify = Gtk.Justification.LEFT; + lbl.xalign = 1; + lbl.use_markup = true; + lbl.ellipsize = Pango.EllipsizeMode.START; + /*lbl.changed.connect(() => { + // notify and save the changed value... + //var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem.get_item()); + + //prop.val = lbl.text; + //_this.updateIter(iter,prop); + _this.changed(); + }); + */ + ((Gtk.ListItem)listitem).activatable = true; + }); + this.el.bind.connect( (listitem) => { + var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child(); + var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item(); + + + item.bind_property("to_display_name_prop", + lb, "label", + GLib.BindingFlags.SYNC_CREATE); + item.bind_property("to_tooltip_name_prop", + lb, "tooltip_markup", + GLib.BindingFlags.SYNC_CREATE); + // was item (1) in old layout + + + }); + } + + // user defined functions + } + + + public class Xcls_valcol : Object + { + public Gtk.ColumnViewColumn el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_valcol(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.valcol = this; + var child_1 = new Xcls_SignalListItemFactory38( _this ); + child_1.ref(); + this.el = new Gtk.ColumnViewColumn( "Value", child_1.el ); + + // my vars (dec) + + // set gobject values + this.el.id = "valcol"; + this.el.expand = true; + this.el.resizable = true; + } + + // user defined functions + } + public class Xcls_SignalListItemFactory38 : Object + { + public Gtk.SignalListItemFactory el; + private Xcls_LeftProps _this; + + + // my vars (def) + public bool is_setting; + + // ctor + public Xcls_SignalListItemFactory38(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.SignalListItemFactory(); + + // my vars (dec) + this.is_setting = false; + + // set gobject values + + //listeners + this.el.setup.connect( (listitem) => { + var hb = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0); + var elbl = new Gtk.EditableLabel(""); + elbl.hexpand = true; + hb.append(elbl); + var lbl = new Gtk.Label(""); + hb.append(lbl); + lbl.hexpand = true; + lbl.use_markup = true; + lbl.xalign =0; + lbl.ellipsize = Pango.EllipsizeMode.END; + var cb = new Gtk.DropDown(new Gtk.StringList({}), null); + cb.hexpand = true; + + hb.append(cb); + ((Gtk.ListItem)listitem).set_child(hb); + + var ef = new Gtk.EventControllerFocus(); + ef.enter.connect(() => { + _this.stop_editor(); + var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item(); + _this.selmodel.selectProp(prop); + }); + elbl.add_controller(ef); + + + // dropdown??? - stop editing, and highliht node + var tb = (Gtk.ToggleButton) cb.get_first_child(); + tb.clicked.connect(() => { + var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item(); + + _this.stop_editor(); + _this.selmodel.selectProp(prop); + + }); + elbl.changed.connect(() => { + // notify and save the changed value... + + //_this.updateIter(iter,prop); + // this should happen automatically + + if (!_this.loading && !this.is_setting) { + var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item(); + + + prop.val = elbl.text; + GLib.debug("calling changed"); + _this.changed(); + + } + + }); + + + cb.notify["selected"].connect(() => { + // dropdown selection changed. + + + + //_this.updateIter(iter,prop); + if (!_this.loading && !this.is_setting) { + var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item(); + var model = (Gtk.StringList)cb.model; + prop.val = model.get_string(cb.selected); + GLib.debug("property set to %s", prop.val); + GLib.debug("calling changed"); + _this.changed(); + + } + + + }); + var gc = new Gtk.GestureClick(); + lbl.add_controller(gc); + gc.pressed.connect(() => { + var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item(); + _this.stop_editor(); + _this.show_editor(_this.file, prop.parent, prop); + }); + + + + }); + this.el.bind.connect( (listitem) => { + this.is_setting = true; + + + var bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child(); + + + + + var elbl = (Gtk.EditableLabel)bx.get_first_child(); + var lbl = (Gtk.Label) elbl.get_next_sibling(); + var cb = (Gtk.DropDown) lbl.get_next_sibling(); + // decide if it's a combo or editable text.. + var model = (Gtk.StringList) cb.model; + + elbl.hide(); + lbl.hide(); + cb.hide(); + + var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item(); + //GLib.debug("prop = %s", prop.get_type().name()); + //GLib.debug("prop.val = %s", prop.val); + //GLib.debug("prop.key = %s", prop.to_display_name()); + + var use_textarea = prop.useTextArea(); + + + var pal = _this.file.project.palete; + + string[] opts; + var has_opts = pal.typeOptions(_this.node.fqn(), prop.name, prop.rtype, out opts); + + if (!has_opts && prop.ptype == JsRender.NodePropType.RAW) { + use_textarea = true; + } + + + if (use_textarea) { + prop.bind_property("val_short", + lbl, "label", + GLib.BindingFlags.SYNC_CREATE); + prop.bind_property("val_tooltip", + lbl, "tooltip_markup", + GLib.BindingFlags.SYNC_CREATE); + lbl.show(); + this.is_setting = false; + return; + + } + + + + + + // others... - fill in options for true/false? + // GLib.debug (ktype.up()); + if (has_opts) { + + while(model.get_n_items() > 0) { + model.remove(0); + } + cb.show(); + // can not remove - hopefully always empty. + var sel = -1; + for(var i = 0; i < opts.length; i ++) { + model.append( opts[i]); + // not sure this is a great idea... + if (opts[i].down() == prop.val.down()) { + sel = i; + } + } + GLib.debug("Set selected item to %d", sel); + cb.set_selected(sel > -1 ? sel : Gtk.INVALID_LIST_POSITION); + this.is_setting = false; + return ; + } + + // see if type is a Enum. + // triggers a changed event + + elbl.set_text(prop.val); + + elbl.show(); + this.is_setting = false; + + + + + + }); + } + + // user defined functions + } + + + public class Xcls_ContextMenu : Object + { + public Gtk.Popover el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_ContextMenu(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.ContextMenu = this; + this.el = new Gtk.Popover(); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Box40( _this ); + this.el.child = child_1.el; + } + + // user defined functions + } + public class Xcls_Box40 : Object + { + public Gtk.Box el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Box40(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Button41( _this ); + child_1.ref(); + this.el.append( child_1.el ); + } + + // user defined functions + } + public class Xcls_Button41 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button41(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Delete"; + + //listeners + this.el.activate.connect( ( ) =>{ + _this.deleteSelected(); + + }); + } - // user defined functions - } + // user defined functions + } - } +} diff --git a/src/Builder4/WindowLeftTree.bjs b/src/Builder4/WindowLeftTree.bjs index ae238abfc..148220b3d 100644 --- a/src/Builder4/WindowLeftTree.bjs +++ b/src/Builder4/WindowLeftTree.bjs @@ -60,6 +60,9 @@ "#left-tree-view indent {", "-gtk-icon-size : 2px;", "}", + "#left-tree-view indent:nth-last-child(2) {", + "min-width: 24px;", + "}", "\");", "", "\tGtk.StyleContext.add_provider_for_display(", @@ -916,7 +919,8 @@ "\t}", "\tGLib.debug(\"Select %d\", row);", "\ts.set_selected(row);", - "\t_this.node_selected(node);\t\t\t", + "\t_this.view.el.scroll_to(row, null, Gtk.ListScrollFlags.SELECT, null);", + "\t//_this.node_selected(node);\t\t\t", "\t", "", "}" diff --git a/src/Builder4/WindowLeftTree.vala b/src/Builder4/WindowLeftTree.vala index 87dadcb2c..a56c2154b 100644 --- a/src/Builder4/WindowLeftTree.vala +++ b/src/Builder4/WindowLeftTree.vala @@ -1,1880 +1,1884 @@ - static Xcls_WindowLeftTree _WindowLeftTree; - - public class Xcls_WindowLeftTree : Object - { - public Gtk.Box el; - private Xcls_WindowLeftTree _this; - - public static Xcls_WindowLeftTree singleton() - { - if (_WindowLeftTree == null) { - _WindowLeftTree= new Xcls_WindowLeftTree(); - } - return _WindowLeftTree; - } - public Xcls_viewwin viewwin; - public Xcls_view view; - public Xcls_drop drop; - public Xcls_selmodel selmodel; - public Xcls_model model; - public Xcls_maincol maincol; - public Xcls_LeftTreeMenu LeftTreeMenu; - - // my vars (def) - public signal bool before_node_change (); - public Xcls_MainWindow main_window; - public signal void changed (); - public signal void node_selected (JsRender.Node? node); - - // ctor - public Xcls_WindowLeftTree() - { - _this = this; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - this.main_window = null; - - // set gobject values - this.el.hexpand = true; - this.el.vexpand = true; - var child_1 = new Xcls_ListView2( _this ); - child_1.ref(); - this.el.append( child_1.el ); - new Xcls_viewwin( _this ); - this.el.append( _this.viewwin.el ); - } - - // user defined functions - public void onresize () { - - - //GLib.debug("Got allocation width of scrolled view %d", allocation.width ); - // _this.maincol.el.set_max_width( _this.viewwin.el.get_width() - 32 ); - } - public JsRender.Node? getActiveElement () { // return path to actie node. - - - return _this.selmodel.getSelectedNode(); - - - } - public JsRender.JsRender getActiveFile () { - return this.main_window.windowstate.file; - } - public class Xcls_ListView2 : Object - { - public Gtk.ListView el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_ListView2(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - var child_1 = new Xcls_SignalListItemFactory3( _this ); - child_1.ref(); - this.el = new Gtk.ListView( null, child_1.el ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - public class Xcls_SignalListItemFactory3 : Object - { - public Gtk.SignalListItemFactory el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_SignalListItemFactory3(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - this.el = new Gtk.SignalListItemFactory(); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - - public class Xcls_viewwin : Object - { - public Gtk.ScrolledWindow el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_viewwin(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - _this.viewwin = this; - this.el = new Gtk.ScrolledWindow(); - - // my vars (dec) - - // set gobject values - this.el.has_frame = true; - this.el.hexpand = true; - this.el.vexpand = true; - new Xcls_view( _this ); - this.el.child = _this.view.el; - new Xcls_LeftTreeMenu( _this ); - - // init method - - this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); - } - - // user defined functions - } - public class Xcls_view : Object - { - public Gtk.ColumnView el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - public bool blockChanges; - public bool headers_visible; - public string lastEventSource; - public bool button_is_pressed; - public Gtk.CssProvider css; - - // ctor - public Xcls_view(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - _this.view = this; - new Xcls_selmodel( _this ); - this.el = new Gtk.ColumnView( _this.selmodel.el ); - - // my vars (dec) - this.blockChanges = false; - this.headers_visible = false; - this.lastEventSource = ""; - this.button_is_pressed = false; - - // set gobject values - this.el.name = "left-tree-view"; - this.el.hexpand = false; - this.el.vexpand = true; - var child_2 = new Xcls_GestureClick6( _this ); - child_2.ref(); - this.el.add_controller( child_2.el ); - var child_3 = new Xcls_GestureClick7( _this ); - child_3.ref(); - this.el.add_controller( child_3.el ); - var child_4 = new Xcls_DragSource8( _this ); - child_4.ref(); - this.el.add_controller( child_4.el ); - var child_5 = new Xcls_EventControllerKey9( _this ); - child_5.ref(); - this.el.add_controller( child_5.el ); - new Xcls_drop( _this ); - this.el.add_controller( _this.drop.el ); - new Xcls_maincol( _this ); - this.el.append_column ( _this.maincol.el ); - var child_8 = new Xcls_ColumnViewColumn15( _this ); - child_8.ref(); - this.el.append_column ( child_8.el ); - - // init method - - { - - this.css = new Gtk.CssProvider(); - // try { - this.css.load_from_string(" - #left-tree-view { font-size: 12px;} - .drag-over { background-color:#88a3bc; } - .drag-below { - border-bottom-width: 5px; - border-bottom-style: solid; - border-bottom-color: #88a3bc; - } - .drag-above { - border-top-width: 5px; - border-top-style: solid; - border-top-color: #88a3bc; - } - #left-tree-view indent { - -gtk-icon-size : 2px; - } - "); - - Gtk.StyleContext.add_provider_for_display( - this.el.get_display(), - this.css, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - ); - - - } - } - - // user defined functions - public Gtk.Widget? getWidgetAtRow (uint row) { - /* - - from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 - var colview = gesture.widget; - var line_no = check_list_widget(colview, x,y); - if (line_no > -1) { - var item = colview.model.get_item(line_no); - - } - */ - //GLib.debug("Get Widget At Row %d", (int)row); - var child = this.el.get_first_child(); - var line_no = -1; - var reading_header = true; - - while (child != null) { - GLib.debug("Got %s", child.get_type().name()); - - if (reading_header) { - - - if (child.get_type().name() != "GtkColumnListView") { - - child = child.get_next_sibling(); - continue; - } - // should be columnlistview - child = child.get_first_child(); - - - - reading_header = false; - - } - - - - line_no++; - if (line_no == row) { - //GLib.debug("Returning widget %s", child.get_type().name()); - return (Gtk.Widget)child; - } - child = child.get_next_sibling(); - } - //GLib.debug("Rturning null"); - return null; - - } - public int getColAt (double x, double y) { - /* - - from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 - - */ - //Gtk.Allocation alloc = { 0, 0, 0, 0 }; - //GLib.debug("Cehck %d, %d", x,y); - var child = this.el.get_first_child(); - - var col = 0; - var offx = 0; - while (child != null) { - - if (child.get_type().name() == "GtkColumnViewRowWidget") { - child = child.get_first_child(); - continue; - } - - //child.get_allocation(out alloc); - if (x < (child.get_width() + offx)) { - return col; - } - return 1; - //offx += child.get_width(); - //col++; - //child = child.get_next_sibling(); - } - - - return -1; - - } - public int getRowAt (double x, double in_y, out string pos) { - - - - - /* - - from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 - var colview = gesture.widget; - var line_no = check_list_widget(colview, x,y); - if (line_no > -1) { - var item = colview.model.get_item(line_no); - - } - */ - - - //GLib.debug("offset = %d y = %d", (int) voff, (int) in_y); - var y = in_y + _this.viewwin.el.vadjustment.value; - var child = this.el.get_first_child(); - //Gtk.Allocation alloc = { 0, 0, 0, 0 }; - var line_no = -1; - var reading_header = true; - var real_y = 0; - var header_height = 0; - pos = "none"; - var h = 0; - while (child != null) { - //GLib.debug("Got %s", child.get_type().name()); - if (reading_header) { - - - if (child.get_type().name() != "GtkColumnListView") { - h += child.get_height(); - child = child.get_next_sibling(); - continue; - } - // should be columnlistview - child = child.get_first_child(); - GLib.debug("header height=%d", h); - header_height = h; - - reading_header = false; - - } - - if (child.get_type().name() != "GtkColumnViewRowWidget") { - child = child.get_next_sibling(); - continue; - } - - if (y < header_height) { - return -1; - } - - line_no++; - var hh = child.get_height(); - //child.get_allocation(out alloc); - //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height); - //GLib.debug("row %d y= %d %s", line_no, (int) (header_height + alloc.y), - - // child.visible ? "VIS" : "hidden"); - - if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) { - if (y > ( header_height + real_y + (hh * 0.8))) { - pos = "below"; - } else if (y > ( header_height + real_y + (hh * 0.2))) { - pos = "over"; - } else { - pos = "above"; - } - GLib.debug("getRowAt return : %d, %s", line_no, pos); - return line_no; - } - - - if (real_y + hh > y) { - return -1; - } - real_y += hh; - child = child.get_next_sibling(); - } - return -1; - - } - public Gtk.Widget? getWidgetAt (double x, double in_y) { - /* - - from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 - var colview = gesture.widget; - var line_no = check_list_widget(colview, x,y); - if (line_no > -1) { - var item = colview.model.get_item(line_no); - - } - */ - var y = in_y + _this.viewwin.el.vadjustment.value; - var child = this.el.get_first_child(); - //Gtk.Allocation alloc = { 0, 0, 0, 0 }; - var line_no = -1; - var reading_header = true; - var curr_y = 0; - var header_height = 0; - var h = 0; - while (child != null) { - //GLib.debug("Got %s", child.get_type().name()); - if (reading_header) { - - - if (child.get_type().name() != "GtkColumnListView") { - h += child.get_height(); - child = child.get_next_sibling(); - continue; - } - // should be columnlistview - child = child.get_first_child(); - GLib.debug("header height=%d", h); - header_height = h; - - reading_header = false; - - } - line_no++; - - if (y < header_height) { - return null; - } - - var hh = child.get_height(); - //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height); - - if (y > curr_y && y <= header_height + hh + curr_y ) { - return (Gtk.Widget)child; - } - curr_y += hh ; - - if (curr_y > y) { - return null; - } - child = child.get_next_sibling(); - } - return null; - - } - } - public class Xcls_GestureClick6 : Object - { - public Gtk.GestureClick el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_GestureClick6(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - this.el = new Gtk.GestureClick(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.released.connect( (n_press, x, y) => { - - _this.view.button_is_pressed = false; - - - }); - this.el.pressed.connect( (n_press, x, y) => { - - //console.log("button press?"); - - //this.el.set_state(Gtk.EventSequenceState.CLAIMED); - - - - _this.view.button_is_pressed = true; - - _this.view.lastEventSource = "tree"; - if (! _this.before_node_change() ) { - GLib.debug("before_node_change return false"); - return ; - } - - // nothing there -show dialog - if (_this.model.el.get_n_items() < 1) { - _this.main_window.windowstate.showAddObject(_this.view.el, null); - GLib.debug("no items"); - return ; - } - string pos; - var row = _this.view.getRowAt(x,y, out pos ); - if (row < 0) { - GLib.debug("no row selected items"); - return; - } - - var node = _this.selmodel.getNodeAt(row); - if (node == null) { - GLib.warning("No node found at row %d", row); - return; - } - - - - if (_this.view.getColAt(x,y) > 0 ) { - GLib.debug("add colum clicked."); - var fqn = node.fqn(); - var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false); - if (cn.size < 1) { - return ; - } - - _this.main_window.windowstate.leftTreeBeforeChange(); - //_this.view.el.get_selection().select_path(res); - GLib.debug("Button Pressed - start show window"); - _this.main_window.windowstate.showAddObject(_this.view.el, node); - GLib.debug("Button Pressed - finsihed show window"); - return ; - } - - - - }); - } - - // user defined functions - } - - public class Xcls_GestureClick7 : Object - { - public Gtk.GestureClick el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_GestureClick7(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - this.el = new Gtk.GestureClick(); - - // my vars (dec) - - // set gobject values - this.el.button = 3; - - //listeners - this.el.pressed.connect( (n_press, x, y) => { - - - - - if (_this.model.el.get_n_items() < 1) { - - GLib.debug("no items"); - return ; - } - string pos; - var row = _this.view.getRowAt(x,y, out pos ); - if (row < 0) { - GLib.debug("no row selected items"); - return; - } - - var node = _this.selmodel.getNodeAt(row); - if (node == null) { - GLib.warning("No node found at row %d", row); - return; - } - _this.model.selectNode(node); - - - - GLib.debug("Prssed %d", (int) this.el.get_current_button()); - //_this.deletemenu.el.set_parent(_this.view.el); - _this.LeftTreeMenu.el.set_parent(_this.view.el); - - - //Gtk.Allocation rect; - //_this.view.el.get_allocation(out rect); - //_this.deletemenu.el.set_has_arrow(false); - _this.LeftTreeMenu.el.set_position(Gtk.PositionType.BOTTOM); - - - _this.LeftTreeMenu.el.set_offset( - (int)x , - (int)y - (int)_this.view.el.get_height()); - - _this.LeftTreeMenu.el.popup(); - - }); - } - - // user defined functions - } - - public class Xcls_DragSource8 : Object - { - public Gtk.DragSource el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_DragSource8(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - this.el = new Gtk.DragSource(); - - // my vars (dec) - - // set gobject values - this.el.actions = Gdk.DragAction.COPY | Gdk.DragAction.MOVE ; - - //listeners - this.el.prepare.connect( (x, y) => { - - - - /// ( drag_context, data, info, time) => { - - - //print("drag-data-get"); - var ndata = _this.selmodel.getSelectedNode(); - if (ndata == null) { - GLib.debug("return empty string - no selection.."); - return null; - - } - - - //data.set_text(tp,tp.length); - - var str = ndata.toJsonString(); - GLib.debug("prepare store: %s", str); - GLib.Value ov = GLib.Value(typeof(string)); - ov.set_string(str); - var cont = new Gdk.ContentProvider.for_value(ov); - /* - GLib.Value v = GLib.Value(typeof(string)); - //var str = drop.read_text( [ "text/plain" ] 0); - - cont.get_value(ref v); - - } - GLib.debug("set %s", v.get_string()); - */ - return cont; - - - }); - this.el.drag_begin.connect( ( drag ) => { - GLib.debug("SOURCE: drag-begin"); - - // find what is selected in our tree... - var data = _this.selmodel.getSelectedNode(); - if (data == null) { - return ; - } - - var xname = data.fqn(); - GLib.debug ("XNAME IS %s", xname); - - var widget = _this.view.getWidgetAtRow(_this.selmodel.el.selected); - - - var paintable = new Gtk.WidgetPaintable(widget); - this.el.set_icon(paintable, 0,0); - - - }); - } - - // user defined functions - } - - public class Xcls_EventControllerKey9 : Object - { - public Gtk.EventControllerKey el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_EventControllerKey9(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - this.el = new Gtk.EventControllerKey(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.key_pressed.connect( (keyval, keycode, state) => { - - - - if (keyval != Gdk.Key.Delete && keyval != Gdk.Key.BackSpace) { - return true; - } - - _this.model.deleteSelected(); - return true; - - }); - } - - // user defined functions - } - - public class Xcls_drop : Object - { - public Gtk.DropTarget el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - public Gtk.Widget? highlightWidget; - public JsRender.Node? lastDragNode; - public string lastDragString; - - // ctor - public Xcls_drop(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - _this.drop = this; - this.el = new Gtk.DropTarget ( typeof(string) , +static Xcls_WindowLeftTree _WindowLeftTree; + +public class Xcls_WindowLeftTree : Object +{ + public Gtk.Box el; + private Xcls_WindowLeftTree _this; + + public static Xcls_WindowLeftTree singleton() + { + if (_WindowLeftTree == null) { + _WindowLeftTree= new Xcls_WindowLeftTree(); + } + return _WindowLeftTree; + } + public Xcls_viewwin viewwin; + public Xcls_view view; + public Xcls_drop drop; + public Xcls_selmodel selmodel; + public Xcls_model model; + public Xcls_maincol maincol; + public Xcls_LeftTreeMenu LeftTreeMenu; + + // my vars (def) + public signal bool before_node_change (); + public Xcls_MainWindow main_window; + public signal void changed (); + public signal void node_selected (JsRender.Node? node); + + // ctor + public Xcls_WindowLeftTree() + { + _this = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + this.main_window = null; + + // set gobject values + this.el.hexpand = true; + this.el.vexpand = true; + var child_1 = new Xcls_ListView2( _this ); + child_1.ref(); + this.el.append( child_1.el ); + new Xcls_viewwin( _this ); + this.el.append( _this.viewwin.el ); + } + + // user defined functions + public void onresize () { + + + //GLib.debug("Got allocation width of scrolled view %d", allocation.width ); + // _this.maincol.el.set_max_width( _this.viewwin.el.get_width() - 32 ); + } + public JsRender.Node? getActiveElement () { // return path to actie node. + + + return _this.selmodel.getSelectedNode(); + + + } + public JsRender.JsRender getActiveFile () { + return this.main_window.windowstate.file; + } + public class Xcls_ListView2 : Object + { + public Gtk.ListView el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_ListView2(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + var child_1 = new Xcls_SignalListItemFactory3( _this ); + child_1.ref(); + this.el = new Gtk.ListView( null, child_1.el ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_SignalListItemFactory3 : Object + { + public Gtk.SignalListItemFactory el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_SignalListItemFactory3(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.SignalListItemFactory(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + public class Xcls_viewwin : Object + { + public Gtk.ScrolledWindow el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_viewwin(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + _this.viewwin = this; + this.el = new Gtk.ScrolledWindow(); + + // my vars (dec) + + // set gobject values + this.el.has_frame = true; + this.el.hexpand = true; + this.el.vexpand = true; + new Xcls_view( _this ); + this.el.child = _this.view.el; + new Xcls_LeftTreeMenu( _this ); + + // init method + + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + } + + // user defined functions + } + public class Xcls_view : Object + { + public Gtk.ColumnView el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + public bool blockChanges; + public bool headers_visible; + public string lastEventSource; + public bool button_is_pressed; + public Gtk.CssProvider css; + + // ctor + public Xcls_view(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + _this.view = this; + new Xcls_selmodel( _this ); + this.el = new Gtk.ColumnView( _this.selmodel.el ); + + // my vars (dec) + this.blockChanges = false; + this.headers_visible = false; + this.lastEventSource = ""; + this.button_is_pressed = false; + + // set gobject values + this.el.name = "left-tree-view"; + this.el.hexpand = false; + this.el.vexpand = true; + var child_2 = new Xcls_GestureClick6( _this ); + child_2.ref(); + this.el.add_controller( child_2.el ); + var child_3 = new Xcls_GestureClick7( _this ); + child_3.ref(); + this.el.add_controller( child_3.el ); + var child_4 = new Xcls_DragSource8( _this ); + child_4.ref(); + this.el.add_controller( child_4.el ); + var child_5 = new Xcls_EventControllerKey9( _this ); + child_5.ref(); + this.el.add_controller( child_5.el ); + new Xcls_drop( _this ); + this.el.add_controller( _this.drop.el ); + new Xcls_maincol( _this ); + this.el.append_column ( _this.maincol.el ); + var child_8 = new Xcls_ColumnViewColumn15( _this ); + child_8.ref(); + this.el.append_column ( child_8.el ); + + // init method + + { + + this.css = new Gtk.CssProvider(); + // try { + this.css.load_from_string(" + #left-tree-view { font-size: 12px;} + .drag-over { background-color:#88a3bc; } + .drag-below { + border-bottom-width: 5px; + border-bottom-style: solid; + border-bottom-color: #88a3bc; + } + .drag-above { + border-top-width: 5px; + border-top-style: solid; + border-top-color: #88a3bc; + } + #left-tree-view indent { + -gtk-icon-size : 2px; + } + #left-tree-view indent:nth-last-child(2) { + min-width: 24px; + } + "); + + Gtk.StyleContext.add_provider_for_display( + this.el.get_display(), + this.css, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + ); + + + } + } + + // user defined functions + public Gtk.Widget? getWidgetAtRow (uint row) { + /* + + from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 + var colview = gesture.widget; + var line_no = check_list_widget(colview, x,y); + if (line_no > -1) { + var item = colview.model.get_item(line_no); + + } + */ + //GLib.debug("Get Widget At Row %d", (int)row); + var child = this.el.get_first_child(); + var line_no = -1; + var reading_header = true; + + while (child != null) { + GLib.debug("Got %s", child.get_type().name()); + + if (reading_header) { + + + if (child.get_type().name() != "GtkColumnListView") { + + child = child.get_next_sibling(); + continue; + } + // should be columnlistview + child = child.get_first_child(); + + + + reading_header = false; + + } + + + + line_no++; + if (line_no == row) { + //GLib.debug("Returning widget %s", child.get_type().name()); + return (Gtk.Widget)child; + } + child = child.get_next_sibling(); + } + //GLib.debug("Rturning null"); + return null; + + } + public int getColAt (double x, double y) { + /* + + from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 + + */ + //Gtk.Allocation alloc = { 0, 0, 0, 0 }; + //GLib.debug("Cehck %d, %d", x,y); + var child = this.el.get_first_child(); + + var col = 0; + var offx = 0; + while (child != null) { + + if (child.get_type().name() == "GtkColumnViewRowWidget") { + child = child.get_first_child(); + continue; + } + + //child.get_allocation(out alloc); + if (x < (child.get_width() + offx)) { + return col; + } + return 1; + //offx += child.get_width(); + //col++; + //child = child.get_next_sibling(); + } + + + return -1; + + } + public int getRowAt (double x, double in_y, out string pos) { + + + + + /* + + from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 + var colview = gesture.widget; + var line_no = check_list_widget(colview, x,y); + if (line_no > -1) { + var item = colview.model.get_item(line_no); + + } + */ + + + //GLib.debug("offset = %d y = %d", (int) voff, (int) in_y); + var y = in_y + _this.viewwin.el.vadjustment.value; + var child = this.el.get_first_child(); + //Gtk.Allocation alloc = { 0, 0, 0, 0 }; + var line_no = -1; + var reading_header = true; + var real_y = 0; + var header_height = 0; + pos = "none"; + var h = 0; + while (child != null) { + //GLib.debug("Got %s", child.get_type().name()); + if (reading_header) { + + + if (child.get_type().name() != "GtkColumnListView") { + h += child.get_height(); + child = child.get_next_sibling(); + continue; + } + // should be columnlistview + child = child.get_first_child(); + GLib.debug("header height=%d", h); + header_height = h; + + reading_header = false; + + } + + if (child.get_type().name() != "GtkColumnViewRowWidget") { + child = child.get_next_sibling(); + continue; + } + + if (y < header_height) { + return -1; + } + + line_no++; + var hh = child.get_height(); + //child.get_allocation(out alloc); + //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height); + //GLib.debug("row %d y= %d %s", line_no, (int) (header_height + alloc.y), + + // child.visible ? "VIS" : "hidden"); + + if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) { + if (y > ( header_height + real_y + (hh * 0.8))) { + pos = "below"; + } else if (y > ( header_height + real_y + (hh * 0.2))) { + pos = "over"; + } else { + pos = "above"; + } + GLib.debug("getRowAt return : %d, %s", line_no, pos); + return line_no; + } + + + if (real_y + hh > y) { + return -1; + } + real_y += hh; + child = child.get_next_sibling(); + } + return -1; + + } + public Gtk.Widget? getWidgetAt (double x, double in_y) { + /* + + from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 + var colview = gesture.widget; + var line_no = check_list_widget(colview, x,y); + if (line_no > -1) { + var item = colview.model.get_item(line_no); + + } + */ + var y = in_y + _this.viewwin.el.vadjustment.value; + var child = this.el.get_first_child(); + //Gtk.Allocation alloc = { 0, 0, 0, 0 }; + var line_no = -1; + var reading_header = true; + var curr_y = 0; + var header_height = 0; + var h = 0; + while (child != null) { + //GLib.debug("Got %s", child.get_type().name()); + if (reading_header) { + + + if (child.get_type().name() != "GtkColumnListView") { + h += child.get_height(); + child = child.get_next_sibling(); + continue; + } + // should be columnlistview + child = child.get_first_child(); + GLib.debug("header height=%d", h); + header_height = h; + + reading_header = false; + + } + line_no++; + + if (y < header_height) { + return null; + } + + var hh = child.get_height(); + //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height); + + if (y > curr_y && y <= header_height + hh + curr_y ) { + return (Gtk.Widget)child; + } + curr_y += hh ; + + if (curr_y > y) { + return null; + } + child = child.get_next_sibling(); + } + return null; + + } + } + public class Xcls_GestureClick6 : Object + { + public Gtk.GestureClick el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_GestureClick6(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.GestureClick(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.released.connect( (n_press, x, y) => { + + _this.view.button_is_pressed = false; + + + }); + this.el.pressed.connect( (n_press, x, y) => { + + //console.log("button press?"); + + //this.el.set_state(Gtk.EventSequenceState.CLAIMED); + + + + _this.view.button_is_pressed = true; + + _this.view.lastEventSource = "tree"; + if (! _this.before_node_change() ) { + GLib.debug("before_node_change return false"); + return ; + } + + // nothing there -show dialog + if (_this.model.el.get_n_items() < 1) { + _this.main_window.windowstate.showAddObject(_this.view.el, null); + GLib.debug("no items"); + return ; + } + string pos; + var row = _this.view.getRowAt(x,y, out pos ); + if (row < 0) { + GLib.debug("no row selected items"); + return; + } + + var node = _this.selmodel.getNodeAt(row); + if (node == null) { + GLib.warning("No node found at row %d", row); + return; + } + + + + if (_this.view.getColAt(x,y) > 0 ) { + GLib.debug("add colum clicked."); + var fqn = node.fqn(); + var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false); + if (cn.size < 1) { + return ; + } + + _this.main_window.windowstate.leftTreeBeforeChange(); + //_this.view.el.get_selection().select_path(res); + GLib.debug("Button Pressed - start show window"); + _this.main_window.windowstate.showAddObject(_this.view.el, node); + GLib.debug("Button Pressed - finsihed show window"); + return ; + } + + + + }); + } + + // user defined functions + } + + public class Xcls_GestureClick7 : Object + { + public Gtk.GestureClick el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_GestureClick7(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.GestureClick(); + + // my vars (dec) + + // set gobject values + this.el.button = 3; + + //listeners + this.el.pressed.connect( (n_press, x, y) => { + + + + + if (_this.model.el.get_n_items() < 1) { + + GLib.debug("no items"); + return ; + } + string pos; + var row = _this.view.getRowAt(x,y, out pos ); + if (row < 0) { + GLib.debug("no row selected items"); + return; + } + + var node = _this.selmodel.getNodeAt(row); + if (node == null) { + GLib.warning("No node found at row %d", row); + return; + } + _this.model.selectNode(node); + + + + GLib.debug("Prssed %d", (int) this.el.get_current_button()); + //_this.deletemenu.el.set_parent(_this.view.el); + _this.LeftTreeMenu.el.set_parent(_this.view.el); + + + //Gtk.Allocation rect; + //_this.view.el.get_allocation(out rect); + //_this.deletemenu.el.set_has_arrow(false); + _this.LeftTreeMenu.el.set_position(Gtk.PositionType.BOTTOM); + + + _this.LeftTreeMenu.el.set_offset( + (int)x , + (int)y - (int)_this.view.el.get_height()); + + _this.LeftTreeMenu.el.popup(); + + }); + } + + // user defined functions + } + + public class Xcls_DragSource8 : Object + { + public Gtk.DragSource el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_DragSource8(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.DragSource(); + + // my vars (dec) + + // set gobject values + this.el.actions = Gdk.DragAction.COPY | Gdk.DragAction.MOVE ; + + //listeners + this.el.prepare.connect( (x, y) => { + + + + /// ( drag_context, data, info, time) => { + + + //print("drag-data-get"); + var ndata = _this.selmodel.getSelectedNode(); + if (ndata == null) { + GLib.debug("return empty string - no selection.."); + return null; + + } + + + //data.set_text(tp,tp.length); + + var str = ndata.toJsonString(); + GLib.debug("prepare store: %s", str); + GLib.Value ov = GLib.Value(typeof(string)); + ov.set_string(str); + var cont = new Gdk.ContentProvider.for_value(ov); + /* + GLib.Value v = GLib.Value(typeof(string)); + //var str = drop.read_text( [ "text/plain" ] 0); + + cont.get_value(ref v); + + } + GLib.debug("set %s", v.get_string()); + */ + return cont; + + + }); + this.el.drag_begin.connect( ( drag ) => { + GLib.debug("SOURCE: drag-begin"); + + // find what is selected in our tree... + var data = _this.selmodel.getSelectedNode(); + if (data == null) { + return ; + } + + var xname = data.fqn(); + GLib.debug ("XNAME IS %s", xname); + + var widget = _this.view.getWidgetAtRow(_this.selmodel.el.selected); + + + var paintable = new Gtk.WidgetPaintable(widget); + this.el.set_icon(paintable, 0,0); + + + }); + } + + // user defined functions + } + + public class Xcls_EventControllerKey9 : Object + { + public Gtk.EventControllerKey el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_EventControllerKey9(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.EventControllerKey(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.key_pressed.connect( (keyval, keycode, state) => { + + + + if (keyval != Gdk.Key.Delete && keyval != Gdk.Key.BackSpace) { + return true; + } + + _this.model.deleteSelected(); + return true; + + }); + } + + // user defined functions + } + + public class Xcls_drop : Object + { + public Gtk.DropTarget el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + public Gtk.Widget? highlightWidget; + public JsRender.Node? lastDragNode; + public string lastDragString; + + // ctor + public Xcls_drop(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + _this.drop = this; + this.el = new Gtk.DropTarget ( typeof(string) , Gdk.DragAction.COPY | Gdk.DragAction.MOVE ); - // my vars (dec) - this.highlightWidget = null; - this.lastDragNode = null; - this.lastDragString = ""; - - // set gobject values - - //listeners - this.el.accept.connect( (drop) => { - - GLib.debug("got DropTarget:accept"); - - // NOT REALLY NEEDED? = put stuff in drop? - - - /* ( ctx, x, y, time) => { - //Seed.print("TARGET: drag-drop"); - - - var src = Gtk.drag_get_source_widget(ctx); - - if (src != this.el) { - - - - this.drag_in_motion = false; - // request data that will be recieved by the recieve... - Gtk.drag_get_data - ( - this.el, // will receive 'drag-data-received' signal - ctx, // represents the current state of the DnD - Gdk.Atom.intern("application/json",true), // the target type we want - time // time stamp - ); - - - // No target offered by source => error - - - return false; - } - - // handle drop around self.. - - - - //print("GETTING POS"); - var targetData = ""; - - Gtk.TreePath path; - Gtk.TreeViewDropPosition pos; - var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos); - - // if there are not items in the tree.. the we have to set isOver to true for anything.. - var isEmpty = false; - if (_this.model.el.iter_n_children(null) < 1) { - print("got NO children?\n"); - isOver = true; //??? - isEmpty = true; - pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER; - } - - - - //var action = Gdk.DragAction.COPY; - // unless we are copying!!! ctl button.. - - var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ? - Gdk.DragAction.COPY : Gdk.DragAction.MOVE ; - // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ; - - - if (_this.model.el.iter_n_children(null) < 1) { - // no children.. -- asume it's ok.. - - targetData = "|%d|".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER); - - // continue through to allow drop... - - } else { - - - - - - //print("ISOVER? " + isOver); - if (!isOver) { - - Gtk.drag_finish (ctx, false, false, time); // drop failed.. - return true; // not over apoint!?! - no action on drop or motion.. - } - - // drag node is parent of child.. - //console.log("SRC TREEPATH: " + src.treepath); - //console.log("TARGET TREEPATH: " + data.path.to_string()); - - // nned to check a few here.. - //Gtk.TreeViewDropPosition.INTO_OR_AFTER - //Gtk.TreeViewDropPosition.INTO_OR_BEFORE - //Gtk.TreeViewDropPosition.AFTER - //Gtk.TreeViewDropPosition.BEFORE - - // locally dragged items to not really use the - var selection_text = this.dragData; - - - - if (selection_text == null || selection_text.length < 1) { - //print("Error - drag selection text returned NULL"); - - Gtk.drag_finish (ctx, false, false, time); // drop failed.. - return true; /// -- fixme -- this is not really correct.. - } - - // see if we are dragging into ourself? - print ("got selection text of " + selection_text); - - var target_path = path.to_string(); - //print("target_path="+target_path); - - // - if (selection_text == target_path) { - print("self drag ?? == we should perhaps allow copy onto self..\n"); - - Gtk.drag_finish (ctx, false, false, time); // drop failed.. - - return true; /// -- fixme -- this is not really correct.. - - } - - // check that - //print("DUMPING DATA"); - //console.dump(data); - // path, pos - - //print(data.path.to_string() +' => '+ data.pos); - - // dropList is a list of xtypes that this node could be dropped on. - // it is set up when we start to drag.. - - - targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos); - - print("targetDAta: " + targetData +"\n"); - - if (targetData.length < 1) { - //print("Can not find drop node path"); - - Gtk.drag_finish (ctx, false, false, time); // drop failed.. - return true; - } - - - - // continue on to allow drop.. - } - // at this point, drag is not in motion... -- as checked above... - so it's a real drop event.. - - - var delete_selection_data = false; - - if (action == Gdk.DragAction.ASK) { - // Ask the user to move or copy, then set the ctx action. - } - - if (action == Gdk.DragAction.MOVE) { - delete_selection_data = true; - } - - // drag around.. - reorder.. - _this.model.moveNode(targetData, action); - - - - - - // we can send stuff to souce here... - - - // do we always say failure, so we handle the reall drop? - Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time); - - return true; - - - - - - - } - */ - return true; - }); - this.el.motion.connect( ( x, y) => { - - string pos; // over / before / after.. - - GLib.debug("got drag motion"); - - GLib.Value v = GLib.Value(typeof(string)); - //var str = drop.read_text( [ "text/plain" ] 0); - var cont = this.el.current_drop.get_drag().content ; - try { - cont.get_value(ref v); - } catch (GLib.Error e) { - GLib.debug("failed to get drag value"); - return Gdk.DragAction.COPY; - - } - - GLib.debug("got %s", v.get_string()); - - if (this.lastDragString != v.get_string() || this.lastDragNode == null) { - // still dragging same node - - this.lastDragNode = new JsRender.Node(); - this.lastDragNode.loadFromJsonString(v.get_string(), 1); - } - - - var drop_on_to = _this.main_window.windowstate.file.palete().getDropList( - this.lastDragNode.fqn()); - - string[] str = {}; - foreach(var dp in drop_on_to) { - str += dp; - } - GLib.debug("droplist: %s", string.joinv(", ", str)); - - - // if there are not items in the tree.. the we have to set isOver to true for anything.. - - if (_this.model.el.n_items < 1) { - // FIXME check valid drop types? - if (drop_on_to.contains("*top")) { - this.addHighlight(_this.view.el, "over"); - } else { - this.addHighlight(null, ""); - } - - return Gdk.DragAction.COPY; // no need to highlight? - - } - - - GLib.debug("check is over"); - - // if path of source and dest are inside each other.. - // need to add source info to drag? - // the fail(); - var row = _this.view.getRowAt(x,y, out pos); - - if (row < 0) { - this.addHighlight(null, ""); - return Gdk.DragAction.COPY; - } - var tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row); - - var node = (JsRender.Node)tr.get_item(); - - GLib.debug("Drop over node: %s", node.fqn()); - - - if (pos == "above" || pos == "below") { - if (node.parent == null) { - GLib.debug("no parent try center"); - pos = "over"; - } else { - - if (!drop_on_to.contains(node.parent.fqn())) { - GLib.debug("drop on does not contain %s - try center" , node.parent.fqn()); - pos = "over"; - } else { - GLib.debug("drop contains %s - using %s" , node.parent.fqn(), pos); - } - } - - } - if (pos == "over") { - if (!drop_on_to.contains(node.fqn())) { - GLib.debug("drop on does not contain %s - try center" , node.fqn()); - this.addHighlight(null, ""); - return Gdk.DragAction.COPY; - } - } - - - // _this.view.highlightDropPath("", (Gtk.TreeViewDropPosition)0); - var w = _this.view.getWidgetAt(x,y); - this.addHighlight(w, pos); - return Gdk.DragAction.COPY; - }); - this.el.leave.connect( ( ) => { - this.addHighlight(null,""); - - }); - this.el.drop.connect( (v, x, y) => { - - this.addHighlight(null,""); - - - - var pos = ""; - // -- get position.. - if (this.lastDragString != v.get_string() || this.lastDragNode == null) { - // still dragging same node - - this.lastDragNode = new JsRender.Node(); - this.lastDragNode.loadFromJsonString(v.get_string(), 1); - } - - - - var dropNode = new JsRender.Node(); - dropNode.loadFromJsonString(v.get_string(), 1); - var drop_on_to = _this.main_window.windowstate.file.palete().getDropList(dropNode.fqn()); - - // if there are not items in the tree.. the we have to set isOver to true for anything.. - - if (_this.model.el.n_items < 1) { - // FIXME check valid drop types? - if (!drop_on_to.contains("*top")) { - GLib.debug("drop on to list does not contain top?"); - return false; - } - // add new node to top.. - - - var m = (GLib.ListStore) _this.model.el.model; - _this.main_window.windowstate.file.tree = dropNode; - - - m.append(dropNode); - _this.model.selectNode(dropNode); - _this.changed(); - return true; // no need to highlight? - - } - - - - var row = _this.view.getRowAt(x,y, out pos); - if (row < 0) { - return false; //Gdk.DragAction.COPY; - } - var tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row); - - var node = (JsRender.Node)tr.get_item(); - - if (pos == "above" || pos == "below") { - if (node.parent == null) { - pos = "over"; - } else { - if (!drop_on_to.contains(node.parent.fqn())) { - pos = "over"; - } else { - GLib.debug("drop contains %s - using %s" , node.parent.fqn(), pos); - } - } - - } - if (pos == "over") { - if (!drop_on_to.contains(node.fqn())) { - GLib.debug("drop on does not contain %s - try center" , node.fqn()); - return false; - - } - } - - switch(pos) { - case "over": - node.appendChild(dropNode); - _this.model.selectNode(dropNode); - _this.changed(); - return true; - - case "above": - GLib.debug("Above - insertBefore"); - - node.parent.insertBefore(dropNode, node); - _this.model.selectNode(dropNode); - _this.changed(); - return true; - - case "below": - GLib.debug("Below - insertAfter"); - node.parent.insertAfter(dropNode, node); - _this.model.selectNode(dropNode); - _this.changed(); - // select it - return true; - - default: - // should not happen - return false; - } - - - - - - - }); - } - - // user defined functions - public void addHighlight (Gtk.Widget? w, string hl) { - if (this.highlightWidget != null) { - var ww = this.highlightWidget; - GLib.debug("clear drag from previous highlight"); - if (ww.has_css_class("drag-below")) { - ww.remove_css_class("drag-below"); - } - if (ww.has_css_class("drag-above")) { - ww.remove_css_class("drag-above"); - } - if (ww.has_css_class("drag-over")) { - ww.remove_css_class("drag-over"); - } - } - if (w != null) { - GLib.debug("add drag=%s to widget", hl); - if (!w.has_css_class("drag-" + hl)) { - w.add_css_class("drag-" + hl); - } - } - this.highlightWidget = w; - } - } - - public class Xcls_selmodel : Object - { - public Gtk.SingleSelection el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_selmodel(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - _this.selmodel = this; - new Xcls_model( _this ); - this.el = new Gtk.SingleSelection( _this.model.el ); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.selection_changed.connect( (position, n_items) => { - - - - //if (!this.button_is_pressed && !this.key_is_pressed) { - // then event was started by some other action - // which should manually trigger all the events.. - // print("SKIPPING select - no button or key pressed\n"); - // return; - //} - - - if (_this.view.blockChanges) { // probably not needed.. - GLib.debug("SKIPPING select - blockchanges set.."); - return ; - } - - if (!_this.before_node_change( ) ) { - _this.view.blockChanges = true; - _this.selmodel.el.unselect_all(); - _this.view.blockChanges = false; - - return; - } - if (_this.main_window.windowstate.file == null) { - GLib.debug("SKIPPING select windowstate file is not set..."); - return; - } - - //var render = this.get('/LeftTree').getRenderer(); - GLib.debug("LEFT TREE -> view -> selection changed called"); - - - // -- it appears that the selection is not updated. - // select the node... - //_this.selmodel.el.set_selected(row); - - GLib.debug("LEFT TREE -> view -> selection changed TIMEOUT CALLED"); - - var snode = _this.selmodel.getSelectedNode(); - if (snode == null) { - - GLib.debug("selected rows < 1"); - //??this.model.load( false); - _this.node_selected(null); - - return ; - } - - // why dup_? - - - GLib.debug ("calling left_tree.node_selected"); - _this.node_selected(snode); - - - - - // no need to scroll. it's in the view as we clicked on it. - // _this.view.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f); - - return ; - }); - } - - // user defined functions - public JsRender.Node? getSelectedNode () { - if (this.el.selected_item == null) { - return null; - } - var tr = (Gtk.TreeListRow)this.el.selected_item; - return (JsRender.Node)tr.get_item(); - - } - public JsRender.Node getNodeAt (uint row) { - - var tr = (Gtk.TreeListRow)this.el.get_item(row); - - var a = tr.get_item();; - GLib.debug("get_item (2) = %s", a.get_type().name()); - - - return (JsRender.Node)tr.get_item(); - - } - } - public class Xcls_model : Object - { - public Gtk.TreeListModel el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_model(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - _this.model = this; - this.el = this.updateModel(null); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - public void loadFile (JsRender.JsRender f) { - //console.dump(f); - - _this.drop.highlightWidget = null; - - var m = (GLib.ListStore) this.el.model; - m.remove_all(); - _this.main_window.windowstate.leftTreeNodeSelected(null); - // needed??? - _this.main_window.windowstate.file = f; - - - if (f.tree == null) { - try { - f.loadItems( ); - } catch (Error e) { - return; - } - } - // if it's still null? - if (f.tree == null) { - _this.main_window.windowstate.showAddObject(_this.view.el, null); - - return; - } - m.append(f.tree); - // expand??? - - /* - if (f.tree.readItems().size < 1) { - // single item.. - - //this.get('/Window.leftvpaned').el.set_position(80); - // select first... - _this.view.el.set_cursor( - new Gtk.TreePath.from_string("0"), null, false); - - - } else { - //this.get('/Window.leftvpaned').el.set_position(200); - } - */ - - - - //_this.maincol.el.set_max_width(_this.viewwin.el.get_allocated_width() - 32); - - _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION); - - return; - - - } - public void deleteSelected () { - - - - var node = _this.selmodel.getSelectedNode(); - - - if (node == null) { - GLib.debug("delete Selected - no node slected?"); - return; - } - _this.selmodel.el.unselect_all(); - - node.remove(); - GLib.debug("delete Selected - done"); - _this.changed(); - /* - print("DELETE SELECTED?"); - //_this.view.blockChanges = true; - print("GET SELECTION?"); - - var s = _this.view.el.get_selection(); - - print("GET SELECTED?"); - Gtk.TreeIter iter; - Gtk.TreeModel mod; - - - if (!s.get_selected(out mod, out iter)) { - return; // nothing seleted.. - } - - - - this.activePath= ""; - print("GET vnode value?"); - - GLib.Value value; - this.el.get_value(iter, 2, out value); - var data = (JsRender.Node)(value.get_object()); - print("removing node from Render\n"); - if (data.parent == null) { - _this.main_window.windowstate.file.tree = null; - } else { - data.remove(); - } - print("removing node from Tree\n"); - s.unselect_all(); - this.el.remove(ref iter); - - - - - // - - - - - this.activePath= ""; // again!?!? - //this.changed(null,true); - - _this.changed(); - - _this.view.blockChanges = false; - */ - } - public Gtk.TreeListModel updateModel (GLib.ListStore? m) { - this.el = new Gtk.TreeListModel( - m != null ? m : new GLib.ListStore(typeof(JsRender.Node)), //..... << that's our store.. - false, // passthru - true, // autexpand - (item) => { - return ((JsRender.Node)item).childstore; - - } - ); - if (_this.selmodel.el == null) { - return this.el; - } - _this.selmodel.el.set_model(this.el); - return this.el; - } - public void selectNode (JsRender.Node node) - { - var row = -1; - var s = (Gtk.SingleSelection)_this.view.el.model; - for (var i = 0; i < s.n_items; i++) { - //GLib.debug("check node %s", s.get_item(i).get_type().name()); - var lr = (Gtk.TreeListRow)s.get_item(i); - GLib.debug("check node %s", lr.get_item().get_type().name()); - if (((JsRender.Node)lr.get_item()).oid == node.oid) { - row = i; - break; - } - } - if (row < 0) { - // select none? - GLib.debug("Could not find node"); - return; - } - GLib.debug("Select %d", row); - s.set_selected(row); - _this.node_selected(node); - - - } - } - - - public class Xcls_maincol : Object - { - public Gtk.ColumnViewColumn el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_maincol(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - _this.maincol = this; - var child_1 = new Xcls_SignalListItemFactory14( _this ); - child_1.ref(); - this.el = new Gtk.ColumnViewColumn( "Property", child_1.el ); - - // my vars (dec) - - // set gobject values - this.el.id = "maincol"; - this.el.expand = true; - this.el.resizable = true; - } - - // user defined functions - } - public class Xcls_SignalListItemFactory14 : Object - { - public Gtk.SignalListItemFactory el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_SignalListItemFactory14(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - this.el = new Gtk.SignalListItemFactory(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.setup.connect( (listitem) => { - - var expand = new Gtk.TreeExpander(); - - expand.set_indent_for_depth(true); - expand.set_indent_for_icon(true); - var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0); - var icon = new Gtk.Image(); - var lbl = new Gtk.Label(""); - lbl.use_markup = true; - lbl.ellipsize = Pango.EllipsizeMode.END; - - icon.margin_end = 4; - lbl.justify = Gtk.Justification.LEFT; - lbl.xalign = 0; - - // listitem.activatable = true; ?? - - hbox.append(icon); - hbox.append(lbl); - expand.set_child(hbox); - ((Gtk.ListItem)listitem).set_child(expand); - - }); - this.el.bind.connect( (listitem) => { - GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name()); - - //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); - var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); - - - var hbox = (Gtk.Box) expand.child; - - - var img = (Gtk.Image) hbox.get_first_child(); - var lbl = (Gtk.Label) img.get_next_sibling(); - - var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item(); - var node = (JsRender.Node) lr.get_item(); - - GLib.debug("node is %s", node.get_type().name()); - // was item (1) in old layout - - - - /* - var ic = Gtk.IconTheme.get_for_display(_this.el.get_display()); - var clsname = node.fqn(); - - var clsb = clsname.split("."); - var sub = clsb.length > 1 ? clsb[1].down() : ""; - - var fn = "/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-" + sub + ".png"; - try { - - - if (FileUtils.test (fn, FileTest.IS_REGULAR)) { - img.set_from_file(fn); - - } else { - img.set_from_paintable( - ic.lookup_icon ( - "media-playback-stop", null, 16,1, - Gtk.TextDirection.NONE, 0 - ) - ); - } - } catch (GLib.Error e) {} - */ - expand.set_hide_expander( !node.hasChildren() ); - expand.set_list_row(lr); - - node.bind_property("iconFilename", - img, "file", - GLib.BindingFlags.SYNC_CREATE); - - node.bind_property("nodeTitleProp", - lbl, "label", - GLib.BindingFlags.SYNC_CREATE); - node.bind_property("nodeTipProp", - lbl, "tooltip_markup", - GLib.BindingFlags.SYNC_CREATE); - // bind image... - - }); - } - - // user defined functions - } - - - public class Xcls_ColumnViewColumn15 : Object - { - public Gtk.ColumnViewColumn el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_ColumnViewColumn15(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - var child_1 = new Xcls_SignalListItemFactory16( _this ); - child_1.ref(); - this.el = new Gtk.ColumnViewColumn( "Add", child_1.el ); - - // my vars (dec) - - // set gobject values - this.el.fixed_width = 25; - } - - // user defined functions - } - public class Xcls_SignalListItemFactory16 : Object - { - public Gtk.SignalListItemFactory el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_SignalListItemFactory16(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - this.el = new Gtk.SignalListItemFactory(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.setup.connect( (listitem) => { - - - var icon = new Gtk.Image(); - - ((Gtk.ListItem)listitem).set_child(icon); - }); - this.el.bind.connect( (listitem) => { - - var img = (Gtk.Image) ((Gtk.ListItem)listitem).get_child(); - var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item(); - var node = (JsRender.Node) lr.get_item(); - - - var ic = Gtk.IconTheme.get_for_display(_this.el.get_display()); - img.set_from_paintable( - ic.lookup_icon ( - "list-add", null, 16,1, - Gtk.TextDirection.NONE, 0 - ) - ); - - var fqn = node.fqn(); - var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false); - - img.set_visible(cn.size > 0 ? true : false); - - }); - } - - // user defined functions - } - - - - public class Xcls_LeftTreeMenu : Object - { - public Gtk.Popover el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_LeftTreeMenu(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - _this.LeftTreeMenu = this; - this.el = new Gtk.Popover(); - - // my vars (dec) - - // set gobject values - var child_1 = new Xcls_Box18( _this ); - this.el.child = child_1.el; - } - - // user defined functions - } - public class Xcls_Box18 : Object - { - public Gtk.Box el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_Box18(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - var child_1 = new Xcls_Button19( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_Button20( _this ); - child_2.ref(); - this.el.append( child_2.el ); - var child_3 = new Xcls_Button21( _this ); - child_3.ref(); - this.el.append( child_3.el ); - } - - // user defined functions - } - public class Xcls_Button19 : Object - { - public Gtk.Button el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_Button19(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.label = "Delete Element"; - - //listeners - this.el.clicked.connect( ( ) => { - _this.LeftTreeMenu.el.hide(); - _this.model.deleteSelected(); - _this.changed(); - }); - } - - // user defined functions - } - - public class Xcls_Button20 : Object - { - public Gtk.Button el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_Button20(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.label = "Save as Template"; - - //listeners - this.el.clicked.connect( () => { - _this.LeftTreeMenu.el.hide(); - DialogSaveTemplate.singleton().showIt( - (Gtk.Window) _this.el.get_root (), - _this.main_window.windowstate.file.palete(), - _this.getActiveElement() - ); - - - }); - } - - // user defined functions - } - - public class Xcls_Button21 : Object - { - public Gtk.Button el; - private Xcls_WindowLeftTree _this; - - - // my vars (def) - - // ctor - public Xcls_Button21(Xcls_WindowLeftTree _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.label = "Save as Module"; - - //listeners - this.el.clicked.connect( () => { - - _this.LeftTreeMenu.el.hide(); - var node = _this.getActiveElement(); - - - var sm = DialogSaveModule.singleton(); - - - sm.showIt( - (Gtk.Window) _this.el.get_root (), - _this.main_window.windowstate.project, - node - ); - /* - gtk4 migration - disabled this part.. probably not used muchanyway - - - if (name.length < 1) { - return; - - } - node.set_prop( new JsRender.NodeProp.special("xinclude", name)); - node.items.clear(); - - - var s = _this.view.el.get_selection(); - - print("GET SELECTED?"); - Gtk.TreeIter iter; - Gtk.TreeModel mod; - - - if (!s.get_selected(out mod, out iter)) { - return; // nothing seleted.. - } - Gtk.TreeIter citer; - var n_cn = mod.iter_n_children(iter) -1; - for (var i = n_cn; i > -1; i--) { - mod.iter_nth_child(out citer, iter, i); - - - print("removing node from Tree\n"); - - _this.model.el.remove(ref citer); - } - _this.changed(); - _this.node_selected(node, "tree"); - */ - - }); - } - - // user defined functions - } - - - - - } + // my vars (dec) + this.highlightWidget = null; + this.lastDragNode = null; + this.lastDragString = ""; + + // set gobject values + + //listeners + this.el.accept.connect( (drop) => { + + GLib.debug("got DropTarget:accept"); + + // NOT REALLY NEEDED? = put stuff in drop? + + + /* ( ctx, x, y, time) => { + //Seed.print("TARGET: drag-drop"); + + + var src = Gtk.drag_get_source_widget(ctx); + + if (src != this.el) { + + + + this.drag_in_motion = false; + // request data that will be recieved by the recieve... + Gtk.drag_get_data + ( + this.el, // will receive 'drag-data-received' signal + ctx, // represents the current state of the DnD + Gdk.Atom.intern("application/json",true), // the target type we want + time // time stamp + ); + + + // No target offered by source => error + + + return false; + } + + // handle drop around self.. + + + + //print("GETTING POS"); + var targetData = ""; + + Gtk.TreePath path; + Gtk.TreeViewDropPosition pos; + var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos); + + // if there are not items in the tree.. the we have to set isOver to true for anything.. + var isEmpty = false; + if (_this.model.el.iter_n_children(null) < 1) { + print("got NO children?\n"); + isOver = true; //??? + isEmpty = true; + pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER; + } + + + + //var action = Gdk.DragAction.COPY; + // unless we are copying!!! ctl button.. + + var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ? + Gdk.DragAction.COPY : Gdk.DragAction.MOVE ; + // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ; + + + if (_this.model.el.iter_n_children(null) < 1) { + // no children.. -- asume it's ok.. + + targetData = "|%d|".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER); + + // continue through to allow drop... + + } else { + + + + + + //print("ISOVER? " + isOver); + if (!isOver) { + + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + return true; // not over apoint!?! - no action on drop or motion.. + } + + // drag node is parent of child.. + //console.log("SRC TREEPATH: " + src.treepath); + //console.log("TARGET TREEPATH: " + data.path.to_string()); + + // nned to check a few here.. + //Gtk.TreeViewDropPosition.INTO_OR_AFTER + //Gtk.TreeViewDropPosition.INTO_OR_BEFORE + //Gtk.TreeViewDropPosition.AFTER + //Gtk.TreeViewDropPosition.BEFORE + + // locally dragged items to not really use the + var selection_text = this.dragData; + + + + if (selection_text == null || selection_text.length < 1) { + //print("Error - drag selection text returned NULL"); + + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + return true; /// -- fixme -- this is not really correct.. + } + + // see if we are dragging into ourself? + print ("got selection text of " + selection_text); + + var target_path = path.to_string(); + //print("target_path="+target_path); + + // + if (selection_text == target_path) { + print("self drag ?? == we should perhaps allow copy onto self..\n"); + + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + + return true; /// -- fixme -- this is not really correct.. + + } + + // check that + //print("DUMPING DATA"); + //console.dump(data); + // path, pos + + //print(data.path.to_string() +' => '+ data.pos); + + // dropList is a list of xtypes that this node could be dropped on. + // it is set up when we start to drag.. + + + targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos); + + print("targetDAta: " + targetData +"\n"); + + if (targetData.length < 1) { + //print("Can not find drop node path"); + + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + return true; + } + + + + // continue on to allow drop.. + } + // at this point, drag is not in motion... -- as checked above... - so it's a real drop event.. + + + var delete_selection_data = false; + + if (action == Gdk.DragAction.ASK) { + // Ask the user to move or copy, then set the ctx action. + } + + if (action == Gdk.DragAction.MOVE) { + delete_selection_data = true; + } + + // drag around.. - reorder.. + _this.model.moveNode(targetData, action); + + + + + + // we can send stuff to souce here... + + + // do we always say failure, so we handle the reall drop? + Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time); + + return true; + + + + + + + } + */ + return true; + }); + this.el.motion.connect( ( x, y) => { + + string pos; // over / before / after.. + + GLib.debug("got drag motion"); + + GLib.Value v = GLib.Value(typeof(string)); + //var str = drop.read_text( [ "text/plain" ] 0); + var cont = this.el.current_drop.get_drag().content ; + try { + cont.get_value(ref v); + } catch (GLib.Error e) { + GLib.debug("failed to get drag value"); + return Gdk.DragAction.COPY; + + } + + GLib.debug("got %s", v.get_string()); + + if (this.lastDragString != v.get_string() || this.lastDragNode == null) { + // still dragging same node + + this.lastDragNode = new JsRender.Node(); + this.lastDragNode.loadFromJsonString(v.get_string(), 1); + } + + + var drop_on_to = _this.main_window.windowstate.file.palete().getDropList( + this.lastDragNode.fqn()); + + string[] str = {}; + foreach(var dp in drop_on_to) { + str += dp; + } + GLib.debug("droplist: %s", string.joinv(", ", str)); + + + // if there are not items in the tree.. the we have to set isOver to true for anything.. + + if (_this.model.el.n_items < 1) { + // FIXME check valid drop types? + if (drop_on_to.contains("*top")) { + this.addHighlight(_this.view.el, "over"); + } else { + this.addHighlight(null, ""); + } + + return Gdk.DragAction.COPY; // no need to highlight? + + } + + + GLib.debug("check is over"); + + // if path of source and dest are inside each other.. + // need to add source info to drag? + // the fail(); + var row = _this.view.getRowAt(x,y, out pos); + + if (row < 0) { + this.addHighlight(null, ""); + return Gdk.DragAction.COPY; + } + var tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row); + + var node = (JsRender.Node)tr.get_item(); + + GLib.debug("Drop over node: %s", node.fqn()); + + + if (pos == "above" || pos == "below") { + if (node.parent == null) { + GLib.debug("no parent try center"); + pos = "over"; + } else { + + if (!drop_on_to.contains(node.parent.fqn())) { + GLib.debug("drop on does not contain %s - try center" , node.parent.fqn()); + pos = "over"; + } else { + GLib.debug("drop contains %s - using %s" , node.parent.fqn(), pos); + } + } + + } + if (pos == "over") { + if (!drop_on_to.contains(node.fqn())) { + GLib.debug("drop on does not contain %s - try center" , node.fqn()); + this.addHighlight(null, ""); + return Gdk.DragAction.COPY; + } + } + + + // _this.view.highlightDropPath("", (Gtk.TreeViewDropPosition)0); + var w = _this.view.getWidgetAt(x,y); + this.addHighlight(w, pos); + return Gdk.DragAction.COPY; + }); + this.el.leave.connect( ( ) => { + this.addHighlight(null,""); + + }); + this.el.drop.connect( (v, x, y) => { + + this.addHighlight(null,""); + + + + var pos = ""; + // -- get position.. + if (this.lastDragString != v.get_string() || this.lastDragNode == null) { + // still dragging same node + + this.lastDragNode = new JsRender.Node(); + this.lastDragNode.loadFromJsonString(v.get_string(), 1); + } + + + + var dropNode = new JsRender.Node(); + dropNode.loadFromJsonString(v.get_string(), 1); + var drop_on_to = _this.main_window.windowstate.file.palete().getDropList(dropNode.fqn()); + + // if there are not items in the tree.. the we have to set isOver to true for anything.. + + if (_this.model.el.n_items < 1) { + // FIXME check valid drop types? + if (!drop_on_to.contains("*top")) { + GLib.debug("drop on to list does not contain top?"); + return false; + } + // add new node to top.. + + + var m = (GLib.ListStore) _this.model.el.model; + _this.main_window.windowstate.file.tree = dropNode; + + + m.append(dropNode); + _this.model.selectNode(dropNode); + _this.changed(); + return true; // no need to highlight? + + } + + + + var row = _this.view.getRowAt(x,y, out pos); + if (row < 0) { + return false; //Gdk.DragAction.COPY; + } + var tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row); + + var node = (JsRender.Node)tr.get_item(); + + if (pos == "above" || pos == "below") { + if (node.parent == null) { + pos = "over"; + } else { + if (!drop_on_to.contains(node.parent.fqn())) { + pos = "over"; + } else { + GLib.debug("drop contains %s - using %s" , node.parent.fqn(), pos); + } + } + + } + if (pos == "over") { + if (!drop_on_to.contains(node.fqn())) { + GLib.debug("drop on does not contain %s - try center" , node.fqn()); + return false; + + } + } + + switch(pos) { + case "over": + node.appendChild(dropNode); + _this.model.selectNode(dropNode); + _this.changed(); + return true; + + case "above": + GLib.debug("Above - insertBefore"); + + node.parent.insertBefore(dropNode, node); + _this.model.selectNode(dropNode); + _this.changed(); + return true; + + case "below": + GLib.debug("Below - insertAfter"); + node.parent.insertAfter(dropNode, node); + _this.model.selectNode(dropNode); + _this.changed(); + // select it + return true; + + default: + // should not happen + return false; + } + + + + + + + }); + } + + // user defined functions + public void addHighlight (Gtk.Widget? w, string hl) { + if (this.highlightWidget != null) { + var ww = this.highlightWidget; + GLib.debug("clear drag from previous highlight"); + if (ww.has_css_class("drag-below")) { + ww.remove_css_class("drag-below"); + } + if (ww.has_css_class("drag-above")) { + ww.remove_css_class("drag-above"); + } + if (ww.has_css_class("drag-over")) { + ww.remove_css_class("drag-over"); + } + } + if (w != null) { + GLib.debug("add drag=%s to widget", hl); + if (!w.has_css_class("drag-" + hl)) { + w.add_css_class("drag-" + hl); + } + } + this.highlightWidget = w; + } + } + + public class Xcls_selmodel : Object + { + public Gtk.SingleSelection el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_selmodel(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + _this.selmodel = this; + new Xcls_model( _this ); + this.el = new Gtk.SingleSelection( _this.model.el ); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.selection_changed.connect( (position, n_items) => { + + + + //if (!this.button_is_pressed && !this.key_is_pressed) { + // then event was started by some other action + // which should manually trigger all the events.. + // print("SKIPPING select - no button or key pressed\n"); + // return; + //} + + + if (_this.view.blockChanges) { // probably not needed.. + GLib.debug("SKIPPING select - blockchanges set.."); + return ; + } + + if (!_this.before_node_change( ) ) { + _this.view.blockChanges = true; + _this.selmodel.el.unselect_all(); + _this.view.blockChanges = false; + + return; + } + if (_this.main_window.windowstate.file == null) { + GLib.debug("SKIPPING select windowstate file is not set..."); + return; + } + + //var render = this.get('/LeftTree').getRenderer(); + GLib.debug("LEFT TREE -> view -> selection changed called"); + + + // -- it appears that the selection is not updated. + // select the node... + //_this.selmodel.el.set_selected(row); + + GLib.debug("LEFT TREE -> view -> selection changed TIMEOUT CALLED"); + + var snode = _this.selmodel.getSelectedNode(); + if (snode == null) { + + GLib.debug("selected rows < 1"); + //??this.model.load( false); + _this.node_selected(null); + + return ; + } + + // why dup_? + + + GLib.debug ("calling left_tree.node_selected"); + _this.node_selected(snode); + + + + + // no need to scroll. it's in the view as we clicked on it. + // _this.view.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f); + + return ; + }); + } + + // user defined functions + public JsRender.Node? getSelectedNode () { + if (this.el.selected_item == null) { + return null; + } + var tr = (Gtk.TreeListRow)this.el.selected_item; + return (JsRender.Node)tr.get_item(); + + } + public JsRender.Node getNodeAt (uint row) { + + var tr = (Gtk.TreeListRow)this.el.get_item(row); + + var a = tr.get_item();; + GLib.debug("get_item (2) = %s", a.get_type().name()); + + + return (JsRender.Node)tr.get_item(); + + } + } + public class Xcls_model : Object + { + public Gtk.TreeListModel el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_model(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + _this.model = this; + this.el = this.updateModel(null); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void loadFile (JsRender.JsRender f) { + //console.dump(f); + + _this.drop.highlightWidget = null; + + var m = (GLib.ListStore) this.el.model; + m.remove_all(); + _this.main_window.windowstate.leftTreeNodeSelected(null); + // needed??? + _this.main_window.windowstate.file = f; + + + if (f.tree == null) { + try { + f.loadItems( ); + } catch (Error e) { + return; + } + } + // if it's still null? + if (f.tree == null) { + _this.main_window.windowstate.showAddObject(_this.view.el, null); + + return; + } + m.append(f.tree); + // expand??? + + /* + if (f.tree.readItems().size < 1) { + // single item.. + + //this.get('/Window.leftvpaned').el.set_position(80); + // select first... + _this.view.el.set_cursor( + new Gtk.TreePath.from_string("0"), null, false); + + + } else { + //this.get('/Window.leftvpaned').el.set_position(200); + } + */ + + + + //_this.maincol.el.set_max_width(_this.viewwin.el.get_allocated_width() - 32); + + _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION); + + return; + + + } + public void deleteSelected () { + + + + var node = _this.selmodel.getSelectedNode(); + + + if (node == null) { + GLib.debug("delete Selected - no node slected?"); + return; + } + _this.selmodel.el.unselect_all(); + + node.remove(); + GLib.debug("delete Selected - done"); + _this.changed(); + /* + print("DELETE SELECTED?"); + //_this.view.blockChanges = true; + print("GET SELECTION?"); + + var s = _this.view.el.get_selection(); + + print("GET SELECTED?"); + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + + if (!s.get_selected(out mod, out iter)) { + return; // nothing seleted.. + } + + + + this.activePath= ""; + print("GET vnode value?"); + + GLib.Value value; + this.el.get_value(iter, 2, out value); + var data = (JsRender.Node)(value.get_object()); + print("removing node from Render\n"); + if (data.parent == null) { + _this.main_window.windowstate.file.tree = null; + } else { + data.remove(); + } + print("removing node from Tree\n"); + s.unselect_all(); + this.el.remove(ref iter); + + + + + // + + + + + this.activePath= ""; // again!?!? + //this.changed(null,true); + + _this.changed(); + + _this.view.blockChanges = false; + */ + } + public Gtk.TreeListModel updateModel (GLib.ListStore? m) { + this.el = new Gtk.TreeListModel( + m != null ? m : new GLib.ListStore(typeof(JsRender.Node)), //..... << that's our store.. + false, // passthru + true, // autexpand + (item) => { + return ((JsRender.Node)item).childstore; + + } + ); + if (_this.selmodel.el == null) { + return this.el; + } + _this.selmodel.el.set_model(this.el); + return this.el; + } + public void selectNode (JsRender.Node node) + { + var row = -1; + var s = (Gtk.SingleSelection)_this.view.el.model; + for (var i = 0; i < s.n_items; i++) { + //GLib.debug("check node %s", s.get_item(i).get_type().name()); + var lr = (Gtk.TreeListRow)s.get_item(i); + GLib.debug("check node %s", lr.get_item().get_type().name()); + if (((JsRender.Node)lr.get_item()).oid == node.oid) { + row = i; + break; + } + } + if (row < 0) { + // select none? + GLib.debug("Could not find node"); + return; + } + GLib.debug("Select %d", row); + s.set_selected(row); + _this.view.el.scroll_to(row, null, Gtk.ListScrollFlags.SELECT, null); + //_this.node_selected(node); + + + } + } + + + public class Xcls_maincol : Object + { + public Gtk.ColumnViewColumn el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_maincol(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + _this.maincol = this; + var child_1 = new Xcls_SignalListItemFactory14( _this ); + child_1.ref(); + this.el = new Gtk.ColumnViewColumn( "Property", child_1.el ); + + // my vars (dec) + + // set gobject values + this.el.id = "maincol"; + this.el.expand = true; + this.el.resizable = true; + } + + // user defined functions + } + public class Xcls_SignalListItemFactory14 : Object + { + public Gtk.SignalListItemFactory el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_SignalListItemFactory14(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.SignalListItemFactory(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.setup.connect( (listitem) => { + + var expand = new Gtk.TreeExpander(); + + expand.set_indent_for_depth(true); + expand.set_indent_for_icon(true); + var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0); + var icon = new Gtk.Image(); + var lbl = new Gtk.Label(""); + lbl.use_markup = true; + lbl.ellipsize = Pango.EllipsizeMode.END; + + icon.margin_end = 4; + lbl.justify = Gtk.Justification.LEFT; + lbl.xalign = 0; + + // listitem.activatable = true; ?? + + hbox.append(icon); + hbox.append(lbl); + expand.set_child(hbox); + ((Gtk.ListItem)listitem).set_child(expand); + + }); + this.el.bind.connect( (listitem) => { + GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name()); + + //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); + var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); + + + var hbox = (Gtk.Box) expand.child; + + + var img = (Gtk.Image) hbox.get_first_child(); + var lbl = (Gtk.Label) img.get_next_sibling(); + + var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item(); + var node = (JsRender.Node) lr.get_item(); + + GLib.debug("node is %s", node.get_type().name()); + // was item (1) in old layout + + + + /* + var ic = Gtk.IconTheme.get_for_display(_this.el.get_display()); + var clsname = node.fqn(); + + var clsb = clsname.split("."); + var sub = clsb.length > 1 ? clsb[1].down() : ""; + + var fn = "/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-" + sub + ".png"; + try { + + + if (FileUtils.test (fn, FileTest.IS_REGULAR)) { + img.set_from_file(fn); + + } else { + img.set_from_paintable( + ic.lookup_icon ( + "media-playback-stop", null, 16,1, + Gtk.TextDirection.NONE, 0 + ) + ); + } + } catch (GLib.Error e) {} + */ + expand.set_hide_expander( !node.hasChildren() ); + expand.set_list_row(lr); + + node.bind_property("iconFilename", + img, "file", + GLib.BindingFlags.SYNC_CREATE); + + node.bind_property("nodeTitleProp", + lbl, "label", + GLib.BindingFlags.SYNC_CREATE); + node.bind_property("nodeTipProp", + lbl, "tooltip_markup", + GLib.BindingFlags.SYNC_CREATE); + // bind image... + + }); + } + + // user defined functions + } + + + public class Xcls_ColumnViewColumn15 : Object + { + public Gtk.ColumnViewColumn el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_ColumnViewColumn15(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + var child_1 = new Xcls_SignalListItemFactory16( _this ); + child_1.ref(); + this.el = new Gtk.ColumnViewColumn( "Add", child_1.el ); + + // my vars (dec) + + // set gobject values + this.el.fixed_width = 25; + } + + // user defined functions + } + public class Xcls_SignalListItemFactory16 : Object + { + public Gtk.SignalListItemFactory el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_SignalListItemFactory16(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.SignalListItemFactory(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.setup.connect( (listitem) => { + + + var icon = new Gtk.Image(); + + ((Gtk.ListItem)listitem).set_child(icon); + }); + this.el.bind.connect( (listitem) => { + + var img = (Gtk.Image) ((Gtk.ListItem)listitem).get_child(); + var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item(); + var node = (JsRender.Node) lr.get_item(); + + + var ic = Gtk.IconTheme.get_for_display(_this.el.get_display()); + img.set_from_paintable( + ic.lookup_icon ( + "list-add", null, 16,1, + Gtk.TextDirection.NONE, 0 + ) + ); + + var fqn = node.fqn(); + var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false); + + img.set_visible(cn.size > 0 ? true : false); + + }); + } + + // user defined functions + } + + + + public class Xcls_LeftTreeMenu : Object + { + public Gtk.Popover el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_LeftTreeMenu(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + _this.LeftTreeMenu = this; + this.el = new Gtk.Popover(); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Box18( _this ); + this.el.child = child_1.el; + } + + // user defined functions + } + public class Xcls_Box18 : Object + { + public Gtk.Box el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_Box18(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_1 = new Xcls_Button19( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_Button20( _this ); + child_2.ref(); + this.el.append( child_2.el ); + var child_3 = new Xcls_Button21( _this ); + child_3.ref(); + this.el.append( child_3.el ); + } + + // user defined functions + } + public class Xcls_Button19 : Object + { + public Gtk.Button el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_Button19(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Delete Element"; + + //listeners + this.el.clicked.connect( ( ) => { + _this.LeftTreeMenu.el.hide(); + _this.model.deleteSelected(); + _this.changed(); + }); + } + + // user defined functions + } + + public class Xcls_Button20 : Object + { + public Gtk.Button el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_Button20(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Save as Template"; + + //listeners + this.el.clicked.connect( () => { + _this.LeftTreeMenu.el.hide(); + DialogSaveTemplate.singleton().showIt( + (Gtk.Window) _this.el.get_root (), + _this.main_window.windowstate.file.palete(), + _this.getActiveElement() + ); + + + }); + } + + // user defined functions + } + + public class Xcls_Button21 : Object + { + public Gtk.Button el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_Button21(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Save as Module"; + + //listeners + this.el.clicked.connect( () => { + + _this.LeftTreeMenu.el.hide(); + var node = _this.getActiveElement(); + + + var sm = DialogSaveModule.singleton(); + + + sm.showIt( + (Gtk.Window) _this.el.get_root (), + _this.main_window.windowstate.project, + node + ); + /* + gtk4 migration - disabled this part.. probably not used muchanyway + + + if (name.length < 1) { + return; + + } + node.set_prop( new JsRender.NodeProp.special("xinclude", name)); + node.items.clear(); + + + var s = _this.view.el.get_selection(); + + print("GET SELECTED?"); + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + + if (!s.get_selected(out mod, out iter)) { + return; // nothing seleted.. + } + Gtk.TreeIter citer; + var n_cn = mod.iter_n_children(iter) -1; + for (var i = n_cn; i > -1; i--) { + mod.iter_nth_child(out citer, iter, i); + + + print("removing node from Tree\n"); + + _this.model.el.remove(ref citer); + } + _this.changed(); + _this.node_selected(node, "tree"); + */ + + }); + } + + // user defined functions + } + + + + +} diff --git a/src/Builder4/WindowRooView.bjs b/src/Builder4/WindowRooView.bjs index 506da32fb..22823176d 100644 --- a/src/Builder4/WindowRooView.bjs +++ b/src/Builder4/WindowRooView.bjs @@ -592,8 +592,10 @@ "$ xns" : "GtkSource", "* pack" : "set_buffer", "bool dirty" : false, + "bool in_cursor_change" : false, "id" : "buffer", "int error_line" : "-1", + "int last_line" : "-1", "listeners" : { "changed" : [ " () => {", @@ -671,6 +673,38 @@ "", " ", "" + ], + "cursor_moved" : [ + "( ) => {", + "GLib.debug(\"cursor moved called\");", + "", + "", + " \tif (this.in_cursor_change ) {", + " GLib.debug(\"cursor changed : %d [ignoring nested call)\", this.el.cursor_position);", + " return;", + " }", + " ", + " GLib.debug(\"cursor changed : %d\", this.el.cursor_position);", + " Gtk.TextIter cpos;", + " this.el.get_iter_at_offset(out cpos, this.el.cursor_position);", + " ", + " var ln = cpos.get_line();", + " if (this.last_line == ln ){", + " \treturn;", + "\t}", + "\tthis.last_line = ln;", + " var node = _this.file.lineToNode(ln);", + "", + " if (node == null) {", + " print(\"can not find node\\n\");", + " return;", + " }", + " this.in_cursor_change = true;", + " var ltree = _this.main_window.windowstate.left_tree;", + " ltree.model.selectNode(node);", + " this.in_cursor_change = false;", + "}", + "" ] }, "xtype" : "Buffer", @@ -745,22 +779,6 @@ ] }, "xtype" : "EventControllerKey" - }, - { - "$ xns" : "Gtk", - "listeners" : { - "released" : [ - "(n_press, x, y) => {", - "", - "\tprint(\"BUTTON RELEASE EVENT\\n\");", - "\t_this.sourceview.onCursorChanged();", - "\t//this.button_is_pressed = false;", - "\t ", - "}", - "" - ] - }, - "xtype" : "GestureClick" } ], "listeners" : { @@ -874,18 +892,18 @@ " ", " _this.main_window.windowstate.updateErrorMarksAll();", " ", - " // what does this do?", + " // restore the cursor position?", + " // after reloading the contents.", " GLib.Timeout.add(500, () => {", - "", + "\t\t_this.buffer.in_cursor_change = true;", " print(\"RESORTING cursor to = %d\\n\", cpos);", "\t\tGtk.TextIter cpos_iter;", "\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);", "\t\tbuf.place_cursor(cpos_iter); ", "\t\t", "\t\tthis.el.get_vadjustment().set_value(vadj_pos);;", - "\t\t", - "", - "\t\tthis.onCursorChanged();", + "\t\t_this.buffer.in_cursor_change = false;", + " ", "\t\t", "\t\t", "\t\t//_this.buffer.checkSyntax();", @@ -898,101 +916,63 @@ "" ], "| void nodeSelected" : [ - "(JsRender.Node? sel, bool scroll ) {", + "(JsRender.Node? sel, bool scroll) {", " ", " ", - "\t", + " if (this.loading) {", + " \treturn;", + "\t}", " // this is connected in widnowstate", + " print(\"Roo-view - node selected\\n\");", + " var buf = this.el.get_buffer();", + " ", + " var sbuf = (GtkSource.Buffer) buf;", "", - "", - "\t// not sure why.... ", - " // while(Gtk.events_pending()) {", - " // Gtk.main_iteration();", - " // }", " ", - " this.node_selected = sel;", " ", - " // this.updateGreySelection(scroll);", + " ", + " // clear all the marks..", + " Gtk.TextIter start;", + " Gtk.TextIter end; ", + " ", + " sbuf.get_bounds (out start, out end);", + " sbuf.remove_source_marks (start, end, \"grey\");", " ", + " this.node_selected = sel;", + " if (sel == null) {", + " // no highlighting..", + " return;", + " }", + " Gtk.TextIter iter; ", + " sbuf.get_iter_at_line(out iter, sel.line_start);", " ", " ", - "}", - "", - " ", - "" - ], - "| void onCursorChanged" : [ - "(/*ParamSpec ps*/) {", - "", - "\t\tif (!this.key_is_pressed && !this.button_is_pressed) {", - "\t\t\treturn;", - "\t\t}", - "", - "\t if (this.loading) {", - " return;", - " }", - " // if (ps.name != \"cursor-position\") {", - " // return;", - " // }", - "", - " var buf = this.el.get_buffer();", - " //print(\"cursor changed : %d\\n\", buf.cursor_position);", - " Gtk.TextIter cpos;", - " buf.get_iter_at_offset(out cpos, buf.cursor_position);", - " ", - " var ln = cpos.get_line();", - " ", - " ", - " // --- select node at line....", - " ", - " var node = _this.file.lineToNode(ln+1);", - " ", - " if (node == null) {", - " print(\"can not find node\\n\");", - " return;", + " Gtk.TextIter cur_iter;", + " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);", + " ", + " //var cur_line = cur_iter.get_line();", + " //if (cur_line > sel.line_start && cur_line < sel.line_end) {", + " ", + " //} else {", + " if (! _this.buffer.in_cursor_change) {", + " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);", + "\t}", + " ", + " ", + " ", + " for (var i = 0; i < buf.get_line_count();i++) {", + " if (i < sel.line_start || i > sel.line_end) {", + " ", + " sbuf.get_iter_at_line(out iter, i);", + " sbuf.create_source_mark(null, \"grey\", iter);", + " ", " }", - " var prop = node.lineToProp(ln+1);", - " print(\"prop : %s\", prop == null ? \"???\" : prop.name);", - " ", - " ", - " // ---------- this selects the tree's node...", - " ", - " var ltree = _this.main_window.windowstate.left_tree;", - " ltree.model.selectNode(node);", - " ", - "\t ", - " //print(\"changing cursor on tree..\\n\");", - " ", + " ", + " }", + " ", "", - " ", - " // let's try allowing editing on the methods.", - " // a little klunky at present..", - " this.prop_selected = \"\";", - " /*", - " if (prop != null) {", - " \t\t//see if we can find it..", - " \t\tvar kv = prop.split(\":\");", - " \t\tif (kv[0] == \"p\") {", - " \t\t", - " \t\t//var k = prop.get_key(kv[1]);", - " \t\t// fixme -- need to determine if it's an editable property...", - " \t\tthis.prop_selected = prop;", - " \t\t", - " \t\t} else if (kv[0] == \"l\") {", - " \t\t\t this.prop_selected = prop;", - " \t\t\t", - " \t\t}", - " }", - " */", - " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ", - " //this.nodeSelected(node,false);", - " ", - " // scrolling is disabled... as node selection calls scroll 10ms after it changes.", - " ", - " ", - " // highlight the node..", "}", - " " + "" ], "| void updateGreySelection" : [ "(bool scroll) { ", diff --git a/src/Builder4/WindowRooView.vala b/src/Builder4/WindowRooView.vala index e8d16f4ba..1ea8faad9 100644 --- a/src/Builder4/WindowRooView.vala +++ b/src/Builder4/WindowRooView.vala @@ -1,2184 +1,2150 @@ - static Xcls_WindowRooView _WindowRooView; - - public class Xcls_WindowRooView : Object - { - public Gtk.Box el; - private Xcls_WindowRooView _this; - - public static Xcls_WindowRooView singleton() - { - if (_WindowRooView == null) { - _WindowRooView= new Xcls_WindowRooView(); - } - return _WindowRooView; - } - public Xcls_notebook notebook; - public Xcls_label_preview label_preview; - public Xcls_label_code label_code; - public Xcls_paned paned; - public Xcls_viewbox viewbox; - public Xcls_AutoRedraw AutoRedraw; - public Xcls_view view; - public Xcls_inspectorcontainer inspectorcontainer; - public Xcls_sourceviewscroll sourceviewscroll; - public Xcls_sourceview sourceview; - public Xcls_buffer buffer; - public Xcls_search_entry search_entry; - public Xcls_search_results search_results; - public Xcls_nextBtn nextBtn; - public Xcls_backBtn backBtn; - public Xcls_search_settings search_settings; - public Xcls_case_sensitive case_sensitive; - public Xcls_regex regex; - public Xcls_multiline multiline; - - // my vars (def) - public Gtk.Widget lastObj; - public Xcls_MainWindow main_window; - public int last_search_end; - public GtkSource.SearchContext searchcontext; - public JsRender.JsRender file; - - // ctor - public Xcls_WindowRooView() - { - _this = this; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - this.lastObj = null; - this.last_search_end = 0; - this.file = null; - - // set gobject values - this.el.hexpand = true; - this.el.vexpand = true; - new Xcls_notebook( _this ); - this.el.append( _this.notebook.el ); - } - - // user defined functions - public void loadFile (JsRender.JsRender file) - { - this.file = file; - this.view.renderJS(true); - this.notebook.el.page = 0;// gtk preview - this.sourceview.loadFile(); - } - public void highlightNodeAtLine (int ln) { - - - - // highlight node... - - - var node = _this.file.lineToNode(ln+1); - - if (node == null) { - //print("can not find node\n"); - return; - } - var prop = node.lineToProp(ln+1); - print("prop : %s", prop == null ? "???" : prop.name); - - - // ---------- this selects the tree's node... - - var ltree = _this.main_window.windowstate.left_tree; - ltree.model.selectNode(node); - - //_this.sourceview.allow_node_scroll = false; /// block node scrolling.. - - - //print("changing cursor on tree..\n"); - - - - // let's try allowing editing on the methods. - // a little klunky at present.. - _this.sourceview.prop_selected = ""; - /* - if (prop != null) { - //see if we can find it.. - var kv = prop.split(":"); - if (kv[0] == "p") { - - //var k = prop.get_key(kv[1]); - // fixme -- need to determine if it's an editable property... - _this.sourceview.prop_selected = prop; - - } else if (kv[0] == "l") { - _this.sourceview.prop_selected = prop; - - } - } - */ - // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); - _this.sourceview.nodeSelected(node,false); - - // scrolling is disabled... as node selection calls scroll 10ms after it changes. - // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => { - // this.allow_node_scroll = true; - // return false; - // }); - // } - - - - - - - - - - - - } - public void requestRedraw () { - this.view.renderJS(false); - this.sourceview.loadFile(); - } - public void forwardSearch (bool change_focus) { - - if (this.searchcontext == null) { - return; - } - this.notebook.el.page = 1; - Gtk.TextIter beg, st,en; - bool has_wrapped_around; - var buf = this.sourceview.el.get_buffer(); - buf.get_iter_at_offset(out beg, this.last_search_end); - if (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) { - this.last_search_end = 0; - return; - } - this.last_search_end = en.get_offset(); - if (change_focus) { - this.sourceview.el.grab_focus(); - } - buf.place_cursor(st); - - - - this.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f); - - - var ln = st.get_line(); - - this.highlightNodeAtLine(ln); - } - public void backSearch (bool change_focus) { - - if (this.searchcontext == null) { - return; - } - - Gtk.TextIter beg, st,en; - bool has_wrapped_around; - this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 ); - - if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) { - - this.last_search_end = 0; - return; - } - this.last_search_end = en.get_offset(); - if (change_focus) { - this.sourceview.el.grab_focus(); - } - this.buffer.el.place_cursor(st); - this.sourceview.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f); - var ln = st.get_line(); - this.highlightNodeAtLine(ln); - - - } - public int search (string in_txt) { - this.notebook.el.page = 1; - - - - var s = new GtkSource.SearchSettings(); - s.case_sensitive = _this.case_sensitive.el.active; - s.regex_enabled = _this.regex.el.active; - s.wrap_around = false; - - this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s); - this.searchcontext.set_highlight(true); - var txt = in_txt; - - if (_this.multiline.el.active) { - txt = in_txt.replace("\\n", "\n"); - } - - s.set_search_text(txt); - Gtk.TextIter beg, st,en; - bool has_wrapped_around; - this.buffer.el.get_start_iter(out beg); - this.searchcontext.forward(beg, out st, out en, out has_wrapped_around); - this.last_search_end = 0; - - return this.searchcontext.get_occurrences_count(); - - - - - } - public void createThumb () { - - - if (this.file == null) { - return; - } - - if (this.notebook.el.page > 0 ) { - return; - } - - this.file.widgetToIcon(this.view.el); - - - - - - } - public void updateErrorMarks (string category) { - - - - var buf = _this.buffer.el; - Gtk.TextIter start; - Gtk.TextIter end; - buf.get_bounds (out start, out end); - - buf.remove_source_marks (start, end, category); - - GLib.debug("highlight errors"); - - // we should highlight other types of errors.. - - - - - if (_this.file == null) { - GLib.debug("file is null?"); - return; - - } - var ar = this.file.getErrors(category); - if (ar == null || ar.get_n_items() < 1) { - GLib.debug("higjlight %s has no errors", category); - return; - } - - - - - var offset = 0; - - - var tlines = buf.get_line_count () +1; - - - - for (var i = 0; i < ar.get_n_items();i++) { - var err = (Palete.CompileError) ar.get_item(i); - - Gtk.TextIter iter; - // print("get inter\n"); - var eline = err.line - offset; - GLib.debug("GOT ERROR on line %d -- converted to %d (offset = %d)", - err.line ,eline, offset); - - - if (eline > tlines || eline < 0) { - return; - } - - - buf.get_iter_at_line( out iter, eline); - - - var msg = "Line: %d %s : %s".printf(eline+1, err.category, err.msg); - buf.create_source_mark( msg, err.category, iter); - GLib.debug("set line %d to %s", eline, msg); - //this.marks.set(eline, msg); - } - return ; - - - - - - } - public void scroll_to_line (int line) { - // code preview... - - GLib.Timeout.add(100, () => { - - this.notebook.el.set_current_page( 1 ); - - - var buf = this.sourceview.el.get_buffer(); - - var sbuf = (GtkSource.Buffer) buf; - - - Gtk.TextIter iter; - sbuf.get_iter_at_line(out iter, line); - this.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); - return false; - }); - - - } - public class Xcls_notebook : Object - { - public Gtk.Notebook el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_notebook(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.notebook = this; - this.el = new Gtk.Notebook(); - - // my vars (dec) - - // set gobject values - this.el.vexpand = true; - new Xcls_label_preview( _this ); - new Xcls_label_code( _this ); - new Xcls_paned( _this ); - this.el.append_page ( _this.paned.el , _this.label_preview.el ); - var child_4 = new Xcls_Box13( _this ); - child_4.ref(); - this.el.append_page ( child_4.el , _this.label_code.el ); - } - - // user defined functions - } - public class Xcls_label_preview : Object - { - public Gtk.Label el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_label_preview(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.label_preview = this; - this.el = new Gtk.Label( "Preview" ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - public class Xcls_label_code : Object - { - public Gtk.Label el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_label_code(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.label_code = this; - this.el = new Gtk.Label( "Preview Generated Code" ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - public class Xcls_paned : Object - { - public Gtk.Paned el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_paned(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.paned = this; - this.el = new Gtk.Paned( Gtk.Orientation.VERTICAL ); - - // my vars (dec) - - // set gobject values - this.el.vexpand = true; - new Xcls_viewbox( _this ); - this.el.set_start_child ( _this.viewbox.el ); - new Xcls_inspectorcontainer( _this ); - this.el.set_end_child ( _this.inspectorcontainer.el ); - } - - // user defined functions - } - public class Xcls_viewbox : Object - { - public Gtk.Box el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_viewbox(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.viewbox = this; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.homogeneous = false; - this.el.vexpand = true; - var child_1 = new Xcls_Box7( _this ); - child_1.ref(); - this.el.append( child_1.el ); - new Xcls_view( _this ); - this.el.append( _this.view.el ); - } +static Xcls_WindowRooView _WindowRooView; + +public class Xcls_WindowRooView : Object +{ + public Gtk.Box el; + private Xcls_WindowRooView _this; + + public static Xcls_WindowRooView singleton() + { + if (_WindowRooView == null) { + _WindowRooView= new Xcls_WindowRooView(); + } + return _WindowRooView; + } + public Xcls_notebook notebook; + public Xcls_label_preview label_preview; + public Xcls_label_code label_code; + public Xcls_paned paned; + public Xcls_viewbox viewbox; + public Xcls_AutoRedraw AutoRedraw; + public Xcls_view view; + public Xcls_inspectorcontainer inspectorcontainer; + public Xcls_sourceviewscroll sourceviewscroll; + public Xcls_sourceview sourceview; + public Xcls_buffer buffer; + public Xcls_search_entry search_entry; + public Xcls_search_results search_results; + public Xcls_nextBtn nextBtn; + public Xcls_backBtn backBtn; + public Xcls_search_settings search_settings; + public Xcls_case_sensitive case_sensitive; + public Xcls_regex regex; + public Xcls_multiline multiline; + + // my vars (def) + public Gtk.Widget lastObj; + public Xcls_MainWindow main_window; + public int last_search_end; + public GtkSource.SearchContext searchcontext; + public JsRender.JsRender file; + + // ctor + public Xcls_WindowRooView() + { + _this = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + this.lastObj = null; + this.last_search_end = 0; + this.file = null; + + // set gobject values + this.el.hexpand = true; + this.el.vexpand = true; + new Xcls_notebook( _this ); + this.el.append( _this.notebook.el ); + } + + // user defined functions + public void loadFile (JsRender.JsRender file) + { + this.file = file; + this.view.renderJS(true); + this.notebook.el.page = 0;// gtk preview + this.sourceview.loadFile(); + } + public void highlightNodeAtLine (int ln) { + + + + // highlight node... + + + var node = _this.file.lineToNode(ln+1); + + if (node == null) { + //print("can not find node\n"); + return; + } + var prop = node.lineToProp(ln+1); + print("prop : %s", prop == null ? "???" : prop.name); + + + // ---------- this selects the tree's node... + + var ltree = _this.main_window.windowstate.left_tree; + ltree.model.selectNode(node); + + //_this.sourceview.allow_node_scroll = false; /// block node scrolling.. + + + //print("changing cursor on tree..\n"); + + + + // let's try allowing editing on the methods. + // a little klunky at present.. + _this.sourceview.prop_selected = ""; + /* + if (prop != null) { + //see if we can find it.. + var kv = prop.split(":"); + if (kv[0] == "p") { + + //var k = prop.get_key(kv[1]); + // fixme -- need to determine if it's an editable property... + _this.sourceview.prop_selected = prop; + + } else if (kv[0] == "l") { + _this.sourceview.prop_selected = prop; + + } + } + */ + // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); + _this.sourceview.nodeSelected(node,false); + + // scrolling is disabled... as node selection calls scroll 10ms after it changes. + // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => { + // this.allow_node_scroll = true; + // return false; + // }); + // } + + + + + + + + + + + + } + public void requestRedraw () { + this.view.renderJS(false); + this.sourceview.loadFile(); + } + public void forwardSearch (bool change_focus) { + + if (this.searchcontext == null) { + return; + } + this.notebook.el.page = 1; + Gtk.TextIter beg, st,en; + bool has_wrapped_around; + var buf = this.sourceview.el.get_buffer(); + buf.get_iter_at_offset(out beg, this.last_search_end); + if (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) { + this.last_search_end = 0; + return; + } + this.last_search_end = en.get_offset(); + if (change_focus) { + this.sourceview.el.grab_focus(); + } + buf.place_cursor(st); + + + + this.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f); + + + var ln = st.get_line(); + + this.highlightNodeAtLine(ln); + } + public void backSearch (bool change_focus) { + + if (this.searchcontext == null) { + return; + } + + Gtk.TextIter beg, st,en; + bool has_wrapped_around; + this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 ); + + if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) { + + this.last_search_end = 0; + return; + } + this.last_search_end = en.get_offset(); + if (change_focus) { + this.sourceview.el.grab_focus(); + } + this.buffer.el.place_cursor(st); + this.sourceview.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f); + var ln = st.get_line(); + this.highlightNodeAtLine(ln); + + + } + public int search (string in_txt) { + this.notebook.el.page = 1; + + + + var s = new GtkSource.SearchSettings(); + s.case_sensitive = _this.case_sensitive.el.active; + s.regex_enabled = _this.regex.el.active; + s.wrap_around = false; + + this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s); + this.searchcontext.set_highlight(true); + var txt = in_txt; + + if (_this.multiline.el.active) { + txt = in_txt.replace("\\n", "\n"); + } + + s.set_search_text(txt); + Gtk.TextIter beg, st,en; + bool has_wrapped_around; + this.buffer.el.get_start_iter(out beg); + this.searchcontext.forward(beg, out st, out en, out has_wrapped_around); + this.last_search_end = 0; + + return this.searchcontext.get_occurrences_count(); + + + + + } + public void createThumb () { + + + if (this.file == null) { + return; + } + + if (this.notebook.el.page > 0 ) { + return; + } + + this.file.widgetToIcon(this.view.el); + + + + + + } + public void updateErrorMarks (string category) { + + + + var buf = _this.buffer.el; + Gtk.TextIter start; + Gtk.TextIter end; + buf.get_bounds (out start, out end); + + buf.remove_source_marks (start, end, category); + + GLib.debug("highlight errors"); + + // we should highlight other types of errors.. + + + + + if (_this.file == null) { + GLib.debug("file is null?"); + return; + + } + var ar = this.file.getErrors(category); + if (ar == null || ar.get_n_items() < 1) { + GLib.debug("higjlight %s has no errors", category); + return; + } + + + + + var offset = 0; + + + var tlines = buf.get_line_count () +1; + + + + for (var i = 0; i < ar.get_n_items();i++) { + var err = (Palete.CompileError) ar.get_item(i); + + Gtk.TextIter iter; + // print("get inter\n"); + var eline = err.line - offset; + GLib.debug("GOT ERROR on line %d -- converted to %d (offset = %d)", + err.line ,eline, offset); + + + if (eline > tlines || eline < 0) { + return; + } + + + buf.get_iter_at_line( out iter, eline); + + + var msg = "Line: %d %s : %s".printf(eline+1, err.category, err.msg); + buf.create_source_mark( msg, err.category, iter); + GLib.debug("set line %d to %s", eline, msg); + //this.marks.set(eline, msg); + } + return ; + + + + + + } + public void scroll_to_line (int line) { + // code preview... + + GLib.Timeout.add(100, () => { + + this.notebook.el.set_current_page( 1 ); + + + var buf = this.sourceview.el.get_buffer(); + + var sbuf = (GtkSource.Buffer) buf; + + + Gtk.TextIter iter; + sbuf.get_iter_at_line(out iter, line); + this.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); + return false; + }); + + + } + public class Xcls_notebook : Object + { + public Gtk.Notebook el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_notebook(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.notebook = this; + this.el = new Gtk.Notebook(); + + // my vars (dec) + + // set gobject values + this.el.vexpand = true; + new Xcls_label_preview( _this ); + new Xcls_label_code( _this ); + new Xcls_paned( _this ); + this.el.append_page ( _this.paned.el , _this.label_preview.el ); + var child_4 = new Xcls_Box13( _this ); + child_4.ref(); + this.el.append_page ( child_4.el , _this.label_code.el ); + } + + // user defined functions + } + public class Xcls_label_preview : Object + { + public Gtk.Label el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_label_preview(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.label_preview = this; + this.el = new Gtk.Label( "Preview" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_label_code : Object + { + public Gtk.Label el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_label_code(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.label_code = this; + this.el = new Gtk.Label( "Preview Generated Code" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_paned : Object + { + public Gtk.Paned el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_paned(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.paned = this; + this.el = new Gtk.Paned( Gtk.Orientation.VERTICAL ); + + // my vars (dec) + + // set gobject values + this.el.vexpand = true; + new Xcls_viewbox( _this ); + this.el.set_start_child ( _this.viewbox.el ); + new Xcls_inspectorcontainer( _this ); + this.el.set_end_child ( _this.inspectorcontainer.el ); + } + + // user defined functions + } + public class Xcls_viewbox : Object + { + public Gtk.Box el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_viewbox(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.viewbox = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + this.el.vexpand = true; + var child_1 = new Xcls_Box7( _this ); + child_1.ref(); + this.el.append( child_1.el ); + new Xcls_view( _this ); + this.el.append( _this.view.el ); + } - // user defined functions - } - public class Xcls_Box7 : Object - { - public Gtk.Box el; - private Xcls_WindowRooView _this; + // user defined functions + } + public class Xcls_Box7 : Object + { + public Gtk.Box el; + private Xcls_WindowRooView _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_Box7(Xcls_WindowRooView _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + // ctor + public Xcls_Box7(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - // my vars (dec) - - // set gobject values - this.el.homogeneous = true; - this.el.height_request = 20; - this.el.vexpand = false; - var child_1 = new Xcls_Button8( _this ); - child_1.ref(); - this.el.append( child_1.el ); - new Xcls_AutoRedraw( _this ); - this.el.append( _this.AutoRedraw.el ); - var child_3 = new Xcls_Button10( _this ); - child_3.ref(); - this.el.append( child_3.el ); - } - - // user defined functions - } - public class Xcls_Button8 : Object - { - public Gtk.Button el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_Button8(Xcls_WindowRooView _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.label = "Redraw"; - - //listeners - this.el.clicked.connect( ( ) => { - _this.view.renderJS( true); - }); - } - - // user defined functions - } - - public class Xcls_AutoRedraw : Object - { - public Gtk.CheckButton el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_AutoRedraw(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.AutoRedraw = this; - this.el = new Gtk.CheckButton(); - - // my vars (dec) - - // set gobject values - this.el.active = true; - this.el.label = "Auto Redraw On"; - - //listeners - this.el.toggled.connect( (state) => { - this.el.set_label(this.el.active ? "Auto Redraw On" : "Auto Redraw Off"); - }); - } - - // user defined functions - } - - public class Xcls_Button10 : Object - { - public Gtk.Button el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_Button10(Xcls_WindowRooView _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.label = "Full Redraw"; - - //listeners - this.el.clicked.connect( () => { - _this.view.redraws = 99; - // _this.view.el.web_context.clear_cache(); - //_this.view.renderJS(true); - FakeServerCache.clear(); - _this.view.reInit(); - - }); - } - - // user defined functions - } - - - public class Xcls_view : Object - { - public WebKit.WebView el; - private Xcls_WindowRooView _this; - - - // my vars (def) - public WebKit.WebInspector inspector; - public bool pendingRedraw; - public int redraws; - public bool refreshRequired; - public string runjs; - public string runhtml; - public string renderedData; - public GLib.DateTime lastRedraw; - - // ctor - public Xcls_view(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.view = this; - this.el = new WebKit.WebView(); - - // my vars (dec) - this.pendingRedraw = false; - this.redraws = 0; - this.refreshRequired = false; - this.runjs = ""; - this.runhtml = ""; - this.renderedData = ""; - this.lastRedraw = null; - - // set gobject values - this.el.vexpand = true; - - // init method - - { - // this may not work!? - var settings = this.el.get_settings(); - settings.enable_developer_extras = true; - - - var fs= new FakeServer(this.el); - fs.ref(); - // this was an attempt to change the url perms.. did not work.. - // settings.enable_file_access_from_file_uris = true; - // settings.enable_offline_web_application_cache - true; - // settings.enable_universal_access_from_file_uris = true; - - - - - - - // FIXME - base url of script.. - // we need it so some of the database features work. - this.el.load_html( "Render not ready" , - //fixme - should be a config option! - // or should we catch stuff and fix it up.. - "http://localhost/app.Builder/" - ); - - - //this.el.open('file:///' + __script_path__ + '/../builder.html'); - /* - Gtk.drag_dest_set - ( - this.el, // - Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT, - null, // list of targets - Gdk.DragAction.COPY // what to do with data after dropped - ); - - // print("RB: TARGETS : " + LeftTree.atoms["STRING"]); - Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList); - */ - GLib.Timeout.add_seconds(1, () =>{ - //print("run refresh?"); - if (this.el == null) { - return false; - } - this.runRefresh(); - return true; - }); - - - } - - //listeners - this.el.script_dialog.connect( (dialog) => { - - - if (this.el == null) { - return true; - } - - var msg = dialog.get_message(); - if (msg.length < 4) { - return false; - } - - GLib.debug("script dialog got %s", msg); - - if (msg.substring(0,4) != "IPC:") { - return false; - } - var ar = msg.split(":", 3); - if (ar.length < 3) { - return false; - } - - switch(ar[1]) { - case "SAVEHTML": - GLib.debug("GOT saveHTML %d", ar[2].length); - _this.file.saveHTML(ar[2]); - _this.createThumb(); - return true; - default: - return false; - } - - }); - this.el.ready_to_show.connect( ( ) => { - this.initInspector(); - - }); - this.el.load_changed.connect( (le) => { - if (le != WebKit.LoadEvent.FINISHED) { - return; - } - if (this.runjs.length < 1) { - return; - } - // this.el.run_javascript(this.runjs, null); - FakeServerCache.remove( this.runjs); - this.runjs = ""; - }); - } - - // user defined functions - public void initInspector () { - - - - // this.inspector.open_window.connect(() => { - this.inspector = this.el.get_inspector(); - - this.inspector.open_window.connect(() => { - print("inspector attach\n"); - var wv = this.inspector.get_web_view(); - if (wv != null) { - print("got inspector web view\n"); - - var cn = _this.inspectorcontainer.el.get_first_child(); - if (cn != null) { - _this.inspectorcontainer.el.remove(cn); - } - - _this.inspectorcontainer.el.append(wv); - wv.show(); - } else { - print("got inspector web view FAILED\n"); - //this.inspector.close(); - - //this.inspector = null; - - - } - return true; - - }); - this.inspector.show(); - - - - } - public void renderJS (bool force) { - - // this is the public redraw call.. - // we refresh in a loop privately.. - var autodraw = _this.AutoRedraw.el.active; - if (!autodraw && !force) { - print("Skipping redraw - no force, and autodraw off"); - return; - } - - this.refreshRequired = true; - } - public void reInit () { - print("reInit?"); - // if this happens destroy the webkit.. - // recreate it.. - this.el.stop_loading(); - - if (_this.viewbox.el.get_parent() == null) { - return; - } - - /* - _this.viewbox.el.remove(_this.viewcontainer.el); - //_this.paned.el.remove(_this.inspectorcontainer.el); - - // destory seems to cause problems. - //this.el.destroy(); - //_this.viewcontainer.el.destroy(); - //_this.inspectorcontainer.el.destroy(); - var inv =new Xcls_inspectorcontainer(_this); - - _this.paned.el.set_end_child(inv.el); - _this.inspectorcontainer = inv; - - this.el = null; - var nv =new Xcls_viewcontainer(_this); - // nv.ref(); - _this.viewbox.el.append(nv.el); - - _this.viewcontainer = nv; - inv.el.show(); - nv.el.show(); - //while(Gtk.events_pending ()) Gtk.main_iteration (); - //_this.view.renderJS(true); - _this.view.refreshRequired = true; - - */ - } - public void runRefresh () - { - // this is run every 2 seconds from the init.. - - - - if (!this.refreshRequired) { - // print("no refresh required"); - return; - } - - if (this.lastRedraw != null) { - // do not redraw if last redraw was less that 5 seconds ago. - if ((int64)(new DateTime.now_local()).difference(this.lastRedraw) < 5000 ) { - return; - } - } - - if (_this.file == null) { - return; - } - - - this.refreshRequired = false; - // print("HTML RENDERING"); - - - //this.get('/BottomPane').el.show(); - //this.get('/BottomPane').el.set_current_page(2);// webkit inspector - _this.file.webkit_page_id = this.el.get_page_id(); - - var js = _this.file.toSourcePreview(); - - if (js.length < 1) { - print("no data"); - return; - } - // var data = js[0]; - this.redraws++; - - var project = (Project.Roo) _this.file.project; - - //print (project.fn); - // set it to non-empty. - - // runhtml = runhtml.length ? runhtml : ''; - - - // this.runhtml = this.runhtml || ''; - - - // then we need to reload the browser using - // load_html_string.. - - // then trigger a redraw once it's loaded.. - this.pendingRedraw = true; - - var runhtml = "\n" ; - - // fix to make sure they are the same.. - this.runhtml = project.runhtml; - // need to modify paths - - string inhtml; - var base_template = project.base_template; - - if (base_template.length > 0 && !FileUtils.test( - BuilderApplication.configDirectory() + "/resources/" + base_template, FileTest.EXISTS) - ) { - print("invalid base_template name - using default: %s\n", base_template); - base_template = ""; - - } - try { - GLib.FileUtils.get_contents( - BuilderApplication.configDirectory() + "/resources/" + - (base_template.length > 0 ? base_template : "roo.builder.html") - , out inhtml); - - } catch (Error e) { - inhtml = ""; - } - this.renderedData = js; - - - string js_src = js + " - Roo.onReady(function() { - if (" + _this.file.name +".show) { - " + _this.file.name +".show({}); - (function() { - Builder.saveHTML.defer(100, Builder); - }).defer(100); - } - Roo.XComponent.build(); - });\n"; - - // print("render js: " + js); - //if (!this.ready) { - // console.log('not loaded yet'); - //} - this.lastRedraw = new DateTime.now_local(); - - - //this.runjs = js_src; - var fc = FakeServerCache.factory_with_data(js_src); - this.runjs = fc.fname; - - var html = inhtml.replace("", runhtml + this.runhtml + - "" + - // "" + - - ""); - //print("LOAD HTML " + html); - - var rootURL = project.rootURL; - - - - this.el.load_html( html , - //fixme - should be a config option! - (rootURL.length > 0 ? rootURL : "xhttp://localhost/roobuilder/") - ); - this.initInspector(); - // force the inspector... - // this.initInspector(); - - // - no need for this, the builder javascript will call it when build is complete - //GLib.Timeout.add_seconds(1, () => { - // this.el.run_javascript("Builder.saveHTML()",null); - // return false; - //}); - // print( "before render" + this.lastRedraw); - // print( "after render" + (new Date())); - - } - } - - - public class Xcls_inspectorcontainer : Object - { - public Gtk.Box el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_inspectorcontainer(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.inspectorcontainer = this; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.vexpand = true; - } - - // user defined functions - } - - - public class Xcls_Box13 : Object - { - public Gtk.Box el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_Box13(Xcls_WindowRooView _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.vexpand = true; - new Xcls_sourceviewscroll( _this ); - this.el.append( _this.sourceviewscroll.el ); - var child_2 = new Xcls_Box19( _this ); - child_2.ref(); - this.el.append( child_2.el ); - } - - // user defined functions - } - public class Xcls_sourceviewscroll : Object - { - public Gtk.ScrolledWindow el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_sourceviewscroll(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.sourceviewscroll = this; - this.el = new Gtk.ScrolledWindow(); - - // my vars (dec) - - // set gobject values - this.el.vexpand = true; - new Xcls_sourceview( _this ); - this.el.set_child ( _this.sourceview.el ); - } - - // user defined functions - } - public class Xcls_sourceview : Object - { - public GtkSource.View el; - private Xcls_WindowRooView _this; - - - // my vars (def) - public int editable_start_pos; - public bool loading; - public bool button_is_pressed; - public string prop_selected; - public bool key_is_pressed; - public Gtk.CssProvider css; - public JsRender.Node? node_selected; - - // ctor - public Xcls_sourceview(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.sourceview = this; - this.el = new GtkSource.View(); - - // my vars (dec) - this.editable_start_pos = -1; - this.loading = true; - this.button_is_pressed = false; - this.prop_selected = ""; - this.key_is_pressed = false; - this.node_selected = null; - - // set gobject values - this.el.name = "roo-view"; - this.el.editable = false; - this.el.show_line_marks = true; - this.el.show_line_numbers = true; - new Xcls_buffer( _this ); - this.el.set_buffer ( _this.buffer.el ); - var child_2 = new Xcls_EventControllerKey17( _this ); - child_2.ref(); - this.el.add_controller ( child_2.el ); - var child_3 = new Xcls_GestureClick18( _this ); - child_3.ref(); - this.el.add_controller( child_3.el ); - - // init method - - { - - this.css = new Gtk.CssProvider(); - - this.css.load_from_string( - "#roo-view { font: 10px monospace; }" - ); - - Gtk.StyleContext.add_provider_for_display( - this.el.get_display(), - this.css, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - ); - - - - this.loading = true; - //var buf = this.el.get_buffer(); - //buf.notify.connect(this.onCursorChanged); - - - var attrs = new GtkSource.MarkAttributes(); - var pink = Gdk.RGBA(); - pink.parse ( "pink"); - attrs.set_background ( pink); - attrs.set_icon_name ( "process-stop"); - attrs.query_tooltip_text.connect(( mark) => { - //print("tooltip query? %s\n", mark.name); - return mark.name; - }); - - this.el.set_mark_attributes ("ERR", attrs, 1); - - var wattrs = new GtkSource.MarkAttributes(); - var blue = Gdk.RGBA(); - blue.parse ( "#ABF4EB"); - wattrs.set_background ( blue); - wattrs.set_icon_name ( "process-stop"); - wattrs.query_tooltip_text.connect(( mark) => { - //print("tooltip query? %s\n", mark.name); - return mark.name; - }); - - this.el.set_mark_attributes ("WARN", wattrs, 1); - - - - var dattrs = new GtkSource.MarkAttributes(); - var purple = Gdk.RGBA(); - purple.parse ( "#EEA9FF"); - dattrs.set_background ( purple); - dattrs.set_icon_name ( "process-stop"); - dattrs.query_tooltip_text.connect(( mark) => { - //print("tooltip query? %s\n", mark.name); - return mark.name; - }); - - this.el.set_mark_attributes ("DEPR", dattrs, 1); - - - var gattrs = new GtkSource.MarkAttributes(); - var grey = Gdk.RGBA(); - grey.parse ( "#ccc"); - gattrs.set_background ( grey); - - - this.el.set_mark_attributes ("grey", gattrs, 1); - - - - - - - } - - //listeners - this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => { - - //GLib.debug("query tooltip"); - Gtk.TextIter iter; - int trailing; - - var yoff = (int) _this.sourceviewscroll.el.vadjustment.value; - - this.el.get_iter_at_position (out iter, out trailing, x, y + yoff); - - var l = iter.get_line(); - //GLib.debug("query tooltip line %d", (int) l); - var marks = _this.buffer.el.get_source_marks_at_line(l, null); - //GLib.debug("query tooltip line marks %d", (int) marks.length()); - var str = ""; - marks.@foreach((m) => { - //GLib.debug("got mark %s", m.name); - str += (str.length > 0 ? "\n" : "") + m.name; - }); - // true if there is a mark.. - if (str.length > 0 ) { - tooltip.set_text( str); - } - return str.length > 0 ? true : false; - - }); - } - - // user defined functions - public void loadFile ( ) { - this.loading = true; - - - // get the cursor and scroll position.... - var buf = this.el.get_buffer(); - var cpos = buf.cursor_position; - - print("BEFORE LOAD cursor = %d\n", cpos); - - var vadj_pos = this.el.get_vadjustment().get_value(); - - - - buf.set_text("",0); - var sbuf = (GtkSource.Buffer) buf; - - - - if (_this.file == null || _this.file.xtype != "Roo") { - print("xtype != Roo"); - this.loading = false; - return; - } - - // get the string from the rendered tree... - - var str = _this.file.toSource(); - - // print("setting str %d\n", str.length); - buf.set_text(str, str.length); - var lm = GtkSource.LanguageManager.get_default(); - - //?? is javascript going to work as js? - - ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language)); - - - _this.main_window.windowstate.updateErrorMarksAll(); - - // what does this do? - GLib.Timeout.add(500, () => { - - print("RESORTING cursor to = %d\n", cpos); - Gtk.TextIter cpos_iter; - buf.get_iter_at_offset(out cpos_iter, cpos); - buf.place_cursor(cpos_iter); - - this.el.get_vadjustment().set_value(vadj_pos);; - - - this.onCursorChanged(); - - - //_this.buffer.checkSyntax(); - return false; - }); - - this.loading = false; - _this.buffer.dirty = false; - } - public void onCursorChanged (/*ParamSpec ps*/) { - - if (!this.key_is_pressed && !this.button_is_pressed) { - return; - } - - if (this.loading) { - return; - } - // if (ps.name != "cursor-position") { - // return; - // } - - var buf = this.el.get_buffer(); - //print("cursor changed : %d\n", buf.cursor_position); - Gtk.TextIter cpos; - buf.get_iter_at_offset(out cpos, buf.cursor_position); - - var ln = cpos.get_line(); - - - // --- select node at line.... - - var node = _this.file.lineToNode(ln+1); - - if (node == null) { - print("can not find node\n"); - return; - } - var prop = node.lineToProp(ln+1); - print("prop : %s", prop == null ? "???" : prop.name); - - - // ---------- this selects the tree's node... - - var ltree = _this.main_window.windowstate.left_tree; - ltree.model.selectNode(node); - - - //print("changing cursor on tree..\n"); - - - - // let's try allowing editing on the methods. - // a little klunky at present.. - this.prop_selected = ""; - /* - if (prop != null) { - //see if we can find it.. - var kv = prop.split(":"); - if (kv[0] == "p") { - - //var k = prop.get_key(kv[1]); - // fixme -- need to determine if it's an editable property... - this.prop_selected = prop; - - } else if (kv[0] == "l") { - this.prop_selected = prop; - - } - } - */ - // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); - //this.nodeSelected(node,false); - - // scrolling is disabled... as node selection calls scroll 10ms after it changes. - - - // highlight the node.. - } - public void nodeSelected (JsRender.Node? sel, bool scroll ) { - - - - // this is connected in widnowstate - - - // not sure why.... - // while(Gtk.events_pending()) { - // Gtk.main_iteration(); - // } - - this.node_selected = sel; - - // this.updateGreySelection(scroll); - - - - } - public void updateGreySelection (bool scroll) { - var sel = this.node_selected; - print("node selected\n"); - var buf = this.el.get_buffer(); - var sbuf = (GtkSource.Buffer) buf; - - - this.clearGreySelection(); - - - - if (sel == null) { - print("no selected node\n"); - // no highlighting.. - return; - } - - print("highlight region %d to %d\n", sel.line_start,sel.line_end); - Gtk.TextIter iter; - sbuf.get_iter_at_line(out iter, sel.line_start); - - - Gtk.TextIter cur_iter; - sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position); - - var cursor_at_line = cur_iter.get_line(); - - - //var cur_line = cur_iter.get_line(); - //if (cur_line > sel.line_start && cur_line < sel.line_end) { - - //} else { - if (scroll) { - print("scrolling to node -- should occur on node picking.\n"); - this.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); - } - - var start_line = sel.line_start; - var end_line = sel.line_end; - - - this.el.editable = false; - - //var colon_pos = 0; - - this.editable_start_pos = -1; - - // now if we have selected a property... - if (this.prop_selected.length> 0 ) { - - int nstart, nend; - if (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) { - start_line = nstart; - end_line = nend; - // this.el.editable = true; << cant do this!!? - print("start line = %d, end line = %d\n", start_line, end_line); - - // see if we are 'right of ':' - // get an iter for the start of the line. - Gtk.TextIter start_first_line_iter,end_first_line_iter; - this.el.buffer.get_iter_at_line(out start_first_line_iter, start_line -1); - this.el.buffer.get_iter_at_line(out end_first_line_iter, start_line -1); - - - - - if (end_first_line_iter.forward_to_line_end()) { - var first_line = this.el.buffer.get_text(start_first_line_iter, end_first_line_iter, false); - - print("first line = %s\n", first_line); - if (first_line.contains(":")) { - this.editable_start_pos = start_first_line_iter.get_offset() + first_line.index_of(":") + 1; - print("colon_pos = %d\n", this.editable_start_pos); - } - - - //Gtk.TextIter colon_iter; - //sbuf.get_iter_at_offset (out colon_iter, colon_pos); - //sbuf.create_source_mark(null, "active_text", colon_iter); - } - - - - //print("is cursor at line? %d ?= %d\n", start_line -1 , cursor_at_line); - //if (start_line - 1 == cursor_at_line) { - // should be ok - current_posssion can not be less than '-1'... - if (sbuf.cursor_position < this.editable_start_pos) { - - print("cursor is before start pos.. - turn off editable...\n"); - //var before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false); - //print("before cursor string = %s\n", before_cursor_string); - //if (!before_cursor_string.contains(":")) { - this.el.editable = false; - //} - - } - - - - - } - print("propSelected = %s range %d -> %d\n", this.prop_selected, start_line, end_line); - - - } - - print("checking selection\n"); - - - // check selection - if it's out of 'bounds' - if (this.el.editable && sbuf.get_has_selection()) { - Gtk.TextIter sel_start_iter, sel_end_iter; - sbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter); - - if (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line || - sel_start_iter.get_line() > end_line || sel_end_iter.get_line() < start_line ) { - // save? - this.el.editable = false; - } - if (this.editable_start_pos > 0 && - (sel_start_iter.get_offset() < this.editable_start_pos || sel_end_iter.get_offset() < this.editable_start_pos) - - ) { - this.el.editable = false; - } - - - - } - - - - - for (var i = 0; i < buf.get_line_count();i++) { - if (i < (start_line -1) || i > (end_line -1)) { - - sbuf.get_iter_at_line(out iter, i); - sbuf.create_source_mark(null, "grey", iter); - - } - - } - if (scroll && (cursor_at_line > end_line || cursor_at_line < start_line)) { - Gtk.TextIter cpos_iter; - buf.get_iter_at_line(out cpos_iter, start_line); - - buf.place_cursor(cpos_iter); - } - - - } - public void highlightErrorsJson (string type, Json.Object obj) { - // this is a hook for the vala code - it has no value in javascript - // as we only have one error ususally.... - return ; - - - - - } - public void clearGreySelection () { - // clear all the marks.. - var sbuf = (GtkSource.Buffer)this.el.buffer; - - Gtk.TextIter start; - Gtk.TextIter end; - - sbuf.get_bounds (out start, out end); - sbuf.remove_source_marks (start, end, "grey"); - - - } - public string toString () { - Gtk.TextIter s; - Gtk.TextIter e; - this.el.get_buffer().get_start_iter(out s); - this.el.get_buffer().get_end_iter(out e); - var ret = this.el.get_buffer().get_text(s,e,true); - //print("TO STRING? " + ret); - return ret; - } - } - public class Xcls_buffer : Object - { - public GtkSource.Buffer el; - private Xcls_WindowRooView _this; - - - // my vars (def) - public int error_line; - public bool dirty; - - // ctor - public Xcls_buffer(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.buffer = this; - this.el = new GtkSource.Buffer( null ); - - // my vars (dec) - this.error_line = -1; - this.dirty = false; - - // set gobject values - - //listeners - this.el.changed.connect( () => { - - // check syntax?? - // ??needed..?? - // _this.save_button.el.sensitive = true; - ///?? has changed occured during loading? - - // only trigger this if - - - - - if (_this.sourceview.loading) { - return; - } - - - - print("- PREVIEW EDITOR CHANGED--"); - - this.dirty = true; - // this.checkSyntax(); // this calls backs and highlights errors.. in theory... - - - - if (!_this.sourceview.button_is_pressed && !_this.sourceview.key_is_pressed) { - print("button or key not pressed to generate change?!\n"); - return; - } - - - // what are we editing?? - if (null == _this.sourceview.node_selected || _this.sourceview.prop_selected.length < 1) { - return; - } - - // find the colon on the first line... - - if (_this.sourceview.editable_start_pos > -1) { - - var buf = (GtkSource.Buffer)_this.sourceview.el.get_buffer(); - - //print("cursor changed : %d\n", buf.cursor_position); - Gtk.TextIter spos,epos; - buf.get_iter_at_offset(out spos, _this.sourceview.editable_start_pos); - buf.get_iter_at_offset(out epos, _this.sourceview.editable_start_pos); // initialize epos.. - - var gotit= false; - var line = spos.get_line(); - var endline = buf.get_line_count(); - while (line < endline) { - line++; - buf.get_iter_at_line(out epos, line); - if (buf.get_source_marks_at_line(line, "grey").length() > 0) { - buf.get_iter_at_line(out epos, line); - gotit=true; - break; - } - } - - if (gotit) { - print("End Offset = %d/%d\n", epos.get_line(), epos.get_offset()); - // get the pos... - // in theory the last char will be '}' or '},' .. or ',' - // we should chop the ',' of the end... - var str = buf.get_text(spos, epos, false); - print("got string\n%s\n", str); - - } - } - return ; - }); - } - - // user defined functions - public bool highlightErrors ( Gee.HashMap validate_res) { - - this.error_line = validate_res.size; - - if (this.error_line < 1) { - return true; - } - var tlines = this.el.get_line_count (); - Gtk.TextIter iter; - var valiter = validate_res.map_iterator(); - while (valiter.next()) { - - // print("get inter\n"); - var eline = valiter.get_key(); - if (eline > tlines) { - continue; - } - this.el.get_iter_at_line( out iter, eline); - //print("mark line\n"); - this.el.create_source_mark(valiter.get_value(), "ERR", iter); - } - return false; - } - public string toString () { - - Gtk.TextIter s; - Gtk.TextIter e; - this.el.get_start_iter(out s); - this.el.get_end_iter(out e); - var ret = this.el.get_text(s,e,true); - //print("TO STRING? " + ret); - return ret; - } - } - - public class Xcls_EventControllerKey17 : Object - { - public Gtk.EventControllerKey el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_EventControllerKey17(Xcls_WindowRooView _owner ) - { - _this = _owner; - this.el = new Gtk.EventControllerKey(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.key_pressed.connect( (keyval, keycode, state) => { - - - - if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { - GLib.debug("SAVE: ctrl-g pressed"); - _this.forwardSearch(true); - return false; - } - if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { - GLib.debug("SAVE: ctrl-f pressed"); - _this.search_entry.el.grab_focus(); - return false ; - } - - //this.button_is_pressed = true; - //return false; - // print(event.key.keyval) - - return false; - - - }); - } - - // user defined functions - } - - public class Xcls_GestureClick18 : Object - { - public Gtk.GestureClick el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_GestureClick18(Xcls_WindowRooView _owner ) - { - _this = _owner; - this.el = new Gtk.GestureClick(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.released.connect( (n_press, x, y) => { - - print("BUTTON RELEASE EVENT\n"); - _this.sourceview.onCursorChanged(); - //this.button_is_pressed = false; - - }); - } - - // user defined functions - } - - - - public class Xcls_Box19 : Object - { - public Gtk.Box el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_Box19(Xcls_WindowRooView _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.homogeneous = false; - this.el.vexpand = false; - new Xcls_search_entry( _this ); - this.el.append( _this.search_entry.el ); - new Xcls_search_results( _this ); - this.el.append( _this.search_results.el ); - new Xcls_nextBtn( _this ); - this.el.append( _this.nextBtn.el ); - new Xcls_backBtn( _this ); - this.el.append( _this.backBtn.el ); - var child_5 = new Xcls_MenuButton25( _this ); - child_5.ref(); - this.el.append( child_5.el ); - } - - // user defined functions - } - public class Xcls_search_entry : Object - { - public Gtk.SearchEntry el; - private Xcls_WindowRooView _this; - - - // my vars (def) - public Gtk.CssProvider css; - - // ctor - public Xcls_search_entry(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.search_entry = this; - this.el = new Gtk.SearchEntry(); - - // my vars (dec) - - // set gobject values - this.el.name = "roo-search-entry"; - this.el.hexpand = true; - this.el.placeholder_text = "Press enter to search"; - var child_1 = new Xcls_EventControllerKey21( _this ); - child_1.ref(); - this.el.add_controller( child_1.el ); - - // init method - - this.css = new Gtk.CssProvider(); - - this.css.load_from_string( - "#roo-search-entry { background-color: #ccc; }" - ); - - Gtk.StyleContext.add_provider_for_display( - this.el.get_display(), - this.css, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - ); - - //listeners - this.el.search_changed.connect( ( ) => { - - _this.search(_this.search_entry.el.text); - _this.search_results.updateResults(); - - GLib.Timeout.add_seconds(1,() => { - _this.search_results.updateResults(); - return false; - }); - }); - } - - // user defined functions - public void forwardSearch (bool change_focus) { - - - _this.forwardSearch(change_focus); - - /* - - switch(_this.windowstate.state) { - case WindowState.State.CODEONLY: - //case WindowState.State.CODE: - // search the code being edited.. - _this.windowstate.code_editor_tab.forwardSearch(change_focus); - - break; - case WindowState.State.PREVIEW: - if (_this.windowstate.file.xtype == "Gtk") { - _this.windowstate.window_gladeview.forwardSearch(change_focus); - } else { - _this.windowstate.window_rooview.forwardSearch(change_focus); - } - - break; - } - */ - - } - } - public class Xcls_EventControllerKey21 : Object - { - public Gtk.EventControllerKey el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_EventControllerKey21(Xcls_WindowRooView _owner ) - { - _this = _owner; - this.el = new Gtk.EventControllerKey(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.key_pressed.connect( (keyval, keycode, state) => { - - if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { - GLib.debug("SAVE: ctrl-g pressed"); - _this.forwardSearch(true); - return true; - } - - - if (keyval == Gdk.Key.Return) { - _this.forwardSearch(true); - - - return true; - - } - // print(event.key.keyval) - - return false; - }); - } - - // user defined functions - } - - - public class Xcls_search_results : Object - { - public Gtk.Label el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_search_results(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.search_results = this; - this.el = new Gtk.Label( "No Results" ); - - // my vars (dec) - - // set gobject values - this.el.margin_end = 4; - this.el.margin_start = 4; - } - - // user defined functions - public void updateResults () { - this.el.visible = true; - - var res = _this.searchcontext.get_occurrences_count(); - if (res < 0) { - _this.search_results.el.label = "??? Matches"; - return; - } - - _this.nextBtn.el.sensitive = false; - _this.backBtn.el.sensitive = false; - - if (res > 0) { - _this.search_results.el.label = "%d Matches".printf(res); - _this.nextBtn.el.sensitive = true; - _this.backBtn.el.sensitive = true; - return; - } - _this.search_results.el.label = "No Matches"; - - } - } - - public class Xcls_nextBtn : Object - { - public Gtk.Button el; - private Xcls_WindowRooView _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_nextBtn(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.nextBtn = this; - this.el = new Gtk.Button(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.icon_name = "go-down"; - this.el.sensitive = false; - - //listeners - this.el.clicked.connect( (event) => { - - _this.forwardSearch(true); - - }); - } - - // user defined functions - } - - public class Xcls_backBtn : Object - { - public Gtk.Button el; - private Xcls_WindowRooView _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_backBtn(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.backBtn = this; - this.el = new Gtk.Button(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.icon_name = "go-up"; - this.el.sensitive = false; - - //listeners - this.el.clicked.connect( (event) => { - - _this.backSearch(true); - - - }); - } - - // user defined functions - } - - public class Xcls_MenuButton25 : Object - { - public Gtk.MenuButton el; - private Xcls_WindowRooView _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_MenuButton25(Xcls_WindowRooView _owner ) - { - _this = _owner; - this.el = new Gtk.MenuButton(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.icon_name = "emblem-system"; - new Xcls_search_settings( _this ); - this.el.popover = _this.search_settings.el; - } - - // user defined functions - } - public class Xcls_search_settings : Object - { - public Gtk.Popover el; - private Xcls_WindowRooView _this; + // my vars (dec) + + // set gobject values + this.el.homogeneous = true; + this.el.height_request = 20; + this.el.vexpand = false; + var child_1 = new Xcls_Button8( _this ); + child_1.ref(); + this.el.append( child_1.el ); + new Xcls_AutoRedraw( _this ); + this.el.append( _this.AutoRedraw.el ); + var child_3 = new Xcls_Button10( _this ); + child_3.ref(); + this.el.append( child_3.el ); + } + + // user defined functions + } + public class Xcls_Button8 : Object + { + public Gtk.Button el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Button8(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Redraw"; + + //listeners + this.el.clicked.connect( ( ) => { + _this.view.renderJS( true); + }); + } + + // user defined functions + } + + public class Xcls_AutoRedraw : Object + { + public Gtk.CheckButton el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_AutoRedraw(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.AutoRedraw = this; + this.el = new Gtk.CheckButton(); + + // my vars (dec) + + // set gobject values + this.el.active = true; + this.el.label = "Auto Redraw On"; + + //listeners + this.el.toggled.connect( (state) => { + this.el.set_label(this.el.active ? "Auto Redraw On" : "Auto Redraw Off"); + }); + } + + // user defined functions + } + + public class Xcls_Button10 : Object + { + public Gtk.Button el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Button10(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Full Redraw"; + + //listeners + this.el.clicked.connect( () => { + _this.view.redraws = 99; + // _this.view.el.web_context.clear_cache(); + //_this.view.renderJS(true); + FakeServerCache.clear(); + _this.view.reInit(); + + }); + } + + // user defined functions + } + + + public class Xcls_view : Object + { + public WebKit.WebView el; + private Xcls_WindowRooView _this; + + + // my vars (def) + public WebKit.WebInspector inspector; + public bool pendingRedraw; + public int redraws; + public bool refreshRequired; + public string runjs; + public string runhtml; + public string renderedData; + public GLib.DateTime lastRedraw; + + // ctor + public Xcls_view(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.view = this; + this.el = new WebKit.WebView(); + + // my vars (dec) + this.pendingRedraw = false; + this.redraws = 0; + this.refreshRequired = false; + this.runjs = ""; + this.runhtml = ""; + this.renderedData = ""; + this.lastRedraw = null; + + // set gobject values + this.el.vexpand = true; + + // init method + + { + // this may not work!? + var settings = this.el.get_settings(); + settings.enable_developer_extras = true; + + + var fs= new FakeServer(this.el); + fs.ref(); + // this was an attempt to change the url perms.. did not work.. + // settings.enable_file_access_from_file_uris = true; + // settings.enable_offline_web_application_cache - true; + // settings.enable_universal_access_from_file_uris = true; + + + + + + + // FIXME - base url of script.. + // we need it so some of the database features work. + this.el.load_html( "Render not ready" , + //fixme - should be a config option! + // or should we catch stuff and fix it up.. + "http://localhost/app.Builder/" + ); + + + //this.el.open('file:///' + __script_path__ + '/../builder.html'); + /* + Gtk.drag_dest_set + ( + this.el, // + Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT, + null, // list of targets + Gdk.DragAction.COPY // what to do with data after dropped + ); + + // print("RB: TARGETS : " + LeftTree.atoms["STRING"]); + Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList); + */ + GLib.Timeout.add_seconds(1, () =>{ + //print("run refresh?"); + if (this.el == null) { + return false; + } + this.runRefresh(); + return true; + }); + + + } + + //listeners + this.el.script_dialog.connect( (dialog) => { + + + if (this.el == null) { + return true; + } + + var msg = dialog.get_message(); + if (msg.length < 4) { + return false; + } + + GLib.debug("script dialog got %s", msg); + + if (msg.substring(0,4) != "IPC:") { + return false; + } + var ar = msg.split(":", 3); + if (ar.length < 3) { + return false; + } + + switch(ar[1]) { + case "SAVEHTML": + GLib.debug("GOT saveHTML %d", ar[2].length); + _this.file.saveHTML(ar[2]); + _this.createThumb(); + return true; + default: + return false; + } + + }); + this.el.ready_to_show.connect( ( ) => { + this.initInspector(); + + }); + this.el.load_changed.connect( (le) => { + if (le != WebKit.LoadEvent.FINISHED) { + return; + } + if (this.runjs.length < 1) { + return; + } + // this.el.run_javascript(this.runjs, null); + FakeServerCache.remove( this.runjs); + this.runjs = ""; + }); + } + + // user defined functions + public void initInspector () { + + + + // this.inspector.open_window.connect(() => { + this.inspector = this.el.get_inspector(); + + this.inspector.open_window.connect(() => { + print("inspector attach\n"); + var wv = this.inspector.get_web_view(); + if (wv != null) { + print("got inspector web view\n"); + + var cn = _this.inspectorcontainer.el.get_first_child(); + if (cn != null) { + _this.inspectorcontainer.el.remove(cn); + } + + _this.inspectorcontainer.el.append(wv); + wv.show(); + } else { + print("got inspector web view FAILED\n"); + //this.inspector.close(); + + //this.inspector = null; + + + } + return true; + + }); + this.inspector.show(); + + + + } + public void renderJS (bool force) { + + // this is the public redraw call.. + // we refresh in a loop privately.. + var autodraw = _this.AutoRedraw.el.active; + if (!autodraw && !force) { + print("Skipping redraw - no force, and autodraw off"); + return; + } + + this.refreshRequired = true; + } + public void reInit () { + print("reInit?"); + // if this happens destroy the webkit.. + // recreate it.. + this.el.stop_loading(); + + if (_this.viewbox.el.get_parent() == null) { + return; + } + + /* + _this.viewbox.el.remove(_this.viewcontainer.el); + //_this.paned.el.remove(_this.inspectorcontainer.el); + + // destory seems to cause problems. + //this.el.destroy(); + //_this.viewcontainer.el.destroy(); + //_this.inspectorcontainer.el.destroy(); + var inv =new Xcls_inspectorcontainer(_this); + + _this.paned.el.set_end_child(inv.el); + _this.inspectorcontainer = inv; + + this.el = null; + var nv =new Xcls_viewcontainer(_this); + // nv.ref(); + _this.viewbox.el.append(nv.el); + + _this.viewcontainer = nv; + inv.el.show(); + nv.el.show(); + //while(Gtk.events_pending ()) Gtk.main_iteration (); + //_this.view.renderJS(true); + _this.view.refreshRequired = true; + + */ + } + public void runRefresh () + { + // this is run every 2 seconds from the init.. + + + + if (!this.refreshRequired) { + // print("no refresh required"); + return; + } + + if (this.lastRedraw != null) { + // do not redraw if last redraw was less that 5 seconds ago. + if ((int64)(new DateTime.now_local()).difference(this.lastRedraw) < 5000 ) { + return; + } + } + + if (_this.file == null) { + return; + } + + + this.refreshRequired = false; + // print("HTML RENDERING"); + + + //this.get('/BottomPane').el.show(); + //this.get('/BottomPane').el.set_current_page(2);// webkit inspector + _this.file.webkit_page_id = this.el.get_page_id(); + + var js = _this.file.toSourcePreview(); + + if (js.length < 1) { + print("no data"); + return; + } + // var data = js[0]; + this.redraws++; + + var project = (Project.Roo) _this.file.project; + + //print (project.fn); + // set it to non-empty. + + // runhtml = runhtml.length ? runhtml : ''; + + + // this.runhtml = this.runhtml || ''; + + + // then we need to reload the browser using + // load_html_string.. + + // then trigger a redraw once it's loaded.. + this.pendingRedraw = true; + + var runhtml = "\n" ; + + // fix to make sure they are the same.. + this.runhtml = project.runhtml; + // need to modify paths + + string inhtml; + var base_template = project.base_template; + + if (base_template.length > 0 && !FileUtils.test( + BuilderApplication.configDirectory() + "/resources/" + base_template, FileTest.EXISTS) + ) { + print("invalid base_template name - using default: %s\n", base_template); + base_template = ""; + + } + try { + GLib.FileUtils.get_contents( + BuilderApplication.configDirectory() + "/resources/" + + (base_template.length > 0 ? base_template : "roo.builder.html") + , out inhtml); + + } catch (Error e) { + inhtml = ""; + } + this.renderedData = js; + + + string js_src = js + " + Roo.onReady(function() { + if (" + _this.file.name +".show) { + " + _this.file.name +".show({}); + (function() { + Builder.saveHTML.defer(100, Builder); + }).defer(100); + } + Roo.XComponent.build(); + });\n"; + + // print("render js: " + js); + //if (!this.ready) { + // console.log('not loaded yet'); + //} + this.lastRedraw = new DateTime.now_local(); + + + //this.runjs = js_src; + var fc = FakeServerCache.factory_with_data(js_src); + this.runjs = fc.fname; + + var html = inhtml.replace("", runhtml + this.runhtml + + "" + + // "" + + + ""); + //print("LOAD HTML " + html); + + var rootURL = project.rootURL; + + + + this.el.load_html( html , + //fixme - should be a config option! + (rootURL.length > 0 ? rootURL : "xhttp://localhost/roobuilder/") + ); + this.initInspector(); + // force the inspector... + // this.initInspector(); + + // - no need for this, the builder javascript will call it when build is complete + //GLib.Timeout.add_seconds(1, () => { + // this.el.run_javascript("Builder.saveHTML()",null); + // return false; + //}); + // print( "before render" + this.lastRedraw); + // print( "after render" + (new Date())); + + } + } + + + public class Xcls_inspectorcontainer : Object + { + public Gtk.Box el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_inspectorcontainer(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.inspectorcontainer = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.vexpand = true; + } + + // user defined functions + } + + + public class Xcls_Box13 : Object + { + public Gtk.Box el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Box13(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.vexpand = true; + new Xcls_sourceviewscroll( _this ); + this.el.append( _this.sourceviewscroll.el ); + var child_2 = new Xcls_Box18( _this ); + child_2.ref(); + this.el.append( child_2.el ); + } + + // user defined functions + } + public class Xcls_sourceviewscroll : Object + { + public Gtk.ScrolledWindow el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_sourceviewscroll(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.sourceviewscroll = this; + this.el = new Gtk.ScrolledWindow(); + + // my vars (dec) + + // set gobject values + this.el.vexpand = true; + new Xcls_sourceview( _this ); + this.el.set_child ( _this.sourceview.el ); + } + + // user defined functions + } + public class Xcls_sourceview : Object + { + public GtkSource.View el; + private Xcls_WindowRooView _this; + + + // my vars (def) + public int editable_start_pos; + public bool loading; + public bool button_is_pressed; + public string prop_selected; + public bool key_is_pressed; + public Gtk.CssProvider css; + public JsRender.Node? node_selected; + + // ctor + public Xcls_sourceview(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.sourceview = this; + this.el = new GtkSource.View(); + + // my vars (dec) + this.editable_start_pos = -1; + this.loading = true; + this.button_is_pressed = false; + this.prop_selected = ""; + this.key_is_pressed = false; + this.node_selected = null; + + // set gobject values + this.el.name = "roo-view"; + this.el.editable = false; + this.el.show_line_marks = true; + this.el.show_line_numbers = true; + new Xcls_buffer( _this ); + this.el.set_buffer ( _this.buffer.el ); + var child_2 = new Xcls_EventControllerKey17( _this ); + child_2.ref(); + this.el.add_controller ( child_2.el ); + + // init method + + { + + this.css = new Gtk.CssProvider(); + + this.css.load_from_string( + "#roo-view { font: 10px monospace; }" + ); + + Gtk.StyleContext.add_provider_for_display( + this.el.get_display(), + this.css, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + ); + + + + this.loading = true; + //var buf = this.el.get_buffer(); + //buf.notify.connect(this.onCursorChanged); + + + var attrs = new GtkSource.MarkAttributes(); + var pink = Gdk.RGBA(); + pink.parse ( "pink"); + attrs.set_background ( pink); + attrs.set_icon_name ( "process-stop"); + attrs.query_tooltip_text.connect(( mark) => { + //print("tooltip query? %s\n", mark.name); + return mark.name; + }); + + this.el.set_mark_attributes ("ERR", attrs, 1); + + var wattrs = new GtkSource.MarkAttributes(); + var blue = Gdk.RGBA(); + blue.parse ( "#ABF4EB"); + wattrs.set_background ( blue); + wattrs.set_icon_name ( "process-stop"); + wattrs.query_tooltip_text.connect(( mark) => { + //print("tooltip query? %s\n", mark.name); + return mark.name; + }); + + this.el.set_mark_attributes ("WARN", wattrs, 1); + + + + var dattrs = new GtkSource.MarkAttributes(); + var purple = Gdk.RGBA(); + purple.parse ( "#EEA9FF"); + dattrs.set_background ( purple); + dattrs.set_icon_name ( "process-stop"); + dattrs.query_tooltip_text.connect(( mark) => { + //print("tooltip query? %s\n", mark.name); + return mark.name; + }); + + this.el.set_mark_attributes ("DEPR", dattrs, 1); + + + var gattrs = new GtkSource.MarkAttributes(); + var grey = Gdk.RGBA(); + grey.parse ( "#ccc"); + gattrs.set_background ( grey); + + + this.el.set_mark_attributes ("grey", gattrs, 1); + + + + + + + } + + //listeners + this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => { + + //GLib.debug("query tooltip"); + Gtk.TextIter iter; + int trailing; + + var yoff = (int) _this.sourceviewscroll.el.vadjustment.value; + + this.el.get_iter_at_position (out iter, out trailing, x, y + yoff); + + var l = iter.get_line(); + //GLib.debug("query tooltip line %d", (int) l); + var marks = _this.buffer.el.get_source_marks_at_line(l, null); + //GLib.debug("query tooltip line marks %d", (int) marks.length()); + var str = ""; + marks.@foreach((m) => { + //GLib.debug("got mark %s", m.name); + str += (str.length > 0 ? "\n" : "") + m.name; + }); + // true if there is a mark.. + if (str.length > 0 ) { + tooltip.set_text( str); + } + return str.length > 0 ? true : false; + + }); + } + + // user defined functions + public void loadFile ( ) { + this.loading = true; + + + // get the cursor and scroll position.... + var buf = this.el.get_buffer(); + var cpos = buf.cursor_position; + + print("BEFORE LOAD cursor = %d\n", cpos); + + var vadj_pos = this.el.get_vadjustment().get_value(); + + + + buf.set_text("",0); + var sbuf = (GtkSource.Buffer) buf; + + + + if (_this.file == null || _this.file.xtype != "Roo") { + print("xtype != Roo"); + this.loading = false; + return; + } + + // get the string from the rendered tree... + + var str = _this.file.toSource(); + + // print("setting str %d\n", str.length); + buf.set_text(str, str.length); + var lm = GtkSource.LanguageManager.get_default(); + + //?? is javascript going to work as js? + + ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language)); + + + _this.main_window.windowstate.updateErrorMarksAll(); + + // restore the cursor position? + // after reloading the contents. + GLib.Timeout.add(500, () => { + _this.buffer.in_cursor_change = true; + print("RESORTING cursor to = %d\n", cpos); + Gtk.TextIter cpos_iter; + buf.get_iter_at_offset(out cpos_iter, cpos); + buf.place_cursor(cpos_iter); + + this.el.get_vadjustment().set_value(vadj_pos);; + _this.buffer.in_cursor_change = false; + + + + //_this.buffer.checkSyntax(); + return false; + }); + + this.loading = false; + _this.buffer.dirty = false; + } + public void nodeSelected (JsRender.Node? sel, bool scroll) { + + + if (this.loading) { + return; + } + // this is connected in widnowstate + print("Roo-view - node selected\n"); + var buf = this.el.get_buffer(); + + var sbuf = (GtkSource.Buffer) buf; + + + + + // clear all the marks.. + Gtk.TextIter start; + Gtk.TextIter end; + + sbuf.get_bounds (out start, out end); + sbuf.remove_source_marks (start, end, "grey"); + + this.node_selected = sel; + if (sel == null) { + // no highlighting.. + return; + } + Gtk.TextIter iter; + sbuf.get_iter_at_line(out iter, sel.line_start); + + + Gtk.TextIter cur_iter; + sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position); + + //var cur_line = cur_iter.get_line(); + //if (cur_line > sel.line_start && cur_line < sel.line_end) { + + //} else { + if (! _this.buffer.in_cursor_change) { + this.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); + } + + + + for (var i = 0; i < buf.get_line_count();i++) { + if (i < sel.line_start || i > sel.line_end) { + + sbuf.get_iter_at_line(out iter, i); + sbuf.create_source_mark(null, "grey", iter); + + } + + } + + + } + public void updateGreySelection (bool scroll) { + var sel = this.node_selected; + print("node selected\n"); + var buf = this.el.get_buffer(); + var sbuf = (GtkSource.Buffer) buf; + + + this.clearGreySelection(); + + + + if (sel == null) { + print("no selected node\n"); + // no highlighting.. + return; + } + + print("highlight region %d to %d\n", sel.line_start,sel.line_end); + Gtk.TextIter iter; + sbuf.get_iter_at_line(out iter, sel.line_start); + + + Gtk.TextIter cur_iter; + sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position); + + var cursor_at_line = cur_iter.get_line(); + + + //var cur_line = cur_iter.get_line(); + //if (cur_line > sel.line_start && cur_line < sel.line_end) { + + //} else { + if (scroll) { + print("scrolling to node -- should occur on node picking.\n"); + this.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); + } + + var start_line = sel.line_start; + var end_line = sel.line_end; + + + this.el.editable = false; + + //var colon_pos = 0; + + this.editable_start_pos = -1; + + // now if we have selected a property... + if (this.prop_selected.length> 0 ) { + + int nstart, nend; + if (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) { + start_line = nstart; + end_line = nend; + // this.el.editable = true; << cant do this!!? + print("start line = %d, end line = %d\n", start_line, end_line); + + // see if we are 'right of ':' + // get an iter for the start of the line. + Gtk.TextIter start_first_line_iter,end_first_line_iter; + this.el.buffer.get_iter_at_line(out start_first_line_iter, start_line -1); + this.el.buffer.get_iter_at_line(out end_first_line_iter, start_line -1); + + + + + if (end_first_line_iter.forward_to_line_end()) { + var first_line = this.el.buffer.get_text(start_first_line_iter, end_first_line_iter, false); + + print("first line = %s\n", first_line); + if (first_line.contains(":")) { + this.editable_start_pos = start_first_line_iter.get_offset() + first_line.index_of(":") + 1; + print("colon_pos = %d\n", this.editable_start_pos); + } + + + //Gtk.TextIter colon_iter; + //sbuf.get_iter_at_offset (out colon_iter, colon_pos); + //sbuf.create_source_mark(null, "active_text", colon_iter); + } + + + + //print("is cursor at line? %d ?= %d\n", start_line -1 , cursor_at_line); + //if (start_line - 1 == cursor_at_line) { + // should be ok - current_posssion can not be less than '-1'... + if (sbuf.cursor_position < this.editable_start_pos) { + + print("cursor is before start pos.. - turn off editable...\n"); + //var before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false); + //print("before cursor string = %s\n", before_cursor_string); + //if (!before_cursor_string.contains(":")) { + this.el.editable = false; + //} + + } + + + + + } + print("propSelected = %s range %d -> %d\n", this.prop_selected, start_line, end_line); + + + } + + print("checking selection\n"); + + + // check selection - if it's out of 'bounds' + if (this.el.editable && sbuf.get_has_selection()) { + Gtk.TextIter sel_start_iter, sel_end_iter; + sbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter); + + if (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line || + sel_start_iter.get_line() > end_line || sel_end_iter.get_line() < start_line ) { + // save? + this.el.editable = false; + } + if (this.editable_start_pos > 0 && + (sel_start_iter.get_offset() < this.editable_start_pos || sel_end_iter.get_offset() < this.editable_start_pos) + + ) { + this.el.editable = false; + } + + + + } + + + + + for (var i = 0; i < buf.get_line_count();i++) { + if (i < (start_line -1) || i > (end_line -1)) { + + sbuf.get_iter_at_line(out iter, i); + sbuf.create_source_mark(null, "grey", iter); + + } + + } + if (scroll && (cursor_at_line > end_line || cursor_at_line < start_line)) { + Gtk.TextIter cpos_iter; + buf.get_iter_at_line(out cpos_iter, start_line); + + buf.place_cursor(cpos_iter); + } + + + } + public void highlightErrorsJson (string type, Json.Object obj) { + // this is a hook for the vala code - it has no value in javascript + // as we only have one error ususally.... + return ; + + + + + } + public void clearGreySelection () { + // clear all the marks.. + var sbuf = (GtkSource.Buffer)this.el.buffer; + + Gtk.TextIter start; + Gtk.TextIter end; + + sbuf.get_bounds (out start, out end); + sbuf.remove_source_marks (start, end, "grey"); + + + } + public string toString () { + Gtk.TextIter s; + Gtk.TextIter e; + this.el.get_buffer().get_start_iter(out s); + this.el.get_buffer().get_end_iter(out e); + var ret = this.el.get_buffer().get_text(s,e,true); + //print("TO STRING? " + ret); + return ret; + } + } + public class Xcls_buffer : Object + { + public GtkSource.Buffer el; + private Xcls_WindowRooView _this; + + + // my vars (def) + public int error_line; + public bool in_cursor_change; + public bool dirty; + public int last_line; + + // ctor + public Xcls_buffer(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.buffer = this; + this.el = new GtkSource.Buffer( null ); + + // my vars (dec) + this.error_line = -1; + this.in_cursor_change = false; + this.dirty = false; + this.last_line = -1; + + // set gobject values + + //listeners + this.el.cursor_moved.connect( ( ) => { + GLib.debug("cursor moved called"); + + + if (this.in_cursor_change ) { + GLib.debug("cursor changed : %d [ignoring nested call)", this.el.cursor_position); + return; + } + + GLib.debug("cursor changed : %d", this.el.cursor_position); + Gtk.TextIter cpos; + this.el.get_iter_at_offset(out cpos, this.el.cursor_position); + + var ln = cpos.get_line(); + if (this.last_line == ln ){ + return; + } + this.last_line = ln; + var node = _this.file.lineToNode(ln); + + if (node == null) { + print("can not find node\n"); + return; + } + this.in_cursor_change = true; + var ltree = _this.main_window.windowstate.left_tree; + ltree.model.selectNode(node); + this.in_cursor_change = false; + }); + this.el.changed.connect( () => { + + // check syntax?? + // ??needed..?? + // _this.save_button.el.sensitive = true; + ///?? has changed occured during loading? + + // only trigger this if + + + + + if (_this.sourceview.loading) { + return; + } + + + + print("- PREVIEW EDITOR CHANGED--"); + + this.dirty = true; + // this.checkSyntax(); // this calls backs and highlights errors.. in theory... + + + + if (!_this.sourceview.button_is_pressed && !_this.sourceview.key_is_pressed) { + print("button or key not pressed to generate change?!\n"); + return; + } + + + // what are we editing?? + if (null == _this.sourceview.node_selected || _this.sourceview.prop_selected.length < 1) { + return; + } + + // find the colon on the first line... + + if (_this.sourceview.editable_start_pos > -1) { + + var buf = (GtkSource.Buffer)_this.sourceview.el.get_buffer(); + + //print("cursor changed : %d\n", buf.cursor_position); + Gtk.TextIter spos,epos; + buf.get_iter_at_offset(out spos, _this.sourceview.editable_start_pos); + buf.get_iter_at_offset(out epos, _this.sourceview.editable_start_pos); // initialize epos.. + + var gotit= false; + var line = spos.get_line(); + var endline = buf.get_line_count(); + while (line < endline) { + line++; + buf.get_iter_at_line(out epos, line); + if (buf.get_source_marks_at_line(line, "grey").length() > 0) { + buf.get_iter_at_line(out epos, line); + gotit=true; + break; + } + } + + if (gotit) { + print("End Offset = %d/%d\n", epos.get_line(), epos.get_offset()); + // get the pos... + // in theory the last char will be '}' or '},' .. or ',' + // we should chop the ',' of the end... + var str = buf.get_text(spos, epos, false); + print("got string\n%s\n", str); + + } + } + return ; + }); + } + + // user defined functions + public bool highlightErrors ( Gee.HashMap validate_res) { + + this.error_line = validate_res.size; + + if (this.error_line < 1) { + return true; + } + var tlines = this.el.get_line_count (); + Gtk.TextIter iter; + var valiter = validate_res.map_iterator(); + while (valiter.next()) { + + // print("get inter\n"); + var eline = valiter.get_key(); + if (eline > tlines) { + continue; + } + this.el.get_iter_at_line( out iter, eline); + //print("mark line\n"); + this.el.create_source_mark(valiter.get_value(), "ERR", iter); + } + return false; + } + public string toString () { + + Gtk.TextIter s; + Gtk.TextIter e; + this.el.get_start_iter(out s); + this.el.get_end_iter(out e); + var ret = this.el.get_text(s,e,true); + //print("TO STRING? " + ret); + return ret; + } + } + + public class Xcls_EventControllerKey17 : Object + { + public Gtk.EventControllerKey el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_EventControllerKey17(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.EventControllerKey(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.key_pressed.connect( (keyval, keycode, state) => { + + + + if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-g pressed"); + _this.forwardSearch(true); + return false; + } + if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-f pressed"); + _this.search_entry.el.grab_focus(); + return false ; + } + + //this.button_is_pressed = true; + //return false; + // print(event.key.keyval) + + return false; + + + }); + } + + // user defined functions + } + + + + public class Xcls_Box18 : Object + { + public Gtk.Box el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Box18(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + this.el.vexpand = false; + new Xcls_search_entry( _this ); + this.el.append( _this.search_entry.el ); + new Xcls_search_results( _this ); + this.el.append( _this.search_results.el ); + new Xcls_nextBtn( _this ); + this.el.append( _this.nextBtn.el ); + new Xcls_backBtn( _this ); + this.el.append( _this.backBtn.el ); + var child_5 = new Xcls_MenuButton24( _this ); + child_5.ref(); + this.el.append( child_5.el ); + } + + // user defined functions + } + public class Xcls_search_entry : Object + { + public Gtk.SearchEntry el; + private Xcls_WindowRooView _this; + + + // my vars (def) + public Gtk.CssProvider css; + + // ctor + public Xcls_search_entry(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.search_entry = this; + this.el = new Gtk.SearchEntry(); + + // my vars (dec) + + // set gobject values + this.el.name = "roo-search-entry"; + this.el.hexpand = true; + this.el.placeholder_text = "Press enter to search"; + var child_1 = new Xcls_EventControllerKey20( _this ); + child_1.ref(); + this.el.add_controller( child_1.el ); + + // init method + + this.css = new Gtk.CssProvider(); + + this.css.load_from_string( + "#roo-search-entry { background-color: #ccc; }" + ); + + Gtk.StyleContext.add_provider_for_display( + this.el.get_display(), + this.css, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + ); + + //listeners + this.el.search_changed.connect( ( ) => { + + _this.search(_this.search_entry.el.text); + _this.search_results.updateResults(); + + GLib.Timeout.add_seconds(1,() => { + _this.search_results.updateResults(); + return false; + }); + }); + } + + // user defined functions + public void forwardSearch (bool change_focus) { + + + _this.forwardSearch(change_focus); + + /* + + switch(_this.windowstate.state) { + case WindowState.State.CODEONLY: + //case WindowState.State.CODE: + // search the code being edited.. + _this.windowstate.code_editor_tab.forwardSearch(change_focus); + + break; + case WindowState.State.PREVIEW: + if (_this.windowstate.file.xtype == "Gtk") { + _this.windowstate.window_gladeview.forwardSearch(change_focus); + } else { + _this.windowstate.window_rooview.forwardSearch(change_focus); + } + + break; + } + */ + + } + } + public class Xcls_EventControllerKey20 : Object + { + public Gtk.EventControllerKey el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_EventControllerKey20(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.EventControllerKey(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.key_pressed.connect( (keyval, keycode, state) => { + + if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-g pressed"); + _this.forwardSearch(true); + return true; + } + + + if (keyval == Gdk.Key.Return) { + _this.forwardSearch(true); + + + return true; + + } + // print(event.key.keyval) + + return false; + }); + } + + // user defined functions + } + + + public class Xcls_search_results : Object + { + public Gtk.Label el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_search_results(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.search_results = this; + this.el = new Gtk.Label( "No Results" ); + + // my vars (dec) + + // set gobject values + this.el.margin_end = 4; + this.el.margin_start = 4; + } + + // user defined functions + public void updateResults () { + this.el.visible = true; + + var res = _this.searchcontext.get_occurrences_count(); + if (res < 0) { + _this.search_results.el.label = "??? Matches"; + return; + } + + _this.nextBtn.el.sensitive = false; + _this.backBtn.el.sensitive = false; + + if (res > 0) { + _this.search_results.el.label = "%d Matches".printf(res); + _this.nextBtn.el.sensitive = true; + _this.backBtn.el.sensitive = true; + return; + } + _this.search_results.el.label = "No Matches"; + + } + } + + public class Xcls_nextBtn : Object + { + public Gtk.Button el; + private Xcls_WindowRooView _this; + + + // my vars (def) + public bool always_show_image; + + // ctor + public Xcls_nextBtn(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.nextBtn = this; + this.el = new Gtk.Button(); + + // my vars (dec) + this.always_show_image = true; + + // set gobject values + this.el.icon_name = "go-down"; + this.el.sensitive = false; + + //listeners + this.el.clicked.connect( (event) => { + + _this.forwardSearch(true); + + }); + } + + // user defined functions + } + + public class Xcls_backBtn : Object + { + public Gtk.Button el; + private Xcls_WindowRooView _this; + + + // my vars (def) + public bool always_show_image; + + // ctor + public Xcls_backBtn(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.backBtn = this; + this.el = new Gtk.Button(); + + // my vars (dec) + this.always_show_image = true; + + // set gobject values + this.el.icon_name = "go-up"; + this.el.sensitive = false; + + //listeners + this.el.clicked.connect( (event) => { + + _this.backSearch(true); + + + }); + } + + // user defined functions + } + + public class Xcls_MenuButton24 : Object + { + public Gtk.MenuButton el; + private Xcls_WindowRooView _this; + + + // my vars (def) + public bool always_show_image; + + // ctor + public Xcls_MenuButton24(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.MenuButton(); + + // my vars (dec) + this.always_show_image = true; + + // set gobject values + this.el.icon_name = "emblem-system"; + new Xcls_search_settings( _this ); + this.el.popover = _this.search_settings.el; + } + + // user defined functions + } + public class Xcls_search_settings : Object + { + public Gtk.Popover el; + private Xcls_WindowRooView _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_search_settings(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.search_settings = this; - this.el = new Gtk.Popover(); - - // my vars (dec) + // ctor + public Xcls_search_settings(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.search_settings = this; + this.el = new Gtk.Popover(); + + // my vars (dec) - // set gobject values - var child_1 = new Xcls_Box27( _this ); - this.el.child = child_1.el; - } + // set gobject values + var child_1 = new Xcls_Box26( _this ); + this.el.child = child_1.el; + } - // user defined functions - } - public class Xcls_Box27 : Object - { - public Gtk.Box el; - private Xcls_WindowRooView _this; + // user defined functions + } + public class Xcls_Box26 : Object + { + public Gtk.Box el; + private Xcls_WindowRooView _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_Box27(Xcls_WindowRooView _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + // ctor + public Xcls_Box26(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - // my vars (dec) + // my vars (dec) - // set gobject values - new Xcls_case_sensitive( _this ); - this.el.append( _this.case_sensitive.el ); - new Xcls_regex( _this ); - this.el.append( _this.regex.el ); - new Xcls_multiline( _this ); - this.el.append( _this.multiline.el ); - } + // set gobject values + new Xcls_case_sensitive( _this ); + this.el.append( _this.case_sensitive.el ); + new Xcls_regex( _this ); + this.el.append( _this.regex.el ); + new Xcls_multiline( _this ); + this.el.append( _this.multiline.el ); + } - // user defined functions - } - public class Xcls_case_sensitive : Object - { - public Gtk.CheckButton el; - private Xcls_WindowRooView _this; + // user defined functions + } + public class Xcls_case_sensitive : Object + { + public Gtk.CheckButton el; + private Xcls_WindowRooView _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_case_sensitive(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.case_sensitive = this; - this.el = new Gtk.CheckButton(); + // ctor + public Xcls_case_sensitive(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.case_sensitive = this; + this.el = new Gtk.CheckButton(); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.label = "Case Sensitive"; + // set gobject values + this.el.label = "Case Sensitive"; - // init method + // init method - { - this.el.show(); - } - } + { + this.el.show(); + } + } - // user defined functions - } + // user defined functions + } - public class Xcls_regex : Object - { - public Gtk.CheckButton el; - private Xcls_WindowRooView _this; + public class Xcls_regex : Object + { + public Gtk.CheckButton el; + private Xcls_WindowRooView _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_regex(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.regex = this; - this.el = new Gtk.CheckButton(); + // ctor + public Xcls_regex(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.regex = this; + this.el = new Gtk.CheckButton(); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.label = "Regex"; + // set gobject values + this.el.label = "Regex"; - // init method + // init method - { - this.el.show(); - } - } + { + this.el.show(); + } + } - // user defined functions - } + // user defined functions + } - public class Xcls_multiline : Object - { - public Gtk.CheckButton el; - private Xcls_WindowRooView _this; + public class Xcls_multiline : Object + { + public Gtk.CheckButton el; + private Xcls_WindowRooView _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_multiline(Xcls_WindowRooView _owner ) - { - _this = _owner; - _this.multiline = this; - this.el = new Gtk.CheckButton(); + // ctor + public Xcls_multiline(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.multiline = this; + this.el = new Gtk.CheckButton(); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.label = "Multi-line (add \\n)"; + // set gobject values + this.el.label = "Multi-line (add \\n)"; - // init method + // init method - { - this.el.show(); - } - } + { + this.el.show(); + } + } - // user defined functions - } + // user defined functions + } @@ -2186,4 +2152,4 @@ - } +} diff --git a/src/Builder4/WindowState.vala b/src/Builder4/WindowState.vala index 9aa323863..31680356e 100644 --- a/src/Builder4/WindowState.vala +++ b/src/Builder4/WindowState.vala @@ -655,7 +655,7 @@ public class WindowState : Object BuilderApplication.updateWindows(); file.getLanguageServer().document_open(file); - + BuilderApplication.showSpinner("spinner", "document open sent"); if (file.xtype == "PlainFile") { this.win.codeeditviewbox.el.show(); @@ -673,10 +673,7 @@ public class WindowState : Object } - - - - + this.gotoLine(line); @@ -771,7 +768,9 @@ public class WindowState : Object return; } this.rightpalete.hide(); - this.add_props.el.set_parent(btn); + if (this.add_props.el.parent == null) { + this.add_props.el.set_parent(btn); + } this.add_props.el.set_position(Gtk.PositionType.RIGHT); this.add_props.show( diff --git a/src/JsRender/Gtk.vala b/src/JsRender/Gtk.vala index dc4313948..3ae204c0b 100644 --- a/src/JsRender/Gtk.vala +++ b/src/JsRender/Gtk.vala @@ -167,7 +167,9 @@ namespace JsRender { // this.saveJS(); - disabled at present.. project settings will probably enable this later.. this.saveVala(); + this.getLanguageServer().document_save(this); + BuilderApplication.showSpinner("spinner", "document save send"); } // ignore these calls. public override void saveHTML ( string html ) {} diff --git a/src/JsRender/JsRender.vala b/src/JsRender/JsRender.vala index 09e4f13b6..3e9818587 100644 --- a/src/JsRender/JsRender.vala +++ b/src/JsRender/JsRender.vala @@ -122,7 +122,25 @@ namespace JsRender { public signal void compile_notice(string type, string file, int line, string message); - + private GLib.Icon? _icon = null; + + public GLib.Icon? icon { + private set {} + get { + if (this._icon != null) { + return this._icon; + } + + if (this.path == "") { + return null; + } + if (!GLib.FileUtils.test(this.path, GLib.FileTest.EXISTS)) { + return null; + } + this._icon = File.new_for_path(this.path).query_info("standard::icon",GLib.FileQueryInfoFlags.NONE).get_icon(); + return this._icon; + } + } /** * UI componenets @@ -171,10 +189,9 @@ namespace JsRender { this.doubleStringProps = new Gee.ArrayList(); this.childfiles = new GLib.ListStore(typeof(JsRender)); this.errorsByType = new Gee.HashMap(); + + - if (this.relpath == "src/Lsp.vala") { - GLib.debug("got testing lsp"); - } } @@ -341,11 +358,14 @@ namespace JsRender { GLib.debug("Width %d, Height %d", widget.get_width(), widget.get_height()); p.snapshot(s, widget.get_width(), widget.get_height()); var n = s.free_to_node(); + if (n == null) { + return; + } var r = new Gsk.CairoRenderer(); r.realize(null); var t = r.render_texture(n,null); GLib.debug("write to %s", filename); - t.save_to_png(filename); + t.save_to_png(filename); r.unrealize(); diff --git a/src/JsRender/Node.vala b/src/JsRender/Node.vala index e1cdd2ab3..324f048d4 100644 --- a/src/JsRender/Node.vala +++ b/src/JsRender/Node.vala @@ -1007,8 +1007,9 @@ public class JsRender.Node : GLib.Object { public void add_prop(NodeProp prop) { - if (this.has_prop_key(prop)) { - GLib.error("duplicate key - can not add - call has_prop_key first"); + if (this.has_prop_key(prop) && !prop.to_index_key().has_suffix("[]")) { + GLib.warning("duplicate key' %s'- can not add - call has_prop_key first", prop.to_index_key()); + return; } prop.parent = this; this.propstore.append(prop); diff --git a/src/JsRender/NodeToGlade.vala b/src/JsRender/NodeToGlade.vala index 669200c04..785db383f 100644 --- a/src/JsRender/NodeToGlade.vala +++ b/src/JsRender/NodeToGlade.vala @@ -127,7 +127,7 @@ public class JsRender.NodeToGlade : Object { var pviter = props.map_iterator(); while (!skip_props && pviter.next()) { - GLib.debug ("Check: " +cls + "::(" + pviter.get_value().propertyof + ")" + pviter.get_key() + " " ); + //GLib.debug ("Check: " +cls + "::(" + pviter.get_value().propertyof + ")" + pviter.get_key() + " " ); // skip items we have already handled.. if (!this.node.has(pviter.get_key())) { diff --git a/src/JsRender/NodeToVala.vala b/src/JsRender/NodeToVala.vala index f92c49016..ce1991e1f 100644 --- a/src/JsRender/NodeToVala.vala +++ b/src/JsRender/NodeToVala.vala @@ -55,12 +55,12 @@ public class JsRender.NodeToVala : Object { this.node = node; this.depth = depth; if (file.name.contains(".")) { // namespaced.. - this.inpad = string.nfill(depth > 0 ? 8 : 4, ' '); + this.inpad = string.nfill(depth > 0 ? 2 : 1, '\t'); } else { - this.inpad = string.nfill(depth > 0 ? 8 : 4, ' '); + this.inpad = string.nfill(depth > 0 ? 1 : 0, '\t'); } - this.pad = this.inpad + " "; - this.ipad = this.inpad + " "; + this.pad = this.inpad + "\t"; + this.ipad = this.inpad + "\t\t"; this.cls = node.xvala_cls; this.xcls = node.xvala_xcls; if (depth == 0 && this.xcls.contains(".")) { @@ -217,9 +217,17 @@ public class JsRender.NodeToVala : Object { } public void addLine(string str= "") { + + if (str.contains("\n")) { + this.addMultiLine(str); + return; + } this.cur_line++; - //this.ret += "/*%d*/ ".printf(this.cur_line-1) + str + "\n"; - this.ret += str + "\n"; + if (BuilderApplication.opt_bjs_compile != null) { + this.ret += "/*%d*/ ".printf(this.cur_line) + str + "\n"; + } else { + this.ret += str + "\n"; + } } public void addMultiLine(string str= "") { diff --git a/src/Lsp.vala b/src/Lsp.vala index b5c4f00cb..1e6c4651d 100644 --- a/src/Lsp.vala +++ b/src/Lsp.vala @@ -366,9 +366,31 @@ namespace Lsp { return node; } - public bool deserialize_property (string property_name, out Value value, ParamSpec pspec, Json.Node property_node) { - error ("deserialization not supported"); - } + public bool deserialize_property (string property_name, out Value value, ParamSpec pspec, Json.Node property_node) + { + + if (property_name != "children") { + return default_deserialize_property (property_name, out value, pspec, property_node); + } + value = GLib.Value (GLib.Type.BOXED); + if (property_node.get_node_type () != Json.NodeType.ARRAY) { + warning ("unexpected property node type for 'arguments' %s", property_node.get_node_type ().to_string ()); + return false; + } + + var arguments = new Gee.ArrayList(); + + property_node.get_array ().foreach_element ((array, index, element) => { + + var add= Json.gobject_deserialize ( typeof (DocumentSymbol), array.get_element(index)) as DocumentSymbol; + arguments.add( add); + + + }); + + value.set_boxed (arguments); + return true; + } } public class SymbolInformation : Object { @@ -635,6 +657,7 @@ namespace Lsp { if (property_name != "tags") { return default_deserialize_property (property_name, out value, pspec, property_node); } + value = GLib.Value (GLib.Type.BOXED); if (property_node.get_node_type () != Json.NodeType.ARRAY) { warning ("unexpected property node type for 'arguments' %s", property_node.get_node_type ().to_string ()); return false; @@ -937,9 +960,10 @@ namespace Lsp { return node; } - public bool deserialize_property (string property_name, out GLib.Value value, GLib.ParamSpec pspec, Json.Node property_node) { + public bool deserialize_property (string property_name, out GLib.Value value, GLib.ParamSpec pspec, Json.Node property_node) + { if (property_name == "arguments") { - value = Value (typeof (Array)); + value = GLib.Value (GLib.Type.BOXED); if (property_node.get_node_type () != Json.NodeType.ARRAY) { warning ("unexpected property node type for 'arguments' %s", property_node.get_node_type ().to_string ()); return false; diff --git a/src/Makefile.am b/src/Makefile.am index 2d5836a1a..b289e94da 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -184,7 +184,6 @@ BUIDERPALETE = Palete/Gir.vala \ Palete/RooDatabase.vala \ Palete/Palete.vala \ Palete/Roo.vala \ - Palete/ValaSource.vala \ Palete/ValaSourceCompiler.vala \ Palete/CompletionProvider.vala \ Palete/CompileError.vala \ diff --git a/src/Palete/CompileError.vala b/src/Palete/CompileError.vala index ef8fcea93..e33935d39 100644 --- a/src/Palete/CompileError.vala +++ b/src/Palete/CompileError.vala @@ -28,7 +28,7 @@ namespace Palete { this.msg = msg; this.file = file; this.category = category; - + } @@ -39,7 +39,7 @@ namespace Palete { this.line = (int) diag.range.start.line; this.msg = diag.message; this.lines = new GLib.ListStore(typeof(CompileError)); - GLib.debug("new error %s : %d %s %s", file.path, this.line, this.category, this.msg); + //GLib.debug("new error %s : %d %s %s", file.path, this.line, this.category, this.msg); diff --git a/src/Palete/CompletionProvider.vala b/src/Palete/CompletionProvider.vala index 74cca1f0b..d8858bd72 100644 --- a/src/Palete/CompletionProvider.vala +++ b/src/Palete/CompletionProvider.vala @@ -37,7 +37,11 @@ namespace Palete { public void activate (GtkSource.CompletionContext context, GtkSource.CompletionProposal proposal) { GLib.debug("compelte activate"); + var p = (CompletionProposal) proposal; + GLib.debug("lsp says use %s", p.ci.insertText); + + global::Gtk.TextMark end_mark = null; global::Gtk.TextIter begin, end; @@ -47,6 +51,20 @@ namespace Palete { var buffer = begin.get_buffer(); var word = p.label; + if (p.ci.kind == Lsp.CompletionItemKind.Method || p.ci.kind == Lsp.CompletionItemKind.Function) { + var bits = p.text.split("("); + var abits = bits[1].split(")"); + var args = abits[0].split(","); + + word += "("; + for(var i = 0 ; i < args.length; i++) { + word += i > 0 ? ", " : " "; + var wbit = args[i].split(" "); + word += wbit[1]; + } + word += args.length > 0 ? " )" : ")"; + } + var len = -1; @@ -91,7 +109,7 @@ namespace Palete { public void display (GtkSource.CompletionContext context, GtkSource.CompletionProposal proposal, GtkSource.CompletionCell cell) { - GLib.debug("compelte display"); + //GLib.debug("compelte display"); var col = cell.get_column(); var p = (CompletionProposal) proposal; @@ -100,12 +118,57 @@ namespace Palete { cell.set_text(p.label); break; case GtkSource.CompletionColumn.ICON: - cell.set_icon_name("completion-snippet-symbolic"); - break; +//cell.set_icon_name("lang-define-symbolic");return; +//cell.set_icon_name("lang-include-symbolic");return; +//cell.set_icon_name("lang-typedef-symbolic");return; +//cell.set_icon_name("lang-union-symbolic");return; + switch (p.ci.kind) { + + case Lsp.CompletionItemKind.Text: cell.set_icon_name("completion-snippet-symbolic");return; + case Lsp.CompletionItemKind.Method: cell.set_icon_name("lang-method-symbolic");return; + case Lsp.CompletionItemKind.Function: cell.set_icon_name("lang-function-symbolic");return; + case Lsp.CompletionItemKind.Constructor: cell.set_icon_name("lang-method-symbolic");return; + case Lsp.CompletionItemKind.Field: cell.set_icon_name("lang-struct-field-symbolic");return; + case Lsp.CompletionItemKind.Variable: cell.set_icon_name("lang-variable-symbolic");return; + case Lsp.CompletionItemKind.Class: cell.set_icon_name("lang-class-symbolic");return; + case Lsp.CompletionItemKind.Interface: cell.set_icon_name("lang-class-symbolic");return; + case Lsp.CompletionItemKind.Module: cell.set_icon_name("lang-namespace-symbolic");return; + case Lsp.CompletionItemKind.Property:cell.set_icon_name("lang-struct-field-symbolic");return; + case Lsp.CompletionItemKind.Unit: cell.set_icon_name("lang-variable-symbolic");return; + case Lsp.CompletionItemKind.Value: cell.set_icon_name("lang-variable-symbolic");return; + case Lsp.CompletionItemKind.Enum: cell.set_icon_name("lang-enum-symbolic");return; + case Lsp.CompletionItemKind.Keyword: cell.set_icon_name("completion-word-symbolic");return; + case Lsp.CompletionItemKind.Snippet: cell.set_icon_name("completion-snippet-symbolic");return; + + case Lsp.CompletionItemKind.Color: cell.set_icon_name("lang-typedef-symbolic");return; + case Lsp.CompletionItemKind.File:cell.set_icon_name("lang-typedef-symbolic");return; + case Lsp.CompletionItemKind.Reference: cell.set_icon_name("lang-typedef-symbolic");return; + case Lsp.CompletionItemKind.Folder:cell.set_icon_name("lang-typedef-symbolic");return; + case Lsp.CompletionItemKind.EnumMember: cell.set_icon_name("lang-typedef-symbolic");return; + case Lsp.CompletionItemKind.Constant:cell.set_icon_name("lang-typedef-symbolic");return; + case Lsp.CompletionItemKind.Struct: cell.set_icon_name("lang-struct-symbolic");return; + case Lsp.CompletionItemKind.Event:cell.set_icon_name("lang-typedef-symbolic");return; + case Lsp.CompletionItemKind.Operator:cell.set_icon_name("lang-typedef-symbolic");return; + case Lsp.CompletionItemKind.TypeParameter:cell.set_icon_name("lang-typedef-symbolic");return; + default: + + + + + cell.set_icon_name("completion-snippet-symbolic"); + return; + } + + case GtkSource.CompletionColumn.COMMENT: - cell.set_text(p.info); + cell.set_text(p.text); break; case GtkSource.CompletionColumn.DETAILS: + if (p.ci.documentation != null) { + cell.set_text(p.ci.documentation.value); + return; + } + cell.set_text(p.text); break; default: @@ -114,19 +177,43 @@ namespace Palete { } } - + bool in_populate = false; - internal async GLib.ListModel populate_async (GtkSource.CompletionContext context, GLib.Cancellable? cancellable) + internal async GLib.ListModel populate_async (GtkSource.CompletionContext context, GLib.Cancellable? cancellable) { GLib.debug("pupoulate async"); - + /*if (!this.in_populate) { + GLib.debug("pupoulate async - skipped waiting for reply"); + return null; + } + this.in_populate = true; +*/ global::Gtk.TextIter begin, end; Lsp.CompletionList res; if (context.get_bounds (out begin, out end)) { - yield this.file.getLanguageServer().completion(this.file, end.get_line(), end.get_line_offset(), 1, out res); + var line = end.get_line(); + var offset = end.get_line_offset(); + if (this.editor.prop != null) { + // tried line -1 (does not work) + + line += this.editor.prop.start_line ; + // this is based on Gtk using tabs (hence 1/2 chars); + offset += this.editor.file.file_namespace == "" ? 1 : 2; + } + + this.file.getLanguageServer().document_change_real(this.file, this.editor.tempFileContents()); + try { + yield this.file.getLanguageServer().completion(this.file, line, offset, 1, out res); + } catch (GLib.Error e) { + GLib.debug("got error %s", e.message); + res = null; + } + } else { res = null; } + + GLib.debug("pupoulate async - got reply"); this.model = new CompletionModel(this, context, res, cancellable); var word = context.get_word(); @@ -137,6 +224,7 @@ namespace Palete { var filter_model = new global::Gtk.FilterListModel(this.model, this.filter); filter.match_mode = global::Gtk.StringFilterMatchMode.PREFIX; filter_model.set_incremental(true); + this.in_populate = false; return filter_model; @@ -146,7 +234,7 @@ namespace Palete { internal void refilter (GtkSource.CompletionContext context, GLib.ListModel in_model) { - GLib.debug("pupoulate refilter"); + //GLib.debug("pupoulate refilter"); var word = context.get_word(); @@ -212,7 +300,7 @@ namespace Palete { } items.sort((a, b) => { - return ((string)(a.text)).collate((string)(b.text)); + return ((string)(a.label)).collate((string)(b.label)); }); } @@ -264,14 +352,17 @@ namespace Palete { public string text { get; set; default = ""; } public string info { get; set; default = ""; } + + public Lsp.CompletionItem ci; + public CompletionProposal(Lsp.CompletionItem ci) //string label, string text, string info) { - + this.ci = ci; this.text = ci.detail == null ? "" : ci.detail ; this.label = ci.label; this.info = ci.documentation == null ? "": ci.documentation.value; - GLib.debug("SET: text=%s, label = %s; info =%s", ci.detail, ci.label, "to long.."); + //GLib.debug("SET: detail =%s, label = %s; info =%s", ci.detail, ci.label, "to long.."); } } diff --git a/src/Palete/LanguageClient.vala b/src/Palete/LanguageClient.vala index d3dd0928f..5f06a22e1 100644 --- a/src/Palete/LanguageClient.vala +++ b/src/Palete/LanguageClient.vala @@ -9,30 +9,111 @@ namespace Palete { - + public enum LanguageClientAction { + INIT, + LAUNCH, + ACCEPT, + + DIAG, + OPEN, + SAVE, + CLOSE, + CHANGE, + TERM, + COMPLETE, + COMPLETE_REPLY, + + RESTART, + ERROR, + ERROR_START, + ERROR_RPC, + ERROR_REPLY, + + EXIT, + } public abstract class LanguageClient : Jsonrpc.Server { public Project.Project project; - private GLib.SubprocessLauncher launcher; - private GLib.Subprocess subprocess; - private IOStream subprocess_stream; + private GLib.SubprocessLauncher launcher = null; + private GLib.Subprocess? subprocess = null; + private IOStream? subprocess_stream = null; public Jsonrpc.Client? jsonrpc_client = null; + Gee.ArrayList open_files; + private JsRender.JsRender? _change_queue_file = null; + private string change_queue_file_source = ""; + + JsRender.JsRender? change_queue_file { + set { + this.change_queue_file_source = value == null ? "" : value.toSource(); + this._change_queue_file = value; + } + get { + return this._change_queue_file; + } + } + + uint change_queue_id = 0; + int countdown = 0; + protected bool initialized = false; + bool sent_shutdown = false; + private bool _closed = false; + private bool closed { + get { return this._closed ; } + set { + GLib.debug("closed has been set? to %s" , value ? "TRUE" : "FALSE" ); + this._closed = value; + } + } + + public signal void log(LanguageClientAction action, string message); + + protected LanguageClient(Project.Project project) { // extend versions will proably call initialize to start and connect to server. this.project = project; - + this.open_files = new Gee.ArrayList(); + this.change_queue_id = GLib.Timeout.add_seconds(1, () => { + if (this.change_queue_file == null) { + return true; + } + this.countdown--; + if (this.countdown < 0){ + this.document_change_real(this.change_queue_file, this.change_queue_file_source); + this.change_queue_file = null; + + } + return true; + }); } public bool initProcess(string process_path) { + this.onClose(); + this.log(LanguageClientAction.LAUNCH, process_path); + GLib.debug("Launching %s", process_path); this.launcher = new GLib.SubprocessLauncher (SubprocessFlags.STDIN_PIPE | SubprocessFlags.STDOUT_PIPE); this.launcher.set_environ(GLib.Environ.get()); try { + + this.subprocess = launcher.spawnv ({ process_path }); + + this.subprocess.wait_async.begin( null, ( obj,res ) => { + try { + this.subprocess.wait_async.end(res); + } catch (GLib.Error e) { + this.log(LanguageClientAction.ERROR_START, e.message); + GLib.debug("subprocess startup error %s", e.message); + } + this.log(LanguageClientAction.EXIT, "process ended"); + GLib.debug("Subprocess ended %s", process_path); + this.onClose(); + + }); var input_stream = this.subprocess.get_stdout_pipe (); var output_stream = this.subprocess.get_stdin_pipe (); @@ -41,19 +122,60 @@ namespace Palete { if (!GLib.Unix.set_fd_nonblocking(((GLib.UnixInputStream)input_stream).fd, true) || !GLib.Unix.set_fd_nonblocking (((GLib.UnixOutputStream)output_stream).fd, true)) { - GLib.debug("could not set pipes to nonblocking"); + GLib.debug("could not set pipes to nonblocking"); + this.onClose(); return false; } } - this.subprocess_stream = new SimpleIOStream (input_stream, output_stream); + this.subprocess_stream = new GLib.SimpleIOStream (input_stream, output_stream); this.accept_io_stream ( this.subprocess_stream); } catch (GLib.Error e) { - GLib.debug("subprocess startup error %s", e.message); + this.log(LanguageClientAction.ERROR_START, e.message); + GLib.debug("subprocess startup error %s", e.message); + this.onClose(); return false; } return true; } - + bool in_close = false; + public void onClose() + { + if (this.in_close) { + return; + } + if (this.launcher == null) { + return; + } + this.in_close = true; + GLib.debug("onClose called"); + + if (this.jsonrpc_client != null) { + try { + this.jsonrpc_client.close(); + } catch (GLib.Error e) { + GLib.debug("rpc Error close error %s", e.message); + } + } + if (this.subprocess_stream != null) { + try { + this.subprocess_stream.close(); + } catch (GLib.Error e) { + GLib.debug("stream Error close %s", e.message); + } + } + if (this.subprocess != null) { + this.subprocess.force_exit(); + } + if (this.launcher != null) { + this.launcher.close(); + } + + this.launcher = null; + this.subprocess = null; + this.jsonrpc_client = null; + this.closed = true; + this.in_close = false; + } /** utility method to build variant based queries */ @@ -77,13 +199,16 @@ namespace Palete { this.jsonrpc_client = client; GLib.debug("client accepted connection - calling init server"); - + this.log(LanguageClientAction.ACCEPT, "client accepted"); this.jsonrpc_client.notification.connect((method, paramz) => { this.onNotification(method, paramz); }); this.jsonrpc_client.failed.connect(() => { + this.log(LanguageClientAction.ERROR_RPC, "client failed"); + this.onClose(); + GLib.debug("language server server has failed"); }); @@ -94,6 +219,19 @@ namespace Palete { } public bool isReady() { + if (this.closed) { + this.log(LanguageClientAction.RESTART,"closed is set - restarting"); + GLib.debug("server stopped = restarting"); + this.initialized = false; + this.closed = false; + this.startServer(); + foreach(var f in this.open_files) { + this.document_open(f); + } + return false; // can't do an operation yet? + + } + if (!this.initialized) { GLib.debug("Server has not been initialized"); return false; @@ -102,16 +240,19 @@ namespace Palete { GLib.debug("Server has been started its shutting down process"); return false; } + // restart server.. + + + return true; } public abstract void initialize_server(); - + public abstract void startServer(); //public abstract void initialize_server() ; - protected bool initialized = false; - bool sent_shutdown = false; + public void onNotification(string method, Variant? return_value) @@ -133,10 +274,13 @@ namespace Palete { */ public void onDiagnostic(Variant? return_value) { + var dg = Json.gobject_deserialize (typeof (Lsp.Diagnostics), Json.gvariant_serialize (return_value)) as Lsp.Diagnostics; + this.log(LanguageClientAction.DIAG, dg.filename); var f = this.project.getByPath(dg.filename); if (f == null) { - GLib.debug("no file %s", dg.uri); + //GLib.debug("no file %s", dg.uri); + this.project.updateErrorsforFile(null); return; } foreach(var v in f.errorsByType.values) { @@ -158,6 +302,10 @@ namespace Palete { if (!this.isReady()) { return; } + if (!this.open_files.contains(file)) { + this.open_files.add(file); + } + GLib.debug ("LS sent open"); try { this.jsonrpc_client.send_notification ( @@ -172,7 +320,10 @@ namespace Palete { ), null ); + this.log(LanguageClientAction.OPEN, file.path); } catch( GLib.Error e) { + this.log(LanguageClientAction.ERROR_RPC, e.message); + this.onClose(); GLib.debug ("LS sent open err %s", e.message); } @@ -183,20 +334,24 @@ namespace Palete { if (!this.isReady()) { return; } - GLib.debug ("LS send save"); + this.change_queue_file = null; + GLib.debug ("LS send save"); try { this.jsonrpc_client.send_notification ( "textDocument/didChange", this.buildDict ( textDocument : this.buildDict ( ///TextDocumentItem; - uri: new GLib.Variant.string (file.to_url()) - + uri: new GLib.Variant.string (file.to_url()), + version : new GLib.Variant.uint64 ( (uint64) file.version) ) ), null ); + this.log(LanguageClientAction.SAVE, file.path); } catch( GLib.Error e) { - GLib.debug ("LS sent save err %s", e.message); + this.log(LanguageClientAction.ERROR_RPC, e.message); + GLib.debug ("LS save err %s", e.message); + this.onClose(); } @@ -206,7 +361,13 @@ namespace Palete { if (!this.isReady()) { return; } - GLib.debug ("LS send close"); + this.change_queue_file = null; + + if (this.open_files.contains(file)) { + this.open_files.remove(file); + } + this.log(LanguageClientAction.CLOSE, file.path); + GLib.debug ("LS send close"); try { this.jsonrpc_client.send_notification ( "textDocument/didChange", @@ -219,23 +380,44 @@ namespace Palete { null ); } catch( GLib.Error e) { - GLib.debug ("LS sent close err %s", e.message); + this.log(LanguageClientAction.ERROR_RPC, e.message); + GLib.debug ("LS close err %s", e.message); + this.onClose(); } } - public void document_change (JsRender.JsRender file) + + + public void document_change (JsRender.JsRender file ) + { + if (this.change_queue_file != null && this.change_queue_file.path != file.path) { + this.document_change_real(this.change_queue_file, this.change_queue_file_source); + } + + this.countdown = 3; + this.change_queue_file = file; + + + + } + + + public void document_change_real (JsRender.JsRender file, string contents) { if (!this.isReady()) { return; } + + GLib.debug ("LS send change"); var ar = new Json.Array(); var obj = new Json.Object(); - obj.set_string_member("text", file.toSource()); + obj.set_string_member("text", contents); ar.add_object_element(obj); var node = new Json.Node(Json.NodeType.ARRAY); node.set_array(ar); + this.log(LanguageClientAction.CHANGE, file.path); try { this.jsonrpc_client.send_notification ( "textDocument/didChange", @@ -250,7 +432,9 @@ namespace Palete { null ); } catch( GLib.Error e) { - GLib.debug ("LS sent close err %s", e.message); + this.log(LanguageClientAction.ERROR_RPC, e.message); + GLib.debug ("LS change err %s", e.message); + this.onClose(); } @@ -258,22 +442,25 @@ namespace Palete { public void exit () throws GLib.Error { if (!this.isReady()) { + return; } - this.sent_shutdown = true; + this.log(LanguageClientAction.TERM, "SEND exit"); - this.jsonrpc_client.send_notification_async ( + this.jsonrpc_client.send_notification ( "exit", null, null ); - - } + this.onClose(); + + } public async void shutdown () throws GLib.Error { if (!this.isReady()) { return; } + this.log(LanguageClientAction.TERM, "SEND shutodwn"); this.sent_shutdown = true; Variant? return_value; yield this.jsonrpc_client.call_async ( @@ -297,14 +484,22 @@ namespace Palete { /* partial_result_token , work_done_token context = null) */ GLib.debug("get completion %s @ %d:%d", file.relpath, line, offset); - ret = null; + ret = new Lsp.CompletionList(); + if (!this.isReady()) { + GLib.debug("completion - language server not ready"); return; } + // make sure completion has the latest info.. + //if (this.change_queue_file != null && this.change_queue_file.path != file.path) { + // this.document_change_real(this.change_queue_file, this.change_queue_file_source); + // this.change_queue_file != null; + //} + this.log(LanguageClientAction.COMPLETE, "SEND complete %s @ %d:%d".printf(file.relpath, line, offset) ); + Variant? return_value; - yield this.jsonrpc_client.call_async ( - "textDocument/completion", - this.buildDict ( + + var args = this.buildDict ( context : this.buildDict ( ///CompletionContext; triggerKind: new GLib.Variant.int32 (triggerType) // triggerCharacter : new GLib.Variant.string ("") @@ -314,10 +509,16 @@ namespace Palete { version : new GLib.Variant.uint64 ( (uint64) file.version) ), position : this.buildDict ( - line : new GLib.Variant.uint64 ( (uint64) line) , - character : new GLib.Variant.uint64 ( (uint64) offset) + line : new GLib.Variant.uint64 ( (uint) line) , + character : new GLib.Variant.uint64 ( uint.max(0, (offset -1))) ) - ), + ); + + GLib.debug ("textDocument/completion send with %s", Json.to_string (Json.gvariant_serialize (args), true)); + + yield this.jsonrpc_client.call_async ( + "textDocument/completion", + args, null, out return_value ); @@ -325,26 +526,76 @@ namespace Palete { //GLib.debug ("LS replied with %s", Json.to_string (Json.gvariant_serialize (return_value), true)); var json = Json.gvariant_serialize (return_value); - var ar = json.get_array(); - if (ar == null) { + + if (json.get_node_type() == Json.NodeType.OBJECT) { ret = Json.gobject_deserialize (typeof (Lsp.CompletionList), json) as Lsp.CompletionList; + this.log(LanguageClientAction.COMPLETE_REPLY, "GOT complete %d items".printf(ret.items.size) ); + GLib.debug ("LS replied with Object"); return; } - ret = new Lsp.CompletionList(); + + if (json.get_node_type() != Json.NodeType.ARRAY) { + GLib.debug ("LS replied with %s", Json.to_string (Json.gvariant_serialize (return_value), true)); + this.log(LanguageClientAction.ERROR_REPLY, "GOT something else??"); + return; + + } + var ar = json.get_array(); + for(var i = 0; i < ar.get_length(); i++ ) { var add= Json.gobject_deserialize ( typeof (Lsp.CompletionItem), ar.get_element(i)) as Lsp.CompletionItem; ret.items.add( add); } - - + this.log(LanguageClientAction.COMPLETE_REPLY, "GOT array %d items".printf(ret.items.size) ); + GLib.debug ("LS replied with Array"); + } //CompletionListInfo.itmems.parse_varient or CompletionListInfo.parsevarient + public async Gee.ArrayList syntax (JsRender.JsRender file) throws GLib.Error + { + /* partial_result_token , work_done_token context = null) */ + GLib.debug("get syntax %s", file.relpath); + var ret = new Gee.ArrayList(); + //ret = null; + if (!this.isReady()) { + return ret; + } + Variant? return_value; + yield this.jsonrpc_client.call_async ( + "textDocument/documentSymbol", + this.buildDict ( + + textDocument : this.buildDict ( ///TextDocumentItem; + uri: new GLib.Variant.string (file.to_url()), + version : new GLib.Variant.uint64 ( (uint64) file.version) + ) + + ), + null, + out return_value + ); + + + GLib.debug ("LS replied with %s", Json.to_string (Json.gvariant_serialize (return_value), true)); + var json = Json.gvariant_serialize (return_value); + + + var ar = json.get_array(); + for(var i = 0; i < ar.get_length(); i++ ) { + var add= Json.gobject_deserialize ( typeof (Lsp.DocumentSymbol), ar.get_element(i)) as Lsp.DocumentSymbol; + ret.add( add); + + } + return ret ; + + + } } } diff --git a/src/Palete/LanguageClientDummy.vala b/src/Palete/LanguageClientDummy.vala index f540d4f3f..b829fc2bb 100644 --- a/src/Palete/LanguageClientDummy.vala +++ b/src/Palete/LanguageClientDummy.vala @@ -13,6 +13,9 @@ namespace Palete { public override void initialize_server() { GLib.debug("initialize dummy server"); } + public override void startServer() + { + } } diff --git a/src/Palete/LanguageClientVala.vala b/src/Palete/LanguageClientVala.vala index 5a9327f06..4860da293 100644 --- a/src/Palete/LanguageClientVala.vala +++ b/src/Palete/LanguageClientVala.vala @@ -8,10 +8,16 @@ namespace Palete { // extend versions will proably call initialize to start and connect to server. base(project); - this.initProcess("/usr/bin/vala-language-server"); + this.startServer(); } + public override void startServer() + { + this.initProcess("/usr/bin/vala-language-server"); + + } + public override void initialize_server() { try { Variant? return_value; @@ -27,8 +33,10 @@ namespace Palete { ); GLib.debug ("LS replied with %s", Json.to_string (Json.gvariant_serialize (return_value), true)); this.initialized = true; + return; } catch (GLib.Error e) { GLib.debug ("LS replied with error %s", e.message); + this.onClose(); } } diff --git a/src/Palete/ValaCompileRequest.vala b/src/Palete/ValaCompileRequest.vala index 19beca5a3..798bf04c0 100644 --- a/src/Palete/ValaCompileRequest.vala +++ b/src/Palete/ValaCompileRequest.vala @@ -165,7 +165,9 @@ namespace Palete { } public void cancel() { - Posix.kill(this.compiler.pid, 9); + if (this.compiler != null && this.compiler.pid > 0) { + Posix.kill(this.compiler.pid, 9); + } this.compiler = null; this.deleteTemp(); } @@ -196,10 +198,16 @@ namespace Palete { this.compiler.isZombie(); GLib.debug("compile got %s", output); if (output == "") { - BuilderApplication.showSpinner(false); + BuilderApplication.showSpinner("face-sad", "compile failed - no error message?"); return; } - + if (this.requestType == ValaCompileRequestType.RUN) { + BuilderApplication.showSpinner(""); + this.execResult(); + return; + } + + // below is not used anymore - as we dont use this try { //GLib.debug("GOT output %s", output); @@ -208,12 +216,12 @@ namespace Palete { var node = pa.get_root(); if (node.get_node_type () != Json.NodeType.OBJECT) { - BuilderApplication.showSpinner(false); + BuilderApplication.showSpinner(""); return; } var ret = node.get_object (); //CompileError.parseCompileResults(this,ret); - BuilderApplication.showSpinner(false); + BuilderApplication.showSpinner(""); @@ -221,13 +229,10 @@ namespace Palete { } catch (GLib.Error e) { GLib.debug("parsing output got error %s", e.message); - BuilderApplication.showSpinner(false); + BuilderApplication.showSpinner(""); return; } - if (this.requestType == ValaCompileRequestType.RUN) { - this.execResult(); - } } public void onOutput(string line) @@ -269,10 +274,9 @@ namespace Palete { var contents = this.alt_code == "" ? this.file.toSourceCode() : this.generateTempContents(); Javascript.singleton().validate(contents, this.file ); - - - BuilderApplication.showSpinner(false); + + BuilderApplication.showSpinner(""); BuilderApplication.updateCompileResults(); //this.queue.onCompileComplete(this); @@ -289,7 +293,7 @@ namespace Palete { var cn = "/proc/%d/task/%d/children".printf(pid,pid); if (!FileUtils.test(cn, GLib.FileTest.EXISTS)) { GLib.debug("%s doesnt exist - killing %d", cn, pid); - Posix.kill(pid, 9); + Posix.kill(pid, 9); return; } string cpids = ""; @@ -305,10 +309,10 @@ namespace Palete { // skip } GLib.debug("killing %d", pid); - Posix.kill(pid, 9); + //Posix.kill(pid, 9); } - int terminal_pid = 0; + public int terminal_pid = 0; public void execResult() { @@ -319,22 +323,22 @@ namespace Palete { var pr = (Project.Gtk) this.file.project; var cg = pr.compilegroups.get(exe); - if (!GLib.FileUtils.test(exe, GLib.FileTest.EXISTS)) { - print("Missing output file: %s\n",exe); + var exbin = pr.path + "/build/" + exe; + if (!GLib.FileUtils.test(exbin, GLib.FileTest.EXISTS)) { + GLib.debug("Missing output file: %s\n",exbin); return; } - var gdb_cfg= pr.path + "/build/.gdb-script"; + var gdb_cfg = pr.path + "/build/.gdb-script"; if (!GLib.FileUtils.test(gdb_cfg, GLib.FileTest.EXISTS)) { pr.writeFile("build/.gdb-script", "set debuginfod enabled off\nr"); } - - + string[] args = "/usr/bin/gnome-terminal --disable-factory --wait -- /usr/bin/gdb -x".split(" "); args+= gdb_cfg; - args += exe; + args += exbin; if (cg.execute_args.length > 0) { args+= "--args"; var aa = cg.execute_args.split(" "); diff --git a/src/Palete/ValaSource.vala b/src/Palete/ValaSource.vala index 92f9ac654..778cc5b97 100644 --- a/src/Palete/ValaSource.vala +++ b/src/Palete/ValaSource.vala @@ -10,6 +10,8 @@ * x = new ValaSource(); * x.connect.compiled(... do something with results... ); * + + THIS IS NOT USED ?? - replaced with valacompilerequest * */ @@ -168,12 +170,12 @@ namespace Palete { return false; } this.compiler.complete.connect(spawnResult); - this.spinner(true); + BuilderApplication.showSpinner("spinner", "compiling file"); try { this.compiler.run(); } catch (GLib.Error e) { GLib.debug("Error %s",e.message); - this.spinner(false); + BuilderApplication.showSpinner("face-sad", "compile failed %s".printf(e.message)); this.compiler = null; this.deleteTemp(); return false; @@ -183,16 +185,7 @@ namespace Palete { } - public void spinner(bool state) - { - foreach (var win in BuilderApplication.windows) { - if (state) { - win.statusbar_compile_spinner.start(); - } else { - win.statusbar_compile_spinner.stop(); - } - } - } + public bool checkFileSpawn(JsRender.JsRender file ) diff --git a/src/Project/Gtk.vala b/src/Project/Gtk.vala index a502648f5..1c0a8f629 100644 --- a/src/Project/Gtk.vala +++ b/src/Project/Gtk.vala @@ -150,6 +150,10 @@ namespace Project public override void onSave() { this.meson.save(); + var vl = this.language_servers.get("vala"); + if (vl != null) { + vl.initialize_server(); // hopefully better than exit? + } } /** @@ -217,7 +221,12 @@ namespace Project } switch( lang ) { case "vala": - this.language_servers.set(lang, new Palete.LanguageClientVala(this)); + var ls = new Palete.LanguageClientVala(this); + ls.log.connect((act, msg) => { + //GLib.debug("log %s: %s", act.to_string(), msg); + BuilderApplication.showSpinnerLspLog(act,msg); + }); + this.language_servers.set(lang, ls); break; default : return this.language_servers.get("dummy"); @@ -272,7 +281,7 @@ namespace Project this.makeMain(); this.makeApplication(); this.makeWindow(); - + this.makeGitIgnore(); var cg = new GtkValaSettings(this, this.name); this.compilegroups.set(this.name, cg); @@ -388,8 +397,12 @@ namespace Project } """); } - - + void makeGitIgnore() + { + this.writeFile(".gitignore", """ +build/ +"""); + } public override void initDatabase() diff --git a/src/Project/GtkValaSettings.vala b/src/Project/GtkValaSettings.vala index c0020e650..0b92cce8f 100644 --- a/src/Project/GtkValaSettings.vala +++ b/src/Project/GtkValaSettings.vala @@ -36,8 +36,8 @@ namespace Project this.execute_args = ""; } // sources and packages. - this.sources = this.project.readArray(el.get_array_member("sources")) ; - + this.sources = this.filterFiles(this.project.readArray(el.get_array_member("sources"))); + } @@ -51,7 +51,7 @@ namespace Project ret.set_string_member("name", this.name); ret.set_string_member("execute_args", this.execute_args); - ret.set_array_member("sources", this.writeArray(this.sources)); + ret.set_array_member("sources", this.writeArray( this.filterFiles(this.sources))); return ret; @@ -82,5 +82,17 @@ namespace Project } + public Gee.ArrayList filterFiles( Gee.ArrayList ar) + { + var ret = new Gee.ArrayList(); + foreach(var f in ar) { + if (null == this.project.getByRelPath(f)) { + continue; + } + ret.add(f); + } + return ret; + } + } } \ No newline at end of file diff --git a/src/Project/Project.vala b/src/Project/Project.vala index d10c23af4..5741178df 100644 --- a/src/Project/Project.vala +++ b/src/Project/Project.vala @@ -858,6 +858,8 @@ namespace Project { file.remove(); + this.save(); + // remove it from @@ -993,15 +995,16 @@ namespace Project { return ret; } - public void updateErrorsforFile(JsRender.JsRender f) + public void updateErrorsforFile(JsRender.JsRender? f) { - var n = this.updateErrorsByType(f, "WARN"); - n += this.updateErrorsByType(f, "ERR"); - n += this.updateErrorsByType(f, "DEPR"); - - if (n > 0) { - BuilderApplication.updateCompileResults(); + if (f != null) { + var n = this.updateErrorsByType(f, "WARN"); + n += this.updateErrorsByType(f, "ERR"); + n += this.updateErrorsByType(f, "DEPR"); } + + BuilderApplication.updateCompileResults(); + } public int updateErrorsByType(JsRender.JsRender f, string n) diff --git a/src/Spawn.vala b/src/Spawn.vala index c80da5cb2..dac287751 100644 --- a/src/Spawn.vala +++ b/src/Spawn.vala @@ -235,7 +235,7 @@ public class Spawn : Object this.ctx = null; } this.tidyup(); - //print("DONE TIDYUP"); + GLib.debug("DONE TIDYUP - calling complete"); this.complete(this.result, this.output, this.stderr); diff --git a/src/codegen/valaccodecompiler.vala b/src/codegen/valaccodecompiler.vala index 2f60d7684..29ac1b43c 100644 --- a/src/codegen/valaccodecompiler.vala +++ b/src/codegen/valaccodecompiler.vala @@ -94,7 +94,7 @@ public class Vala.CCodeCompiler { } if (context.verbose_mode) { - stdout.printf ("%s\n", cmdline); + //stdout.printf ("%s\n", cmdline); } int exit_status = 0; -- 2.39.2