summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Techet <techet@gmail.com>2016-09-27 00:34:36 +0200
committerJiří Techet <techet@gmail.com>2016-09-27 00:34:36 +0200
commite1f6e591ca752f20bb29cbe46b7f2e4e41468a56 (patch)
tree81639f98a9ab39a1101c9b5d0812621778f2b575
parentcb478b22ab1a64f250eea117aa2e807b2fbf3b34 (diff)
downloadlibchamplain-e1f6e591ca752f20bb29cbe46b7f2e4e41468a56.tar.gz
launcher-gtk: allow replacing exported map
It's too easy to miss there's already a png export in the current directory and expect the export happened alright even though it's still the original file. Also close the output stream correctly which was missing in the original code.
-rw-r--r--demos/launcher-gtk.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/demos/launcher-gtk.c b/demos/launcher-gtk.c
index 950b01f..70975b4 100644
--- a/demos/launcher-gtk.c
+++ b/demos/launcher-gtk.c
@@ -223,14 +223,6 @@ append_point (ChamplainPathLayer *layer, gdouble lon, gdouble lat)
static void
-export_to_png_cb (GdkPixbuf *pixbuf,
- GAsyncResult *res)
-{
- gdk_pixbuf_save_to_stream_finish (res, NULL);
-}
-
-
-static void
export_png (GtkButton *button,
ChamplainView *view)
{
@@ -254,18 +246,15 @@ export_png (GtkButton *button,
return;
file = g_file_new_for_path ("champlain-map.png");
- os = g_file_create (file, G_FILE_CREATE_NONE, NULL, NULL);
+ os = g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL);
if (!os)
{
g_object_unref (pixbuf);
return;
}
- gdk_pixbuf_save_to_stream_async (pixbuf,
- G_OUTPUT_STREAM (os), "png",
- NULL,
- (GAsyncReadyCallback) export_to_png_cb,
- NULL);
+ gdk_pixbuf_save_to_stream (pixbuf, G_OUTPUT_STREAM (os), "png", NULL, NULL);
+ g_output_stream_close (G_OUTPUT_STREAM (os), NULL, NULL);
}