GNOME Bugzilla – Bug 647697
screenshot tool should always use a unique file name
Last modified: 2011-10-30 19:51:05 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.
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.
Though I'm wondering if it would be even better to just use a timestamp. This helps keep screenshots in the right order too.
Created attachment 200261 [details] [review] Appends a string created with strftime to the file name.
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.
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 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!
Closing as FIXED. The other improvements can be dealt with later, and in another bug.