default.txt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using DBus;
  2. namespace Test {
  3. class Foo : Object {
  4. public signal void some_event (); // definition of the signal
  5. public void method () {
  6. some_event (); // emitting the signal (callbacks get invoked)
  7. }
  8. }
  9. }
  10. /* defining a class */
  11. class Track : GLib.Object, Test.Foo { /* subclassing 'GLib.Object' */
  12. public double mass; /* a public field */
  13. public double name { get; set; } /* a public property */
  14. private bool terminated = false; /* a private field */
  15. public void terminate() { /* a public method */
  16. terminated = true;
  17. }
  18. }
  19. const ALL_UPPER_CASE = "you should follow this convention";
  20. var t = new Track(); // same as: Track t = new Track();
  21. var s = "hello"; // same as: string s = "hello";
  22. var l = new List<int>(); // same as: List<int> l = new List<int>();
  23. var i = 10; // same as: int i = 10;
  24. #if (ololo)
  25. Regex regex = /foo/;
  26. #endif
  27. /*
  28. * Entry point can be outside class
  29. */
  30. void main () {
  31. var long_string = """
  32. Example of "verbatim string".
  33. Same as in @"string" in C#
  34. """
  35. var foo = new Foo ();
  36. foo.some_event.connect (callback_a); // connecting the callback functions
  37. foo.some_event.connect (callback_b);
  38. foo.method ();
  39. }