mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-22 23:29:16 +02:00
Add properties
svn path=/trunk/; revision=6006
This commit is contained in:
parent
650c65e892
commit
d8266ffb8f
@ -1,3 +1,7 @@
|
|||||||
|
2007-12-01 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gbufferedoutputstream.c: Add properties
|
||||||
|
|
||||||
2007-11-30 Matthias Clasen <mclasen@redhat.com>
|
2007-11-30 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* *.c: Unify the capitalization of section headings.
|
* *.c: Unify the capitalization of section headings.
|
||||||
|
@ -39,19 +39,17 @@
|
|||||||
*
|
*
|
||||||
* By default, #GBufferedOutputStream's buffer size is set at 4 kilobytes.
|
* By default, #GBufferedOutputStream's buffer size is set at 4 kilobytes.
|
||||||
*
|
*
|
||||||
* To create a buffered output stream, use g_buffered_output_stream_new(), or
|
* To create a buffered output stream, use g_buffered_output_stream_new(),
|
||||||
* g_buffered_output_stream_new_sized() to specify the buffer's size at construction.
|
* or g_buffered_output_stream_new_sized() to specify the buffer's size
|
||||||
|
* at construction.
|
||||||
*
|
*
|
||||||
* To get the size of a buffer within a buffered input stream, use
|
* To get the size of a buffer within a buffered input stream, use
|
||||||
* g_buffered_output_stream_get_buffer_size(). To change the size of a
|
* g_buffered_output_stream_get_buffer_size(). To change the size of a
|
||||||
* buffered output stream's buffer, use g_buffered_output_stream_set_buffer_size().
|
* buffered output stream's buffer, use
|
||||||
* Note: the buffer's size cannot be reduced below the size of the data within the
|
* g_buffered_output_stream_set_buffer_size(). Note that the buffer's
|
||||||
* buffer.
|
* size cannot be reduced below the size of the data within the buffer.
|
||||||
*
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define DEFAULT_BUFFER_SIZE 4096
|
#define DEFAULT_BUFFER_SIZE 4096
|
||||||
|
|
||||||
struct _GBufferedOutputStreamPrivate {
|
struct _GBufferedOutputStreamPrivate {
|
||||||
@ -63,7 +61,8 @@ struct _GBufferedOutputStreamPrivate {
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_BUFSIZE
|
PROP_BUFSIZE,
|
||||||
|
PROP_AUTO_GROW
|
||||||
};
|
};
|
||||||
|
|
||||||
static void g_buffered_output_stream_set_property (GObject *object,
|
static void g_buffered_output_stream_set_property (GObject *object,
|
||||||
@ -157,6 +156,15 @@ g_buffered_output_stream_class_init (GBufferedOutputStreamClass *klass)
|
|||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||||
G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
|
G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_AUTO_GROW,
|
||||||
|
g_param_spec_boolean ("auto-grow",
|
||||||
|
P_("Auto-grow"),
|
||||||
|
P_("Whether the buffer should automatically grow"),
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READWRITE|
|
||||||
|
G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -193,6 +201,9 @@ g_buffered_output_stream_set_buffer_size (GBufferedOutputStream *stream,
|
|||||||
|
|
||||||
priv = stream->priv;
|
priv = stream->priv;
|
||||||
|
|
||||||
|
if (size == priv->len)
|
||||||
|
return;
|
||||||
|
|
||||||
if (priv->buffer)
|
if (priv->buffer)
|
||||||
{
|
{
|
||||||
size = MAX (size, priv->pos);
|
size = MAX (size, priv->pos);
|
||||||
@ -210,6 +221,8 @@ g_buffered_output_stream_set_buffer_size (GBufferedOutputStream *stream,
|
|||||||
priv->len = size;
|
priv->len = size;
|
||||||
priv->pos = 0;
|
priv->pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT (stream), "buffer-size");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -240,9 +253,15 @@ void
|
|||||||
g_buffered_output_stream_set_auto_grow (GBufferedOutputStream *stream,
|
g_buffered_output_stream_set_auto_grow (GBufferedOutputStream *stream,
|
||||||
gboolean auto_grow)
|
gboolean auto_grow)
|
||||||
{
|
{
|
||||||
|
GBufferedOutputStreamPrivate *priv;
|
||||||
g_return_if_fail (G_IS_BUFFERED_OUTPUT_STREAM (stream));
|
g_return_if_fail (G_IS_BUFFERED_OUTPUT_STREAM (stream));
|
||||||
|
priv = stream->priv;
|
||||||
stream->priv->auto_grow = auto_grow;
|
auto_grow = auto_grow != FALSE;
|
||||||
|
if (priv->auto_grow != auto_grow)
|
||||||
|
{
|
||||||
|
priv->auto_grow = auto_grow;
|
||||||
|
g_object_notify (G_OBJECT (stream), "auto-grow");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -251,17 +270,18 @@ g_buffered_output_stream_set_property (GObject *object,
|
|||||||
const GValue *value,
|
const GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
GBufferedOutputStream *buffered_stream;
|
GBufferedOutputStream *stream;
|
||||||
GBufferedOutputStreamPrivate *priv;
|
|
||||||
|
|
||||||
buffered_stream = G_BUFFERED_OUTPUT_STREAM (object);
|
stream = G_BUFFERED_OUTPUT_STREAM (object);
|
||||||
priv = buffered_stream->priv;
|
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
case PROP_BUFSIZE:
|
case PROP_BUFSIZE:
|
||||||
g_buffered_output_stream_set_buffer_size (buffered_stream, g_value_get_uint (value));
|
g_buffered_output_stream_set_buffer_size (stream, g_value_get_uint (value));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_AUTO_GROW:
|
||||||
|
g_buffered_output_stream_set_auto_grow (stream, g_value_get_boolean (value));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -285,11 +305,14 @@ g_buffered_output_stream_get_property (GObject *object,
|
|||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
case PROP_BUFSIZE:
|
case PROP_BUFSIZE:
|
||||||
g_value_set_uint (value, priv->len);
|
g_value_set_uint (value, priv->len);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_AUTO_GROW:
|
||||||
|
g_value_set_boolean (value, priv->auto_grow);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user