Changes between Version 84 and Version 85 of Developing your own applications


Ignore:
Timestamp:
Jan 18, 2011, 10:14:19 PM (7 years ago)
Author:
Ben
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Developing your own applications

    v84 v85  
    124124Once you have successfully completed the steps above, you may wish to know how to add a Graphical User Interface (GUI). The next steps will show how to adapt the Hello World program to use the Elementary widget set.
    125125
     126=== 1. Creating a source folder ===
     127{{{
     128$ cd /path/to/shr/build
     129$ mkdir myfirstgui
     130$ cd myfirstgui
     131}}}
     132 
     133=== 2. Writing a Hello World GUI in Vala and Elementary ===
     134Create and enter a sub folder for the source:
     135{{{
     136$ mkdir src
     137$ cd src
     138}}}
     139Create a file called '''myfirstgui.vala''' and insert the following text:
     140{{{
     141using Elm;
    126142
    127  
     143private void win_del()
     144{
     145        Elm.exit();
     146}
    128147
     148class Demo.HelloWorldGui : GLib.Object
     149{
     150        public static int main(string[] args)
     151        {
     152                Elm.init(args);
     153
     154                Win win = new Win(null, "hello", WinType.BASIC);
     155                win.title_set("Hello");
     156                win.smart_callback_add("delete-request", win_del);
     157   
     158                Bg bg = new Bg(win);
     159                bg.size_hint_weight_set(1.0, 1.0);
     160                win.resize_object_add(bg);
     161                bg.show();
     162
     163                Label lb = new Label(win);
     164                lb.label_set("Hello World!");
     165                lb.size_hint_weight_set(1.0, 1.0);
     166                win.resize_object_add(lb);
     167                lb.show();
     168
     169                win.show();
     170
     171                Elm.run();
     172                Elm.shutdown();
     173
     174                return 0;
     175        }
     176}
     177}}}
     178
     179More information about Vala can be found here: [http://live.gnome.org/Vala/Tutorial]
     180