site  contact  subhomenews

Vala 0.5.7

March 10, 2009 — BarryK
I have upload the latest Vala/Genie compiler, vala-0.5.7.pet (compiled in Puppy4), to here:

http://distro.ibiblio.org/pub/linux/distributions/puppylinux/pet_packages-woof/

I found a tiny HTML viewer written in Vala, so I translated it to Genie code:

[indent=4]

uses
Gtk

init
Gtk.init (ref args)
var test = new TestWindow ()
test.show_all ()
Gtk.main ();

class TestWindow : Window
init
title = "ultra tiny html viewer"
default_height = 550
default_width = 550
window_position = WindowPosition.CENTER
create_widgets ()

def private status_cb (moz:MozEmbed) : void
stdout.printf(moz.get_title())

def create_widgets () : void
destroy += Gtk.main_quit
var moz = new MozEmbed ()
moz.title += status_cb
moz.load_url("file:///usr/share/doc/index.html")
add (moz)


I got an error that it couldn't find the gtkmozembed header file, and I couldn't see why, so I used the '-C' switch to generate C code then gcc to create an executable:

# valac -C --pkg=gtkmozembed basic-gtk-moz.gs
# gcc `pkg-config --cflags gtk+-2.0 --libs gtk+-2.0` -I/usr/include/gtkembedmoz -lgtkembedmoz basic-gtk-moz.c -o basic-gtk-moz

After stripping, the executable is 5.8KB. I guess this could have some use as a super-tiny custom viewer for just one HTML file -- although of course code could be added for the URL and size as commandline parameters. It has all the power of SeaMonkey rendering -- that 'index.html' file has Javascript, which works.

Oh yeah, I uploaded the little executable, named 'basic-gtk-moz':

http://distro.ibiblio.org/pub/linux/distributions/puppylinux/test/

Comments

cool stuff
Username: MU
hehe cool, works even with the old seamonkey 1.1.8 in newyearspup. Writing this message in your ultra tiny html viewer now. If it works with flash, too, this would be great. Needs an option to pass a URL as argument. Mark

so cool...
Username: MU
"[code][indent=4] /* GTK+ Genie Sample Code - compile with valac --pkg=gtk+-2.0 --pkg=gtkmozembed moz.gs */ uses Gtk init Gtk.init (ref args) var test = new TestWindow () test.show_all () Gtk.main (); class TestWindow : Window init title = "ultra tiny html viewer" default_height = 740 default_width = 1020 window_position = WindowPosition.CENTER /* destroy += Gtk.main_quit*/ create_widgets () def private status_cb (moz:MozEmbed) : void stdout.printf(moz.get_title()) def create_widgets () : void destroy += Gtk.main_quit var moz = new MozEmbed () moz.title += status_cb /* moz.load_url("www.google.com")*/ moz.load_url("http://www.derbauer.de") add (moz) [/code] binary/source/makefile: http://www.murga-linux.com/puppy/viewtopic.php?p=282849#282849 Mark

Toolbar
Username: BarryK
"MU, yeah, I reckon it's cool too. It was so easy to add a toolbar with buttons (see my next post). I've got some example code also that shows how to add a URL-bar into the toolbar.

Change font
Username: BarryK
"I wonder how the program can be made to change the default font? At least, tell it to display antialiased.

Original author
Username: BarryK
"I'm a beginner at Vala/GTK coding, and the little genie program I wrote is based on two examples I found, one using gtkmozembed the other using webkit. They are written in Vala, and I rewrote in Genie. The guy who wrote the gtkmozembed example is Alberto Ruiz and he also did the gtkmozembed binding for Vala: http://aruiz.typepad.com/siliconisland/2007/08/the-first-vala-.html


Tags: woof