GtkBuilderConnectFunc and <signal> tag



Tristan Van Berkom wrote:
[..]
>>> Another important point that was raised:
>>>
>>> On Wed, 2007-06-13 at 10:01 -0300, Johan Dahlin wrote:
>>> [...]
>>>> Well, actually swapped handlers are supported, using the object attribute, eg:
>>>>
>>>>   <object class="GtkButton" id="button"/>
>>>>   <object class="GtkEntry" id="entry">
>>>>     <signal name="activate" handler="button_clicked" object="button"/>
>>>>   </object>
>>> I think its quite important here to not repeat one of the 
>>> the most obvious mistakes of glade/libglade, swapping the
>>> signal based on the fact that an "object" was specified
>>> is confusing - it also rules out the use case of specifying
>>> a signal that is not swapped & has an object user_data.
>>>
>>> Can we please not swap signal handlers unless they are
>>> explicitly specified ?
>>>
>>>   <object class="GtkEntry" id="entry">
>>>     <signal name="activate" handler="button_clicked" object="button"/> 
>>>   </object>
>> I mainly kept this for Glade compatibility, I'd be happy to remove the
>> object attribute if it's not something you're keen to support.
> 
> I think you misunderstand me, my request is that we do support
> "objects", and we do support "swapped", just that one does not
> imply the other.
> 
> in this patch[1] to libglade we added support for optionally looking
> up the userdata in the running application using dlsym(), which would
> also be a useful alternative for the user_data field, this could
> be a good future expansion to how the user data is used in builder
> (integers or enums passed in as GINT_TO_POINTER() are also a
> good candidate).
> 
> So to recap:
>   - The user should be allowed to specify something for user_data of
>     a signal (currently only "object" is supported)
>   - The user should be allowed to connect handlers "swapped" for
>     whatever convenient reason (i.e. connecting gtk_widget_hide()
>     on some other object and swapping it so that its the first arg).
>   - The builder should not assume that if the user specified a
>     user_data, that the user_data should become the first argument
>     (why ? just because its confusing when the underlying framework
>     makes that kind of assumption for you, and because it denies you
>     the possibility of using user_data without being swapped).

Let's do something a little cleaner and more flexible;

typedef void (*GtkBuilderConnectFunc) (GtkBuilder   *builder,
				       const gchar  *handler_name,
				       GObject      *object,
				       const gchar  *signal_name,
				       const GValue *signal_user_data,
				       GConnectFlags flags,
				       gpointer      user_data);

and;

 <signal name=".*" handler=".*" after="bool" swapped="bool"
         user_type="type" user_data=""/>

user_type would take a GType name, if it's derived from G_TYPE_OBJECT
user_data will be treated an object reference, similar to other
object properties.

Would that be enough?

Johan



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