Toutes les langues

[Genie] Test Mx Widget

0
Your rating: Aucun
[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

[Genie] Confirm before exit application

3
Your rating: Aucun Average: 3 (2 votes)
[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()
 

[Genie] Changing the background color of a Widget

0
Your rating: Aucun
[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)
 

Gtk Toolbar

0
Your rating: Aucun
using Gtk;
 
public class Toolbar : Window
{
	VBox vbox;
	ActionGroup actionGroup;
	UIManager uimanger;
 
	public Toolbar()
	{
		vbox = new VBox(true, 8);
		this.add(vbox);
 
		this.set_title("Toolbar Example");
		this.set_position(WindowPosition.CENTER_ALWAYS);
		this.destroy.connect(Gtk.main_quit);
 
		// create actions for the tool bar buttons
		Action quitAction = new Action("QuitAction", "Quit", "Exit application", Gtk.STOCK_QUIT);
 
		// connect to the action
		quitAction.activate.connect(HandleQuitAction);
 
		// add action to action group
		actionGroup = new Ac

Vala Makefile Example

0
Your rating: Aucun
# Makefile
# vala project
#
 
# name of your project/program
PROGRAM = main_debug
 
 
# for most cases the following two are the only you'll need to change
# add your source files here
SRC = main.vala
 
# add your used packges here
PKGS = --pkg gtk+-2.0 --pkg gee-1.0
 
# vala compiler
VALAC = valac
 
# compiler options for a debug build
VALACOPTS = -g --save-temps
 
# set this as root makefile for Valencia
BUILD_ROOT = 1
 
# the 'all' target build a debug build
all:
	@$(VALAC) $(VALACOPTS) $(SRC) -o $(PROGRAM) $(PKGS)
 
# the 'release' target builds a release build
# you mi

Segmented Bar

4.583335
Your rating: Aucun Average: 4.6 (12 votes)
/* Vala version of the segmented bar as seen in ubuntu installer, eeebuntu installer, banshee and rhythmbox.  
    Ported from CSharp and C versions.  Create within a V or HBox on the window.

Snippet to read Input.Event struct's from /dev/input/event* using IOChannel's

4
Your rating: Aucun Average: 4 (2 votes)
/*
 * To compile: valac --pkg=linux --pkg=posix inputeventreader.vala
 *
 * Description:
 *   This example uses of the GLib's main loop and IOChannel's
 *   to listen for Input.Event's on one or more /dev/input/event*
 *   devices, and outputs the values to standard output.
 *
 * Copyright 2010, Robert Thomson.
 *
 * Released under the MIT License
 */
using Linux;
using Posix;
 
class InputEventReader {
 
    // Read a single input event from the channel, and print out the values.
    private static bool gio_in(IOChannel gio, IOCondition condition) {
        if((condition & IO

[Genie] Cairo transparent window

5
Your rating: Aucun Average: 5 (4 votes)
[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 !

Example for reading archives using libarchive

4.333335
Your rating: Aucun Average: 4.3 (3 votes)
/* archive.vala - Example for using the libarchive bindings in Vala.
 *
 * Copyright (C) 2009 Julian Andres Klode <jak@debian.org>
 *
 * Copying and distribution of this file, with or without modification,
 * are permitted in any medium without royalty provided the copyright
 * notice and this notice are preserved.

Extract Arabic Words From a Text File

5
Your rating: Aucun Average: 5 (5 votes)
/**
*
*    Description  : A simple snippet to demonstrate how to extract Arabic Words in Vala programming language
*    Vala version : 0.7.8
*    Developed by : Emad Al-Bloushi
*    Date         : Mon 23 Nov, 2009
*    Compile with : valac --pkg gee-1.0 word.vala
*
**/
Syndiquer le contenu