在Q5上用vala寫程式

來源:互聯網
上載者:User
如是,你比較喜歡C#的文法,但又但心它的效率,那麼vala是個不錯的選擇。
http://live.gnome.org/Vala
在mojo的源有vala的包,但版本較老,這裡編譯了一個目前的最新版0.7.4版,下載:vala-0.7.4.deb
控制台應用樣本: main.valausing GLib;

public class HelloVala: GLib.Object 
{
    public static int main (string[] args) 
    {
        stdout.printf ("Hello world!\n");
        
        return 0;
    }
}

編譯命令:valac -o main main.vala
./main

Gtk應用樣本:gtk-hello.valausing Gtk;

static int main (string[] args)
{
    Gtk.init (ref args);

    var window = new Window (WindowType.TOPLEVEL);
    window.title = "First GTK+ Program";
    window.set_default_size (300, 50);
    window.position = WindowPosition.CENTER;
    window.destroy += Gtk.main_quit;

    var button = new Button.with_label ("Click me!");
    button.clicked += (source) => 
    {
        source.label = "Thank you";
    };

    window.add (button);
    window.show_all ();

    Gtk.main ();
    return 0;
}

編譯命令:valac --pkg gtk+-2.0 gtk-hello.vala 
./gtk-hello

運行效果:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.