summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberts Muktupāvels <alberts.muktupavels@gmail.com>2020-09-13 11:31:58 +0300
committerAlberts Muktupāvels <alberts.muktupavels@gmail.com>2020-09-13 11:31:58 +0300
commitb9ca97f9fe9b55a1ba312e17e242d5a1345c4b86 (patch)
tree8346bd928077646f6e94be471e47120df61f2130
parentbbf6760f9eab421bd558cbb45872ceafa033b21c (diff)
downloadmetacity-b9ca97f9fe9b55a1ba312e17e242d5a1345c4b86.tar.gz
main: use enumeration type to find value
-rw-r--r--src/Makefile.am1
-rw-r--r--src/core/main.c21
2 files changed, 13 insertions, 9 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 4f703eb3..f86af600 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -200,6 +200,7 @@ testasyncgetprop_CFLAGS = \
ENUM_TYPES = \
$(srcdir)/core/window-private.h \
+ $(srcdir)/include/meta-compositor.h \
$(NULL)
core/meta-enum-types.c: core/meta-enum-types.c.in $(ENUM_TYPES) Makefile.am
diff --git a/src/core/main.c b/src/core/main.c
index 5b62b461..038398ed 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -47,6 +47,7 @@
#include "util.h"
#include "display-private.h"
#include "errors.h"
+#include "meta-enum-types.h"
#include "ui.h"
#include "session.h"
#include "prefs.h"
@@ -224,19 +225,18 @@ option_compositior_cb (const char *option_name,
GError **error)
{
MetaArguments *args;
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
args = data;
- if (g_strcmp0 (value, "none") == 0)
- {
- args->compositor = META_COMPOSITOR_TYPE_NONE;
- }
- else if (g_strcmp0 (value, "xrender") == 0)
- {
- args->compositor = META_COMPOSITOR_TYPE_XRENDER;
- }
- else
+ enum_class = g_type_class_ref (META_TYPE_COMPOSITOR_TYPE);
+ enum_value = g_enum_get_value_by_nick (enum_class, value);
+
+ if (enum_value == NULL)
{
+ g_type_class_unref (enum_class);
+
g_set_error (error,
G_OPTION_ERROR,
G_OPTION_ERROR_FAILED,
@@ -246,8 +246,11 @@ option_compositior_cb (const char *option_name,
return FALSE;
}
+ args->compositor = enum_value->value;
args->compositor_set = TRUE;
+ g_type_class_unref (enum_class);
+
return TRUE;
}