X-Git-Url: http://git.roojs.org/?p=app.Builder.js;a=blobdiff_plain;f=tests%2Fmenu.vala;h=8423e05d867cd24a9f0d1ad4bb678da33d9d0ab4;hp=63ac91a2a26368775e9bbaa181802e1799370de3;hb=df1bc552d9ddc36cd32e7408ea1bd4082f08a5fd;hpb=9a56ba4d807b0e49b413d2d4f778c7032cc4a54e diff --git a/tests/menu.vala b/tests/menu.vala index 63ac91a2a..8423e05d8 100644 --- a/tests/menu.vala +++ b/tests/menu.vala @@ -18,186 +18,59 @@ int main (string[] args) { Gtk.init (ref args); GLib.Log.set_always_fatal(LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL); - - var a = new Xcls_WindowLeftTree(); - a.el.show_all(); - - Gtk.main(); + new Xcls_Window(); - - + Gtk.main(); return 0; } -public static Xcls_WindowLeftTree WindowLeftTree; - -public class Xcls_WindowLeftTree : Object -{ - public Gtk.Window el; - private Xcls_WindowLeftTree _this; - public Xcls_button button; - public Xcls_LeftTreeMenu LeftTreeMenu; - - // ctor - public void init() - { - base(); - this.el = new Gtk.Window( ); - _this = this; - WindowLeftTree = this; +public class Xcls_Window : Object { - // my vars - // set gobject values - - var child_0 = new Xcls_button(); child_0.init(_this); - this.el.add ( child_0.el ); - _this.LeftTreeMenu = new Xcls_LeftTreeMenu(_this); - - // init method - - - } - + public Xcls_Window() { + var w = new Gtk.Window( ); - // skip xvala_id - not pipe - public class Xcls_button : Object - { - public Gtk.Button el; - private Xcls_WindowLeftTree _this; - - // ctor - public void init(Xcls_WindowLeftTree _owner) - { - - this.el = new Gtk.Button.with_label ("Click me (0)"); - _this = _owner; - _this.button = this; - - - - // listeners - this.el.button_press_event.connect( ( ev) => { - //console.log("button press?"); - - - - if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) { - //print("click" + ev.type); - return false; - } + var b = new Gtk.Button.with_label ("Click me (0)"); + w.add(b); + var leftmenu = new Gtk.Menu(); + + b.button_press_event.connect( ( ev) => { + + if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) { + return false; + } - - //_this.LeftTreeMenu.el.set_screen(Gdk.Screen.get_default()); - - _this.LeftTreeMenu.el.popup(null, null, null, ev.button, ev.time); - - // print("click:" + res.path.to_string()); - return true; - } ); - - } - - - } - - - + leftmenu.popup(null, null, null, ev.button, ev.time); - public class Xcls_LeftTreeMenu : Object - { - public Gtk.Menu el; - private Xcls_WindowLeftTree _this; - - - // my vars - - // ctor - public void init(Xcls_WindowLeftTree _owner) - { - - print("Xcls_LeftTreeMenu:Ctor called\n"); - _this = _owner; - - - this.el = new Gtk.Menu(); - _this.LeftTreeMenu = this; - - // my vars - - // set gobject values - var child_0 = new Xcls_MenuItem7(); - child_0.init(_this); - this.el.append ( child_0.el ); - - var child_1 = new Xcls_MenuItem8(_this); - child_1.init(_this); - this.el.append ( child_1.el ); - this.el.show_all(); - } - - - } - public class Xcls_MenuItem7 : Object - { - public Gtk.MenuItem el; - private Xcls_WindowLeftTree _this; - - - // my vars - - // ctor - - public void init(Xcls_WindowLeftTree _owner) { - base(); - _this = _owner; - + return true; + } ); + + + var child_0 = new Xcls_MenuItem7(); + child_0.ref(); + child_0.init(this); + leftmenu.append ( child_0.el ); + leftmenu.show_all(); + w.show_all(); + + } + public class Xcls_MenuItem7 : Object + { + public Gtk.MenuItem el; + public Xcls_Window _this; + + public void init(Xcls_Window _owner ) { + //_this = _owner; this.el = new Gtk.MenuItem.with_label("Delete Element"); - // my vars - - // set gobject values - //this.el.label = "Delete Element"; - - // listeners - - print("add activate\n"); - this.el.activate.connect( ( ) => { - - print("SELECT?"); - + this.el.ref(); + print("add activate\n"); + this.el.activate.connect( ( ) => { + + print("SELECT?"); + return ; - } ); - } - - } - public class Xcls_MenuItem8 : Object - { - public Gtk.MenuItem el; - private Xcls_WindowLeftTree _this; - - - // my vars - - // ctor - public Xcls_MenuItem8(Xcls_WindowLeftTree _owner) - { - base(); - this.el = new Gtk.MenuItem(); - _this = _owner; - - // my vars - - // set gobject values - this.el.label = "Save as Template"; - - // listeners - this.el.activate.connect( () => { - - print("connect"); - - } ); - } + } ); + } - - } + } }