Guadec Day 1

Today the Guadec started at 15:00 with a conference about GnomeShell the new main user interface of Gnome and future substitute of gnome-panel. Owen Taylor explained us the new shell that it’s a really interesting idea based in top of javascript and gobject-introspection.

The next conference was about GnomeZeitgeist . This is an app for easily find files in your computer but the method of search is based in the date when you work with this file. So you can find the file you open two weeks ago for example.

The other great new is that ebassi announce us in his conference about Clutter that the next week will be released the 1.0 version of clutter (API/ABI stable in 1.x). Wow !!

Vala examples III

Working with strings. Can i concat strings ? Can i compare two strings ? Sureeeee 🙂


/* string1.vala                       */
/* valac -o string1 string1.vala */
using GLib;

public class Sample : Object {
        public Sample () {
        }

        public void concat_example () {
                string s1 = "hello, " ;
                string s2 = "my name is telemaco" ;

                stdout.printf("contat: %s\n", s1.concat(s2)) ;
        }

        public void are_equal (string str1, string str2) {
                stdout.printf("are_equal: ");
                if (str1 == str2) {
                        stdout.printf("%s == %s\n", str1, str2);
                }
                else
                {
                        stdout.printf("%s != %s\n", str1, str2);
                }
        }

        static int main (string[] args) {
                var sample = new Sample ();
                sample.concat_example ();
                sample.are_equal("apple", "orange");
                sample.are_equal("apple", "apple");
                return 0;
        }
}

Vala examples II

Today, we learn the basic vala types, very similar to C types .


/* types.vala                          */
/* valac -o types types.vala      */

using GLib;

public class Sample : Object {

        public int integer1 = 1 ;
        public char character1 = 'a' ;
        public long long1 = 1 ;
        public double double1 = 0.1 ;
        public string string1 = "Hello !!" ;

        public Sample () {
        }

        public void show_class_variables () {
                stdout.printf ("integer1 value => %i\n", integer1);
                stdout.printf ("char1 value => %c\n", character1);
                stdout.printf ("long1 value => %i\n", long1);
                stdout.printf ("double1 value => %e\n", double1);
                stdout.printf ("string1 value => %s\n", string1);

        }

        static int main (string[] args) {
                var sample = new Sample ();
                sample.show_class_variables();
                return 0;
        }
}

Vala examples I

Some weeks ago, i was thinking about to write a vala tutorial. Finally, i’ve decided to write only vala examples. Easy vala examples that anyone can understand it only reading it once times (or twice times if you don’t undestand it the first time 😉 ).

The first example is the clasical “hello world” :


/* hello-world.vala */
/* valac -o hello-world hello-world.vala */

using GLib;

public class Sample : Object {
        public Sample () {
        }

        public void run () {
                stdout.printf ("Hello World\n");
        }

        static int main (string[] args) {
                var sample = new Sample ();
                sample.run ();
                return 0;
        }
}

Happy hacking !!