Re: libseed-list watching stdin



 
> > The new API has changed (most of the methods have moved into
> > GLib.IOChannel http://devel.akbkhome.com/seed/GLib.IOChannel.html
> 
> Ok, I see. Will the old API still be there?

Nope, I've had to do this in some of my code to handle the potential changes.

var gdir = GLib.dir_open(dir,0);
...
var fn = gdir.read_name ? gdir.read_name () : GLib.dir_read_name(gdir);
...
gdir.close ? gdir.close() : GLib.dir_close(gdir);


> 
> I don't see any method to create an IOChannel from an existing fd 
> though, something like 'new GLib.IOChannel.fd(n)' ?

There is cross references at the bottom of the io channel page.
http://devel.akbkhome.com/seed/GLib.IOChannel.html

I'm guessing this is what you where looking for.
GLib.io_channel_unix_new (Number fd)

> 
> > For some of this to work, we need support for byte arrays using the
> > new introspection array syntax. - those methods also need correct
> > introspection hints.
> 
> What's that?



This is the comment above read_chars in here. - I've added what might work as introspection hints.
http://git.gnome.org/browse/glib/tree/glib/giochannel.c

Details of how annotations are here.
http://live.gnome.org/GObjectIntrospection/Annotations

However, Seed does not support this type of array yet. - it should end up generating a GIR with array type hints... with the latest introspection release..

**
 * g_io_channel_read_chars:
 * @channel: a #GIOChannel
 * @buf: (inout) (array length=count) (element-type uchar): a buffer to read data into
 * @count: the size of the buffer. Note that the buffer may
 *         not be complelely filled even if there is data
 *         in the buffer if the remaining data is not a
 *         complete character.
 * @bytes_read: (out) The number of bytes read. This may be zero even on
 *              success if count < 6 and the channel's encoding is non-%NULL.
 *              This indicates that the next UTF-8 character is too wide for
 *              the buffer.
 * @error: (out) a location to return an error of type #GConvertError
 *         or #GIOChannelError.
 *
 * Replacement for g_io_channel_read() with the new API.
 *
 * Return value: the status of the operation.
 **/



> 
> /Jonatan
> 
> > Regards Alan
> > 
> > --- On 24/Jun/2010, Jonatan Liljedahl wrote:
> >> This worked:
> >> 
> >> GLib.io_add_watch(stdin, 0, GLib.IOCondition.IN, watch_func);
> >> 
> >> And I had to use GString as buffer when reading:
> >> 
> >> var linebuf = new GLib.String; var codebuf = ""; var watch =
> >> function(source, condition, data) { 
> >> GLib.io_channel_read_line_string(source, linebuf); codebuf +=
> >> linebuf.str; .... return true; }
> >> 
> >> It would be nice if also the other read-functions worked, those who
> >> take a gchar pointer. How does Seed handle pointer-arguments?
> >> 
> >> Also, why does some stuff work in OOP style and some not? I created
> >> the GString with "new GLib.String", but it doesn't seem to have any
> >> methods. The IOChannel is created with GLib.io_channel_unix_new(),
> >> since "new GLib.IOChannel" can't pass any filedescriptor. And the
> >> returned IOChannel doesn't have any methods either. Is this because
> >> both are only GLib and not GObject?
> >> 
> >> /Jonatan
> >> 
> >> Jonatan Liljedahl wrote:
> >>> What's the simplest way to have a watcher on stdin?
> >>> 
> >>> I tried something like 
> >>> GLib.io_channel_add_watch(GLib.io_channel_unix_new(1),1,my_func)
> >>> but get "ConversionError Can not convert Javascript value to
> >>> long".
> >>> 
> >>> /Jonatan
> >>> 
> >>> _______________________________________________ libseed-list
> >>> mailing list libseed-list gnome org 
> >>> http://mail.gnome.org/mailman/listinfo/libseed-list
> >> _______________________________________________ libseed-list
> >> mailing list libseed-list gnome org 
> >> http://mail.gnome.org/mailman/listinfo/libseed-list
> > 
> > _______________________________________________ libseed-list mailing
> > list libseed-list gnome org 
> > http://mail.gnome.org/mailman/listinfo/libseed-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]