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 711826 - [REGRESSION] gtk_text_view_add_child_in_window not scrolling
[REGRESSION] gtk_text_view_add_child_in_window not scrolling
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
3.10.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 720870 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-11-11 09:29 UTC by Ignacio Casal Quinteiro (nacho)
Modified: 2014-01-10 11:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
testtextview: Add test for gtk_text_view_add_child_in_window (1.91 KB, patch)
2014-01-08 13:04 UTC, Alexander Larsson
none Details | Review
testtextview: Add test for gtk_text_view_add_child_in_window (3.20 KB, patch)
2014-01-08 14:30 UTC, Alexander Larsson
committed Details | Review
GtkTextView: Fix scrolling of added children (3.77 KB, patch)
2014-01-08 14:30 UTC, Alexander Larsson
committed Details | Review

Description Ignacio Casal Quinteiro (nacho) 2013-11-11 09:29:09 UTC
You can try this by enabling the pickcolor plugin of gedit.
Write: #aaaaaa, select the text to get the color button and then scroll.
Comment 1 Ignacio Casal Quinteiro (nacho) 2013-12-21 14:49:00 UTC
*** Bug 720870 has been marked as a duplicate of this bug. ***
Comment 2 Alexander Larsson 2014-01-08 13:04:31 UTC
Created attachment 265698 [details] [review]
testtextview: Add test for gtk_text_view_add_child_in_window
Comment 3 Alexander Larsson 2014-01-08 13:08:32 UTC
As can be seen with this test its not like we were in a great shape before either. If you run this in master the child will *always* be in the specified position relative to the window no matter what you do. However, on Gtk 3.8 if you scroll with the widget visible it will follow the scroll, *but* if you force a repaint by e.g. selecting or resizing the window it will jump back to the original position wrt the window.
Comment 4 Alexander Larsson 2014-01-08 13:19:43 UTC
Indeed, i verified this with Gtk2, it has the same broken behaviour when using GTK_TEXT_WINDOW_TEXT. The only use of this seem to be gedit, so lets make it do what gedit wants.
Comment 5 Alexander Larsson 2014-01-08 14:30:34 UTC
Created attachment 265707 [details] [review]
testtextview: Add test for gtk_text_view_add_child_in_window
Comment 6 Alexander Larsson 2014-01-08 14:30:44 UTC
Created attachment 265708 [details] [review]
GtkTextView: Fix scrolling of added children

The behaviour of gtk_text_view_add_child_in_window() used to be
quite broken. It scrolled with the window during scrolling, then
jumped to the absolute position when the widget resized. Furthermore,
in 3.10 we broke the first feature, making it always be fixed.

The "proper" way to handle this is to always follow scrolling. This
is what the only user so far (gedit) wants, and if you want some
kind of overlay you should use GtkOverlay instead.

So, this changes the behaviour to something that is internally consistent
and works. I.e. all added widgets scroll with the textview as needed.
Comment 7 Ignacio Casal Quinteiro (nacho) 2014-01-08 19:21:29 UTC
as pointed out on irc:

<nacho> alex_away, seems to be placed at the wrong place...
<nacho> alex_away, which is ok, if I need to do the window coordinates thing is ok for me too
<nacho> alex_away, also it seems to fix the other issue about drag and drop

I wonder if this is actually the right behavior... I'll need to double check though
Comment 8 Ignacio Casal Quinteiro (nacho) 2014-01-08 19:23:18 UTC
so this is what I currently have in colorpicker:

                    start, end = bounds
                    location = self.view.get_iter_location(start)
                    win_x, win_y = self.view.buffer_to_window_coords(Gtk.TextWindowType.TEXT, location.x, location.y)
                    min_width, nat_width = self._color_button.get_preferred_width()
                    min_height, nat_height = self._color_button.get_preferred_height()
                    x = win_x
                    if win_y - nat_height > 0:
                        y = win_y - nat_height
                    else:
                        y = win_y + location.height

                    self.view.add_child_in_window(self._color_button, Gtk.TextWindowType.TEXT, x, y)
Comment 9 Ignacio Casal Quinteiro (nacho) 2014-01-08 19:31:16 UTC
diff --git a/plugins/colorpicker/colorpicker.py b/plugins/colorpicker/colorpicker.py
index 21c27c4..7e7163f 100644
--- a/plugins/colorpicker/colorpicker.py
+++ b/plugins/colorpicker/colorpicker.py
So this fixes colorpicker and I think it makes sense.

@@ -252,14 +252,13 @@ class ColorPickerViewActivatable(GObject.Object, Gedit.ViewActivatable):
 
                     start, end = bounds
                     location = self.view.get_iter_location(start)
-                    win_x, win_y = self.view.buffer_to_window_coords(Gtk.TextWindowType.TEXT, location.x, location.y)
                     min_width, nat_width = self._color_button.get_preferred_width()
                     min_height, nat_height = self._color_button.get_preferred_height()
-                    x = win_x
-                    if win_y - nat_height > 0:
-                        y = win_y - nat_height
+                    x = location.x
+                    if location.y - nat_height > 0:
+                        y = location.y - nat_height
                     else:
-                        y = win_y + location.height
+                        y = location.y + location.height
 
                     self.view.add_child_in_window(self._color_button, Gtk.TextWindowType.TEXT, x, y)
         elif not rgba_str and self._color_button is not None:
Comment 10 Paolo Borelli 2014-01-08 20:59:39 UTC
Review of attachment 265708 [details] [review]:

maybe it is less confusing if we deprecate the old function and just mark it as broken and add a new one with the proper behavior? add_child_at_position or something like that...
Comment 11 Matthias Clasen 2014-01-09 03:24:24 UTC
Review of attachment 265707 [details] [review]:

sure. might be nice to test the other text window types while we are at it
Comment 12 Matthias Clasen 2014-01-09 03:25:13 UTC
Review of attachment 265708 [details] [review]:

I think it is fine to fix up this function to do the right thing.
Comment 13 Matthias Clasen 2014-01-09 03:25:40 UTC
Review of attachment 265708 [details] [review]:

Might be good to add a note in README.in about the change in behaviour, though
Comment 14 Matthias Clasen 2014-01-09 03:25:49 UTC
Review of attachment 265708 [details] [review]:

Might be good to add a note in README.in about the change in behaviour, though
Comment 15 Alexander Larsson 2014-01-09 16:44:34 UTC
We used to have a testtext.c app that tested all sorts of textview stuff, but it was disabled and then removed. Does anyone know why?
Comment 16 Matthias Clasen 2014-01-09 18:23:02 UTC
I think it just wasn't ported to some of the pre-3.0 removals, and maybe there was complications with doing that. If you want to try, you can bring it back
Comment 17 Alexander Larsson 2014-01-10 11:06:55 UTC
Attachment 265707 [details] pushed as 59bf558 - testtextview: Add test for gtk_text_view_add_child_in_window
Attachment 265708 [details] pushed as 664fe89 - GtkTextView: Fix scrolling of added children