Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 27 Aug 2014, 11:24
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Vala and Genie programming
Post new topic   Reply to topic View previous topic :: View next topic
Page 29 of 35 [517 Posts]   Goto page: Previous 1, 2, 3, ..., 27, 28, 29, 30, 31, 32, 33, 34, 35 Next
Author Message
nikobordx

Joined: 23 May 2009
Posts: 84
Location: Bordeaux, France

PostPosted: Sun 20 Sep 2009, 07:59    Post subject:  

For NicoEdit, see post:
http://www.murga-linux.com/puppy/viewtopic.php?t=46629&start=15

Nicolas.
Back to top
View user's profile Send private message 
caleb72

Joined: 15 May 2009
Posts: 57

PostPosted: Tue 20 Oct 2009, 21:26    Post subject:  

This topic hasn't really moved much for a while.

I'm trying again to find time to teach myself Genie and I've got some ideas in mind for some utilities but as we know a huge amount of documentation isn't on hand although there are some good examples in this thread.

What I thought I might do to start teaching myself Gtk programming in Genie is to translate the current Vala Gtk+ Examples into Genie syntax.

I thought it might be useful to have a direct document that could help me see the same examples in Genie syntax that newcomers to Vala have been enjoying previously.

Ideally it would be nice to flesh it out into a full tutorial, but I doubt I would find the time. In any case I really learn by example alot of the time and can't guarantee that I would explain the underlying theories of what's happening with great accuracy as I really know nothing about Gtk in general and am relying on just being able to understand how to use it much like people learning a foreign language through emersion.

Anyway - to my question. Would such an exercise be worthwhile to publish somewhere for other Puppyites?

At the least it's a personal exercise to get me across Gtk programming in Genie - but it could potentially be added somewhere for common reference if it's going to be useful.

Regards
Caleb
Back to top
View user's profile Send private message 
nikobordx

Joined: 23 May 2009
Posts: 84
Location: Bordeaux, France

PostPosted: Wed 21 Oct 2009, 04:36    Post subject:  

Hi Caleb,

I've created some gtk examples in http://code.valaide.org/

I'm also working on a code generator for genie, and i will make a website with many sample.

Nicolas.
Back to top
View user's profile Send private message 
caleb72

Joined: 15 May 2009
Posts: 57

PostPosted: Wed 21 Oct 2009, 05:17    Post subject:  

Oooh - thanks for that. I didn't realise there were so many samples available. I've bookmarked it for future reference.

Actually - that makes me more determined to do what I was doing so that I can compare the code that I think looks right with how other people are doing the same thing. Thanks for that.

Regards
Caleb
Back to top
View user's profile Send private message 
caleb72

Joined: 15 May 2009
Posts: 57

PostPosted: Thu 22 Oct 2009, 03:29    Post subject:  

I've been managing to convert the Vala GTK+ examples I've seen quite easily into Genie - even managed to convert a GtkBuilder example.

Although I have to say, it's a bit weird implementing callback methods via GtkBuilder (in Vala anyway). I haven't tried these peculiarities in Genie. Things like this:

Quote:
If you declare the callback methods inside a class and/or namespace you have to prefix the callback method in Glade with the namespace/class name in lower case letters and with underscores. For example, Foo.MyBar.on_button_clicked would be foo_my_bar_on_button_clicked in Glade


And this:

Quote:
If you want the callback methods to be instance methods instead of static methods you have to annotate them with the [CCode(instance_pos=-1)] attribute and pass the instance to connect_signals(...) instead of null


Bizarre.

My instinct in coding these signals/callback methods is to have the GUI XML file as per normal and then I would have an Application class which defines all the callback methods, initiates the gui interface and interacts with the other classes that define the application model as a whole. If the advice above applies to Genie that would mean either I have to create slightly weird signals in that they won't look exactly the same as the callback methods they trigger, or I would need to include this weird CCode thingy in my code which looks incomprehensible to me.

I'm guessing I could also define the callback methods outside of the Application class I create, but that seems a bit weird to me.

Just wondering if there are other people out there using GtkBuilder either in Vala or Genie that could put some perspective on this for me. It may be that I'm just not getting it.

Regards
Caleb
Back to top
View user's profile Send private message 
ttuuxxx


Joined: 05 May 2007
Posts: 10747
Location: Ontario Canada,Sydney Australia

PostPosted: Thu 22 Oct 2009, 03:54    Post subject:  

Why doesn't someone add tabs to NicoEdit and then I could ditch Geany ??
ttuuxxx

_________________
http://audio.online-convert.com/ <-- excellent site
http://samples.mplayerhq.hu/A-codecs/ <-- Codec Test Files
http://html5games.com/ <-- excellent HTML5 games Smile

Back to top
View user's profile Send private message Visit poster's website 
caleb72

Joined: 15 May 2009
Posts: 57

PostPosted: Thu 22 Oct 2009, 04:07    Post subject:  

ttuuxxx wrote:
Why doesn't someone add tabs to NicoEdit and then I could ditch Geany ??
ttuuxxx


I actually like Geany - but it doesn't have syntax highlighting for Genie which is a bit of a bummer. In fact, the Genie syntax highlighting is the only reason I use NicoEdit. I know there's others I could use for that but NicoEdit came with 4.3 so I figure - why not?

It would be nice to have a pIDE though don't you think? Something like Geany but possibly lighter, developed in something like vala or genie and developed/maintained by Puppy people.

Regards
Caleb
Back to top
View user's profile Send private message 
ttuuxxx


Joined: 05 May 2007
Posts: 10747
Location: Ontario Canada,Sydney Australia

PostPosted: Thu 22 Oct 2009, 04:20    Post subject:  

caleb72 wrote:
ttuuxxx wrote:
Why doesn't someone add tabs to NicoEdit and then I could ditch Geany ??
ttuuxxx


I actually like Geany - but it doesn't have syntax highlighting for Genie which is a bit of a bummer. In fact, the Genie syntax highlighting is the only reason I use NicoEdit. I know there's others I could use for that but NicoEdit came with 4.3 so I figure - why not?

It would be nice to have a pIDE though don't you think? Something like Geany but possibly lighter, developed in something like vala or genie and developed/maintained by Puppy people.

Regards
Caleb


I actually like codebrowser but the only thing I don't like about it is that you have to rt click the document and select on the list close page, it should have a close tab on the main gui user interface.
http://www.murga-linux.com/puppy/viewtopic.php?p=350519&sid=32fd611f1beac5586f3c5a6ddcb65e87 and at 178kb pet its 1/4 the size of Geany and its smaller than nicoedit if you remove all the vala and genie deps that you need to install to run it on say 2.14X or 3, early 4 series. etc

ttuuxxx

_________________
http://audio.online-convert.com/ <-- excellent site
http://samples.mplayerhq.hu/A-codecs/ <-- Codec Test Files
http://html5games.com/ <-- excellent HTML5 games Smile

Back to top
View user's profile Send private message Visit poster's website 
caleb72

Joined: 15 May 2009
Posts: 57

PostPosted: Fri 23 Oct 2009, 09:09    Post subject:  

Hmmm - anyone know if you can split source over multiple lines or have multi-line string values in Genie source?

eg:

Code:

do_action(parameter1, parameter2, parameter3,
        parameter4, parameter5)


and:

Code:

this_string = """I am a multi-line string.
Hope this is what you were looking for."""


These examples are Python syntax, but I'm hoping there is a way in Genie to accomplish the same tasks. So far none of the example I've seen break a line of code over multiple lines of source and I can't find any reference to the notion. So I'm wondering if Genie just doesn't have this.

Regards
Caleb
Back to top
View user's profile Send private message 
nikobordx

Joined: 23 May 2009
Posts: 84
Location: Bordeaux, France

PostPosted: Fri 23 Oct 2009, 13:42    Post subject:  

Hi Caleb,

For the first i don't know !
Try this:

def do_action (
parameter1
parameter2
)

For the second i use:

test : string = """
blah blah blah
blah blah blah blah blah
blah blah blah blah blah blah blah
"""

And it's work !

Nicolas.
Back to top
View user's profile Send private message 
caleb72

Joined: 15 May 2009
Posts: 57

PostPosted: Fri 23 Oct 2009, 20:25    Post subject:  

Thanks Nicholas - don't know why I was having trouble with that second one. Embarassed

The first idea didn't seem to work. Oh well - it's just handy if you've got a massive list of parameters sometimes to break it up over multiple lines for readability. I can, of course, live without it.

Regards
Caleb
Back to top
View user's profile Send private message 
nikobordx

Joined: 23 May 2009
Posts: 84
Location: Bordeaux, France

PostPosted: Sat 24 Oct 2009, 05:04    Post subject:  

Hi Caleb,

If you have another question you can contact the "genie" creator Jamie at jamie.mccrack@gmail.com

Nicolas.
Back to top
View user's profile Send private message 
caleb72

Joined: 15 May 2009
Posts: 57

PostPosted: Sat 24 Oct 2009, 06:40    Post subject:  

You know - that's an excellent idea. I'm not sure if he's inundated with email about Genie - but if not, he might even get a kick out of knowing people are learning the Genie syntax.

Regards
Caleb
Back to top
View user's profile Send private message 
Lobster
Official Crustacean


Joined: 04 May 2005
Posts: 15117
Location: Paradox Realm

PostPosted: Sun 25 Oct 2009, 03:13    Post subject:  

Barry has announced a focus on Genie, with updates
http://www.puppylinux.com/blog/?viewDetailed=01181

This page much of it based on Barry's page could do with splitting into Genie and Vala and updating
http://puppylinux.org/wikka/GenieProgramming

Smile

_________________
Puppy WIKI
Back to top
View user's profile Send private message Visit poster's website 
caleb72

Joined: 15 May 2009
Posts: 57

PostPosted: Tue 27 Oct 2009, 00:30    Post subject:  

Just put together a small example of using the libxml library in Genie.

The program just reads in the .jwmrc-tray file and prints out its components - nodes, attributes and text.

It's fairly meaningless on its own but I put it together to learn a bit more about the libxml library as I am working on something related to parsing JWM configuration files.

Code:

[indent=3]
uses
   Xml

class JWMReader : Object
   path : string

   init
      Parser.init()

   final
      Parser.cleanup()

   def run()
      var doc = Parser.parse_file(path)
      var node = doc->get_root_element()
      parse_node(node)

   def set_source(pathname : string)
      path = pathname

   def private parse_node(node : Xml.Node*)
      if node is null
         return
      case node->type
         when ElementType.ELEMENT_NODE
            print "NODE: %s", node->name
            if node->properties is not null
               get_attributes(node, node->properties)
            if node->children is null
               node = node->next
            else
               node = node->children
         when ElementType.TEXT_NODE
            if not (node->content.strip() is "")
               print "TEXT: %s", node->content.strip()
            if node->next is null
               node = node->parent->next
            else
               node = node->next
         when ElementType.COMMENT_NODE
            node = node->next
         default
            print("DO NOT RECOGNISE NODE!")
            return   
      parse_node(node)

   def private get_attributes(node : Xml.Node*, properties : Xml.Attr*)
      if properties is null
         return
      print "ATTR: %s VALUE: %s", properties->name, node->get_prop(properties->name)
      properties = properties->next
      get_attributes(node, properties)

init
   var reader = new JWMReader()
   reader.set_source("/root/.jwmrc-tray")
   reader.run()


If you actually wanted to compile this, the command would be:

Code:
valac --pkg libxml-2.0 indent.gs


You'll get a warning about unreachable code but it doesn't stop anything from running. Perhaps I should have used an 'if/else' construct rather than just an 'if' what I used there - but I believe it's doing what I wanted it to.

If you feel compelled to pick this to pieces - that's fine. I might learn something out of it.

A note about libxml. I've only just tried to get my head around this and I come from a Python background where I don't have to worry too much about memory management. Genie doesn't either except I believe if pointers are specifically created. Apparently this is your way of saying I want to handle this manually.

There are pointers in the above code and I have not specifically cleaned them up so this code in a larger program may cause issues. The Parser.cleanup() line may not actually completely clean this stuff up.

That may all be complete bollocks, but it's just the understanding I have right now. I will be looking into how to handle these pointers better as I progress.

Regards
Caleb
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 29 of 35 [517 Posts]   Goto page: Previous 1, 2, 3, ..., 27, 28, 29, 30, 31, 32, 33, 34, 35 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0970s ][ Queries: 12 (0.0054s) ][ GZIP on ]