don't clobber existing screenshots
This commit is contained in:
parent
35e834ff2c
commit
a3eebbac21
|
@ -218,7 +218,7 @@ void on_menu_quit_activate (GtkMenuItem *menuitem, gpointer user_data) { gtk
|
||||||
static void Printscreen()
|
static void Printscreen()
|
||||||
{
|
{
|
||||||
GdkPixbuf *screenshot;
|
GdkPixbuf *screenshot;
|
||||||
gchar *filename;
|
gchar *filename = NULL;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
u8 *rgb;
|
u8 *rgb;
|
||||||
u16 *gpuFramebuffer = (u16 *)GPU->GetDisplayInfo().masterNativeBuffer;
|
u16 *gpuFramebuffer = (u16 *)GPU->GetDisplayInfo().masterNativeBuffer;
|
||||||
|
@ -243,13 +243,17 @@ static void Printscreen()
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
filename = g_strdup_printf("./desmume-screenshot-%d.png", seq);
|
do {
|
||||||
|
g_free(filename);
|
||||||
|
filename = g_strdup_printf("./desmume-screenshot-%d.png", seq++);
|
||||||
|
}
|
||||||
|
while (g_file_test(filename, G_FILE_TEST_EXISTS));
|
||||||
|
|
||||||
gdk_pixbuf_save(screenshot, filename, "png", &error, NULL);
|
gdk_pixbuf_save(screenshot, filename, "png", &error, NULL);
|
||||||
if (error) {
|
if (error) {
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_printerr("Failed to save %s", filename);
|
g_printerr("Failed to save %s", filename);
|
||||||
} else {
|
seq--;
|
||||||
seq++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(rgb);
|
free(rgb);
|
||||||
|
|
|
@ -2359,7 +2359,7 @@ static void Printscreen()
|
||||||
{
|
{
|
||||||
GdkPixbuf *screenshot;
|
GdkPixbuf *screenshot;
|
||||||
const gchar *dir;
|
const gchar *dir;
|
||||||
gchar *filename, *filen;
|
gchar *filename = NULL, *filen = NULL;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
u8 rgb[256 * 384 * 4];
|
u8 rgb[256 * 384 * 4];
|
||||||
static int seq = 0;
|
static int seq = 0;
|
||||||
|
@ -2396,15 +2396,19 @@ static void Printscreen()
|
||||||
dir = g_get_home_dir();
|
dir = g_get_home_dir();
|
||||||
}
|
}
|
||||||
|
|
||||||
filen = g_strdup_printf("desmume-screenshot-%d.png", seq);
|
do {
|
||||||
|
g_free(filen);
|
||||||
|
g_free(filename);
|
||||||
|
filen = g_strdup_printf("desmume-screenshot-%d.png", seq++);
|
||||||
filename = g_build_filename(dir, filen, NULL);
|
filename = g_build_filename(dir, filen, NULL);
|
||||||
|
}
|
||||||
|
while (g_file_test(filename, G_FILE_TEST_EXISTS));
|
||||||
|
|
||||||
gdk_pixbuf_save(screenshot, filename, "png", &error, NULL);
|
gdk_pixbuf_save(screenshot, filename, "png", &error, NULL);
|
||||||
if (error) {
|
if (error) {
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_printerr("Failed to save %s", filename);
|
g_printerr("Failed to save %s", filename);
|
||||||
} else {
|
seq--;
|
||||||
seq++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//free(rgb);
|
//free(rgb);
|
||||||
|
|
Loading…
Reference in New Issue