src/Builder4/DialogTemplateSelect.bjs
authorAlan Knowles <alan@roojs.com>
Wed, 22 Apr 2015 08:35:16 +0000 (16:35 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 22 Apr 2015 08:35:16 +0000 (16:35 +0800)
src/Builder4/DialogTemplateSelect.vala

src/Builder4/DialogTemplateSelect.bjs
src/Builder4/DialogTemplateSelect.vala

index ae7214c..eeeafbb 100644 (file)
     "delete_event" : "  (self, event)  =>{\n    this.el.hide();\n    return true;\n}"
    },
    "default_width" : 400,
-   "title" : "Add an Object",
    "xtype" : "Dialog",
+   "title" : "Add an Object",
    "default_height" : 200,
    "$ modal" : true,
    "$ xns" : "Gtk",
-   "| JsRender.Node? show" : " (Gtk.Window pwindow, Palete.Palete pal, JsRender.Node node, Project.Project project) {\n    \n    this.el.show_all();\n    var opts = pal.listTemplates(node);\n    if (opts.length() < 1) {\n        this.el.hide();\n        return node;\n    }\n    this.el.set_attached_to( pwindow);\n     this.el.set_transient_for( pwindow);\n    \n    //opts.unshift({ path: '' , name :'Just add Element' });\n     _this.model.loadData(opts);\n     _this.combo.el.set_active(-1);\n     \n     \n     var db =  new Palete.RooDatabase.from_project(project);\n     _this.dbmodel.loadData(db.readTablesGee());\n     \n     \n     _this.dbcombo.el.set_active(-1);\n     \n     \n   \n    var res = this.el.run();\n    this.el.hide();    \n    //var ix = _this.combo.el.get_active();\n    if (res < 1 ) {\n        return null; // 0 = cancel.\n    }\n    if (res < 2 ) {\n        return node; // 1 = just add it..\n    }\n    \n   Gtk.TreeIter iter;\n    if (!_this.combo.el.get_active_iter (out iter)) {\n\n        return node; // nothing selected...\n    }\n    Value vfname;\n    this.model.el.get_value (iter, 0, out vfname);\n    \n    \n    return pal.loadTemplate((string)vfname);\n\n}\n",
+   "| JsRender.Node? show" : " (Xcls_MainWindow mwindow, Palete.Palete pal, JsRender.Node node, Project.Project project) {\n    \n    this.el.show_all();\n    var opts = pal.listTemplates(node);\n    if (opts.length() < 1) {\n        this.el.hide();\n        return node;\n    }\n    this.el.set_attached_to( mwindow.el);\n     this.el.set_transient_for( mwindow.el);\n    \n    //opts.unshift({ path: '' , name :'Just add Element' });\n     _this.model.loadData(opts);\n     _this.combo.el.set_active(-1);\n     \n     \n     var db =  new Palete.RooDatabase.from_project(project);\n     _this.dbmodel.loadData(db.readTablesGee());\n     \n     \n     _this.dbcombo.el.set_active(-1);\n     \n     \n   \n    var res = this.el.run();\n    this.el.hide();    \n    //var ix = _this.combo.el.get_active();\n    if (res < 1 ) {\n        return null; // 0 = cancel.\n    }\n    if (res < 2 ) {\n        return node; // 1 = just add it..\n    }\n    \n   Gtk.TreeIter iter;\n    if (!_this.combo.el.get_active_iter (out iter)) {\n\n        return node; // nothing selected...\n    }\n    Value vfname;\n    this.model.el.get_value (iter, 0, out vfname);\n    \n    \n    return pal.loadTemplate((string)vfname);\n\n}\n",
    "items" : [
     {
      "xtype" : "VBox",
      "$ xns" : "Gtk",
      "items" : [
       {
+       "gint margin" : 3,
        "* pack" : "pack_start,false,false,0",
        "xtype" : "HBox",
-       "gint margin" : 3,
        "$ xns" : "Gtk",
        "items" : [
         {
          "label" : "Select Template : ",
-         "xtype" : "Label",
          "* pack" : "pack_start,false,false",
+         "xtype" : "Label",
          "$ xns" : "Gtk"
         },
         {
          "items" : [
           {
            "id" : "cellrenderer",
-           "xtype" : "CellRendererText",
            "* pack" : "pack_start,true",
+           "xtype" : "CellRendererText",
            "$ xns" : "Gtk"
           },
           {
            "id" : "model",
-           "* pack" : "set_model",
            "xtype" : "ListStore",
+           "* pack" : "set_model",
            "$ columns" : "typeof(string),typeof(string)",
            "n_columns" : 2,
            "$ xns" : "Gtk",
        ]
       },
       {
+       "gint margin" : 3,
        "* pack" : "pack_start,false,false,0",
        "xtype" : "HBox",
-       "gint margin" : 3,
        "$ xns" : "Gtk",
        "items" : [
         {
          "label" : "Select Database Table : ",
-         "xtype" : "Label",
          "* pack" : "pack_start,false,false",
+         "xtype" : "Label",
          "$ xns" : "Gtk"
         },
         {
          "items" : [
           {
            "id" : "dbcellrenderer",
-           "xtype" : "CellRendererText",
            "* pack" : "pack_start,true",
+           "xtype" : "CellRendererText",
            "$ xns" : "Gtk"
           },
           {
            "id" : "dbmodel",
-           "* pack" : "set_model",
            "xtype" : "ListStore",
+           "* pack" : "set_model",
            "$ columns" : "typeof(string),typeof(string)",
            "n_columns" : 2,
            "$ xns" : "Gtk",
     },
     {
      "label" : "Cancel",
-     "xtype" : "Button",
      "* pack" : "add_action_widget,0",
+     "xtype" : "Button",
      "$ xns" : "Gtk"
     },
     {
      "label" : "Just add it",
-     "* pack" : "add_action_widget,1",
      "xtype" : "Button",
+     "* pack" : "add_action_widget,1",
      "$ xns" : "Gtk"
     },
     {
      "label" : "OK",
-     "xtype" : "Button",
      "* pack" : "add_action_widget,2",
+     "xtype" : "Button",
      "$ xns" : "Gtk"
     }
    ]
index 995c4b0..880aadb 100644 (file)
@@ -55,7 +55,7 @@ public class DialogTemplateSelect : Object
     }
 
     // user defined functions 
-    public JsRender.Node? show (Gtk.Window pwindow, Palete.Palete pal, JsRender.Node node, Project.Project project) {
+    public JsRender.Node? show (Xcls_MainWindow mwindow, Palete.Palete pal, JsRender.Node node, Project.Project project) {
         
         this.el.show_all();
         var opts = pal.listTemplates(node);
@@ -63,8 +63,8 @@ public class DialogTemplateSelect : Object
             this.el.hide();
             return node;
         }
-        this.el.set_attached_to( pwindow);
-         this.el.set_transient_for( pwindow);
+        this.el.set_attached_to( mwindow.el);
+         this.el.set_transient_for( mwindow.el);
         
         //opts.unshift({ path: '' , name :'Just add Element' });
          _this.model.loadData(opts);