summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen W. Taylor <otaylor@fishsoup.net>2010-11-04 17:26:24 -0400
committerOwen W. Taylor <otaylor@fishsoup.net>2010-11-13 11:44:45 -0500
commita846434bcfaabcf8bfb16fff1f415dab104cb737 (patch)
treec745acf6e1a3de71b0f464a1e4f7d0240f96cc4f
parent825fc2c0c86c36b58abb4a9eb41863c6aeefffd2 (diff)
downloadmutter-a846434bcfaabcf8bfb16fff1f415dab104cb737.tar.gz
MetaShadowFactory: convert to a GObject
https://bugzilla.gnome.org/show_bug.cgi?id=592382
-rw-r--r--src/compositor/meta-shadow-factory.c45
-rw-r--r--src/compositor/meta-shadow-factory.h13
2 files changed, 44 insertions, 14 deletions
diff --git a/src/compositor/meta-shadow-factory.c b/src/compositor/meta-shadow-factory.c
index 72697641e..577e33b04 100644
--- a/src/compositor/meta-shadow-factory.c
+++ b/src/compositor/meta-shadow-factory.c
@@ -84,11 +84,20 @@ struct _MetaShadow
struct _MetaShadowFactory
{
+ GObject parent_instance;
+
/* MetaShadowCacheKey => MetaShadow; the shadows are not referenced
* by the factory, they are simply removed from the table when freed */
GHashTable *shadows;
};
+struct _MetaShadowFactoryClass
+{
+ GObjectClass parent_class;
+};
+
+G_DEFINE_TYPE (MetaShadowFactory, meta_shadow_factory, G_TYPE_OBJECT);
+
static guint
meta_shadow_cache_key_hash (gconstpointer val)
{
@@ -253,27 +262,22 @@ meta_shadow_get_bounds (MetaShadow *shadow,
bounds->height = window_height + shadow->outer_border_top + shadow->outer_border_bottom;
}
-MetaShadowFactory *
-meta_shadow_factory_new (void)
+static void
+meta_shadow_factory_init (MetaShadowFactory *factory)
{
- MetaShadowFactory *factory;
-
- factory = g_slice_new0 (MetaShadowFactory);
-
factory->shadows = g_hash_table_new (meta_shadow_cache_key_hash,
meta_shadow_cache_key_equal);
-
- return factory;
}
-void
-meta_shadow_factory_free (MetaShadowFactory *factory)
+static void
+meta_shadow_factory_finalize (GObject *object)
{
+ MetaShadowFactory *factory = META_SHADOW_FACTORY (object);
GHashTableIter iter;
gpointer key, value;
/* Detach from the shadows in the table so we won't try to
- * remove them when they freed. */
+ * remove them when they're freed. */
g_hash_table_iter_init (&iter, factory->shadows);
while (g_hash_table_iter_next (&iter, &key, &value))
{
@@ -283,7 +287,21 @@ meta_shadow_factory_free (MetaShadowFactory *factory)
g_hash_table_destroy (factory->shadows);
- g_slice_free (MetaShadowFactory, factory);
+ G_OBJECT_CLASS (meta_shadow_factory_parent_class)->finalize (object);
+}
+
+static void
+meta_shadow_factory_class_init (MetaShadowFactoryClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = meta_shadow_factory_finalize;
+}
+
+MetaShadowFactory *
+meta_shadow_factory_new (void)
+{
+ return g_object_new (META_TYPE_SHADOW_FACTORY, NULL);
}
MetaShadowFactory *
@@ -672,6 +690,9 @@ meta_shadow_factory_get_shadow (MetaShadowFactory *factory,
gboolean cacheable;
int center_width, center_height;
+ g_return_val_if_fail (META_IS_SHADOW_FACTORY (factory), NULL);
+ g_return_val_if_fail (shape != NULL, NULL);
+
/* Using a single shadow texture for different window sizes only works
* when there is a central scaled area that is greater than twice
* the spread of the gaussian blur we are applying to get to the
diff --git a/src/compositor/meta-shadow-factory.h b/src/compositor/meta-shadow-factory.h
index 8c2c33651..8dc9e958d 100644
--- a/src/compositor/meta-shadow-factory.h
+++ b/src/compositor/meta-shadow-factory.h
@@ -28,6 +28,13 @@
#include <clutter/clutter.h>
#include "meta-window-shape.h"
+#define META_TYPE_SHADOW_FACTORY (meta_shadow_factory_get_type ())
+#define META_SHADOW_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_SHADOW_FACTORY, MetaShadowFactory))
+#define META_SHADOW_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_SHADOW_FACTORY, MetaShadowFactoryClass))
+#define META_IS_SHADOW_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_SHADOW_FACTORY))
+#define META_IS_SHADOW_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_SHADOW_FACTORY))
+#define META_SHADOW_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_SHADOW_FACTORY, MetaShadowFactoryClass))
+
/**
* MetaShadow:
* #MetaShadow holds a shadow texture along with information about how to
@@ -58,12 +65,14 @@ void meta_shadow_get_bounds (MetaShadow *shadow,
* so that multiple shadows created for the same shape with the same radius will
* share the same MetaShadow.
*/
-typedef struct _MetaShadowFactory MetaShadowFactory;
+typedef struct _MetaShadowFactory MetaShadowFactory;
+typedef struct _MetaShadowFactoryClass MetaShadowFactoryClass;
MetaShadowFactory *meta_shadow_factory_get_default (void);
+GType meta_shadow_factory_get_type (void);
+
MetaShadowFactory *meta_shadow_factory_new (void);
-void meta_shadow_factory_free (MetaShadowFactory *factory);
MetaShadow * meta_shadow_factory_get_shadow (MetaShadowFactory *factory,
MetaWindowShape *shape,
int width,