[gimp] app: port gimpconfig-dump.c to GIO
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: port gimpconfig-dump.c to GIO
- Date: Tue, 12 Aug 2014 10:59:33 +0000 (UTC)
commit 26f45822e763bb8b97ea144340eb9ebb28537a54
Author: Michael Natterer <mitch gimp org>
Date: Tue Aug 12 12:59:12 2014 +0200
app: port gimpconfig-dump.c to GIO
app/Makefile.am | 2 +
app/config/Makefile.am | 2 +
app/config/gimpconfig-dump.c | 75 +++++++++++++++++++++++++----------------
3 files changed, 50 insertions(+), 29 deletions(-)
---
diff --git a/app/Makefile.am b/app/Makefile.am
index 674fcb2..ecaad10 100644
--- a/app/Makefile.am
+++ b/app/Makefile.am
@@ -178,6 +178,8 @@ gimpconsoleldadd = \
$(PANGOCAIRO_LIBS) \
$(HARFBUZZ_LIBS) \
$(CAIRO_LIBS) \
+ $(GIO_UNIX_LIBS) \
+ $(GIO_WINDOWS_LIBS) \
$(GEGL_LIBS) \
$(GLIB_LIBS) \
$(GEXIV2_LIBS) \
diff --git a/app/config/Makefile.am b/app/config/Makefile.am
index 8046291..c5772bc 100644
--- a/app/config/Makefile.am
+++ b/app/config/Makefile.am
@@ -14,6 +14,8 @@ AM_CPPFLAGS = \
-I$(top_srcdir) \
-I$(top_builddir)/app \
-I$(top_srcdir)/app \
+ $(GIO_UNIX_CFLAGS) \
+ $(GIO_WINDOWS_CFLAGS) \
$(GEGL_CFLAGS) \
$(CAIRO_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
diff --git a/app/config/gimpconfig-dump.c b/app/config/gimpconfig-dump.c
index 1de6330..8f3decd 100644
--- a/app/config/gimpconfig-dump.c
+++ b/app/config/gimpconfig-dump.c
@@ -23,22 +23,20 @@
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
+#ifdef G_OS_WIN32
+#include <gio/gwin32outputstream.h>
+#else
+#include <gio/gunixoutputstream.h>
+#endif
+
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
-#ifdef G_OS_WIN32
-#include "libgimpbase/gimpwin32-io.h"
-#endif
-
#include "config-types.h"
#include "gimpconfig-dump.h"
@@ -48,23 +46,31 @@
static void dump_gimprc_system (GimpConfig *rc,
GimpConfigWriter *writer,
- gint fd);
+ GOutputStream *output);
static void dump_gimprc_manpage (GimpConfig *rc,
GimpConfigWriter *writer,
- gint fd);
+ GOutputStream *output);
static gchar * dump_describe_param (GParamSpec *param_spec);
-static void dump_with_linebreaks (gint fd,
+static void dump_with_linebreaks (GOutputStream *output,
const gchar *text);
gboolean
gimp_config_dump (GimpConfigDumpFormat format)
{
+ GOutputStream *output;
GimpConfigWriter *writer;
GimpConfig *rc;
rc = g_object_new (GIMP_TYPE_RC, NULL);
- writer = gimp_config_writer_new_fd (1);
+
+#ifdef G_OS_WIN32
+ output = g_win32_output_stream_new ((gpointer) 1, FALSE);
+#else
+ output = g_unix_output_stream_new (1, FALSE);
+#endif
+
+ writer = gimp_config_writer_new_stream (output, NULL, NULL);
switch (format)
{
@@ -80,15 +86,16 @@ gimp_config_dump (GimpConfigDumpFormat format)
break;
case GIMP_CONFIG_DUMP_GIMPRC_SYSTEM:
- dump_gimprc_system (rc, writer, 1);
+ dump_gimprc_system (rc, writer, output);
break;
case GIMP_CONFIG_DUMP_GIMPRC_MANPAGE:
- dump_gimprc_manpage (rc, writer, 1);
+ dump_gimprc_manpage (rc, writer, output);
break;
}
gimp_config_writer_finish (writer, NULL, NULL);
+ g_object_unref (output);
g_object_unref (rc);
return TRUE;
@@ -113,7 +120,7 @@ static const gchar system_gimprc_header[] =
static void
dump_gimprc_system (GimpConfig *rc,
GimpConfigWriter *writer,
- gint fd)
+ GOutputStream *output)
{
GObjectClass *klass;
GParamSpec **property_specs;
@@ -244,14 +251,15 @@ static const gchar man_page_footer[] =
static void
dump_gimprc_manpage (GimpConfig *rc,
GimpConfigWriter *writer,
- gint fd)
+ GOutputStream *output)
{
GObjectClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
- write (fd, man_page_header, strlen (man_page_header));
+ gimp_output_stream_printf (output, NULL, NULL, NULL,
+ "%s", man_page_header);
klass = G_OBJECT_GET_CLASS (rc);
property_specs = g_object_class_list_properties (klass, &n_property_specs);
@@ -267,16 +275,20 @@ dump_gimprc_manpage (GimpConfig *rc,
if (prop_spec->flags & GIMP_CONFIG_PARAM_IGNORE)
continue;
- write (fd, ".TP\n", strlen (".TP\n"));
+ gimp_output_stream_printf (output, NULL, NULL, NULL,
+ ".TP\n");
if (gimp_config_serialize_property (rc, prop_spec, writer))
{
- write (fd, "\n", 1);
+ gimp_output_stream_printf (output, NULL, NULL, NULL,
+ "\n");
desc = dump_describe_param (prop_spec);
- dump_with_linebreaks (fd, desc);
- write (fd, "\n", 1);
+ dump_with_linebreaks (output, desc);
+
+ gimp_output_stream_printf (output, NULL, NULL, NULL,
+ "\n");
g_free (desc);
}
@@ -284,8 +296,10 @@ dump_gimprc_manpage (GimpConfig *rc,
g_free (property_specs);
- write (fd, man_page_path, strlen (man_page_path));
- write (fd, man_page_footer, strlen (man_page_footer));
+ gimp_output_stream_printf (output, NULL, NULL, NULL,
+ "%s", man_page_path);
+ gimp_output_stream_printf (output, NULL, NULL, NULL,
+ "%s", man_page_footer);
}
@@ -495,8 +509,8 @@ dump_describe_param (GParamSpec *param_spec)
#define LINE_LENGTH 78
static void
-dump_with_linebreaks (gint fd,
- const gchar *text)
+dump_with_linebreaks (GOutputStream *output,
+ const gchar *text)
{
gint len = strlen (text);
@@ -507,7 +521,8 @@ dump_with_linebreaks (gint fd,
/* groff doesn't like lines to start with a single quote */
if (*text == '\'')
- write (fd, "\\&", 2); /* this represents a zero width space */
+ gimp_output_stream_printf (output, NULL, NULL, NULL,
+ "\\&"); /* a zero width space */
for (t = text, i = 0, space = 0;
*t != '\n' && (i <= LINE_LENGTH || space == 0) && i < len;
@@ -520,11 +535,13 @@ dump_with_linebreaks (gint fd,
if (i > LINE_LENGTH && space && *t != '\n')
i = space;
- write (fd, text, i);
- write (fd, "\n", 1);
+ g_output_stream_write_all (output, text, i, NULL, NULL, NULL);
+ gimp_output_stream_printf (output, NULL, NULL, NULL,
+ "\n");
if (*t == '\n')
- write (fd, ".br\n", 4);
+ gimp_output_stream_printf (output, NULL, NULL, NULL,
+ ".br\n");
i++;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]