[mutter] context/test: Make type derivable
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] context/test: Make type derivable
- Date: Thu, 15 Jul 2021 12:40:56 +0000 (UTC)
commit 3d5a2b2ffbcaf121265492c5d8cdbf2f55de4ed9
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Mon May 10 09:15:02 2021 +0200
context/test: Make type derivable
This makes it possible to declare the type in an installed header (so
that e.g. META_CONTEXT_TEST(context) works), but without having to
expose the MetaContextClass struct.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
src/tests/meta-context-test.c | 31 ++++++++++++++++++++++---------
src/tests/meta-context-test.h | 8 ++++----
2 files changed, 26 insertions(+), 13 deletions(-)
---
diff --git a/src/tests/meta-context-test.c b/src/tests/meta-context-test.c
index 5e99322a91..0de4d39030 100644
--- a/src/tests/meta-context-test.c
+++ b/src/tests/meta-context-test.c
@@ -25,6 +25,7 @@
#include <glib.h>
#include <gio/gio.h>
+#include "core/meta-context-private.h"
#include "tests/meta-backend-test.h"
#include "tests/meta-test-utils.h"
#include "wayland/meta-wayland.h"
@@ -44,15 +45,19 @@ enum
static guint signals[N_SIGNALS];
-struct _MetaContextTest
+typedef struct _MetaContextTestPrivate
{
- GObject parent;
-
MetaContextTestType type;
MetaContextTestFlag flags;
+} MetaContextTestPrivate;
+
+struct _MetaContextTestClass
+{
+ MetaContextClass parent_class;
};
-G_DEFINE_TYPE (MetaContextTest, meta_context_test, META_TYPE_CONTEXT)
+G_DEFINE_TYPE_WITH_PRIVATE (MetaContextTest, meta_context_test,
+ META_TYPE_CONTEXT)
static gboolean
meta_context_test_configure (MetaContext *context,
@@ -61,6 +66,8 @@ meta_context_test_configure (MetaContext *context,
GError **error)
{
MetaContextTest *context_test = META_CONTEXT_TEST (context);
+ MetaContextTestPrivate *priv =
+ meta_context_test_get_instance_private (context_test);
MetaContextClass *context_class =
META_CONTEXT_CLASS (meta_context_test_parent_class);
const char *plugin_name;
@@ -71,7 +78,7 @@ meta_context_test_configure (MetaContext *context,
g_test_init (argc, argv, NULL);
g_test_bug_base ("https://gitlab.gnome.org/GNOME/mutter/issues/");
- if (context_test->flags & META_CONTEXT_TEST_FLAG_TEST_CLIENT)
+ if (priv->flags & META_CONTEXT_TEST_FLAG_TEST_CLIENT)
meta_ensure_test_client_path (*argc, *argv);
meta_wayland_override_display_name ("mutter-test-display");
@@ -95,8 +102,10 @@ static MetaX11DisplayPolicy
meta_context_test_get_x11_display_policy (MetaContext *context)
{
MetaContextTest *context_test = META_CONTEXT_TEST (context);
+ MetaContextTestPrivate *priv =
+ meta_context_test_get_instance_private (context_test);
- if (context_test->flags & META_CONTEXT_TEST_FLAG_NO_X11)
+ if (priv->flags & META_CONTEXT_TEST_FLAG_NO_X11)
return META_X11_DISPLAY_POLICY_DISABLED;
else
return META_X11_DISPLAY_POLICY_ON_DEMAND;
@@ -159,8 +168,10 @@ meta_context_test_create_backend (MetaContext *context,
GError **error)
{
MetaContextTest *context_test = META_CONTEXT_TEST (context);
+ MetaContextTestPrivate *priv =
+ meta_context_test_get_instance_private (context_test);
- switch (context_test->type)
+ switch (priv->type)
{
case META_CONTEXT_TEST_TYPE_NESTED:
return create_nested_backend (context, error);
@@ -250,12 +261,14 @@ meta_create_test_context (MetaContextTestType type,
MetaContextTestFlag flags)
{
MetaContextTest *context_test;
+ MetaContextTestPrivate *priv;
context_test = g_object_new (META_TYPE_CONTEXT_TEST,
"name", "Mutter Test",
NULL);
- context_test->type = type;
- context_test->flags = flags;
+ priv = meta_context_test_get_instance_private (context_test);
+ priv->type = type;
+ priv->flags = flags;
return META_CONTEXT (context_test);
}
diff --git a/src/tests/meta-context-test.h b/src/tests/meta-context-test.h
index 187ea85dcc..f5d18445e1 100644
--- a/src/tests/meta-context-test.h
+++ b/src/tests/meta-context-test.h
@@ -21,7 +21,7 @@
#ifndef META_CONTEXT_TEST_H
#define META_CONTEXT_TEST_H
-#include "core/meta-context-private.h"
+#include "meta/meta-context.h"
typedef enum _MetaContextTestType
{
@@ -39,9 +39,9 @@ typedef enum _MetaContextTestFlag
} MetaContextTestFlag;
#define META_TYPE_CONTEXT_TEST (meta_context_test_get_type ())
-G_DECLARE_FINAL_TYPE (MetaContextTest, meta_context_test,
- META, CONTEXT_TEST,
- MetaContext)
+G_DECLARE_DERIVABLE_TYPE (MetaContextTest, meta_context_test,
+ META, CONTEXT_TEST,
+ MetaContext)
MetaContext * meta_create_test_context (MetaContextTestType type,
MetaContextTestFlag flags);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]