Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File chooser dialogs remember the last visited directory #38

Open
frankMilde opened this issue Dec 23, 2016 · 10 comments
Open

File chooser dialogs remember the last visited directory #38

frankMilde opened this issue Dec 23, 2016 · 10 comments

Comments

@frankMilde
Copy link
Contributor

Nice and really useful software. This is a feature request from having worked a bit with it.

It would be nice, when the Add and Save file chooser dialogs would remember (separately) the last visited
dir instead of having to browse anew all the time.

@adrienverge
Copy link
Owner

That's true. Contributions are welcome! :)

@frankMilde
Copy link
Contributor Author

I think it might be possible to hard code something and save the last visited dir and then set_current_folder upon opening the filechooser.

However, it seems, the behavior of the file chooser is partially controlled by the GTK system settings.

Until GTK+2 you could change the behavoir by changing ~/.config/gtk-2.0/gtkfilechooser.ini and choose as

StartupMode=cwd | recent | last

which would mean, when you open any file chooser, use initially cwd -> your home dir, or recent -> recently used or last -> last visited dir.

This changed with GTK+3. There is no more .ini, instead you have to

$ gsettings set org.gtk.Settings.FileChooser startup-mode cwd

Also last is no longer available as startup mode.

<enum id='org.gtk.Settings.FileChooser.StartupMode'>
    <value nick='recent' value='0'/>
    <value nick='cwd' value='1'/>
</enum>

There is still a key called last-folder-uri but it does not work as intended.

The GTK maintainers go a lot of flag for this sudden and unneccessary change, but they are a stubborn bunch and did not change anything.

@ojob
Copy link

ojob commented Oct 17, 2017

Hi,
Just a comment on this feature: why not save the location in a ~/.photocollage/session file? Would this be breaking any state-of-the-art development rule?
If not, this is something I know how to do, and may be able to contribute in the coming weeks.

@adrienverge
Copy link
Owner

Hi @ojob,

Good idea, I think this would be a good way to do it.

If you want to contribute, can you split your change in two:

  1. Use a config file if present, using standard locations:

    # User-global config is supposed to be in ~/.config/photocollage/config
    if 'XDG_CONFIG_HOME' in os.environ:
        config_file = os.path.join(
            os.environ['XDG_CONFIG_HOME'], 'photocollage', 'config')
    else:
        config_file = os.path.expanduser('~/.config/photocollage/config')

    I'd like to use the YAML format for this config file, for example like this, what do you think?

    config:
      last_visited_directory: /home/adrien/photos
  2. Read / store the last visited directory in config.

@ojob
Copy link

ojob commented Oct 26, 2017

Hi @adrienverge,

Ok, so I'll made two commits in the pull request I'll provide, one for file creation/handling, another for usage in the frame of visited directory storage/usage.

Concerning YAML, no problem with that. I had to read a little about it, but nothing too complicated considering the available PyYAML library.

I'll slowly start working on this in the coming weeks, as winter comes closer ;-)

@adrienverge
Copy link
Owner

Sounds good! :-)

ojob pushed a commit to ojob/PhotoCollage that referenced this issue Oct 26, 2017
…m filesystem

WARNING: this commit has not been tested (missing GTK dependencies)

Format of the configuration is dict-based. Current implementation will
use the YAML format.

Signed-off-by: Joël BOURGAULT <jbourgault@sii.fr>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 7, 2017
Also added usage of built-in `logging` module.

WARNING: this commit has not been tested (missing GTK dependencies)

Signed-off-by: Joël BOURGAULT <joel.bourgault@gmail.com>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 7, 2017
WARNING: this has not been tested (missing GTK dependencies)

Signed-off-by: Joël BOURGAULT <jbourgault@sii.fr>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 7, 2017
I choose to make interface with other Gtk classes 'simpler', i.e. at a
lower level: these do not access Options instance directly, but directly
to parameters or to `parent` instance.

WARNING: not tested yet (missing GTK dependencies)

Signed-off-by: Joël BOURGAULT <jbourgault@sii.fr>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 7, 2017
…ming.

WARNING: not tested yet (missing GTK dependencies)

Signed-off-by: Joël BOURGAULT <jbourgault@sii.fr>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 7, 2017
Signed-off-by: Joël BOURGAULT <jbourgault@sii.fr>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 7, 2017
WARNING: not tested (missing GTK dependencies)

Signed-off-by: Joël BOURGAULT <jbourgault@sii.fr>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 7, 2017
Signed-off-by: Joël BOURGAULT <jbourgault@sii.fr>
@ojob
Copy link

ojob commented Nov 7, 2017

I added an YamlOptionsManager class, in a config module. Not sure that the names are the best overall; feel free to propose more appropriate names (I hesitated between config and options).

In current state of branch, the Options class that existed in PhotoCollageWindow.__init__ is now handled by an instance of YamlOptionsManager, meaning that output size, border size and color, should be now tunable by manually editing the config file, or by changing the setting through the HMI and proper program exit. However, I could not yet test the code, as I still have to manage to install GTK dependencies.

@ojob
Copy link

ojob commented Nov 9, 2017

@adrienverge I feel that I am, in fact, working on another topic than just remembering the last visited directory - this could have been limited to the current session.

Any idea how I could identify nicely the work on config file I'm doing, after creating a new GitHub Issue, without having to rebase all my commits with the new issue reference?

ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 9, 2017
Signed-off-by: Joël Bourgault <joel.bourgault@gmail.com>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 9, 2017
Signed-off-by: Joël Bourgault <joel.bourgault@gmail.com>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 9, 2017
Signed-off-by: Joël Bourgault <joel.bourgault@gmail.com>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 9, 2017
And some other minor improvements.

This commit has been tested, both with python2.7.13 and python3.5.3.

Signed-off-by: Joël Bourgault <joel.bourgault@gmail.com>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 9, 2017
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 10, 2017
Signed-off-by: Joël Bourgault <joel.bourgault@gmail.com>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 10, 2017
Signed-off-by: Joël Bourgault <joel.bourgault@gmail.com>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 10, 2017
This works by file selection using the GUI, or by file addition with a
drag&drop operation. Last visited directory is also stored on disk, using
the options file.

Signed-off-by: Joël Bourgault <joel.bourgault@gmail.com>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 10, 2017
Signed-off-by: Joël BOURGAULT <jbourgault@sii.fr>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 10, 2017
Signed-off-by: Joël BOURGAULT <jbourgault@sii.fr>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 10, 2017
This works by file selection using the GUI, or by file addition with a
drag&drop operation.

Signed-off-by: Joël Bourgault <joel.bourgault@gmail.com>
ojob referenced this issue in ojob/PhotoCollage Nov 11, 2017
…d-dir' into daily

# Conflicts:
#	photocollage/gtkgui.py
ojob referenced this issue in ojob/PhotoCollage Nov 11, 2017
…o daily

# Conflicts:
#	photocollage/gtkgui.py
#	photocollage/render.py
@ojob
Copy link

ojob commented Nov 11, 2017

I merged the two branches.

See the result in my daily build.

@ojob
Copy link

ojob commented Nov 11, 2017

I missed another location to remember: the output directory (which can be different from inputs directory). Will work on this later.

ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 12, 2017
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 12, 2017
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 12, 2017
…tps://github.com/ojob/PhotoCollage.git into daily

# Conflicts:
#	photocollage/gtkgui.py

Signed-off-by: Joël Bourgault <joel.bourgault@gmail.com>
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Nov 12, 2017
ojob pushed a commit to ojob/PhotoCollage that referenced this issue Mar 10, 2019
This is linked to issue adrienverge#38: remember last visited directory.

Access to configuration data can be performed by attribute or as dict
entries.

File is in YAML format, and is written automatically at exit.

I choose to make interface with other Gtk classes 'simpler', i.e. at a
lower level: these do not access Options instance directly, but directly
to parameters or to `parent` instance.

Signed-off-by: Joël Bourgault <joel.bourgault@gmail.com>
zkhcohen added a commit to zkhcohen/PhotoCollage that referenced this issue Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants