Mer/Documentation/Vala control panel

Line 55: Line 55:
Improvements ''very'' much welcomed.
Improvements ''very'' much welcomed.

Revision as of 15:13, 11 February 2010

Mer needs new control panels. But not everyone knows C, but they may be proficient in C#. Vala is a language with C#-like syntax, that compiles to C, which makes it perfect for writing CPAs which are (to my knowledge) C only. But, documentation on Vala is rather lacking.

An example can be found here:

 *      cpa.vala
 *      Copyright 2009 Faheem Pervez <qwerty12>
 *      This library is free software; you can redistribute it and/or
 *      modify it under the terms of the GNU Lesser General Public
 *      License as published by the Free Software Foundation; either
 *      version 2.1 of the License, or (at your option) any later version.
 *      This library is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      Lesser General Public License for more details.
 *      You should have received a copy of the GNU Lesser General Public
 *      License along with this library; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.

using Osso;
using Hildon;
using Gtk;

public Hildon.Program program;
public Gtk.Widget dialog;

Status execute(Context *osso, void* data, bool user_activated)
        osso = new Osso.Context("vala-test-applet", "0.1", false, null);
        program = Hildon.Program.get_instance();
        data = new Hildon.Window();

        dialog = new Hildon.Note.information ((Hildon.Window)data, "Hey, I'ma CPA written in Vala.\n"+"The \"programmer\" who wrote me sucks; but he hopes \nthat this can be used for something.");
	delete osso;

        return Status.OK;

//valac -C --pkg libosso --pkg hildon-1 cpa.vala ; gcc `pkg-config --cflags libosso hildon-1` -fPIC -c cpa.c ; gcc -module -avoid-version -shared -Wl,-soname,  -o cpa.o  -lc

Save the above as "cpa.vala". Because valac seems to be more accustomed for making programs, you have to use valac's -C option which'll output the generated C code and gcc can then be used to make it into a library.

Improvements very much welcomed.