Commits

Jeff Sparkes  committed 1ccda2a

Map event types to names.

* device-gtk.c (gtk_event_name): Get event names by
stringification of type constants.

  • Participants
  • Parent commits 53c005c

Comments (0)

Files changed (2)

File src/ChangeLog.GTK

+2012-05-17  Jeff Sparkes  <jsparkes@gmail.com>
+
+	* device-gtk.c (gtk_event_name): Get event names by
+	stringification of constants.
+
 2012-05-16  Jeff Sparkes  <jsparkes@gmail.com>
 
 	* redisplay-xlike-inc.c (XLIKE_clear_frame_windows): Accidentally

File src/device-gtk.c

 const char *
 gtk_event_name (GdkEventType event_type)
 {
-  //GtkEnumValue *vals = gtk_type_enum_get_values (GTK_TYPE_GDK_EVENT_TYPE);
 
-  //while (vals && ((GdkEventType)(vals->value) != event_type)) vals++;
+#define GET_EVENT_NAME(ev) case ev: return #ev;
 
-  //if (vals)
-  //return (vals->value_nick);
-
-  //return (NULL);
-  return "GdkEvent";
+  switch (event_type)
+  {
+    GET_EVENT_NAME (GDK_NOTHING);
+    GET_EVENT_NAME (GDK_DELETE);
+    GET_EVENT_NAME (GDK_DESTROY);
+    GET_EVENT_NAME (GDK_EXPOSE);
+    GET_EVENT_NAME (GDK_MOTION_NOTIFY);
+    GET_EVENT_NAME (GDK_BUTTON_PRESS);
+    GET_EVENT_NAME (GDK_2BUTTON_PRESS);
+    GET_EVENT_NAME (GDK_3BUTTON_PRESS);
+    GET_EVENT_NAME (GDK_BUTTON_RELEASE);
+    GET_EVENT_NAME (GDK_KEY_PRESS);
+    GET_EVENT_NAME (GDK_KEY_RELEASE);
+    GET_EVENT_NAME (GDK_ENTER_NOTIFY);
+    GET_EVENT_NAME (GDK_LEAVE_NOTIFY);
+    GET_EVENT_NAME (GDK_FOCUS_CHANGE);
+    GET_EVENT_NAME (GDK_CONFIGURE);
+    GET_EVENT_NAME (GDK_MAP);
+    GET_EVENT_NAME (GDK_UNMAP);
+    GET_EVENT_NAME (GDK_PROPERTY_NOTIFY);
+    GET_EVENT_NAME (GDK_SELECTION_CLEAR);
+    GET_EVENT_NAME (GDK_SELECTION_REQUEST);
+    GET_EVENT_NAME (GDK_SELECTION_NOTIFY);
+    GET_EVENT_NAME (GDK_PROXIMITY_IN);
+    GET_EVENT_NAME (GDK_PROXIMITY_OUT);
+    GET_EVENT_NAME (GDK_DRAG_ENTER);
+    GET_EVENT_NAME (GDK_DRAG_LEAVE);
+    GET_EVENT_NAME (GDK_DRAG_MOTION);
+    GET_EVENT_NAME (GDK_DRAG_STATUS);
+    GET_EVENT_NAME (GDK_DROP_START);
+    GET_EVENT_NAME (GDK_DROP_FINISHED);
+    GET_EVENT_NAME (GDK_CLIENT_EVENT);
+    GET_EVENT_NAME (GDK_VISIBILITY_NOTIFY);
+    GET_EVENT_NAME (GDK_SCROLL);
+    GET_EVENT_NAME (GDK_WINDOW_STATE);
+    GET_EVENT_NAME (GDK_SETTING);
+    GET_EVENT_NAME (GDK_OWNER_CHANGE);
+    GET_EVENT_NAME (GDK_GRAB_BROKEN);
+    GET_EVENT_NAME (GDK_DAMAGE);
+  }
+#undef GET_EVENT_NAME
+  return "Unknown GdkEventType";
 }