gobjectification: 5c240b4a: Implemented the GObject properties
grim at pidgin.im
grim at pidgin.im
Mon Mar 21 05:10:47 EDT 2011
----------------------------------------------------------------------
Revision: 5c240b4af2e215d53ee307b6aa7a32cbb2d5778a
Parent: 61b9fcfa675b77124b7e0a3d92f41b59aa2713a6
Author: grim at pidgin.im
Date: 03/21/11 05:06:31
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/5c240b4af2e215d53ee307b6aa7a32cbb2d5778a
Changelog:
Implemented the GObject properties
Cleaned up some API
Changes against parent 61b9fcfa675b77124b7e0a3d92f41b59aa2713a6
patched libpurple/circbuffer.c
patched libpurple/circbuffer.h
-------------- next part --------------
============================================================
--- libpurple/circbuffer.c 0f0033b374215374714e384b3a96b132d805779d
+++ libpurple/circbuffer.c ffbda0412887e5528426c4536cd1b5f13965c607
@@ -47,11 +47,9 @@ enum {
*****************************************************************************/
enum {
PROP_ZERO,
- PROP_BUFFER,
PROP_GROW_SIZE,
- PROP_BUFFER_LEN,
PROP_BUFFER_USED,
- PROP_IN_POINTER,
+ PROP_INPUT,
PROP_OUTPUT,
PROP_LAST,
};
@@ -183,6 +181,21 @@ purple_circular_buffer_real_mark_read(Pu
}
/******************************************************************************
+ * Private API
+ *****************************************************************************/
+static void
+purple_circular_buffer_set_grow_size(PurpleCircularBuffer *buffer,
+ gsize grow_size)
+{
+ PurpleCircularBufferPrivate *priv =
+ PURPLE_CIRCULAR_BUFFER_GET_PRIVATE(buffer);
+
+ priv->growsize = (grow_size != 0) ? grow_size : DEFAULT_BUF_SIZE;
+
+ g_object_notify(G_OBJECT(buffer), "grow-size");
+}
+
+/******************************************************************************
* Object Stuff
*****************************************************************************/
static void
@@ -202,6 +215,22 @@ purple_circular_buffer_get_property(GObj
PurpleCircularBuffer *buffer = PURPLE_CIRCULAR_BUFFER(obj);
switch(param_id) {
+ case PROP_GROW_SIZE:
+ g_value_set_ulong(value,
+ purple_circular_buffer_get_grow_size(buffer));
+ break;
+ case PROP_BUFFER_USED:
+ g_value_set_ulong(value,
+ purple_circular_buffer_get_used(buffer));
+ break;
+ case PROP_INPUT:
+ g_value_set_pointer(value,
+ purple_circular_buffer_get_input(buffer));
+ break;
+ case PROP_OUTPUT:
+ g_value_set_pointer(value,
+ purple_circular_buffer_get_output(buffer));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
break;
@@ -215,6 +244,10 @@ purple_circular_buffer_set_property(GObj
PurpleCircularBuffer *buffer = PURPLE_CIRCULAR_BUFFER(obj);
switch(param_id) {
+ case PROP_GROW_SIZE:
+ purple_circular_buffer_set_grow_size(buffer,
+ g_value_get_uint(value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
break;
@@ -236,6 +269,31 @@ purple_circular_buffer_class_init(Purple
buffer_class->append = purple_circular_buffer_real_append;
buffer_class->max_read_size = purple_circular_buffer_real_max_read_size;
buffer_class->mark_read = purple_circular_buffer_real_mark_read;
+
+ /* using a ulong for the gsize properties since there is no
+ * g_param_spec_size, and the ulong should always work. --gk 3/21/11
+ */
+ g_object_class_install_property(obj_class, PROP_GROW_SIZE,
+ g_param_spec_ulong("grow-size", "grow-size",
+ "The grow size of the buffer",
+ 0, G_MAXSIZE, 0,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property(obj_class, PROP_BUFFER_USED,
+ g_param_spec_ulong("buffer-used", "buffer-used",
+ "The amount of the buffer used",
+ 0, G_MAXSIZE, 0,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property(obj_class, PROP_INPUT,
+ g_param_spec_pointer("input", "input",
+ "The input pointer of the buffer",
+ G_PARAM_READABLE));
+
+ g_object_class_install_property(obj_class, PROP_OUTPUT,
+ g_param_spec_pointer("output", "output",
+ "The output pointer of the buffer",
+ G_PARAM_READABLE));
}
/******************************************************************************
@@ -319,47 +377,48 @@ gsize
}
gsize
-purple_circular_buffer_get_used(const PurpleCircularBuffer *buffer) {
+purple_circular_buffer_get_grow_size(const PurpleCircularBuffer *buffer) {
+
PurpleCircularBufferPrivate *priv = NULL;
g_return_val_if_fail(PURPLE_IS_CIRCULAR_BUFFER(buffer), 0);
priv = PURPLE_CIRCULAR_BUFFER_GET_PRIVATE(buffer);
- return priv->bufused;
+ return priv->growsize;
}
-const gchar *
-purple_circular_buffer_get_input(const PurpleCircularBuffer *buffer) {
+gsize
+purple_circular_buffer_get_used(const PurpleCircularBuffer *buffer) {
PurpleCircularBufferPrivate *priv = NULL;
- g_return_val_if_fail(PURPLE_IS_CIRCULAR_BUFFER(buffer), NULL);
+ g_return_val_if_fail(PURPLE_IS_CIRCULAR_BUFFER(buffer), 0);
priv = PURPLE_CIRCULAR_BUFFER_GET_PRIVATE(buffer);
- return priv->input;
+ return priv->bufused;
}
const gchar *
-purple_circular_buffer_get_output(const PurpleCircularBuffer *buffer) {
+purple_circular_buffer_get_input(const PurpleCircularBuffer *buffer) {
PurpleCircularBufferPrivate *priv = NULL;
g_return_val_if_fail(PURPLE_IS_CIRCULAR_BUFFER(buffer), NULL);
priv = PURPLE_CIRCULAR_BUFFER_GET_PRIVATE(buffer);
- return priv->output;
+ return priv->input;
}
const gchar *
-purple_circular_buffer_get_buffer(const PurpleCircularBuffer *buffer) {
+purple_circular_buffer_get_output(const PurpleCircularBuffer *buffer) {
PurpleCircularBufferPrivate *priv = NULL;
g_return_val_if_fail(PURPLE_IS_CIRCULAR_BUFFER(buffer), NULL);
priv = PURPLE_CIRCULAR_BUFFER_GET_PRIVATE(buffer);
- return priv->buffer;
+ return priv->output;
}
void
============================================================
--- libpurple/circbuffer.h 50871314da7f13cd0876394ffb6b169065f2947f
+++ libpurple/circbuffer.h 1175b9e64b874e32f640b10dff2dba88a291c7e2
@@ -113,10 +113,10 @@ void purple_circular_buffer_grow(PurpleC
gboolean purple_circular_buffer_mark_read(PurpleCircularBuffer *buf, gsize len);
void purple_circular_buffer_grow(PurpleCircularBuffer *buffer, gsize len);
+gsize purple_circular_buffer_get_grow_size(const PurpleCircularBuffer *buffer);
gsize purple_circular_buffer_get_used(const PurpleCircularBuffer *buffer);
const gchar *purple_circular_buffer_get_input(const PurpleCircularBuffer *buffer);
const gchar *purple_circular_buffer_get_output(const PurpleCircularBuffer *buffer);
-const gchar *purple_circular_buffer_get_buffer(const PurpleCircularBuffer *buffer);
void purple_circular_buffer_reset(PurpleCircularBuffer *buffer);
G_END_DECLS
More information about the Commits
mailing list