Re: [gtk-list] Proposal: changes to _interp functions
- From: Tim Janik <timj gimp org>
- To: Owen Taylor <owt1 cornell edu>
- cc: Gtk+ MList <gtk-list redhat com>
- Subject: Re: [gtk-list] Proposal: changes to _interp functions
- Date: Tue, 10 Feb 1998 21:33:47 +0100 (CET)
On 10 Feb 1998, Owen Taylor wrote:
>
> Problem:
> -------
>
> With the current _interp() functions, it is not possible to notified
> when the handler is removed, and then free the data, without also
> using the full marshalling mechanism.
>
> ("Full marshalling mechanism" means that instead of supplying a
> normal C language callback, you supply "GtkCallbackMarshall"
> function, which takes a GtkArg array; giving both type information
> and a value.)
>
> This requirement is a pain both for applications and for
> statically typed language bindings. Dynamic type is not useful;
> notification when the callback data is no longer needed is
> still needed.
so if there are *two* different needs, why don't we provide two
different interfaces for it? (explaination is at the end)
> Proposal:
> --------
>
> A typical _interp function currently looks like:
>
> gint
> gtk_timeout_add_interp (guint32 interval,
> GtkCallbackMarshal function,
> gpointer data,
> GtkDestroyNotify destroy);
>
> The simplest change would be to add a flag indicating whether
> 'function' is a C callback function or a marshal function.
this falg could be kept internal if we provide different functions.
> gint
> gtk_timeout_add_interp (guint32 interval,
> GtkFunction function,
> gboolean is_marshal,
> gpointer data,
> GtkDestroyNotify destroy);
>
> This, however means that 'function' will have a different type
> signature depending on is_marshal. So it might be better to
> do:
the different signatures would be handled internaly then,
and i think that would be acceptible.
> gint
> gtk_timeout_add_interp (guint32 interval,
> GtkFunction function,
> GtkCallbackMarshal marshal,
> gpointer data,
> GtkDestroyNotify destroy);
>
> And specify that 'function' is ignored if 'marshal' is
> given. Marius actually proposed a variant on this where
> both 'function' and 'marshal_func' have meanings (see below).
> I tend to think that that is an unnecessary complication.
hm, so you are always required to use the "full-blown" signature
of gtk_timeout_add_interp, for two different things, which
in turn requires you to pass at least one argument as NULL.
> I'd actually also like to change the name of the _interp functions -
> since they'll no longer be just for interpreted languages, and the
> suffix is confusing to begin with. My preference would be simply:
>
> gtk_timeout_add_full (...)
now what i'm suggesting is to have two different interfaces:
gint
gtk_timeout_add_notify (guint32 interval,
GtkFunction function,
gpointer data,
GtkDestroyNotify notify);
gint
gtk_timeout_add_notify_marshal (guint32 interval,
GtkCallbackMarshal function,
gpointer data,
GtkDestroyNotify notify);
internaly we cast the "GtkCallbackMarshal function" argument to an
ordinary function pointer for storage, and keep a flag that describes
what signature will be used for the invokation.
i even think this approach will be more consistent with the rest
of the toolkit, e.g. take a look at gtk_signal_connect,
gtk_signal_connect_after, gtk_signal_connect_object and
gtk_signal_connect_object_after (and gtk_signal_connect_interp), they are
all front ends for gtk_signal_connect_by_type which takes a variety of
flags to determine the actual behaviour.
>
> Regards,
> Owen
>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]