summaryrefslogtreecommitdiff
path: root/mate-screenshot/src/screenshot-save.c
diff options
context:
space:
mode:
Diffstat (limited to 'mate-screenshot/src/screenshot-save.c')
-rw-r--r--mate-screenshot/src/screenshot-save.c71
1 files changed, 39 insertions, 32 deletions
diff --git a/mate-screenshot/src/screenshot-save.c b/mate-screenshot/src/screenshot-save.c
index 85559ed6..1acf898f 100644
--- a/mate-screenshot/src/screenshot-save.c
+++ b/mate-screenshot/src/screenshot-save.c
@@ -1,23 +1,26 @@
-/* screenshot-save.c - image saving functions for MATE Screenshot
+/* Copyright (C) 2001-2006 Jonathan Blandford <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
- * Copyright (C) 2001-2006 Jonathan Blandford <[email protected]>
+ * This file is part of MATE Utils.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * MATE Utils is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * MATE Utils is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * You should have received a copy of the GNU General Public License
+ * along with MATE Utils. If not, see <https://www.gnu.org/licenses/>.
*/
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
+
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
@@ -178,12 +181,12 @@ signal_handler (int sig)
void
screenshot_save_start (GdkPixbuf *pixbuf,
- SaveFunction callback,
- gpointer user_data)
+ SaveFunction callback,
+ gpointer user_data)
{
GPid pid;
- int parent_exit_notification[2];
- int pipe_from_child[2];
+ int parent_exit_notification[2];
+ int pipe_from_child[2];
if (pipe (parent_exit_notification) == -1)
perror("pipe error");
@@ -196,8 +199,8 @@ screenshot_save_start (GdkPixbuf *pixbuf,
return;
tmp_filename = g_build_filename (parent_dir,
- _("Screenshot.png"),
- NULL);
+ _("Screenshot.png"),
+ NULL);
save_callback = callback;
save_user_data = user_data;
@@ -214,18 +217,22 @@ screenshot_save_start (GdkPixbuf *pixbuf,
close (pipe_from_child [0]);
if (! gdk_pixbuf_save (pixbuf, tmp_filename,
- "png", &error,
- "tEXt::Software", "mate-screenshot",
- NULL))
- {
- if (error && error->message)
- if (write (pipe_from_child[1], error->message, strlen (error->message)) == -1)
- perror("write error");
- else
+ "png", &error,
+ "tEXt::Software", "mate-screenshot",
+ NULL))
+ {
+ if (error && error->message)
+ {
+ if (write (pipe_from_child[1], error->message, strlen (error->message)) == -1)
+ perror("write error");
+ }
+ else
+ {
#define ERROR_MESSAGE _("Unknown error saving screenshot to disk")
- if (write (pipe_from_child[1], ERROR_MESSAGE, strlen (ERROR_MESSAGE)) == -1)
- perror("write error");
- }
+ if (write (pipe_from_child[1], ERROR_MESSAGE, strlen (ERROR_MESSAGE)) == -1)
+ perror("write error");
+ }
+ }
/* By closing the pipe, we let the main process know that we're
* done saving it. */
close (pipe_from_child[1]);
@@ -245,9 +252,9 @@ screenshot_save_start (GdkPixbuf *pixbuf,
channel = g_io_channel_unix_new (pipe_from_child[0]);
g_io_add_watch (channel,
- G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
- read_pipe_from_child,
- NULL);
+ G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+ read_pipe_from_child,
+ NULL);
g_io_channel_unref (channel);
g_child_watch_add (pid, child_done_notification, NULL);
}