Add ecore_getopt to support options for ephoto. Thanks to PrinceAMD for the patch.

SVN revision: 43085
This commit is contained in:
titan 2009-10-14 21:17:34 +00:00 committed by titan
parent a28e26d06d
commit c50aa91d93
3 changed files with 77 additions and 1 deletions

View File

@ -1,5 +1,59 @@
#include "ephoto.h" #include "ephoto.h"
Getopts_Data *getopts;
const Ecore_Getopt general_opts =
{
"ephoto",
NULL,
"5.15",
"(C) 2009 - Stephen okra Houston <UnixTitan@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) int main(int argc, char **argv)
{ {
if (!eina_init()) if (!eina_init())
@ -53,6 +107,9 @@ int main(int argc, char **argv)
return 1; return 1;
} }
if (!_ephoto_args_init(argc, argv))
return 0;
create_main_window(); create_main_window();
ecore_main_loop_begin(); ecore_main_loop_begin();

View File

@ -9,6 +9,7 @@
#include <Ecore_Data.h> #include <Ecore_Data.h>
#include <Ecore_Evas.h> #include <Ecore_Evas.h>
#include <Ecore_File.h> #include <Ecore_File.h>
#include <Ecore_Getopt.h>
#include <Eet.h> #include <Eet.h>
#include <Efreet_Mime.h> #include <Efreet_Mime.h>
#include <Eina.h> #include <Eina.h>
@ -91,4 +92,14 @@ struct _Ephoto
}; };
extern Ephoto *em; 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 #endif

View File

@ -17,7 +17,15 @@ void create_main_window(void)
em->width = 955; em->width = 955;
em->height = 540; 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_title_set(em->ee, "Ephoto");
ecore_evas_name_class_set(em->ee, "Ephoto", "Ephoto"); ecore_evas_name_class_set(em->ee, "Ephoto", "Ephoto");
ecore_evas_callback_destroy_set(em->ee, window_close); ecore_evas_callback_destroy_set(em->ee, window_close);