--- gsf-output-gzip.c.orig 2019-10-14 10:28:11.549673629 -0400 +++ gsf-output-gzip.c 2019-10-14 13:09:36.813060057 -0400 @@ -35,6 +35,7 @@ GsfOutput *sink; /* compressed data */ gboolean raw; /* No header and no trailer. */ + gint complev; /* zlib compression level */ z_stream stream; uLong crc; /* crc32 of uncompressed data */ @@ -51,7 +52,8 @@ enum { PROP_0, PROP_RAW, - PROP_SINK + PROP_SINK, + PROP_COMPLEV }; @@ -63,7 +65,7 @@ { int ret; - ret = deflateInit2 (&gzip->stream, Z_DEFAULT_COMPRESSION, + ret = deflateInit2 (&gzip->stream, gzip->complev, Z_DEFLATED, -MAX_WBITS, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY); if (ret != Z_OK) @@ -105,6 +107,39 @@ } /** + * gsf_output_gzip_new_full: + * @sink: The underlying data source. + * @compress_level: The zlib compression level (0 to 9). + * @err: optionally %NULL. + * + * Adds a reference to @sink. + * + * Returns: a new file or %NULL. + **/ +GsfOutput * +gsf_output_gzip_new_full (GsfOutput *sink, gint compress_level, GError **err) +{ + GsfOutput *output; + GError const *con_err; + + g_return_val_if_fail (GSF_IS_OUTPUT (sink), NULL); + + output = g_object_new (GSF_OUTPUT_GZIP_TYPE, "sink", sink, + "complev", compress_level, NULL); + + con_err = gsf_output_error (output); + + if (con_err) { + if (err) + *err = g_error_copy (con_err); + g_object_unref (output); + return NULL; + } + + return output; +} + +/** * gsf_output_gzip_new: * @sink: The underlying data source. * @err: optionally %NULL. @@ -281,6 +316,7 @@ gzip->isize = 0; gzip->buf = NULL; gzip->buf_size = 0; + gzip->complev = Z_DEFAULT_COMPRESSION; } static void @@ -298,6 +334,9 @@ case PROP_SINK: g_value_set_object (value, gzip->sink); break; + case PROP_COMPLEV: + g_value_set_int (value, gzip->complev); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -329,6 +368,9 @@ case PROP_SINK: gsf_output_gzip_set_sink (gzip, g_value_get_object (value)); break; + case PROP_COMPLEV: + gzip->complev = g_value_get_int (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -393,6 +435,16 @@ GSF_PARAM_STATIC | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property + (gobject_class, + PROP_COMPLEV, + g_param_spec_int ("complev", "Complev", + "zlib compression level.", + -1, 9, -1, + GSF_PARAM_STATIC | + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); + parent_class = g_type_class_peek_parent (gobject_class); } --- gsf-output-gzip.h.orig 2019-10-14 10:28:11.549673629 -0400 +++ gsf-output-gzip.h 2019-10-14 10:30:49.916341194 -0400 @@ -36,6 +36,8 @@ GType gsf_output_gzip_get_type (void); /* void gsf_output_gzip_register_type (GTypeModule *module); glib dynamic types are not thread safe */ +GsfOutput *gsf_output_gzip_new_full (GsfOutput *sink, gint compress_level, GError **err); + GsfOutput *gsf_output_gzip_new (GsfOutput *sink, GError **err); G_END_DECLS