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
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#151 Post by MU »

I attach picturebrowser v0.4.

Massive internal changes.

The whole treeclass was cleaned up, and is easier to use.
I think it now has reached the "final" structure, so the method names will not change in future.
I just might add some more, or enhance some. what might require more parameters.

Old code:

Code: Select all

    treeclass1 = new treeclass()
    treeclass1.mode = "filebrowser"
    mytree1 = treeclass1.treeview()
    treeclass1.column.set_title("Folders")
    get_scrolledwindow("scrolledwindow1" ).add (mytree1)


    var iter = treeclass2.get_first_iter(mytree2)
        if treeclass2.store.iter_is_valid(iter)
            treeclass2.select_iter(treeclass2, iter)
            tree2_row_click()
New code:

Code: Select all

    tree1 = new treeclass()
    tree1.mode = "filebrowser"
    tree1.init()
    tree1.column.set_title("Folders")
    var sw1 = (ScrolledWindow)get_widget("scrolledwindow1")
    sw1.add(tree1.tree)

    tree2.select_first_item()
    tree2_row_click()
Please note, that also the libglade.gs changed.

old:

Code: Select all

    get_scrolledwindow("scrolledwindow1" ).add (mytree1)
This used a method, that had to be defined "by hand", like this:

Code: Select all

//-- HELPER method: this method returns a SCROLLEDWINDOW ! --

def get_scrolledwindow(name : string) : ScrolledWindow
    b : Gtk.ScrolledWindow*
    var w = xml.get_widget(name)
    b = (ScrolledWindow) w
    return b
This is no longer needed!
You only need these 2 lines:

Code: Select all

    var sw1 = (ScrolledWindow) get_widget("scrolledwindow1")
    sw1.add(tree1.tree)
I think this is one of the enhancements in Vala 0.7.1, if I remember well, it did not work in 0.5.7, so I had written those helper methods.

The Windows binary is included again.

The program no longer uses "Threads" to scale a picture, but a method based on Gdk.Pixbuf.
This works faster, needs less resources (14% cpu-usage instead of 42%), and works in Linux and Windows.

And bookmarks now also work with special characters in the filenames.

A PET for Puppy 4.12 follows later.

Mark
Last edited by MU on Tue 05 May 2009, 20:18, 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:

#152 Post by MU »

[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:

#153 Post by MU »

I seperated the code to display the pictures in a own class now.
So it can easily embedded in own programs.
The class even manages to download pictures, that are dropped on the viewer (it uses wget).

I attach the source of a seperate small example application, that is described here:
http://www.murga-linux.com/puppy/viewto ... 769#302769

As no tree is included, this example is extremely short :)


The source for the picturebrowser is not adapted yet.
Mark
Attachments
Class-Pictureview-0.1b.zip
(44.15 KiB) Downloaded 766 times
[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:

#154 Post by MU »

there was a bug in the load_picture() method in the pictureview class.
There 3 methods were called with a leading "picview.", so it did not work, if your instance of the class had a different name.

Uploaded 0.1b.

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:

#155 Post by MU »

I updated the pictureviewer class, it can display PDF files now.

On Windows, you also need:
http://dotpups.de/puppy4/dotpups/Progra ... wslibs.zip

http://dotpups.de/puppy4/dotpups/Progra ... wslibs.txt

Mark
Attachments
Class-Pictureview-0.2.zip
(48.82 KiB) Downloaded 648 times
[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:

#156 Post by MU »

new update, see:
http://www.murga-linux.com/puppy/viewto ... 348#303348

Windows binary included again, see previous messages for dependencies on Windows.

Mark
Attachments
Class-Pictureview-0.3.zip
(54.19 KiB) Downloaded 685 times
[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:

#157 Post by MU »

here is a small interface for Mplayer.
The GIT version no longer supports an own grafical interface as far as I see.

So I hacked together this simple "playbar" , it allows to pause or switch fullscreen.
The cursor keys work too, to jump forward/backward.

In jwm, the playbar is covered in fullscreen mode, hit "f" to turn of fullscreen again.


The playbar has no fileselector, so you must pass a movie as commandline argument, or add the "genie-mplayer" script with full path as run-action to rox-filer (set the correct path in that script, too).

In the current state, it is not really recommended for average users, I just post it as small coding example.
Compiled in Puppy 412.

Mark
Attachments
GenieMplayer-0.2.tar.gz
(17.09 KiB) Downloaded 682 times
GenieMplayer.jpg
(32.96 KiB) Downloaded 1370 times
[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:

#158 Post by MU »

the Genie mplayer did not compile in Puppy 4.12, I added some changes, so now 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

#159 Post by caleb72 »

Can anyone play here?

I like developing in Python (Windows refugee) and am wondering if I should have a go at Genie.

I'm very fond of the Python syntax and style which makes me think Genie is the more logical choice for me rather than Vala for example.

I can't really find a huge amount of info - Barry's page with the examples is about all. Just wondering how to go about diving into Genie.

Regards
Caleb

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

#160 Post by Lobster »

am wondering if I should have a go at Genie
Yes. This thread and Barrys page is about all there is in Genie (it is very new)
Valide and Genie are part of the devx for the latest Woof alphas.

Marks examples (go through this thread) and my paltry efforts are a good place to begin.
Genie is faster (being compiled) than Python and works on both Windows and Linux, creating standalone efficient code.

Mark is very supportive and Barry will be providing more work in the future ;)

Be a Pioneer Puppy
Last edited by Lobster on Sat 16 May 2009, 02:04, 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:

#161 Post by MU »

there are not many Genie examples.

But once you wrote some small programs, using our examples as template, you will find a meanwhile quite huge collection of other examples: those from Vala.

A genie program has a simpler syntax.
So it is pretty easy, to "translate" vala code to genie.

This is especially valid for Gtk based examples.
Both languages use external libraries, and their call are almost identical.

Vala

Code: Select all

if ( a == 10){
    window.set_title("test");
}
Genie:

Code: Select all

if a is 10
    window.set_title("test")
So translating parts of code basically means to remove some "{ }" , some ";" and rename some keywords ("is" instead of "==").

I currently collect small examples, and will upload them in 3 weeks or so, after I cleaned them up.
It will be a collection of those posted in this thread, and maybe some simple others.
They can be browsed using a treeview, and you then can run them, or open them in the Vala-Ide.
But first I need to clean them, as especially my first Glade examples were too complicated, they can be simplified like the last ones.

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

#162 Post by caleb72 »

Good to know.
I will try to jump in when I can.

I'm currently swamped with Perl coding commitments for work - but I'll keep an eye on this for personal programming projects.

Great to see it can compile to Windows executable as well if the need arrives. With a windows executable will there be any dependencies or are they all built into the binary?

Regards
Caleb

gpnet
Posts: 56
Joined: Sat 09 May 2009, 15:49
Location: Ivrea ,Italy

#163 Post by gpnet »

Hi to all , Guys

I need help.
I have puppy 4.20 and devx_420.sfs installed.
I usually program in win c# and I would like to try vala in puppy. So I have download these packages from a deb repository:

valac_0.7.2-1_i386.deb
libvala0_0.7.2-1_i386.deb
vala-utils_0.3.4-1_i386.deb
libcairo2_1.4.14-1_i386.deb
.. because I wanted to try the last version with last fixed bugs.
.. converted to pet and installed

and gtksourceview-2.0.2-i486.pet from this thread

and valide-0.4-1-i686-svn-2009-03-27.pet from this site : http://dotpups.de/puppy4/dotpups/Programming/Vala/

Next step i compile by hand the hello.vala pgm example, and all gone well

so i tried to create a new project in valaide and I have got these errors:

1. when I try to create a new project :
valide_project_manager_copy_template: assertion `path != NULL' failed

2. so i create a project by hand copying from glade1.vide in this thread and than open the project and tried to compile. but I have got this error:

PCRE library is compiled without UTF8 properties support.

Coul any one help me to understand what's wrog !

thanks

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

#164 Post by MU »

gpnet,
Please use this gtksourceview, the other one works erratic:
http://dotpups.de/puppy4/dotpups/Progra ... -2.4.2.pet

I also attach the pcre-libraries I use in newyearspup.
Maybe those work for you.

Caleb,
no, the libs are not built into the binary.

There are 2 ways to deliver them:
1.) the user installs vala, a 10 MB download.
2.) you add the required libs in the same folder, where your binary is located.

I made a 5 MB (12 MB extracted) example package including required Wiindows libs:
http://www.murga-linux.com/puppy/viewtopic.php?t=40193
It is a pet, so easy to install, then it can be run with Wine.

Mark
Attachments
libpcre.tar.gz
(161.09 KiB) Downloaded 688 times
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

gpnet
Posts: 56
Joined: Sat 09 May 2009, 15:49
Location: Ivrea ,Italy

#165 Post by gpnet »

Hi Mu,

Thanks for replay,

No, I can't use the gtksourceview 2.4.2 with valaide because if I do that (i tried ) I lost syntax Highlight ( almost in vala ). So I had to come back to previous version.

Thank you for the pcre libraries , I presume I have to replace the older one?

And what about the creation of a new project :assertion `path != NULL' failed
have you any suggestion?.

Also I notice that to work with vala / glade would be necessary the 3.6.x version because with this version you can save the xml UI in proper way for Gtk.Builder("xxxxx");
Have you any news about a new release or could I install it from deb packages ?.

Tanks a lot.

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

#166 Post by MU »

I have not used Gtkbuilder yet, as I did not understand exactly, how to use those files in Genie.
It is something though I must look at in future, as libglade has become depreciated, and Gtkbuilder shall be used instead.

Concerning libpcre:
yes, replace them (but backup the old ones first).
Or better try what I suggest next:

I just tried to reproduce your problems in Puppy 4.20.
It works however.

I installed these files:
http://dotpups.de/puppy4/dotpups/Progra ... 0-i486.pet
http://dotpups.de/puppy4/dotpups/Progra ... -2.4.2.pet
http://dotpups.de/puppy4/dotpups/Progra ... -03-27.pet

Then in a console, I typed:
validestart

I clicked on "new projet", chose "Genie , Gtk".
Filled in every field then (that is important - also the license, or the IDE crashes later, if you try to open the options).

If you loose syntax highligting in other programs, try to run them with a startscript like /usr/bin/validestart.
It forces to load the newer Gtk libraries required by the newer gtksourceview.

If you need help with that, let me know.
I can compile vala 0.7.2 tomorrow, today I was away and had no time for programming.
Tomorrow I will be away, too, but hope I can compile it in the evening.
For first steps, 0.7.0 should be fine though.
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:

#167 Post by MU »

and important:
if you use Vala-IDE, other programs might crash afterwards, e.g. seamonkey.
This happens if you try to open the "file open" diialog.
The reason is the file /root/.recently-used.xbel.

Simply delete it then, the Ide seems to write a wrong line in there.

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

gpnet
Posts: 56
Joined: Sat 09 May 2009, 15:49
Location: Ivrea ,Italy

#168 Post by gpnet »

Hi MU,

Sorry , I didn't save the libs before replacing.

Any way I can tray to copy from the .sfs. Well now I remove the currents and try to install the packages you link me.
I would like to get rid of this!.

I thank you if you can compile vala 0.7.2.

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

#169 Post by MU »

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

gpnet
Posts: 56
Joined: Sat 09 May 2009, 15:49
Location: Ivrea ,Italy

#170 Post by gpnet »

Thank you MU

Now I'll try. I'll keep you informed.

Post Reply