Vala and Genie programming

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#76 Post by BarryK »

Lobster,
for the hello-gtk.gs, do you have a carriage-return on the last line?

I just tested, running Intrepid Puppy alpha3, devx loaded, I copied the example hello-gtk from my web page, pasted it into a file, compiled it with valac, it works.

Hmm, I took the carriage-return off the last line, it still compiles.

I have copied the code you posted to this thread, that compiles too.

I'm using Vala 0.5.7.
[url]https://bkhome.org/news/[/url]

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#77 Post by Lobster »

Many thanks Barry,

I am awaiting a page on GTK on your Genie pages :)
I have cautiously added Valide :shock:
and got a working hello world

There are good example GTK for Vala but not Genie on the Vala pages
Mark is already using Glade but I am still working up to crawl status
Lobster,
for the hello-gtk.gs, do you have a carriage-return on the last line?
Yes tried all that but it just must be that!
thanks will try again . . .

edit:
no luck and leafpad is not saving - valide strikes again . . .
gonna try another computer . .
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

DMcCunney
Posts: 889
Joined: Tue 03 Feb 2009, 00:45

#78 Post by DMcCunney »

Lobster wrote:I instead installed medit

that seems OK and supports Vala - I have written to the developer about Genie support
AFAIK, Geany supports Vala.

File type support is defined in a file called filetypes.<name>, where <name> is the language name.

There is a filetypes.vala file in /usr/share/geany
______
Dennis

aragon
Posts: 1698
Joined: Mon 15 Oct 2007, 12:18
Location: Germany

#79 Post by aragon »

@ lobster

attached is the genie.lang from here:
http://bugzilla.gnome.org/show_bug.cgi?id=576141

if you're using my medit-package, extract it to

Code: Select all

/usr/share/moo/language-specs
and there you are.

aragon
Attachments
genie.lang_medit.tar.gz
(2.09 KiB) Downloaded 594 times

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#80 Post by Lobster »

Thanks guys
Thanks aragon
how about a free movie . . . violence and stuff . . . Blank
http://www.webtvwire.com/blank-movie-di ... ittorrent/
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

seeker
Posts: 89
Joined: Thu 27 Nov 2008, 00:43
Location: Indiana, USA

#81 Post by seeker »

Lobster,

I just tried to compile hello-gtk.gs with Genie and got the same error you had. I noticed the line 'add (button)' was indented with two tab characters so I replaced the tabs with 8 spaces. It didn't compile so I added a blank line , without any indentation, at the end of the code and then it compiled. Using Vala 0.5.7 and Puppy 4.1.2 frugal.

Seeker

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#82 Post by Lobster »

Thanks seeker :)

that is good advice
(didn't seem to help)

The Valide editor seems to be the source of serious problems for me
- or maybe it is the required libraries for gtk compiling . . .
- it effects other editors and even Seamonkey, so that invoking save as crashes the program you are activating save as and sometimes even save from
this effects things too drastically to use it
and I must for now stick with Geany editor or Medit editor

I have noticed this on three pristine installs of Puppy

for now I will be using
  • Puppy 4.12
    and the devxx
    vala-05.7.pet
    libgee-20081125-i486.pet
    medit-0.9.4.pet
    genie.lang_medit.tar.gz
Valide is however potentially an excellent IDE for Vala/Genie
so if anyone can replicate this behaviour and find out what and why
that would be great ;)
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#83 Post by MU »

- it effects other editors and even Seamonkey, so that invoking save as crashes the program you are activating save as and sometimes even save from
this effects things too drastically to use it
Maybe I know the reason.
When you used the IDE, delete the file:
/root/.recently-used.xbel

It seems that Puppys programs use an older syntax in it, while new programs like Valide use a new syntax. It is a XML file, that you can look at in an editor.
It stores the "recently used" entries in the Gtk filedialog, so there is no problem to delete it.

Puppys libraries slowly start to get outdated, such issues might happen more often in future, using new programs.
Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
Mr. Maxwell
Posts: 215
Joined: Sat 30 Aug 2008, 23:56
Location: Nebraska, USA

#84 Post by Mr. Maxwell »

I have medit and the genie launguage specs package installed but how do I turn on the genie syntax highlighting?

EDIT:

Never mind, a couple reboots later it works.
[url=http://www.tribalwars.net/3389956.html]Super amazing game![/url]

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#85 Post by Lobster »

Great tip MU - makes sense - it has been difficult
but hey this is cutting edge . . . :)
Never mind, a couple reboots later it works.
. . . we await your first programming examples :)
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
Mr. Maxwell
Posts: 215
Joined: Sat 30 Aug 2008, 23:56
Location: Nebraska, USA

#86 Post by Mr. Maxwell »

This should be an easy question, how do I use a window I made with Glade in Genie?

What about square roots and exponents?
[url=http://www.tribalwars.net/3389956.html]Super amazing game![/url]

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#87 Post by MU »

full example: glade window in Genie:
http://www.murga-linux.com/puppy/viewto ... 241#286241

A simpler example I attached here:
http://www.murga-linux.com/puppy/viewto ... 0&start=30
Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
Mr. Maxwell
Posts: 215
Joined: Sat 30 Aug 2008, 23:56
Location: Nebraska, USA

#88 Post by Mr. Maxwell »

Thanks I'll take a look at it.

But now when I try to compile my program I get this error message:

Code: Select all

test.gs:5.22-5.36: error: The name `Gee' does not exist in the context of `main'
    var my_list = new list of int
My guess says that is caused by an error with Genie and Geelib. Any ideas on how to fix this?
[url=http://www.tribalwars.net/3389956.html]Super amazing game![/url]

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#89 Post by MU »

install:
http://distro.ibiblio.org/pub/linux/dis ... -0.1.5.pet

http://distro.ibiblio.org/pub/linux/dis ... -0.1.5.pet

Then in the Valaide, go to the options, and add as library there:
gee-1.0

On my system, the ide crashes again, if I go to the options :(
That worked right after I had installed it.
So I added with an editor:

Code: Select all

    <pkg>gee-1.0</pkg>
to the file:
/root/valide/gee1/gee1.vide

If your project has a different name and location, use the .vide file of your project.

If someone compiles by hand, use such a command:
valac --pkg=gee-1.0 hello.gs
Barry explains it here:
http://puppylinux.com/genie/datatypes.htm
Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
Mr. Maxwell
Posts: 215
Joined: Sat 30 Aug 2008, 23:56
Location: Nebraska, USA

#90 Post by Mr. Maxwell »

Thanks! The "valac --pkg=gee-1.0 hello.gs" is what I needed. The IDE broke my puppy so I can't use it. :(
[url=http://www.tribalwars.net/3389956.html]Super amazing game![/url]

User avatar
Mr. Maxwell
Posts: 215
Joined: Sat 30 Aug 2008, 23:56
Location: Nebraska, USA

#91 Post by Mr. Maxwell »

Now I have another problem. I have a list with many doubles in it, I wish to get rid of these doubles. If I try this code:

Code: Select all

for num:int in num_list
    if num not in finished_num_list
        finished_num_list.add(num)
I get this error:

Code: Select all

test.gs:16.18-16.20: error: syntax error, expected end of line but got `!' with previous identifier
        if num not in finished_num_list
               ^^^
test.gs:21-1-21-0: error: syntax error, expected identifier

Compilation failed: 2 error(s), 0 warning(s)
When I try this code:

Code: Select all

for num:int in num_list
    if not (num in finished_num_list)
        finished_num_list.add(num)
It compiles just fine but I get this message when I try to run it:

Code: Select all

Segmentation fault
Both of those work fine in python and should work with other launguages. Any ideas?
[url=http://www.tribalwars.net/3389956.html]Super amazing game![/url]

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#92 Post by MU »

Ok, I used a testprogram:

Code: Select all

[indent=2]
init

  var num_list = new list of int
  num_list.add(1)
  num_list.add(2)
  
  var finished_num_list = new list of int

  for num in num_list
    print("testing: %d" , num)
    if not finished_num_list.contains(num) 

      print("adding: %d" , num)
      finished_num_list.add(num)

  print("bye")
Looks slightly different to your code, but does the same (I also tested yours, and then mine, to check where the error ould be).
When I compile and run it in the IDE, it never reaches "bye".
Running in console, I also get the segmentation fault.
If I run it in the debugger, I get:
# valac --pkg=gee-1.0 main.gs
# gdb ./main
GNU gdb 6.7
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-t2-linux-gnu"...
(no debugging symbols found)
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run
Starting program: /root/valide/gee1/main
(no debugging symbols found)
(no debugging symbols found)
testing: 1
adding: 1
testing: 2

Program received signal SIGSEGV, Segmentation fault.
0xb7ea1476 in g_int_equal () from /usr/lib/libglib-2.0.so.0
(gdb) backtrace
#0 0xb7ea1476 in g_int_equal () from /usr/lib/libglib-2.0.so.0
#1 0xb7f3d1d9 in gee_array_list_real_index_of (base=0x804f670, item=0x2) at arraylist.c:185
#2 0xb7f438ef in gee_list_index_of (self=0x804f670, item=0x2) at list.c:61
#3 0xb7f3e4d0 in gee_array_list_real_contains (base=0x804f670, item=0x2) at arraylist.c:174
#4 0xb7f3eabf in gee_collection_contains (self=0x804f670, item=0x2) at collection.c:39
#5 0x08048764 in _main ()
#6 0x08048829 in main ()
(gdb) quit
The program is running. Exit anyway? (y or n) y
#
So there is a bug concerning int types in lists.
I then used "uint" instead.
This works.
You just need to "cast" it to int, if you want to compare it to other integers, or print it.
This is done with

Code: Select all

(int) variablename
Here is a working example:

Code: Select all

[indent=2]

init

  var num_list = new list of uint
  num_list.add(1)
  num_list.add(2)
  
  var finished_num_list = new list of uint
  var a=0   
   
  for num in num_list 
    a = (int) num
    if not (num in finished_num_list) 
      print("adding: %d" , a)    
      finished_num_list.add(num)
      print("added: %d" , a)


  print("bye")

 
Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
Mr. Maxwell
Posts: 215
Joined: Sat 30 Aug 2008, 23:56
Location: Nebraska, USA

#93 Post by Mr. Maxwell »

Thanks much better. :D I'm going to start working on the GUI now so I hope you're ready for more questions. :D
[url=http://www.tribalwars.net/3389956.html]Super amazing game![/url]

mymas
Posts: 3
Joined: Sun 29 Mar 2009, 14:07
Location: japan

#94 Post by mymas »

hi. I try to do cairo-sample in genie. :)
So, window open ok, but I cannot do picture-image output in window ...

Code: Select all

[indent=2]
uses 
  Gtk
  GLib
  Cairo
    
init 
  Gtk.init (ref args)
  var test = new CairoSample ()
  test.show_all ()
  Gtk.main ()

class CairoSample : Window
  init
    title = "Cairo Genie Demo"
    default_height = 550
    default_width = 450
    window_position = WindowPosition.CENTER
    
    destroy += Gtk.main_quit
    
    var drawing_area = new DrawingArea ()
    drawing_area.expose_event += on_expose
    add (drawing_area)
    
  def on_expose (da: DrawingArea, event: Gdk.EventExpose) : bool
    var ctx = Gdk.cairo_create (da.window)
    var surf = new Cairo.ImageSurface (Cairo.Format.ARGB32,240,80)
    ctx.save ()
    
    ctx.select_font_face ('serif', Cairo.FontSlant.NORMAL, Cairo.FontWeight.BOLD)
    ctx.set_font_size (32.0)
    ctx.set_source_rgb (0, 0, 1)
    ctx.move_to (10,50)
    ctx.show_text ('Hello, World')
    
    ctx.restore ()
    surf.write_to_png ('genie_cairotext.png')
    return true
umm... My code is not tidy... :(

aragon
Posts: 1698
Joined: Mon 15 Oct 2007, 12:18
Location: Germany

#95 Post by aragon »

New Version of Vala => 0.6

http://live.gnome.org/Vala/Release

aragon

Post Reply