Example #1
0
gboolean
gimp_config_dump (GObject              *gimp,
                  GimpConfigDumpFormat  format)
{
  GOutputStream    *output;
  GimpConfigWriter *writer;
  GimpConfig       *rc;

  g_return_val_if_fail (G_IS_OBJECT (gimp), FALSE);

  rc = g_object_new (GIMP_TYPE_RC,
                     "gimp", gimp,
                     NULL);

#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)
    {
    case GIMP_CONFIG_DUMP_NONE:
      break;

    case GIMP_CONFIG_DUMP_GIMPRC:
      gimp_config_writer_comment (writer,
                                  "Dump of the GIMP default configuration");
      gimp_config_writer_linefeed (writer);
      gimp_config_serialize_properties (rc, writer);
      gimp_config_writer_linefeed (writer);
      break;

    case GIMP_CONFIG_DUMP_GIMPRC_SYSTEM:
      dump_gimprc_system (rc, writer, output);
      break;

    case GIMP_CONFIG_DUMP_GIMPRC_MANPAGE:
      dump_gimprc_manpage (rc, writer, output);
      break;
    }

  gimp_config_writer_finish (writer, NULL, NULL);
  g_object_unref (output);
  g_object_unref (rc);

  return TRUE;
}
Example #2
0
/**
 * gimp_config_serialize_to_stream:
 * @config: a #GObject that implements the #GimpConfigInterface.
 * @output: the #GOutputStream to write the configuration to.
 * @header: optional file header (must be ASCII only)
 * @footer: optional file footer (must be ASCII only)
 * @data: user data passed to the serialize implementation.
 * @error: return location for a possible error
 *
 * Serializes the object properties of @config to the stream specified
 * by @output.
 *
 * Return value: %TRUE if serialization succeeded, %FALSE otherwise.
 *
 * Since: 2.10
 **/
gboolean
gimp_config_serialize_to_stream (GimpConfig     *config,
                                 GOutputStream  *output,
                                 const gchar    *header,
                                 const gchar    *footer,
                                 gpointer        data,
                                 GError        **error)
{
  GimpConfigWriter *writer;

  g_return_val_if_fail (GIMP_IS_CONFIG (config), FALSE);
  g_return_val_if_fail (G_IS_OUTPUT_STREAM (output), FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  writer = gimp_config_writer_new_stream (output, header, error);
  if (!writer)
    return FALSE;

  GIMP_CONFIG_GET_INTERFACE (config)->serialize (config, writer, data);

  return gimp_config_writer_finish (writer, footer, error);
}