2 * Copyright (C) 2008 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
24 #include "swfdec_cached.h"
25 #include "swfdec_debug.h"
28 G_DEFINE_ABSTRACT_TYPE (SwfdecCached
, swfdec_cached
, G_TYPE_OBJECT
)
41 static guint signals
[LAST_SIGNAL
] = { 0, };
44 swfdec_cached_get_property (GObject
*object
, guint param_id
, GValue
*value
,
47 SwfdecCached
*cached
= SWFDEC_CACHED (object
);
51 g_value_set_ulong (value
, cached
->size
);
54 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, param_id
, pspec
);
60 swfdec_cached_set_property (GObject
*object
, guint param_id
, const GValue
*value
,
63 SwfdecCached
*cached
= SWFDEC_CACHED (object
);
67 cached
->size
= g_value_get_ulong (value
);
70 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, param_id
, pspec
);
76 swfdec_cached_class_init (SwfdecCachedClass
* g_class
)
78 GObjectClass
*object_class
= G_OBJECT_CLASS (g_class
);
80 object_class
->get_property
= swfdec_cached_get_property
;
81 object_class
->set_property
= swfdec_cached_set_property
;
83 /* FIXME: should be g_param_spec_size(), but no such thing exists */
84 g_object_class_install_property (object_class
, PROP_SIZE
,
85 g_param_spec_ulong ("size", "size", "size of this object in bytes",
86 0, G_MAXULONG
, 0, G_PARAM_READWRITE
| G_PARAM_CONSTRUCT_ONLY
));
88 signals
[USE
] = g_signal_new ("use", G_TYPE_FROM_CLASS (g_class
),
89 G_SIGNAL_RUN_LAST
, 0, NULL
, NULL
, g_cclosure_marshal_VOID__VOID
,
91 signals
[UNUSE
] = g_signal_new ("unuse", G_TYPE_FROM_CLASS (g_class
),
92 G_SIGNAL_RUN_LAST
, 0, NULL
, NULL
, g_cclosure_marshal_VOID__VOID
,
97 swfdec_cached_init (SwfdecCached
* cached
)
99 cached
->size
= sizeof (SwfdecCached
);
103 swfdec_cached_use (SwfdecCached
*cached
)
105 g_return_if_fail (SWFDEC_IS_CACHED (cached
));
107 g_signal_emit (cached
, signals
[USE
], 0);
111 swfdec_cached_unuse (SwfdecCached
*cached
)
113 g_return_if_fail (SWFDEC_IS_CACHED (cached
));
115 g_signal_emit (cached
, signals
[UNUSE
], 0);
119 swfdec_cached_get_size (SwfdecCached
*cached
)
121 g_return_val_if_fail (SWFDEC_IS_CACHED (cached
), 0);