From 9bd4a7f9bbb8c678e04ded5e940c4681f63b571c Mon Sep 17 00:00:00 2001 From: Laurent Ghigonis Date: Sat, 21 Jul 2012 21:41:11 +0200 Subject: add a basic glouglou_efl program that opens a graphical window and connects to 127.0.0.1 port 4430 UDP --- glouglou_efl/Makefile | 20 +++++++++++++ glouglou_efl/glouglou_efl.c | 71 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 glouglou_efl/Makefile create mode 100644 glouglou_efl/glouglou_efl.c (limited to 'glouglou_efl') diff --git a/glouglou_efl/Makefile b/glouglou_efl/Makefile new file mode 100644 index 0000000..8f8617c --- /dev/null +++ b/glouglou_efl/Makefile @@ -0,0 +1,20 @@ +CFLAGS += $(shell pkg-config --cflags elementary evas ecore) +LIBS += $(shell pkg-config --libs elementary evas ecore) +CFLAGS += -Wall -O2 + +BINARY=glouglou_efl + +PREFIX=/usr/local +BINDIR=$(PREFIX)/bin + +$(BINARY): $(BINARY).o + $(CC) -o $@ $< $(LIBS) + +install: $(BINARY) + @echo "installation of $(BINARY)" + mkdir -p $(BINDIR) + install -m 0755 $(BINARY) $(BINDIR) + +clean: + rm -f $(BINARY) $(BINARY).o + diff --git a/glouglou_efl/glouglou_efl.c b/glouglou_efl/glouglou_efl.c new file mode 100644 index 0000000..d4d592a --- /dev/null +++ b/glouglou_efl/glouglou_efl.c @@ -0,0 +1,71 @@ +#include + +#include + +static Eina_Bool +_cb_conn_data(void *data, int type, Ecore_Con_Event_Server_Data *ev) +{ + char fmt[128]; + + snprintf(fmt, sizeof(fmt), + "connection received %i bytes from server:\n" + "========\n" + "%%.%is\n" + "========\n", + ev->size, ev->size); + + printf(fmt, ev->data); + + return ECORE_CALLBACK_RENEW; +} + +static void +on_done(void *data, Evas_Object *obj, void *event_info) +{ + // quit the mainloop (elm_run function will return) + elm_exit(); +} + +EAPI_MAIN int +elm_main(int argc, char **argv) +{ + Evas_Object *win, *box, *lab, *btn, *bg; + Ecore_Con_Server *conn; + + win = elm_win_util_standard_add("hello", "Hello"); + evas_object_smart_callback_add(win, "delete,request", on_done, NULL); + + bg = elm_bg_add(win); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(win, bg); + evas_object_show(bg); + + box = elm_box_add(win); + elm_box_horizontal_set(box, EINA_TRUE); + elm_win_resize_object_add(win, box); + evas_object_show(box); + + lab = elm_label_add(win); + elm_object_text_set(lab, "Welcome to glouglou_efl"); + elm_box_pack_end(box, lab); + evas_object_show(lab); + + btn = elm_button_add(win); + elm_object_text_set(btn, "OK"); + elm_box_pack_end(box, btn); + evas_object_show(btn); + evas_object_smart_callback_add(btn, "clicked", on_done, NULL); + + evas_object_show(win); + + ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, + (Ecore_Event_Handler_Cb)_cb_conn_data, NULL); + conn = ecore_con_server_connect(ECORE_CON_REMOTE_UDP, "127.0.0.1", 4430, NULL); + ecore_con_server_send(conn, "hello", 5); + ecore_con_server_flush(conn); + + elm_run(); + elm_shutdown(); + return 0; +} +ELM_MAIN() -- cgit v1.2.3-59-g8ed1b