see other getgopt users (ie: eve), there easier and extensible way to
list and choose engies.

On 10/14/09, Enlightenment SVN <no-re...@enlightenment.org> wrote:
> 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 <unixti...@gmail.com>",
> +    "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);
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> enlightenment-svn mailing list
> enlightenment-...@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-svn
>


-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: barbi...@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to