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
gege2061
Posts: 4
Joined: Sat 21 Mar 2009, 00:59
Location: France
Contact:

#341 Post by gege2061 »

BarryK wrote:A problem, I cannot get ValIDE to compile:

http://puppylinux.com/blog/?viewDetailed=00814
Have you applied the patch for vala?

I will soon publish a minor release without this patch and running with GTK+ 2.14

nikobordx
Posts: 84
Joined: Sat 23 May 2009, 09:08
Location: Bordeaux, France

#342 Post by nikobordx »

[See newer message]

Nicolas.
Last edited by nikobordx on Fri 26 Jun 2009, 11:43, edited 2 times in total.

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

#343 Post by BarryK »

Nicolas,
I have put your NicoEdit version 1.5 into Puppy 414, just uploaded. Note, I made a start at improving the file-type detection:

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

I'll be announcing 414 on my blog soon.
[url]https://bkhome.org/news/[/url]

nikobordx
Posts: 84
Joined: Sat 23 May 2009, 09:08
Location: Bordeaux, France

#344 Post by nikobordx »

[See newer message]

Nicolas.
Last edited by nikobordx on Fri 26 Jun 2009, 11:43, edited 1 time in total.

nikobordx
Posts: 84
Joined: Sat 23 May 2009, 09:08
Location: Bordeaux, France

#345 Post by nikobordx »

[See newer message]

Nicolas.
Last edited by nikobordx on Sat 27 Jun 2009, 11:16, edited 1 time in total.

nikobordx
Posts: 84
Joined: Sat 23 May 2009, 09:08
Location: Bordeaux, France

#346 Post by nikobordx »

[See newer message]

Nicolas.
Last edited by nikobordx on Sun 28 Jun 2009, 16:47, edited 1 time in total.

caleb72
Posts: 57
Joined: Fri 15 May 2009, 12:44

#347 Post by caleb72 »

Can I get some help with dates and times in Genie?

So far I've worked out that I can get a very accurate time if I use something like:

Code: Select all

var t = TimeVal()
print t.to_iso8601()
Of course it's a bit of a problem that the result of this is not in my timezone.

So then I've got two more options Time, Date - but I haven't really got anything useful out of them at all.

I get as far as:

Code: Select all

var t = Time()
But have no luck using Time.local() as it wants something called time_t that I can't seem to come up with.

I have managed to use the TimeVal() return to create a Date value, but this is without the timestamp altogether so not terribly useful.

Has anyone had some experience dealing with date and time in Genie?

Regards
Caleb

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

#348 Post by MU »

caleb,

time_t is a inbuilt functon.
See first message here:
http://www.murga-linux.com/puppy/viewto ... 0&start=60

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

caleb72
Posts: 57
Joined: Fri 15 May 2009, 12:44

#349 Post by caleb72 »

I could have sworn I did almost exactly as you had in that post at least at one stage. Shows how useless swearing is.

I tried it again and it works like a charm. Many thanks.

With the time_t function - is there docco on it? What exactly is it returning for example?

I'm guessing when you say it's an inbuilt function - that it's actually part of the Vala language?

I'm on a bit of a mission to learn Genie at the moment and for an exercise I'm converting some of my work Perl and Python scripts into Genie. It's all command line text and file processing stuff so I'm giving GTK+ a miss until at least I know how to navigate my way around the back-end concepts like file-handling, class creation/usage, the language structure itself etc...

Regards
Caleb

caleb72
Posts: 57
Joined: Fri 15 May 2009, 12:44

#350 Post by caleb72 »

OK - I was not going mad.

Seems like it works on Linux but does not work on Windows.

I get a:

.......asdfw.o:main.vala.c:(text+0xa0): undefined reference to 'localtime_r'
collect2: Id returned 1 exit status.

I get errors about 'gmtime_r' when using Time.gm as well.

Are Time.gm and Time.local platform specific?

Regards
Caleb

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

#351 Post by MU »

time_t seems to be a C "struct".
A "struct" is a kind of what would in Perl be an array of different datatypes, so several values in a special format are returned.

To find out details, I followed the links, here is the way I followed:
http://valadoc.org/
http://valadoc.org/?pkg=glib-2.0
http://valadoc.org/?pkg=glib-2.0&element=GLib.Time
http://valadoc.org/?pkg=glib-2.0&elemen ... Time.local
http://valadoc.org/?pkg=glib-2.0&element=time_t
http://valadoc.org/?pkg=glib-2.0&element=time_t.time_t

valadoc.org just shows you the syntax, but no descriptions.
To find out more, we need to look up the C documentation:
http://www.gtk.org/documentation.html
http://library.gnome.org/devel/glib/stable/
http://library.gnome.org/devel/glib/sta ... tions.html

Hmm... the functions here look somewhat different than at valadoc.org.
Usually they are very similar.
I thought I could find here a exact description of time_t, but there is no link on time_t for example here:
http://library.gnome.org/devel/glib/sta ... set-time-t
Very often, the parameters are clickable, so that you can read more details, for example, how the struct looks like.

So here, we had to use our own interpretation:
time_t is a value, that cannot be used directly (like a second), but that returns the time in a format, that is required by other methods like time.local().

Mark
Last edited by MU on Sun 28 Jun 2009, 01:59, edited 1 time in total.
[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:

#352 Post by MU »

caleb72 wrote:.......asdfw.o:main.vala.c:(text+0xa0): undefined reference to 'localtime_r'
collect2: Id returned 1 exit status.

I get errors about 'gmtime_r' when using Time.gm as well.

Are Time.gm and Time.local platform specific?
After googling for "localtime_r glib windows", the answer seems to be "yes".
Somewhere I saw, that instead of 'localtime_r', 'localtime' should be used - but this would apply to coding in C.
I don't know, how this can be solved in Vala or Genie.
You might have to post a request in the Vala mailing lists (I never poted there before, so cannot give you further hints here).

Mark
Last edited by MU on Sun 28 Jun 2009, 02:00, edited 1 time in total.
[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:

#353 Post by MU »

Maybe this works:
look in your Windows Vala installation for a file /share/vala/glib-2.0.vapi.
Open it in an editor, and search there for "localtime_r".
Here in my vala in Puppy it is line 1891:

Code: Select all

		[CCode (cname = "gmtime_r", instance_pos = -1)]
		public Time.gm (time_t time);
		[CCode (cname = "localtime_r", instance_pos = -1)]
		public Time.local (time_t time);
Try to remove the "_r" (also for gmtime), like this:

Code: Select all

		[CCode (cname = "gmtime", instance_pos = -1)]
		public Time.gm (time_t time);
		[CCode (cname = "localtime", instance_pos = -1)]
		public Time.local (time_t time);
Save it, and compile your project again.

I want to sleep soon, so do not test it myself in Windows now, but maybe it works.

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

caleb72
Posts: 57
Joined: Fri 15 May 2009, 12:44

#354 Post by caleb72 »

Wow man! Thanks for taking the time.

I had a feeling you'd say something about having to dig into the C documentation. It does look like some sort of value that can't be used except by passing it as an argument as something else - which is a bit funny - but then so's life.

I've turned my work laptop off so I don't have Windows running at the moment but I'll try to find the .vapi files and test out your suggestion. They weren't under C:\vala\ last time I checked unfortunately so I may need to search around elsewhere for them.

Regards
Caleb

User avatar
samedog
Posts: 56
Joined: Sun 12 Oct 2008, 11:03
Location: Panguipulli,Chile
Contact:

#355 Post by samedog »

i have solved my problem and it was just a library issue, i have updated glib from slackware 12.2 packages and now it compiles and i have no segmentation faul. i post this just in case someone else is having the same issue

samedog
<Rupp>ERROR: Communication problem with khotkeys, it probably crashed.
<Rupp>damn
<samedog>EPIC
<Rupp>FAIL
<samedog>hmm... pretty good for a signature..
<Rupp>XD

caleb72
Posts: 57
Joined: Fri 15 May 2009, 12:44

#356 Post by caleb72 »

OK - got to my Windows laptop and found the .vapi files. If anyone else is starting to work with Vala/Genie on Windows - you find the .vapi files at:

C:\Documents and Settings\All Users\Application Data\vala\vapi\

Now - I found the two entries for localtime_r and gmtime_r and altered them. I'm not longer getting that error.

However, I'm getting a new error:

"too many arguments to function 'gmtime' (and localtime accordingly).

I have raised a defect against the Valide project. I know that's a strange recourse, but this is where the Windows build of Vala is supplied, so I thought it made sense somehow.

I just don't know enough about vala, .vapi files or the underlying C libraries to troubleshoot this myself.

Regards
Caleb

nikobordx
Posts: 84
Joined: Sat 23 May 2009, 09:08
Location: Bordeaux, France

#357 Post by nikobordx »

[See newer message]

Nicolas.
Last edited by nikobordx on Mon 29 Jun 2009, 15:47, edited 1 time in total.

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

#358 Post by Lobster »

I am trying to get genie to generate some sound.
Is this possible? Rather than play a wav I was wondering about generating a beep?

Not sure where to start?
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

nikobordx
Posts: 84
Joined: Sat 23 May 2009, 09:08
Location: Bordeaux, France

#359 Post by nikobordx »

Lobster wrote:I am trying to get genie to generate some sound.
Is this possible? Rather than play a wav I was wondering about generating a beep?

Not sure where to start?
Hi,
You can take a look here: http://live.gnome.org/Vala/GStreamerSample
It's in vala but it's simple to convert to genie.

Nicolas.

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#360 Post by Pizzasgood »

Finally got enough stuff compiled for NicoEdit to run. Cool. Not sure if this is a bug with the program or with my half-ascii attempt to get it to work in Puppy 4.2, but the find-bar doesn't seem to actually work (though, if I previously used the find-window, the button on the find-bar will act as the button in the find-window, running the find-window's search). Also, the F11 key doesn't un-fullscreen it (or do you have a different key/key-combo to un-fullscreen?)

I think the 'set font-size' dialog should probably look at the current settings when it loads, so that if you change the font size and then come back and change it again, it doesn't revert back to the defaults like it does now.

Otherwise it looks pretty good. I see it does have multi-line tabbing and bracket-matching. One thing that might make that a little bit nicer is if the matching bracket didn't use the same colorscheme as highlighted text, but that isn't very important.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

Post Reply