Clones.bjs
authorAlan Knowles <alan@roojs.com>
Tue, 30 Oct 2018 06:01:47 +0000 (14:01 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 30 Oct 2018 06:01:47 +0000 (14:01 +0800)
Clones.vala

Clones.bjs
Clones.vala

index b3a0bac..b0edbc1 100644 (file)
@@ -8,11 +8,15 @@
  "build_module" : "",
  "items" : [
   {
+   "listeners" : {
+    "delete_event" : "(self, event) => {\n    this.el.hide();\n    return true; \n    //test  \n}\n ",
+    "response" : "(self, response_id) =>  { \n \n        this.el.hide();\n  \n}"
+   },
    "default_width" : 600,
-   "| void show" : "(Gtk.Widget menuitem)    {\n\n\n\tGdk.Screen s;\n\tGdk.Rectange r;\n\tGtk.Orientation o;\n\t\n\tstatusicon.get_geometry( out s, out r, out o);\n\n   \n\tthis.el.set_relative_to( null );\n\tthis.el.set_pointing_to( r);\n\tthis.el.set_position(Gtk.PositionType.BOTTOM);\n\t\n    \n    \t//console.log('show all');\n\tthis.el.set_modal(true);\n\n\n\t\n//\tthis.el.popup();\n\t// window + header?\n\tthis.el.show_all();\n\tthis.el.set_size_request(800,500);\n\n\t//this.view.el.grab_focus();\n}\n",
    "$ deletable" : true,
+   "| void show" : "()    {\n\n    \n    this.el.set_deletable(false);\n    this.el.set_gravity(Gdk.Gravity.NORTH);\n    this.el.move(Gdk.Screen.width() / 2 ,0);\n    this.el.show_all();\n    // load clones..\n//     this.get('/reposStore').load();\n    \n    //this.get('/ok_button').el.set_sensitive(false);\n    \n    // block until we return.\n//    var run_ret = this.el.run();\n//    if (run_ret < 1 ) {\n//        return  \"DONE\";\n//    }\n//    print(\"RUN RETURN : \" + run_ret);\n//    return \"DONE\";\n    //print(JSON.stringify(this.get('bug').getValue()));\n   // return this.get('bug').getValue();\n    //this.success = c.success;\n}\n",
    "title" : "Manage Clones",
-   "xtype" : "Popover",
+   "xtype" : "Dialog",
    "default_height" : 500,
    "$ modal" : true,
    "$ xns" : "Gtk",
@@ -20,7 +24,7 @@
    "items" : [
     {
      "xtype" : "Box",
-     "$ pack" : "add",
+     "$ pack" : "get_content_area().add ",
      "$ xns" : "Gtk",
      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
      "items" : [
@@ -35,8 +39,8 @@
           "clicked" : "() => {\n\n/*    var rv = this.get('/reposView');\n    var rs = this.get('/reposStore');\n    if (rv.el.get_selection().count_selected_rows() != 1) {\n        //nothing?\n        // error condition.\n        return;\n    }\n    var Remotes =     imports.Remotes.Remotes;\n    \n \n    var ret = {};       \n    var s = rv.el.get_selection();\n    var path = '';\n    s.selected_foreach(function(model,p,iter) {\n                                                    \n       path = model.get_value(iter, 6).value.get_string();\n     \n    }); \n\n    var repo = false;\n    rs.repos.forEach(function(r) {\n        if (r.repopath == path) {\n            repo = r;\n        \n        }\n    \n    });\n    Remotes.repo = repo;\n    Remotes.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Remotes.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n  */   \n    \n     \n\n       \n    \n    \n}"
          },
          "label" : "Remotes / Clones",
-         "* pack" : "add",
          "xtype" : "Button",
+         "* pack" : "add",
          "$ xns" : "Gtk"
         },
         {
@@ -44,8 +48,8 @@
           "clicked" : "() => {\n/*\n    var rv = this.get('/reposView');\n    var rs = this.get('/reposStore');\n    if (rv.el.get_selection().count_selected_rows() != 1) {\n        //nothing?\n        // error condition.\n        return;\n    }\n    var Branches =     imports.Branches.Branches;\n    \n \n    var ret = {};       \n    var s = rv.el.get_selection();\n    var path = '';\n    s.selected_foreach(function(model,p,iter) {\n                                                    \n       path = model.get_value(iter, 6).value.get_string();\n     \n    }); \n\n    var repo = false;\n    rs.repos.forEach(function(r) {\n        if (r.repopath == path) {\n            repo = r;\n        \n        }\n    \n    });\n    Branches.repo = repo;\n    Branches.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Branches.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n     \n    \n    \n    \n\n       \n */   \n    \n}"
          },
          "label" : "Branches",
-         "* pack" : "add",
          "xtype" : "Button",
+         "* pack" : "add",
          "$ xns" : "Gtk"
         },
         {
@@ -53,8 +57,8 @@
           "clicked" : "() =>  {\n/*\n    var rv = this.get('/reposView');\n    var rs = this.get('/reposStore');\n    if (rv.el.get_selection().count_selected_rows() != 1) {\n        //nothing?\n        // error condition.\n        return;\n    }\n    var Merger =     imports.Merger.Merger;\n    \n \n    var ret = {};       \n    var s = rv.el.get_selection();\n    var path = '';\n    s.selected_foreach(function(model,p,iter) {\n                                                    \n       path = model.get_value(iter, 6).value.get_string();\n     \n    }); \n\n    var repo = false;\n    rs.repos.forEach(function(r) {\n        if (r.repopath == path) {\n            repo = r;\n        \n        }\n    \n    });\n    Merger.repo = repo;\n    Merger.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Merger.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n    \n    \n\n     \n    \n\n */      \n    \n    \n}"
          },
          "label" : "Merge",
-         "* pack" : "add",
          "xtype" : "Button",
+         "* pack" : "add",
          "$ xns" : "Gtk"
         },
         {
@@ -62,8 +66,8 @@
           "clicked" : "() => {\n    \n    \n \n       \n    \n    \n}"
          },
          "label" : "Switch Branch",
-         "* pack" : "add",
          "xtype" : "Button",
+         "* pack" : "add",
          "$ xns" : "Gtk"
         },
         {
@@ -71,8 +75,8 @@
           "clicked" : "() => {\n    \n    \n \n       \n    \n    \n}"
          },
          "label" : "Pull",
-         "* pack" : "add",
          "xtype" : "Button",
+         "* pack" : "add",
          "$ xns" : "Gtk"
         }
        ]
@@ -81,7 +85,7 @@
        "* init" : "  {\n  \n   this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n",
        "bool expand" : true,
        "xtype" : "ScrolledWindow",
-       "* pack" : "add",
+       "* pack" : "pack_end,false,false,0",
        "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN",
        "$ xns" : "Gtk",
        "items" : [
               "toggled" : "  (self, path)  => {\n/*    var ret ={} ;\n    var store = this.get('/reposStore');\n    store.el.get_iter_from_string(ret, path);\n                                                                 \n    var value =   store.el.get_value(ret.iter,4).value.get_boolean();\n                                                                 \n    //print(JSON.stringify(value));\n    store.el.set_value(ret.iter,4, !value);\n    \n     var path =  store.el.get_value(ret.iter, 6).value.get_string();\n     var repo = imports.Scm.Repo.Repo.get(path);\n     repo.autocommit(!value);\n  */   \n    \n    \n}"
              },
              "id" : "cr_autocommit",
-             "* pack" : "pack_start,false",
              "xtype" : "CellRendererToggle",
+             "* pack" : "pack_start,false",
              "$ xns" : "Gtk",
              "$ mode" : "Gtk.CellRendererMode.ACTIVATABLE"
             }
               "toggled" : "  (self, path)  => {\n/*    var ret ={} ;\n    var store = this.get('/reposStore');\n    store.el.get_iter_from_string(ret, path);\n                                                                 \n    var value =   store.el.get_value(ret.iter,5).value.get_boolean();\n                                                                 \n    //print(JSON.stringify(value));\n    store.el.set_value(ret.iter,5, !value);\n      var path =  store.el.get_value(ret.iter, 6).value.get_string();\n     var repo = imports.Scm.Repo.Repo.get(path);\n     repo.autopush(!value);\n    */\n}"
              },
              "id" : "cr_autopush",
-             "* pack" : "pack_start,false",
              "xtype" : "CellRendererToggle",
+             "* pack" : "pack_start,false",
              "$ xns" : "Gtk",
              "$ mode" : "Gtk.CellRendererMode.ACTIVATABLE"
             }
            "items" : [
             {
              "id" : "cr_repo",
-             "* pack" : "pack_start,false",
              "xtype" : "CellRendererText",
+             "* pack" : "pack_start,false",
              "$ xns" : "Gtk"
             }
            ]
            "items" : [
             {
              "id" : "cr_current_branch",
-             "* pack" : "pack_start,false",
              "xtype" : "CellRendererText",
+             "* pack" : "pack_start,false",
              "$ xns" : "Gtk"
             }
            ]
            "items" : [
             {
              "id" : "cr_last_updated",
-             "* pack" : "pack_start,false",
              "xtype" : "CellRendererText",
+             "* pack" : "pack_start,false",
              "$ xns" : "Gtk"
             }
            ]
            "items" : [
             {
              "id" : "cr_all_branches",
-             "* pack" : "pack_start,false",
              "xtype" : "CellRendererText",
+             "* pack" : "pack_start,false",
              "$ xns" : "Gtk"
             }
            ]
          ]
         }
        ]
-      },
-      {
-       "label" : "Close",
-       "id" : "ok_button",
-       "* pack" : "add",
-       "xtype" : "Button",
-       "$ xns" : "Gtk"
       }
      ]
+    },
+    {
+     "label" : "Close",
+     "id" : "ok_button",
+     "* pack" : "add_action_widget,1 ",
+     "xtype" : "Button",
+     "$ xns" : "Gtk"
     }
    ]
   }
index 3cfbb00..51de068 100644 (file)
@@ -2,7 +2,7 @@ static Clones  _Clones;
 
 public class Clones : Object
 {
-    public Gtk.Popover el;
+    public Gtk.Dialog el;
     private Clones  _this;
 
     public static Clones singleton()
@@ -34,45 +34,60 @@ public class Clones : Object
     public Clones()
     {
         _this = this;
-        this.el = new Gtk.Popover( null );
+        this.el = new Gtk.Dialog();
 
         // my vars (dec)
 
         // set gobject values
+        this.el.title = "Manage Clones";
         this.el.border_width = 3;
+        this.el.default_height = 500;
+        this.el.default_width = 600;
+        this.el.deletable = true;
         this.el.modal = true;
         var child_0 = new Xcls_Box2( _this );
         child_0.ref();
-        this.el.add (  child_0.el  );
+        this.el.get_content_area().add (  child_0.el  );
+        var child_1 = new Xcls_ok_button( _this );
+        child_1.ref();
+        this.el.add_action_widget (  child_1.el , 1  );
+
+        //listeners
+        this.el.delete_event.connect( (self, event) => {
+            this.el.hide();
+            return true; 
+            //test  
+        });
+        this.el.response.connect( (self, response_id) =>  { 
+         
+                this.el.hide();
+          
+        });
     }
 
     // user defined functions
-    public void show (Gtk.Widget menuitem)    {
+    public void show ()    {
     
-    
-       Gdk.Screen s;
-       Gdk.Rectange r;
-       Gtk.Orientation o;
-       
-       statusicon.get_geometry( out s, out r, out o);
-    
-       
-       this.el.set_relative_to( null );
-       this.el.set_pointing_to( r);
-       this.el.set_position(Gtk.PositionType.BOTTOM);
-       
         
-               //console.log('show all');
-       this.el.set_modal(true);
-    
-    
-       
-    // this.el.popup();
-       // window + header?
-       this.el.show_all();
-       this.el.set_size_request(800,500);
-    
-       //this.view.el.grab_focus();
+        this.el.set_deletable(false);
+        this.el.set_gravity(Gdk.Gravity.NORTH);
+        this.el.move(Gdk.Screen.width() / 2 ,0);
+        this.el.show_all();
+        // load clones..
+    //     this.get('/reposStore').load();
+        
+        //this.get('/ok_button').el.set_sensitive(false);
+        
+        // block until we return.
+    //    var run_ret = this.el.run();
+    //    if (run_ret < 1 ) {
+    //        return  "DONE";
+    //    }
+    //    print("RUN RETURN : " + run_ret);
+    //    return "DONE";
+        //print(JSON.stringify(this.get('bug').getValue()));
+       // return this.get('bug').getValue();
+        //this.success = c.success;
     }
     public class Xcls_Box2 : Object
     {
@@ -96,10 +111,7 @@ public class Clones : Object
             this.el.pack_start (  child_0.el , false,false,0 );
             var child_1 = new Xcls_ScrolledWindow9( _this );
             child_1.ref();
-            this.el.add (  child_1.el  );
-            var child_2 = new Xcls_ok_button( _this );
-            child_2.ref();
-            this.el.add (  child_2.el  );
+            this.el.pack_end (  child_1.el , false,false,0 );
         }
 
         // user defined functions
@@ -937,6 +949,7 @@ public class Clones : Object
 
 
 
+
     public class Xcls_ok_button : Object
     {
         public Gtk.Button el;
@@ -961,5 +974,4 @@ public class Clones : Object
         // user defined functions
     }
 
-
 }