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
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#31 Post by Lobster »

MU wrote:Lobster, be certain to activate "view - bottom view".
That displays the internal console, where the messages from your program are printed.
Thank goodness there are smart people guiding the idiot cructaceans . . .
That did it
Works fine :D
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

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

#32 Post by Lobster »

Mark are you more inclined to use Vala
because of your java experience? 8)
I am more inclined to Genie . . .

The reason I ask is because if we have a list
of reserved words for Genie that might be a way for the programmers of
Valide to provide some colour coding
and support both languages?
I believe this exists for Vala but not Genie?
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:

#33 Post by MU »

No, I like both.
Vala is more like C/Java, Genie like Basic.

I concentrate on vala, because there is more documentation.
So to get startet, I tried vala, then I can try to port the programs to Genie.

Concerning Syntax-highlighting, I think further modifications of the IDE would be required.
I hesitate to mess around in foreign code.
I would suggest, that you contact the author:
http://code.google.com/p/valide/
http://valaide.blogspot.com/

I think it would be better, if you do it, not me.
I already have this "tunnel-view", so would not see requirements for beginners.
So I think you could suggest more "basic" issues, that would have priority at the current state.
---------------------------------------------------
I attach a new example.
This was a "pain in the *", it took a whole day, to find out, how it works.

It is an extended version of the Glade example now written in Genie.
During compilation you get a warning, but you can ignore it.

I added two helper functions, that allow to set values like a buttontext on the Window, that was generated from the gladesample.glade.

If you use other widgets, you had to add corresponding helperfunctions, but they are very simple.
Make a copy of "get_button", and rename "button" to the type of widget, that you need to access.

Unlike C, vala/genie does not allow Widget-conversion.
This will not work:

Code: Select all

GtkWidget *w;
w=glade_xml_get_widget(xml, "button1");
Gtk_button_set_label(GTK_BUTTON(w) , "testtext");
This is not possible:
GTK_BUTTON(w)

The new helperfunctions work around that issue.

Mark
Attachments
gladegs.jpg
buttons change size and text, if you click on them.
(16.91 KiB) Downloaded 2572 times
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

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

#34 Post by Lobster »

I already have this "tunnel-view", so would not see requirements for beginners.
OK I am in a strange place (quite usual for me)
I could not drag .gs files into an editor or open them in a text editor

the only command that worked was

Code: Select all

cat v1.gs
from the terminal . . .

So I am in the process of reinstalling genie
and getting it to work from the command line again . . .
in a new run of Puppy (setting puppy up was easy)

I have no idea what or how I broke things . . .
downloading every stray pet under the sun and
wearing no tin hat might be part of it ;)

Is anyone else playing with genie?
What ya doing? :)
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

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

#35 Post by Lobster »

I would suggest, that you contact the author:
Hey Mark
I wrote to the author:
Barry Kauler (creator of Puppy Linux) is adopting Vala/Genie
http://puppylinux.com/genie/

and MU one of our top coders is exploring and adapting
Valide to run Genie

Is Genie support and colour syntax coding planned for future valide releases?
with a link to this forum
and have got 'Geni(e)de' working again

Now to try your GTK example . ..
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

MUguest
Posts: 73
Joined: Sat 09 Dec 2006, 16:40

#36 Post by MUguest »

The examples now also work in Windows.

They require to add some files to a standard Vala installation, and to add options to the compiler.

Everything is here:
http://dotpups.de/puppy4/dotpups/Progra ... r-Windows/
see "readme.txt" for details.

Mark

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

#37 Post by Lobster »

Mark
Vala or Valide is making my system unstable (running 4.2 rc3)

Ideally I would recompile for 4.2 or wait for an update of Vala or use 4.12
The main problem is not being able to edit text files.
They seem to lock.

I may have wait until 4.2 final is released this week
and take it from there . . .
or maybe go straight to woof alpha 3 hopefully with added Vala

It is good to be on the cutting edge but I am being shredded . . .

Hopefully more intrepid programmers will join us soon ;)
Last edited by Lobster on Thu 19 Mar 2009, 11:46, edited 1 time in total.
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:

#38 Post by MU »

Lob, first thanks for writing to the author.

Second, I'm very surprised, about your issues.
I can not imagine, what causes this, as vala and valaide do not modify anything in the system.

Do your problems remain after a reboot?
When exactly do they begin?
I would compile an example in console.
Then try the IDE.

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

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

#39 Post by Lobster »

MU wrote:Lob, first thanks for writing to the author.
No problem :D
This is what Nicolas has written back
Hello,

I have planned Genie support for Val(a)IDE.

Currently I work on auto completion, after this I think I will work on
genie support.
So Genie support is coming.
Second, I'm very surprised, about your issues.
I can not imagine, what causes this, as vala and valaide do not modify anything in the system.
not good.

I install nvidia support
and flash 10 Beta
then Vala
then Valide
Valide is working
but I need to access files
Text editing is basic and I get a lock up
- I can not open .gs as text files
Rebooting does not help
Do your problems remain after a reboot?
When exactly do they begin?
I would compile an example in console.
Then try the IDE.
The problem is Mark
Any level of programming is quite hard for me
Takes a lot of concentration
If the base OS is doing odd stuff
then obviously I become distracted.

Vala and Genie are far too important to let
Lobsterian glitches slow it down.
The difficulties seem to occur when valide is installed

Because it has a file manager this makes me suspect Valide
is taking some liberties.

What I will do is work without it and see what happens.

Need to set up my system again :)

Puppy has Vala
and valour
Brave Pup
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

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

#40 Post by Lobster »

What I will do is work without it and see what happens.
What I have done so far is run 4.2 rc3 and not tweaked Deep Thought- run in Icewm etc
I have been running vala/genie from the command line all yesterday without incident

I have simplified my IMT program
and trying different code
So far . . . (does not quite work incidentally)

Code: Select all

// Infinite Monkey Theorem
// Lobster March 2009
// myLine = myLine.concat(myChars[GLib.Random.int_range(0,myChars.length)])

init
	a:int
	myChars:array of string = {" ", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
	myText:string = "i"
	myLine:string = ""
	i:int = 0
	while i<10
		a = GLib.Random.int_range(0,27)
		if myChars[a] is not "i" do continue
		if myChars[a] is not "n" do continue
		print("%d",a)
		print(myChars[a])
		if myChars[a] is "n" do break
Do you know how to use 'Print' continuously rather than with a line break?
Shadow did it here:

Code: Select all

// myLine = myLine.concat(myChars[GLib.Random.int_range(0,myChars.length)])
however that is too hard for me to work out why it works . . . 8)

Anyway just to let you know how I am getting on :)
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:

#41 Post by MU »

Code: Select all

  stdout.printf("test")
  stdout.printf("test")
  stdout.printf("ok\n")
  stdout.flush()
Without "\n", no linefeed is printed.
stdout is printing to a buffer, so you finally in the end have to print a "\n", and you have to "flush" to be sure, it becomes visible.

The long line you mentioned also can be written like this:

Code: Select all

[indent=2] 

init 

  //-- define the random characters --
  myChars:array of string = {" ", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"} 


  //-- fill the line with a word --
  var myLine = "testline" 
  
  print ("%s" , myLine) 


  //-- this is like the long line with print statements included 

  //-- calculate the allowed random numbers --
  var thelength = myChars.length 

  //-- create a random number --
  var randomvalue = Random.int_range(0,thelength) 

  //-- get a random character -- 
  var randomcharacter = myChars[randomvalue] 

  print ("%s" , randomcharacter) 

  //-- add the character to the line --
  var alltogether = myLine.concat(randomcharacter) 

  print ("%s" , alltogether)
  
  
Notes:
I simplified the code.
Instead of:

Code: Select all

myLine:string = "testline"
you can use:

Code: Select all

var myLine = "testline"
And "GLib." can be ommited, as this library is always loaded.
So instead of:

Code: Select all

var randomvalue = GLib.Random.int_range(0,thelength)
we can use:

Code: Select all

var randomvalue = Random.int_range(0,thelength)
Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

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

#42 Post by MU »

I am not certain, what your program shall do, maybe this is working:

Code: Select all

[indent=2]

init 
  

  myChars:array of string = {" ", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"} 

  var a = 0
  while true
  
    a = Random.int_range(0,27) 
    //print("%d",a) 
    
    if myChars[a] is not "i" do
      if myChars[a] is not "n" do
        stdout.printf("%d%s ",a, myChars[a]) 

    if myChars[a] is "n" do 
      //stdout.printf("%d%s ",a, myChars[a]) 
      break
  
   stdout.printf("\n")
   stdout.flush()
       

      
It will print random characters.
It will never print "i".
It stops, when "n" is the random character (it will not be printed).

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

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

#43 Post by Lobster »

I am not certain, what your program shall do, maybe this is working:
Mark - many thanks for you help
My program is an implementation of the
infinite monkey theorem
http://en.wikipedia.org/wiki/Infinite_monkey_theorem

It randomly creates text and then looks for specific readable text
in this case it is looking for:
in the beginning god created the heaven and earth

A quantum computer would find the whole of the Bible in an instant
What computing power we have presently takes a lot longer . . .
The infinite monkey theorem states that a monkey hitting keys at random on a typewriter keyboard for an infinite amount of time will almost surely type a given text, such as the complete works of William Shakespeare
. . . anyway gonna look at your code now . . .

Incidentally I am editing from Geany with code set as shell script and the colour coding looks OK :)
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

gege2061
Posts: 4
Joined: Sat 21 Mar 2009, 00:59
Location: France
Contact:

#44 Post by gege2061 »

MU wrote:We should inform the developer of the IDE about this thread.
I think it might be pretty motivating to see people using it :)
Mark
Yes :D I have added the support for Genie: http://valaide.blogspot.com/2009/03/genie-support.html

Your feedbacks are welcome!
MU wrote:Start the IDE again, and open your project.
Now right-click main.vala, and choose "add".
There add "main.gs".
And delete "main.vala" with a rightclick.
It still is listed, as you just renamed it, but it still is shown, as the IDE uses a internal filelist, to manage projects.
At this point, the IDE crashes.
It still is somewhat buggy :(
I have fixed this bug in trunk.

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

#45 Post by MU »

fantastique, merci beaucoup :!: :D
I will compile and package it this evening, must sleep first.

Just wrote my first "real" Genie program :)
http://www.murga-linux.com/puppy/viewto ... 241#286241

We certainly will request more features in future.
I am certain, that Genie/Vala and ValaIDE will become a very important part in Puppylinux.

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

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

#46 Post by Lobster »

must sleep first.
Maybe just this once . . . :lol:
Will be gardening today
Good news from gege2061
Looking forward to your efforts Mark :)
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:

#47 Post by MU »

Uploaded the new SVN version of ValaIDE.
Deleted the outdated Pets.

This is really great.
I included the syntaxfile for Genie mentioned in the blog.
This release also fixes crashes I had encountered, e.g. when opening the options dialog.

I hope I forgot no file (it uses "waf", not "make", so new2dir cannot track the installationprocess, and I must copy the files by hand).

http://dotpups.de/puppy4/dotpups/Programming/Vala/

Oh, there is a bug, when I click on "new project":

Code: Select all

** (valide:5873): DEBUG: Couldn't open this document

Code: Select all

Program received signal SIGSEGV, Segmentation fault.
0xb7d14bd4 in gtk_tree_model_get_iter () from /usr/lib/libgtk-x11-2.0.so.0
Program received signal SIGSEGV, Segmentation fault.
I also get it, when I try to use the old binary, that worked before.
Details from "gdb" - "run" - "backtrace":

0xb7d14bd4 in gtk_tree_model_get_iter () from /usr/lib/libgtk-x11-2.0.so.0

Code: Select all

(gdb) backtrace
#0  0xb7d14bd4 in gtk_tree_model_get_iter () from /usr/lib/libgtk-x11-2.0.so.0
#1  0xb7d14c39 in gtk_tree_row_reference_new_proxy ()
   from /usr/lib/libgtk-x11-2.0.so.0
#2  0xb7d14db4 in gtk_tree_row_reference_new ()
   from /usr/lib/libgtk-x11-2.0.so.0
#3  0xb7c01e62 in gtk_combo_box_set_active_internal ()
   from /usr/lib/libgtk-x11-2.0.so.0
#4  0xb7c02286 in gtk_combo_box_set_active () from /usr/lib/libgtk-x11-2.0.so.0
#5  0xb7806da9 in IA__g_object_set_property (object=0x82e0020, 
    property_name=0x82db890 "active", value=0x82ded14) at gobject.c:938
#6  0xb7d4dd00 in gtk_widget_buildable_set_buildable_property ()
   from /usr/lib/libgtk-x11-2.0.so.0
#7  0xb7be17a5 in _gtk_builder_construct () from /usr/lib/libgtk-x11-2.0.so.0
#8  0xb7be208b in builder_construct () from /usr/lib/libgtk-x11-2.0.so.0
#9  0xb7be34be in start_element () from /usr/lib/libgtk-x11-2.0.so.0
#10 0xb7ecb075 in g_markup_parse_context_parse ()
   from /usr/lib/libglib-2.0.so.0
#11 0xb7be1efb in _gtk_builder_parser_parse_buffer ()
   from /usr/lib/libgtk-x11-2.0.so.0
#12 0xb7be067c in gtk_builder_add_from_string ()
   from /usr/lib/libgtk-x11-2.0.so.0
#13 0xb7fadb73 in ?? () from /usr/lib/libvalide-0.0.so
#14 0x082819b8 in ?? ()
---Type <return> to continue, or q <return> to quit---
#15 0xb7fc9e44 in ?? () from /usr/lib/libvalide-0.0.so
#16 0x00003341 in ?? ()
#17 0xbf8e8ac0 in ?? ()
#18 0x00000000 in ?? ()
Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#48 Post by BarryK »

Genie support is now in Gtksourceview:

http://puppylinux.com/blog/?viewDetailed=00609

My Genie strings page has been expanded slightly:

http://puppylinux.com/blog/?viewDetailed=00608
[url]https://bkhome.org/news/[/url]

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

#49 Post by Lobster »

Thanks Mark

Just to remind to install the gtksourcefile pet as well as the Valide one
Mark has kindly prepared
http://dotpups.de/puppy4/dotpups/Programming/Vala/

Thanks Barry for the extra string handling info
- normally I stick to string theory which I find easier . . . 8)

Mark seems very enthusiastic about genie and as an amateur programmer I like Genie a lot.

Barry is Genie living up to your expectations so far?
Last edited by Lobster on Sat 21 Mar 2009, 08:35, edited 1 time in total.
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:

#50 Post by MU »

ok, worked around this bug, uploaded a new version.
Changes:
svn/valide-read-only/libvalide/ui/
abstract-project-dialog.ui
abstract-project-dialog.glade
abstract-project-dialog.vala

In all 3 files I removed 1 occurence of:

Code: Select all

<property name="active">0</property>
It is in the combobox to choose one of the languages Vala or Genie.
So none of the 2 is selected by default.
No more crash.

This might be a bug in our outdated libglade, I think I had similar issues in Gtkbasic. Libglade crashes, if a combo has a defaultvalue in the *.glade file.
There also was similar in the WineColorSetter I just had written.
There I then have set it active after the *.glade was loaded.

Code: Select all

get_combobox(get_widget("combobox1")).set_active(0)
Maybe it can be solved in the IDE, by setting it active somewhere in the vala code, but I found not yet out, where I could insert that.

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

Post Reply