X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=tests%2Fmenu.vala;h=8423e05d867cd24a9f0d1ad4bb678da33d9d0ab4;hb=6f6e6ab99d47d1211e8f308cc7f2e88efc06503f;hp=41111f638024730f1f27582736cc5bd17268c402;hpb=6e3d749d7dc9a9cd7024509b7caad98d5f3781cf;p=app.Builder.js diff --git a/tests/menu.vala b/tests/menu.vala index 41111f638..8423e05d8 100644 --- a/tests/menu.vala +++ b/tests/menu.vala @@ -1,6 +1,6 @@ /* -- to compile -valac --pkg gio-2.0 --pkg posix --pkg gtk+-3.0 --pkg libnotify --pkg gtksourceview-3.0 --pkg libwnck-3.0 \ - /tmp/WindowLeftTree.vala -o /tmp/WindowLeftTree +valac --pkg gio-2.0 --pkg posix --pkg gtk+-3.0 \ + menu.vala -o /tmp/menutest */ @@ -13,218 +13,64 @@ static int main (string[] args) { return 0; } */ + +int main (string[] args) { + Gtk.init (ref args); + + GLib.Log.set_always_fatal(LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL); + 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_LeftTreeMenu LeftTreeMenu; - - // ctor - public Xcls_WindowLeftTree() - { - this.el = new Gtk.Window( ); - _this = this; - WindowLeftTree = this; - - // my vars - - // set gobject values - this.el.shadow_type = Gtk.ShadowType.IN; - var child_0 = new Xcls_button(_this); - this.el.add ( child_0.el ); - _this.LeftTreeMenu = new Xcls_LeftTreeMenu(_this); - - // init method - this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); - - } - +public class Xcls_Window : Object { - // skip xvala_id - not pipe - public class Xcls_button : Object - { - public Gtk.Button el; - private Xcls_WindowLeftTree _this; - - // ctor - public Xcls_button(Xcls_WindowLeftTree _owner) - { - this.el = new Gtk.Button.with_label ("Click me (0)"); - _this = _owner; - _this.button = this; - + public Xcls_Window() { + var w = new Gtk.Window( ); - // 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.show_all(); - _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 Xcls_LeftTreeMenu(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(_this); - this.el.add ( child_0.el ); - var child_1 = new Xcls_MenuItem8(_this); - this.el.add ( child_1.el ); - } - - // userdefined functions - - // skip id - not pipe - - // skip pack - not pipe - - // skip xtype - not pipe - - // skip |xns - no return type - - // skip items - not pipe - - // skip xvala_cls - not pipe - - // skip xvala_xcls - not pipe - - // skip xvala_id - not pipe - } - public class Xcls_MenuItem7 : Object - { - public Gtk.MenuItem el; - private Xcls_WindowLeftTree _this; - - - // my vars - - // ctor - public Xcls_MenuItem7(Xcls_WindowLeftTree _owner) - { - - _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"; - print("add activate\n"); - // listeners - - - this.el.select.connect( ( ) => { - - print("SELECT?"); - + this.el.ref(); + print("add activate\n"); + this.el.activate.connect( ( ) => { + + print("SELECT?"); + return ; - } ); - } - - // userdefined functions - - // skip listeners - not pipe - - // skip label - already used - - // skip pack - not pipe - - // skip xtype - not pipe - - // skip |xns - no return type - - // skip xvala_cls - not pipe - - // skip xvala_xcls - not pipe - - // skip xvala_id - not pipe - } - public class Xcls_MenuItem8 : Object - { - public Gtk.MenuItem el; - private Xcls_WindowLeftTree _this; - - - // my vars - - // ctor - public Xcls_MenuItem8(Xcls_WindowLeftTree _owner) - { - this.el = new Gtk.MenuItem(); - _this = _owner; - - // my vars - - // set gobject values - this.el.label = "Save as Template"; - - // listeners - this.el.activate.connect( () => { - - DialogSaveTemplate.show(_this.model.file.palete(), _this.getActiveElement()); - - - } ); - } - - // userdefined functions - - // skip listeners - not pipe - - // skip label - already used - - // skip pack - not pipe - - // skip xtype - not pipe - - // skip |xns - no return type - - // skip xvala_cls - not pipe - - // skip xvala_xcls - not pipe + } ); + } - // skip xvala_id - not pipe - } + } }