[indent=4] uses Mx progressbar : ProgressBar slider : Slider def static main_content () : Clutter.Actor var table = new Table () table.column_spacing = 24 table.row_spacing = 24 var mylabel = new Label.with_text ("Hello World") mylabel.tooltip_text = "I'm a label" table.add_actor_with_properties (mylabel, 0, 0, "y-fill", false) var combo = new ComboBox () combo.active_text = "Hello World" combo.append_text ("Hello") combo.append_text ("Word") table.add_actor_with_properties (combo, 0, 1, "y-fill", false) progressb
[indent=4] uses Gtk class MyWin : Gtk.Window mdlg : Gtk.MessageDialog const exit_str : string = "Exit ?" // from a menu item def exit_clicked () var e = new Gdk.Event(Gdk.EventType.DELETE) this.exit_event(e) // from Alt-F4 or window toolbar or ... def exit_event (E : Gdk.Event) : bool var mdlg = new Gtk.MessageDialog (this, Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, this.exit_str) if mdlg.run() == Gtk.ResponseType.YES Gtk.main_quit()
[indent=2] uses Gtk, Gdk def set_color (out w : Gtk.Widget) c : Gdk.Color // background now black instead of gray Gdk.Color.parse("black", out c) w.modify_bg(StateType.NORMAL, c) // red when hover over Gdk.Color.parse("red", out c) w.modify_bg(StateType.PRELIGHT, c) // blue when focused Gdk.Color.parse("blue", out c) w.modify_bg(StateType.ACTIVE, c) // cyan when selected Gdk.Color.parse("cyan", out c) w.modify_bg(StateType.SELECTED, c)
[indent=4] /* Build with valac --pkg gtk+-2.0 --pkg cairo yourfile.gs */ uses Gtk Cairo class TransparentWindow : Gtk.Window init this.type = Gtk.WindowType.TOPLEVEL /* Set the title is useless !
[indent=4] /* Requires Vala >= 0.7.9 valac --pkg clutter-1.0 yourfile.gs */ uses Clutter class ClutterDemo animations : array of Animation stage : Stage rectangles : array of Rectangle const colors : array of string = { "blanched almond", "OldLace", "MistyRose", "White", "LavenderBlush", "CornflowerBlue", "chartreuse", "chocolate", "light coral", "medium violet red", "LemonChiffon2", "RosyBrown3" } construct () stage = Stage.get_default () rectangles = new array of Rectangle[colors.length] stage.hide.connect (Clutter.main_q
[indent=4] def default_handler(server : Soup.Server, msg : Soup.Message, path : string, query : GLib.HashTable?, client : Soup.ClientContext) response_text : string = "<html><body><p>Current location: %s</p><p><a href=\"/xml\">Test XML</a></p>
[indent=4] def process_request (input : InputStream, output : OutputStream) raises Error var data_in = new DataInputStream (input) line : string while ((line = data_in.read_line (null, null)) != null) print line if (line.strip () == "") do break content : string = "<html><h1>Hello from Genie server</h1></html>" var header = new StringBuilder () header.append ("HTTP/1.0 200 OK\r\n") header.append ("Content-Type: text/html\r\n") header.append_printf ("Content-Length: %lu\r\n\r\n", content.size ()) output.write (header.str, heade
[indent=4] /* Build with valac --pkg gtk+-2.0 colorselectiondialog.gs */ uses Gtk init Gtk.init (ref args) var test = new TestWindow () test.show_all () Gtk.main () class TestWindow : Window label : Label init title = "Test Gtk.ColorSelectionDialog !" default_height = 70 default_width = 140 window_position = WindowPosition.CENTER destroy += Gtk.main_quit label = new Label("I'm a simple label !!!") var button = new Button.with_label("Change Text Color") button.clicked += ch
[indent=4] /* Build with valac --pkg gtk+-2.0 --pkg pango fontselectiondialog.gs */ uses Gtk Pango init Gtk.init (ref args) var test = new TestWindow () test.show_all () Gtk.main () class TestWindow : Window label : Label init title = "Test Gtk.FontSelectionDialog !" default_height = 70 default_width = 140 window_position = WindowPosition.CENTER destroy += Gtk.main_quit label = new Label("I'm a simple label !!!") var button = new Button.with_label("Change Text Font")
[indent=4] /* Build with valac --pkg gtk+-2.0 yourfile.gs */ uses Gtk init Gtk.init (ref args) var test = new StatusIconTest () test.show_all () Gtk.main () class StatusIconTest : Window trayicon : StatusIcon menu : Menu init title = "StatusIcon" window_position = WindowPosition.CENTER set_resizable(false) destroy += exit_app var label = new Label("Look the house in your taskbar !!!") var hbox = new HBox (false, 0) hbox.pack_start (label, false, true, 0) add (hbox)