GNOME Bugzilla – Bug 170171
User defined name when saving by drag and drop
Last modified: 2021-05-25 12:37:38 UTC
Distribution/Version: ubuntu Log on GNOME with a non-english locale (let say french "fr_FR.UTF-8") Press the key "Print Screen" to invoke the screenshot applet. when the UI appears when the thumbnail, drop the thumbnail to the desktop instead of saving. The file produced didn't have it's name translated (screenshot.png instead of capture.png)
This is an 'issue' at Gentoo too. imo the dropped image shouldn't use the default generic name, but the one filled in at the name textbox, wich defaults to the name in the current locale. That would also allow someone to choose a name and dnd it at the same time. And if it has to be a default name, allow for the option to change it too screenshot-2.png or something when it encounters an already existing screenshot.png.
Created attachment 56326 [details] [review] Attached patch fixes the bug. The Dragged preview image in the screenshot dialog uses the default generic name, but the not one filled in at the textbox entry. When Screenshot is taken, a temporary directory is created and the preview image file is stored in the directory with a generic name (for eg:"screenshot.png" in C locale) which is the cause of the bug. Copying the preview image to the temporary folder with the filename in the text box entry when ever there is a drag operation fixes the bug.
Hello, is there somebody to review that patch and commit it ? Thank you
some review of the patch; I'm not the author of gnome-screensaver, though. I don't really undestand the namings of the patch: you say that a temporary directory is going to be created; yet, I don't see how it's going to be created. also, why do you have "first_saved" and "last_saved"? What does this mean? + filename = g_strdup (screenshot_save_get_lastfile()); + + if (g_file_test (filename, G_FILE_TEST_EXISTS)) + error_occurred = unlink (filename); You should never use g_file_test to check whether it's safe to perform an action, because the state of the file might change between the test and the action: just remove the file and check for failure; also, use g_unlink() which is portable. +gchar * +screenshot_dialog_get_filename (gpointer data) +{ + ScreenshotDialog *dialog = data; + + return gtk_entry_get_text (GTK_ENTRY (dialog->filename_entry)); +} Don't use a gpointer: you are making debugging more difficult by using void pointers. C already has its type problems with explicit castings: don't make it harder for developers by using unnecessary an implicit cast. If you wish to use the screenshot_dialog_get_filename() function inside a file where ScreenshotDialog is not a known type you are masking a logic error - and asking for trouble. +char * +screenshot_save_get_filename (gpointer data) same here: screenshot-save.h does not need to know about the ScreenshotDialog; also, use g_build_filename() to create a valid file name. I don't think that most of the machinery done with this patch is needed; screenshot_save_get_filename() should accept an optional filename for the target: if it's passed, then it should use it to create the target filename: gchar * screenshot_save_get_filename (const gchar *target) { gchar *retval = NULL; if (target && target[0] != '\0') retval = g_build_filename (parent_dir, "screenshot.png", NULL); else retval = g_strdup_printf (parent_dir, target, NULL); g_free (last_saved_file); last_saved_file = g_strdup (retval); return retval; } at this point, you can call it with the contents of the file entry.
the logic of the if() is backwards, sorry
I've marked the string holding the name of the temporary file as translatable; now, saving by drag and drop will use the translated name. as for using the content of the file entry: there's a plan for removing the file entry and using a filechooser button and changing the layout of the UI; since we are in UI freeze, I cannot make this change now, and it'll have to wait the next development cycle. I also plan to branch off earlier in order to work on this and other issues. I'll remove the "blocker" status, as the base request has been implemented, and mark this bug as a RFE.
Hello Emmanuele, As you said you planned to correct this in 2.15.x I wanted to ping you on that. Cheers.
sorry, didn't have enough time to work on all the UI changes in gnome-screenshot. I'm afraid it'll have to wait as soon as we branch for the next development cycle (which might be sooner than 2.16 is released, if no major stuff is going to happen).
One year passed, and the freeze was hit again, let's wait another year :)
This bug partially overlaps with bug 399326 "Dragging to nautilus doesn't store as filename used in file location input field".
*** Bug 399326 has been marked as a duplicate of this bug. ***
Setting patch status to obsolete, since the patch doesn't apply anymore.
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new enhancement request ticket at https://gitlab.gnome.org/GNOME/gnome-screenshot/-/issues/ Thank you for your understanding and your help.