[gnome-settings-daemon/wip/hadess/xsettings-enum: 6/6] xsettings: Simplify fetching string for an enum value




commit 4bd1b0175120097d1e4e69d4b5279bd534c4eb62
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Mar 30 18:41:56 2022 +0200

    xsettings: Simplify fetching string for an enum value

 plugins/xsettings/fc-monitor.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
---
diff --git a/plugins/xsettings/fc-monitor.c b/plugins/xsettings/fc-monitor.c
index 63e87125..cafc8bf5 100644
--- a/plugins/xsettings/fc-monitor.c
+++ b/plugins/xsettings/fc-monitor.c
@@ -187,17 +187,6 @@ monitor_files (FcMonitor *self,
         FcStrListDone (list);
 }
 
-static const gchar *
-get_name (GType enum_type,
-          gint enum_value)
-{
-        GEnumClass *klass = g_type_class_ref (enum_type);
-        GEnumValue *value = g_enum_get_value (klass, enum_value);
-        const gchar *name = value ? value->value_name : "(unknown)";
-        g_type_class_unref (klass);
-        return name;
-}
-
 static void
 stuff_changed (GFileMonitor *monitor G_GNUC_UNUSED,
                GFile *file G_GNUC_UNUSED,
@@ -206,7 +195,7 @@ stuff_changed (GFileMonitor *monitor G_GNUC_UNUSED,
                gpointer data)
 {
         FcMonitor *self = FC_MONITOR (data);
-        const gchar *event_name = get_name (G_TYPE_FILE_MONITOR_EVENT, event_type);
+        const gchar *event_name = g_enum_to_string (G_TYPE_FILE_MONITOR_EVENT, event_type);
 
         switch (self->state) {
         case UPDATE_IDLE:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]