2011-02-24 14:26:47 -08:00
|
|
|
#include "ephoto.h"
|
|
|
|
|
2011-02-01 13:44:38 -08:00
|
|
|
static void _ephoto_display_usage(void);
|
2010-09-13 15:24:59 -07:00
|
|
|
|
2017-11-28 13:01:48 -08:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
2010-07-01 11:49:22 -07:00
|
|
|
{
|
2017-11-28 14:03:11 -08:00
|
|
|
int gadget = 0, id_num = 0, r = 0;
|
|
|
|
char buf[4096];
|
2010-10-08 12:03:21 -07:00
|
|
|
|
2017-11-28 13:01:48 -08:00
|
|
|
elm_init(argc, (char **)argv);
|
2010-10-12 23:15:16 -07:00
|
|
|
eio_init();
|
2010-10-08 12:04:34 -07:00
|
|
|
elm_need_efreet();
|
2015-08-10 12:33:18 -07:00
|
|
|
elm_language_set("");
|
2015-08-11 07:58:02 -07:00
|
|
|
elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
|
2017-11-28 13:01:48 -08:00
|
|
|
elm_app_info_set(main, "ephoto", "themes/ephoto.edj");
|
2015-01-29 13:06:33 -08:00
|
|
|
#if HAVE_GETTEXT && ENABLE_NLS
|
|
|
|
elm_app_compile_locale_set(LOCALEDIR);
|
2015-08-11 07:58:02 -07:00
|
|
|
bindtextdomain(PACKAGE, elm_app_locale_dir_get());
|
2015-08-10 13:58:16 -07:00
|
|
|
bind_textdomain_codeset(PACKAGE, "UTF-8");
|
2015-01-29 13:06:33 -08:00
|
|
|
textdomain(PACKAGE);
|
2015-02-20 08:07:50 -08:00
|
|
|
#endif
|
2015-01-29 13:06:33 -08:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
if (!efreet_mime_init())
|
2016-03-24 10:16:05 -07:00
|
|
|
printf("Could not initialize Efreet_Mime!\n");
|
|
|
|
if (!e_ipc_init())
|
|
|
|
printf("Could not initialize IPC!\n");
|
|
|
|
if (!e_thumb_init())
|
|
|
|
printf("Could not initialize Thumbnailer!\n");
|
2010-10-09 12:13:35 -07:00
|
|
|
|
2010-10-09 18:13:53 -07:00
|
|
|
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
2010-10-08 12:03:21 -07:00
|
|
|
|
2017-11-28 13:01:48 -08:00
|
|
|
if (getenv("E_GADGET_ID"))
|
2017-11-28 14:03:11 -08:00
|
|
|
{
|
|
|
|
gadget = 1;
|
|
|
|
snprintf(buf, sizeof(buf), "%s", getenv("E_GADGET_ID"));
|
|
|
|
id_num = atoi(buf);
|
|
|
|
}
|
|
|
|
if (id_num < 0)
|
|
|
|
{
|
|
|
|
Evas_Object *win, *icon;
|
2017-11-28 13:01:48 -08:00
|
|
|
|
2017-11-28 14:03:11 -08:00
|
|
|
win = elm_win_add(NULL, "ephoto", ELM_WIN_BASIC);
|
|
|
|
elm_win_title_set(win, "Ephoto");
|
|
|
|
elm_win_alpha_set(win, 1);
|
|
|
|
elm_win_autodel_set(win, 1);
|
|
|
|
evas_object_size_hint_aspect_set(win, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
|
|
|
|
|
|
|
|
icon = elm_image_add(win);
|
|
|
|
elm_image_file_set(icon, PACKAGE_DATA_DIR "/images/ephoto.png", NULL);
|
|
|
|
elm_win_resize_object_add(win, icon);
|
|
|
|
evas_object_show(icon);
|
|
|
|
|
|
|
|
evas_object_show(win);
|
|
|
|
}
|
|
|
|
else if (argc > 2)
|
2010-10-08 12:04:34 -07:00
|
|
|
{
|
2017-08-30 07:01:07 -07:00
|
|
|
printf("Too Many Arguments!\n");
|
|
|
|
_ephoto_display_usage();
|
|
|
|
r = 1;
|
|
|
|
goto end;
|
2010-10-08 12:04:34 -07:00
|
|
|
}
|
2011-02-24 14:26:47 -08:00
|
|
|
else if (argc < 2)
|
2010-10-08 12:04:34 -07:00
|
|
|
{
|
2017-11-28 13:01:48 -08:00
|
|
|
Evas_Object *win = ephoto_window_add(NULL, gadget);
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2017-08-30 07:01:07 -07:00
|
|
|
if (!win)
|
|
|
|
{
|
|
|
|
r = 1;
|
|
|
|
goto end;
|
|
|
|
}
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
|
|
|
else if (!strncmp(argv[1], "--help", 6))
|
|
|
|
{
|
2017-08-30 07:01:07 -07:00
|
|
|
_ephoto_display_usage();
|
|
|
|
r = 0;
|
|
|
|
goto end;
|
2010-10-08 12:04:34 -07:00
|
|
|
}
|
2011-02-21 17:55:08 -08:00
|
|
|
else
|
2010-10-08 12:04:34 -07:00
|
|
|
{
|
2017-08-30 07:01:07 -07:00
|
|
|
char *real = ecore_file_realpath(argv[1]);
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2017-08-30 07:01:07 -07:00
|
|
|
if (!real)
|
|
|
|
{
|
|
|
|
printf("invalid file or directory: '%s'\n", argv[1]);
|
|
|
|
r = 1;
|
|
|
|
goto end;
|
|
|
|
}
|
2017-11-28 13:01:48 -08:00
|
|
|
Evas_Object *win = ephoto_window_add(real, gadget);
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2017-08-30 07:01:07 -07:00
|
|
|
free(real);
|
|
|
|
if (!win)
|
|
|
|
{
|
|
|
|
r = 1;
|
|
|
|
goto end;
|
|
|
|
}
|
2010-10-08 12:04:34 -07:00
|
|
|
}
|
|
|
|
|
2017-11-28 13:01:48 -08:00
|
|
|
ecore_main_loop_begin();
|
2017-08-30 07:01:07 -07:00
|
|
|
end:
|
2016-03-24 10:16:05 -07:00
|
|
|
e_thumb_shutdown();
|
2011-02-24 14:26:47 -08:00
|
|
|
efreet_mime_shutdown();
|
2010-10-12 23:15:16 -07:00
|
|
|
eio_shutdown();
|
2017-11-28 13:01:48 -08:00
|
|
|
elm_shutdown();
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2010-10-08 12:04:34 -07:00
|
|
|
return r;
|
2010-07-01 11:49:22 -07:00
|
|
|
}
|
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
/* Display useage commands for ephoto */
|
2010-07-10 14:52:14 -07:00
|
|
|
static void
|
|
|
|
_ephoto_display_usage(void)
|
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
printf("Ephoto Usage: \n" "ephoto --help : This page\n"
|
2017-08-30 07:01:07 -07:00
|
|
|
"ephoto filename : Specifies a file to open\n"
|
|
|
|
"ephoto dirname : Specifies a directory to open\n");
|
2010-07-10 14:52:14 -07:00
|
|
|
}
|