config: Add argument "-to" to open a new file with templates
Summary: Add argument "-to" to open a new file with templates Reviewers: Hermet Differential Revision: https://phab.enlightenment.org/D1536
This commit is contained in:
parent
5229b12423
commit
f929c7af02
|
@ -14,6 +14,7 @@ typedef struct app_s
|
|||
|
||||
Eina_Bool ctrl_pressed : 1;
|
||||
Eina_Bool shift_pressed : 1;
|
||||
Eina_Bool template_new : 1;
|
||||
} app_data;
|
||||
|
||||
int main(int argc, char **argv);
|
||||
|
@ -218,9 +219,11 @@ tools_set(Evas_Object *enventor)
|
|||
|
||||
static void
|
||||
args_dispatch(int argc, char **argv, char *edc_path, char *img_path,
|
||||
char *snd_path, char *fnt_path, char *dat_path)
|
||||
char *snd_path, char *fnt_path, char *dat_path,
|
||||
Eina_Bool *template_new)
|
||||
{
|
||||
Eina_Bool default_edc = EINA_TRUE;
|
||||
*template_new = EINA_FALSE;
|
||||
|
||||
//No arguments. set defaults
|
||||
if (argc == 1) goto defaults;
|
||||
|
@ -228,8 +231,8 @@ args_dispatch(int argc, char **argv, char *edc_path, char *img_path,
|
|||
//Help
|
||||
if ((argc >=2 ) && !strcmp(argv[1], "--help"))
|
||||
{
|
||||
fprintf(stdout, "Usage: enventor [input file] [-id image path]"
|
||||
"[-sd sound path] [-fd font path] [-dd data path]\n");
|
||||
fprintf(stdout, "Usage: enventor [input file] [-to] [-id image path]"
|
||||
"[-sd sound path] [-fd font path] [-dd data path]\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
@ -239,6 +242,10 @@ args_dispatch(int argc, char **argv, char *edc_path, char *img_path,
|
|||
sprintf(edc_path, "%s", argv[1]);
|
||||
default_edc = EINA_FALSE;
|
||||
}
|
||||
else if ((argc >= 2) && !strcmp("-to", argv[1]))
|
||||
{
|
||||
*template_new = EINA_TRUE;
|
||||
}
|
||||
else goto defaults;
|
||||
|
||||
//edc image path
|
||||
|
@ -246,18 +253,31 @@ args_dispatch(int argc, char **argv, char *edc_path, char *img_path,
|
|||
|
||||
while (cur_arg < argc)
|
||||
{
|
||||
if (argc > (cur_arg + 1))
|
||||
if (!strcmp("-to", argv[cur_arg]))
|
||||
{
|
||||
if (!strcmp("-id", argv[cur_arg]))
|
||||
sprintf(img_path, "%s", argv[cur_arg + 1]);
|
||||
else if (!strcmp("-sd", argv[cur_arg]))
|
||||
sprintf(snd_path, "%s", argv[cur_arg + 1]);
|
||||
else if (!strcmp("-fd", argv[cur_arg]))
|
||||
sprintf(fnt_path, "%s", argv[cur_arg + 1]);
|
||||
else if (!strcmp("-dd", argv[cur_arg]))
|
||||
sprintf(dat_path, "%s", argv[cur_arg + 1]);
|
||||
*template_new = EINA_TRUE;
|
||||
cur_arg++;
|
||||
}
|
||||
else if (!strcmp("-id", argv[cur_arg]))
|
||||
{
|
||||
sprintf(img_path, "%s", argv[cur_arg + 1]);
|
||||
cur_arg += 2;
|
||||
}
|
||||
else if (!strcmp("-sd", argv[cur_arg]))
|
||||
{
|
||||
sprintf(snd_path, "%s", argv[cur_arg + 1]);
|
||||
cur_arg += 2;
|
||||
}
|
||||
else if (!strcmp("-fd", argv[cur_arg]))
|
||||
{
|
||||
sprintf(fnt_path, "%s", argv[cur_arg + 1]);
|
||||
cur_arg += 2;
|
||||
}
|
||||
else if (!strcmp("-dd", argv[cur_arg]))
|
||||
{
|
||||
sprintf(dat_path, "%s", argv[cur_arg + 1]);
|
||||
cur_arg += 2;
|
||||
}
|
||||
cur_arg += 2;
|
||||
}
|
||||
|
||||
defaults:
|
||||
|
@ -272,10 +292,13 @@ config_data_set(app_data *ad, int argc, char **argv)
|
|||
char snd_path[PATH_MAX] = { 0, };
|
||||
char fnt_path[PATH_MAX] = { 0, };
|
||||
char dat_path[PATH_MAX] = { 0, };
|
||||
Eina_Bool template_new = EINA_FALSE;
|
||||
|
||||
args_dispatch(argc, argv, edc_path, img_path, snd_path, fnt_path, dat_path);
|
||||
args_dispatch(argc, argv, edc_path, img_path, snd_path, fnt_path, dat_path,
|
||||
&template_new);
|
||||
config_init(edc_path, img_path, snd_path, fnt_path, dat_path);
|
||||
config_update_cb_set(config_update_cb, ad);
|
||||
ad->template_new = template_new;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -656,7 +679,7 @@ main_key_down_cb(void *data, int type EINA_UNUSED, void *ev)
|
|||
//New
|
||||
if (!strcmp(event->key, "F2"))
|
||||
{
|
||||
menu_edc_new();
|
||||
menu_edc_new(EINA_FALSE);
|
||||
return ECORE_CALLBACK_DONE;
|
||||
}
|
||||
//Save
|
||||
|
@ -716,6 +739,12 @@ statusbar_set()
|
|||
base_statusbar_toggle(EINA_FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
template_show()
|
||||
{
|
||||
menu_edc_new(EINA_TRUE);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
init(app_data *ad, int argc, char **argv)
|
||||
{
|
||||
|
@ -741,6 +770,8 @@ init(app_data *ad, int argc, char **argv)
|
|||
|
||||
menu_init(ad->enventor);
|
||||
|
||||
if (ad->template_new) template_show();
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ struct menu_s
|
|||
|
||||
int active_request;
|
||||
|
||||
Eina_Bool template_new : 1;
|
||||
};
|
||||
|
||||
typedef struct menu_s menu_data;
|
||||
|
@ -121,7 +122,7 @@ newfile_ok_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
menu_data *md = data;
|
||||
newfile_set(md->enventor);
|
||||
newfile_set(md->enventor, md->template_new);
|
||||
newfile_close(md);
|
||||
menu_close(md);
|
||||
}
|
||||
|
@ -366,7 +367,7 @@ static void
|
|||
new_btn_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
menu_edc_new();
|
||||
menu_edc_new(EINA_FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -692,9 +693,10 @@ menu_setting(void)
|
|||
}
|
||||
|
||||
void
|
||||
menu_edc_new(void)
|
||||
menu_edc_new(Eina_Bool template_new)
|
||||
{
|
||||
menu_data *md = g_md;
|
||||
md->template_new = template_new;
|
||||
if (enventor_object_modified_get(md->enventor))
|
||||
warning_open(md, new_yes_btn_cb, new_save_btn_cb);
|
||||
else
|
||||
|
|
|
@ -18,7 +18,7 @@ list_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
}
|
||||
|
||||
void
|
||||
newfile_set(Evas_Object *enventor)
|
||||
newfile_set(Evas_Object *enventor, Eina_Bool template_new)
|
||||
{
|
||||
new_data *nd = g_nd;
|
||||
if (!nd) return;
|
||||
|
@ -28,20 +28,23 @@ newfile_set(Evas_Object *enventor)
|
|||
|
||||
Eina_Bool success = EINA_TRUE;
|
||||
char buf[PATH_MAX];
|
||||
char default_path[PATH_MAX];
|
||||
char path[PATH_MAX];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/templates/%s.edc",
|
||||
elm_app_data_dir_get(), elm_object_item_text_get(it));
|
||||
sprintf(default_path, DEFAULT_EDC_PATH_FORMAT, getpid());
|
||||
success = eina_file_copy(buf, default_path,
|
||||
if (template_new && config_edc_path_get())
|
||||
sprintf(path, "%s", config_edc_path_get());
|
||||
else
|
||||
sprintf(path, DEFAULT_EDC_PATH_FORMAT, getpid());
|
||||
success = eina_file_copy(buf, path,
|
||||
EINA_FILE_COPY_DATA, NULL, NULL);
|
||||
if (!success)
|
||||
{
|
||||
EINA_LOG_ERR("Cannot find file! \"%s\"", buf);
|
||||
return;
|
||||
}
|
||||
enventor_object_file_set(enventor, default_path);
|
||||
base_title_set(default_path);
|
||||
enventor_object_file_set(enventor, path);
|
||||
base_title_set(path);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -3,7 +3,7 @@ void menu_term(void);
|
|||
void menu_toggle(void);
|
||||
void menu_ctxpopup_register(Evas_Object *ctxpopup);
|
||||
void menu_ctxpopup_unregister(Evas_Object *ctxpopup);
|
||||
void menu_edc_new(void);
|
||||
void menu_edc_new(Eina_Bool template_new);
|
||||
void menu_edc_save(void);
|
||||
void menu_edc_load(void);
|
||||
void menu_exit(void);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
void newfile_default_set(void);
|
||||
void newfile_set(Evas_Object *enventor);
|
||||
void newfile_set(Evas_Object *enventor, Eina_Bool template_new);
|
||||
Evas_Object * newfile_create(Evas_Object *parent, Evas_Smart_Cb selected_cb, void *data);
|
||||
|
||||
|
|
Loading…
Reference in New Issue