Public bug reported:

When the `PrintScrn` key is pressed in GNOME Shell, it takes a
screenshot and writes it to `$HOME/Pictures`, or otherwise falling back
to `$HOME` if that directory is not found. The `gnome-screenshot` tool
does a similar action, but also checks for the existence of the `auto-
save-directory` gsetting in `org.gnome.gnome-screenshot`. This will
allow GNOME Shell to also use that key, and store screenshots in this
location when found.

### Implementation Note

I added a `CowPtr` type to make it possible for the
`get_screenshot_directory()` function to return a `gchar*` which is
either owned or borrowed, and to free a value when it is owned.
`g_get_user_special_dir ()` and `g_get_home_dir ()` return `gchar*`
values which are owned by GLib, and must not be freed, but
`g_settings_get_string` is owned, and must be freed.

Alternatively, I could `g_strdup()` the values to copy them onto the
heap.

### Testing

1. Before applying the patch, take a screenshot with the PrintScrn key.
2. A screenshot should now be stored in `$HOME/Pictures`.
3. Create the new screenshot directory, and set the value for gnome-screenshot:
```sh
mkdir $HOME/Screenshots
gsettings set org.gnome.gnome-screenshot auto-save-directory $HOME/Screenshots
```
4. Take the screenshot again, and notice that it stores in `$HOME/Pictures` 
instead of `$HOME/Screenshots`
5. Apply the patch, and restart `gnome-shell`, then take the screenshot again
6. The screenshot should be written in `$HOME/Screenshots` instead of 
`$HOME/Pictures`.
7. Delete the gsettings value, and try again, to see that it returns to storing 
screenshots in `$HOME/Pictures`
```sh
gsettings reset org.gnome.gnome-screenshot auto-save-directory
```

** Affects: gnome-shell (Ubuntu)
     Importance: Undecided
         Status: New

** Patch added: "screenshot_dir.patch"
   
https://bugs.launchpad.net/bugs/1818905/+attachment/5244172/+files/screenshot_dir.patch

-- 
You received this bug notification because you are a member of Ubuntu
Desktop Bugs, which is subscribed to gnome-shell in Ubuntu.
https://bugs.launchpad.net/bugs/1818905

Title:
  Store screenshots to the org.gnome.gnome-screenshot auto-save-
  directory directory, if defined

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gnome-shell/+bug/1818905/+subscriptions

-- 
desktop-bugs mailing list
desktop-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/desktop-bugs

Reply via email to