Hi Guido,
Terribly sorry for late reply.
Many of the GLib functions that takes a GMainContext to
"attach" to
accepts NULL instead of an actual main context. If you pass
NULL to
these functions it is going to use the default main context
which is
created and "owned" by GLib.
20 apr 2008 kl. 17.05 skrev Guido Parente:
> Hi everyone,
> I'm a new user of Loudmouth and I've got a question
about GMainLoop.
> I wrote a client that is able to catch and parse
incoming messages.
> In order to keep it alive I used an instance of
GMainLoop and added
> these lines at the end of my Main function:
>
> GMainLoop * main_loop= g_main_loop_new (NULL, FALSE);
> g_main_loop_run (main_loop);
>
> The client works well.
> The question is: in g_main_loop_new() I don't pass any
GMainContext
> as argument so I suppose it uses the default context.
> I saw that in _LmConnection struct there is a
GMainContext variable
> that is filled with some stuff (channel, callback..).
Does it become
> the default context in some implicit way?
> For example, I saw in lm_connection_new_with_context()
the use of
> function g_main_context_ref(connection->context). It
is mandatory
> only for other context than default?
The reason we reference the main context passed in to
lm_connection_new_with_main_context is because Loudmouth
then holds a
reference to this context.
> In other words, how does GMainLoop understand (if it
understands
> it....)that the GMainContext variable in _LmConnection
struct is the
> default context?
The GMainContext in the LmConnection struct is NULL by
default so
unless you set it you are going to pass in NULL to the GLib
functions
(which as mentioned above, means the default context).
> Another question: the previous doubt comes out because
I'd like to
> use Loudmouth to write a GUI client under Windows
using wxWidgets.
> Do you think it's possible? Could this dependency to
GMainLoop (and
> GLib in general) cause any problem?
I must admit that I don't have any experience with wxWidgets
or it's
integration with the GLib mainloop. I would however urge you
to use GTK
+ instead
Cheers,
Micke
--
Mikael Hallendal
Imendio AB - Expert solutions in GTK+
http://www.imendio.com
_______________________________________________
Loudmouth mailing list
Loudmouth lists.imendio.com
h
ttp://lists.imendio.com/mailman/listinfo/loudmouth
|