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 635499 - gtk_entry_completion_set_text_column doesn't remove old column renderers
gtk_entry_completion_set_text_column doesn't remove old column renderers
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkEntry
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2010-11-22 09:20 UTC by Jasper St. Pierre (not reading bugmail)
Modified: 2018-04-15 00:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Simple Python test case. (592 bytes, text/x-python)
2010-11-22 09:21 UTC, Jasper St. Pierre (not reading bugmail)
  Details
Make text column setting in GtkEntryCompletion consistent (3.13 KB, patch)
2010-12-03 16:49 UTC, Christian Dywan
none Details | Review
gtk_entry_completion_set_text_column: reuse old renderer (6.25 KB, patch)
2013-11-02 09:13 UTC, Lars Karlitski
accepted-commit_now Details | Review
gtk_entry_completion_set_text_column: reuse old renderer (6.67 KB, patch)
2013-11-02 13:28 UTC, Lars Karlitski
none Details | Review
gtk_entry_completion_set_text_column: reuse old renderer (7.58 KB, patch)
2013-11-02 16:17 UTC, Lars Karlitski
committed Details | Review
gtk_entry_completion_set_text_column: don't remove renderers (8.08 KB, patch)
2013-12-07 15:36 UTC, Lars Karlitski
none Details | Review

Description Jasper St. Pierre (not reading bugmail) 2010-11-22 09:20:18 UTC
Simple testcase attached.

Type "f" in the box, click the button, watch them multiply.

Even weirder, setting the "text-column" property doesn't
call the method, so it doesn't cause the duplication.
Comment 1 Jasper St. Pierre (not reading bugmail) 2010-11-22 09:21:21 UTC
Created attachment 175010 [details]
Simple Python test case.
Comment 2 Benjamin Otte (Company) 2010-11-22 09:29:55 UTC
Yeah, we should (at least for gtk3) make sure g_object_set ("text-column") and entry_completion_set_text_column() don't do different stuff. Guess we shouldn't do that for GTK2, because the docs explicitly mention it's broken.
Comment 3 Christian Dywan 2010-12-03 16:49:42 UTC
Created attachment 175795 [details] [review]
Make text column setting in GtkEntryCompletion consistent

Using the function should behave the same as using the property.

No additional renderers should be added if any exist already. I changed the comment to refer to GtkCellLayout for complex use cases.
Comment 4 Benjamin Otte (Company) 2010-12-03 19:15:13 UTC
I don't like this behavior, because the following code will not do what you'd expect:
gtk_entry_completion_set_text_column (completion, 0);
gtk_entry_completion_set_text_column (completion, 1);
It will still use column 0.

I'd prefer it if the code would remove _all_ cell renderers and add one new renderer displaying the text.

(Fwiw, I'd also prefer if text-column was set to -1 whenever a renderer was added or removed. So text-column != -1 means there's exactly one renderer and it displays the given column. But I guess that'd be a different bug.)
Comment 5 Christian Dywan 2010-12-04 02:53:12 UTC
(In reply to comment #4)
> I'd prefer it if the code would remove _all_ cell renderers and add one new
> renderer displaying the text.

I think it is somewhat unexpected for it to destroy your renderers, if all you want is set the column used for completion.

Though if in doubt I would second your approach, it does sound reasonable.
Comment 6 Lars Karlitski 2013-11-02 09:13:51 UTC
Created attachment 258794 [details] [review]
gtk_entry_completion_set_text_column: reuse old renderer

gtk_entry_completion_set_text_column() always added a cell renderer,
regardless of whether there was an existing one already installed.  This
patch reuses an old renderer if it exists, but only if it was added by a
previous call to this function.

To avoid conflicts, all renderers that were added manually are removed
when calling this function. Also, the renderer added by this function is
removed when manually adding new renderers. This effectively gives
GtkEntryCompletion two modes (managed and manual cell renderers) and
allows seamless switching between the two.

This is a minor API break. However, this shouldn't be an issue in
practice as applications couldn't call set_text_column() more than once
because of this bug. Also, it is unlikely that many applications mix
set_text_column() and custom cell renderers. The interaction between the
two modes was erratic and not documented well.
Comment 7 Benjamin Otte (Company) 2013-11-02 10:10:54 UTC
Review of attachment 258794 [details] [review]:

Patch looks good.

Only thing I'm wondering: Should we also gtk_entry_completion_clear_text_column_renderer() in the other GtkCellLayout functions (like clear() or set_cell_data_func()) or is that overkill?
Comment 8 Lars Karlitski 2013-11-02 13:28:10 UTC
Created attachment 258798 [details] [review]
gtk_entry_completion_set_text_column: reuse old renderer

Thanks for the review. I've amended the patch to also clear the automatically
set up renderer when calling gtk_cell_layout_clear().

I didn't do the same for set_cell_data_func(). The renderer that is passed into
this function would be deleted right after the call. I think we should just
consider poking into the layout to get the renderer that was automatically set
up to result in undefined.
Comment 9 Lars Karlitski 2013-11-02 16:17:31 UTC
Created attachment 258808 [details] [review]
gtk_entry_completion_set_text_column: reuse old renderer

Don't expose the internal GtkCellRendererText from gtk_cell_layout_get_cells().
Thank you Benjamin for the tip.
Comment 10 Benjamin Otte (Company) 2013-11-02 18:39:40 UTC
Comment on attachment 258808 [details] [review]
gtk_entry_completion_set_text_column: reuse old renderer

Weeee
Comment 11 Volker Sobek (weld) 2013-12-06 23:59:16 UTC
I think these commits (3c2829713463228094d66170564a4d6d7c31c245 / f6a0debdd9d4f90b9d6b54c263b10926ba530c7e) somehow broke the auto completion in another way. With current gtk+ master, as soon as the file chooser should insert the unique match into the entry, the popup with matches disappears, but the the match is not inserted into the entry.

9761a966d8ffda724226a21022a42ce40932b443 was the last commit with a working auto completion in the GtkFileChooser.

Can anyone confirm?
Comment 12 Volker Sobek (weld) 2013-12-07 00:20:38 UTC
> 9761a966d8ffda724226a21022a42ce40932b443 was the last commit with a working
> auto completion in the GtkFileChooser.

The last commit with regard to the file gtk/gtkentrycompletion.c I should say.

With git master, when I run
$ git checkout 9761a966d8ffda724226a21022a42ce40932b443 gtk/gtkentrycompletion.c

and compile again, I have the working completion back.
Comment 13 Benjamin Otte (Company) 2013-12-07 00:28:43 UTC
Yup, can confirm. The inline completion uses the text column so the changes in here that clear the text column break inline completion.
Comment 14 Lars Karlitski 2013-12-07 15:36:45 UTC
Created attachment 263712 [details] [review]
gtk_entry_completion_set_text_column: don't remove renderers

Second try at fixing this :)

Instead of removing all renderers when setting text-column, introduce a flag
that signifies whether an internal renderer is being used.
Comment 15 Benjamin Otte (Company) 2013-12-09 01:13:22 UTC
I'm not convinced this whole trickery is worth it. You've added how many lines of code now to gain essentially nothing?

Could we just revert this and WONTFIX it?
Comment 16 Jasper St. Pierre (not reading bugmail) 2013-12-09 01:15:32 UTC
We have such great APIs.
Comment 17 Benjamin Otte (Company) 2013-12-09 01:17:21 UTC
I would actually welcome deprecating this API and adding a new one, which is what I argued a bit with Lars on IRC. But somebody would need to write the patches. *hint*
Comment 18 Matthias Clasen 2013-12-09 20:31:33 UTC
> Could we just revert this and WONTFIX it?

Might be better, indeed
Comment 19 Lars Karlitski 2013-12-10 11:49:28 UTC
> You've added how many lines of code now to gain essentially nothing?

Including the latest patch that is not yet committed, there have been 186 insertions and 70 deletions related to this issue. 116 lines added to fix two bugs, one of which is visible enough to already have a duplicate.

> Could we just revert this and WONTFIX it?

WONTFIX obviously wrong behavior? You can't use entry completions from glade and calling a setter twice has weird side effects. I'd consider both of those severe.

I agree that a less complex API is valuable, but we could help quite a few people out right now if we just fixed what we have.
Comment 20 Benjamin Otte (Company) 2013-12-10 11:59:42 UTC
Yes, the API is obviously really bad and should go away asap, but I'm not convinced that forcing two different APIs to do the same thing - and the setter and the property are different because they do vastly different things - is the way to go.

I'd rather have new and different APIs for those things.
Comment 21 Shaun McCance 2014-02-22 18:15:50 UTC
Yelp's completion for the search field is completely broken right now with GTK+ master. I don't have an opinion on the right solution, but I really don't think we should break existing applications.
Comment 22 Matthias Clasen 2014-03-03 11:04:38 UTC
I've now reverted all the commits that were made for this bug.
We can try again next cycle to sort this out.
We cannot ship 3.12 with broken completion all over the place.
Comment 23 Matthias Clasen 2018-02-10 05:15:18 UTC
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
Comment 24 Matthias Clasen 2018-04-15 00:05:39 UTC
As announced a while ago, we are migrating to gitlab, and bugs that haven't seen activity in the last year or so will be not be migrated, but closed out in bugzilla.

If this bug is still relevant to you, you can open a new issue describing the symptoms and how to reproduce it with gtk 3.22.x or master in gitlab:

https://gitlab.gnome.org/GNOME/gtk/issues/new