summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk-test/.gitignore4
-rw-r--r--gtk-test/Clean.h43
-rw-r--r--gtk-test/Makefile10
-rw-r--r--gtk-test/helloworld.c45
-rw-r--r--gtk-test/helloworld.h11
-rwxr-xr-xgtk-test/helloworld_testbin0 -> 105712 bytes
-rw-r--r--gtk-test/helloworld_test.icl9
7 files changed, 122 insertions, 0 deletions
diff --git a/gtk-test/.gitignore b/gtk-test/.gitignore
new file mode 100644
index 0000000..c906672
--- /dev/null
+++ b/gtk-test/.gitignore
@@ -0,0 +1,4 @@
+Clean System Files
+*.o
+helloworld.dcl
+helloworld.icl
diff --git a/gtk-test/Clean.h b/gtk-test/Clean.h
new file mode 100644
index 0000000..7429934
--- /dev/null
+++ b/gtk-test/Clean.h
@@ -0,0 +1,43 @@
+
+#define Clean(a)
+
+typedef struct clean_string *CleanString;
+
+/* a string in Clean is:
+ struct clean_string {
+ int clean_string_length;
+ char clean_string_characters[clean_string_length];
+ };
+ The string does not end with a '\0' !
+*/
+
+/* CleanStringLength(clean_string) returns the length of the clean_string in characters */
+#define CleanStringLength(clean_string) (*(unsigned int *)(clean_string))
+
+/* CleanStringCharacters(clean_string) returns a pointer to the characters of the clean_string */
+#define CleanStringCharacters(clean_string) ((char*)(1+(unsigned int *)(clean_string)))
+
+/* CleanStringSizeInts(string_length) return size of *CleanString in integers */
+#define CleanStringSizeInts(string_length) (1+(((unsigned int)(string_length)+3)>>2))
+
+/* CleanStringVariable(clean_string,string_length) defines variable clean_string with length string_length,
+ before using the clean_string variable, cast to CleanString, except for the macros above */
+#define CleanStringVariable(clean_string,string_length) unsigned int clean_string[CleanStringSizeInts(string_length)]
+
+/* CleanStringSizeBytes(string_length) return size of *CleanString in bytes */
+#define CleanStringSizeBytes(string_length) (4+(((unsigned int)(string_length)+3) & -4))
+
+typedef int *CleanIntArray;
+
+/* CleanIntArraySize(clean_array) returns the size (number of elements) of the clean_int_array */
+#define CleanIntArraySize(clean_int_array) (((unsigned int *)(clean_int_array))[-2])
+
+typedef double *CleanRealArray;
+
+/* CleanRealArraySize(clean_real_array) returns the size (number of elements) of the clean_real_array */
+#define CleanRealArraySize(clean_real_array) (((unsigned int *)(clean_real_array))[-2])
+
+typedef unsigned char *CleanCharArray;
+
+/* CleanCharArraySize(clean_char_array) returns the size (number of elements) of the clean_char_array */
+#define CleanCharArraySize(clean_char_array) (((unsigned int *)(clean_char_array))[-1])
diff --git a/gtk-test/Makefile b/gtk-test/Makefile
new file mode 100644
index 0000000..703facc
--- /dev/null
+++ b/gtk-test/Makefile
@@ -0,0 +1,10 @@
+SHELL=/bin/bash
+
+all:
+ htoclean helloworld.h
+ cc -O -c helloworld.c `pkg-config --cflags --libs gtk+-3.0`
+ libs=""; for l in $$(pkg-config --libs gtk+-3.0); do libs="$$libs -l $$l"; done ; \
+ clm $$libs -l -lglib-2.0 -l helloworld.o helloworld_test -o helloworld_test
+
+run:
+ ./helloworld_test
diff --git a/gtk-test/helloworld.c b/gtk-test/helloworld.c
new file mode 100644
index 0000000..968c16f
--- /dev/null
+++ b/gtk-test/helloworld.c
@@ -0,0 +1,45 @@
+#include "Clean.h"
+#include "helloworld.h"
+#include <gtk/gtk.h>
+
+static void hello(GtkWidget *widget, gpointer data) {
+ g_print("Hello world\n");
+}
+
+static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) {
+ g_print("Delete event\n");
+ return TRUE;
+}
+
+static void destroy(GtkWidget *widget, gpointer data) {
+ gtk_main_quit();
+}
+
+void ginit() {
+ gtk_init(NULL, NULL);
+}
+
+void gopen() {
+ GtkWidget *window;
+ GtkWidget *button;
+
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+
+ g_signal_connect(window, "delete-event", G_CALLBACK(delete_event), NULL);
+ g_signal_connect(window, "destroy", G_CALLBACK(destroy), NULL);
+
+ gtk_container_set_border_width(GTK_CONTAINER(window), 10);
+
+ button = gtk_button_new_with_label("Hello world");
+
+ g_signal_connect(button, "clicked", G_CALLBACK(hello), NULL);
+ g_signal_connect_swapped(button, "clicked", G_CALLBACK(gtk_widget_destroy), window);
+
+ gtk_container_add(GTK_CONTAINER(window), button);
+
+ gtk_widget_show(button);
+ gtk_widget_show(window);
+
+ gtk_main();
+}
+
diff --git a/gtk-test/helloworld.h b/gtk-test/helloworld.h
new file mode 100644
index 0000000..aee75bf
--- /dev/null
+++ b/gtk-test/helloworld.h
@@ -0,0 +1,11 @@
+Clean(
+ :: *State :== Int;
+ :: IntPointer :== Int
+)
+
+void ginit();
+Clean(ginit :: State -> State)
+
+void gopen();
+Clean(gopen :: State -> State)
+
diff --git a/gtk-test/helloworld_test b/gtk-test/helloworld_test
new file mode 100755
index 0000000..7972603
--- /dev/null
+++ b/gtk-test/helloworld_test
Binary files differ
diff --git a/gtk-test/helloworld_test.icl b/gtk-test/helloworld_test.icl
new file mode 100644
index 0000000..3d1461e
--- /dev/null
+++ b/gtk-test/helloworld_test.icl
@@ -0,0 +1,9 @@
+module helloworld_test
+
+import StdEnv, helloworld
+
+Start
+# state = 0
+# state = ginit state
+# state = gopen state
+= state