Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > More E-Book Readers > iRex > iRex Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 10-30-2009, 08:44 AM   #76
Iņigo
Guru
Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.
 
Posts: 712
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, in love with iRex DR800S. Also a K4NT. Now a Kobo Aura
Quote:
Originally Posted by ericshliao View Post
One question:
How to operate with GTK, GDK...function in Lua script? I know that there is a dir "examples" in lgob and I can learn a lot by imitating the examples. But, where is the manual (not the officail GTK documentation)?
There isn't any.
Study those examples and take also a look at hansel's and my own's programs: multicalc, minipad, toolbox...[*]

I usually check pygtk docs and programs too and then translate to lua. Though is not directly translatable it should point you in the proper direction. Note that callbacks send arguments in a different way.

Iņigo
[*] Hansel lua code is quite polished and pretty, mine is ugly 'cos I don't know lua much.
Iņigo is offline   Reply With Quote
Old 10-30-2009, 09:45 AM   #77
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 974
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
Well, I can live without a manual.
Just wrote a image viewer running on iLiad in 15 lines of lua script. And the speed is quite fast. Really amazing.
In fact, lgob provides operation with ATK, CAIRO, PANGO, GDK ,GTK in lua script.
I guess I can turn my homebrew application written in over one thousand lines of C code to 200 lines of lua script.
ericshliao is offline   Reply With Quote
 
Advertisement
Old 10-30-2009, 10:04 AM   #78
Iņigo
Guru
Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.
 
Posts: 712
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, in love with iRex DR800S. Also a K4NT. Now a Kobo Aura
Quote:
Originally Posted by ericshliao View Post
Well, I can live without a manual.
Just wrote a image viewer running on iLiad in 15 lines of lua script. And the speed is quite fast. Really amazing.
In fact, lgob provides operation with ATK, CAIRO, PANGO, GDK ,GTK in lua script.
I guess I can turn my homebrew application written in over one thousand lines of C code to 200 lines of lua script.
Good!

note however that some recent pango/gtk/... functions are not available on Iliad.
I consult pygtk docs to find out which they are.

I have just joined #iliad in irc.freenode.net if you want realtime chat ;-)

Iņigo
Iņigo is offline   Reply With Quote
Old 10-30-2009, 01:30 PM   #79
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 974
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
Iņigo,
thanx. I need some time to adapt to the way to call GTK+ function in lua.
This is a image viewer written in lua. Users can open file dialog to choose a image file to open. Unpack to anywhere and execute from Contentlister.
Attached Thumbnails
Click image for larger version

Name:	Debian5-2009-10-31-00-31-19.png
Views:	82
Size:	98.5 KB
ID:	38308  
Attached Files
File Type: zip luademo.zip (17.4 KB, 71 views)
ericshliao is offline   Reply With Quote
Old 10-30-2009, 02:07 PM   #80
hansel
JSR FFD2
hansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheese
 
hansel's Avatar
 
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
Quote:
Originally Posted by ericshliao View Post
Well, I can live without a manual.
The official gtk docs are quite good.
The Lua api is almost identical to the C api if you replace the underscores with dots, and capitalize here and there

Pay special attention where it mentions 'available since...' If its old enough, it will work on the Iliad. The Iliad versions are
  • GOBJECT=2.6.6
  • GDK=2.6.7
  • PANGO=1.8.1
  • GTK=2.6.7

Great to see your enthusiasm!
Happy coding,
Hansel
hansel is offline   Reply With Quote
Old 10-30-2009, 03:03 PM   #81
Iņigo
Guru
Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.
 
Posts: 712
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, in love with iRex DR800S. Also a K4NT. Now a Kobo Aura
Help: call to poweroff doesn't work inside lgob callback

Does anyone know why this code does not work?

Code:
btn:connect("clicked", function ()
                              win:hide()
                              win:destroy()
                              os.execute("/sbin/poweroff")
                           end)
If I substitute "/bin/poweroff" with "/sbin/fconfig" it prints ifconfig output on the terminal, so I'm pretty sure callback is correctly called.

I've also checked with "shutdown -t 0 now".
No way to switch off the Iliad from inside a lua+lgob program.

Thanks,
Iņigo
Iņigo is offline   Reply With Quote
Old 10-30-2009, 03:04 PM   #82
hansel
JSR FFD2
hansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheese
 
hansel's Avatar
 
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
Quote:
Originally Posted by Iņigo View Post
In my dreams, we should have a lua module for all this stuff...
I'll do that some day (if you don't beat me at it )... Basically it's not difficult: a Lua wrapper for liberipc/eripcclient would provide most functions...
hansel is offline   Reply With Quote
Old 10-30-2009, 03:11 PM   #83
hansel
JSR FFD2
hansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheese
 
hansel's Avatar
 
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
Quote:
Originally Posted by Iņigo View Post
Does anyone know why this code does not work?
Maybe because it's a symbolic link? try /sbin/halt.sysvinit (not sure, just guessing, untested)
hansel is offline   Reply With Quote
Old 10-30-2009, 03:43 PM   #84
Iņigo
Guru
Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.
 
Posts: 712
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, in love with iRex DR800S. Also a K4NT. Now a Kobo Aura
Quote:
Originally Posted by hansel View Post
Maybe because it's a symbolic link? try /sbin/halt.sysvinit (not sure, just guessing, untested)
That didn't work either.
It's strange because /sbin/reboot works, and it's a link in fact.

Anyway, I've found a command that can shutdown the Iliad "/sbin/shutdown.sysvinit -h -P now"!

I'll study it a bit more...

Thanks,
Iņigo
Iņigo is offline   Reply With Quote
Old 10-31-2009, 09:50 AM   #85
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 974
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
I have a question:
Can I access gdk_gc_new() (http://library.gnome.org/devel/gdk/s...-Contexts.html) in lua script through lgob?

I want to use some GDK drawing primitives (http://library.gnome.org/devel/gdk/2...rimitives.html), and some functions need GdkGC parameter.

Added:
I figured it out. It's gdk.GC.new().

Last edited by ericshliao; 10-31-2009 at 10:23 AM.
ericshliao is offline   Reply With Quote
Old 10-31-2009, 10:40 AM   #86
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 974
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
Another question:
I want to access some function, such as pango_matrix_rotate() (http://library.gnome.org/devel/pango...h-Storage.html). I have tried several times with no success. How do I know if certain function can be access through lgob, and in what form?

Added:
It seems the correct form is pango.Matrix.rotate().

Last edited by ericshliao; 10-31-2009 at 10:47 AM.
ericshliao is offline   Reply With Quote
Old 10-31-2009, 11:23 AM   #87
Iņigo
Guru
Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.
 
Posts: 712
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, in love with iRex DR800S. Also a K4NT. Now a Kobo Aura
Quote:
Originally Posted by ericshliao View Post
Another question:
I want to access some function, such as pango_matrix_rotate() (http://library.gnome.org/devel/pango...h-Storage.html). I have tried several times with no success. How do I know if certain function can be access through lgob, and in what form?

Added:
It seems the correct form is pango.Matrix.rotate().
Same happens to me from time to time.
What I do is grep lgob sources for the function I need. Look at the .def, .ovr, and iface.c files.

Also, note that the translation from C to lua is almost always done in this way:

module_widget_method => module.Widget.method

so pango_matrix_rotate() => pango.Matrix.rotate()


Btw, instead of using GDK drawing primitives, maybe is a better option to use Cairo, it's much powerful, easier and looks it has better documentation as well.
You can find 3 or 4 examples in lgob sources too.


Regards,
Iņigo
Iņigo is offline   Reply With Quote
Old 10-31-2009, 12:08 PM   #88
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 974
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
Another question:
I have a line of C code "PangoMatrix matrix = PANGO_MATRIX_INIT;" (http://library.gnome.org/devel/pango...h-Storage.html) and I want to convert it to Lua. The line will create a struct consisting 6 double variables.

I tried with "p_matrix = pango.PANGO_MATRIX_INIT". Lua interpretor did accept the form, but in fact p_matrix is still "nil". How do I solve the problem?

Added:
There seems a convenient utility: toLua (http://www.tecgraf.puc-rio.br/~celes/tolua/). But I can't build it on my Linux desktop.

Added 2:
I can build toLua now, but it seems not what I want.

Added 3:
Problem solved. The correct form is "p_matrix = pango.Matrix.INIT".

Added 4:
I am wrong. "p_matrix = pango.Matrix.INIT" is not correct.

Last edited by ericshliao; 10-31-2009 at 02:17 PM.
ericshliao is offline   Reply With Quote
Old 10-31-2009, 01:10 PM   #89
hansel
JSR FFD2
hansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheese
 
hansel's Avatar
 
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
Quote:
Originally Posted by ericshliao View Post
Another question: How do I know if certain function can be access through lgob, and in what form?(
A cool tool is the Navigator example in the lgob distro: you can load any Lua module (such as lgob.gdk), and view al functions and constants that are in i

I also wrote a function 'pr()' (included in MiniPad.tgz), which recursively prints any Lua variable. The top table in Lua is '_G'. So if you load some modules with require, and then do pr(_G), it will show you all variables (including all known modules and functions)

Happy Lua!
hansel is offline   Reply With Quote
Old 10-31-2009, 01:14 PM   #90
hansel
JSR FFD2
hansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheese
 
hansel's Avatar
 
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
Smile SPAM

This is becoming a top thread: 6th if you sort by nr of replies
It even beats the battery hack thread
hansel is offline   Reply With Quote
Reply

Tags
gtk+, iliad, lgob, lua, networking, xml

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pandigital announce the black Novel Nate the great News 0 08-18-2010 06:21 PM
iLiad China iLiad users can get developer package. ericshliao iRex Developer's Corner 35 03-20-2010 06:21 AM
iLiad Announce: Glade4Lua, develop graphical apps for the Iliad hansel iRex Developer's Corner 1 10-27-2009 06:00 PM
Sony to announce colour e-book ? markiehill News 11 08-22-2009 01:45 PM
Proud to announce our new moderator! Alexander Turcic Announcements 5 12-09-2003 12:18 AM


All times are GMT -4. The time now is 06:47 PM.


MobileRead.com is a privately owned, operated and funded community.