After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 542337 - Allow anjuta to handle clicks on widgets in designer
Allow anjuta to handle clicks on widgets in designer
Status: RESOLVED FIXED
Product: glade
Classification: Applications
Component: anjuta integration
git master
Other Linux
: Normal normal
: ---
Assigned To: Glade 3 Maintainers
Glade 3 Maintainers
Depends on:
Blocks: 542412
 
 
Reported: 2008-07-10 09:33 UTC by Pavel Kostyuchenko
Modified: 2009-01-20 22:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
The patch makes it possible to intercept the widget signals (6.89 KB, patch)
2008-07-10 09:37 UTC, Pavel Kostyuchenko
none Details | Review
Patch (5.24 KB, patch)
2008-08-20 22:32 UTC, Pavel Kostyuchenko
none Details | Review
Widget events v3 (5.81 KB, patch)
2009-01-19 22:57 UTC, Pavel Kostyuchenko
none Details | Review

Description Pavel Kostyuchenko 2008-07-10 09:33:45 UTC
I'm proposing to send all signals to glade project and anjuta will be connected to it. Using an integer instead of a boolean allows to control calling of default handler.
Comment 1 Pavel Kostyuchenko 2008-07-10 09:37:57 UTC
Created attachment 114297 [details] [review]
The patch makes it possible to intercept the widget signals
Comment 2 Tristan Van Berkom 2008-08-06 23:29:25 UTC
Ok this is complex so lets shed some light:

  - Events are caught from the actual widgets by GladeWidget implementation
  - For filtering/marshalling reasons, all events are sent to the parenting
    GladeDesignLayout
  - The layout in turn decides which GladeWidget to send the event for 
    processing.

We need per widget processing for GladeFixed implementations (Drag/Resize
in various container types), gladefixed uses the gladewidget::button-events.

Now, furthermore, there is a serious of priorities to respect with
button events - first button click on a widget is used to select the
widget - you are not allowed to catch that and return TRUE. The second
event is used either, in the case of GladeFixed and modifiers active,
may be used for a drag/resize - asides from that the widget is left to 
process the event in the glade environment and look cute that way.

So, We can add an event notification on the project sure - but first,
what are you using them for ? shall it be a second stage emission that
we can send out directly from the GladeDisignLayout event hub ?
Comment 3 Pavel Kostyuchenko 2008-08-20 22:32:19 UTC
Created attachment 117090 [details] [review]
Patch

A new signal in design layout for listening and intercepting widget events.
I really cannot figure out how I managed to miss that in spite of a lot of time spent working on events and especially clicks. Probably, it's because the lines
"if (!layout)
	return glade_widget_event (gwidget, event);" (which send the event directly to the widget if there's no design layout). Thanks for the explanation.
Comment 4 Tristan Van Berkom 2008-08-22 18:44:20 UTC
Ok thaks, few nitpicks and comments:

  - you have a stale diff included from glade-project.h
  - please include C context in your patches (i.e. the -p option to diff)
    (otherwise I have to open sources to find what functions your
    diffs apply to... reading those line number... gah)
  - AFAICS your signal return value is used to either stop the
    emission or not, is there any reason not to use a normal boolean
    handled accumulator ?

Now this one is the important one, I want it done a little backwards from
the way you did it, you registered the signal as RUN_LAST, and handle glade
widgets in the layout's class handler, *after* third party callbacks are 
honored.

What we need here is to:
   a.) Run the glade widget handlers and mind the return value
   b.) if the return value of the glade handlers is still "unhandled", 
       then fire a signal for third party handlers (at this point
       it probably doesnt matter to us about the return value of the
       signal, although a boolean accumulator could help just for
       convenience for third party signal callbacks).

Note we wont be able to accomplish this by changing the signal to
RUN_FIRST, because from the RUN_FIRST class handler we have no way
I can see to abort the signal emission (I may be wrong here, but Im
quite sure that requesting an abort from the class handler doesnt
cancel out the next stage of signal emission).
Comment 5 Tristan Van Berkom 2008-08-22 18:53:00 UTC
(In reply to comment #4)
[...]
> What we need here is to:
>    a.) Run the glade widget handlers and mind the return value
>    b.) if the return value of the glade handlers is still "unhandled", 
>        then fire a signal for third party handlers (at this point
>        it probably doesnt matter to us about the return value of the
>        signal, although a boolean accumulator could help just for
>        convenience for third party signal callbacks).
> 

Ok I noticed I have something else to clarify... basically, here
is the "deal" we are willing to make.

  a.) If you want to get absolutely all events from glade, then you
      are not allowed to abort the native glade signal callbacks.
  b.) If you want to some kind of interactive actions with mouse clicks,
      specifically any actions that modify the GladeProject, you'll
      want/have to abort glade callbacks, in which case you must wait in
      line and see if that signal ever comes.

Now, if what you want is "a", then were in bussiness, if you want "b",
then it gets a little more complex, because in the case of "b", you'll
want to fire the third party callback: AFTER the glade bussiness logic
handlers have been called and BEFORE by default throwing the event at the
actual widget so that the button "clicks" in the UI.

I.E., you are allowed to abort callbacks before they are handled by the
actual widget in the UI, but not before they are handled by glade.
Comment 6 Pavel Kostyuchenko 2008-08-23 16:16:35 UTC
Using my patch I can catch an event before and after glade handler, so I get full control of widget events.
Using my accumulator function the signal emission may be aborted by class handler or any other handler and the last return value will be used. The first bit of handler return value means "abort" and the second bit contains a boolean value. In this way I will abort events selectively, so I cannot see any problems.
Comment 7 Tristan Van Berkom 2008-08-24 05:11:34 UTC
Yes but there are two problems I previously outlined:

  a.) The order in which callbacks are called when they trigger
      commands that effect the project is important, its important
      for instance, that glade sets selection on the first click,
      then project actions, and in the last case the widget natural
      actions.

  b.) Your patch allows third parties to handle the event before
      glade *and* abort the emission - I already stated this is not
      part of the deal.

Comment 8 Pavel Kostyuchenko 2009-01-13 23:33:03 UTC
First of all, I wanted to handle double clicks in anjuta plugin. The problem is how to block the second click of double click, because double click signal is received after all single clicks.
Secondly, I planed to make something like a travesty of preview mode, in which all clicks would be send directly to widgets. Probably, that's rubbish, though I cannot see any problems in making the possibility of changing the glade behavior.
So, will the changing of behavior cause any serious problems?
Also, GtkFixed seems to be little buggy and AFAIK there was no changes to that problems. I'll create a separate bug for one of the bugs. The second bug is that GtkMixed handles clicks on a wrong stage of their processing. I think I will have more details tomorrow.
Comment 9 Tristan Van Berkom 2009-01-16 02:37:38 UTC
Please let me know about the problems you find with GtkFixed/GtkLayout
manipulations...

Thanks for giving me more insight on what you want to do, I had not
considered what happens with double clicks either, the code in this
patch is clean, thats not a problem, although I wonder if theres
a way to simplify the handler to have a simple boolean return
value.

I'm going to look through it more in depth this week, we have a very
long track record of bugs regarding event handling, and its been working
well for quite some time, after several refactorings.
Comment 10 Tristan Van Berkom 2009-01-16 15:13:43 UTC
I looked at it again, I wonder what is the behavior of the callback when
connecting with g_signal_connect_after() ? I think the "after" signals 
run in a different emission stage which could be a problem. 

I would prefer if connect_after() meant that you will be called
only if glade_widget_event() returned FALSE for that event
(i.e. allowing the user to serialize his callback after glade
initial selection click/drag resize mode - but still before
native widget event handlers) - if connect_after doesnt behave
this way, then we wont be able to add callbacks to events in what
I believe to be the most sensible place: after selections and
before native event handlers.

Also, if we have the ability to connect before or after
the GladeWidget handlers, is there a reason for the integer
return value ? the value returned still symbolizes whether
the event is propagated further.

Is there any reason you would want to abort the glade handler
manually and still let the native widget handler run ?
(i.e. return abort|false)

I would prefer to see the widget come before the event, ideally:
gboolean widget_event (GladeDesignLayout *, GladeWidget *, GdkEvent *);

The added GladeDesignLayout::widget-event should come with
a gtk-doc statement, and an explanation about the effects of
connecting before and after the signal.

NOTE: if we cant serialize all the callbacks into one signal,
we can consider adding 2 (boolean handled) signals to be run
at different stages.
Comment 11 Pavel Kostyuchenko 2009-01-17 04:36:48 UTC
By connecting after default handler it behaves just as you wish - the first is glade logic, the second is custom handler and the third is widget handler, propagation can be aborted at any stage using boolean handled accumulator. But what I need is:
- to block all clicks from getting to widgets, because I want to use double click, but GDK_BUTTON_PRESS event is emitted before GDK_2BUTTON_PRESS, so I have no idea how to block it without the total blocking;
- in a special mode, all click are delivered directly to widgets, so you can perform any necessary actions on them. This is the only place where abort|false is needed.
I suppose the special mode to be turned on by holding some key or something else.

Why should a widget come before an event in the parameter list?

I'm not sure that splitting of event handling into 2 signals would be a good idea. I hope some documentation will help to make things cleaner for everybody.

PS: I cannot reproduce that bugs anymore, so they seem to be fixed.
Comment 12 Tristan Van Berkom 2009-01-17 05:15:57 UTC
(In reply to comment #11)
> By connecting after default handler it behaves just as you wish - the first is
> glade logic, the second is custom handler and the third is widget handler,
> propagation can be aborted at any stage using boolean handled accumulator. But
> what I need is:
> - to block all clicks from getting to widgets, because I want to use double
> click, but GDK_BUTTON_PRESS event is emitted before GDK_2BUTTON_PRESS, so I
> have no idea how to block it without the total blocking;
> - in a special mode, all click are delivered directly to widgets, so you can
> perform any necessary actions on them. This is the only place where abort|false
> is needed.
> I suppose the special mode to be turned on by holding some key or something
> else.

Fair, so long as they are both possible, particularly that
a connect_after() callback is not fired when a widget is initially
clicked for selection - then we have all the possibilities.

> 
> Why should a widget come before an event in the parameter list?

Just because is does in glade_widget_event(), and it also does
in gtk_widget_event()... and also in all the event signals of a widget,
basically for no technical reason, except to not have to consult
the docs/headers when typing code ;-)

> 
> I'm not sure that splitting of event handling into 2 signals would be a good
> idea. I hope some documentation will help to make things cleaner for everybody.

No no, so long as both emission stages can be treated with the
same signal, theres no need for another one.

Comment 13 Pavel Kostyuchenko 2009-01-19 22:57:53 UTC
Created attachment 126803 [details] [review]
Widget events v3

I added some docs for the signal and changed order of its parameters.
Comment 14 Juan Pablo Ugarte 2009-01-20 22:25:21 UTC
Patch commited in trunk