From c50aa91d9394e864bf034e461e9d04d18afc621c Mon Sep 17 00:00:00 2001 From: titan Date: Wed, 14 Oct 2009 21:17:34 +0000 Subject: [PATCH] Add ecore_getopt to support options for ephoto. Thanks to PrinceAMD for the patch. SVN revision: 43085 --- src/bin/ephoto.c | 57 +++++++++++++++++++++++++++++++++++++++++++ src/bin/ephoto.h | 11 +++++++++ src/bin/ephoto_main.c | 10 +++++++- 3 files changed, 77 insertions(+), 1 deletion(-) diff --git a/src/bin/ephoto.c b/src/bin/ephoto.c index c60a886..ef781b8 100644 --- a/src/bin/ephoto.c +++ b/src/bin/ephoto.c @@ -1,5 +1,59 @@ #include "ephoto.h" +Getopts_Data *getopts; + +const Ecore_Getopt general_opts = +{ + "ephoto", + NULL, + "5.15", + "(C) 2009 - Stephen okra Houston ", + "BSD License", + "Ephoto - Version 5.15\n" + " Fancy Image Viewing\n", + 0, + { + ECORE_GETOPT_COUNT + ('\0',"use-software", "Use the Software engine to render this program"), + ECORE_GETOPT_COUNT + ('\0', "use-xrender", "Use the Xrender engine to render this program"), + ECORE_GETOPT_COUNT + ('\0', "use-opengl", "Use the OpenGL engine to render this program"), + ECORE_GETOPT_LICENSE('L', "license"), + ECORE_GETOPT_COPYRIGHT('C', "copyright"), + ECORE_GETOPT_VERSION('V', "version"), + ECORE_GETOPT_HELP('h', "help"), + ECORE_GETOPT_SENTINEL + } +}; + +static Eina_Bool +_ephoto_args_init(int argc, char **argv) +{ + getopts = calloc(1, sizeof(Getopts_Data)); + int arg_index; + + Ecore_Getopt_Value general_values[] = + { + ECORE_GETOPT_VALUE_BOOL(getopts->software), + ECORE_GETOPT_VALUE_BOOL(getopts->xrender), + ECORE_GETOPT_VALUE_BOOL(getopts->opengl), + ECORE_GETOPT_VALUE_BOOL(getopts->quit), + ECORE_GETOPT_VALUE_BOOL(getopts->quit), + ECORE_GETOPT_VALUE_BOOL(getopts->quit), + ECORE_GETOPT_VALUE_BOOL(getopts->quit), + ECORE_GETOPT_VALUE_NONE + }; + arg_index = ecore_getopt_parse(&general_opts, general_values, argc, argv); + + if (getopts->quit) + { + return EINA_FALSE; + } + else + return EINA_TRUE; +} + int main(int argc, char **argv) { if (!eina_init()) @@ -53,6 +107,9 @@ int main(int argc, char **argv) return 1; } + if (!_ephoto_args_init(argc, argv)) + return 0; + create_main_window(); ecore_main_loop_begin(); diff --git a/src/bin/ephoto.h b/src/bin/ephoto.h index a605773..a9c0b96 100644 --- a/src/bin/ephoto.h +++ b/src/bin/ephoto.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -91,4 +92,14 @@ struct _Ephoto }; extern Ephoto *em; +typedef struct _Getopts_Data Getopts_Data; +struct _Getopts_Data +{ + Eina_Bool software; + Eina_Bool xrender; + Eina_Bool opengl; + Eina_Bool quit; +}; +extern Getopts_Data *getopts; + #endif diff --git a/src/bin/ephoto_main.c b/src/bin/ephoto_main.c index 5718274..22255e0 100644 --- a/src/bin/ephoto_main.c +++ b/src/bin/ephoto_main.c @@ -17,7 +17,15 @@ void create_main_window(void) em->width = 955; em->height = 540; - em->ee = ecore_evas_software_x11_new(0, 0, 0, 0, 955, 540); + if (getopts->software) + em->ee = ecore_evas_software_x11_new(0, 0, 0, 0, 955, 540); + else if (getopts->xrender) + em->ee = ecore_evas_xrender_x11_new(0, 0, 0, 0, 955, 540); + else if (getopts->opengl) + em->ee = ecore_evas_gl_x11_new(0, 0, 0, 0, 955, 540); + else + em->ee = ecore_evas_software_x11_new(0, 0, 0, 0, 955, 540); + ecore_evas_title_set(em->ee, "Ephoto"); ecore_evas_name_class_set(em->ee, "Ephoto", "Ephoto"); ecore_evas_callback_destroy_set(em->ee, window_close);