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 593671 - Needed func for GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS)
Needed func for GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS)
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.20.x
Other All
: Normal blocker
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 69872 593601 597365 597610 597906 612484 615294 615613
 
 
Reported: 2009-08-31 12:58 UTC by Ignacio Casal Quinteiro (nacho)
Modified: 2011-02-04 16:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
widget: Add send_focus_change() (4.75 KB, patch)
2010-04-12 14:03 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review
window: Use gtk_widget_send_focus_change() (1.24 KB, patch)
2010-04-12 14:04 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review
tree-view: Use gtk_widget_send_focus_change() (1.27 KB, patch)
2010-04-12 14:04 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review

Description Ignacio Casal Quinteiro (nacho) 2009-08-31 12:58:10 UTC
Currently in gedit and gtktreeview is used GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); to implement the interactive search. I'd like to have a func or some kind of api to get rid of this to be able to build gedit with the gseal thingie.
Comment 1 Christian Dywan 2009-08-31 13:05:14 UTC

*** This bug has been marked as a duplicate of bug 69872 ***
Comment 2 Javier Jardón (IRC: jjardon) 2009-10-12 15:08:56 UTC
From https://bugzilla.gnome.org/show_bug.cgi?id=69872#c27

> the GtkTreeView needs that for the search entry focusing, but that's evil and > we should find a way to have public API for doing this correctly - also 
> for applications using the same search entry semantics on TextView widgets
> (e.g. > gedit).

Reopening
Comment 3 Javier Jardón (IRC: jjardon) 2010-04-11 19:42:48 UTC
Seems that all the affected external application just copied this gtktreeview hack into their code:

[1] http://git.gnome.org/browse/gtk+/tree/gtk/gtktreeview.c#n10264
Comment 4 Emmanuele Bassi (:ebassi) 2010-04-12 13:19:12 UTC
something like:

  gtk_widget_send_focus_change (GtkWidget *widget, gboolean is_focus_in);

or:

  gtk_widget_send_focus_change (GtkWidget *widget, GdkEvent *event);

similar to gtk_widget_send_expose(). the implementation would be trivial.
Comment 5 Emmanuele Bassi (:ebassi) 2010-04-12 14:03:00 UTC
Created attachment 158484 [details] [review]
widget: Add send_focus_change()

Currently the only users of the GTK_HAS_FOCUS flag are setting it
before sending a focus change event. This is normally needed by
GtkWindow, but there are widgets that require controlling the focus
of widgets that are semantically their children even though they are
parented to another top-level. Case in point: the quick search entry
for GtkTreeView.

Over the years people have been hacking the focus change out of
gtkwindow.c and gtktreeview.c, thus leaking the direct access of the
GTK_HAS_FOCUS flag.

The simplest way to avoid that is to add a function that sends the
focus change event and controls the setting of the flag, thus removing
the need for external widgets to do the same.
Comment 6 Emmanuele Bassi (:ebassi) 2010-04-12 14:04:05 UTC
Created attachment 158485 [details] [review]
window: Use gtk_widget_send_focus_change()

Remove the original user of the GTK_HAS_FOCUS flags.
Comment 7 Emmanuele Bassi (:ebassi) 2010-04-12 14:04:19 UTC
Created attachment 158486 [details] [review]
tree-view: Use gtk_widget_send_focus_change()

Remove the second (and last) internal user of the GTK_HAS_FOCUS flag.
Comment 8 Emmanuele Bassi (:ebassi) 2010-04-12 14:10:55 UTC
the patches above fix the issue of HAS_FOCUS in the most trivial way possible: acknowledging the existing code base.

another potential, and more time consuming, solution would be to create a GtkSearchEntry widget and expose it as a way to implement the TreeView-style floating search entry on any widget. while this might be a worthy goal for 3.x I don't think it would be a good way to spend time in the last days of the 2.x development cycle - and it's not fully orthogonal to the send_focus_change() function: at the end of the day, we need a way to affect the focus on widgets that are semantically our children, even if they are not really parented to us.
Comment 9 Matthias Clasen 2010-04-12 23:41:24 UTC
Looks like a very pragmatic way of dealing with this issue.

+1 from me.

This is probably something that we need to backport to 2.22 under the 'missing accessor' exception ?
Comment 10 Christian Dywan 2010-04-13 14:24:39 UTC
Looks pretty elegant to me, even if it's the same behind the scenes.

(In reply to comment #9)
> This is probably something that we need to backport to 2.22 under the 'missing
> accessor' exception ?

Yes.
Comment 11 Emmanuele Bassi (:ebassi) 2010-04-26 18:15:38 UTC
Attachment 158484 [details] pushed as f04a720 - widget: Add send_focus_change()
Attachment 158485 [details] pushed as 91930f8 - window: Use gtk_widget_send_focus_change()
Attachment 158486 [details] pushed as 621b415 - tree-view: Use gtk_widget_send_focus_change()