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 647697 - screenshot tool should always use a unique file name
screenshot tool should always use a unique file name
Status: RESOLVED FIXED
Product: vinagre
Classification: Applications
Component: general
unspecified
Other Linux
: Normal enhancement
: 3.4
Assigned To: vinagre-maint
vinagre-maint
Depends on:
Blocks:
 
 
Reported: 2011-04-13 18:31 UTC by William Jon McCann
Modified: 2011-10-30 19:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Appends a string created with strftime to the file name. (3.06 KB, patch)
2011-10-29 20:25 UTC, Sorina
rejected Details | Review
Appends a string containing the date created using glib functions with to the file name. (2.10 KB, patch)
2011-10-30 19:28 UTC, Sorina
committed Details | Review

Description William Jon McCann 2011-04-13 18:31:39 UTC
When I take successive screenshots of the same window it should ensure it defaults to a unique filename instead of making me append numbers to make it unique.  There is probably some code we can copy from gnome-screenshot for this.
Comment 1 David King 2011-04-13 21:17:21 UTC
http://git.gnome.org/browse/gnome-utils/tree/gnome-screenshot/gnome-screenshot.c#n1020 has the code for incrementing the number to be appended to the screenshot filename. As screenshot saving in Vinagre is currently done synchronously (http://git.gnome.org/browse/vinagre/tree/vinagre/vinagre-tab.c#n876), a possible solution would be to check if the file exists, and increment a suffix until a unique filename is created.
Comment 2 William Jon McCann 2011-04-14 18:09:11 UTC
Though I'm wondering if it would be even better to just use a timestamp.  This helps keep screenshots in the right order too.
Comment 3 Sorina 2011-10-29 20:25:24 UTC
Created attachment 200261 [details] [review]
Appends a string created with strftime to the file name.
Comment 4 David King 2011-10-29 21:15:22 UTC
Review of attachment 200261 [details] [review]:

In general, the approach that you have taken seems OK. However, there was new datetime API added in GLib 2.26 which can be used to make this task simpler:

http://developer.gnome.org/glib/stable/glib-GDateTime.html#glib-GDateTime.description

As GDateTime is a reference-counted object, it should make the memory management simpler, and g_date_time_format() will give a newly-allocated datetime string. A good first attempt, let me know if you need any further comments.
Comment 5 Sorina 2011-10-30 19:28:00 UTC
Created attachment 200297 [details] [review]
Appends a string containing the date created using glib functions with  to the file name.

That's my second try, I believe it should be better now.
Comment 6 David King 2011-10-30 19:49:48 UTC
Comment on attachment 200297 [details] [review]
Appends a string containing the date created using glib functions with  to the file name.

Pushed to master as commit 2c04d4558deae6414dd4de4b2fed13c7e06a024d, thanks!
Comment 7 David King 2011-10-30 19:51:05 UTC
Closing as FIXED. The other improvements can be dealt with later, and in another bug.