diff options
Diffstat (limited to 'src/eulogium.c')
-rw-r--r-- | src/eulogium.c | 139 |
1 files changed, 139 insertions, 0 deletions
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; +} |