summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlliver Schinagl <o.schinagl@ultimaker.com>2015-02-05 13:08:27 (GMT)
committerOlliver Schinagl <o.schinagl@ultimaker.com>2015-04-28 05:07:12 (GMT)
commit68624705cd11cbc28bfdf73e2b011cea1e1ca0d2 (patch)
treeaf229da541e2f86d57c5f6bc07bfd8c58321023e
parentfcc9a7cc3f0ca7e95085bfdc278e3736692730a4 (diff)
downloadeulogium-68624705cd11cbc28bfdf73e2b011cea1e1ca0d2.zip
eulogium-68624705cd11cbc28bfdf73e2b011cea1e1ca0d2.tar.gz
eulogium-68624705cd11cbc28bfdf73e2b011cea1e1ca0d2.tar.bz2
first try on going the elementary route
-rw-r--r--configure.ac6
-rw-r--r--src/eulogium.c202
2 files changed, 122 insertions, 86 deletions
diff --git a/configure.ac b/configure.ac
index 5598443..f651dad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,11 +30,11 @@ EFL_CHECK_PATH_MAX
# Check for EFL
PKG_CHECK_MODULES([EFL],
[
+ ecore >= 1.8.0
+ ecore-evas >= 1.8.0
eina >= 1.8.0
+ elementary >= 1.8.0
evas >= 1.8.0
- ecore-evas >= 1.8.0
- ecore >= 1.8.0
- edje >= 1.8.0
])
# Check for tests and coverage
diff --git a/src/eulogium.c b/src/eulogium.c
index cdfff46..2e621f8 100644
--- a/src/eulogium.c
+++ b/src/eulogium.c
@@ -2,11 +2,10 @@
# include "config.h"
#endif
-#include <Eina.h>
-#include <Ecore.h>
-#include <Ecore_Evas.h>
#include <Ecore_Getopt.h>
-#include <Edje.h>
+#include <Eina.h>
+#include <Elementary.h>
+#include <Evas.h>
#include <stdlib.h>
#include <string.h>
@@ -16,9 +15,82 @@
#define EULOGIUM_THEME "eulogium.edj"
-int main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
+
+static void _cb_eulogium_resize(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+ /* TODO */
+}
+
+static void _cb_eulogium_exit(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+ elm_exit();
+}
+
+static Evas_Object *eulogium_mainmenu_create(Evas_Object *window)
+{
+ Evas_Object *screen;
+ Evas_Object *bg;
+ Evas_Object *vert_box, *hor_box;
+ Evas_Object *but_print, *hspacer, *but_material, *vspacer, *but_maintanance;
+
+ screen = elm_box_add(window);
+
+ bg = elm_bg_add(window);
+ elm_bg_color_set(bg, 255, 0, 255);
+ evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_box_pack_end(screen, bg);
+ evas_object_show(bg);
+
+// vert_box = elm_box_add(window);
+// hor_box = elm_box_add(vert_box);
+
+// elm_box_horizontal_set(hor_box, EINA_TRUE);
+// elm_box_horizontal_set(vert_box, EINA_FALSE);
+
+// elm_object_add(window, vert_box);
+
+// evas_object_show(hor_box);
+// evas_object_show(vert_box);
+
+// but_print = elm_button_add(window);
+// elm_object_text_set(but_print, "PRINT");
+// elm_box_pack_end(hor_box, but_print);
+// evas_object_show(but_print);
+
+// vspacer = elm_separator_add(window);
+// elm_separator_horizontal_set(vspacer, EINA_FALSE);
+// elm_box_pack_end(hor_box, vspacer);
+// evas_object_show(vspacer);
+
+// but_material = elm_button_add(window);
+// elm_object_text_set(but_print, "MATERIAL");
+// elm_box_pack_end(hor_box, but_material);
+// evas_object_show(but_material);
+
+// hspacer = elm_separator_add(window);
+// elm_separator_horizontal_set(hspacer, EINA_TRUE);
+// elm_box_pack_end(vert_box, hspacer);
+// evas_object_show(hspacer);
+
+// but_maintanance = elm_button_add(window);
+// elm_object_text_set(but_maintanance, "MAINTANANCE");
+// elm_box_pack_end(vert_box, but_maintanance);
+// evas_object_show(but_maintanance);
+ evas_object_show(screen);
+
+ return screen;
+}
+
+static Evas_Object *eulogium_menu(Evas_Object *window)
+{
+ return eulogium_mainmenu_create(window);
+}
+
+EAPI_MAIN int elm_main(int argc, char **argv)
{
Eina_Bool quit_option = EINA_FALSE;
+ Evas_Object *content;
static const Ecore_Getopt optdesc = {
"eulogium",
"%prog [options]",
@@ -43,42 +115,8 @@ int main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
ECORE_GETOPT_VALUE_NONE
};
int args;
- Eina_Prefix *prefix;
- Ecore_Evas *window;
- Evas *canvas;
+ Evas_Object *splash_window, *window;
Eina_List *engines, *l;
- Evas_Object *edje;
- const char *eulogium_edj = EULOGIUM_THEME;
- const int eulogium_edj_size = sizeof(EULOGIUM_THEME);
- int prefix_size;
- char *theme_file;
- int theme_file_size;
- int height, width;
-
-#if ENABLE_NLS
- setlocale(LC_ALL, "");
- bindtextdomain(PACKAGE, LOCALE_DIR);
- bind_textdomain_codeset(PACKAGE, "UTF-8");
- textdomain(PACKAGE);
-#endif
-
- if (!eina_init())
- return EXIT_FAILURE;
-
- if (!ecore_evas_init())
- return EXIT_FAILURE;
-
- if (!edje_init())
- return EXIT_FAILURE;
-
- prefix = eina_prefix_new(argv[0], NULL,
- "EULOGIUM",
- "eulogium",
- eulogium_edj,
- PACKAGE_BIN_DIR,
- PACKAGE_LIB_DIR,
- PACKAGE_DATA_DIR,
- LOCALE_DIR);
args = ecore_getopt_parse(&optdesc, values, argc, argv);
if (args < 0) {
@@ -86,54 +124,52 @@ int main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
return EXIT_FAILURE;
}
- /* Initialize the window with fake dimensions, we'll set the proper dimensions via the theme */
- height = 0;
- width = 0;
-
- window = ecore_evas_new(NULL, 0, 0, height, width, NULL);
- canvas = ecore_evas_get(window);
- edje = edje_object_add(canvas);
- if (!edje) {
- EINA_LOG_CRIT("Could not create edje object!");
- return EXIT_FAILURE;
- }
-
- prefix_size = strlen(eina_prefix_data_get(prefix));
- theme_file_size = prefix_size + eulogium_edj_size + 1;
- theme_file = malloc(sizeof(char) * theme_file_size);
- eina_str_join_len(theme_file, theme_file_size, '/',
- eina_prefix_data_get(prefix), prefix_size, eulogium_edj, eulogium_edj_size);
- if (!edje_object_file_set(edje, theme_file, "mainscreen")) {
- int err = edje_object_load_error_get(edje);
- const char *errmsg = edje_load_error_str(err);
- EINA_LOG_ERR("Could not load 'mainscreen' from %s: %s (%d)", theme_file, errmsg, err);
-
- evas_object_del(edje);
- return EXIT_FAILURE;
- }
+ elm_policy_set(ELM_POLICY_QUIT, /* ELM_POLICY_QUIT_NONE */ ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
+ elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
+ elm_app_compile_lib_dir_set(PACKAGE_LIB_DIR);
+ elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
+#if HAVE_GETTEXT && ENABLE_NLS
+ elm_app_compile_locale_set(LOCALE_DIR);
+#endif
+#if ENABLE_NLS /* TODO Check for removal */
+// setlocale(LC_ALL, "");
+// bindtextdomain(PACKAGE, LOCALE_DIR);
+// bind_textdomain_codeset(PACKAGE, "UTF-8");
+// textdomain(PACKAGE);
+#endif
+ elm_app_info_set(NULL, PACKAGE, NULL); /* TODO */
+#if (ELM_VERSION_MAJOR > 1) || (ELM_VERSION_MINOR >= 10)
+ elm_config_accel_preference_set("accel");
+#endif
+#if 0 /* TODO */
+ icon = evas_object_image_add(evas_object_evas_get(win));
+ snprintf(buf, sizeof(buf), "%s/images/rage.png", elm_app_data_dir_get());
+ evas_object_image_file_set(o, buf, NULL);
+ elm_win_icon_object_set(win, o);
+#endif
- height = atoi(edje_file_data_get(theme_file, "height"));
- width = atoi(edje_file_data_get(theme_file, "width"));
- if (height < 1 || width < 1) {
- EINA_LOG_ERR("Invalid height (%d) or width (%d) parameter in %s", height, width, theme_file);
+// splash_window = elm_win_add(NULL, PACKAGE_NAME, ELM_WIN_SPLASH);
+ window = elm_win_add(NULL, PACKAGE_NAME, ELM_WIN_BASIC);
+ if (!window)
return EXIT_FAILURE;
- }
- free(theme_file);
+ elm_win_title_set(window, PACKAGE_NAME);
+ elm_win_autodel_set(window, EINA_TRUE);
+ evas_object_smart_callback_add(window, "delete,request", _cb_eulogium_exit, NULL);
+ evas_object_event_callback_add(window, EVAS_CALLBACK_RESIZE, _cb_eulogium_resize, NULL);
- evas_object_show(edje);
- ecore_evas_resize(window, height, width);
- ecore_evas_title_set(window, PACKAGE_NAME);
- ecore_evas_show(window);
+ evas_object_resize(window, 500, 400);
- ecore_main_loop_begin();
+ content = eulogium_menu(window);
+ evas_object_size_hint_weight_set(content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(content, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_win_resize_object_add(window, content);
+ evas_object_show(content);
+ evas_object_show(window);
- evas_object_del(edje);
- ecore_evas_free(window);
- eina_prefix_free(prefix);
-
- eina_shutdown();
- ecore_evas_shutdown();
- edje_shutdown();
+ elm_run();
+ elm_shutdown();
return EXIT_SUCCESS;
}
+
+ELM_MAIN();