diff options
author | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2020-09-13 11:31:58 +0300 |
---|---|---|
committer | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2020-09-13 11:31:58 +0300 |
commit | b9ca97f9fe9b55a1ba312e17e242d5a1345c4b86 (patch) | |
tree | 8346bd928077646f6e94be471e47120df61f2130 /src | |
parent | bbf6760f9eab421bd558cbb45872ceafa033b21c (diff) | |
download | metacity-b9ca97f9fe9b55a1ba312e17e242d5a1345c4b86.tar.gz |
main: use enumeration type to find value
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/core/main.c | 21 |
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; } |