Re: [Vala] GTK and Property problems



Hi,

Why not simply using this:

[indent=4]

// Compile with

uses
    Gtk
    Gdk

class wMain : GLib.Object

    prop main_window : MainWindow

    init
        var main_window = new MainWindow()
        var main_viewport = new Viewport(null, null)

        main_window.scrolled_window.add(main_viewport)
        main_window.show_all()

        main_window.location_entry.activate.connect(on_location_activate)

    def on_show_menuitem_activate(show_menuitem:CheckMenuItem)
        if show_menuitem.active
            print "Toggled"
            main_window.show()
        else
            print "Not Toggled"
            main_window.hide()

    def on_location_activate(location_entry:Gtk.Entry)
        print "connected"



class MainWindow : Gtk.Window

    scrolled_window : ScrolledWindow
    toolbar : Toolbar
    back_button : ToolButton
    forward_button : ToolButton
    location_entry : Entry

    construct(type:Gtk.WindowType=Gtk.WindowType.TOPLEVEL)
        GLib.Object(type:type)
        this.set_default_size(900, 600)

    init
        this.delete_event.connect(on_mainwindow_delete_event)

        // Toolbar creation
        scrolled_window = new ScrolledWindow(null, null)
        var vbox = new VBox(false, 0)
        var toolbar_hbox = new HBox(true, 0)
        toolbar = new Toolbar()
        back_button = new ToolButton.from_stock("gtk-go-back")
        forward_button = new ToolButton.from_stock("gtk-go-forward")
        location_entry = new Entry()

        //Toolbar Packing
        toolbar.insert(back_button, -1)
        toolbar.insert(forward_button, -1)
        toolbar_hbox.pack_start(toolbar, false, true)
        toolbar_hbox.pack_start(location_entry, false, true)
        vbox.pack_start(toolbar_hbox, false, true)
        vbox.pack_start(scrolled_window, true, true)
        this.add(vbox)


    def on_mainwindow_delete_event() : bool
        this.hide()
        return true


init
    Gtk.init (ref args)
    new wMain()
    Gtk.main()

Sincerly,
Nicolas.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]