[gnome-control-center] datetime: Add test application for date endianess



commit 968b3adbe51558a2f6ffad867da866b9e550a293
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Mar 8 07:58:52 2011 +0000

    datetime: Add test application for date endianess

 panels/datetime/Makefile.am      |    9 +++++-
 panels/datetime/test-endianess.c |   49 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 2 deletions(-)
---
diff --git a/panels/datetime/Makefile.am b/panels/datetime/Makefile.am
index 1d48bae..4384a28 100644
--- a/panels/datetime/Makefile.am
+++ b/panels/datetime/Makefile.am
@@ -72,17 +72,22 @@ AM_CPPFLAGS =						\
 	-DDATADIR="\"$(uidir)\""			\
 	$(NULL)
 
-noinst_PROGRAMS = test-timezone
+noinst_PROGRAMS = test-timezone test-endianess
 
 test_timezone_SOURCES = test-timezone.c tz.c tz.h
 test_timezone_LDADD = $(DATETIME_PANEL_LIBS)
 test_timezone_CFLAGS = $(DATETIME_PANEL_CFLAGS)
 
+test_endianess_SOURCES = test-endianess.c date-endian.c date-endian.h
+test_endianess_LDADD = $(DATETIME_PANEL_LIBS)
+test_endianess_CFLAGS = $(DATETIME_PANEL_CFLAGS)
+
 all-local: check-local
 
 # FIXME remove "|| :" when we have all the necessary pixmaps
-check-local: test-timezone
+check-local: test-timezone test-endianess
 	$(builddir)/test-timezone $(srcdir)/data || :
+	$(builddir)/test-endianess
 
 ccpanelsdir = $(PANELS_DIR)
 ccpanels_LTLIBRARIES = libdate_time.la
diff --git a/panels/datetime/test-endianess.c b/panels/datetime/test-endianess.c
new file mode 100644
index 0000000..1086732
--- /dev/null
+++ b/panels/datetime/test-endianess.c
@@ -0,0 +1,49 @@
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <locale.h>
+#include "date-endian.h"
+
+static int verbose = 0;
+
+static void
+print_endianess (const char *lang)
+{
+	DateEndianess endianess;
+
+	if (lang != NULL) {
+		setlocale (LC_TIME, lang);
+		endianess = date_endian_get_for_lang (lang, verbose);
+	} else {
+		endianess = date_endian_get_default (verbose);
+	}
+	if (verbose)
+		g_print ("\t\t%s\n", date_endian_to_string (endianess));
+}
+
+int main (int argc, char **argv)
+{
+	GDir *dir;
+	const char *name;
+
+	setlocale (LC_ALL, "");
+	bind_textdomain_codeset ("libc", "UTF-8");
+
+	if (argv[1] != NULL) {
+		verbose = 1;
+
+		if (g_str_equal (argv[1], "-c"))
+			print_endianess (NULL);
+		else
+			print_endianess (argv[1]);
+		return 0;
+	}
+
+	dir = g_dir_open ("/usr/share/i18n/locales/", 0, NULL);
+	if (dir == NULL)
+		return 1;
+
+	while ((name = g_dir_read_name (dir)) != NULL)
+		print_endianess (name);
+
+	return 0;
+}



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