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 333320 - Completion in location entry is not selected when clipboard utility is in use
Completion in location entry is not selected when clipboard utility is in use
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkFileChooser
2.8.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
Federico Mena Quintero
: 309734 333319 607485 633604 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-03-04 00:45 UTC by Yevgen Muntyan
Modified: 2018-04-14 23:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test helper (1.21 KB, text/plain)
2006-03-17 04:29 UTC, Yevgen Muntyan
Details

Description Yevgen Muntyan 2006-03-04 00:45:54 UTC
When typing in the location entry, the completed part is not selected. So if I type "/usr", I get "/usr/src/" - "/u" completes to "/usr/" and "rc" then apparently completes to "src/". Note that this behavior seems to depend on speed of typing: if you type slowly, everything is fine. It's not clear what "slow" is, seems it depends on what speed my processor is running at.
Comment 1 Matthias Clasen 2006-03-04 17:31:55 UTC
Hmm, this could conceivably happen if you manage to type
/u and then the s after the entry has completed to /usr/, but
before it has selected the sr/ part. The s would then complete
to /usr/src. 

I am not able to reproduce this here, either my machine is too fast
or I am too slow...
Comment 2 Yevgen Muntyan 2006-03-04 20:08:57 UTC
Looks like #309734 describes a similar problem, namely:
"..For example,  
if I want to go to "/usr/bin/" and I just start typing away, I'd end up with  
"/u/sr/bin" or maybe "/usr/bin/in" as the gtkfilesel will autocomplete faster  
then I can type.."
Though it says you need to type slowly enough, not fast. In any case this problem does exist here, and I need to be very careful typing a filename in.
Comment 3 Matthias Clasen 2006-03-05 05:30:18 UTC
but the autocompletion should not be a problem, since the completion code
matches against the autoinserted part. The following is happening for me
([] indicating autoinserted and selected part)

input      result
/          /
u          /u[sr/]
s          /us[r/]
r          /usr[/]
/          /usr/
s          /usr/s[rc/]
r          /usr/sr[c/]
c          /usr/src[/]

etc
Comment 4 Yevgen Muntyan 2006-03-05 05:36:24 UTC
Hm, seems it works fine after ctrl-L is used. So, here are exact steps to reproduce.

1) press Ctrl-O to get Open dialog (say, in gedit)
2) type '/usr' in.

Result: '/usr/src/' in the entry.

If you use ctrl-L, it works fine; if you cancel the entry, and just type after that (but not closing dialog), then it sometimes works right, sometimes doesn't.
Comment 5 Federico Mena Quintero 2006-03-06 16:17:15 UTC
*** Bug 309734 has been marked as a duplicate of this bug. ***
Comment 6 Federico Mena Quintero 2006-03-06 16:22:39 UTC
What locale are you using?  What's the exact version of GTK+?  I cannot reproduce this with C-l or /

What kind of machine (processor, speed)?
Comment 7 Yevgen Muntyan 2006-03-07 01:29:28 UTC
muntyan@mlap:~ $ echo $LANG; echo $LANGUAGE;
en_US
en_US:en_GB:en

No LC* variables set. Debian testing, with gtk-2.8.12. Pentium 4, 2.6GHz.

I'll try gtk-2-8 branch as soon as I have time for building it.
Comment 8 Yevgen Muntyan 2006-03-09 16:41:30 UTC
I tried gtk-2-8 branch, same result. Works fine with ctrl-L, breaks when just typing path in.
Comment 9 Yevgen Muntyan 2006-03-09 17:54:22 UTC
It has something to do with idiotic clipboard business. I disabled "clear-selection-on-clear-primary-selection", and it works fine. (in gtk-2-8 branch)
Comment 10 Yevgen Muntyan 2006-03-09 17:57:47 UTC
Sorry, forgot about details. So, I commented out the gtk_editable_select_region(nothing) in primary_clear_cb, in gtkentry.c.
Comment 11 Yevgen Muntyan 2006-03-09 18:09:25 UTC
Here's backtrace of first primary_clear_cb call - I press '/', location dialog appears on the screen, and it stops.

Breakpoint 2, primary_clear_cb (clipboard=0x8684bf0, data=0xb7d6b7f0) at gtkentry.c:3808
3808    {
(gdb) bt
  • #0 primary_clear_cb
    at gtkentry.c line 3808
  • #1 clipboard_unset
    at gtkclipboard.c line 674
  • #2 selection_clear_event_cb
    at gtkclipboard.c line 337
  • #3 _gtk_marshal_BOOLEAN__BOXED
    at gtkmarshalers.c line 83
  • #4 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #5 g_signal_stop_emission
    from /usr/lib/libgobject-2.0.so.0
  • #6 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #7 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #8 gtk_widget_event_internal
    at gtkwidget.c line 3732
  • #9 IA__gtk_selection_owner_set_for_display
    at gtkselection.c line 609
  • #10 IA__gtk_clipboard_clear
    at gtkclipboard.c line 700
  • #11 gtk_entry_update_primary_selection
    at gtkentry.c line 3852
  • #12 IA__gtk_editable_select_region
    at gtkeditable.c line 187
  • #13 location_popup_handler
    at gtkfilechooserdefault.c line 7386
  • #14 trap_activate_cb
    at gtkfilechooserdefault.c line 3416
  • #15 _gtk_marshal_BOOLEAN__BOXED
    at gtkmarshalers.c line 83
  • #16 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #17 g_signal_stop_emission
    from /usr/lib/libgobject-2.0.so.0
  • #18 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #19 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #20 gtk_widget_event_internal
    at gtkwidget.c line 3732
  • #21 IA__gtk_window_propagate_key_event
    at gtkwindow.c line 4517
  • #22 gtk_window_key_press_event
    at gtkwindow.c line 4547

Comment 12 Yevgen Muntyan 2006-03-09 18:31:02 UTC
Here's backtrace of second call. If i type "/u" in the FileChooser dialog, then primary_clear_cb is called twice (i put g_print there), so this is it.

Breakpoint 2, primary_clear_cb (clipboard=0x8684bf0, data=0x8755418) at gtkentry.c:3812
3812      g_print ("hi there\n");
(gdb) bt
  • #0 primary_clear_cb
    at gtkentry.c line 3812
  • #1 gtk_entry_update_primary_selection
    at gtkentry.c line 3848
  • #2 IA__gtk_editable_select_region
    at gtkeditable.c line 187
  • #3 append_common_prefix
    at gtkfilechooserentry.c line 490
  • #4 check_completion_callback
    at gtkfilechooserentry.c line 519

Comment 13 Yevgen Muntyan 2006-03-09 18:53:09 UTC
After adding some debug output, it looks like the following happens:

I type "/u" in, entry inserts "sr/", then it calls gtk_editable_select_region (the inserted text, selection bounds are all correct), but the text doesn't get selected for some reasons. It's not someone stealing the selection, because primary_clear_cb is called *before* gtk_editable_select_region, and not called after that.

What can be a reason for gtk_editable_select_region having no effect (no effect at all, not just selecting and unselecting due to someone else getting selection)?
Comment 14 Yevgen Muntyan 2006-03-09 19:10:13 UTC
I tracked it down to gtk_clipboard_set_with_owner() failing in gtk_entry_update_primary_selection() (called from gtk_entry_set_selection_bounds). It fails, then entry calls primary_clear_cb and text unselects.
Comment 15 Yevgen Muntyan 2006-03-17 04:29:07 UTC
Created attachment 61410 [details]
test helper

This helps to reproduce what I see here.
Comment 16 Federico Mena Quintero 2006-07-07 16:17:39 UTC
See also bug #330565.
Comment 17 Federico Mena Quintero 2007-01-25 19:27:03 UTC
See also bug #333319; I'm not sure if it is a duplicate.
Comment 18 Yevgen Muntyan 2007-04-07 08:15:15 UTC
*** Bug 333319 has been marked as a duplicate of this bug. ***
Comment 19 Matthias Clasen 2007-06-12 18:50:23 UTC
I have been able to reproduce this problem in thunderbird under kde now.
The very easy workaround is to just remove the klipper applet from the panel.
Comment 20 Yevgen Muntyan 2007-06-13 00:57:52 UTC
(In reply to comment #19)
> I have been able to reproduce this problem in thunderbird under kde now.
> The very easy workaround is to just remove the klipper applet from the panel.

Nope, you've only seen the 100%-reproducable problem with klipper, the one I don't say anything about since nobody gives a shoot to klipper. The bug exists without klipper too, unfortunately. Hardly reproducable, depending on day time and weather, and I don't know what else.

Note that the "easy workaround" means you need to stop using clipboard manager, something which might not be that "easy" (I indeed have stopped using it, exactly because gtk has some strange ideas about how text selection should behave in a modern gui toolkit). You know, another easy workaround is not to use GtkFileChooser. Apparently people indeed use this workaround. "Mouse and nautilus are your friends", "geeks use terminal", and all that.
Comment 21 Oded Arbel 2007-06-13 11:54:44 UTC
I can't reproduce this problem anymore with GNOME 2.18 and klipper. I'm using a rather fast computer, so it might be that my computer is too fast. I tried to reproduce this on a virtual machine, but apparently that wasn't slow enough either.
Comment 22 kujub 2009-03-17 16:27:27 UTC
I _can_ confirm this problem here on ArchLinux 686 with Xfce 4.6.0 when klipper is running.

It happend with Firefox in "Choose Helper Application" file dialog after clicking on a link to a file of unknown type and select Open with -> Browse, but i can not reproduce this any more with firefox right now after restarting firefox and klipper.

I can reproduce this with both avidemux2_gtk and mousepad (Xfce text editor) File->Open.

Steps to reproduce:
- ensure /usr/src/ exists.
- make a clean user profile ($HOME contains only: .bash_history .bash_profile .bashrc)
- start Xfce4
- start klipper
- start avidemux2_gtk or mousepad
- click File->Open
- click "Type a file name" icon to show "Location:"
- type in: /usr/
- wait until autocomplete list is ready
- erase and type in again: /usr/
Result:
location contains text /usr/src//

ArchLinux 686 package versions:
avidemux 2.4.4-1
firefox 3.0.7-1
gtk2 2.14.7-2
glib 1.2.10-7
KDE: 4.2.1 (KDE 4.2.1)
Klipper: v0.9.7
mousepad 0.2.16-1
Qt: 4.5.0
xfce4-clipman-plugin 0.9.0-1
xorg-server 1.5.3-4

Hardware:
Pentium Dual  CPU  E2200  @ 2.20GHz


Further problem:

When using Xfce4 clipman panel plugin with "Add selection to history" enabled
and typing /usr/local/share in some open file dialog i get these entries in the history:
sr/
r/
cal/
al/
l/
are/
re/
e/
When using klipper with option "Ignore selection" disabled (default) i get:
l/
share

This is very weird too, since there was no selection made by the user.
Comment 23 Alexander Kojevnikov 2009-03-17 21:13:38 UTC
I can (sometimes) reproduce this bug in Ubuntu 8.10 x64 when Parcellite [1] is running.

If I quit Parcellite everything works fine.

[1] http://parcellite.sourceforge.net
Comment 24 Federico Mena Quintero 2009-03-18 17:08:16 UTC
The problem is that the file chooser's entry uses the selection in GtkEntry to hold state about "this is what will be inserted if the user hits Tab", but klipper steals the selection ownership.

I'm willing to consider a patch that adds two fields to GtkFileChooserEntry, completion_start_pos and completion_end_pos, and uses *those* to keep the selection bounds instead of GtkEntry's own data.
Comment 25 Owen Taylor 2009-03-18 18:55:02 UTC
If klipper is stealing the selection, the user experience will be entirely be broken anyways. No point in trying to work around that.
Comment 26 kujub 2009-03-18 19:55:20 UTC
Hmm, I really think there shouldn't be any selection at all here because the user does not do it. Even if this bug would get fixed, there would still remain the 'further problem' i described in comment #22. It seems to me there should be some separate mechanism to do this competition stuff.
Comment 27 Connor Behan 2009-12-29 18:32:25 UTC
This bug follows me persistently in Archlinux as well. The only way I can get rid of it is by removing xfce4-clipman-plugin.

xfce4-clipman-plugin 1.1.3-1
gtk2 2.18.5-1

Is there a way to make certain widgets impervious to clipboard manager interference?
Comment 28 Emmanuele Bassi (:ebassi) 2009-12-30 00:05:49 UTC
(In reply to comment #26)
> Hmm, I really think there shouldn't be any selection at all here because the
> user does not do it.

moot point: we programmatically use the selection elsewhere to indicate that a part of the content will be overwritten (e.g. in gnome-screenshot, when saving the screenshot to a file, the file minus the extension will be pre-selected; this is customary to most save dialogs on Gnome).

the problem is the clipboard manager being overzealous and stealing the PRIMARY selection, as well as the CLIPBOARD. actually, the problem is the mere existence of a "clipboard manager" in the XXI century - but let's not digress.
Comment 29 Christian Dywan 2009-12-30 01:10:55 UTC
I think the point about abusing selection for state keeping is very valid. There is no way to programmatically find out the common completion or all possible completions. And it's impossible to insert one, even by inserting and selecting text. For what I want, proper state and API would be the right way.
My personal workaround is bookmarks and a mouse pointer. I can't do without persistent clipboard history.
Comment 30 Connor Behan 2009-12-30 01:21:51 UTC
But somehow certain programs can automatically select text without worrying about it getting stolen by a clipboard manager. e.g. the location entry bar in Thunar works exactly the same way as the Filechooser when the clipboard manager is disabled... however when I enable it Thunar keeps working while the Filechooser doesn't.

I've tried to see what Thunar does differently but their code is completely based on the Filechooser code. Hardly anything is different.
Comment 31 Connor Behan 2010-01-11 21:47:52 UTC
Clipman users: A very rudimentary workaround is here: http://aur.archlinux.org/packages/xfce4-clipman-plugin-passive/xfce4-clipman-plugin-passive/nosteal.patch
Comment 32 Alexander Kojevnikov 2010-01-20 00:23:04 UTC
*** Bug 607485 has been marked as a duplicate of this bug. ***
Comment 33 Tim Hockin 2010-01-20 00:27:53 UTC
Apparently Glipper causes the same bug.  Sigh.
Comment 34 Clarence Risher 2010-04-28 17:15:58 UTC
While investigating this bug, before finding this bug report, I filmed a short screencast and explanation of the always-buggy behavior while Klipper/Glipper/etc are running.

http://www.youtube.com/watch?v=lkUgA8cwT2U
Comment 35 Federico Mena Quintero 2010-11-01 14:15:05 UTC
*** Bug 633604 has been marked as a duplicate of this bug. ***
Comment 36 Connor Behan 2011-02-25 03:21:43 UTC
Xfce users: This is fixed in the git version of xfce4-clipman-plugin. If you use xfce-4.8 you'll also need the git version of xfce4-settings to have things go back to normal. Or you can just kill xfce4-settings-helper.
Comment 37 Connor Behan 2012-01-02 22:36:05 UTC
Stupid Arch changed its policy so the link I posted above no longer works. To see the workaround that makes the xfce clipboard manager play nice with the location bar, just go to https://aur.archlinux.org/packages/xf/xfce4-clipman-plugin-passive/ and download the tarball.
Comment 38 Matthias Clasen 2018-02-10 05:12:46 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 39 Matthias Clasen 2018-04-14 23:59:30 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