[PATCH weston 4/7] desktop-shell/client: Use a proper enum for clock format

Quentin Glidic sardemff7+wayland at sardemff7.net
Thu Jun 23 16:55:21 UTC 2016


From: Quentin Glidic <sardemff7+git at sardemff7.net>

Signed-off-by: Quentin Glidic <sardemff7+git at sardemff7.net>
---
 clients/desktop-shell.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index 2c215e1..89c3277 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -40,6 +40,7 @@
 #include <libgen.h>
 #include <ctype.h>
 #include <time.h>
+#include <assert.h>
 
 #include <wayland-client.h>
 #include "window.h"
@@ -55,6 +56,12 @@
 
 extern char **environ; /* defined by libc */
 
+enum clock_format {
+	CLOCK_FORMAT_MINUTES,
+	CLOCK_FORMAT_SECONDS,
+	CLOCK_FORMAT_NONE
+};
+
 struct desktop {
 	struct display *display;
 	struct weston_desktop_shell *shell;
@@ -90,7 +97,7 @@ struct panel {
 	struct wl_list launcher_list;
 	struct panel_clock *clock;
 	int painted;
-	int clock_format;
+	enum clock_format clock_format;
 	uint32_t color;
 };
 
@@ -417,12 +424,6 @@ panel_destroy_clock(struct panel_clock *clock)
 	free(clock);
 }
 
-enum {
-	CLOCK_FORMAT_MINUTES,
-	CLOCK_FORMAT_SECONDS,
-	CLOCK_FORMAT_NONE
-};
-
 static void
 panel_add_clock(struct panel *panel)
 {
@@ -449,6 +450,8 @@ panel_add_clock(struct panel *panel)
 		clock->format_string = "%a %b %d, %I:%M:%S %p";
 		clock->refresh_timer = 1;
 		break;
+	case CLOCK_FORMAT_NONE:
+		assert(!"not reached");
 	}
 
 	clock->clock_task.run = clock_func;
-- 
2.9.0



More information about the wayland-devel mailing list