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 482534 - GtkFileChooserDefault needs to monitor "activate" on the filename entry
GtkFileChooserDefault needs to monitor "activate" on the filename entry
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkFileChooser
2.10.x
Other All
: Normal minor
: ---
Assigned To: gtk-bugs
Federico Mena Quintero
Depends on:
Blocks:
 
 
Reported: 2007-10-02 10:56 UTC by Kieran Clancy
Modified: 2018-02-10 04:33 UTC
See Also:
GNOME target: ---
GNOME version: 2.17/2.18



Description Kieran Clancy 2007-10-02 10:56:20 UTC
When creating a default file chooser, putting a directory into the location entry and pressing enter does nothing at all. See simple code below which does this reproducibly.

Expected behaviour would be to jump to the directory specified. If the entry isn't a directory, go to the parent (or if that doesn't exist, it's parent, etc) and have the file selected if it exists.

Some examples of expected behaviour:
1. Enter /tmp into the location entry and press enter
 - Open /tmp and display its contents

2. Enter /tmp/myfile into the location entry and press enter
 - Open /tmp and have the file 'myfile' selected

3. Enter /tmp/notfile into the location entry and press enter
 - Open /tmp

Curiously, the file chooser used in programs like gedit don't have this problem. I'm not sure what extra signals they connect to do that, but the standard file chooser should do this by default.

Other information:
#include <stdio.h>
#include <gtk/gtk.h>

int main(int argc, char **argv) {
    GtkWidget *win, *chooser;
    gtk_init(&argc, &argv);
    win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    chooser = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_OPEN);
    gtk_container_add(GTK_CONTAINER(win), chooser);
    gtk_widget_show_all(win);
    gtk_main();
}
Comment 1 Federico Mena Quintero 2008-03-07 04:15:58 UTC
The problem with your example is that you are using a plain GtkFileChooserWidget, not a full-fledged GtkFileChooserDialog.  The latter handles Enter correctly --- see bug #505857.

But now that you mention it, it's pretty hard to make a plain GtkFileChooserWidget work correctly, as there is no way to know when its filename entry gets activated.  Very few people use GtkFileChooserWidget (which is meant to be a building block, not a complete thing), and they rather use the full dialog instead.

Can you use a GtkFileChooserDialog instead?

If not, you may want to work on a patch for gtkfilechooserdefault.c so that it will do this:

* connect to "activate" on its GtkFileChooserEntry
* from its signal handler, emit "file-activated" like it does in list_row_activated().
Comment 2 Matthias Clasen 2018-02-10 04:33:55 UTC
We're moving to gitlab! As part of this move, we are closing bugs that haven't seen activity in more than 5 years. If this issue is still imporant to you and
still relevant with GTK+ 3.22 or master, please consider creating a gitlab issue
for it.