+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-About=new XObject({
- show_all : () {
- this.el.show_all();
- },
- copyright : "LGPL",
- xtype : "AboutDialog",
- program_name : "app.Builder.js",
- modal : TRUE,
- authors : { "Alan Knowles" },
- xns : Gtk,
- website : "http://www.akbkhome.com/blog.php",
- license : "LGPL",
- listeners : {
- delete_event : (self, event) => {
- this.el.hide();
- return true;
-
- },
- response : (rid) => {
- this.el.hide();
- }
- }
-});
-About.init();
-XObject.cache['/About'] = About;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-ClutterFiles=new XObject({
- fileitems : "",
- id : "ClutterFiles",
- clearFiles : () {
-
- this.filelayout.el.remove_all_children();
- // we need to unref all the chidren that we loaded though...
-
- },
- scroll_mode : "Clutter.ScrollMode.VERTICALLY",
- xtype : "ScrollActor",
- reactive : TRUE,
- loadProject : (Project.Project pr) {
- // list all the files, and create new Xcls_fileitem for each one.
-
- // LEAK --- we should unref all the chilren...
- this.filelayout.el.y = 0;
- this.clearFiles();
-
- print("clutter files - load project: " + pr.name +"\n");
- // should unref.. them hopefully.
- this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
-
-
-
- var fiter = pr.sortedFiles().list_iterator();
- while (fiter.next()) {
- var a = new Xcls_fileitem(this,fiter.get());
- this.fileitems.add(a);
-
- // a.ref();
- print("add to clutter file view: " + fiter.get().name + "\n");
- this.filelayout.el.add_child(a.el);
- }
-
-
-
- this.el.show_all();
- },
- open : "(JsRender.JsRender file)",
- xns : Clutter,
- set_size : (float w, float h)
- {
- if (this.el == null) {
- print("object not ready yet?");
- return;
- }
- _this.filelayout_manager.el.max_column_width = w - 150;
- this.el.set_size(this.el.get_stage().width-150,
- this.el.get_stage().height);
- this.el.set_position(100,50);
- },
- listeners : {
- scroll_event : ( event) => {
- //Sprint("scroll event");
- var y = this.filelayout.el.y;
- var dir = event.direction;
- switch (dir) {
- case Clutter.ScrollDirection.UP:
- y += event.y /2;
- break;
- case Clutter.ScrollDirection.DOWN:
- y -= event.y /2 ;
- break;
- default:
- return false;
- }
- // range of scroll -- can go up -- eg.. -ve value.
-
- y = float.min(0, y);
-
- // to work out the max -ve number
- // height of filelayout
- // height of scrollactor..
-
- var last_child_bottom = this.filelayout.el.last_child.y + this.filelayout.el.last_child.height;
- if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
- return false;
- }
-
-
-
-
- // print("\nlast child - this height = %f ==== new y %f\n ".printf(
- // last_child_bottom - this.el.height,
- // y));
- // y = float.min(0, y); //??
- // print("scroll event of %f - new y = %f ".printf(event.y, y));
- this.filelayout.el.y = y;
- return true;
-
- }
- },
- items : [
- {
- layout_manager : {
- id : "filelayout_manager",
- orientation : Clutter.FlowOrientation.HORIZONTAL,
- xtype : "FlowLayout",
- xns : Clutter,
- row_spacing : 20,
- column_spacing : 20,
- homogeneous : TRUE
- },
- id : "filelayout",
- xtype : "Actor",
- reactive : TRUE,
- xns : Clutter,
- items : [
- {
- layout_manager : {
- orientation : Clutter.Orientation.VERTICAL,
- spacing : 4,
- xtype : "BoxLayout",
- xns : Clutter
- },
- id : "*fileitem",
- xtype : "Actor",
- file : "",
- reactive : TRUE,
- xns : Clutter,
- listeners : {
- button_press_event : ( event) => {
- _this.open(this.file);
- return false;
- },
- enter_event : ( event) => {
- this.el.background_color = new Clutter.Color.from_string("#333");
- return false;
- },
- leave_event : ( event) => {
- this.el.background_color = new Clutter.Color.from_string("#000");
- return false;
- }
- },
- items : [
- {
- margin_top : 5,
- margin_right : 5,
- id : "+image",
- x_expand : TRUE,
- xtype : "Texture",
- y_align : Clutter.ActorAlign.START,
- margin_left : 5,
- xns : Clutter,
- y_expand : FALSE,
- x_align : Clutter.ActorAlign.START
- },
- {
- id : "+typetitle",
- x_expand : TRUE,
- xtype : "Text",
- y_align : Clutter.ActorAlign.START,
- xns : Clutter,
- y_expand : FALSE,
- x_align : Clutter.ActorAlign.START
- },
- {
- id : "+title",
- x_expand : TRUE,
- xtype : "Text",
- y_align : Clutter.ActorAlign.START,
- xns : Clutter,
- y_expand : FALSE,
- x_align : Clutter.ActorAlign.START
- }
- ]
-
- }
- ]
-
- }
- ]
-
-});
-ClutterFiles.init();
-XObject.cache['/ClutterFiles'] = ClutterFiles;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-DialogConfirm=new XObject({
- message_type : Gtk.MessageType.QUESTION,
- text : "Tests",
- title : "Please Confirm d",
- xtype : "MessageDialog",
- modal : TRUE,
- show : (string title, string msg) {
- //if (!this.el) { this.init(); }
- //this.success = success;
- this.el.title = title;
- this.el.text = msg;
- this.el.show_all();
- var ret = this.el.run();
- //print("ret got %d", ret);
- this.el.hide();
- return ret;
-
-
- },
- buttons : Gtk.ButtonsType.YES_NO,
- xns : Gtk,
- flags : "Gtk.DialogFlags.MODAL",
- use_markup : TRUE,
- name : "DialogConfirm",
- listeners : {
- delete_event : (event) => {
- this.el.response(Gtk.ResponseType.CANCEL);
- this.el.hide();
- return true;
-
- }
- }
-});
-DialogConfirm.init();
-XObject.cache['/DialogConfirm'] = DialogConfirm;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-DialogNewComponent=new XObject({
- updateFileFromEntry : () {
-
- _this.file.title = _this.title.el.get_text();
- _this.file.region = _this.region.el.get_text();
- _this.file.parent = _this.parent.el.get_text();
- _this.file.permname = _this.permname.el.get_text();
- _this.file.modOrder = _this.modOrder.el.get_text();
- },
- success : "(Project.Project pr, JsRender.JsRender file)",
- id : "DialogNewComponent",
- default_width : 500,
- deletable : TRUE,
- project : "",
- title : "New Component",
- xtype : "Dialog",
- show : (JsRender.JsRender c)
- {
- this.project = c.project;
-
- //if (!this.el) {
- //this.init();
- //}
-
- _this.name.el.set_text(c.name);
- _this.title.el.set_text(c.title);
- _this.parent.el.set_text(c.parent);
- _this.region.el.set_text(c.region);
- _this.modOrder.el.set_text(c.modOrder);
- _this.permname.el.set_text(c.permname);
-
- if (c.path.length > 0) {
- this.el.set_title("Edit File Details - " + c.name);
- } else {
- this.el.set_title("Create New File");
- }
-
- _this.file = c;
- //console.log('show all');
- this.el.show_all();
-
- //this.success = c.success;
-
-
- },
- file : "null",
- default_height : 200,
- modal : TRUE,
- xns : Gtk,
- listeners : {
- delete_event : (self, event) => {
- this.el.hide();
- return true;
- //test
- },
- response : (self, response_id) => {
-
- if (response_id < 1) { // cancel!
- this.el.hide();
- return;
- }
-
- if (_this.name.el.get_text().length < 1) {
- StandardErrorDialog.show(
- this.el,
- "You have to set Component name "
- );
-
- return;
- }
- // what does this do?
-
- var isNew = _this.file.name.length > 0 ? false : true;
-
- if (!isNew && this.file.name != _this.name.el.get_text()) {
- Xcls_StandardErrorDialog.singleton().show(
- this.el,
- "Sorry changing names does not work yet. "
- );
-
- return;
- }
-
-
-
-
- // FIXME - this may be more complicated...
- //for (var i in this.def) {
- // this.file[i] = this.get(i).el.get_text();
- //}
-
- if (!isNew) {
- this.updateFileFromEntry();
-
-
- _this.file.save();
- this.el.hide();
- return;
- }
- var fn = this.name.el.get_text();
- var dir = _this.project.firstPath();
-
- if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
- Xcls_StandardErrorDialog.singleton().show(
- this.el,
- "That file already exists"
- );
- return;
- }
-
- var f = JsRender.JsRender.factory(
- _this.file.project.xtype,
- _this.file.project,
- dir + "/" + fn + ".bjs");
-
- _this.file = f;
-
-
-
- this.updateFileFromEntry();
- _this.file.save();
- _this.file.project.addFile(_this.file);
-
-
- // what about .js ?
-
- this.el.hide();
-
-
- //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());
-
- //var nf = _this.project.create(dir + "/" + _this.file.name + ".bjs");
- //for (var i in this.file) {
- // nf[i] = this.file[i];
- //}
- _this.success(_this.project, _this.file);
- /*
-
- -- fixme -- needs to be a signal..
- if (DialogNewComponent.success != null) {
- DialogNewComponent.success(_this.project, nf);
- }
- */
- },
- show : (self) => {
- this.el.show_all();
- //test
- }
- },
- items : [
- {
- xtype : "VBox",
- pack : get_content_area().add,
- xns : Gtk,
- items : [
- {
- xtype : "Table",
- n_columns : 2,
- xns : Gtk,
- n_rows : 3,
- homogeneous : TRUE,
- items : [
- {
- label : "Component Name",
- xalign : 0.900000,
- xtype : "Label",
- justify : Gtk.Justification.RIGHT,
- x_options : 4,
- xns : Gtk
- },
- {
- id : "name",
- visible : TRUE,
- xtype : "Entry",
- xns : Gtk
- },
- {
- label : "Title",
- visible : TRUE,
- xalign : 0.900000,
- xtype : "Label",
- justify : Gtk.Justification.RIGHT,
- x_options : 4,
- xns : Gtk
- },
- {
- id : "title",
- visible : TRUE,
- xtype : "Entry",
- xns : Gtk
- },
- {
- label : "Region",
- tooltip_text : "center, north, south, east, west",
- visible : TRUE,
- xalign : 0.900000,
- xtype : "Label",
- justify : Gtk.Justification.RIGHT,
- x_options : 4,
- xns : Gtk
- },
- {
- id : "region",
- visible : TRUE,
- xtype : "Entry",
- xns : Gtk
- },
- {
- label : "Parent Name",
- visible : TRUE,
- xalign : 0.900000,
- xtype : "Label",
- justify : Gtk.Justification.RIGHT,
- x_options : 4,
- xns : Gtk
- },
- {
- id : "parent",
- visible : TRUE,
- xtype : "Entry",
- xns : Gtk
- },
- {
- label : "Permission Name",
- visible : TRUE,
- xalign : 0.900000,
- xtype : "Label",
- justify : Gtk.Justification.RIGHT,
- x_options : 4,
- xns : Gtk
- },
- {
- id : "permname",
- visible : TRUE,
- xtype : "Entry",
- xns : Gtk
- },
- {
- label : "Order (for tabs)",
- visible : TRUE,
- xalign : 0.900000,
- xtype : "Label",
- justify : Gtk.Justification.RIGHT,
- x_options : 4,
- xns : Gtk
- },
- {
- id : "modOrder",
- visible : TRUE,
- xtype : "Entry",
- xns : Gtk
- }
- ]
-
- }
- ]
-
- },
- {
- label : "Cancel",
- xtype : "Button",
- xns : Gtk
- },
- {
- label : "OK",
- xtype : "Button",
- xns : Gtk
- }
- ]
-
-});
-DialogNewComponent.init();
-XObject.cache['/DialogNewComponent'] = DialogNewComponent;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-DialogSaveModule=new XObject({
- default_width : 400,
- project : "",
- xtype : "Dialog",
- default_height : 200,
- modal : TRUE,
- data : "",
- show : (Gtk.Window parent, Project.Project project, JsRender.Node data) {
-
-
- this.el.set_transient_for(parent);
- this.el.modal = true;
-
- this.data = data;
- this.project = project;
- this.name.el.set_text("");
- this.el.show_all();
- var name = "";
- while (true) {
- var response_id = this.el.run();
- if (response_id < 1) {
- this.el.hide();
- return "";
- }
-
- name = _this.name.el.get_text();
- if (name.length < 1) {
- StandardErrorDialog.singleton().show(
- _this.el,
- "You must give the template a name. "
- );
- continue;
- }
- if (!Regex.match_simple ("^[A-Za-z][A-Za-z0-9.]+$", name) )
- {
- StandardErrorDialog.singleton().show(
- _this.el,
- "Template Name must contain only letters dots"
- );
- continue;
- }
- break;
- }
- var f = project.newFile(name);
- f.tree = _this.data.deepClone();
- f.save();
-
- // now we save it..
- this.el.hide();
-
- return name;
-
-
-
- },
- xns : Gtk,
- listeners : {
- delete_event : (self, event) => {
- this.el.response(Gtk.ResponseType.CANCEL);
- return true;
- }
- },
- items : [
- {
- xtype : "HBox",
- pack : get_content_area().add,
- xns : Gtk,
- items : [
- {
- label : "Name",
- xtype : "Label",
- xns : Gtk
- },
- {
- id : "name",
- xtype : "Entry",
- xns : Gtk
- }
- ]
-
- },
- {
- label : "Cancel",
- xtype : "Button",
- xns : Gtk
- },
- {
- label : "OK",
- xtype : "Button",
- xns : Gtk
- }
- ]
-
-});
-DialogSaveModule.init();
-XObject.cache['/DialogSaveModule'] = DialogSaveModule;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-DialogSaveTemplate=new XObject({
- default_width : 400,
- show : (Gtk.Window parent, Palete.Palete palete, JsRender.Node data) {
-
-
- this.el.set_transient_for(parent);
- this.el.modal = true;
-
- this.name.el.set_text("");
- this.el.show_all();
- var name = "";
- while (true) {
- var response_id = this.el.run();
- if (response_id < 1) {
- this.el.hide();
- return;
- }
-
- name = _this.name.el.get_text();
- if (name.length < 1) {
- StandardErrorDialog.singleton().show(
- _this.el,
- "You must give the template a name. "
- );
- continue;
- }
- if (!Regex.match_simple ("^[A-Za-z][A-Za-z0-9. ]+$", name) )
- {
- StandardErrorDialog.singleton().show(
- _this.el,
- "Template Name must contain only letters dots"
- );
- continue;
- }
- break;
- }
- palete.saveTemplate(name, data);
-
- // now we save it..
- this.el.hide();
-
-
-
-
- },
- xtype : "Dialog",
- default_height : 200,
- palete : "",
- modal : TRUE,
- data : "",
- xns : Gtk,
- listeners : {
- delete_event : (self, event) => {
- this.el.response(Gtk.ResponseType.CANCEL);
- return true;
-
- }
- },
- items : [
- {
- xtype : "HBox",
- pack : get_content_area().add,
- xns : Gtk,
- items : [
- {
- label : "Name",
- xtype : "Label",
- xns : Gtk
- },
- {
- id : "name",
- xtype : "Entry",
- xns : Gtk
- }
- ]
-
- },
- {
- label : "Cancel",
- xtype : "Button",
- xns : Gtk
- },
- {
- label : "OK",
- xtype : "Button",
- xns : Gtk
- }
- ]
-
-});
-DialogSaveTemplate.init();
-XObject.cache['/DialogSaveTemplate'] = DialogSaveTemplate;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-DialogTemplateSelect=new XObject({
- default_width : 400,
- title : "Add an Object",
- xtype : "Dialog",
- default_height : 200,
- modal : true,
- xns : Gtk,
- show : (Palete.Palete pal, JsRender.Node node) {
-
- this.el.show_all();
- var opts = pal.listTemplates(node);
- if (opts.length() < 1) {
- this.el.hide();
- return node;
- }
- this.el.set_attached_to( Xcls_MainWindow.singleton().el);
- this.el.set_transient_for( Xcls_MainWindow.singleton().el);
-
- //opts.unshift({ path: '' , name :'Just add Element' });
- _this.model.loadData(opts);
- _this.combo.el.set_active(0);
-
-
- this.el.run();
- this.el.hide();
- var ix = _this.combo.el.get_active();
- if (ix < 1 ) {
- return node;
- }
- Gtk.TreeIter iter;
- _this.combo.el.get_active_iter (out iter);
- Value vfname;
- this.model.el.get_value (iter, 0, out vfname);
-
- return pal.loadTemplate((string)vfname);
-
- },
- listeners : {
- delete_event : (self, event) =>{
- this.el.hide();
- return true;
- }
- },
- items : [
- {
- xtype : "VBox",
- pack : get_content_area().add,
- xns : Gtk,
- items : [
- {
- xtype : "HBox",
- xns : Gtk,
- items : [
- {
- label : "Select Template : ",
- xtype : "Label",
- xns : Gtk
- },
- {
- id : "combo",
- xtype : "ComboBox",
- xns : Gtk,
- items : [
- {
- id : "cellrenderer",
- xtype : "CellRendererText",
- xns : Gtk
- },
- {
- id : "model",
- xtype : "ListStore",
- columns : typeof(string),typeof(string),
- n_columns : 2,
- xns : Gtk,
- loadData : (GLib.List<string> data) {
- this.el.clear();
- Gtk.TreeIter iter;
- var el = this.el;
-
- el.append(out iter);
-
-
- el.set_value(iter, 0, "");
- el.set_value(iter, 1, "Just add Element");
-
- for (var i = 0; i < data.length();i++) {
-
-
- el.append(out iter);
- var str = data.nth_data(i);
- var fn = Path.get_basename (str);
- fn.replace(".json", "");
-
- el.set_value(iter, 0, str);
- el.set_value(iter, 1, fn);
-
- }
- this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING);
-
- }
- }
- ]
-
- }
- ]
-
- }
- ]
-
- },
- {
- label : "OK",
- xtype : "Button",
- xns : Gtk
- }
- ]
-
-});
-DialogTemplateSelect.init();
-XObject.cache['/DialogTemplateSelect'] = DialogTemplateSelect;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-EditProject=new XObject({
- xtype: Gtk.Dialog,
- listeners : {
- destroy_event : (self, event) => {
- this.el.response(0);
- // this.el.hide();
- return false;
- }
- },
- border_width : 3,
- default_height : 500,
- default_width : 600,
- name : "EditProject",
- title : "Project Properties",
- 'Project.Project?:show' : () {
-
-
- //[ 'xtype' ].forEach(function(k) {
- // _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);
- //});
- // shouild set path..
- _this.model.loadData();
- this.el.show_all();
-
- var err_dialog = StandardErrorDialog.singleton();
-
- var id = -1;
- while (id < 0) {
- id = this.el.run();
- if (id < 1) {
- this.el.hide();
- return null;
- }
-
-
- if (_this.xtype.getValue().length < 1) {
-
- err_dialog.show(_this.el,"You have to set Project type");
- id = -1;
- continue;
- }
- if (_this.dir.el.get_filename().length < 1) {
-
- err_dialog.show(_this.el,"You have to select a folder");
- id = -1;
- continue;
- }
-
- }
-
- this.el.hide();
-
-
-
-
- var fn = _this.dir.el.get_filename();
- print("add %s\n" , fn);
-
- var project = Project.Project.factory(_this.xtype.getValue(), fn);
- project.save();
- Project.projects.set(project.name,project);
-
- //var pr = imports.Builder.Provider.ProjectManager.ProjectManager.update(this.project);
-
- return project;
-
-
- //this.success = c.success;
- },
- deletable : true,
- modal : true,
- items : [
- {
- xtype: Gtk.VBox,
- homogeneous : false,
- pack : get_content_area().add,
- items : [
- {
- xtype: Gtk.HBox,
- homogeneous : false,
- pack : "pack_start,false,true,3",
- items : [
- {
- xtype: Gtk.Label,
- pack : "pack_start,false,true,3",
- label : "Project type :"
- },
- {
- xtype: Gtk.ComboBox,
- id : "xtype",
- pack : "pack_end,true,true,3",
- init : this.el.add_attribute(_this.cellrender.el , "markup", 1 );,
- setValue : (v) {
- var el = this.el;
- el.set_active(-1);
-
- for (var i =0;i < this.data.length; i++ ) {
- if (v == this.data.nth_datA(i)) {
- el.set_active(ix);
- return false;
- }
- }
- },
- 'string:getValue' : () {
- var ix = this.el.get_active();
- if (ix < 0 ) {
- return "";
- }
- switch(ix) {
- case 0:
- return "Roo";
- case 1:
- return "Gtk";
- }
- return "";
- },
- items : [
- {
- xtype: Gtk.CellRendererText,
- id : "cellrender",
- pack : "pack_start,true"
- },
- {
- xtype: Gtk.ListStore,
- columns : typeof(string),typeof(string),
- id : "model",
- n_columns : 2,
- pack : "set_model",
- 'void:loadData' : ( ) {
- this.el.clear();
-
- Gtk.TreeIter iter;
-
- el.append(out iter);
-
- el.set_value(iter, 0, "Roo");
- el.set_value(iter, 1, "Roo Project");
- el.append(out iter);
-
- el.set_value(iter, 0, "Gtk");
- el.set_value(iter, 1, "Gtk Project");
-
-
-
- }
- }
- ]
- }
- ]
- },
- {
- xtype: Gtk.FileChooserWidget,
- create_folders : false,
- id : "dir",
- pack : "pack_end,true,true,5",
- action : Gtk.FileChooserAction.SELECT_FOLDER,
- select_multiple : false
- }
- ]
- },
- {
- xtype: Gtk.Button,
- label : "OK",
- pack : "add_action_widget,1"
- },
- {
- xtype: Gtk.Button,
- pack : "add_action_widget,0",
- label : "Cancel"
- }
- ]
-});
-EditProject.init();
-XObject.cache['/EditProject'] = EditProject;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-Editor=new XObject({
- activeEditor : "\"\"",
- saveContents : () {
-
-
-
-
-
-
-
-
-
- var str = _this.buffer.toString();
-
- if (!_this.buffer.checkSyntax()) {
- print("check syntax failed");
- //this.get('/StandardErrorDialog').show("Fix errors in code and save..");
- return false;
- }
-
- // LeftPanel.model.changed( str , false);
- _this.dirty = false;
- _this.save_button.el.sensitive = false;
-
-
-
-
- // find the text for the node..
- if (ptype == "listener") {
- this.node.listeners.set(key,str);
-
- } else {
- this.node.props.set(key,str);
- }
-
-
-
- // call the signal..
- this.save();
-
- return true;
-
- },
- pos_root_x : "",
- pos_root_y : "",
- ptype : "\"\"",
- key : "\"\"",
- xtype : "VBox",
- show : (JsRender.Node node, string ptype, string key)
- {
- this.ptype = ptype;
- this.key = key;
- this.node = node;
-
- string val = "";
- // find the text for the node..
- if (ptype == "listener") {
- val = node.listeners.get(key);
-
- } else {
- val = node.props.get(key);
- }
- this.view.load(val);
- this.key_edit.el.text = key;
-
- },
- pos : false,
- id : "Editor",
- dirty : false,
- xns : Gtk,
- save : "()",
- homogeneous : FALSE,
- node : "null",
- items : [
- {
- xtype : "HBox",
- xns : Gtk,
- homogeneous : FALSE,
- items : [
- {
- label : "Save",
- id : "save_button",
- xtype : "Button",
- xns : Gtk,
- listeners : {
- clicked : () => {
- _this.saveContents();
- }
- }
- },
- {
- id : "key_edit",
- xtype : "Entry",
- xns : Gtk
- }
- ]
-
- },
- {
- id : "RightEditor",
- xtype : "ScrolledWindow",
- xns : Gtk,
- items : [
- {
- id : "view",
- insert_spaces_instead_of_tabs : TRUE,
- xtype : "View",
- highlight_current_line : true,
- auto_indent : TRUE,
- xns : GtkSource,
- load : (string str) {
-
- // show the help page for the active node..
- //this.get('/Help').show();
-
-
- // this.get('/BottomPane').el.set_current_page(0);
- this.el.get_buffer().set_text(str, str.length);
- var lm = Gtk.SourceLanguageManager.get_default();
-
- ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lm.get_language("js"));
- var buf = this.el.get_buffer();
-
- /* -- what does all this do? */
- /*
- var cursor = buf.get_mark("insert");
- Gtk.TextIter iter;
- buf.get_iter_at_mark(out iter, cursor);
- iter.set_line(1);
- iter.set_line_offset(4);
- buf.move_mark(cursor, iter);
-
-
- cursor = buf.get_mark("selection_bound");
- //iter= new Gtk.TextIter;
- buf.get_iter_at_mark(out iter, cursor);
- iter.set_line(1);
- iter.set_line_offset(4);
- buf.move_mark(cursor, iter);
-
- */
-
- _this.dirty = false;
- this.el.grab_focus();
- _this.save_button.el.sensitive = false;
- },
- indent_width : 4,
- show_line_numbers : TRUE,
- listeners : {
- key_release_event : (event) => {
-
- if (event.keyval == 115 && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
- print("SAVE: ctrl-S pressed");
- _this.saveContents();
- return false;
- }
- // print(event.key.keyval)
-
- return false;
-
- }
- },
- items : [
- {
- id : "buffer",
- checkSyntax : () {
- /*
- var str = this.toString();
- var res = "";
- /*
- try {
- // print('var res = ' + str);
- Seed.check_syntax('var res = ' + str);
-
-
- } catch (e) {
-
- this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
- red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
- }));
- print("SYNTAX ERROR IN EDITOR");
- print(e);
- // print(str);
- //console.dump(e);
- return false;
- }
- this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
- red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
- }));
- */
- return true;
- },
- 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;
- },
- xtype : "Buffer",
- xns : GtkSource,
- listeners : {
- changed : () => {
- // check syntax??
- if(this.checkSyntax()) {
- _this.save_button.el.sensitive = true;
- }
- // print("EDITOR CHANGED");
- _this.dirty = true;
-
- // this.get('/LeftPanel.model').changed( str , false);
- return ;
- }
- }
- }
- ]
-
- }
- ]
-
- }
- ]
-
-});
-Editor.init();
-XObject.cache['/Editor'] = Editor;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-GladeView=new XObject({
- id : "GladeView",
- createThumb : () {
-
-
- if (this.file == null) {
- return;
- }
- var filename = this.file.getIconFileName(false);
-
- var win = this.el.get_parent_window();
- var width = win.get_width();
- var height = win.get_height();
-
- Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?
-
- screenshot.save(filename,"png");
- return;
-
-
-
-
-
-
-
- // should we hold until it's printed...
-
-
-
-
-
-
-
-
-
- },
- loadFile : (JsRender.JsRender file)
- {
-
-
- this.file = file;
-
-
- // clear existing elements from project?
-
- var p = this.el.get_project();
- var li = p.get_objects().copy();
- // should remove all..
- for (var i =0; i < li.length(); i++) {
- p.remove_object(li.nth_data(i));
- }
-
- if (file.tree == null) {
- return;
- }
-
- // print("%s\n",tf.tree.toJsonString());
- var x = new JsRender.NodeToGlade(file.tree, "");
-
-
- FileIOStream iostream;
- var f = File.new_tmp ("tpl-XXXXXX.glade", out iostream);
- var ostream = iostream.output_stream;
- var dostream = new DataOutputStream (ostream);
- dostream.put_string (x.munge());
- this.el.show();
- print("LOADING %s\n",f.get_path ());
- p.load_from_file(f.get_path ());
-
-
-
- },
- xtype : "DesignView",
- file : "null",
- xns : Glade
-});
-GladeView.init();
-XObject.cache['/GladeView'] = GladeView;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-
-
-atoms = {
- "STRING" : Gdk.atom_intern("STRING")
- };
-targetList = new Gtk.TargetList();
-targetList.add( atoms["STRING"], 0, 0);
-
-
-
-Gtk.rc_parse_string(
- "style \"gtkcombobox-style\" {\n" +
- " GtkComboBox::appears-as-list = 1\n" +
- "}\n"+
- "class \"GtkComboBox\" style \"gtkcombobox-style\"\n");
-
-
-//imports.Window.Window.el.show_all();
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-GtkView=new XObject({
- id : "GtkView",
- lastObj : "null",
- loadFile : (JsRender.JsRender file)
- {
-
-
- this.file = null;
-
- if (file.tree == null) {
- return;
- }
- this.file = file;
- if (this.lastObj != null) {
- this.container.el.remove(this.lastObj);
- }
-
- var x = new JsRender.NodeToGtk(file.tree);
- var obj = x.munge() as Gtk.Widget;
- this.lastObj = null;
- if (obj == null) {
- return;
- }
- this.lastObj = obj;
-
- this.container.el.add(obj);
- obj.show_all();
- },
- createThumb : () {
-
-
- if (this.file == null) {
- return;
- }
- var filename = this.file.getIconFileName(false);
-
- var win = this.el.get_parent_window();
- var width = win.get_width();
- var height = win.get_height();
-
- Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?
-
- screenshot.save(filename,"png");
- return;
-
-
-
-
-
-
-
- // should we hold until it's printed...
-
-
-
-
-
-
-
-
-
- },
- xtype : "Viewport",
- file : "null",
- xns : Gtk,
- items : [
- {
- id : "container",
- xtype : "HBox",
- xns : Gtk
- }
- ]
-
-});
-GtkView.init();
-XObject.cache['/GtkView'] = GtkView;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-
-Window = imports.Builder4.Window.Window;
-
-JSON.xstringify = function (o) {
- var seen = [];
- return JSON.stringify(o, function(_, value) {
- if (typeof value === 'object' && value !== null) {
- if (seen.indexOf(value) !== -1) return null;
- else seen.push(value);
- }
- return value;
- }, 4);
-}
-
-/*
-atoms = {
- "STRING" : Gdk.atom_intern("STRING")
- };
-targetList = new Gtk.TargetList();
-targetList.add( atoms["STRING"], 0, 0);
-
-
-
-Gtk.rc_parse_string(
- "style \"gtkcombobox-style\" {\n" +
- " GtkComboBox::appears-as-list = 1\n" +
- "}\n"+
- "class \"GtkComboBox\" style \"gtkcombobox-style\"\n");
-
-*/
-Window.el.show_all();
-
-
-// this ties two elements together...
-// it used to hapen in the init() code for the element, it should be moved to a 'global init for a whole module'
-var pm = imports.ProjectManager.ProjectManager;
-
-var combomodel = Window.get('/LeftProjectTree.combomodel');
-pm.on('changed', function() {
- print("caught changed hook on project manager - reloading data");
- combomodel.loadData(pm.projects);
-
-});
-
\ No newline at end of file
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-MainWindow=new XObject({
- hideAddListener : () {
- _this.backbutton.el.hide();
- _this.projectbutton.el.show();
- _this.projecteditbutton.el.show();
- _this.editfilebutton.el.show();
- _this.addpropsview.el.save_easing_state();
- var el = _this.rooview.el;
- el.save_easing_state();
-
-
- el.set_scale(1.0f,1.0f);
- _this.addpropsview.el.set_scale(0.0f,0.0f);
- _this.state = "edit";
-
-
- //_this.clutterfiles.loadProject(_this.project);
-
- el.restore_easing_state();
- _this.addpropsview.el.restore_easing_state();
- },
- initChildren : () {
- // this needs putting in a better place..
-
- print("init children");
- this.left_tree = new Xcls_WindowLeftTree();
- this.left_tree.ref();
- this.left_tree.main_window = _this;
- this.tree.el.pack_start(this.left_tree.el,true, true,0);
- this.left_tree.el.show_all();
-
- this.left_tree.before_node_change.connect(() => {
- if (this.state != "codeedit") {
- this.left_props.finish_editing();
- return true;
- }
- if (!this.code_editor.saveContents()) {
- return false;
- }
- return false;
-
- });
-
- this.left_tree.node_selected.connect((sel) => {
-
- print("node_selected called %s\n", (sel == null) ? "NULL" : "a value");
-
- if (sel == null) {
- this.left_props.el.hide();
- }
- this.left_props.el.show();
- this.left_props.load(this.left_tree.getActiveFile(), sel);
- switch (this.state) {
- case "object":
-
- if (sel == null) {
- this.rightpalete.clear();
- break;
- }
- this.rightpalete.load(_this.left_tree.getActiveFile().palete(), sel.fqn());
- break;
-
-
- case "addprop":
- if (sel == null) {
- this.add_props.clear();
- break;
- }
- this.add_props.show(_this.left_tree.getActiveFile().palete(), "props", sel.fqn());
- break;
-
- case "addlistener":
- if (sel == null) {
- this.add_props.clear();
- break;
- }
- this.add_props.show(_this.left_tree.getActiveFile().palete(), "signals", sel.fqn());
- break;
-
- case "codeedit":
-
- this.hideCodeEdit();
- break;
-
-
- }
- return ;
-
- });
-
- this.left_tree.changed.connect(() => {
- this.window_rooview.requestRedraw();
- this.left_tree.model.file.save();
- });
-
-
-
- // left properties
-
- this.left_props =new Xcls_LeftProps();
- this.left_props.ref();
- this.left_props.main_window = _this;
- this.props.el.pack_start(this.left_props.el,true, true,0);
- this.left_props.el.show_all();
-
- this.left_props.show_editor.connect( (file, node, type, key) => {
- this.showCodeEdit(node, type, key);
- });
- this.left_props.stop_editor.connect( () => {
- if (this.state != "codeedit") {
- return true;
- }
-
- var ret = this.code_editor.saveContents();
- if (!ret) {
- return false;
- }
- this.hideCodeEdit();
- return ret;
- });
- this.left_props.changed.connect(() => {
- if (this.left_tree.getActiveFile().xtype == "Roo" ) {
- this.window_rooview.requestRedraw();
-
- } else {
- this.window_gladeview.loadFile(this.left_tree.getActiveFile());
- }
- this.left_tree.model.updateSelected();
- this.left_tree.model.file.save();
- });
-
-
-
-
- // left projects..
- this.left_projects = new Xcls_WindowLeftProjects();
- this.left_projects.ref();
- this.leftpane.el.pack_start(this.left_projects.el,true, true,0);
- this.left_projects.el.show_all();
- this.left_projects.project_selected.connect((proj) => {
- proj.scanDirs();
- _this.clutterfiles.loadProject(proj);
-
- });
-
-
- // project edit..
- this.projectsettings =new Xcls_ProjectSettings();
- this.projectsettings.ref(); /// really?
- ((Gtk.Container)(this.projecteditview.el.get_widget())).add(this.projectsettings.el);
- //this.projectsettings.el.show_all();
-
- var stage = _this.projecteditview.el.get_stage();
- stage.set_background_color( Clutter.Color.from_string("#000"));
-
- this.projectsettings.buttonPressed.connect((btn) => {
- if (this.left_tree.getActiveFile().xtype == "Roo" ) {
-
- if (btn == "save") {
- _this.window_rooview.view.renderJS(true);
- }
- if (btn == "apply") {
- _this.window_rooview.view.renderJS(true);
- return;
- }
- } else {
- // do nothing for gtk..
- }
- if (btn == "save" || btn == "apply") {
- _this.project.save();
-
- }
-
- this.hideProjectEdit();
-
- });
-
-
- // objects (palate..)
- this.rightpalete = new Xcls_RightPalete();
- this.rightpalete.ref(); /// really?
- ((Gtk.Container)(this.objectview.el.get_widget())).add(this.rightpalete.el);
- //this.projectsettings.el.show_all();
-
- stage = _this.objectview.el.get_stage();
- stage.set_background_color( Clutter.Color.from_string("#000"));
-
- /*this.projectsettings.buttonPressed.connect((btn) => {
- if (btn == "save") {
- _this.window_rooview.view.renderJS(true);
- }
- if (btn == "apply") {
- _this.window_rooview.view.renderJS(true);
- return;
- }
- this.hideProjectEdit();
-
- });
- */
-
-
-
- // Add properties
- this.add_props = new Xcls_WindowAddProp();
- this.add_props.ref(); /// really?
- ((Gtk.Container)(this.addpropsview.el.get_widget())).add(this.add_props.el);
- //this.projectsettings.el.show_all();
-
- stage = _this.addpropsview.el.get_stage();
- stage.set_background_color( Clutter.Color.from_string("#000"));
-
-
- _this.add_props.select.connect( (key,type,skel, etype) => {
- this.left_props.addProp(etype, key, skel, type);
- });
-
- // editor
-
-
- this.code_editor = new Editor();
- this.code_editor.ref(); /// really?
- ((Gtk.Container)(this.codeeditview.el.get_widget())).add(this.code_editor.el);
- //this.projectsettings.el.show_all();
-
- stage = _this.codeeditview.el.get_stage();
- stage.set_background_color( Clutter.Color.from_string("#000"));
- // editor.save...
-
- _this.code_editor.save.connect( () => {
- this.left_tree.model.file.save();
- this.left_tree.model.updateSelected();
- });
-
-
-
-
- // roo view
-
- this.window_rooview =new Xcls_WindowRooView();
- this.window_rooview.ref();
- ((Gtk.Container)(this.rooview.el.get_widget())).add(this.window_rooview.el);
- this.window_rooview.el.show_all();
-
- stage = _this.rooview.el.get_stage();
- stage.set_background_color( Clutter.Color.from_string("#000"));
-
-
- // glade view
-
- this.window_gladeview =new Xcls_GtkView();
- this.window_gladeview.ref();
-
- //((Gtk.Container)(this.rooview.el.get_widget())).add(this.window_gladeview.el);
- ///this.window_gladeview.el.hide();
-
-
-
- // clutter files
-
-
- this.clutterfiles = new Xcls_ClutterFiles();
- this.clutterfiles.ref();
- stage.add_child(this.clutterfiles.el);
- this.clutterfiles.el.show_all();
-
-
- this.clutterfiles.open.connect((file) => {
- _this.project = file.project;
- _this.showViewEditing();
- this.left_tree.model.loadFile(file);
- var ctr= ((Gtk.Container)(this.rooview.el.get_widget()));
- if (file.xtype == "Roo" ) {
- ctr.foreach( (w) => { ctr.remove(w); });
- ctr.add(this.window_rooview.el);
- this.window_rooview.loadFile(file);
-
- this.window_rooview.el.show_all();
- } else {
- ctr.foreach( (w) => { ctr.remove(w); });
- ctr.add(this.window_gladeview.el);
- this.window_gladeview.loadFile(file);
- this.window_gladeview.el.show_all();
- }
- print("OPEN : " + file.name);
- _this.editpane.el.set_position(_this.editpane.el.max_position);
-
-
- });
-
- // new file dialog
- this.new_file_dialog = new Xcls_DialogNewComponent();
- // force it modal to the main window..
- this.new_file_dialog.el.set_transient_for(this.el);
- this.new_file_dialog.el.set_modal(true);
-
- this.new_file_dialog.success.connect((project,file) =>
- {
- _this.project = project;
- _this.showViewEditing();
- this.left_tree.model.loadFile(file);
- var ctr= ((Gtk.Container)(this.rooview.el.get_widget()));
- if (file.xtype == "Roo" ) {
- ctr.foreach( (w) => { ctr.remove(w); });
- ctr.add(this.window_rooview.el);
- this.window_rooview.loadFile(file);
-
- this.window_rooview.el.show_all();
- } else {
- ctr.foreach( (w) => { ctr.remove(w); });
- ctr.add(this.window_gladeview.el);
- this.window_gladeview.loadFile(file);
- this.window_gladeview.el.show_all();
- }
-
- });
-
-
-
- //w.el.show_all();
- var tl = new Clutter.Timeline(6000);
- tl.set_repeat_count(-1);
- tl.start();
- tl.ref();
-
- this.children_loaded = true;
-
-
-
-
- },
- project : "null",
- children_loaded : false,
- hideCodeEdit : () {
- //this.code_editor.saveContents();
- _this.backbutton.el.hide();
- _this.projectbutton.el.show();
- _this.projecteditbutton.el.show();
- _this.editfilebutton.el.show();
- _this.codeeditview.el.save_easing_state();
- var el = _this.rooview.el;
- el.save_easing_state();
-
-
- el.set_scale(1.0f,1.0f);
- _this.codeeditview.el.set_scale(0.0f,0.0f);
- _this.state = "edit";
-
-
- //_this.clutterfiles.loadProject(_this.project);
-
- el.restore_easing_state();
- _this.codeeditview.el.restore_easing_state();
- },
- showAddProp : () {
-
-
- var ae = this.left_tree.getActiveElement();
- if (ae == null) {
- return;
- }
- _this.backbutton.el.show();
- _this.projectbutton.el.hide();
- _this.editfilebutton.el.hide();
- _this.projecteditbutton.el.hide();
-
-
-
- //this.rooview.el.hide();
- this.add_props.el.show_all();
- this.add_props.show(
- Palete.factory(this.project.xtype),
- "props",
- ae.fqn()
- );
-
- _this.addpropsview.el.save_easing_state();
-
- var el = _this.rooview.el;
- el.save_easing_state();
- _this.clutterembed.setSizesAlloc("addprop");
-
-
-
- _this.addpropsview.el.set_scale(1.0f,1.0f);
-
-
-
- //_this.clutterfiles.loadProject(_this.project);
-
- el.restore_easing_state();
- _this.addpropsview.el.restore_easing_state();
- this.state = "addprop";
- },
- showViewEditing : ( ) {
- this.editpane.el.show();
- // this.rooview.el.show();
- this.left_projects.el.hide();
-
- _this.addprojectbutton.el.hide();
- _this.delprojectbutton.el.hide();
- _this.addfilebutton.el.hide();
- _this.backbutton.el.hide();
-
- _this.projectbutton.el.show();
- _this.editfilebutton.el.show();
- _this.projecteditbutton.el.show();
- _this.objectshowbutton.el.show();
- _this.addpropbutton.el.show();
- _this.addlistenerbutton.el.show();
-
-
- var el = _this.rooview.el;
- el.save_easing_state();
-
-
- el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 0.0f);
- el.set_scale(1.0f,1.0f);
- _this.state = "edit";
- // _this.mainpane.el.set_position(_this.leftpane.lastWidth);
- _this.clutterfiles.el.hide();
-
- el.restore_easing_state();
-
- print("show view editing");
- },
- border_width : 0,
- hideProjectEdit : () {
- // return to editing state..
-
- _this.projectbutton.el.show();
- _this.projecteditbutton.el.show();
- _this.backbutton.el.hide();
- _this.editfilebutton.el.show();
-
- //this.rooview.el.hide();
- //this.edit_project.el.show();
- _this.projecteditview.el.save_easing_state();
- var el = _this.rooview.el;
- el.save_easing_state();
-
-
- el.set_scale(1.0f,1.0f);
- _this.projecteditview.el.set_scale(1.0f,0.0f);
- _this.state = "edit";
-
-
- //_this.clutterfiles.loadProject(_this.project);
-
- el.restore_easing_state();
- _this.projecteditview.el.restore_easing_state();
-
- },
- default_height : 500,
- left_projects : "null",
- id : "MainWindow",
- showProjectEdit : () {
- // make the browser smaller, and show the edit dialog
-
-
- _this.projectbutton.el.hide();
- _this.projecteditbutton.el.hide();
-
- _this.editfilebutton.el.hide();
-
-
-
-
- _this.backbutton.el.show();
-
- //this.rooview.el.hide();
- this.projectsettings.el.show_all();
- this.projectsettings.show(this.project);
- _this.projecteditview.el.save_easing_state();
-
- var el = _this.rooview.el;
- el.save_easing_state();
-
-
- el.set_scale(0.5f,0.5f);
-
- _this.projecteditview.el.set_scale(1.0f,1.0f);
-
- _this.state = "projectedit";
-
-
- //_this.clutterfiles.loadProject(_this.project);
-
- el.restore_easing_state();
- _this.projecteditview.el.restore_easing_state();
- // print("show view browsing");
-
- },
- showAddListener : () {
-
-
-
- var ae = this.left_tree.getActiveElement();
- if (ae == null) {
- return;
- }
-
- _this.backbutton.el.show();
- _this.projectbutton.el.hide();
- _this.editfilebutton.el.hide();
- _this.projecteditbutton.el.hide();
-
-
- //this.rooview.el.hide();
- this.add_props.el.show_all();
- this.add_props.show(
- Palete.factory(this.project.xtype),
- "signals",
- ae.fqn()
- );
- //this.rightpalete.show(this.project);
-
- _this.addpropsview.el.save_easing_state();
-
- var el = _this.rooview.el;
- el.save_easing_state();
-
- _this.clutterembed.setSizesAlloc("addlistener");
-
-
-
-
- _this.addpropsview.el.set_scale(1.0f,1.0f);
-
-
-
- //_this.clutterfiles.loadProject(_this.project);
-
- el.restore_easing_state();
- _this.addpropsview.el.restore_easing_state();
- this.state = "addlistener";
- },
- window_rooview : "null",
- default_width : 800,
- xtype : "Window",
- type : Gtk.WindowType.TOPLEVEL,
- hideAddProp : () {
- _this.backbutton.el.hide();
- _this.projectbutton.el.show();
- _this.projecteditbutton.el.show();
- _this.editfilebutton.el.show();
- _this.addpropsview.el.save_easing_state();
-
- var el = _this.rooview.el;
- el.save_easing_state();
-
-
- el.set_scale(1.0f,1.0f);
- _this.addpropsview.el.set_scale(0.0f,0.0f);
- _this.state = "edit";
-
-
- //_this.clutterfiles.loadProject(_this.project);
-
- el.restore_easing_state();
- _this.addpropsview.el.restore_easing_state();
- },
- left_tree : "null",
- code_editor : "null",
- showCodeEdit : (JsRender.Node node, string ptype, string key)
- {
- // this is a bit different,
- // it's not called via a button - but triggered by the prop edit class signal.
- // so it has to hide any other state..
-
- switch(this.state) {
- case "object":
- this.hideObject();
- break;
- case "addprop":
- this.hideAddProp();
- break;
- case "addlistener":
- this.hideAddListener();
- break;
- }
-
- _this.backbutton.el.show();
-
- _this.projectbutton.el.hide();
- _this.editfilebutton.el.hide();
- _this.projecteditbutton.el.hide();
- // more??
-
- //this.rooview.el.hide();
- this.code_editor.el.show_all();
- this.code_editor.show(
- node,
- ptype,
- key
- );
-
- _this.codeeditview.el.save_easing_state();
-
- var el = _this.rooview.el;
- el.save_easing_state();
- _this.clutterembed.setSizesAlloc("codedit");
-
- _this.codeeditview.el.set_scale(1.0f,1.0f);
-
-
-
- //_this.clutterfiles.loadProject(_this.project);
-
- el.restore_easing_state();
- _this.codeeditview.el.restore_easing_state();
- this.state = "codeedit";
- },
- new_file_dialog : "null",
- projectsettings : "null",
- setTitle : (string str) {
- this.el.set_title(this.title + " - " + str);
- },
- show : () {
- this.left_tree =new Xcls_WindowLeftTree();
- _this.vbox.el.pack_start(this.left_tree.el,true, true,0);
- this.el.show_all();
-
- },
- xns : Gtk,
- clutterfiles : "null",
- left_props : "null",
- state : "",
- hideViewEditing : ( ) {
-
- // show the file navigation...
-
- if (this.left_tree.getActiveFile() != null) {
- if (this.left_tree.getActiveFile().xtype == "Roo" ) {
- this.window_rooview.createThumb();
- } else {
- this.window_gladeview.createThumb();
- }
- }
-
- _this.addprojectbutton.el.show();
- _this.addfilebutton.el.show();
- _this.backbutton.el.show();
- _this.delprojectbutton.el.show();
-
- _this.editfilebutton.el.hide();
- _this.projectbutton.el.hide();
- _this.projecteditbutton.el.hide();
- _this.objectshowbutton.el.hide();
- _this.addpropbutton.el.hide();
- _this.addlistenerbutton.el.hide();
-
-
-
-
-
- // show the add file button..
-
-
-
- this.editpane.el.hide();
- //this.rooview.el.hide();
- this.left_projects.el.show();
-
- var el = _this.rooview.el;
- el.save_easing_state();
- el.set_easing_duration(1000);
- // show project / file view..
- //_this.mainpane.lastWidth = _this.leftpane.el.get_position();
- //_this.mainpane.el.set_position(0);
- // rotate y 180..
- el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 360.0f);
- el.set_scale(0.0f,0.0f);
-
- _this.state = "files";
- if (_this.project != null) {
- _this.left_projects.selectProject(_this.project);
- }
- //_this.clutterfiles.loadProject(_this.project);
-
- el.restore_easing_state();
-
- print("show view browsing");
- },
- rightpalete : "null",
- title : "\"Application Builder\"",
- add_props : "null",
- showObject : () {
-
-
- // what's the active node on the left hand side..
-
- var n = _this.left_tree.getActiveElement();
-
- if (_this.left_tree.model.file == null) {
- return;
- }
-
- if (n == null && _this.left_tree.model.file.tree != null) {
- return;
- }
-
- _this.backbutton.el.show();
- _this.projectbutton.el.hide();
- _this.editfilebutton.el.hide();
- _this.projecteditbutton.el.hide();
-
-
- //this.rooview.el.hide();
- this.rightpalete.el.show_all();
- this.rightpalete.load(_this.left_tree.getActiveFile().palete(), n == null ? "*top" : n.fqn());
-
-
- //this.rightpalete.show(this.project);
-
- _this.objectview.el.save_easing_state();
-
- var el = _this.rooview.el;
- el.save_easing_state();
-
- _this.clutterembed.setSizesAlloc("object");
-
-
- _this.objectview.el.set_scale(1.0f,1.0f);
-
-
-
- //_this.clutterfiles.loadProject(_this.project);
-
- el.restore_easing_state();
- _this.objectview.el.restore_easing_state();
- this.state = "object";
- },
- hideObject : () {
- // return to editing state..
-
- _this.projecteditbutton.el.show();
- _this.backbutton.el.hide();
- _this.projectbutton.el.show();
- _this.editfilebutton.el.show();
- _this.objectview.el.save_easing_state();
- var el = _this.rooview.el;
- el.save_easing_state();
-
-
- el.set_scale(1.0f,1.0f);
- _this.objectview.el.set_scale(0.0f,0.0f);
- _this.state = "edit";
-
-
- //_this.clutterfiles.loadProject(_this.project);
-
- el.restore_easing_state();
- _this.objectview.el.restore_easing_state();
-
-
- },
- window_gladeview : "null",
- listeners : {
- delete_event : ( event) => {
- return false;
- },
- destroy : () => {
- Gtk.main_quit();
- },
- show : ( ) => {
- // hide the file editing..
-
- //this.hideViewEditing();
- }
- },
- items : [
- {
- id : "vbox",
- xtype : "VBox",
- xns : Gtk,
- homogeneous : FALSE,
- items : [
- {
- id : "mainpane",
- position : 400,
- lastWidth : 0,
- xtype : "HPaned",
- xns : Gtk,
- items : [
- {
- id : "leftpane",
- xtype : "VBox",
- xns : Gtk,
- items : [
- {
- id : "editpane",
- xtype : "VPaned",
- xns : Gtk,
- items : [
- {
- id : "tree",
- xtype : "VBox",
- xns : Gtk
- },
- {
- id : "props",
- xtype : "VBox",
- xns : Gtk
- }
- ]
-
- }
- ]
-
- },
- {
- xtype : "VBox",
- xns : Gtk,
- items : [
- {
- id : "clutterembed",
- xtype : "Embed",
- setSizes : ( Gtk.Allocation alloc, string state) {
- if (!_this.children_loaded) { return; }
-
- _this.clutterfiles.set_size(alloc.width-50, alloc.height);
-
- // project view appears at top...
-
- _this.projecteditview.el.set_size(alloc.width-50, alloc.height / 2.0f);
-
-
-
- var avail = alloc.width < 50.0f ? 0 : alloc.width - 50.0f;
-
-
- var palsize = avail < 300.0f ? avail : 300.0f;
- print("set palsize size %f\n", palsize);
- // palate / props : fixed 300 pix
-
- _this.objectview.el.set_size(palsize, alloc.height);
- _this.addpropsview.el.set_size(palsize, alloc.height);
-
-
-
- // code edit min 600
-
- var codesize = avail < 600.0f ? avail : 600.0f;
- print("set code size %f\n", codesize);
-
- _this.codeeditview.el.set_size(codesize, alloc.height);
- _this.rooview.el.set_size(alloc.width-50, alloc.height);
-
- switch ( state) {
- case "codeedit":
-
- var scale = avail > 0.0f ? (avail - codesize -10 ) / avail : 0.0f;
-
-
- _this.rooview.el.set_scale(scale,scale);
- break;
- case "addprop":
- case "addlistener":
- case "object":
- var scale = avail > 0.0f ? (avail - palsize -10 ) / avail : 0.0f;
- _this.rooview.el.set_scale(scale,scale);
- break;
- }
-
- },
- xns : GtkClutter,
- setSizesAlloc : (string state) {
-
- Gtk.Allocation alloc;
- this.el.get_allocation(out alloc);
- this.setSizes(alloc, state);
- },
- listeners : {
- size_allocate : ( alloc) => {
- this.setSizes(alloc, _this.state);
-
- }
- },
- items : [
- {
- id : "rooview",
- xtype : "Actor",
- xns : GtkClutter
- },
- {
- id : "objectview",
- xtype : "Actor",
- xns : GtkClutter
- },
- {
- id : "codeeditview",
- xtype : "Actor",
- xns : GtkClutter
- },
- {
- id : "addpropsview",
- xtype : "Actor",
- xns : GtkClutter
- },
- {
- id : "projecteditview",
- xtype : "Actor",
- xns : GtkClutter
- },
- {
- layout_manager : {
- orientation : Clutter.Orientation.VERTICAL,
- xtype : "BoxLayout",
- xns : Clutter
- },
- id : "buttonlayout",
- xtype : "Actor",
- xns : Clutter,
- items : [
- {
- id : "backbutton",
- xtype : "Actor",
- xns : Clutter,
- items : [
- {
- xtype : "Actor",
- xns : GtkClutter,
- items : [
- {
- xtype : "Button",
- width_request : 50,
- label : "<<",
- xns : Gtk,
- height_request : 50,
- listeners : {
- clicked : ( ) => {
- switch (_this.state) {
- case "edit":
-
- _this.hideViewEditing();
- break;
- case "files":
- // should only occur if there is an active file..
- _this.showViewEditing();
- break;
-
- case "addprop":
- _this.hideAddProp();
-
- break;
- case "addlistener":
- _this.hideAddListener();
-
- break;
-
- case "object":
- _this.hideObject();
- break;
-
- case "codeedit":
-
- _this.hideCodeEdit();
- break;
-
- case "projectedit":
- // save?
- _this.hideProjectEdit();
- break;
-
- default:
- break;
- }
- return ;
-
- }
- }
- }
- ]
-
- }
- ]
-
- },
- {
- id : "projectbutton",
- xtype : "Actor",
- xns : Clutter,
- items : [
- {
- xtype : "Actor",
- xns : GtkClutter,
- items : [
- {
- xtype : "Button",
- width_request : 50,
- label : "Open\nFiles",
- xns : Gtk,
- height_request : 50,
- listeners : {
- clicked : ( ) => {
- switch (_this.state) {
- case "edit":
-
- _this.hideViewEditing();
- break;
- case "files":
- _this.showViewEditing();
- break;
-
- case "addprop":
- _this.hideAddProp();
- _this.hideViewEditing();
- break;
- case "addlistener":
- _this.hideAddListener();
- _this.hideViewEditing();
- break;
-
- case "object":
- _this.hideObject();
- _this.hideViewEditing();
- break;
-
- default:
- break;
- }
- return ;
-
- }
- }
- }
- ]
-
- }
- ]
-
- },
- {
- id : "editfilebutton",
- xtype : "Actor",
- xns : Clutter,
- items : [
- {
- xtype : "Actor",
- xns : GtkClutter,
- items : [
- {
- xtype : "Button",
- width_request : 50,
- label : "File\nDetails",
- xns : Gtk,
- height_request : 50,
- listeners : {
- clicked : ( ) => {
-
- // create a new file in project..
- if (_this.project == null || _this.left_tree.model.file == null) {
- return ;
- }
-
- _this.new_file_dialog.show(_this.left_tree.model.file);
-
- return ;
-
-
- }
- }
- }
- ]
-
- }
- ]
-
- },
- {
- id : "projecteditbutton",
- xtype : "Actor",
- xns : Clutter,
- items : [
- {
- xtype : "Actor",
- xns : GtkClutter,
- items : [
- {
- xtype : "Button",
- width_request : 50,
- label : "Project\nDetails",
- xns : Gtk,
- height_request : 50,
- listeners : {
- clicked : ( ) => {
- switch (_this.state) {
- case "edit":
- _this.showProjectEdit();
- break;
- case "files":
- // _this.showViewEditing();
- break;
- case "projectedit":
- _this.hideProjectEdit();
- break;
-
-
-
- case "addprop":
- _this.hideAddProp();
- _this.showProjectEdit();
- break;
- case "addlistener":
- _this.hideAddListener();
- _this.showProjectEdit();
- break;
-
- case "object":
- _this.hideObject();
- _this.showProjectEdit();
- break;
- default:
- break;
- }
- return ;
-
-
- }
- }
- }
- ]
-
- }
- ]
-
- },
- {
- id : "objectshowbutton",
- xtype : "Actor",
- xns : Clutter,
- listeners : {
- button_press_event : ( ) => {
-
-
-
- switch (_this.state) {
-
-
- case "addprop":
- _this.hideAddProp();
- _this.showObject();
- break;
- case "addlistener":
- _this.hideAddListener();
- _this.showObject();
- break;
-
- // show
- case "edit":
- _this.showObject();
- break;
-
- // hide
- case "object":
- _this.hideObject();
- break;
- break;
-
- default:
- print("unhandled add objects from %s\n",_this.state);
- break;
- }
- return false;
-
-
- },
- enter_event : ( event) => {
- this.el.background_color = new Clutter.Color.from_string("#333");
- return false;
- },
- leave_event : ( event) => {
- this.el.background_color = new Clutter.Color.from_string("#000");
- return false;
- }
- },
- items : [
- {
- xtype : "Actor",
- xns : GtkClutter,
- items : [
- {
- xtype : "Button",
- width_request : 50,
- label : "Show\nPalete",
- xns : Gtk,
- height_request : 50,
- listeners : {
- clicked : ( ) => {
-
-
-
- switch (_this.state) {
-
-
- case "addprop":
- _this.hideAddProp();
- _this.showObject();
- break;
- case "addlistener":
- _this.hideAddListener();
- _this.showObject();
- break;
-
- // show
- case "edit":
- _this.showObject();
- break;
-
- // hide
- case "object":
- _this.hideObject();
- break;
- break;
-
- default:
- print("unhandled add objects from %s\n",_this.state);
- break;
- }
- return ;
-
-
- }
- }
- }
- ]
-
- }
- ]
-
- },
- {
- id : "addpropbutton",
- xtype : "Actor",
- xns : Clutter,
- items : [
- {
- xtype : "Actor",
- xns : GtkClutter,
- items : [
- {
- xtype : "Button",
- width_request : 50,
- label : "Add\nProp",
- xns : Gtk,
- height_request : 50,
- listeners : {
- clicked : ( ) => {
-
-
-
- switch (_this.state) {
- case "edit":
- _this.showAddProp();
- break;
-
- case "object":
- _this.hideObject();
- _this.showAddProp();
- break;
-
- case "addlistener":
- _this.hideAddListener();
- _this.showAddProp();
- break;
-
-
- case "addprop":
- _this.hideAddProp();
- break;
-
- default:
- print("unhandled add property from %s\n",_this.state);
- break;
-
- }
- return ;
-
-
- }
- }
- }
- ]
-
- }
- ]
-
- },
- {
- id : "addlistenerbutton",
- xtype : "Actor",
- xns : Clutter,
- items : [
- {
- xtype : "Actor",
- xns : GtkClutter,
- items : [
- {
- xtype : "Button",
- width_request : 50,
- label : "Add\nEvent\nCode",
- xns : Gtk,
- height_request : 50,
- listeners : {
- clicked : ( ) => {
-
-
-
- switch (_this.state) {
- case "edit":
- _this.showAddListener();
- break;
-
-
- case "addlistener":
- _this.hideAddListener();
- break;
-
-
- case "addprop":
- _this.hideAddProp();
- _this.showAddListener();
- break;
- case "object":
- _this.hideObject();
- _this.showAddListener();
- break;
-
- default:
- print("unhandled add listener from %s\n",_this.state);
-
- break;
-
- }
- return ;
-
-
- }
- }
- }
- ]
-
- }
- ]
-
- },
- {
- id : "addprojectbutton",
- xtype : "Actor",
- xns : Clutter,
- items : [
- {
- xtype : "Actor",
- xns : GtkClutter,
- items : [
- {
- xtype : "Button",
- width_request : 50,
- label : "New\nProj.",
- xns : Gtk,
- height_request : 50,
- listeners : {
- clicked : ( ) => {
-
- // create a new file in project..
- //Xcls_DialogNewComponent.singleton().show(
- var pe = Xcls_EditProject.singleton();
- pe.el.set_transient_for(_this.el);
- pe.el.set_modal(true);
-
- var p = pe.show();
-
- if (p == null) {
- return;
- }
- _this.left_projects.is_loaded = false;
- _this.left_projects.load();
- _this.left_projects.selectProject(p);
- return ;
-
-
- }
- }
- }
- ]
-
- }
- ]
-
- },
- {
- id : "addfilebutton",
- xtype : "Actor",
- xns : Clutter,
- items : [
- {
- xtype : "Actor",
- xns : GtkClutter,
- items : [
- {
- xtype : "Button",
- width_request : 50,
- label : "Add\nFile",
- xns : Gtk,
- height_request : 50,
- listeners : {
- clicked : () => {
- // create a new file in project..
-
- // what's the currently selected project...
- var proj = _this.left_projects.getSelectedProject();
-
- if (proj == null) {
- return ;
- }
-
-
-
- var f = JsRender.JsRender.factory(proj.xtype, proj, "");
- _this.project = proj;
- _this.new_file_dialog.show(f);
-
- return ;
- }
- }
- }
- ]
-
- }
- ]
-
- },
- {
- id : "delprojectbutton",
- xtype : "Actor",
- xns : Clutter,
- items : [
- {
- xtype : "Actor",
- xns : GtkClutter,
- items : [
- {
- xtype : "Button",
- width_request : 50,
- label : "Del\nProj",
- xns : Gtk,
- height_request : 50,
- listeners : {
- clicked : ( ) => {
-
- var cd = DialogConfirm.singleton();
- cd.el.set_transient_for(_this.el);
- cd.el.set_modal(true);
-
- var project = _this.left_projects.getSelectedProject();
- if (project == null) {
- print("SKIP - no project\n");
- return;
- }
-
-
- if (Gtk.ResponseType.YES != cd.show("Confirm",
- "Are you sure you want to delete project %s".printf(project.name))) {
- return;
- }
-
-
- // confirm?
- Project.Project.remove(project);
- _this.project = null;
-
- _this.left_projects.is_loaded = false;
- _this.left_projects.load();
- _this.clutterfiles.clearFiles();
-
- }
- }
- }
- ]
-
- }
- ]
-
- }
- ]
-
- }
- ]
-
- }
- ]
-
- }
- ]
-
- }
- ]
-
- }
- ]
-
-});
-MainWindow.init();
-XObject.cache['/MainWindow'] = MainWindow;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-ProjectSettings=new XObject({
- buttonPressed : "(string btn)",
- id : "ProjectSettings",
- show : (Project.Project project) {
- _this.project = project;
- _this.path.el.label = project.firstPath();
- // get the active project.
- var lm = Gtk.SourceLanguageManager.get_default();
-
- ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(
-
- lm.get_language("html"));
-
- //print (project.fn);
- //project.runhtml = project.runhtml || '';
- _this.view.el.get_buffer().set_text(project.runhtml);
-
-
- _this.rootURL.el.set_text( _this.project.rootURL );
- _this.base_template.el.set_text(_this.project.base_template);
-
-
- //this.el.show_all();
- },
- project : "",
- xtype : "VBox",
- save : ()
- {
- var buf = _this.view.el.get_buffer();
- Gtk.TextIter s;
- Gtk.TextIter e;
- buf.get_start_iter(out s);
- buf.get_end_iter(out e);
- _this.project.runhtml = buf.get_text(s,e,true);
-
- _this.project.rootURL = _this.rootURL.el.get_text();
- _this.project.base_template = _this.base_template.el.get_text();
-
-
- },
- xns : Gtk,
- border_width : 5,
- homogeneous : FALSE,
- items : [
- {
- xtype : "HBox",
- expand : false,
- xns : Gtk,
- homogeneous : TRUE,
- vexpand : false,
- items : [
- {
- label : "Apply",
- xtype : "Button",
- xns : Gtk,
- listeners : {
- button_press_event : () => {
- _this.save();
-
- _this.buttonPressed("apply");
- return false;
- }
- }
- },
- {
- label : "Save",
- xtype : "Button",
- xns : Gtk,
- listeners : {
- button_press_event : () => {
- _this.save();
-
- _this.buttonPressed("save");
- return false;
- }
- }
- }
- ]
-
- },
- {
- label : "filename",
- id : "path",
- xalign : 0,
- xtype : "Label",
- xns : Gtk
- },
- {
- label : "HTML To insert at end of <HEAD>",
- xtype : "Label",
- xns : Gtk
- },
- {
- xtype : "HBox",
- expand : false,
- xns : Gtk,
- homogeneous : FALSE,
- items : [
- {
- label : "HTML template file",
- xtype : "Label",
- xns : Gtk
- },
- {
- id : "base_template",
- xtype : "Entry",
- xns : Gtk
- }
- ]
-
- },
- {
- xtype : "HBox",
- expand : false,
- xns : Gtk,
- homogeneous : FALSE,
- items : [
- {
- label : "root URL",
- xtype : "Label",
- xns : Gtk
- },
- {
- id : "rootURL",
- xtype : "Entry",
- xns : Gtk
- }
- ]
-
- },
- {
- xtype : "ScrolledWindow",
- xns : Gtk,
- items : [
- {
- id : "view",
- xtype : "View",
- xns : GtkSource,
- listeners : {
- key_release_event : ( event) =>{
- if (event.keyval != 115) {
- return false;
-
- }
- if ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {
- return false;
- }
- var buf = this.el.get_buffer();
- Gtk.TextIter s;
- Gtk.TextIter e;
- buf.get_start_iter(out s);
- buf.get_end_iter(out e);
- _this.project.runhtml = buf.get_text(s,e,true);
-
-
- _this.buttonPressed("save");
-
- return false;
-
- }
- }
- }
- ]
-
- }
- ]
-
-});
-ProjectSettings.init();
-XObject.cache['/ProjectSettings'] = ProjectSettings;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-RooProjectProperties=new XObject({
- xtype: Gtk.Dialog,
- listeners : {
- delete_event : (self, event) => {
- this.el.hide();
- return true;
- },
- response : (self, response_id) => {
- //print(response_id);
- if (response_id< 1 ) {
- this.el.hide();
-
- return;
- }
-
- var buf = view.el.get_buffer();
- Gtk.TextIter s;
- Gtk.TextIter e;
- buf.get_start_iter(out s);
- buf.get_end_iter(out e);
- var str = buf.get_text(s,e,true);
- // ideally we should syntax check it.. but it's html!?
-
- //var project = this.get('/Window.LeftTree').getActiveFile().project;
-
-
- _this.project.runhtml = str;
- _this.project.save();
-
- // imports.Builder.Provider.ProjectManager.ProjectManager.saveConfig();
- // print (str);
- // this.get('view').el.get_buffer().get_text(project.runjs, project.runjs.length);
- // ok pressed..
- this.el.hide();
- }
- },
- default_width : 500,
- modal : true,
- 'void:show' : (Project.Project project) {
- _this.project = project;
- // get the active project.
-
- //print (project.fn);
- //project.runhtml = project.runhtml || '';
- _this.view.el.get_buffer().set_text(project.runhtml);
-
- this.el.show_all();
- },
- items : [
- {
- xtype: Gtk.VBox,
- border_width : 5,
- pack : get_content_area().add,
- items : [
- {
- xtype: Gtk.Label,
- pack : "pack_start,false,false,0",
- label : "HTML To insert at end of <HEAD>"
- },
- {
- xtype: Gtk.ScrolledWindow,
- pack : "pack_end,true,true,0",
- items : [
- {
- xtype: GtkSource.View,
- pack : "add",
- id : "view"
- }
- ]
- }
- ]
- },
- {
- xtype: Gtk.Button,
- pack : "add_action_widget,1",
- label : "OK"
- },
- {
- xtype: Gtk.Button,
- pack : "add_action_widget,0",
- label : "Cancel"
- }
- ]
-});
-RooProjectProperties.init();
-XObject.cache['/RooProjectProperties'] = RooProjectProperties;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-StandardErrorDialog=new XObject({
- xtype: Gtk.MessageDialog,
- listeners : {
- delete_event : (self, event) => {
- this.el.hide();
- return true;
-
- },
- response : (self, response_id) => {
- this.el.hide();
- }
- },
- text : "fixme",
- buttons : Gtk.ButtonsType.OK,
- message_type : Gtk.MessageType.ERROR,
- modal : true,
- use_markup : true,
- 'void:show' : (Gtk.Window win, string msg) {
-
- this.el.set_transient_for(win);
- this.el.modal = true;
- this.el.text = msg;
- this.el.show_all();
- }
-});
-StandardErrorDialog.init();
-XObject.cache['/StandardErrorDialog'] = StandardErrorDialog;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-WindowAddProp=new XObject({
- xtype: Gtk.ScrolledWindow,
- 'void:clear' : () {
- this.model.el.clear();
-
- },
- id : "WindowAddProp",
- init : this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);,
- shadow_type : Gtk.ShadowType.IN,
- 'void:show' : (Palete.Palete pal, string etype, string xtype) {
- this.model.el.clear();
-
- Gtk.TreeIter iter;
- var elementList = pal.getPropertiesFor( xtype,etype);
-
-
- //print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
- // console.dump(elementList);
-
- var miter = elementList.map_iterator();
- while (miter.next()) {
- var p = miter.get_value();
-
- this.model.el.append(out iter);
-
- this.model.el.set(iter,
- 0, p.name,
- 1, p.type,
- 2, "<b>" + p.name +"</b> <i>"+p.type+"</i>\n" +
- GLib.Markup.escape_text(p.doctxt),
- 3, p.sig,
- 4, "<b>" + p.name +"</b> <span size=\"small\"><i>"+p.type+"</i></span>",
- 5, etype,
- -1
- );
- }
- this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);
-
- },
- items : [
- {
- xtype: Gtk.TreeView,
- listeners : {
- row_activated : (path, column) => {
-
- Gtk.TreeIter iter;
-
-
- var m = _this.model;
-
- m.el.get_iter(out iter,path);
-
-
- // var val = "";
-
-
- var key = m.getValue(iter, 0);
-
- var type = m.getValue(iter, 1);
- var skel = m.getValue(iter, 3);
- var etype = m.getValue(iter, 5);
-
-
- _this.select(key,etype == "signals" ? "" : type,skel, etype);
-
- }
- },
- pack : "add",
- tooltip_column : 2,
- enable_tree_lines : true,
- headers_visible : false,
- init : {
- var description = new Pango.FontDescription();
- description.set_size(8000);
- this.el.modify_font(description);
-
- this.el.get_selection().set_mode( Gtk.SelectionMode.SINGLE);
-
-
-
-
-
- },
- items : [
- {
- xtype: Gtk.ListStore,
- id : "model",
- n_columns : 6,
- pack : "set_model",
- columns : typeof(string), // 0 real key
- typeof(string), // 1 real type
- typeof(string), // 2 docs ?
- typeof(string), // 3 visable desc
- typeof(string), // 4 function desc
- typeof(string) // 5 element type (event|prop),
- 'string:getValue' : (Gtk.TreeIter iter, int col)
- {
-
- GLib.Value value;
- this.el.get_value(iter, col, out value);
-
- return (string)value;
-
- }
- },
- {
- xtype: Gtk.TreeViewColumn,
- id : "namecol",
- pack : "append_column",
- init : this.el.add_attribute(_this.namerender.el , "markup", 4 );,
- items : [
- {
- xtype: Gtk.CellRendererText,
- id : "namerender",
- pack : "pack_start,true"
- }
- ]
- }
- ]
- }
- ]
-});
-WindowAddProp.init();
-XObject.cache['/WindowAddProp'] = WindowAddProp;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-WindowLeftProjects=new XObject({
- project_selected : "(Project.Project project)",
- id : "WindowLeftProjects",
- load : () {
- // clear list...
-
- if (_this.is_loaded) {
- return;
- }
- _this.is_loading = true;
-
- _this.is_loaded = true;
-
- Project.Project.loadAll();
- var projects = Project.Project.allProjectsByName();
-
- Gtk.TreeIter iter;
- var m = this.model.el;
- m.clear();
-
- for (var i = 0; i < projects.size; i++) {
- m.append(out iter);
- m.set(iter, 0,projects.get(i).name );
-
- var o = new GLib.Value(typeof(Object));
- o.set_object((Object)projects.get(i));
-
- m.set_value(iter, 1, o);
-
- }
- m.set_sort_column_id(0, Gtk.SortType.ASCENDING);
- _this.is_loading = false;
- },
- is_loaded : false,
- xtype : "VBox",
- getSelectedProject : () {
- Gtk.TreeIter iter;
- Gtk.TreeModel mod;
-
- var s = this.view.el.get_selection();
- if (!s.get_selected(out mod, out iter)) {
- return null;
- }
-
- GLib.Value gval;
-
- mod.get_value(iter, 1 , out gval);
- var project = (Project.Project)gval.get_object();
-
- return project;
- },
- selectProject : (Project.Project project) {
-
- var sel = _this.view.el.get_selection();
-
- sel.unselect_all();
-
- var found = false;
- _this.model.el.foreach((mod, path, iter) => {
- GLib.Value val;
-
- mod.get_value(iter, 1, out val);
- if ( ( (Project.Project)val.get_object()).fn != project.fn) {
- print("SKIP %s != %s\n", ((Project.Project)val.get_object()).name , project.name);
- return false;//continue
- }
- sel.select_iter(iter);
- this.project_selected(project);
- found = true;
- return true;
-
-
- });
- if (!found) {
- print("tried to select %s, could not find it", project.name);
- }
- },
- is_loading : false,
- xns : Gtk,
- homogeneous : FALSE,
- show_new_project : "()",
- listeners : {
- show : ( ) => {
- this.load();
- }
- },
- items : [
- {
- shadow_type : Gtk.ShadowType.IN,
- xtype : "ScrolledWindow",
- xns : Gtk,
- items : [
- {
- id : "view",
- xtype : "TreeView",
- enable_tree_lines : TRUE,
- headers_visible : FALSE,
- xns : Gtk,
- listeners : {
- cursor_changed : () => {
- if (_this.is_loading) {
- return;
- }
-
- Gtk.TreeIter iter;
- Gtk.TreeModel mod;
-
- var s = this.el.get_selection();
- if (!s.get_selected(out mod, out iter)) {
- return;
- }
-
- GLib.Value gval;
-
- mod.get_value(iter, 1 , out gval);
- var project = (Project.Project)gval.get_object();
-
- _this.project_selected(project);
-
- }
- },
- items : [
- {
- id : "model",
- xtype : "ListStore",
- columns : typeof(string), typeof(Object),
- n_columns : 2,
- xns : Gtk
- },
- {
- xtype : "TreeViewColumn",
- xns : Gtk,
- items : [
- {
- id : "namecol",
- xtype : "CellRendererText",
- xns : Gtk
- }
- ]
-
- }
- ]
-
- }
- ]
-
- }
- ]
-
-});
-WindowLeftProjects.init();
-XObject.cache['/WindowLeftProjects'] = WindowLeftProjects;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-WindowLeftProps=new XObject({
- allow_edit : false,
- before_edit : ()
- {
-
- print("before edit - stop editing\n");
-
- // these do not appear to trigger save...
- _this.keyrender.el.stop_editing(false);
- _this.keyrender.el.editable =false;
-
- _this.valrender.el.stop_editing(false);
- _this.valrender.el.editable =false;
-
-
- // technicall stop the popup editor..
-
- },
- id : "LeftProps",
- 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];
-
-
-
- },
- finish_editing : () {
- //
- this.before_edit();
- },
- startEditingValue : ( Gtk.TreePath path) {
-
- // ONLY return true if editing is allowed - eg. combo..
-
- print("start editing?\n");
- if (!this.stop_editor()) {
- print("stop editor failed\n");
- return false;
- }
-
- Gtk.TreeIter iter;
-
- var mod = this.model.el;
- mod.get_iter (out iter, path);
-
- /*
- m.set(iter,
- 0, "listener",
- 1, miter.get_key(),
- 2, "<b>" + miter.get_key() + "</b>",
- 3, miter.get_value()
- );
-
- */
- GLib.Value gval;
- mod.get_value(iter, 3 , out gval);
- var val = (string)gval;
-
- mod.get_value(iter, 1 , out gval);
- var key = (string)gval;
- var type_ar = key.split(" ");
-
-
-
- mod.get_value(iter, 0 , out gval);
- var type = (string)gval;
-
-
-
- var use_textarea = false;
-
- //------------ things that require the text editor...
-
- if (type == "listener") {
- use_textarea = true;
- }
- if (key.length > 0 && key[0] == '|') { // user defined method
- use_textarea = true;
- }
- if (key.length > 0 && key[0] == '$') { // raw string
- use_textarea = true;
- }
- if (key.length > 0 && key == "* init") {
- use_textarea = true;
- }
- if (val.length > 40) { // long value...
- use_textarea = true;
- }
-
-
-
- if (use_textarea) {
- print("Call show editor\n");
- GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
- this.view.el.get_selection().select_path(path);
-
- this.show_editor(file, node, type, key);
-
- return false;
- });
-
-
- return false;
- }
- // others... - fill in options for true/false?
- print("turn on editing %s \n" , mod.get_path(iter).to_string());
-
- print (type_ar[0].up());
- if (type_ar.length > 1 && (
- type_ar[0].up() == "BOOLEAN"
- ||
- type_ar[0].up() == "BOOL"
- )) {
- print("start editing try/false)???");
- this.valrender.el.has_entry = false;
- string[] opts = { "true", "false" };
- this.valrender.setOptions(opts);
-
- this.valrender.el.has_entry = false;
- this.valrender.el.editable = true;
- this.allow_edit = true;
- GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {
- this.view.el.set_cursor_on_cell(
- path,
- this.valcol.el,
- this.valrender.el,
- true
- );
- return false;
- });
- return true;
- }
-
-
-
- string[] opts = { };
- this.valrender.setOptions(opts);
-
- GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
-
- // at this point - work out the type...
- // if its' a combo... then show the options..
- this.valrender.el.has_entry = true;
-
- this.valrender.el.editable = true;
-
-
- this.allow_edit = true;
-
-
-
-
-
- this.view.el.set_cursor_on_cell(
- path,
- this.valcol.el,
- this.valrender.el,
- true
- );
- return false;
- });
- return false;
- },
- load : (JsRender.JsRender file, JsRender.Node? node)
- {
- print("load leftprops\n");
- this.before_edit();
- this.node = node;
- this.file = file;
-
-
- this.model.el.clear();
-
- //this.get('/RightEditor').el.hide();
- if (node ==null) {
- return ;
- }
-
-
-
- //var provider = this.get('/LeftTree').getPaleteProvider();
- Gtk.TreeIter iter;
-
- //typeof(string), // 0 key type
- //typeof(string), // 1 key
- //typeof(string), // 2 key (display)
- //typeof(string), // 3 value
- //typeof(string), // 4 value (display)
- //typeof(string), // 5 both (tooltip)
-
-
-
-
- // really need a way to sort the hashmap...
- var m = this.model.el;
-
- var miter = node.listeners.map_iterator();
- var i = 0;
-
- while(miter.next()) {
- i++;
- m.append(out iter,null);
-
- this.updateIter(iter, "listener", miter.get_key(), miter.get_value());
-
-
- }
-
-
- miter = node.props.map_iterator();
-
-
- while(miter.next()) {
- i++;
- m.append(out iter,null);
- this.updateIter(iter, "prop", miter.get_key(), miter.get_value());
-
- }
- print("clear selection\n");
- // clear selection?
- this.model.el.set_sort_column_id(6,Gtk.SortType.ASCENDING); // sort by real key..
-
- this.view.el.get_selection().unselect_all();
-
- var pane = _this.main_window.editpane.el;
- var try_size = (i * 25) + 60; // est. 20px per line + 40px header
-
- // max 80%...
- pane.set_position(
- ((try_size * 1.0f) / (pane.max_position * 1.0f)) > 0.8f ?
- (int) (pane.max_position * 0.2f) :
- pane.max_position-try_size);
-
-
- },
- xtype : "VBox",
- keyFormat : (string val, string type) {
-
- // Glib.markup_escape_text(val);
-
- if (type == "listener") {
- return "<span font_weight=\"bold\" color=\"#660000\">" +
- GLib.Markup.escape_text(val) +
- "</span>";
- }
- // property..
- if (val.length < 1) {
- return "<span color=\"#FF0000\">--empty--</span>";
- }
-
- //@ = 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 @"<span font_weight=\"bold\">@ $dval</span>";
- case '#': // object properties?
- if (dval[0] == '#') {
- dval = dval.substring(1);
- }
- return @"<span font_weight=\"bold\">$dval</span>";
- case '*': // special
- if (dval[0] == '*') {
- dval = dval.substring(1);
- }
- return @"<span color=\"#0000CC\" font_weight=\"bold\">$dval</span>";
- case '$':
- if (dval[0] == '$') {
- dval = dval.substring(1);
- }
- return @"<span style=\"italic\">$dval</span>";
- case '|': // user defined methods
- if (dval[0] == '|') {
- dval = dval.substring(1);
- }
- return @"<span color=\"#008000\" font_weight=\"bold\">$dval</span>";
-
-
-
- default:
- return dval;
- }
-
-
-
- },
- file : "",
- stop_editor : "()",
- show_editor : "(JsRender.JsRender file, JsRender.Node node, string type, string key)",
- changed : "()",
- deleteSelected : () {
-
- 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 type = (string)gval;
-
- mod.get_value(iter, 1 , out gval);
- var key = (string)gval;
-
- switch(type) {
- case "listener":
- this.node.listeners.remove(key);
- break;
-
- case "props":
- this.node.props.remove(key);
- break;
- }
- this.load(this.file, this.node);
-
- _this.changed();
- },
- xns : Gtk,
- startEditingKey : ( Gtk.TreePath path) {
-
- if (!this.stop_editor()) {
- return;
- }
-
- // others... - fill in options for true/false?
-
-
- GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
- this.allow_edit = true;
- this.keyrender.el.editable = true;
-
- this.view.el.set_cursor_on_cell(
- path,
- this.keycol.el,
- this.keyrender.el,
- true
- );
-
- return false;
- });
-
-
- },
- show_add_props : "(string type)",
- homogeneous : false,
- main_window : "null",
- addProp : (string in_type, string key, string value, string value_type) {
- // info includes key, val, skel, etype..
- //console.dump(info);
- //type = info.type.toLowerCase();
- //var data = this.toJS();
-
- var type = in_type == "signals" ? "listener" : in_type;
-
- var fkey = (value_type.length > 0 ? value_type + " " : "") + key;
-
- if (type == "listener") {
- if (this.node.listeners.has_key(key)) {
- return;
- }
- this.node.listeners.set(key,value);
- } else {
-
- if (this.node.props.has_key(fkey)) {
- return;
- }
- this.node.props.set(fkey,value);
- }
-
-
- // add a row???
- this.load(this.file, this.node);
-
-
-
- /// need to find the row which I've just added..
-
-
- var s = this.view.el.get_selection();
- s.unselect_all();
-
- print("trying to find new iter");
-
- this.model.el.foreach((model, path, iter) => {
- GLib.Value gval;
-
- this.model.el.get_value(iter, 0 , out gval);
- if ((string)gval != type) {
- print("not type: %s = %s\n", (string)gval , type);
- return false;
- }
- this.model.el.get_value(iter, 1 , out gval);
- if ((string)gval != fkey) {
- print("not key: %s = %s\n", (string)gval , fkey);
- return false;
- }
- // delay this?
- GLib.Timeout.add_full(GLib.Priority.DEFAULT,40 , () => {
-
- this.startEditingValue(this.model.el.get_path(iter));
- return false;
- });
- //s.select_iter(iter);
- return true;
- });
-
-
-
-
- },
- updateIter : (Gtk.TreeIter iter, string type, string key, string value) {
-
- print("update Iter %s, %s\n", key,value);
- //typeof(string), // 0 key type
- //typeof(string), // 1 key
- //typeof(string), // 2 key (display)
- //typeof(string), // 3 value
- //typeof(string), // 4 value (display)
- //typeof(string), // 5 both (tooltip)
- //typeof(string), // 6 key (sort)
-
- var dl = value.strip().split("\n");
-
- var dis_val = dl.length > 1 ? (dl[0].strip()+ "...") : dl[0];
-
- if (type == "listener") {
-
-
-
- this.model.el.set(iter,
- 0, type,
- 1, key,
- 2, this.keyFormat(key ,type),
- 3, value,
- 4, dis_val,
- 5, "<tt>" + GLib.Markup.escape_text(key + " " +value) + "</tt>",
- 6, "0 " + key
- );
- return;
- }
-
-
-
- this.model.el.set(iter,
- 0, "props",
- 1, key,
- 2, this.keyFormat(key , "prop"),
- 3, value,
- 4, dis_val,
- 5, "<tt>" + GLib.Markup.escape_text(key + " " + value) + "</tt>",
- 6, this.keySortFormat(key)
- );
- },
- node : "",
- items : [
- {
- xtype : "HBox",
- xns : Gtk,
- items : [
- {
- xtype : "Button",
- xns : Gtk,
- listeners : {
- button_press_event : (self, ev) => {
- _this.before_edit();
-
-
- var p = _this.AddPropertyPopup;
- p.el.set_screen(Gdk.Screen.get_default());
- p.el.show_all();
- p.el.popup(null, null, null, ev.button, ev.time);
- return true;
- }
- },
- items : [
- {
- xtype : "HBox",
- xns : Gtk,
- items : [
- {
- xtype : "Image",
- stock : Gtk.STOCK_ADD,
- xns : Gtk,
- icon_size : Gtk.IconSize.MENU
- },
- {
- label : "Other",
- xtype : "Label",
- xns : Gtk
- }
- ]
-
- },
- {
- id : "AddPropertyPopup",
- xtype : "Menu",
- xns : Gtk,
- items : [
- {
- label : "ID",
- xtype : "MenuItem",
- tooltip_markup : "Using this.get('*someid') will find any id in an application.",
- xns : Gtk,
- listeners : {
- activate : () => {
- _this.addProp( "prop", "id", "", "string");
- }
- }
- },
- {
- label : "PACK",
- xtype : "MenuItem",
- tooltip_markup : "Add what type of packing is to be used",
- xns : Gtk,
- listeners : {
- activate : ( ) => {
-
- _this.addProp( "prop", "pack","add", "*");
- }
- }
- },
- {
- label : "INIT",
- xtype : "MenuItem",
- tooltip_markup : "Override the init method",
- xns : Gtk,
- listeners : {
- activate : ( ) => {
-
- _this.addProp( "prop", "init", "{\n\n}\n", "*" );
- }
- }
- },
- {
- xtype : "SeparatorMenuItem",
- xns : Gtk
- },
- {
- label : "String",
- xtype : "MenuItem",
- tooltip_markup : "Add a user defined string property",
- xns : Gtk,
- listeners : {
- activate : (self) => {
-
- _this.addProp( "prop", "XXXX", "","string");
-
- }
- }
- },
- {
- label : "Number",
- xtype : "MenuItem",
- tooltip_markup : "Add a user defined number property",
- xns : Gtk,
- listeners : {
- activate : ( ) =>{
-
- _this.addProp("prop", "XXX", "0", "int");
- }
- }
- },
- {
- label : "Boolean",
- xtype : "MenuItem",
- tooltip_markup : "Add a user defined boolean property",
- xns : Gtk,
- listeners : {
- activate : ( ) =>{
-
- _this.addProp( "prop", "XXX", "true", "bool");
- }
- }
- },
- {
- xtype : "SeparatorMenuItem",
- xns : Gtk
- },
- {
- label : "Javascript Function",
- xtype : "MenuItem",
- tooltip_markup : "Add a user function boolean property",
- xns : Gtk,
- listeners : {
- activate : ( ) =>{
-
- _this.addProp("prop", "XXXX", "function() { }", "| function");
- }
- }
- },
- {
- label : "Vala Method",
- xtype : "MenuItem",
- tooltip_markup : "Add a user function boolean property",
- xns : Gtk,
- listeners : {
- activate : ( ) =>{
-
- _this.addProp( "prop", "XXXX", "() {\n\n}\n", "| return_type");
- }
- }
- }
- ]
-
- }
- ]
-
- }
- ]
-
- },
- {
- editing : false,
- id : "EditProps",
- shadow_type : Gtk.ShadowType.IN,
- xtype : "ScrolledWindow",
- xns : Gtk,
- items : [
- {
- id : "view",
- tooltip_column : 5,
- xtype : "TreeView",
- enable_tree_lines : TRUE,
- headers_visible : TRUE,
- xns : Gtk,
- listeners : {
- button_press_event : ( ev) => {
-
- Gtk.TreeViewColumn col;
- int cell_x;
- int cell_y;
- Gtk.TreePath path;
- if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {
- print("nothing selected on click");
- GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
- this.el.get_selection().unselect_all();
-
- return false;
- });
- _this.before_edit();
- return false; //not on a element.
- }
-
- // right click.
- if (ev.type == Gdk.EventType.BUTTON_PRESS && ev.button == 3) {
- // show popup!.
- if (col.title == "Value") {
- _this.before_edit();
- return false;
- }
-
- var p = _this.ContextMenu;
-
- p.el.set_screen(Gdk.Screen.get_default());
- p.el.show_all();
- p.el.popup(null, null, null, ev.button, ev.time);
- //Seed.print("click:" + res.column.title);
- // select the
- GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
-
- this.el.get_selection().select_path(path);
- return false;
- });
- _this.before_edit();
- return false;
- }
-
-
- if (col.title != "Value") {
- print("col title != Value");
-
- GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
- this.el.get_selection().select_path(path);
- return false;
- });
-
- _this.before_edit();
- // XObject.error("column is not value?");
- return false; // ignore.. - key click.. ??? should we do this??
- }
-
-
- // if the cell can be edited with a pulldown
- // then we should return true... - and let the start_editing handle it?
-
-
-
-
-
-
-
- // currently editing???
- // if ( this.activePath) {
-
- // this.activePath = false;
- // stop editing!!!!
- /*
- if (this.get('/Editor').dirty) {
- //if (!this.get('/Editor.buffer').checkSyntax()) {
- // this.get('/StandardErrorDialog').show("Fix errors in code and save..");
- // return true;
- // // error Dialog
- //}
- if (!this.get('/Editor.view').save()) {
- return true;
- }
- }
- */
-
- //this.EditProps.editableColumn.items[0].el.stop_editing();
- //this.EditProps.editing = false;
-
- // XObject.error("Currently editing?");
- // return false;
- // }
-
- // var renderer = this.valrender.el; // set has_entry..
-
- //var type = this.get('/LeftPanel.model').getType(res.path.to_string());
-
- // get options for this type -- this is to support option lists etc..
- //var provider = this.get('/LeftTree').getPaleteProvider();
- //var opts = provider.findOptions(type);
-
- // if (opts === false) {
- // it's text etnry
- // this.get('/LeftPanel').editableColumn.setOptions([]);
- // renderer.has_entry = true;
- // } else {
- // this.get('/LeftPanel').editableColumn.setOptions(opts);
- // renderer.has_entry = false;
- // }
-
- // we need to set the selected row..
-
- //Gtk.TreePath path;
-
- ;
- // _this.before_edit(); <<< we really need to stop the other editor..
- _this.keyrender.el.stop_editing(false);
- _this.keyrender.el.editable =false;
-
-
- return _this.startEditingValue(path); // assumes selected row..
-
-
-
-
-
- }
- },
- items : [
- {
- id : "model",
- changed : function(str, doRefresh) {
- if (!this.activePath) {
- return;
- }
- var iter = new Gtk.TreeIter();
- this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
-
- this.el.set_value(iter, 1, '' +str);
- this.el.set_value(iter, 3, '' + this.toShort(str));
- var type = this.getIterValue(iter, 4);
-
- this.el.set_value(iter, 5, type + ' : ' + str);
- // update the tree...
-
- this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
- },
- xtype : "TreeStore",
- columns : typeof(string), // 0 key type
- typeof(string), // 1 key
- typeof(string), // 2 key (display)
- typeof(string), // 3 value
- typeof(string), // 4 value (display)
- typeof(string), // 5 both (tooltip)
- typeof(string) // 6 key (for sorting),
- n_columns : 7,
- xns : Gtk,
- toShort : function(str) {
- var a = typeof(str) == 'string' ? str.split("\n") : [];
- return a.length > 1 ? a[0] + '....' : '' + str;
- }
- },
- {
- id : "keycol",
- title : "Name",
- xtype : "TreeViewColumn",
- resizable : TRUE,
- xns : Gtk,
- items : [
- {
- id : "keyrender",
- xtype : "CellRendererText",
- xns : Gtk,
- listeners : {
- editing_started : ( editable, path) => {
-
- Gtk.TreeIter iter;
- _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
- GLib.Value gval;
-
-
-
- // this.get('/LeftPanel.model').activePath = path;
- _this.model.el.get_value(iter,1, out gval);
- var val = (string)gval;
-
- ((Gtk.Entry)editable).set_text(val);
- },
- edited : (path, newtext) => {
- print("Keyrender - signal:edited\n");
-
- this.el.editable = false;
-
-
-
- Gtk.TreeIter iter;
- _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
- GLib.Value gval;
-
- _this.model.el.get_value(iter,1, out gval);
- var oldval = (string)gval;
-
- _this.model.el.get_value(iter,0, out gval);
- var ktype = (string)gval;
-
- _this.model.el.set_value(iter, 1, newtext);
-
- print("ktype: %s\n",ktype);
- switch(ktype) {
- case "listener":
- var ov = _this.node.listeners.get(oldval);
- _this.node.listeners.set(newtext, ov);
- _this.node.listeners.remove(oldval);
-
- _this.updateIter(iter, ktype, newtext, ov);
-
- break;
- case "props":
- var ov = _this.node.props.get(oldval);
- _this.node.props.set(newtext, ov);
- _this.node.props.remove(oldval);
- _this.updateIter(iter, ktype, newtext, ov);
- break;
- }
- _this.changed();
-
- }
- }
- }
- ]
-
- },
- {
- id : "valcol",
- title : "Value",
- xtype : "TreeViewColumn",
- resizable : TRUE,
- xns : Gtk,
- items : [
- {
- model : {
- id : "valrendermodel",
- xtype : "ListStore",
- columns : typeof(string),
- n_columns : 1,
- xns : Gtk
- },
- id : "valrender",
- xtype : "CellRendererCombo",
- editable : FALSE,
- has_entry : TRUE,
- xns : Gtk,
- setOptions : (string[] ar) {
- var m = _this.valrendermodel.el;
- m.clear();
- Gtk.TreeIter iret;
- for (var i =0; i < ar.length; i++) {
- m.append(out iret);
- m.set_value(iret, 0, ar[i]);
- }
-
- },
- text_column : 0,
- listeners : {
- editing_started : ( editable, path) => {
- //_this.editing = true;
- print("editing started called\n");
- if (!_this.allow_edit) {
-
- print("val - editing_Started\n");
- this.el.editable = false; // make sure it's not editor...
-
-
- return;
- }
- _this.allow_edit =false;
-
-
- if ( this.el.has_entry ) {
-
- Gtk.TreeIter iter;
- _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
- GLib.Value gval;
-
-
-
- // this.get('/LeftPanel.model').activePath = path;
- _this.model.el.get_value(iter,3, out gval);
-
-
- var val = (string)gval;
- var combo = (Gtk.ComboBox)editable;
-
- var entry = (Gtk.Entry) combo.get_child();
- entry.set_text(val);
- }
-
- },
- edited : (path, newtext) => {
- print("Valrender - signal:edited\n");
-
- this.el.editable = false;
- /*
- m.set(iter,
- 0, "listener",
- 1, miter.get_key(),
- 2, "<b>" + miter.get_key() + "</b>",
- 3, miter.get_value(),
- 4, display_value(short);
- );
-
- */
-
- Gtk.TreeIter iter;
- _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
- GLib.Value gval;
-
- _this.model.el.get_value(iter,0, out gval);
- var ktype = (string)gval;
-
-
- _this.model.el.get_value(iter,3, out gval);
- var oldval = (string)gval;
-
- _this.model.el.get_value(iter,1, out gval);
- var key = (string)gval;
-
-
-
- switch(ktype) {
- case "listener":
- _this.node.listeners.set(key, newtext);
- _this.updateIter(iter,ktype,key,newtext);
- break;
- case "props":
- _this.node.props.set(key,newtext);
- _this.updateIter(iter,ktype, key,newtext);
- break;
- }
- // _this.load(_this.file,_this.node);
- _this.changed();
-
- }
- },
- items : [
-
- ]
-
- }
- ]
-
- },
- {
- id : "ContextMenu",
- xtype : "Menu",
- xns : Gtk,
- items : [
- {
- label : "Edit",
- xtype : "MenuItem",
- xns : Gtk,
- listeners : {
- activate : ( ) =>{
-
- var s = _this.view.el.get_selection();
- Gtk.TreeIter iter;
- Gtk.TreeModel model;
- s.get_selected (out model, out iter);
- _this.startEditingKey(model.get_path(iter));
- }
- }
- },
- {
- xtype : "SeparatorMenuItem",
- xns : Gtk
- },
- {
- label : "Delete",
- xtype : "MenuItem",
- xns : Gtk,
- listeners : {
- activate : ( ) =>{
- _this.deleteSelected();
- }
- }
- }
- ]
-
- }
- ]
-
- }
- ]
-
- }
- ]
-
-});
-WindowLeftProps.init();
-XObject.cache['/WindowLeftProps'] = WindowLeftProps;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-WindowLeftTree=new XObject({
- getActiveElement : () { // return path to actie node.
-
- var path = this.getActivePath();
- if (path.length < 1) {
- return null;
- }
- return _this.model.pathToNode(path);
-
- },
- id : "WindowLeftTree",
- before_node_change : "(JsRender.Node? node)",
- shadow_type : Gtk.ShadowType.IN,
- getActiveFile : () {
- return this.model.file;
- },
- xtype : "ScrolledWindow",
- changed : "()",
- xns : Gtk,
- node_selected : "(JsRender.Node? node)",
- main_window : "null",
- getActivePath : () {
- var model = this.model;
- var view = this.view.el;
- if (view.get_selection().count_selected_rows() < 1) {
- return "";
- }
- Gtk.TreeIter iter;
- Gtk.TreeModel mod;
- view.get_selection().get_selected(out mod, out iter);
- return mod.get_path(iter).to_string();
- },
- items : [
- {
- dragData : "",
- drag_x : "",
- dropList : "",
- id : "view",
- headers_visible : true,
- drag_y : "",
- tooltip_column : 1,
- xtype : "TreeView",
- enable_tree_lines : TRUE,
- headers_visible : FALSE,
- highlightDropPath : ( string treepath, Gtk.TreeViewDropPosition pos) {
-
- // highlighting for drag/drop
- if (treepath.length > 0) {
- this.el.set_drag_dest_row( new Gtk.TreePath.from_string( treepath ), pos);
- } else {
- this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
- }
-
- },
- drag_in_motion : "",
- blockChanges : false,
- xns : Gtk,
- selectNode : (string treepath_str) {
- //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
- var tp = new Gtk.TreePath.from_string(treepath_str);
-
- this.el.set_cursor(tp, null, false);
- this.el.scroll_to_cell(tp, null, false, 0,0);
- },
- listeners : {
- button_press_event : ( ev) => {
- //console.log("button press?");
- if (! _this.before_node_change(null) ) {
- return true;
- }
-
-
- if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) {
- //print("click" + ev.type);
- return false;
- }
- Gtk.TreePath res;
- if (!_this.view.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {
- return true;
- }
-
- this.el.get_selection().select_path(res);
-
- //if (!this.get('/LeftTreeMenu').el) {
- // this.get('/LeftTreeMenu').init();
- // }
-
- _this.LeftTreeMenu.el.set_screen(Gdk.Screen.get_default());
- _this.LeftTreeMenu.el.show_all();
- _this.LeftTreeMenu.el.popup(null, null, null, 3, ev.time);
- // print("click:" + res.path.to_string());
- return true;
- },
- drag_begin : ( ctx) => {
- //print('SOURCE: drag-begin');
-
-
- //this.targetData = "";
-
- // find what is selected in our tree...
-
- var s = _this.view.el.get_selection();
- if (s.count_selected_rows() < 1) {
- return;
- }
- Gtk.TreeIter iter;
- Gtk.TreeModel mod;
- s.get_selected(out mod, out iter);
-
-
-
- // set some properties of the tree for use by the dropped element.
- GLib.Value value;
- _this.model.el.get_value(iter, 2, out value);
- var data = (JsRender.Node)(value.dup_object());
- var xname = data.fqn();
- print ("XNAME IS " + xname+ "\n");
- this.dragData = xname;
- this.dropList = _this.model.file.palete().getDropList(xname);
-
- print ("DROP LIST IS " + string.joinv(", ", this.dropList) + "\n");
-
-
- // make the drag icon a picture of the node that was selected
- var path = _this.model.el.get_path(iter);
-
- //this.treepath = path.to_string();
-
- var pix = this.el.create_row_drag_icon ( path);
-
- Gtk.drag_set_icon_surface (ctx, pix) ;
-
- return;
- },
- cursor_changed : ( ) => {
-
-
- if (this.blockChanges) { // probably not needed..
- return ;
- }
- if (!_this.before_node_change(null) ) {
- this.blockChanges = true;
- this.el.get_selection().unselect_all();
- this.blockChanges = false;
- return;
- }
- if (_this.model.file == null) {
- return;
- }
-
- //var render = this.get('/LeftTree').getRenderer();
- print("LEFT TREE -> view -> selection changed called\n");
-
-
- // -- it appears that the selection is not updated.
-
- GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
-
-
- if (this.el.get_selection().count_selected_rows() < 1) {
-
- print("selected rows < 1\n");
- //??this.model.load( false);
- _this.node_selected(null);
-
- return false ;
- }
-
- //console.log('changed');
- var s = this.el.get_selection();
- Gtk.TreeIter iter;
- Gtk.TreeModel mod;
- s.get_selected(out mod, out iter);
-
-
- // var val = "";
- GLib.Value value;
- _this.model.el.get_value(iter, 2, out value);
- _this.model.activePath = mod.get_path(iter).to_string();
-
- var node = (JsRender.Node)value.dup_object();
- _this.node_selected(node);
- return false;
- });
- //_this.after_node_change(node);
-
- // _this.model.file.changed(node, "tree");
-
- //Seed.print( value.get_string());
- return ;
-
- },
- drag_end : (drag_context) => {
- //Seed.print('LEFT-TREE: drag-end');
- this.dragData = "";
- this.dropList = null;
- // this.targetData = "";
- this.highlightDropPath("",0);
- // return true;
- },
- drag_motion : ( ctx, x, y, time) => {
-
- // the point of this is to detect where an item could be dropped..
- print("got drag motion");
- this.drag_in_motion = true;
- this.drag_x = x;
- this.drag_y = y;
-
- // 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("STRING",true), // the target type we want
- time // time stamp
- );
- return true;
-
- },
- drag_data_get : ( drag_context, data, info, time) => {
-
-
- print("drag-data-get");
- var s = this.el.get_selection();
- if (s.count_selected_rows() < 1) {
- data.set_text("",0);
- print("return empty string - no selection..");
- return;
- }
-
- Gtk.TreeIter iter;
- Gtk.TreeModel mod;
-
- s.get_selected(out mod, out iter);
-
-
- var tp = mod.get_path(iter).to_string();
- data.set_text(tp,tp.length);
- print("return " + tp);
- },
- drag_data_received : (ctx, x, y, sel, info, time) => {
- //print("Tree: drag-data-received");
-
- //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;
- }
-
-
- //console.log("LEFT-TREE: drag-motion");
- var src = Gtk.drag_get_source_widget(ctx);
-
- // a drag from elsewhere...- prevent drop..
- if (src != this.el) {
- //print("drag_data_recieved from another element");
-
-
- var selection_text = sel.get_text();
-
- if (selection_text == null || selection_text.length < 1 || !isOver) {
- // nothing valid foudn to drop...
- if (this.drag_in_motion) {
- Gdk.drag_status(ctx, 0, time);
- this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
- return;
- }
- Gtk.drag_finish (ctx, false, false, time); // drop failed..
- // no drop action...
- return;
-
- }
-
- // dropList --- need to gather this ...
- //print("get dropList for : %s\n",selection_text);
- var dropList = _this.model.file.palete().getDropList(selection_text);
-
- print("dropList: %s\n", string.joinv(" , ", dropList));
-
- targetData = _this.model.findDropNodeByPath( isEmpty ? "" : path.to_string(), dropList, pos);
-
- print("targetDAta: " + targetData +"\n");
-
- if (targetData.length < 1) {
-
- // invalid drop path..
- if (this.drag_in_motion) {
- Gdk.drag_status(ctx, 0, time);
- this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
- return;
- }
- Gtk.drag_finish (ctx, false, false, time); // drop failed..
- // no drop action...
- return;
- }
- // valid drop path..
-
- var td_ar = targetData.split("|");
-
-
- if (this.drag_in_motion) {
- Gdk.drag_status(ctx, Gdk.DragAction.COPY ,time);
-
- this.highlightDropPath( td_ar[0] , (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));
- return;
- }
- // continue on to allow drop..
-
-
- // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..
- var node = new JsRender.Node();
- node.setFqn(selection_text);
-
- _this.model.dropNode(targetData, node, true);
- print("ADD new node!!!\n");
-
- ///Xcls_DialogTemplateSelect.singleton().show( _this.model.file.palete(), node);
-
- Gtk.drag_finish (ctx, false, false,time);
-
-
-
-
-
- return;
-
- }
-
-
- //var action = Gdk.DragAction.COPY;
- // unless we are copying!!! ctl button..
- var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ? 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);
- if (this.drag_in_motion) {
- this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
- Gdk.drag_status(ctx, action ,time);
- return;
- }
- // continue through to allow drop...
-
- } else {
-
-
-
-
-
- //print("ISOVER? " + isOver);
- if (!isOver) {
- if (this.drag_in_motion) {
- Gdk.drag_status(ctx, 0 ,time);
- this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
- return;
- }
- Gtk.drag_finish (ctx, false, false, time); // drop failed..
- return; // 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
-
- // what's in the selected data....
- var selection_text = sel.get_text();
-
-
-
- if (selection_text == null || selection_text.length < 1) {
- //print("Error - drag selection text returned NULL");
- if (this.drag_in_motion) {
- Gdk.drag_status(ctx, 0 ,time);
- this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
- return;
- }
- Gtk.drag_finish (ctx, false, false, time); // drop failed..
- return; /// -- 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");
- if (this.drag_in_motion) {
- Gdk.drag_status(ctx, 0 ,time);
- this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
- return;
- }
- Gtk.drag_finish (ctx, false, false, time); // drop failed..
-
- return; /// -- 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");
- if (this.drag_in_motion) {
- Gdk.drag_status(ctx, 0, time);
- this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
- return;
- }
- Gtk.drag_finish (ctx, false, false, time); // drop failed..
- return;
- }
-
- var td_ar = targetData.split("|");
-
-
- if (this.drag_in_motion) {
- Gdk.drag_status(ctx, action ,time);
- this.highlightDropPath(td_ar[0], (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));
- return;
- }
- // 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 (ctx.get_actions() == Gdk.DragAction.ASK) {
- /* Ask the user to move or copy, then set the ctx action. */
- }
-
- if (ctx.get_actions() == Gdk.DragAction.MOVE) {
- delete_selection_data = true;
- }
-
-
- // drag around.. - reorder..
- _this.model.moveNode(targetData, ctx.get_actions());
-
-
-
-
-
- // 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);
-
- },
- drag_drop : ( ctx, x, y, time) => {
- //Seed.print("TARGET: drag-drop");
- 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("STRING",true), // the target type we want
- time // time stamp
- );
-
-
- // No target offered by source => error
-
-
- return false;
- }
- },
- items : [
- {
- findDropNode : (string treepath_str, string[] targets) {
-
- // this is used by the dragdrop code in the roo version AFAIR..
-
- //var path = treepath_str.replace(/^builder-/, '');
- // treemap is depreciated... - should really check if model has any entries..
-
- if (this.el.iter_n_children(null) < 1) {
- //print("NO KEYS");
- return "|%d".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);
- }
- //print("FIND treepath: " + path);
- //console.dump(this.treemap);
-
- //if (!treepath_str.match(/^builder-/)) {
- // return []; // nothing!
- //}
- if (targets.length > 0 && targets[0] == "*") {
- return treepath_str;
- }
- return this.findDropNodeByPath(treepath_str,targets, -1);
- },
- currentTree : false,
- id : "model",
- loadFile : (JsRender.JsRender f) {
- //console.dump(f);
- this.el.clear();
- this.file = f;
-
-
- // if (!f) {
- // console.log('missing file');
- // return;
- // }
-
- // load the file if not loaded..
- if (f.tree == null) {
- f.loadItems( );
- }
- // if it's still null?
- if (f.tree == null) {
- return;
- }
-
- /// this.get('/Window').setTitle(f.project.getName() + ' - ' + f.name);
-
- //if (f.items.length && typeof(f.items[0]) == 'string') {
-
- //this.get('/RightEditor').el.show();
- //this.get('/RightEditor.view').load( f.items[0]);
- // return;
- //}
- //print("LOAD");
- //print(JSON.stringify(f.items, null,4));
- //console.dump(f.items);
- var o = new Gee.ArrayList<JsRender.Node>();
- o.add(f.tree);
- this.load(o,null);
-
- _this.view.el.expand_all();
-
- if (f.tree.items.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);
- }
-
- return;
- /*
-
- //print("hide right editior");
- //this.get('/RightEditor').el.hide();
- //this.get('/Editor').el.hide();
- //print("set current tree");
- //this.currentTree = this.toJS(false, false)[0];
- //console.dump(this.currentTree);
- //this.currentTree = this.currentTree || { items: [] };
- //_this.renderView();
- //console.dump(this.map);
- //var RightPalete = imports.Builder.RightPalete.RightPalete;
-
-
- var pm = this.get('/RightPalete.model');
- // set up provider..
-
- this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
-
- if (!this.get('/RightPalete').provider) {
- print ("********* PALETE PROVIDER MISSING?!!");
- }
- this.get('/LeftTree').renderView();
-
- pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
-
-
-
- this.get('/Window.view-notebook').el.set_current_page(
- this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
- */
-
- },
- file : "null",
- updateSelected : () {
-
-
- var s = _this.view.el.get_selection();
-
- Gtk.TreeIter iter;
- Gtk.TreeModel mod;
-
-
-
- if (!s.get_selected(out mod, out iter)) {
- return; // nothing seleted..
- }
-
- GLib.Value value;
- this.el.get_value(iter, 2, out value);
- var node = (JsRender.Node)(value.get_object());
-
- this.el.set(iter, 0, node.nodeTitle(),
- 1, node.nodeTip(), -1
- );
- },
- xtype : "TreeStore",
- findDropNodeByPath : (string treepath_str, string[] targets, int in_pref = -1) {
-
- var path = treepath_str; // dupe it..
-
- int pref = in_pref < 0 ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : in_pref;
-
- var last = "";
-
- //console.dump(this.treemap);
-
- print("findDropNodeByPath : got path length %d / %s\n", path.length, path);
-
- if (path.length == 0) {
- // top drop. // just return empty..
- return "|%d".printf((int)pref) ;
-
- }
-
-
- while (path.length > 0) {
- //print("LOOKING FOR PATH: " + path);
- var node_data = this.pathToNode(path);
-
- if (node_data == null) {
- print("node not found");
- return null;
- }
-
- var xname = node_data.fqn();
- var match = "";
- var prop = "";
-
- for (var i =0; i < targets.length; i++) {
- var tg = targets[i];
- if ((tg == xname) ) {
- match = tg;
- break;
- }
- // if target is "xxxx:name"
- if (tg.contains(xname +":")) {
- match = tg;
- var ar = tg.split(":");
- prop = ar[1];
- break;
- }
- }
-
- if (match.length > 0) {
- if (last.length > 0) { // pref is after/before..
- // then it's after last
- if (pref > 1) {
- return "";
- }
- return last + "|%d".printf((int)pref) + "|" + prop;
-
-
- }
- return path + "|%d".printf( (int) Gtk.TreeViewDropPosition.INTO_OR_AFTER) + "|" + prop;
- }
- last = "" + path;
- var par = path.split(":");
- string [] ppar = {};
- for (var i = 0; i < par.length-1; i++) {
- ppar += par[i];
- }
-
- path = string.joinv(":", ppar);
-
-
- }
-
- return "";
-
- },
- moveNode : (string target_data, Gdk.DragAction action)
- {
-
- /// target_data = "path|pos");
-
-
- //print("MOVE NODE");
- // console.dump(target_data);
- Gtk.TreeIter old_iter;
- Gtk.TreeModel mod;
-
- var s = _this.view.el.get_selection();
- s.get_selected(out mod , out old_iter);
- mod.get_path(old_iter);
-
- var node = this.pathToNode(mod.get_path(old_iter).to_string());
- //console.dump(node);
- if (node == null) {
- print("moveNode: ERROR - node is null?");
- }
-
-
-
- // needs to drop first, otherwise the target_data
- // treepath will be invalid.
-
-
- if ((action & Gdk.DragAction.MOVE) > 0) {
- print("REMOVING OLD NODE : " + target_data + "\n");
- node.remove();
- this.dropNode(target_data, node, false);
- this.el.remove(ref old_iter);
-
-
-
- } else {
- print("DROPPING NODE // copy: " + target_data + "\n");
- node = node.deepClone();
- this.dropNode(target_data, node, false);
- }
- _this.changed();
- this.activePath= "";
- //this.updateNode(false,true);
- },
- activePath : "\"\"",
- columns : typeof(string),typeof(string),typeof(Object),
- load : (Gee.ArrayList<JsRender.Node> tr, Gtk.TreeIter? iter)
- {
- Gtk.TreeIter citer;
- //this.insert(citer,iter,0);
- for(var i =0 ; i < tr.size; i++) {
- if (iter != null) {
- this.el.insert(out citer,iter,-1); // why not append?
- } else {
- this.el.append(out citer,null);
- }
-
- this.el.set(citer, 0, tr.get(i).nodeTitle(),
- 1, tr.get(i).nodeTip(), -1
- );
- var o = new GLib.Value(typeof(Object));
- o.set_object((Object)tr.get(i));
-
- this.el.set_value(citer, 2, o);
-
- if (tr.get(i).items.size > 0) {
- this.load(tr.get(i).items, citer);
- }
-
- }
-
-
- },
- deleteSelected : () {
-
- 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.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;
- },
- project : "null",
- n_columns : 3,
- xns : Gtk,
- pathToNode : (string path) {
-
-
- Gtk.TreeIter iter;
- _this.model.el.get_iter_from_string(out iter, path);
-
- GLib.Value value;
- _this.model.el.get_value(iter, 2, out value);
-
- return (JsRender.Node)value.dup_object();
-
- },
- dropNode : (string target_data_str, JsRender.Node node, bool show_templates) {
- // print("drop Node");
- // console.dump(node);
- // console.dump(target_data);
-
-
- // 0 = before , 1=after 2/3 onto
-
-
- var target_data= target_data_str.split("|");
-
- var parent_str = target_data[0].length > 0 ? target_data[0] : "";
- var pos = target_data.length > 1 ? int.parse(target_data[1]) : 2; // ontop..
-
-
- Gtk.TreePath tree_path = parent_str.length > 0 ? new Gtk.TreePath.from_string( parent_str ) : null;
-
-
-
- //print("add " + tp + "@" + target_data[1] );
-
- JsRender.Node parentNode = null;
-
- Gtk.TreeIter iter_after;
- Gtk.TreeIter iter_par ;
-
-
- if (target_data.length == 3 && target_data[2].length > 0) {
- node.props.set("* prop", target_data[2]);
- }
-
- Gtk.TreePath expand_parent = null;
-
- // we only need to show the template if it's come from else where?
- if (show_templates) {
- var new_node = DialogTemplateSelect.singleton().show( this.file.palete(), node);
- if (new_node != null) {
- node = new_node;
- }
- }
-
- //print("pos is %d \n".printf(pos));
-
- Gtk.TreeIter n_iter;
-
- if ( parent_str.length < 1) {
- this.el.append(out n_iter, null); // drop at top level..
- node.parent = null;
- this.file.tree = node;
-
-
- } else if (pos < 2) {
- //print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
-
- this.el.get_iter(out iter_after, tree_path );
- this.el.iter_parent(out iter_par, iter_after);
- expand_parent = this.el.get_path(iter_par);
-
- GLib.Value value;
- this.el.get_value( iter_par, 2, out value);
- parentNode = (JsRender.Node)value.dup_object();
-
-
- this.el.get_value( iter_after, 2, out value);
- var relNode = (JsRender.Node)value.dup_object();
-
- if ( pos > 0 ) {
-
- this.el.insert_after(out n_iter, iter_par , iter_after);
- var ix = parentNode.items.index_of(relNode);
- parentNode.items.insert(ix+1, node);
-
- } else {
- this.el.insert_before(out n_iter, iter_par , iter_after);
- var ix = parentNode.items.index_of(relNode);
- parentNode.items.insert(ix, node);
-
- }
- node.parent = parentNode;
-
-
-
- } else {
- // print("appending to " + parent_str);
- this.el.get_iter(out iter_par, tree_path);
- this.el.append(out n_iter, iter_par );
- expand_parent = this.el.get_path(iter_par);
-
- GLib.Value value;
- this.el.get_value( iter_par, 2, out value);
- parentNode = (JsRender.Node)value.dup_object();
- node.parent = parentNode;
- parentNode.items.add(node);
- }
-
- // reparent node in tree...
-
-
- // why only on no parent???
-
- //if (node.parent = null) {
-
-
-
- //}
-
-
- // work out what kind of packing to use.. -- should be in
- if (!node.has("pack") && parent_str.length > 1) {
-
- this.file.palete().fillPack(node,parentNode);
-
-
- }
-
- // add the node...
-
- this.el.set(n_iter, 0, node.nodeTitle(), 1, node.nodeTip(), -1 );
- var o = new GLib.Value(typeof(Object));
- o.set_object((Object)node);
-
- this.el.set_value(n_iter, 2, o);
-
-
-
-
- // load children - if it has any..
-
- if (node.items.size > 0) {
- this.load(node.items, n_iter);
- _this.view.el.expand_row(this.el.get_path(n_iter), true);
- } else if (expand_parent != null && !_this.view.el.is_row_expanded(expand_parent)) {
- _this.view.el.expand_row(expand_parent,true);
- }
-
- //if (tp != null && (node.items.length() > 0 || pos > 1)) {
- // _this.view.el.expand_row(this.el.get_path(iter_par), true);
- // }
- // wee need to get the empty proptypes from somewhere..
-
- //var olditer = this.activeIter;
- this.activePath = this.el.get_path(n_iter).to_string();
-
-
-
-
- _this.view.el.set_cursor(this.el.get_path(n_iter), null, false);
- _this.changed();
-
-
-
- },
- listAllTypes : function() {
- var s = this.get('/LeftTree.view').selection;
- print ("LIST ALL TYPES: " + s.count_selected_rows() );
-
- if (s.count_selected_rows() > 0) {
- var iter = new Gtk.TreeIter();
- s.get_selected(this.el, iter);
-
- // set some properties of the tree for use by the dropped element.
- var value = new GObject.Value('');
- this.el.get_value(iter, 2, value);
- var data = JSON.parse(value.value);
-
-
- var xname = this.get('/LeftTree.model').file.guessName(data);
- console.log('selected:' + xname);
- if (xname.length) {
- return [ xname ];
- }
- return []; // could not find it..
- }
-
- var ret = [ ];
-
- var _this = this;
- function addall(li)
- {
- li.forEach(function(el) {
- // this is specific to roo!!!?
- if (!el) { // skip empty?
- return;
- }
- var fullpath = _this.file.guessName(el);
- if (fullpath.length && ret.indexOf(fullpath) < 0) {
- ret.push(fullpath);
- }
-
-
- if (el.items && el.items.length) {
- addall(el.items);
- }
-
- });
-
-
- }
-
- addall([this.currentTree]);
-
- // only if we have nothing, should we add '*top'
- if (!ret.length) {
- ret = [ '*top' ];
- }
- //console.log('all types in tree');
- //console.dump(ret);
-
- return ret;
-
- }
- },
- {
- title : "test",
- xtype : "TreeViewColumn",
- xns : Gtk,
- items : [
- {
- id : "renderer",
- xtype : "CellRendererText",
- xns : Gtk
- }
- ]
-
- }
- ]
-
- },
- {
- id : "LeftTreeMenu",
- xtype : "Menu",
- xns : Gtk,
- items : [
- {
- label : "Delete Element",
- xtype : "MenuItem",
- xns : Gtk,
- listeners : {
- activate : ( ) => {
-
- print("ACTIVATE?");
-
-
- _this.model.deleteSelected();
- }
- }
- },
- {
- label : "Save as Template",
- xtype : "MenuItem",
- xns : Gtk,
- listeners : {
- activate : () => {
-
- DialogSaveTemplate.singleton().show(
- (Gtk.Window) _this.el.get_toplevel (),
- _this.model.file.palete(),
- _this.getActiveElement()
- );
-
-
- }
- }
- },
- {
- label : "Save as Module",
- xtype : "MenuItem",
- xns : Gtk,
- listeners : {
- activate : () => {
- var node = _this.getActiveElement();
- var name = DialogSaveModule.singleton().show(
- (Gtk.Window) _this.el.get_toplevel (),
- _this.model.file.project,
- node
- );
- if (name.length < 1) {
- return;
-
- }
- node.props.set("* 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);
-
-
- }
- }
- }
- ]
-
- }
- ]
-
-});
-WindowLeftTree.init();
-XObject.cache['/WindowLeftTree'] = WindowLeftTree;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-WindowRightPalete=new XObject({
- id : "RightPalete",
- 'node)' : "",
- xtype : "VBox",
- 'node)' : "",
- load : (Palete.Palete pal, string cls ) {
-
- // this.get('model').expanded();
-
- var tr = pal.getChildList(cls);
- this.model.el.clear();
-
-
- Gtk.TreeIter citer;
-
- for(var i =0 ; i < tr.length; i++) {
- this.model.el.append(out citer);
-
- this.model.el.set_value(citer, 0, tr[i] ); // title
-
- }
- this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);
-
- },
- 'drag_end()' : "",
- xns : Gtk,
- clear : () {
- this.model.el.clear();
- },
- items : [
- {
- id : "viewbox",
- xtype : "VBox",
- xns : Gtk,
- items : [
- {
- shadow_type : Gtk.ShadowType.IN,
- xtype : "ScrolledWindow",
- xns : Gtk,
- items : [
- {
- dragData : "",
- xtype : "TreeView",
- enable_tree_lines : true,
- headers_visible : false,
- xns : Gtk,
- listeners : {
- button_press_event : ( event) => {
-
- // if (!this.get('/Editor').save()) {
- // // popup!! - click handled..
- // return true;
- // }
- return false;
- },
- drag_begin : ( ctx) => {
- // we could fill this in now...
- // Seed.print('SOURCE: drag-begin');
-
-
-
- Gtk.TreeIter iter;
- var s = this.el.get_selection();
-
- Gtk.TreeModel mod;
- s.get_selected(out mod, out iter);
- var path = mod.get_path(iter);
-
- /// pix is a surface..
- var pix = this.el.create_row_drag_icon ( path);
-
-
- Gtk.drag_set_icon_surface (ctx, pix);
- GLib.Value value;
-
-
- _this.model.el.get_value(iter, 0, out value);
-
- this.dragData = (string) value;
-
-
- return;
- },
- drag_end : ( drag_context) => {
- //Seed.print('SOURCE: drag-end');
-
- this.dragData = "";
- //this.dropList = null;
- _this.drag_end(); // call signal..
- //this.get('/LeftTree.view').highlight(false);
-
- },
- drag_data_get : (drag_context, selection_data, info, time) => {
- //Seed.print('Palete: drag-data-get: ' + target_type);
- if (this.dragData.length > 0 ) {
- print("setting drag data to %s", this.dragData);
- selection_data.set_text(this.dragData ,this.dragData.length);
- }
-
-
- //this.el.dragData = "TEST from source widget";
-
-
- }
- },
- items : [
- {
- getValue : (Gtk.TreeIter iter, int col) {
- GLib.Value gval;
- this.el.get_value(iter, col , out gval);
- return (string)gval;
-
-
- },
- id : "model",
- xtype : "ListStore",
- columns : typeof(string),typeof(string),
- n_columns : 2,
- xns : Gtk
- },
- {
- xtype : "TreeViewColumn",
- xns : Gtk,
- items : [
- {
- id : "txtrender",
- xtype : "CellRendererText",
- xns : Gtk
- }
- ]
-
- }
- ]
-
- }
- ]
-
- }
- ]
-
- }
- ]
-
-});
-WindowRightPalete.init();
-XObject.cache['/WindowRightPalete'] = WindowRightPalete;
+++ /dev/null
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
-console = imports.console;
-XObject = imports.XObject.XObject;
-WindowRooView=new XObject({
- id : "WindowRooView",
- createThumb : () {
-
-
- if (this.file == null) {
- return;
- }
- var filename = this.file.getIconFileName(false);
-
- var win = this.el.get_parent_window();
- var width = win.get_width();
- var height = win.get_height();
-
- Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, this.el.position);
-
- screenshot.save(filename,"png");
- return;
-
-
-
-
-
-
-
- var p = new WebKit.PrintOperation(_this.view.el);
-
- var ps = new Gtk.PrintSettings();
- ps.set_printer("Print to File");
- ps.set("output-file-format", "pdf");
- ps.set("output-uri", "file://" + filename + ".pdf");
-
- // find the printer...
-
- /*
- var ar = Gtk.PaperSize.get_paper_sizes(false);
- var psetup = new Gtk.PageSetup();
- for(var i = 0; i < ar.length(); i++) {
- if (ar.nth_data(i).get_name() =="iso_a4") {
- psetup.set_paper_size(ar.nth_data(i));
- }
- }
- psetup.set_orientation(Gtk.PageOrientation.LANDSCAPE);
-
-
- p.set_page_setup(psetup);
- */
- p.set_print_settings(ps);
-
- p.finished.connect(() => {
- print("creating thumbnail for " + filename + ".pdf\n");
- var s = new Cairo.PdfSurface(filename + ".pdf", 400,400);
-
- s.write_to_png (filename);
-
- // var f = GLib.File.new_for_path (filename + ".pdf");
- // f.delete();
- });
-
-
- p.print();
-
- // should we hold until it's printed...
-
-
-
-
-
-
-
-
-
- },
- loadFile : (JsRender.JsRender file)
- {
- this.file = file;
- this.view.renderJS(true);
- },
- xtype : "VPaned",
- file : "",
- requestRedraw : () {
- this.view.renderJS(false);
- },
- xns : Gtk,
- items : [
- {
- id : "viewbox",
- xtype : "VBox",
- xns : Gtk,
- homogeneous : FALSE,
- items : [
- {
- vexpand : FALSE,
- height_request : 20,
- xtype : "HBox",
- xns : Gtk,
- homogeneous : TRUE,
- items : [
- {
- label : "Redraw",
- xtype : "Button",
- xns : Gtk,
- listeners : {
- clicked : ( ) => {
- _this.view.renderJS( true);
- }
- }
- },
- {
- label : "Auto Redraw On",
- id : "AutoRedraw",
- active : TRUE,
- xtype : "CheckButton",
- xns : Gtk,
- listeners : {
- toggled : (state) => {
- this.el.set_label(this.el.active ? "Auto Redraw On" : "Auto Redraw Off");
- }
- }
- },
- {
- label : "Full Redraw",
- xtype : "Button",
- xns : Gtk,
- listeners : {
- clicked : () => {
- _this.view.redraws = 99;
- _this.view.el.web_context.clear_cache();
- _this.view.renderJS(true);
-
- }
- }
- }
- ]
-
- },
- {
- id : "viewcontainer",
- shadow_type : Gtk.ShadowType.IN,
- xtype : "ScrolledWindow",
- xns : Gtk,
- items : [
- {
- renderedData : "\"\"",
- id : "view",
- refreshRequired : false,
- redraws : 0,
- xtype : "WebView",
- inspector : "",
- redraws : 0,
- 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 = _this.file.project;
-
- //print (project.fn);
- // set it to non-empty.
-
- // runhtml = runhtml.length ? runhtml : '<script type="text/javascript"></script>';
-
-
- // 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 = "<script type=\"text/javascript\">\n" ;
- string builderhtml;
-
-
- GLib.FileUtils.get_contents(Builder4.Application.configDirectory() + "/resources/roo.builder.js", out builderhtml);
-
- runhtml += builderhtml + "\n";
- runhtml += "</script>\n" ;
-
- // fix to make sure they are the same..
- this.runhtml = project.runhtml;
- // need to modify paths
-
- string inhtml;
- var base_template = _this.file.project.base_template;
-
- if (base_template.length > 0 && !FileUtils.test(
- Builder4.Application.configDirectory() + "/resources/" + base_template, FileTest.EXISTS)
- ) {
- print("invalid base_template name - using default: %s\n", base_template);
- base_template = "";
-
- }
-
- GLib.FileUtils.get_contents(
- Builder4.Application.configDirectory() + "/resources/" +
- (base_template.length > 0 ? base_template : "roo.builder.html")
- , out inhtml);
-
-
- this.renderedData = js;
-
-
- string js_src = js + "\n" +
- "Roo.onReady(function() {\n" +
- "if (" + _this.file.name +".show) " + _this.file.name +".show({});\n" +
- "Roo.XComponent.build();\n" +
- "});\n";
-
- // print("render js: " + js);
- //if (!this.ready) {
- // console.log('not loaded yet');
- //}
- this.lastRedraw = new DateTime.now_local();
-
- var html = inhtml.replace("</head>", runhtml + this.runhtml +
-
- "<script type=\"text/javascript\">\n" +
- js_src + "\n" +
- "</script>" +
-
- "</head>");
- //print("LOAD HTML " + html);
-
- var rootURL = _this.file.project.rootURL;
-
-
-
- this.el.load_html( html ,
- //fixme - should be a config option!
- (rootURL.length > 0 ? rootURL : "http://localhost/app.Builder/")
- );
-
- // 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()));
-
- },
- xns : WebKit,
- initInspector : () {
-
- if (this.inspector == this.el.get_inspector()) {
- this.inspector.show();
- this.inspector.open_window();
- print("init inspecter called, and inspector is the same as existing\n");
- return;
- }
- print("new inspector?\n");
-
- this.inspector = this.el.get_inspector();
- this.inspector.ref();
-
- // got a new inspector...
-
- this.inspector.open_window.connect(() => {
- this.inspector = this.el.get_inspector();
- print("inspector attach\n");
- var wv = this.inspector.get_web_view();
- if (wv != null) {
- print("got inspector web view\n");
- _this.inspectorcontainer.el.add(wv);
- wv.show();
- } else {
- //this.inspector.close();
-
- //this.inspector = null;
-
-
- }
- return true;
-
- });
- this.inspector.closed.connect(() => {
- print("inspector closed?!?");
- // if this happens destroy the webkit..
- // recreate it..
- this.el.stop_loading();
- _this.viewbox.el.remove(_this.viewcontainer.el);
- _this.el.remove(_this.inspectorcontainer.el);
-
- // destory seems to cause problems.
- //this.el.destroy();
- //_this.viewcontainer.el.destroy();
- //_this.inspectorcontainer.el.destroy();
-
- this.el = null;
- var nv =new Xcls_viewcontainer(_this);
- nv.ref();
- _this.viewbox.el.pack_end(nv.el,true,true,0);
-
- var inv =new Xcls_inspectorcontainer(_this);
- inv.ref();
- _this.el.pack2(inv.el,true,true);
-
- inv.el.show_all();
- nv.el.show_all();
- //while(Gtk.events_pending ()) Gtk.main_iteration ();
- //_this.view.renderJS(true);
- _this.view.refreshRequired = true;
-
- });
-
- this.inspector.show();
- },
- lastRedraw : "null",
- runhtml : "\"\"",
- pendingRedraw : false,
- 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;
- },
- listeners : {
- script_dialog : (dialog) => {
- if (this.el == null) {
- return true;
- }
-
- var msg = dialog.get_message();
- if (msg.length < 4) {
- return false;
- }
- if (msg.substring(0,4) != "IPC:") {
- return false;
- }
- var ar = msg.split(":", 3);
- if (ar.length < 3) {
- return false;
- }
- switch(ar[1]) {
- case "SAVEHTML":
- _this.file.saveHTML(ar[2]);
- return true;
- default:
- return false;
- }
-
- },
- show : ( ) => {
- this.initInspector();;
- },
- drag_drop : ( ctx, x, y,time, ud) => {
- return false;
- /*
- print("TARGET: drag-drop");
- var is_valid_drop_site = true;
-
-
- Gtk.drag_get_data
- (
- w, // will receive 'drag-data-received' signal
- ctx, /* represents the current state of the DnD
- this.get('/Window').atoms["STRING"], /* the target type we want
- time /* time stamp
- );
-
-
- /* No target offered by source => error
-
-
- return is_valid_drop_site;
- */
- }
- }
- }
- ]
-
- }
- ]
-
- },
- {
- id : "inspectorcontainer",
- shadow_type : Gtk.ShadowType.IN,
- xtype : "ScrolledWindow",
- xns : Gtk
- }
- ]
-
-});
-WindowRooView.init();
-XObject.cache['/WindowRooView'] = WindowRooView;