summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-09-24 11:56:24 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2013-09-24 11:56:24 +0200
commit79305f45e742282dff3fd987a10a379bf686aa78 (patch)
tree5ad8c41e7f2e1ab53aee9be35ceae2abdc61d15e
parent03e4c3b99dccb44a7ea2666f51c7c341d273a97d (diff)
app: add elm_skel_app
-rw-r--r--app/src/Makefile_lib.am7
-rw-r--r--app/src/bin/main.c20
-rw-r--r--app/src/lib/elm_skel_app.c66
-rw-r--r--app/src/lib/elm_skel_app.h10
4 files changed, 99 insertions, 4 deletions
diff --git a/app/src/Makefile_lib.am b/app/src/Makefile_lib.am
index d6a3a28..cbe38af 100644
--- a/app/src/Makefile_lib.am
+++ b/app/src/Makefile_lib.am
@@ -1,12 +1,15 @@
1### Libraries 1### Libraries
2 2
3includes_HEADERS = lib/elm_skel.h
4includesdir = $(includedir)/elm_skel-@VMAJ@ 3includesdir = $(includedir)/elm_skel-@VMAJ@
4includes_HEADERS = \
5 lib/elm_skel.h \
6 lib/elm_skel_app.h
5 7
6lib_LTLIBRARIES += lib/libelm_skel.la 8lib_LTLIBRARIES += lib/libelm_skel.la
7 9
8lib_libelm_skel_la_SOURCES = \ 10lib_libelm_skel_la_SOURCES = \
9 lib/elm_skel.c 11 lib/elm_skel.c \
12 lib/elm_skel_app.c
10 13
11lib_libelm_skel_la_LIBADD = @ELM_SKEL_LIBS@ @ELM_SKEL_COV_LIBS@ 14lib_libelm_skel_la_LIBADD = @ELM_SKEL_LIBS@ @ELM_SKEL_COV_LIBS@
12lib_libelm_skel_la_CFLAGS = 15lib_libelm_skel_la_CFLAGS =
diff --git a/app/src/bin/main.c b/app/src/bin/main.c
index cedd3dd..7fd37ce 100644
--- a/app/src/bin/main.c
+++ b/app/src/bin/main.c
@@ -3,6 +3,7 @@
3#endif /* HAVE_CONFIG_H */ 3#endif /* HAVE_CONFIG_H */
4 4
5#include "elm_skel.h" 5#include "elm_skel.h"
6#include "elm_skel_app.h"
6#include <Ecore_Getopt.h> 7#include <Ecore_Getopt.h>
7 8
8#undef EINA_LOG_DOMAIN_DEFAULT 9#undef EINA_LOG_DOMAIN_DEFAULT
@@ -44,13 +45,14 @@ static const Ecore_Getopt options =
44EAPI_MAIN int 45EAPI_MAIN int
45elm_main(int argc, char *argv[]) 46elm_main(int argc, char *argv[])
46{ 47{
48 Evas_Object *app;
47 49
48 Eina_Bool exit = EINA_FALSE; 50 Eina_Bool exit = EINA_FALSE;
49 int args; 51 int args;
50 char *engine = NULL; 52 char *engine = NULL;
51 int verbosity = 0; 53 int verbosity = 0;
52 Eina_Bool fullscreen = EINA_FALSE; 54 Eina_Bool fullscreen = EINA_FALSE;
53 Eina_Rectangle geometry = {-1, -1, -1, -1}; 55 Eina_Rectangle geometry = {600, 300, 200, 50};
54 int eina_log_level = EINA_LOG_LEVEL_WARN; 56 int eina_log_level = EINA_LOG_LEVEL_WARN;
55 57
56 Ecore_Getopt_Value values[] = 58 Ecore_Getopt_Value values[] =
@@ -98,7 +100,21 @@ elm_main(int argc, char *argv[])
98 elm_app_bin_dir_get(), 100 elm_app_bin_dir_get(),
99 elm_app_lib_dir_get(), 101 elm_app_lib_dir_get(),
100 elm_app_data_dir_get()); 102 elm_app_data_dir_get());
101 EINA_LOG_ERR("says: %s", elm_skel_hello()); 103
104 app = elm_skel_app();
105
106 // set position and size according to parameters
107 evas_object_show(app);
108 if(fullscreen) {
109 elm_win_fullscreen_set(app, EINA_TRUE);
110 }
111 else {
112 evas_object_resize(app, geometry.w, geometry.h);
113 evas_object_move(app, geometry.x, geometry.y);
114 }
115
116 elm_run();
117 elm_shutdown();
102 118
103 return EXIT_SUCCESS; 119 return EXIT_SUCCESS;
104} 120}
diff --git a/app/src/lib/elm_skel_app.c b/app/src/lib/elm_skel_app.c
new file mode 100644
index 0000000..b3ae4e7
--- /dev/null
+++ b/app/src/lib/elm_skel_app.c
@@ -0,0 +1,66 @@
1#include "elm_skel_app.h"
2#include "elm_skel.h"
3
4static Eina_Bool sigint_handler(void *data EINA_UNUSED,
5 int ev_type EINA_UNUSED,
6 void *ev EINA_UNUSED)
7{
8 EINA_LOG_ERR("Ctrl-C hit");
9 elm_exit();
10 return EINA_TRUE;
11}
12
13static void
14on_del(void *data EINA_UNUSED,
15 Evas_Object *obj EINA_UNUSED,
16 void *event_info EINA_UNUSED)
17{
18 EINA_LOG_INFO("delete,request");
19 elm_exit();
20}
21
22static void
23on_click(void *data EINA_UNUSED,
24 Evas_Object *obj EINA_UNUSED,
25 void *event_info EINA_UNUSED)
26{
27 EINA_LOG_INFO("clicked");
28 elm_exit();
29}
30
31EAPI Evas_Object*
32elm_skel_app()
33{
34 ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, sigint_handler, NULL);
35
36 Evas_Object *win, *box, *lab, *btn;
37
38 win = elm_win_util_standard_add("hello", elm_skel_hello());
39 evas_object_smart_callback_add(win, "delete,request", on_del, NULL);
40
41 // add a vertical box as a resize object for the window
42 // (controls window minimum size and gets resized if window is resized)
43 box = elm_box_add(win);
44 elm_box_horizontal_set(box, EINA_TRUE);
45 elm_win_resize_object_add(win, box);
46 evas_object_show(box);
47
48 // add a label widget, set the text
49 // pack it at the end of the box
50 lab = elm_label_add(win);
51 elm_object_text_set(lab, "Label");
52 elm_box_pack_end(box, lab);
53 evas_object_show(lab);
54
55 // add a button widget, set the text
56 // pack it at the end of the box
57 // call on_click when it is clicked
58 btn = elm_button_add(win);
59 elm_object_text_set(btn, "OK");
60 elm_box_pack_end(box, btn);
61 evas_object_show(btn);
62 evas_object_smart_callback_add(btn, "clicked", on_click, NULL);
63 elm_object_focus_set(btn, EINA_TRUE);
64
65 return win;
66}
diff --git a/app/src/lib/elm_skel_app.h b/app/src/lib/elm_skel_app.h
new file mode 100644
index 0000000..cffd40b
--- /dev/null
+++ b/app/src/lib/elm_skel_app.h
@@ -0,0 +1,10 @@
1#ifndef ELM_SKEL_APP_H
2#define ELM_SKEL_APP_H
3
4#include <Elementary.h>
5#include <config.h>
6
7EAPI Evas_Object*
8elm_skel_app();
9
10#endif /* ELM_SKEL_APP_H */