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 741870 - When opening file, file chooser should default to the directory of a currently-opened file
When opening file, file chooser should default to the directory of a currentl...
Status: RESOLVED FIXED
Product: gnome-builder
Classification: Other
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: GNOME Builder Maintainers
GNOME Builder Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-12-22 17:04 UTC by Michael Catanzaro
Modified: 2014-12-27 17:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
editor-workspace: memorize last directory (3.17 KB, patch)
2014-12-27 04:51 UTC, Fabiano Fidêncio
committed Details | Review
editor-workspace: use g_clear_pointer() (967 bytes, patch)
2014-12-27 16:15 UTC, Michael Catanzaro
committed Details | Review

Description Michael Catanzaro 2014-12-22 17:04:31 UTC
When I select Open, Builder creates a file chooser dialog that starts out by displaying my recently-opened files. I then have to click through several levels of directories in order to reach the file I want to open. I could speed this up a little by adding a bookmark to the sidebar using nautilus, but in a big project with lots of nested directories that doesn't help much unless I create tons of bookmarks; for example, if the file I want to open is in ~/WebKit/Source/WebKit2/UIProcess/API/gtk then I have to click through six levels of folders before I can click on the file. I don't like this very much.

gedit takes a different approach: it uses gtk_file_chooser_set_current_folder() to show the directory of the file I'm currently editing when the file chooser is launched. From here, I can view recently-opened files with one click on the sidebar if need be, but I probably want to edit another file in the same directory, or in a nearby directory. This is much nicer. (Note that the documentation for GtkFileChooser explicitly recommends against what gedit is doing [1], but I think the documentation is wrong and silly: as a programmer, I don't want to open random recently-edited text files from other projects, I want to open files from the project I'm currently working on.)

(Since Builder can display multiple files at once, a somewhat different heuristic would be needed to pick the directory to show.)

[1] 
https://developer.gnome.org/gtk3/stable/GtkFileChooserDialog.html#gtkfilechooserdialog-setting-up
Comment 1 Christian Hergert 2014-12-22 19:01:52 UTC
This sounds reasonable to me. There was no reason for it to be different, it's just how it got written in haste to have a way to open files.
Comment 2 Fabiano Fidêncio 2014-12-27 04:51:18 UTC
Created attachment 293373 [details] [review]
editor-workspace: memorize last directory

When choosing a file to open, memorize the directory from where the
last file was opened and open this directory instead of "Recent" one.
Comment 3 Christian Hergert 2014-12-27 06:04:53 UTC
Thanks!

Pushed this to master, with a small style fix and I switched dirname() to g_path_get_dirname() since dirname() has non-obvious side-effects.
Comment 4 Fabiano Fidêncio 2014-12-27 11:48:05 UTC
I've also removed the libgen.h include, as it was not necessary anymore, and pushed to master.
Thanks a lot!
Comment 5 Michael Catanzaro 2014-12-27 16:15:12 UTC
Created attachment 293377 [details] [review]
editor-workspace: use g_clear_pointer()

Thanks Fabiano!

I see one missed opportunity to use g_clear_pointer().