src/Builder4/PopoverFileDetails.bjs
authorAlan Knowles <alan@roojs.com>
Fri, 13 Nov 2015 07:00:51 +0000 (15:00 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 13 Nov 2015 07:00:51 +0000 (15:00 +0800)
src/Builder4/PopoverFileDetails.vala

src/Builder4/PopoverFileDetails.bjs
src/Builder4/PopoverFileDetails.vala

index 8fffed7..98675c7 100644 (file)
@@ -12,8 +12,8 @@
     "closed" : "() => {\n  if (!this.done) {\n    _this.el.show();\n  \n  }\n} "
    },
    "|   void updateFileFromEntry" : "() {\n\n        _this.file.title = _this.title.el.get_text();\n        _this.file.region = _this.region.el.get_text();            \n        _this.file.parent = _this.parent.el.get_text();                        \n        _this.file.permname = _this.permname.el.get_text();                                    \n        _this.file.modOrder = _this.modOrder.el.get_text();\n        \n        if (_this.file.name.length  > 0 && _this.file.name != _this.name.el.get_text()) {\n            _this.file.renameTo(_this.name.el.get_text());\n        }\n        // store the module...\n        _this.file.build_module = \"\";        \n         Gtk.TreeIter iter; \n        if (_this.build_module.el.get_active_iter (out iter)) {\n             Value vfname;\n             this.dbmodel.el.get_value (iter, 0, out vfname);\n             if (((string)vfname).length > 0) {\n                 _this.file.build_module = (string)vfname;\n             }\n    \n        }\n        \n        \n\n                                                    \n}    ",
-   "id" : "PopoverFileDetails",
    "@ void success" : "(Project.Project pr, JsRender.JsRender file)",
+   "id" : "PopoverFileDetails",
    "| void show" : "(JsRender.JsRender c, Gtk.Widget btn) \n{\n    this.project = c.project;\n    this.done = false;\n    \n    \n    //if (!this.el) {\n        //this.init();\n     //}\n    \n    _this.name.el.set_text(c.name);\n    _this.title.el.set_text(c.title);\n    _this.parent.el.set_text(c.parent);    \n    _this.region.el.set_text(c.region);\n    _this.modOrder.el.set_text(c.modOrder);\n     _this.permname.el.set_text(c.permname);\n    \n    \n    \n    \n    \n    \n    \n    if (c.path.length > 0) {\n\t\t \n\t    this.save_btn.el.set_label(\"Save\");\n    } else {\n        this.save_btn.el.set_label(\"Create\");\n        \n\t   \n    }\n    \n     var ar = new Gee.ArrayList<string>();\n     _this.dbmodel.loadData(ar,\"\");\n    // load the modules... if relivant..\n    if (this.project.xtype == \"Gtk\") {\n        var p = (Project.Gtk)c.project;\n          var cg = p.compilegroups;\n\n        var iter = cg.map_iterator();\n       while(iter.next()) {\n            var key = iter.get_key();\n            if (key == \"_default_\") {\n                continue;\n            }\n            ar.add(key);\n        };\n        _this.dbmodel.loadData(ar, c.build_module);\n\n    }\n    \n     \n    _this.file = c;\n    //console.log('show all');\n   this.el.set_modal(true);\n    this.el.set_relative_to(btn);\n\n    this.el.set_position(Gtk.PositionType.RIGHT);\n    \n    // window + header?\n     print(\"SHOWALL - POPIP\\n\");\n    this.el.show_all();\n    this.name.el.grab_focus();\n    \n    \n    \n    if (c.path.length > 0) {\n\t\t_this.filetype.el.hide();\n\t\t_this.filetypelbl.el.hide();\n \n    } else {\n        \n        _this.ftdbmodel.loadData(\"bjs\"); // fixme - need to determine type..\n\t    _this.filetype.el.show();\n\t    _this.filetypelbl.el.show();\n    }\n    \n    \n    //this.success = c.success;\n    \n    \n}",
    "bool done" : false,
    "# Project.Project project" : "",
@@ -27,8 +27,8 @@
    "items" : [
     {
      "bool homogeneous" : false,
-     "$ pack" : "add",
      "xtype" : "Box",
+     "$ pack" : "add",
      "$ xns" : "Gtk",
      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
      "items" : [
          "items" : [
           {
            "id" : "ftdbcellrenderer",
-           "xtype" : "CellRendererText",
            "* pack" : "pack_start,true",
+           "xtype" : "CellRendererText",
            "$ xns" : "Gtk"
           },
           {
            "id" : "ftdbmodel",
-           "xtype" : "ListStore",
            "* pack" : "set_model",
+           "xtype" : "ListStore",
            "$ columns" : "typeof(string),typeof(string)",
            "n_columns" : 2,
            "$ xns" : "Gtk",
         },
         {
          "label" : "Region",
-         "tooltip_text" : "center, north, south, east, west",
          "$ visible" : true,
+         "tooltip_text" : "center, north, south, east, west",
          "xalign" : 0.90000000000000002,
          "* pack" : "attach,0,3,1,1",
          "xtype" : "Label",
          "items" : [
           {
            "id" : "dbcellrenderer",
-           "* pack" : "pack_start,true",
            "xtype" : "CellRendererText",
+           "* pack" : "pack_start,true",
            "$ xns" : "Gtk"
           },
           {
            "id" : "dbmodel",
-           "* pack" : "set_model",
            "xtype" : "ListStore",
+           "* pack" : "set_model",
            "$ columns" : "typeof(string),typeof(string)",
            "n_columns" : 2,
            "$ xns" : "Gtk",
         }
        ]
       },
+      {
+       "label" : "Module to build (Vala only)",
+       "$ visible" : true,
+       "xalign" : 0.90000000000000002,
+       "* pack" : "attach,0,7,1,1",
+       "xtype" : "Label",
+       "$ justify" : "Gtk.Justification.RIGHT",
+       "x_options" : 4,
+       "$ xns" : "Gtk"
+      },
       {
        "int margin_bottom" : 4,
        "int margin_right" : 4,
          "listeners" : {
           "clicked" : "() => { \n\n  _this.done = true;\n    _this.el.hide(); \n}"
          },
+         "string label" : "Cancel",
          "* pack" : "add",
          "xtype" : "Button",
-         "string label" : "Cancel",
          "$ xns" : "Gtk"
         },
         {
          "listeners" : {
-          "clicked" : "( ) =>  { \n\n \n\n\n\tif (_this.name.el.get_text().length  < 1) {\n\t    StandardErrorDialog.show(\n\t        _this.mainwindow.el,\n\t        \"You have to set Component name \"\n\t    );\n\t     \n\t    return;\n\t}\n\t// what does this do?\n\t\n\tvar isNew = _this.file.name.length  > 0 ? false : true;\n\t/*\n\tif (!isNew && this.file.name != _this.name.el.get_text()) {\n\t    Xcls_StandardErrorDialog.singleton().show(\n\t        this.el,\n\t        \"Sorry changing names does not work yet. \"\n\t    );\n\t     \n\t    return;\n\t}\n\t*/\n\t \n\t\n  \n\t// FIXME - this may be more complicated...\n\t//for (var i in this.def) {\n\t//    this.file[i] =  this.get(i).el.get_text();\n\t//}\n\n\tif (!isNew) {\n\t    try {\n\t         _this.updateFileFromEntry();\n\t     } catch( JsRender.Error.RENAME_FILE_EXISTS er) {\n\t          Xcls_StandardErrorDialog.singleton().show(\n\t            _this.mainwindow.el,\n\t            \"The name you used already exists \"\n\t        );\n\t        return;\n\t         \n\t     }\n\n\t      _this.done = true;\n\t    _this.file.save();\n\t    _this.el.hide();\n\t    return;\n\t}\n\t\n\t// ---------------- NEW FILES...\n\t\n\tvar fn = _this.name.el.get_text();\n\tvar dir = _this.project.firstPath();   // fixme.. should be based on a pulldown?\n\t\n\tvar targetfile = dir + \"/\" + fn;\n\t\n\t// strip the file type off the end..\n\tGtk.TreeIter iter;\n\n\tif (!_this.filetype.el.get_active_iter(out iter)) {\n\t\t// should not happen...\n\t\t// so we are jut going to return without \n\t\tStandardErrorDialog.show(\n\t        _this.mainwindow.el,\n\t        \"You must select a file type. \"\n\t    );\n\t}\n\tValue ftypename;\n\t_this.ftdbmodel.el.get_value (iter, 0, out ftypename);\n\tvar ext = ((string)ftypename);\n\t\n    var rx = new GLib.Regex(\"\\\\.\" + ext + \"$\",GLib.RegexCompileFlags.CASELESS);\n    targetfile = rx.replace(targetfile, targetfile.length, 0, \"\"); \n   \n\tif (GLib.FileUtils.test(targetfile + \".\" + ext, GLib.FileTest.EXISTS)) {\n\t    Xcls_StandardErrorDialog.singleton().show(\n\t        _this.mainwindow.el,\n\t        \"That file already exists\"\n\t    ); \n\t    return;\n\t}\n   \n   var f =  JsRender.JsRender.factory(\n\t\text == \"bjs\" ? _this.file.project.xtype : \"PlainFile\",  \n\t\t_this.file.project, \n\t\ttargetfile + \".\" + ext);\n\n\t_this.file = f;\n\t\n\n\t\n\t_this.updateFileFromEntry();\n\t_this.file.loaded = true;\n\t_this.file.save();\n\tif (ext == \"bjs\") {\n\t\t_this.file.project.addFile(_this.file);\n\t}\n\t\n \n\t// what about .js ?\n   _this.done = true;\n\t_this.el.hide();\n\n\t\n\t\n\t_this.success(_this.project, _this.file);\n   \n}"
+          "clicked" : "( ) =>  { \n\n \n\n\n\tif (_this.name.el.get_text().length  < 1) {\n\t    StandardErrorDialog.show(\n\t        _this.mainwindow.el,\n\t        \"You have to set Component name \"\n\t    );\n\t     \n\t    return;\n\t}\n\t// what does this do?\n\t\n\tvar isNew = _this.file.name.length  > 0 ? false : true;\n\t/*\n\tif (!isNew && this.file.name != _this.name.el.get_text()) {\n\t    Xcls_StandardErrorDialog.singleton().show(\n\t        this.el,\n\t        \"Sorry changing names does not work yet. \"\n\t    );\n\t     \n\t    return;\n\t}\n\t*/\n\t \n\t\n  \n\t// FIXME - this may be more complicated...\n\t//for (var i in this.def) {\n\t//    this.file[i] =  this.get(i).el.get_text();\n\t//}\n\n\tif (!isNew) {\n\t    try {\n\t         _this.updateFileFromEntry();\n\t     } catch( JsRender.Error.RENAME_FILE_EXISTS er) {\n\t          Xcls_StandardErrorDialog.singleton().show(\n\t            _this.mainwindow.el,\n\t            \"The name you used already exists \"\n\t        );\n\t        return;\n\t         \n\t     }\n\n\t      _this.done = true;\n\t    _this.file.save();\n\t    _this.el.hide();\n\t    return;\n\t}\n\t\n\t// ---------------- NEW FILES...\n\t\n\tvar fn = _this.name.el.get_text();\n\tvar dir = _this.project.firstPath();   // fixme.. should be based on a pulldown?\n\t\n\tvar targetfile = dir + \"/\" + fn;\n\t\n\t// strip the file type off the end..\n\tGtk.TreeIter iter;\n\n\tif (!_this.filetype.el.get_active_iter(out iter)) {\n\t\t// should not happen...\n\t\t// so we are jut going to return without \n\t\tStandardErrorDialog.show(\n\t        _this.mainwindow.el,\n\t        \"You must select a file type. \"\n\t    );\n\t}\n\tValue ftypename;\n\t_this.ftdbmodel.el.get_value (iter, 0, out ftypename);\n\tvar ext = ((string)ftypename);\n\t\n    var rx = new GLib.Regex(\"\\\\.\" + ext + \"$\",GLib.RegexCompileFlags.CASELESS);\n    targetfile = rx.replace(targetfile, targetfile.length, 0, \"\"); \n   \n\tif (GLib.FileUtils.test(targetfile + \".\" + ext, GLib.FileTest.EXISTS)) {\n\t    Xcls_StandardErrorDialog.singleton().show(\n\t        _this.mainwindow.el,\n\t        \"That file already exists\"\n\t    ); \n\t    return;\n\t}\n   \n   var f =  JsRender.JsRender.factory(\n\t\text == \"bjs\" ? _this.file.project.xtype : \"PlainFile\",  \n\t\t_this.file.project, \n\t\ttargetfile + \".\" + ext);\n\n\t_this.file = f;\n\t\n\n\t\n\t_this.updateFileFromEntry();\n\t_this.file.loaded = true;\n\t_this.file.save();\n\tif (ext == \"bjs\") {\n\t\t_this.file.project.addFile(_this.file);\n\t}\n\t\n \n\t// what about .js ?\n   _this.done = true;\n\t_this.el.hide();\n\n// hopefull this will work with bjs files..\n\t\n\t_this.success(_this.project, _this.file);\n   \n}"
          },
          "id" : "save_btn",
-         "* pack" : "add",
          "xtype" : "Button",
+         "* pack" : "add",
          "string label" : "Save",
          "$ xns" : "Gtk"
         }
index 4bdf83c..4bad38b 100644 (file)
@@ -197,9 +197,12 @@ public class Xcls_PopoverFileDetails : Object
             var child_1 = new Xcls_grid( _this );
             child_1.ref();
             this.el.pack_start (  child_1.el , false,false,4 );
-            var child_2 = new Xcls_HButtonBox25( _this );
+            var child_2 = new Xcls_Label25( _this );
             child_2.ref();
-            this.el.pack_end (  child_2.el , false,true,0 );
+            this.el.attach (  child_2.el , 0,7,1,1 );
+            var child_3 = new Xcls_HButtonBox26( _this );
+            child_3.ref();
+            this.el.pack_end (  child_3.el , false,true,0 );
         }
 
         // user defined functions
@@ -914,7 +917,32 @@ public class Xcls_PopoverFileDetails : Object
 
 
 
-    public class Xcls_HButtonBox25 : Object
+    public class Xcls_Label25 : Object
+    {
+        public Gtk.Label el;
+        private Xcls_PopoverFileDetails  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Label25(Xcls_PopoverFileDetails _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Label( "Module to build (Vala only)" );
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.justify = Gtk.Justification.RIGHT;
+            this.el.xalign = 0.900000f;
+            this.el.visible = true;
+        }
+
+        // user defined functions
+    }
+
+    public class Xcls_HButtonBox26 : Object
     {
         public Gtk.HButtonBox el;
         private Xcls_PopoverFileDetails  _this;
@@ -923,7 +951,7 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor
-        public Xcls_HButtonBox25(Xcls_PopoverFileDetails _owner )
+        public Xcls_HButtonBox26(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
             this.el = new Gtk.HButtonBox();
@@ -934,7 +962,7 @@ public class Xcls_PopoverFileDetails : Object
             this.el.margin_right = 4;
             this.el.margin_left = 4;
             this.el.margin_bottom = 4;
-            var child_0 = new Xcls_Button26( _this );
+            var child_0 = new Xcls_Button27( _this );
             child_0.ref();
             this.el.add (  child_0.el  );
             var child_1 = new Xcls_save_btn( _this );
@@ -944,7 +972,7 @@ public class Xcls_PopoverFileDetails : Object
 
         // user defined functions
     }
-    public class Xcls_Button26 : Object
+    public class Xcls_Button27 : Object
     {
         public Gtk.Button el;
         private Xcls_PopoverFileDetails  _this;
@@ -953,7 +981,7 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor
-        public Xcls_Button26(Xcls_PopoverFileDetails _owner )
+        public Xcls_Button27(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
             this.el = new Gtk.Button();
@@ -1101,7 +1129,7 @@ public class Xcls_PopoverFileDetails : Object
                _this.done = true;
                _this.el.hide();
             
-               
+            // hopefull this will work with bjs files..
                
                _this.success(_this.project, _this.file);