working on it ...

Filters

Explore Public Snippets

Sort by

Found 51 snippets

    public by marceloviana modified Nov 14, 2016  1334  14  4  0

    Csharp consumindo Rest + lendo JSON

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Net;
    using System.IO;
    using Newtonsoft.Json;
    using Newtonsoft.Json.Linq;
    
    namespace ExemploChatBot
    {
        public partial class Chat : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void enviar_Click(object sender, EventArgs e)
            {
                string txt_campo_texto = campo_texto.Text;
    
                var url = "http://128.0.0.1:5000/site?id=2542&texto_digitado="+ txt_campo_texto + "";
    
                var syncClient = new WebClient();
                var content = syncClient.DownloadString(url);            
    
                dynamic registro = JObject.Parse(content);
                campo_texto.Text = registro.pergunta;
    
            }
        }
    }

    external by BZHDeveloper modified Aug 19, 2017  4  0  1  0

    test utilities

    test utilities: ubuntu-utils.vala
    /* utils.vapi generated by valac UNKNOWN, do not modify. */
    
    namespace System {
    	[CCode (cheader_filename = "utils.h")]
    	public class Distribution : GLib.Object {
    		public Distribution ();
    		public string codename { get; construct; }
    		public string description { get; construct; }
    		public string id { get; construct; }
    		public string release { get; construct; }
    	}
    	[CCode (cheader_filename = "utils.h")]
    	public class Kernel : GLib.Object {
    		public class Version : GLib.Object {
    			public string to_string ();
    			public string kernel_type { get; private set; }
    			public uint major { get; private set; }
    			public uint micro { get; private set; }
    			public uint minor { get; private set; }
    			public uint revision { get; private set; }
    		}
    		public Kernel ();
    		public string to_string ();
    		public string architecture { owned get; }
    		public string name { owned get; }
    		public System.Distribution operating_system { get; private set; }
    		public string pc_name { owned get; }
    		public System.Kernel.Version version { owned get; }
    	}
    	[CCode (cheader_filename = "utils.h")]
    	public class Source : GLib.Object, Gee.Hashable<System.Source> {
    		public Source (System.SourceType source_type, string uri, string suite);
    		public string to_string ();
    		public bool active { get; set construct; }
    		public Gee.Set<string> components { get; }
    		public System.SourceType source_type { get; construct; }
    		public string suite { get; construct; }
    		public string uri { get; construct; }
    	}
    	[CCode (cheader_filename = "utils.h")]
    	public class SourceList : Gee.AbstractSet<System.Source> {
    		public SourceList ();
    		public override bool add (System.Source source);
    		public override void clear ();
    		public override bool contains (System.Source source);
    		public override Gee.Iterator<System.Source> iterator ();
    		public static System.SourceList open (string path) throws GLib.Error;
    		public override bool remove (System.Source source);
    		public override bool read_only { get; }
    		public override int size { get; }
    	}
    	[CCode (cheader_filename = "utils.h")]
    	public enum SourceType {
    		DEB,
    		DEB_SRC;
    		public string get_nick ();
    		public static System.SourceType from_nick (string nick);
    	}
    }
    
    

    external by Mario Daniel Ruiz Saavedra modified Aug 13, 2017  3  0  1  0

    Emit custom notify in Vala

    Emit custom notify in Vala: custom-emit-notify.vala
    using GLib;
    
    public class TestClass : GLib.Object {
    	public string test1 {get;set;default = "test1";}
    	//Ths one won't emit on assignment
    	[CCode (notify = false)]
    	public string test2 {get;set;default = "test2";}
    
    	public static void main (string[] args) {
    		var test = new TestClass ();
    		test.notify["test1"].connect (() => GLib.print ("test1 notification\n"));
    		test.notify["test2"].connect (() => GLib.print ("test2 notification\n"));
    		test.test1 = "Ahoy";
    		test.test2 = "Újale";
    		test.test2 = "Ajúa";
    		ParamSpec pspec = ((ObjectClass) typeof (TestClass).class_ref ()).find_property ("test2");
    		GLib.print ("First try, will not work %s\n", pspec.name);
    		test.notify(pspec);
    		GLib.print ("second one, this is how it works");
    		test.notify["test2"] (pspec);
    		return;
    	}
    }
    
    

    external by ???????? modified Jul 8, 2017  3  0  2  0

    Reads all bytes from an InputStream (Vala)

    Reads all bytes from an InputStream (Vala): read_all_bytes_from_stream.vala
    public uint8[] read_all_bytes_from_stream (InputStream stream, ulong buf_size) throws Error {
    	uint8[] data = {};
    	uint8[] buf = new uint8[buf_size];
    	ssize_t bytes;
    	ulong total = 0;
    	while (true) {
    		bytes = stream.read(buf);
    		if (bytes <= 0) break;
    		
    		ulong size = (ulong) (total + bytes);
    		if (size > data.length) {
    			ulong new_len = MathUtils.next_pot(size);
    			uint8[] prev = data;
    			data = new uint8[new_len];
    			Memory.copy(&data[0], &prev[0], total);
    			prev = null;
    		}
    		Memory.copy(&data[0] + total, &buf[0], bytes);
    		total += (ulong) bytes;
    	}
    	return data[0:total];
    }
    
    

    external by Adrià Arrufat modified Jun 2, 2017  4  0  1  0

    Vcl-test

    Vcl-test: vcl-test.vala
    // modules: vcl-0.36 gee-0.8
    
    using GLib;
    using Vcl;
    
    int main (string[] args) {
    	
    	var src_file = args[1]; // I'm passing the path to this file
    	var context = new Context ();
    
      /* this works :D */
    	var packages = context.available_packages;
    	foreach (var p in packages) {
    		print (@"$p\n");
    	}
      
      /* this doesn't */
    	var symbols = context.lookup_symbols_for_text (src_file, 18, 20, "context");
    	foreach (var s in symbols) {
    		print ("%s\n", s.name);
    	}
    	return 0;
    }
    
    

    external by BZHDeveloper modified Apr 30, 2017  10  0  1  0

    vala GObject wrapper (sic)

    vala GObject wrapper (sic): vcl-0.38.vapi
    /* vcl-0.38.vapi generated by valac 0.36.1.14-035c, do not modify. */
    
    namespace Vcl {
    	[CCode (cheader_filename = "vcl.h")]
    	public class Context : GLib.Object {
    		public Context ();
    		public bool add_source_filename (string filename);
    		public GLib.List<Vala.Symbol> lookup_symbol_expression (Vala.Expression? inner, string name, bool prefix_match, Vala.Symbol? block);
    		public Gee.Collection<Vala.Symbol> lookup_symbols_for_text (string filename, int line, int column, string text);
    		public void parse ();
    		public async void parse_async ();
    		public Gee.List<string> available_packages { owned get; }
    		public Gee.Collection<string> gir_directories { get; }
    		public Gee.Collection<string> metadata_directories { get; }
    		public Gee.List<string> packages { get; }
    		public Vcl.Report report { get; set; }
    		public Gee.List<Vcl.SourceFile> source_files { get; }
    		public Gee.Collection<string> vapi_directories { get; }
    		public signal void begin_parsing ();
    		public signal void end_parsing ();
    	}
    	[CCode (cheader_filename = "vcl.h")]
    	public class Report : GLib.Object {
    		public Report ();
    		public signal void deprecated (Vcl.SourceReference source, string message);
    		public signal void error (Vcl.SourceReference source, string message);
    		public signal void note (Vcl.SourceReference source, string message);
    		public signal void warning (Vcl.SourceReference source, string message);
    	}
    	[CCode (cheader_filename = "vcl.h")]
    	public class SourceFile : GLib.Object, Gee.Hashable<Vcl.SourceFile>, Gee.Comparable<Vcl.SourceFile> {
    		public SourceFile ();
    		public static Vcl.SourceFile? open (string filename);
    		public static Vcl.SourceFile? open_file (GLib.File file);
    		public GLib.File file { get; construct; }
    		public string filename { owned get; }
    		public bool is_source { get; construct; }
    	}
    	[CCode (cheader_filename = "vcl.h")]
    	public class SourceReference : GLib.Object {
    		public bool contains (Vcl.SourceLocation location);
    		public Vcl.SourceLocation begin { get; construct; }
    		public Vcl.SourceLocation end { get; construct; }
    		public string filename { get; construct; }
    	}
    	[CCode (cheader_filename = "vcl.h")]
    	public struct SourceLocation {
    		public int line;
    		public int column;
    		public SourceLocation (int line, int column);
    		public bool before (Vcl.SourceLocation other);
    		public bool inside (Vcl.SourceReference source);
    	}
    	[CCode (cheader_filename = "vcl.h")]
    	public static string[] get_vapi_directories ();
    	[CCode (cheader_filename = "vcl.h")]
    	public static bool package_exists (string package);
    	[CCode (cheader_filename = "vcl.h")]
    	public static int symbol_compare (Vala.Symbol symbol, Vala.Symbol other);
    	[CCode (cheader_filename = "vcl.h")]
    	public static bool symbol_equal (Vala.Symbol symbol, Vala.Symbol other);
    	[CCode (cheader_filename = "vcl.h")]
    	public static uint symbol_hash (Vala.Symbol symbol);
    }
    
    
    

    external by M. Gage Morgan modified Apr 25, 2017  5  0  1  0

    After C#, learned an easy way to write this cairo sh!t without reinventing fourteen wheels

    After C#, learned an easy way to write this cairo sh!t without reinventing fourteen wheels: logo.vala
    using Cairo;
    public class Main : GLib.Object {
    	public static void Triangle1p1() {
    		// Create a context:
    		Cairo.SvgSurface triangle_surface_1p2 = new Cairo.SvgSurface ("triangle1p1.svg", 421, 410);
    
    		Cairo.Context triangle_context_1p2 = new Cairo.Context (triangle_surface_1p2);
    		Cairo.Context triangle_context_1p3 = new Cairo.Context (triangle_surface_1p2);
    		Cairo.Context triangle_context_1p4 = new Cairo.Context (triangle_surface_1p2);
    		Cairo.Context triangle_context_1p5 = new Cairo.Context (triangle_surface_1p2);
    
    		triangle_context_1p2.set_line_width(2.5);
    		triangle_context_1p2.save();
    
    		// Triangle 1
    		triangle_context_1p2.set_source_rgba (0.7, 0.20, 0.17, 0.8);
    		triangle_context_1p2.scale(1.0, 1.0);
    		triangle_context_1p2.line_to (143, 39);
    		triangle_context_1p2.line_to (198, 176);
    		triangle_context_1p2.line_to (23, 281);
    		triangle_context_1p2.close_path ();
    
    		triangle_context_1p2.fill_preserve();
    		triangle_context_1p2.restore();
    		triangle_context_1p2.set_source_rgba(0.98, 0.38, 0.09, 0.8);
    		triangle_context_1p2.stroke();
    
    		triangle_context_1p3.set_line_width(2.5);
    		triangle_context_1p3.save();
    
    		// Triangle 2:
    		triangle_context_1p3.set_source_rgba (0, 0.63, 0.90, 0.8);
    		triangle_context_1p3.scale(1.0, 1.0);
    		triangle_context_1p3.line_to (275, 44);
    		triangle_context_1p3.line_to (377, 102);
    		triangle_context_1p3.line_to (100, 118);
    		triangle_context_1p3.close_path ();
    
    		triangle_context_1p3.fill_preserve();
    		triangle_context_1p3.restore();	
    		triangle_context_1p3.set_source_rgba(0, 0.99, 0.93, 0.8);
    		triangle_context_1p3.stroke();
    		
    		triangle_context_1p4.set_line_width(2.5);
    		triangle_context_1p4.save();
    
    		// Triangle 5:
    		triangle_context_1p4.set_source_rgba (0, 0.63, 0.90, 0.8);
    		triangle_context_1p4.scale(1.0, 1.0);
    		triangle_context_1p4.line_to (244, 314);
    		triangle_context_1p4.line_to (148, 375);
    		triangle_context_1p4.line_to (70, 184);
    		triangle_context_1p4.close_path ();
    
    		triangle_context_1p4.fill_preserve();
    		triangle_context_1p4.restore();
    		triangle_context_1p4.set_source_rgba(0, 0.99, 0.93, 0.8);
    		triangle_context_1p4.stroke();
    
    		triangle_context_1p5.set_line_width(2.5);
    		triangle_context_1p5.save();
    	}
    
    	public static void Triangle1p2() {
    		// Create a context:
    		Cairo.SvgSurface triangle_surface_1p2 = new Cairo.SvgSurface ("triangle1p2.svg", 421, 410);
    
    		Cairo.Context triangle_context_1p2 = new Cairo.Context (triangle_surface_1p2);
    		Cairo.Context triangle_context_1p3 = new Cairo.Context (triangle_surface_1p2);
    		Cairo.Context triangle_context_1p4 = new Cairo.Context (triangle_surface_1p2);
    		Cairo.Context triangle_context_1p5 = new Cairo.Context (triangle_surface_1p2);
    		Cairo.Context triangle_context_1p6 = new Cairo.Context (triangle_surface_1p2);		
    
    
    		triangle_context_1p2.set_line_width(2.5);
    		triangle_context_1p2.save();
    
    		// Triangle 1
    		triangle_context_1p2.set_source_rgba (0.7, 0.20, 0.17, 0.8);
    		triangle_context_1p2.scale(1.0, 1.0);
    		triangle_context_1p2.line_to (143, 39);
    		triangle_context_1p2.line_to (198, 176);
    		triangle_context_1p2.line_to (23, 281);
    		triangle_context_1p2.close_path ();
    
    		triangle_context_1p2.fill_preserve();
    		triangle_context_1p2.restore();
    		triangle_context_1p2.set_source_rgba(0.98, 0.38, 0.09, 0.8);
    		triangle_context_1p2.stroke();
    
    		triangle_context_1p3.set_line_width(2.5);
    		triangle_context_1p3.save();
    
    		// Triangle 2:
    		triangle_context_1p3.set_source_rgba (0, 0.63, 0.90, 0.8);
    		triangle_context_1p3.scale(1.0, 1.0);
    		triangle_context_1p3.line_to (275, 44);
    		triangle_context_1p3.line_to (377, 102);
    		triangle_context_1p3.line_to (100, 118);
    		triangle_context_1p3.close_path ();
    
    		triangle_context_1p3.fill_preserve();
    		triangle_context_1p3.restore();	
    		triangle_context_1p3.set_source_rgba(0, 0.99, 0.93, 0.8);
    		triangle_context_1p3.stroke();
    		
    		triangle_context_1p4.set_line_width(2.5);
    		triangle_context_1p4.save();
    
    		// Triangle 5:
    		triangle_context_1p4.set_source_rgba (0, 0.63, 0.90, 0.8);
    		triangle_context_1p4.scale(1.0, 1.0);
    		triangle_context_1p4.line_to (244, 314);
    		triangle_context_1p4.line_to (148, 375);
    		triangle_context_1p4.line_to (70, 184);
    		triangle_context_1p4.close_path ();
    
    		triangle_context_1p4.fill_preserve();
    		triangle_context_1p4.restore();
    		triangle_context_1p4.set_source_rgba(0, 0.99, 0.93, 0.8);
    		triangle_context_1p4.stroke();
    
    		triangle_context_1p5.set_line_width(2.5);
    		triangle_context_1p5.save();
    
    		// Triangle 3:
    		triangle_context_1p5.set_source_rgba (0.78, 0.38, 0.09, 0.8);
    		triangle_context_1p5.scale(1.0, 1.0);
    		triangle_context_1p5.line_to (363, 190);
    		triangle_context_1p5.line_to (250, 126);
    		triangle_context_1p5.line_to (305, 26);
    		triangle_context_1p5.close_path ();
    
    		triangle_context_1p5.fill_preserve();
    		triangle_context_1p5.restore();
    		triangle_context_1p5.set_source_rgba(0.98, 0.20, 0.17, 0.8);
    		triangle_context_1p5.stroke();
    
    		triangle_context_1p6.set_line_width(2.5);
    		triangle_context_1p6.save();
    
    		// Triangle 6:
    		triangle_context_1p6.set_source_rgba (0.78, 0.38, 0.09, 0.8);
    		triangle_context_1p6.scale(1.0, 1.0);
    		triangle_context_1p6.line_to (195, 260);
    		triangle_context_1p6.line_to (333, 356);
    		triangle_context_1p6.line_to (128, 330);
    		triangle_context_1p6.close_path ();
    
    		triangle_context_1p6.fill_preserve();
    		triangle_context_1p6.restore();
    		triangle_context_1p6.set_source_rgba(0.98, 0.20, 0.17, 0.8);
    		triangle_context_1p6.stroke();
    	}
    
    	public static void Triangle1p3() {
    		// Create a context:
    		Cairo.SvgSurface triangle_surface_1p2 = new Cairo.SvgSurface ("triangle1p3.svg", 421, 410);
    
    		Cairo.Context triangle_context_1p2 = new Cairo.Context (triangle_surface_1p2);
    		Cairo.Context triangle_context_1p3 = new Cairo.Context (triangle_surface_1p2);
    		Cairo.Context triangle_context_1p4 = new Cairo.Context (triangle_surface_1p2);
    		Cairo.Context triangle_context_1p5 = new Cairo.Context (triangle_surface_1p2);
    		Cairo.Context triangle_context_1p6 = new Cairo.Context (triangle_surface_1p2);		
    		
    		triangle_context_1p2.set_line_width(2.5);
    		triangle_context_1p2.save();
    
    		// Triangle 1
    		triangle_context_1p2.set_source_rgba (0.7, 0.20, 0.17, 0.8);
    		triangle_context_1p2.scale(1.0, 1.0);
    		triangle_context_1p2.line_to (143, 39);
    		triangle_context_1p2.line_to (198, 176);
    		triangle_context_1p2.line_to (23, 281);
    		triangle_context_1p2.close_path ();
    
    		triangle_context_1p2.fill_preserve();
    		triangle_context_1p2.restore();
    		triangle_context_1p2.set_source_rgba(0.98, 0.38, 0.09, 0.8);
    		triangle_context_1p2.stroke();
    
    		triangle_context_1p3.set_line_width(2.5);
    		triangle_context_1p3.save();
    
    		// Triangle 2:
    		triangle_context_1p3.set_source_rgba (0, 0.63, 0.90, 0.8);
    		triangle_context_1p3.scale(1.0, 1.0);
    		triangle_context_1p3.line_to (275, 44);
    		triangle_context_1p3.line_to (377, 102);
    		triangle_context_1p3.line_to (100, 118);
    		triangle_context_1p3.close_path ();
    
    		triangle_context_1p3.fill_preserve();
    		triangle_context_1p3.restore();	
    		triangle_context_1p3.set_source_rgba(0, 0.99, 0.93, 0.8);
    		triangle_context_1p3.stroke();
    		
    		triangle_context_1p4.set_line_width(2.5);
    		triangle_context_1p4.save();
    
    		// Triangle 5:
    		triangle_context_1p4.set_source_rgba (0, 0.63, 0.90, 0.8);
    		triangle_context_1p4.scale(1.0, 1.0);
    		triangle_context_1p4.line_to (244, 314);
    		triangle_context_1p4.line_to (148, 375);
    		triangle_context_1p4.line_to (70, 184);
    		triangle_context_1p4.close_path ();
    
    		triangle_context_1p4.fill_preserve();
    		triangle_context_1p4.restore();
    		triangle_context_1p4.set_source_rgba(0, 0.99, 0.93, 0.8);
    		triangle_context_1p4.stroke();
    
    		triangle_context_1p5.set_line_width(2.5);
    		triangle_context_1p5.save();
    
    		// Triangle 3:
    		triangle_context_1p5.set_source_rgba (0.78, 0.38, 0.09, 0.8);
    		triangle_context_1p5.scale(1.0, 1.0);
    		triangle_context_1p5.line_to (363, 190);
    		triangle_context_1p5.line_to (250, 126);
    		triangle_context_1p5.line_to (305, 26);
    		triangle_context_1p5.close_path ();
    
    		triangle_context_1p5.fill_preserve();
    		triangle_context_1p5.restore();
    		triangle_context_1p5.set_source_rgba(0.98, 0.20, 0.17, 0.8);
    		triangle_context_1p5.stroke();
    
    		triangle_context_1p6.set_line_width(2.5);
    		triangle_context_1p6.save();
    
    		// Triangle 6:
    		triangle_context_1p6.set_source_rgba (0.78, 0.38, 0.09, 0.8);
    		triangle_context_1p6.scale(1.0, 1.0);
    		triangle_context_1p6.line_to (195, 260);
    		triangle_context_1p6.line_to (333, 356);
    		triangle_context_1p6.line_to (128, 330);
    		triangle_context_1p6.close_path ();
    
    		triangle_context_1p6.fill_preserve();
    		triangle_context_1p6.restore();
    		triangle_context_1p6.set_source_rgba(0.98, 0.20, 0.17, 0.8);
    		triangle_context_1p6.stroke();
    	}
    					
    	public static void Triangle1() {
    		SvgSurface triangle_surface_1 = new Cairo.SvgSurface ("triangle1.svg", 421, 410);
    		Context triangle_context_1 = new Cairo.Context (triangle_surface_1);
    
    		triangle_context_1.set_line_width(2.5);
    		triangle_context_1.save();
    
    		// Triangle 1
    		triangle_context_1.set_source_rgba (0.7, 0.20, 0.17, 0.8);
    		triangle_context_1.scale(1.0, 1.0);
    		triangle_context_1.line_to (143, 39);
    		triangle_context_1.line_to (198, 176);
    		triangle_context_1.line_to (23, 281);
    		triangle_context_1.close_path ();
    
    		triangle_context_1.fill_preserve();
    		triangle_context_1.restore();
    		triangle_context_1.set_source_rgba(0.98, 0.38, 0.09, 0.8);
    		triangle_context_1.stroke();
    	}
    
    	public static void Triangle2() {
    		SvgSurface triangle_surface_2 = new Cairo.SvgSurface ("triangle2.svg", 421, 410);
    		Context triangle_context_2 = new Cairo.Context (triangle_surface_2);
    
    		triangle_context_2.set_line_width(2.5);
    		triangle_context_2.save();
    
    		// Triangle 2:
    		triangle_context_2.set_source_rgba (0, 0.63, 0.90, 0.8);
    		triangle_context_2.scale(1.0, 1.0);
    		triangle_context_2.line_to (275, 44);
    		triangle_context_2.line_to (377, 102);
    		triangle_context_2.line_to (100, 118);
    		triangle_context_2.close_path ();
    
    		triangle_context_2.fill_preserve();
    		triangle_context_2.restore();
    		triangle_context_2.set_source_rgba(0, 0.99, 0.93, 0.8);
    		triangle_context_2.stroke();
    
    		triangle_context_2.set_line_width(2.5);
    		triangle_context_2.save();
    	}
    		
    	public static void Triangle3() {
    		SvgSurface triangle_surface_3 = new Cairo.SvgSurface ("triangle3.svg", 421, 410);
    		Context triangle_context_3 = new Cairo.Context (triangle_surface_3);
    
    		triangle_context_3.set_line_width(2.5);
    		triangle_context_3.save();
    
    		// Triangle 3:
    		triangle_context_3.set_source_rgba (0.78, 0.38, 0.09, 0.8);
    		triangle_context_3.scale(1.0, 1.0);
    		triangle_context_3.line_to (363, 190);
    		triangle_context_3.line_to (250, 126);
    		triangle_context_3.line_to (305, 26);
    		triangle_context_3.close_path ();
    
    		triangle_context_3.fill_preserve();
    		triangle_context_3.restore();
    		triangle_context_3.set_source_rgba(0.98, 0.20, 0.17, 0.8);
    		triangle_context_3.stroke();
    	}	
    	
    	public static void Triangle4() {
    		SvgSurface triangle_surface_4 = new Cairo.SvgSurface ("triangle4.svg", 421, 410);
    		Context triangle_context_4 = new Cairo.Context (triangle_surface_4);
    
    		triangle_context_4.set_line_width(2.5);
    		triangle_context_4.save();
    
    		// Triangle 4:
    		triangle_context_4.set_source_rgba (0.19, 0.80, 0.19, 0.8);
    		triangle_context_4.scale(1.0, 1.0);
    		triangle_context_4.line_to (376, 130);
    		triangle_context_4.line_to (304, 222);
    		triangle_context_4.line_to (290, 147);
    		triangle_context_4.close_path ();
    
    		triangle_context_4.fill_preserve();
    		triangle_context_4.restore();
    		triangle_context_4.set_source_rgba(0.48, 0.98, 0, 0.8);
    		triangle_context_4.stroke();
    	}
    
    	public static void Triangle5() {
    		SvgSurface triangle_surface_5 = new Cairo.SvgSurface ("triangle5.svg", 421, 410);
    		Context triangle_context_5 = new Cairo.Context (triangle_surface_5);
    
    		triangle_context_5.set_line_width(2.5);
    		triangle_context_5.save();
    
    		// Triangle 5:
    		triangle_context_5.set_source_rgba (0, 0.63, 0.90, 0.8);
    		triangle_context_5.scale(1.0, 1.0);
    		triangle_context_5.line_to (244, 314);
    		triangle_context_5.line_to (148, 375);
    		triangle_context_5.line_to (70, 184);
    		triangle_context_5.close_path ();
    
    		triangle_context_5.fill_preserve();
    		triangle_context_5.restore();
    		triangle_context_5.set_source_rgba(0, 0.99, 0.93, 0.8);
    		triangle_context_5.stroke();
    	}
    
    	public static void Triangle6() {
    		SvgSurface triangle_surface_6 = new Cairo.SvgSurface ("triangle6.svg", 421, 410);
    		Context triangle_context_6 = new Cairo.Context (triangle_surface_6);
    
    		triangle_context_6.set_line_width(2.5);
    		triangle_context_6.save();
    
    		// Triangle 6:
    		triangle_context_6.set_source_rgba (0.78, 0.38, 0.09, 0.8);
    		triangle_context_6.scale(1.0, 1.0);
    		triangle_context_6.line_to (195, 260);
    		triangle_context_6.line_to (333, 356);
    		triangle_context_6.line_to (128, 330);
    		triangle_context_6.close_path ();
    
    		triangle_context_6.fill_preserve();
    		triangle_context_6.restore();
    		triangle_context_6.set_source_rgba(0.98, 0.20, 0.17, 0.8);
    		triangle_context_6.stroke();
    	}
    
    	public static void Triangle7() {
    		SvgSurface triangle_surface_7 = new Cairo.SvgSurface ("triangle7.svg", 421, 410);
    		Context triangle_context_7 = new Cairo.Context (triangle_surface_7);
    
    		triangle_context_7.set_line_width(2.5);
    		triangle_context_7.save();
    
    		// Triangle 7:
    		triangle_context_7.set_source_rgba (0.19, 0.80, 0.19, 0.8);
    		triangle_context_7.scale(1.0, 1.0);
    		triangle_context_7.line_to (304, 270);
    		triangle_context_7.line_to (311, 380);
    		triangle_context_7.line_to (252, 326);
    		triangle_context_7.close_path ();
    
    		triangle_context_7.fill_preserve();
    		triangle_context_7.restore();
    		triangle_context_7.set_source_rgba(0.48, 0.98, 0, 0.8);
    		triangle_context_7.stroke();
    	}
    
    	public static void Logo() {
    		// Create a context:
    		Cairo.SvgSurface surface = new Cairo.SvgSurface ("triangles-all.svg", 421, 410);
    		Cairo.Context context = new Cairo.Context (surface);
    		
    		context.set_line_width(2.5);
    		context.save();
    
    		// Triangle 1
    		context.set_source_rgba (0.7, 0.20, 0.17, 0.8);
    		context.scale(1.0, 1.0);
    		context.line_to (143, 39);
    		context.line_to (198, 176);
    		context.line_to (23, 281);
    		context.close_path ();
    
    		context.fill_preserve();
    		context.restore();
    		context.set_source_rgba(0.98, 0.38, 0.09, 0.8);
    		context.stroke();
    
    		context.set_line_width(2.5);
    		context.save();
    
    		// Triangle 2:
    		context.set_source_rgba (0, 0.63, 0.90, 0.8);
    		context.scale(1.0, 1.0);
    		context.line_to (275, 44);
    		context.line_to (377, 102);
    		context.line_to (100, 118);
    		context.close_path ();
    
    		context.fill_preserve();
    		context.restore();	
    		context.set_source_rgba(0, 0.99, 0.93, 0.8);
    		context.stroke();
    
    		context.set_line_width(2.5);
    		context.save();
    
    		// Triangle 3:
    		context.set_source_rgba (0.78, 0.38, 0.09, 0.8);
    		context.scale(1.0, 1.0);
    		context.line_to (363, 190);
    		context.line_to (250, 126);
    		context.line_to (305, 26);
    		context.close_path ();
    
    		context.fill_preserve();
    		context.restore();
    		context.set_source_rgba(0.98, 0.20, 0.17, 0.8);
    		context.stroke();
    
    		context.set_line_width(2.5);
    		context.save();
    
    		// Triangle 4:
    		context.set_source_rgba (0.19, 0.80, 0.19, 0.8);
    		context.scale(1.0, 1.0);
    		context.line_to (376, 130);
    		context.line_to (304, 222);
    		context.line_to (290, 147);
    		context.close_path ();
    
    		context.fill_preserve();
    		context.restore();
    		context.set_source_rgba(0.48, 0.98, 0, 0.8);
    		context.stroke();
    
    		context.set_line_width(2.5);
    		context.save();
    
    		// Triangle 5:
    		context.set_source_rgba (0, 0.63, 0.90, 0.8);
    		context.scale(1.0, 1.0);
    		context.line_to (244, 314);
    		context.line_to (148, 375);
    		context.line_to (70, 184);
    		context.close_path ();
    
    		context.fill_preserve();
    		context.restore();
    		context.set_source_rgba(0, 0.99, 0.93, 0.8);
    		context.stroke();
    
    		context.set_line_width(2.5);
    		context.save();
    
    		// Triangle 6:
    		context.set_source_rgba (0.78, 0.38, 0.09, 0.8);
    		context.scale(1.0, 1.0);
    		context.line_to (195, 260);
    		context.line_to (333, 356);
    		context.line_to (128, 330);
    		context.close_path ();
    
    		context.fill_preserve();
    		context.restore();
    		context.set_source_rgba(0.98, 0.20, 0.17, 0.8);
    		context.stroke();
    
    		context.set_line_width(2.5);
    		context.save();
    
    		// Triangle 7:
    		context.set_source_rgba (0.19, 0.80, 0.19, 0.8);
    		context.scale(1.0, 1.0);
    		context.line_to (304, 270);
    		context.line_to (311, 380);
    		context.line_to (252, 326);
    		context.close_path ();
    
    		context.fill_preserve();
    		context.restore();
    		context.set_source_rgba(0.48, 0.98, 0, 0.8);
    		context.stroke();
    	}
    
    	public static void main (string[] args) {
    		Triangle1();
    		Triangle2();
    		Triangle3();
    		Triangle4();
    		Triangle5();
    		Triangle6();
    		Triangle7();
    		Triangle1p1();
    		Triangle1p2();
    		Logo();
    	}
    }
    
    
    

    external by Lukas Middelberg modified Apr 20, 2017  7  0  2  0

    Tango Colors in Gdk.RGBA representation

    Tango Colors in Gdk.RGBA representation: tangocolors.vala
    public void main (string[] args) {
    	var tango_colors = new Gee.ArrayList<Gdk.RGBA?> ();
    
    	// Aluminium
    	tango_colors.add (Gdk.RGBA () { red = 0.9296875, green = 0.9296875, blue = 0.921875, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.82421875, green = 0.83984375, blue = 0.80859375, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.7265625, green = 0.73828125, blue = 0.7109375, alpha = 1 });
    
    	// Butter
    	tango_colors.add (Gdk.RGBA () { red = 0.984375, green = 0.91015625, blue = 0.30859375, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.92578125, green = 0.828125, blue = 0.0, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.765625, green = 0.625, blue = 0.0, alpha = 1 });
    
    	// Chameleon
    	tango_colors.add (Gdk.RGBA () { red = 0.5390625, green = 0.8828125, blue = 0.203125, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.44921875, green = 0.8203125, blue = 0.0859375, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.3046875, green = 0.6015625, blue = 0.0234375, alpha = 1 });
    
    	// Orange
    	tango_colors.add (Gdk.RGBA () { red = 0.984375, green = 0.68359375, blue = 0.2421875, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.95703125, green = 0.47265625, blue = 0.0, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.8046875, green = 0.359375, blue = 0.0, alpha = 1 });
    
    	// Chocolate
    	tango_colors.add (Gdk.RGBA () { red = 0.91015625, green = 0.72265625, blue = 0.4296875, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.75390625, green = 0.48828125, blue = 0.06640625, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.55859375, green = 0.34765625, blue = 0.0078125, alpha = 1 });
    
    	// Sky Blue
    	tango_colors.add (Gdk.RGBA () { red = 0.4453125, green = 0.62109375, blue = 0.80859375, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.203125, green = 0.39453125, blue = 0.640625, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.125, green = 0.2890625, blue = 0.52734375, alpha = 1 });
    
    	// Plum
    	tango_colors.add (Gdk.RGBA () { red = 0.67578125, green = 0.49609375, blue = 0.65625, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.45703125, green = 0.3125, blue = 0.48046875, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.359375, green = 0.20703125, blue = 0.3984375, alpha = 1 });
    
    	// Slate
    	tango_colors.add (Gdk.RGBA () { red = 0.53125, green = 0.5390625, blue = 0.51953125, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.33203125, green = 0.33984375, blue = 0.32421875, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.1796875, green = 0.203125, blue = 0.2109375, alpha = 1 });
    
    	// Scarlet Red
    	tango_colors.add (Gdk.RGBA () { red = 0.93359375, green = 0.16015625, blue = 0.16015625, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.796875, green = 0.0, blue = 0.0, alpha = 1 });
    	tango_colors.add (Gdk.RGBA () { red = 0.640625, green = 0.0, blue = 0.0, alpha = 1 });
    }
    
    
    

    external by baka-gaijin-hakka modified Jan 11, 2017  8  0  2  0

    another vala app

    another vala app: app02.vala
    using Gtk;
    
    class windowApp {
      protected class winInstance : Gtk.Window {
        public winInstance() {
          destroy.connect(Gtk.main_quit);
    
          window_position = WindowPosition.CENTER;
          set_default_size(300, 500);
    
          var btn = new Gtk.Button.with_label("Button");
          add(btn);
          btn.clicked.connect(sup);
    
          show_all();
        }
        
        public void sup() {
          stdout.printf("Sup /b/!\n");
        }
      }
      
      public static int main(string[] args) {
        Gtk.init(ref args);
        var win = new winInstance();
        Gtk.main();
        
        return 0;
      }
    }
    
    

    external by baka-gaijin-hakka modified Jan 11, 2017  4  0  2  0

    Vala example

    Vala example: helloworld.vala
    using Gtk;
    
    class MyValaApp {
    
      protected class AwesomeApp : Gtk.Window {
        public AwesomeApp() {
          destroy.connect(Gtk.main_quit);
          show_all();
        }
      }
      
      public static int main(string[] args) {
        Gtk.init(ref args);
        AwesomeApp win = new AwesomeApp();
        Gtk.main();
        
        return 0;
      }
    }
    
    
    
    
    • Public Snippets
    • Channels Snippets