summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOlliver Schinagl <oliver@schinagl.nl>2015-01-24 16:33:38 (GMT)
committerOlliver Schinagl <o.schinagl@ultimaker.com>2015-04-28 05:07:12 (GMT)
commitfcc9a7cc3f0ca7e95085bfdc278e3736692730a4 (patch)
tree1f9c4cf34cd600176b100e1afbbc59a2e6dca550 /src
parent08cfb908c22c0c7b5aeb788569950718939b7465 (diff)
downloadeulogium-fcc9a7cc3f0ca7e95085bfdc278e3736692730a4.zip
eulogium-fcc9a7cc3f0ca7e95085bfdc278e3736692730a4.tar.gz
eulogium-fcc9a7cc3f0ca7e95085bfdc278e3736692730a4.tar.bz2
wip commit
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am16
-rw-r--r--src/bin/Makefile.am19
-rw-r--r--src/bin/eulogium_main.c118
-rw-r--r--src/bin/eulogium_private.h6
-rw-r--r--src/eulogium.c139
-rw-r--r--src/gettext.h (renamed from src/bin/gettext.h)0
-rw-r--r--src/lib/Eulogium.h111
-rw-r--r--src/lib/Makefile.am18
-rw-r--r--src/lib/eulogium.c64
-rw-r--r--src/lib/eulogium_private.h27
10 files changed, 154 insertions, 364 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 15871c9..a0417e7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,18 @@
MAINTAINERCLEANFILES = Makefile.in
-SUBDIRS = lib bin tests
+SUBDIRS = tests
+bin_PROGRAMS = eulogium
+
+AM_CPPFLAGS = -DPACKAGE_BIN_DIR=\"$(bindir)/\" \
+ -DPACKAGE_LIB_DIR=\"$(bindir)/\" \
+ -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
+-I$(top_builddir)/src/ \
+-I$(top_srcdir)/src/ \
+@EFL_CFLAGS@
+
+eulogium_SOURCES = eulogium.c
+eulogium_LDADD = @EFL_LIBS@
+
+localedir = $(datadir)/locale
+DEFS = -DLOCALE_DIR=\"$(localedir)\" @DEFS@
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
deleted file mode 100644
index 589f68d..0000000
--- a/src/bin/Makefile.am
+++ /dev/null
@@ -1,19 +0,0 @@
-MAINTAINERCLEANFILES = Makefile.in
-
-bin_PROGRAMS = eulogium
-
-AM_CPPFLAGS = -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
--I$(top_builddir)/src/bin/ \
--I$(top_srcdir)/src/bin/ \
--I$(top_builddir)/src/lib/ \
--I$(top_srcdir)/src/lib/ \
-@EFL_CFLAGS@
-
-eulogium_SOURCES = eulogium_main.c
-eulogium_LDADD = @EFL_LIBS@ $(top_builddir)/src/lib/libeulogium.la
-
-localedir = $(datadir)/locale
-DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
-
-EXTRA_DIST = eulogium_private.h
-
diff --git a/src/bin/eulogium_main.c b/src/bin/eulogium_main.c
deleted file mode 100644
index b8a83e1..0000000
--- a/src/bin/eulogium_main.c
+++ /dev/null
@@ -1,118 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* NOTE: Respecting header order is important for portability.
- * Always put system first, then EFL, then your public header,
- * and finally your private one. */
-
-#include <Ecore_Getopt.h>
-#include <Elementary.h>
-
-#include "gettext.h"
-
-#include "Eulogium.h"
-
-#include "eulogium_private.h"
-
-#define COPYRIGHT "Copyright © 2013 oliver <o.schinagl@ultimaker.com> and various contributors (see AUTHORS)."
-
-static void
-_eulogium_win_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
-{
- elm_exit();
-}
-
-static Evas_Object *
-eulogium_win_setup(void)
-{
- Evas_Object *win;
- Evas_Object *label;
-
- win = elm_win_util_standard_add("main", "Eulogium");
- if (!win) return NULL;
-
- elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
- evas_object_smart_callback_add(win, "delete,request", _eulogium_win_del, NULL);
-
- label = elm_label_add(win);
- elm_object_text_set(label, " Hello World !");
- evas_object_size_hint_weight_set(label, 0.0, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(label, 0.0, EVAS_HINT_FILL);
- evas_object_show(label);
-
- elm_win_resize_object_add(win, label);
-
- evas_object_show(win);
-
- return win;
-}
-
-static const Ecore_Getopt optdesc = {
- "eulogium",
- "%prog [options]",
- PACKAGE_VERSION,
- COPYRIGHT,
- "BSD with advertisement clause",
- "An EFL eulogium program",
- 0,
- {
- ECORE_GETOPT_LICENSE('L', "license"),
- ECORE_GETOPT_COPYRIGHT('C', "copyright"),
- ECORE_GETOPT_VERSION('V', "version"),
- ECORE_GETOPT_HELP('h', "help"),
- ECORE_GETOPT_SENTINEL
- }
-};
-
-EAPI_MAIN int
-elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
-{
- Evas_Object *win;
- int args;
- Eina_Bool quit_option = EINA_FALSE;
-
- Ecore_Getopt_Value values[] = {
- ECORE_GETOPT_VALUE_BOOL(quit_option),
- ECORE_GETOPT_VALUE_BOOL(quit_option),
- ECORE_GETOPT_VALUE_BOOL(quit_option),
- ECORE_GETOPT_VALUE_BOOL(quit_option),
- ECORE_GETOPT_VALUE_NONE
- };
-
-#if ENABLE_NLS
- setlocale(LC_ALL, "");
- bindtextdomain(PACKAGE, LOCALEDIR);
- bind_textdomain_codeset(PACKAGE, "UTF-8");
- textdomain(PACKAGE);
-#endif
-
- eulogium_init();
-
- args = ecore_getopt_parse(&optdesc, values, argc, argv);
- if (args < 0)
- {
- EINA_LOG_CRIT("Could not parse arguments.");
- goto end;
- }
- else if (quit_option)
- {
- goto end;
- }
-
- elm_app_info_set(elm_main, "eulogium", "images/eulogium.png");
-
- if (!(win = eulogium_win_setup()))
- goto end;
-
- eulogium_library_call();
-
- elm_run();
-
- end:
- eulogium_shutdown();
- elm_shutdown();
-
- return 0;
-}
-ELM_MAIN()
diff --git a/src/bin/eulogium_private.h b/src/bin/eulogium_private.h
deleted file mode 100644
index aa968c6..0000000
--- a/src/bin/eulogium_private.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef EULOGIUM_PRIVATE_H_
-# define EULOGIUM_PRIVATE_H_
-
-// FIXME: put some private stuff related to your binary
-
-#endif
diff --git a/src/eulogium.c b/src/eulogium.c
new file mode 100644
index 0000000..cdfff46
--- /dev/null
+++ b/src/eulogium.c
@@ -0,0 +1,139 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <Eina.h>
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+#include <Ecore_Getopt.h>
+#include <Edje.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gettext.h"
+
+#define COPYRIGHT "Copyright © 2015 Olliver Schinagl <oliver@schinagl.nl> and various contributors (see AUTHORS)."
+
+#define EULOGIUM_THEME "eulogium.edj"
+
+int main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
+{
+ Eina_Bool quit_option = EINA_FALSE;
+ static const Ecore_Getopt optdesc = {
+ "eulogium",
+ "%prog [options]",
+ PACKAGE_VERSION,
+ COPYRIGHT,
+ "Affero GPLv3",
+ "eulogium program",
+ 0,
+ {
+ ECORE_GETOPT_LICENSE('L', "license"),
+ ECORE_GETOPT_COPYRIGHT('C', "copyright"),
+ ECORE_GETOPT_VERSION('V', "version"),
+ ECORE_GETOPT_HELP('h', "help"),
+ ECORE_GETOPT_SENTINEL
+ }
+ };
+ Ecore_Getopt_Value values[] = {
+ ECORE_GETOPT_VALUE_BOOL(quit_option),
+ ECORE_GETOPT_VALUE_BOOL(quit_option),
+ ECORE_GETOPT_VALUE_BOOL(quit_option),
+ ECORE_GETOPT_VALUE_BOOL(quit_option),
+ ECORE_GETOPT_VALUE_NONE
+ };
+ int args;
+ Eina_Prefix *prefix;
+ Ecore_Evas *window;
+ Evas *canvas;
+ 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) {
+ EINA_LOG_CRIT("Could not parse arguments.");
+ 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;
+ }
+
+ 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);
+ return EXIT_FAILURE;
+ }
+ free(theme_file);
+
+ evas_object_show(edje);
+ ecore_evas_resize(window, height, width);
+ ecore_evas_title_set(window, PACKAGE_NAME);
+ ecore_evas_show(window);
+
+ ecore_main_loop_begin();
+
+ evas_object_del(edje);
+ ecore_evas_free(window);
+ eina_prefix_free(prefix);
+
+ eina_shutdown();
+ ecore_evas_shutdown();
+ edje_shutdown();
+
+ return EXIT_SUCCESS;
+}
diff --git a/src/bin/gettext.h b/src/gettext.h
index e76b592..e76b592 100644
--- a/src/bin/gettext.h
+++ b/src/gettext.h
diff --git a/src/lib/Eulogium.h b/src/lib/Eulogium.h
deleted file mode 100644
index 7ef7c0d..0000000
--- a/src/lib/Eulogium.h
+++ /dev/null
@@ -1,111 +0,0 @@
-#ifndef EULOGIUM_H_
-# define EULOGIUM_H_
-
-#include <Elementary.h>
-
-#ifdef EAPI
-# undef EAPI
-#endif
-
-#ifdef _WIN32
-# ifdef EFL_EULOGIUM_BUILD
-# ifdef DLL_EXPORT
-# define EAPI __declspec(dllexport)
-# else
-# define EAPI
-# endif /* ! DLL_EXPORT */
-# else
-# define EAPI __declspec(dllimport)
-# endif /* ! EFL_EULOGIUM_BUILD */
-#else
-# ifdef __GNUC__
-# if __GNUC__ >= 4
-# define EAPI __attribute__ ((visibility("default")))
-# else
-# define EAPI
-# endif
-# else
-# define EAPI
-# endif
-#endif /* ! _WIN32 */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @file
- * @brief These routines are used for Eulogium library interaction.
- */
-
-/**
- * @brief Init / shutdown functions.
- * @defgroup Init Init / Shutdown
- *
- * @{
- *
- * Functions of obligatory usage, handling proper initialization
- * and shutdown routines.
- *
- * Before the usage of any other function, Eulogium should be properly
- * initialized with @ref eulogium_init() and the last call to Eulogium's
- * functions should be @ref eulogium_shutdown(), so everything will
- * be correctly freed.
- *
- * Eulogium logs everything with Eina Log, using the "eulogium" log domain.
- *
- */
-
-/**
- * Initialize Eulogium.
- *
- * Initializes Eulogium, its dependencies and modules. Should be the first
- * function of Eulogium to be called.
- *
- * @return The init counter value.
- *
- * @see eulogium_shutdown().
- *
- * @ingroup Init
- */
-EAPI int eulogium_init(void);
-
-/**
- * Shutdown Eulogium
- *
- * Shutdown Eulogium. If init count reaches 0, all the internal structures will
- * be freed. Any Eulogium library call after this point will leads to an error.
- *
- * @return Eulogium's init counter value.
- *
- * @see eulogium_init().
- *
- * @ingroup Init
- */
-EAPI int eulogium_shutdown(void);
-
-/**
- * @}
- */
-
-/**
- * @brief Main group API that wont do anything
- * @defgroup Main Main
- *
- * @{
- *
- * @brief A function that doesn't do any good nor any bad
- *
- * @ingroup Main
- */
-EAPI void eulogium_library_call(void);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* EULOGIUM_H_ */
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
deleted file mode 100644
index 56d5c22..0000000
--- a/src/lib/Makefile.am
+++ /dev/null
@@ -1,18 +0,0 @@
-MAINTAINERCLEANFILES = Makefile.in
-
-AM_CPPFLAGS = \
--I$(top_srcdir)/src/lib \
--I$(top_builddir)/src/lib \
--DPACKAGE_LIB_DIR=\"$(libdir)\" \
--DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
-@EFL_CFLAGS@ \
--DEFL_EFL_BUILD
-
-lib_LTLIBRARIES = libeulogium.la
-
-includes_HEADERS = Eulogium.h
-includesdir = $(includedir)/eulogium-@VMAJ@
-
-libeulogium_la_SOURCES = eulogium.c
-libeulogium_la_LIBADD = @EFL_LIBS@ -lm
-libeulogium_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
diff --git a/src/lib/eulogium.c b/src/lib/eulogium.c
deleted file mode 100644
index 8e19356..0000000
--- a/src/lib/eulogium.c
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "Eulogium.h"
-
-#include "eulogium_private.h"
-
-static int _eulogium_init = 0;
-int _eulogium_lib_log_dom = -1;
-
-EAPI int
-eulogium_init(void)
-{
- _eulogium_init++;
- if (_eulogium_init > 1) return _eulogium_init;
-
- eina_init();
-
- _eulogium_lib_log_dom = eina_log_domain_register("eulogium", EINA_COLOR_CYAN);
- if (_eulogium_lib_log_dom < 0)
- {
- EINA_LOG_ERR("Eulogium can not create its log domain.");
- goto shutdown_eina;
- }
-
- // Put here your initialization logic of your library
-
- eina_log_timing(_eulogium_lib_log_dom, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT);
-
- return _eulogium_init;
-
- shutdown_eina:
- eina_shutdown();
- _eulogium_init--;
-
- return _eulogium_init;
-}
-
-EAPI int
-eulogium_shutdown(void)
-{
- _eulogium_init--;
- if (_eulogium_init != 0) return _eulogium_init;
-
- eina_log_timing(_eulogium_lib_log_dom,
- EINA_LOG_STATE_START,
- EINA_LOG_STATE_SHUTDOWN);
-
- // Put here your shutdown logic
-
- eina_log_domain_unregister(_eulogium_lib_log_dom);
- _eulogium_lib_log_dom = -1;
-
- eina_shutdown();
-
- return _eulogium_init;
-}
-
-EAPI void
-eulogium_library_call(void)
-{
- INF("Not really doing anything useful.");
-}
diff --git a/src/lib/eulogium_private.h b/src/lib/eulogium_private.h
deleted file mode 100644
index ff03439..0000000
--- a/src/lib/eulogium_private.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef EULOGIUM_PRIVATE_H
-# define EULOGIUM_PRIVATE_H
-
-extern int _eulogium_lib_log_dom;
-
-#ifdef ERR
-# undef ERR
-#endif
-#define ERR(...) EINA_LOG_DOM_ERR(_eulogium_lib_log_dom, __VA_ARGS__)
-#ifdef INF
-# undef INF
-#endif
-#define INF(...) EINA_LOG_DOM_INFO(_eulogium_lib_log_dom, __VA_ARGS__)
-#ifdef WRN
-# undef WRN
-#endif
-#define WRN(...) EINA_LOG_DOM_WARN(_eulogium_lib_log_dom, __VA_ARGS__)
-#ifdef CRIT
-# undef CRIT
-#endif
-#define CRIT(...) EINA_LOG_DOM_CRIT(_eulogium_lib_log_dom, __VA_ARGS__)
-#ifdef DBG
-# undef DBG
-#endif
-#define DBG(...) EINA_LOG_DOM_DBG(_eulogium_lib_log_dom, __VA_ARGS__)
-
-#endif