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 170171 - User defined name when saving by drag and drop
User defined name when saving by drag and drop
Status: RESOLVED OBSOLETE
Product: gnome-screenshot
Classification: Core
Component: general
git master
Other Linux
: Normal enhancement
: ---
Assigned To: gnome-screenshot-maint
gnome-screenshot-maint
: 399326 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-03-13 13:15 UTC by Baptiste Mille-Mathias
Modified: 2021-05-25 12:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Attached patch fixes the bug. (7.79 KB, patch)
2005-12-23 08:09 UTC, Anilkumar BVN
none Details | Review

Description Baptiste Mille-Mathias 2005-03-13 13:15:06 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)
Comment 1 Patrick Huizinga 2005-11-17 10:50:21 UTC
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.
Comment 2 Anilkumar BVN 2005-12-23 08:09:12 UTC
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.
Comment 3 Baptiste Mille-Mathias 2006-01-29 19:24:10 UTC
Hello, 

is there somebody to review that patch and commit it ?
Thank you
Comment 4 Emmanuele Bassi (:ebassi) 2006-01-29 20:13:50 UTC
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.
Comment 5 Emmanuele Bassi (:ebassi) 2006-01-29 20:21:38 UTC
the logic of the if() is backwards, sorry
Comment 6 Emmanuele Bassi (:ebassi) 2006-02-05 17:31:00 UTC
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.
Comment 7 Baptiste Mille-Mathias 2006-07-24 14:50:17 UTC
Hello Emmanuele,

As you said you planned to correct this in 2.15.x I wanted to ping you on that.

Cheers.
Comment 8 Emmanuele Bassi (:ebassi) 2006-07-24 15:03:55 UTC
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).
Comment 9 Baptiste Mille-Mathias 2007-08-03 21:35:50 UTC
One year passed, and the freeze was hit again, let's wait another year :)
Comment 10 Robert Pollak 2007-12-15 10:40:00 UTC
This bug partially overlaps with bug 399326 "Dragging to nautilus doesn't store as filename used in file location input field".
Comment 11 Cosimo Cecchi 2008-08-28 17:55:20 UTC
*** Bug 399326 has been marked as a duplicate of this bug. ***
Comment 12 Cosimo Cecchi 2008-08-28 17:55:54 UTC
Setting patch status to obsolete, since the patch doesn't apply anymore.
Comment 13 André Klapper 2021-05-25 12:37:38 UTC
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.