From: Enlightenment S. <no-...@en...> - 2009-10-14 21:17:51
|
Log: Add ecore_getopt to support options for ephoto. Thanks to PrinceAMD for the patch. Author: titan Date: 2009-10-14 14:17:34 -0700 (Wed, 14 Oct 2009) New Revision: 43085 Modified: trunk/ephoto/src/bin/ephoto.c trunk/ephoto/src/bin/ephoto.h trunk/ephoto/src/bin/ephoto_main.c Modified: trunk/ephoto/src/bin/ephoto.c =================================================================== --- trunk/ephoto/src/bin/ephoto.c 2009-10-14 19:41:54 UTC (rev 43084) +++ trunk/ephoto/src/bin/ephoto.c 2009-10-14 21:17:34 UTC (rev 43085) @@ -1,5 +1,59 @@ #include "ephoto.h" +Getopts_Data *getopts; + +const Ecore_Getopt general_opts = +{ + "ephoto", + NULL, + "5.15", + "(C) 2009 - Stephen okra Houston <Uni...@gm...>", + "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 @@ return 1; } + if (!_ephoto_args_init(argc, argv)) + return 0; + create_main_window(); ecore_main_loop_begin(); Modified: trunk/ephoto/src/bin/ephoto.h =================================================================== --- trunk/ephoto/src/bin/ephoto.h 2009-10-14 19:41:54 UTC (rev 43084) +++ trunk/ephoto/src/bin/ephoto.h 2009-10-14 21:17:34 UTC (rev 43085) @@ -9,6 +9,7 @@ #include <Ecore_Data.h> #include <Ecore_Evas.h> #include <Ecore_File.h> +#include <Ecore_Getopt.h> #include <Eet.h> #include <Efreet_Mime.h> #include <Eina.h> @@ -91,4 +92,14 @@ }; 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 Modified: trunk/ephoto/src/bin/ephoto_main.c =================================================================== --- trunk/ephoto/src/bin/ephoto_main.c 2009-10-14 19:41:54 UTC (rev 43084) +++ trunk/ephoto/src/bin/ephoto_main.c 2009-10-14 21:17:34 UTC (rev 43085) @@ -17,7 +17,15 @@ 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); |