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

Re: [Basic Glib Questions/Help] Unable to create GSource




You should replace this line:

        GSource*        clash_console_source    = g_source_new
(&clash_console_source_funcs, sizeof
(clash_console_source_funcs));

with the obvious fix:

        GSource*        clash_console_source    = g_source_new
(&clash_console_source_funcs, sizeof (GSource));

The docs state that:

struct_size :	 size of the GSource structure to create

So it's not the size of source_funcs parameter (which is fix),
but is the size of _derived_ type you have created based on
GSource.  In your case, you don't have a derived type, so simply
use GSource itself and pass sizeof(GSource) as struct_size.

http://lidn.sourceforge.net/books/glib-2.0/book/glib-the-main-event-loop.html#G-SOURCE-NEW

behdad


On Sun, 21 Dec 2003, Ryan McDougall wrote:

> On Sun, 2003-12-21 at 15:34, Michael Torrie wrote:
> > On Sun, 2003-12-21 at 15:27, Ryan McDougall wrote:
> >
> > > Any help is appreciated!
> >
> > Afraid you'll need to post the source code.  Can't do anything with just
> > a binary.
>
> My apologies!! I posted the binary by accident. *embarassed*
> >
> > It would also help if you told us specifically what you want
> > accomplish.  Your description was a bit vague.  My understanding of the
> > glib event loop is that unless you have written a console driver (not
> > the write word) to push events into the glib loop (much as gtk brings
> > X11 events into the loop), you'll probably not be able to use the glib
> > main event loop in the manner you are seeking.  In other words you might
> > have to use the old
>
> My understanding is that I can define an arbitrary "source" of data
> events. Specifically all I want to do at this point is send events from
> stdin to stdout, similar to using select(2) to monitor stdin/out, but in
> Glib terms. Basically I want to the context to monitor those two files
> and call my signals when there is data to be read or written.
>
> I know how to do this via select(2), and I was under the impression that
> this is what the main loop was meant to do. Once again, if my ideas are
> on crack, Id love to see a doc that explains things better...
>
> >
> > while (g_main_context_pending(context))
> > g_main_context_iteration(context, may_block)
> >
> > trick so that you can keep control of the program in your code.
> > Remember that glib's event loop takes command.  You're program flow is
> > no longer linear.  Typically console-based programs are intended to be
> > linear.
> >
> > Michael
> >
>
> Thanks for you time Micheal!
> >
> > >
> > > Cheers,
> > > Ryan
>



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