The time now is Tue 18 Jun 2013, 20:52
All times are UTC - 4 |
| Author |
Message |
technosaurus

Joined: 18 May 2008 Posts: 3845
|
Posted: Thu 18 Feb 2010, 20:42 Post_subject:
|
|
apart from the 2-3 examples in the devx - there are none as far as I know - maybe something from another distro... did you have to make any patches to compile without glade? I don't recall seeing a --disable-glade or --without-glade option.
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
disciple
Joined: 20 May 2006 Posts: 6197 Location: Auckland, New Zealand
|
Posted: Fri 19 Feb 2010, 01:05 Post_subject:
|
|
I was lazy, so I hand edited the makefile.
I deleted everything to do with glade, except the line that said something along the lines of HAS_LIBGLADE="yes", which I changed to "no"... I don't know whether I needed to do both those things
One of the comments in the changelog implies that it will still build if you don't have Glade installed, so I imagine it would be fairly easy to add a --disable-glade.
_________________ DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
|
|
Back to top
|
|
 |
ljfr
Joined: 23 Apr 2009 Posts: 176
|
Posted: Wed 07 Apr 2010, 05:05 Post_subject:
New version |
|
Hi,
A new version released last week:
March 31, 2010: Vala 0.8.0 released
see:http://live.gnome.org/Vala
regards,
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3845
|
Posted: Thu 08 Apr 2010, 15:14 Post_subject:
|
|
pasang-emas board game was recently rewritten in vala
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3845
|
Posted: Sat 05 Jun 2010, 16:12 Post_subject:
|
|
TrayIcon template - hacked from Nic's Status Icon Test (still has the same references)
| Code: | [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 : Widget
trayicon : StatusIcon
menu : Menu
init
/* Create tray icon */
trayicon = new StatusIcon.from_stock(STOCK_HOME)
trayicon.set_tooltip_text ("Hello, i'm a tooltip !")
trayicon.set_visible(true)
trayicon.activate += icon_clicked
create_menu()
/* Create menu */
def private create_menu ()
menu = new Menu()
var menuItem = new ImageMenuItem.from_stock(STOCK_ABOUT, null)
menuItem.activate += about_clicked
menu.append(menuItem)
var menuItem2 = new ImageMenuItem.from_stock(STOCK_QUIT, null)
menuItem2.activate += exit_app
menu.append(menuItem2)
menu.show_all()
trayicon.popup_menu += def (button, time)
show_popup(button, time)
/* Show popup menu */
def private show_popup (button : uint, time : uint)
menu.popup(null, null, null, button, time)
def private icon_clicked ()
print("I know you have clicked on the icon !!")
def private about_clicked ()
var about = new AboutDialog ()
about.set_version("1.0")
about.set_program_name("Simple StatusIcon Test")
about.set_comments("This is a Simple StatusIcon Test")
about.set_copyright("Nicolas alias nikobordx")
about.run()
about.hide()
def private exit_app ()
Gtk.main_quit(); |
Compile with:
valac -C --pkg gtk+-2.0 genietray.gs
gcc -Os `pkg-config --cflags --libs gtk+-2.0` -o genietray genietray.c -s
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3845
|
Posted: Mon 07 Jun 2010, 02:03 Post_subject:
Multi-call binaries in Vala Sub_title: have multiple programs in one binary (a la busybox) |
|
Multi-call binaries in Vala (like in busybox)
Here is a very basic example using the symlink method:
(just make a symlink called hello and another called goodbye)
| Code: | class Demo.HelloWorld : GLib.Object
{
public static int main(string[] args)
{
if ("hello" in args[0]){stdout.printf("Hello World!\n");}
if ("goodbye" in args[0]){stdout.printf("Good-Bye World!\n");}
return 0;
}
} |
Notes:
to get the alternate behavior such as in busybox <command> use args[1] instead ... for a larger number of commands a "case" would be better than a bunch of "if"s
The number of libraries available to vala is growing - with something like this it becomes possible to create an entire desktop in a single binary, thus saving significant code size.
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3845
|
Posted: Tue 08 Jun 2010, 01:27 Post_subject:
|
|
Vala-0.9.1 was released today - it breaks compatibility with most of the plugin examples I have seen including Valide, so I un-patched that part.
http://git.gnome.org/browse/vala/commit/?id=5fd7b8cebb983fccdebcd9329671d94c1e5cf826
I built Valide-0.7.0 against that and it works great so far - unfortunately I had to also add gdl and upgrade gtk>2.18, glib>2.22, and gtksourceview(I just went ahead and compiled the latest... still no genie support though) ... gtk and glib upgrades are available from the ibiblio repo
| Description |
|

Download |
| Filename |
gdl_DEV-2.30.0-i486.pet |
| Filesize |
9.03 KB |
| Downloaded |
516 Time(s) |
| Description |
|

Download |
| Filename |
gtksourceview-2.11.1-i486.pet |
| Filesize |
257 KB |
| Downloaded |
473 Time(s) |
| Description |
|

Download |
| Filename |
gdl-2.30.0-i486.pet |
| Filesize |
64.76 KB |
| Downloaded |
505 Time(s) |
| Description |
Note: This is not the official 0.9.1 because I removed plugin code that generates a compile error. Use the link above to fix your plugin code prior to the 1.0 release.
|

Download |
| Filename |
vala-0.9.1-i486.pet |
| Filesize |
1.52 MB |
| Downloaded |
569 Time(s) |
| Description |
|

Download |
| Filename |
valide-0.7.0-i486.pet |
| Filesize |
740.42 KB |
| Downloaded |
551 Time(s) |
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
growler

Joined: 24 Mar 2008 Posts: 209 Location: Kapiti - New Zealand
|
Posted: Sat 28 Aug 2010, 03:43 Post_subject:
Genie and Sqlite |
|
Having a go with my first forays into Genie programming.... appreciated all the examples in this thread.
I am trying to understand how to use the sqlite bindings and as an exercise I tried to convert an example in Vala to get the code below:
| Code: | [indent=4]
uses Sqlite
class SqliteSample : Object
def callback (n_columns: int, values : array of string, column_names : array of string ) : int
for i:int = 0 to n_columns
print ("%s = %s\n", column_names[i], values[i]);
print ("\n");
return 0;
def main (args : array of string): int
var db = new Database
rc :int
if args.length != 2
print ("Usage: %s DATABASE SQL-STATEMENT\n", args[0])
return 1
if !FileUtils.test (args[1], FileTest.IS_REGULAR)
print ("Database %s does not exist or is directory\n", args[1])
return 1
rc = Database.open (args[1], out db)
if rc != Sqlite.OK
print ("Can't open database: %d, %s\n", rc, db.errmsg ())
return 1
rc = db.exec (args[2], callback, null)
if rc != Sqlite.OK
print ("SQL error: %d, %s\n", rc, db.errmsg ())
return 1
return 0
init
var SQLLiteTest = new SqliteSample
params: array of string = {"/root/my-applications/PointOfSale.sqlite", "SELECT * FROM currencies"}
SQLLiteTest.main(params)
|
I get:
| Code: | # valac --pkg sqlite3 sqlite.gs
sqlite.gs:39.5-39.10: error: syntax error, expected identifier
params: array of string = {"/root/my-applications/PointOfSale.sqlite", "SELECT * FROM currencies"}
^^^^^^
Compilation failed: 1 error(s), 0 warning(s)
|
Appreciate any pointers.
Edited_times_total
|
|
Back to top
|
|
 |
growler

Joined: 24 Mar 2008 Posts: 209 Location: Kapiti - New Zealand
|
Posted: Sat 28 Aug 2010, 03:58 Post_subject:
XML-RPC with libSOUP |
|
I am trying to get data from another application (webERP) over XML-RPC and started to play with libsoup - again there is a vala example which I have tried to hack into Genie but coming unstuck.
I can get the following to compile:
| Code: |
indent=4]
/* Build with "valac --thread --pkg libsoup-2.4 yourfile.gs */
uses
Soup
init
var session = new Soup.SessionAsync ()
ItemCode:string = "DVD-TOPGUN"
UserName:string = "admin"
Password:string = "weberp"
var message = Soup.xmlrpc_request_new ("http://localhost/webERP/api/api_xml-rpc.php", "weberp.xmlrpc_GetStockBalance", typeof(string),ItemCode, typeof(string), UserName, typeof(string), Password)
session.send_message(message)
ResponseData:string = message.response_body.flatten().data
ErrorNumber:int = typeof(int)
try
xmlrpc_parse_method_response (ResponseData, -1, ErrorNumber)
print("Stock of %s = %s",ItemCode, ResponseData)
print("Error number %d", ErrorNumber)
except
print("Could not get webERP API location stock over XML-RPC")
/*Is this how to create an associative array
struct LocQty
quantity : double
loccode : string
var StockQuantities = new array of LocQty
ErrorMessage:string
xmlrpc_extract_method_response(ResponseData, -1, ErrorMessage, typeof(array of dict of string, double), StockQuantities)
*/
|
However, I can't get the last bit to xmlrpc_extract_method_response call to work - I think this is supposed to parse the response XML to nice variables. I think the 3rd parameter is supposed to be the data type of the return variables - which is an array of structs - the program as compiled returns:
| Code: | # ./SoupXMLRPC
Stock of DVD-TOPGUN = <?xml version="1.0"?>
<methodResponse>
<params>
<param>
<value><array>
<data>
<value><int>0</int></value>
<value><array>
<data>
<value><struct>
<member><name>quantity</name>
<value><string>-1</string></value>
</member>
<member><name>loccode</name>
<value><string>MEL</string></value>
</member>
</struct></value>
<value><struct>
<member><name>quantity</name>
<value><string>0</string></value>
</member>
<member><name>loccode</name>
<value><string>TOR</string></value>
</member>
</struct></value>
</data>
</array></value>
</data>
</array></value>
</param>
</params>
</methodResponse>
Error number 24
|
So it works with a good XML message returned.
Do I then have to parse the XML using xml as per Caleb's jwmconf example or does that method xmlrpc_extract_method_response do the trick....
This is very steep learning for me, I am in WAY over my head here!
Hope someone has done this before and can point me in the right direction
|
|
Back to top
|
|
 |
nikobordx
Joined: 23 May 2009 Posts: 84 Location: Bordeaux, France
|
Posted: Sat 28 Aug 2010, 05:59 Post_subject:
Genie and Sqlite |
|
Hi growler,
Can you try this:
| Code: |
[indent=4]
uses
Sqlite
class SqliteSample : Object
db : Sqlite.Database
def callback (n_columns: int, values : array of string, column_names : array of string ) : int
for i:int = 0 to n_columns
print ("%s = %s\n", column_names[i], values[i])
print ("\n");
return 0;
def begin (args : array of string) : int
rc : int
if args.length != 2
print ("Usage: %s DATABASE SQL-STATEMENT\n", args[0])
return 1
if !FileUtils.test (args[0], FileTest.IS_REGULAR)
print ("Database %s does not exist or is directory\n", args[0])
return 1
rc = Database.open (args[0], out db)
if rc != Sqlite.OK
print ("Can't open database: %d, %s\n", rc, db.errmsg ())
return 1
rc = db.exec (args[1], callback, null)
if rc != Sqlite.OK
print ("SQL error: %d, %s\n", rc, db.errmsg ())
return 1
return 0
init
var SQLLiteTest = new SqliteSample
test : array of string = {"/root/my-applications/PointOfSale.sqlite", "SELECT * FROM currencies"}
SQLLiteTest.begin(test)
|
Do not use "def main" in fonction, and "params" for arrays of string.
Nicolas.
|
|
Back to top
|
|
 |
growler

Joined: 24 Mar 2008 Posts: 209 Location: Kapiti - New Zealand
|
Posted: Sat 28 Aug 2010, 06:53 Post_subject:
Genie and Sqlite |
|
Not sure what the first parameter was meant to be I made the parameters array to have a blank element since the DB file was the second element and the SQL the third. et voila ...
| Code: | test : array of string = {"", "/root/my-applications/PointOfSale.sqlite", "SELECT * FROM currencies"}
|
Merci beaucoup Nicolas!!
|
|
Back to top
|
|
 |
Mobeus

Joined: 26 Aug 2010 Posts: 94
|
Posted: Mon 30 Aug 2010, 22:11 Post_subject:
|
|
With Vala I can't find a means to explicitly close a file opened with FileStream.open. Is there not a wrapper for fclose()? How is it done?
tia
Mobeus
|
|
Back to top
|
|
 |
nikobordx
Joined: 23 May 2009 Posts: 84 Location: Bordeaux, France
|
Posted: Tue 31 Aug 2010, 05:31 Post_subject:
|
|
Hi everyone,
growler:
Why not using
| Code: | | test : array of string = {"/root/my-applications/PointOfSale.sqlite", "SELECT * FROM currencies"} |
and change number of your "args" ?
Mobeus:
You don't need to specify to close the file because it is automatically closed!
In GLib's vapi file you can see on the class "FileStream":
| Code: | | [CCode (cname = "FILE", free_function = "fclose", cheader_filename = "stdio.h")] |
See you,
Nicolas.
|
|
Back to top
|
|
 |
growler

Joined: 24 Mar 2008 Posts: 209 Location: Kapiti - New Zealand
|
Posted: Tue 31 Aug 2010, 05:33 Post_subject:
|
|
Yes your solution is better.
Have you ever used libsoup - I can't get to grips with the
xmlrpc_extract_method_response method. I find the documentation very cryptic and spartan!!
|
|
Back to top
|
|
 |
nikobordx
Joined: 23 May 2009 Posts: 84 Location: Bordeaux, France
|
Posted: Tue 31 Aug 2010, 06:16 Post_subject:
|
|
I made only 2 small samples with libsoup:
http://code.valaide.org/content/genie-libsoup-simple-sample
http://code.valaide.org/content/genie-libsoup-simple-server
I can help you if you post your code (if your code is not top secret ! )
Nicolas.
|
|
Back to top
|
|
 |
|
|
|
Rules_post_cannot Rules_reply_cannot Rules_edit_cannot Rules_delete_cannot Rules_vote_cannot You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|