Completion of examples feature

This commit is contained in:
Andy Williams 2018-02-10 20:47:13 +00:00
commit a5ce833292
16 changed files with 404 additions and 153 deletions

View File

@ -0,0 +1,67 @@
collections {
group {
name: "hellogui";
max: 128 128;
data {
item: "title" "C EFL Beta Hello World";
item: "path" "tutorials/c/hellogui/";
item: "description"
"Hello World using the EFL Beta APIs";
}
parts {
part { name: "icon";
description { state: "default" 0.0;
max: 128 128;
images.image: "hellogui.png" COMP;
image.normal: "hellogui.png";
}
}
}
}
group {
name: "life";
max: 128 128;
data {
item: "title" "C EFL Beta Game of Life";
item: "path" "apps/c/life/";
item: "description"
"Game of Life using the EFL Beta APIs";
}
parts {
part { name: "icon";
description { state: "default" 0.0;
max: 128 128;
images.image: "life.png" COMP;
image.normal: "life.png";
}
}
}
}
group {
name: "texteditor";
max: 128 128;
data {
item: "title" "C EFL Beta Basic Text Editor";
item: "path" "apps/c/texteditor/";
item: "description"
"A basic text editor app using the EFL Beta APIs";
}
parts {
part { name: "icon";
description { state: "default" 0.0;
max: 128 128;
images.image: "texteditor.png" COMP;
image.normal: "texteditor.png";
}
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,20 @@
tar = find_program('tar')
edje_cc = find_program('edje_cc')
cmd = [ edje_cc,
'-id', join_paths(meson.source_root(), 'data' , 'extra', 'examples', 'images'),
'@INPUT@', '@OUTPUT@'
]
examples_dir = join_paths(get_option('datadir'), 'edi', 'examples')
custom_target('examples_meta',
input : 'examples.edc',
output : 'examples.edj',
command : cmd,
install_dir: examples_dir,
install: true,
)
out = join_paths(get_option('prefix'), examples_dir, 'examples.edj')
meson.add_install_script('../../../scripts/world_read.sh', out)

View File

@ -1,23 +0,0 @@
data {
item: "title" "C EFL Project";
item: "file" "skeletons/eflproject.tar.gz";
item: "description"
"Begin your C programming EFL project. All content is freely modifiable and distributable and licensed in the public-domain.<br><br>Happy hacking!";
}
collections {
group {
name: "logo";
max: 128 128;
parts {
part { name: "icon";
description { state: "default" 0.0;
max: 128 128;
image.image: "c.png" COMP;
image.normal: "c.png";
}
}
}
}
}

View File

@ -1,23 +0,0 @@
data {
item: "title" "Python EFL Project";
item: "file" "skeletons/eflproject_python.tar.gz";
item: "description"
"Start your new EFL Python programming project. All code is in the public-domain, you are free to modify and distribute as you wish.";
}
collections {
group {
name: "logo";
max: 128 128;
parts {
part { name: "icon";
description { state: "default" 0.0;
max: 128 128;
image.image: "python.png" COMP;
image.normal: "python.png";
}
}
}
}
}

View File

@ -9,7 +9,7 @@ foreach skeleton_name : skeleton_names
command : [tar, 'zcf', '@OUTPUT@', '-C', '../data/extra/templates/skeletons', skeleton_name], command : [tar, 'zcf', '@OUTPUT@', '-C', '../data/extra/templates/skeletons', skeleton_name],
input : 'skeletons' + '/' + skeleton_name, input : 'skeletons' + '/' + skeleton_name,
output : skeleton_name + '.tar.gz', output : skeleton_name + '.tar.gz',
install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'edi', 'templates', 'skeletons'), install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'edi', 'templates'),
install : true, install : true,
) )
@ -20,18 +20,14 @@ cmd = [ edje_cc,
'@INPUT@', '@OUTPUT@' '@INPUT@', '@OUTPUT@'
] ]
skeleton_meta = ['eflproject', 'eflproject_python']
template_dir = join_paths(get_option('datadir'), 'edi', 'templates') template_dir = join_paths(get_option('datadir'), 'edi', 'templates')
foreach meta : skeleton_meta custom_target('templates_meta',
custom_target('meta ' + meta, input : 'templates.edc',
input : meta + '.edc', output : 'templates.edj',
output : meta + '.edj', command : cmd,
command : cmd, install_dir: template_dir,
install_dir: template_dir, install: true,
install: true, )
) out = join_paths(get_option('prefix'), template_dir, 'templates.edj')
out = join_paths(get_option('prefix'), template_dir, meta + '.edj') meson.add_install_script('../../../scripts/world_read.sh', out)
meson.add_install_script('../../../scripts/world_read.sh', out)
endforeach

View File

@ -0,0 +1,45 @@
collections {
group {
name: "eflproject";
max: 128 128;
data {
item: "title" "C EFL Project";
item: "path" "eflproject";
item: "description"
"Begin your C programming EFL project. All content is freely modifiable and distributable and licensed in the public-domain.<br><br>Happy hacking!";
}
parts {
part { name: "icon";
description { state: "default" 0.0;
max: 128 128;
images.image: "c.png" COMP;
image.normal: "c.png";
}
}
}
}
group {
name: "eflproject_python";
max: 128 128;
data {
item: "title" "Python EFL Project";
item: "path" "eflproject_python";
item: "description"
"Start your new EFL Python programming project. All code is in the public-domain, you are free to modify and distribute as you wish.";
}
parts {
part { name: "icon";
description { state: "default" 0.0;
max: 128 128;
images.image: "python.png" COMP;
image.normal: "python.png";
}
}
}
}
}

View File

@ -1,4 +1,5 @@
subdir('desktop') subdir('desktop')
subdir('images') subdir('images')
subdir('extra/templates') subdir('extra/templates')
subdir('extra/examples')
subdir('themes') subdir('themes')

View File

@ -41,7 +41,7 @@ _exe_del(void *d EINA_UNUSED, int t EINA_UNUSED, void *event_info EINA_UNUSED)
static const Ecore_Getopt optdesc = { static const Ecore_Getopt optdesc = {
"edi_build", "edi_build",
"%prog [options] [build|clean|create|test]", "%prog [options] [build|clean|test|create|example]",
PACKAGE_VERSION, PACKAGE_VERSION,
COPYRIGHT, COPYRIGHT,
"BSD with advertisement clause", "BSD with advertisement clause",
@ -107,9 +107,17 @@ static void
_edi_build_create_start(int argc, int arg0, char **argv) _edi_build_create_start(int argc, int arg0, char **argv)
{ {
elm_init(argc, argv); elm_init(argc, argv);
edi_create_efl_project(argv[arg0 + 1], argv[arg0 + 2], argv[arg0 + 3], edi_create_project(argv[arg0 + 1], argv[arg0 + 2], argv[arg0 + 3],
argv[arg0 + 4], argv[arg0 + 5], argv[arg0 + 6], argv[arg0 + 4], argv[arg0 + 5], argv[arg0 + 6],
_edi_build_create_done_cb); _edi_build_create_done_cb);
}
static void
_edi_build_example_start(int argc, int arg0, char **argv)
{
elm_init(argc, argv);
edi_create_example(argv[arg0 + 1], argv[arg0 + 2], argv[arg0 + 3],
_edi_build_create_done_cb);
} }
EAPI_MAIN int EAPI_MAIN int
@ -165,13 +173,27 @@ main(int argc, char **argv)
if (argc - args != 7) if (argc - args != 7)
{ {
fprintf(stderr, _("create requires 6 additional parameters:\n")); fprintf(stderr, _("create requires 6 additional parameters:\n"));
fprintf(stderr, " skeleton, parent_path, project_name, " fprintf(stderr, " template_name, parent_path, project_name, "
"project_url, creator_name, creator_email\n"); "project_url, creator_name, creator_email\n");
goto end; goto end;
} }
_edi_build_create_start(argc, args, argv); _edi_build_create_start(argc, args, argv);
ecore_main_loop_begin();
goto end;
}
if (!strncmp("example", build_type, 7))
{
if (argc - args != 4)
{
fprintf(stderr, _("example requires 3 additional parameters:\n"));
fprintf(stderr, " example_name, parent_path, project_name\n");
goto end;
}
_edi_build_example_start(argc, args, argv);
ecore_main_loop_begin(); ecore_main_loop_begin();
goto end; goto end;
} }

View File

@ -286,12 +286,14 @@ _edi_language_c_lookup(Edi_Editor *editor, unsigned int row, unsigned int col)
} }
if (name) if (name)
suggest_it->summary = strdup(name); {
suggest_it->detail = _edi_suggest_c_detail_get(editor, name, ret?ret:"", param?param:""); suggest_it->summary = strdup(name);
suggest_it->detail = _edi_suggest_c_detail_get(editor, name, ret?ret:"", param?param:"");
list = eina_list_append(list, suggest_it);
}
if (param) if (param)
free(param); free(param);
list = eina_list_append(list, suggest_it);
} }
clang_disposeCodeCompleteResults(res); clang_disposeCodeCompleteResults(res);
#else #else

View File

@ -16,10 +16,13 @@
typedef struct _Edi_Template typedef struct _Edi_Template
{ {
char *edje_path; char *edje_id;
char *skeleton_path; char *edje_path; // TODO fix
char *path; // file path for skeleton, directory for example
char *title; char *title;
char *desc; char *desc;
Eina_Bool is_template;
} Edi_Template; } Edi_Template;
typedef struct _Edi_Welcome_Data { typedef struct _Edi_Welcome_Data {
@ -31,6 +34,7 @@ typedef struct _Edi_Welcome_Data {
} Edi_Welcome_Data; } Edi_Welcome_Data;
static Eina_List *_available_templates = NULL; static Eina_List *_available_templates = NULL;
static Eina_List *_available_examples = NULL;
static Evas_Object *_welcome_window, *_welcome_naviframe; static Evas_Object *_welcome_window, *_welcome_naviframe;
static Evas_Object *_edi_new_popup; static Evas_Object *_edi_new_popup;
@ -164,7 +168,7 @@ _edi_welcome_project_choose_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNU
static void static void
_edi_welcome_project_new_directory_row_add(const char *text, int row, _edi_welcome_project_new_directory_row_add(const char *text, int row,
Evas_Object *parent) Evas_Object *parent)
{ {
Evas_Object *label, *input; Evas_Object *label, *input;
@ -186,9 +190,9 @@ _edi_welcome_project_new_directory_row_add(const char *text, int row,
_create_inputs[row] = input; _create_inputs[row] = input;
} }
static void static Evas_Object *
_edi_welcome_project_new_input_row_add(const char *text, const char *placeholder, int row, _edi_welcome_project_new_input_row_add(const char *text, const char *placeholder,
Evas_Object *parent) Eina_Bool show, int row, Evas_Object *parent)
{ {
Evas_Object *label, *input; Evas_Object *label, *input;
@ -197,7 +201,8 @@ _edi_welcome_project_new_input_row_add(const char *text, const char *placeholder
evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_table_pack(parent, label, 0, row, 1, 1); elm_table_pack(parent, label, 0, row, 1, 1);
evas_object_show(label); if (show)
evas_object_show(label);
input = elm_entry_add(parent); input = elm_entry_add(parent);
elm_entry_scrollable_set(input, EINA_TRUE); elm_entry_scrollable_set(input, EINA_TRUE);
@ -205,32 +210,106 @@ _edi_welcome_project_new_input_row_add(const char *text, const char *placeholder
evas_object_size_hint_weight_set(input, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_weight_set(input, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(input, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_align_set(input, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_table_pack(parent, input, 1, row, _EDI_WELCOME_PROJECT_NEW_TABLE_WIDTH - 1, 1); elm_table_pack(parent, input, 1, row, _EDI_WELCOME_PROJECT_NEW_TABLE_WIDTH - 1, 1);
evas_object_show(input); if (show)
evas_object_show(input);
if (placeholder) if (placeholder)
{ {
elm_object_text_set(input, placeholder); elm_object_text_set(input, placeholder);
} }
_create_inputs[row] = input; _create_inputs[row] = input;
return input;
}
Edi_Template *
_edi_template_add(const char *templates, const char *groupname)
{
Edi_Template *t;
Evas_Object *group;
Ecore_Evas *evas; // TODO find a way to not need this!
t = malloc(sizeof(Edi_Template));
evas = ecore_evas_buffer_new(0, 0);
group = edje_object_add(ecore_evas_get(evas));
edje_object_file_set(group, templates, groupname);
t->title = strdup(edje_object_data_get(group, "title"));
t->desc = strdup(edje_object_data_get(group, "description"));
t->path = strdup(edje_object_data_get(group, "path"));
t->edje_path = strdup(templates);
t->edje_id = strdup(groupname);
return t;
} }
static void static void
_edi_template_free(Edi_Template *t) _edi_template_free(Edi_Template *t)
{ {
if (t) if (!t)
return;
free(t->title);
free(t->desc);
free(t->edje_path);
free(t->edje_id);
free(t->path);
free(t);
}
static void
_edi_templates_discover(const char *directory)
{
Eina_List *collection, *list;
char path[PATH_MAX];
const char *groupname;
eina_file_path_join(path, sizeof(path), directory, "templates.edj");
if (!ecore_file_exists(path))
return;
collection = edje_file_collection_list(path);
EINA_LIST_FOREACH(collection, list, groupname)
{ {
free(t->title); Edi_Template *template = _edi_template_add(path, groupname);
free(t->desc); if (!template)
free(t->edje_path); continue;
free(t->skeleton_path);
free(t); template->is_template = EINA_TRUE;
_available_templates = eina_list_append(_available_templates, template);
} }
edje_mmap_collection_list_free(collection);
}
static void
_edi_examples_discover(const char *directory)
{
Eina_List *collection, *list;
char path[PATH_MAX];
const char *groupname;
eina_file_path_join(path, sizeof(path), directory, "examples.edj");
if (!ecore_file_exists(path))
return;
collection = edje_file_collection_list(path);
EINA_LIST_FOREACH(collection, list, groupname)
{
Edi_Template *example = _edi_template_add(path, groupname);
if (!example)
continue;
example->is_template = EINA_FALSE;
_available_examples = eina_list_append(_available_examples, example);
}
edje_mmap_collection_list_free(collection);
} }
static void static void
_edi_welcome_project_new_create_done_cb(const char *path, Eina_Bool success) _edi_welcome_project_new_create_done_cb(const char *path, Eina_Bool success)
{ {
Edi_Template *template; Edi_Template *template, *example;
if (!success) if (!success)
{ {
@ -241,51 +320,12 @@ _edi_welcome_project_new_create_done_cb(const char *path, Eina_Bool success)
EINA_LIST_FREE(_available_templates, template) EINA_LIST_FREE(_available_templates, template)
_edi_template_free(template); _edi_template_free(template);
EINA_LIST_FREE(_available_examples, example)
_edi_template_free(example);
_edi_welcome_project_open(path, EINA_TRUE); _edi_welcome_project_open(path, EINA_TRUE);
} }
Edi_Template *
_edi_template_add(const char *directory, const char *file)
{
Edi_Template *t;
char *path = edi_path_append(directory, file);
if (!ecore_file_exists(path))
return NULL;
t = malloc(sizeof(Edi_Template));
t->title = edje_file_data_get(path, "title");
t->desc = edje_file_data_get(path, "description");
t->skeleton_path = edi_path_append(directory, edje_file_data_get(path, "file"));
t->edje_path = path;
return t;
}
static void
_edi_templates_discover(const char *directory)
{
Eina_List *files;
char *file;
files = ecore_file_ls(directory);
EINA_LIST_FREE(files, file)
{
if (eina_str_has_extension(file, ".edj"))
{
Edi_Template *template = _edi_template_add(directory, file);
if (template)
_available_templates = eina_list_append(_available_templates, template);
}
free(file);
}
if (files)
eina_list_free(files);
}
static void static void
_edi_welcome_project_new_create_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) _edi_welcome_project_new_create_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{ {
@ -300,16 +340,20 @@ _edi_welcome_project_new_create_cb(void *data EINA_UNUSED, Evas_Object *obj EINA
user = elm_object_text_get(_create_inputs[3]); user = elm_object_text_get(_create_inputs[3]);
email = elm_object_text_get(_create_inputs[4]); email = elm_object_text_get(_create_inputs[4]);
if (template && path && path[0] && name && name[0]) if (path && path[0] && name && name[0])
{ {
edi_create_efl_project(template->skeleton_path, path, name, url, user, email, if (!template->is_template)
_edi_welcome_project_new_create_done_cb); edi_create_example(template->path, path, name,
_edi_welcome_project_new_create_done_cb);
else
edi_create_project(template->path, path, name, url, user, email,
_edi_welcome_project_new_create_done_cb);
} }
else else
{ {
if (path && !path[0]) if (!path || !path[0])
elm_object_focus_set(_create_inputs[0], EINA_TRUE); elm_object_focus_set(_create_inputs[0], EINA_TRUE);
else if (name && !name[0]) else if (!name || !name[0])
elm_object_focus_set(_create_inputs[1], EINA_TRUE); elm_object_focus_set(_create_inputs[1], EINA_TRUE);
} }
} }
@ -348,7 +392,7 @@ _edi_welcome_user_fullname_get(const char *username, char *fullname, size_t max)
static void static void
_edi_welcome_project_details(Evas_Object *naviframe, Edi_Template *template) _edi_welcome_project_details(Evas_Object *naviframe, Edi_Template *template)
{ {
Evas_Object *content, *button; Evas_Object *content, *button, *input;
Elm_Object_Item *item; Elm_Object_Item *item;
int row = 0; int row = 0;
char fullname[1024]; char fullname[1024];
@ -363,13 +407,16 @@ _edi_welcome_project_details(Evas_Object *naviframe, Edi_Template *template)
if (!username) if (!username)
username = getenv("USERNAME"); username = getenv("USERNAME");
_edi_welcome_project_new_directory_row_add(_("Parent Path"), row++, content); _edi_welcome_project_new_directory_row_add(_("Parent Path"), row++, content);
_edi_welcome_project_new_input_row_add(_("Project Name"), NULL, row++, content); input = _edi_welcome_project_new_input_row_add(_("Project Name"), NULL, EINA_TRUE, row++, content);
_edi_welcome_project_new_input_row_add(_("Project URL"), NULL, row++, content); if (!template->is_template)
elm_object_text_set(input, template->edje_id);
_edi_welcome_project_new_input_row_add(_("Project URL"), NULL, template->is_template, row++, content);
if (_edi_welcome_user_fullname_get(username, fullname, sizeof(fullname))) if (_edi_welcome_user_fullname_get(username, fullname, sizeof(fullname)))
_edi_welcome_project_new_input_row_add(_("Creator Name"), fullname, row++, content); _edi_welcome_project_new_input_row_add(_("Creator Name"), fullname, template->is_template, row++, content);
else else
_edi_welcome_project_new_input_row_add(_("Creator Name"), username, row++, content); _edi_welcome_project_new_input_row_add(_("Creator Name"), username, template->is_template, row++, content);
_edi_welcome_project_new_input_row_add(_("Creator Email"), NULL, row++, content); _edi_welcome_project_new_input_row_add(_("Creator Email"), NULL, template->is_template, row++, content);
button = elm_button_add(content); button = elm_button_add(content);
elm_object_text_set(button, _("Create")); elm_object_text_set(button, _("Create"));
@ -429,7 +476,7 @@ _content_get(void *data, Evas_Object *obj, const char *source)
evas_object_size_hint_weight_set(image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_weight_set(image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(image, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_align_set(image, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_min_set(image, 96 * elm_config_scale_get(), 96 * elm_config_scale_get()); evas_object_size_hint_min_set(image, 96 * elm_config_scale_get(), 96 * elm_config_scale_get());
elm_image_file_set(image, template->edje_path, "logo"); elm_image_file_set(image, template->edje_path, template->edje_id);
evas_object_show(image); evas_object_show(image);
elm_table_pack(table, image, 0, 0, 1, 1); elm_table_pack(table, image, 0, 0, 1, 1);
@ -449,6 +496,12 @@ _content_get(void *data, Evas_Object *obj, const char *source)
return frame; return frame;
} }
static char *
_header_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *source EINA_UNUSED)
{
return strdup((char *)data);
}
static void static void
_edi_welcome_project_new_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) _edi_welcome_project_new_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{ {
@ -456,19 +509,16 @@ _edi_welcome_project_new_cb(void *data, Evas_Object *obj EINA_UNUSED, void *even
Evas_Object *content, *button, *naviframe; Evas_Object *content, *button, *naviframe;
Evas_Object *table, *list, *rect, *hbox; Evas_Object *table, *list, *rect, *hbox;
Elm_Object_Item *item; Elm_Object_Item *item;
Edi_Template *template; Edi_Template *template, *example;
Elm_Genlist_Item_Class *itc; Elm_Genlist_Item_Class *ith, *itc;
char path[PATH_MAX];
naviframe = (Evas_Object *) data; naviframe = (Evas_Object *) data;
EINA_LIST_FREE(_available_templates, template) EINA_LIST_FREE(_available_templates, template)
_edi_template_free(template); _edi_template_free(template);
snprintf(path, sizeof(path), "%s/templates", _edi_config_dir_get());
_edi_templates_discover(PACKAGE_DATA_DIR "/templates"); _edi_templates_discover(PACKAGE_DATA_DIR "/templates");
_edi_templates_discover(path); _edi_examples_discover(PACKAGE_DATA_DIR "/examples");
content = elm_box_add(naviframe); content = elm_box_add(naviframe);
evas_object_size_hint_weight_set(content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_weight_set(content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@ -503,6 +553,12 @@ _edi_welcome_project_new_cb(void *data, Evas_Object *obj EINA_UNUSED, void *even
elm_table_pack(table, list, 0, 0, 1, 1); elm_table_pack(table, list, 0, 0, 1, 1);
elm_box_pack_end(hbox, table); elm_box_pack_end(hbox, table);
ith = elm_genlist_item_class_new();
ith->item_style = "group_index";
ith->func.text_get = _header_text_get;
ith->func.del = NULL;
elm_genlist_item_append(list, ith, _("Templates"), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
itc = elm_genlist_item_class_new(); itc = elm_genlist_item_class_new();
itc->item_style = "full"; itc->item_style = "full";
itc->func.text_get = NULL; itc->func.text_get = NULL;
@ -513,6 +569,11 @@ _edi_welcome_project_new_cb(void *data, Evas_Object *obj EINA_UNUSED, void *even
EINA_LIST_FOREACH(_available_templates, l, template) EINA_LIST_FOREACH(_available_templates, l, template)
elm_genlist_item_append(list, itc, template, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); elm_genlist_item_append(list, itc, template, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
elm_genlist_item_append(list, ith, _("Examples"), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
EINA_LIST_FOREACH(_available_examples, l, example)
elm_genlist_item_append(list, itc, example, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
elm_genlist_realized_items_update(list); elm_genlist_realized_items_update(list);
elm_genlist_item_class_free(itc); elm_genlist_item_class_free(itc);
@ -615,9 +676,9 @@ _edi_welcome_project_clone_cb(void *data, Evas_Object *obj EINA_UNUSED, void *ev
evas_object_size_hint_weight_set(content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_weight_set(content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(content); evas_object_show(content);
_edi_welcome_project_new_input_row_add(_("Source Control URL"), NULL, row++, content); _edi_welcome_project_new_input_row_add(_("Source Control URL"), NULL, EINA_TRUE, row++, content);
_edi_welcome_project_new_directory_row_add(_("Parent Path"), row++, content); _edi_welcome_project_new_directory_row_add(_("Parent Path"), row++, content);
_edi_welcome_project_new_input_row_add(_("Project Name"), NULL, row++, content); _edi_welcome_project_new_input_row_add(_("Project Name"), NULL, EINA_TRUE, row++, content);
pb = elm_progressbar_add(content); pb = elm_progressbar_add(content);
evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5); evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5);

View File

@ -10,6 +10,8 @@
#include "edi_private.h" #include "edi_private.h"
#define EXAMPLES_GIT_URL "https://git.enlightenment.org/tools/examples.git"
typedef struct _Edi_Create typedef struct _Edi_Create
{ {
char *path, *temp, *name, *skelfile; char *path, *temp, *name, *skelfile;
@ -21,6 +23,15 @@ typedef struct _Edi_Create
int filters; int filters;
} Edi_Create; } Edi_Create;
typedef struct _Edi_Create_Example
{
char *path, *name;
Edi_Create_Cb callback;
} Edi_Create_Example;
static Edi_Create *_edi_create_data; static Edi_Create *_edi_create_data;
static const char * static const char *
@ -298,12 +309,12 @@ _edi_create_extract_done(void *data, int type EINA_UNUSED, void *event EINA_UNUS
} }
EAPI void EAPI void
edi_create_efl_project(const char *skelpath, const char *parentdir, edi_create_project(const char *template_name, const char *parentdir,
const char *name, const char *url, const char *user, const char *name, const char *url, const char *user,
const char *email, Edi_Create_Cb func) const char *email, Edi_Create_Cb func)
{ {
char *cmd, *extract; char *cmd, *extract;
char tmp[PATH_MAX], dest[PATH_MAX]; char tmp[PATH_MAX], dest[PATH_MAX], skelpath[PATH_MAX];
Edi_Create *data; Edi_Create *data;
Ecore_Event_Handler *handler; Ecore_Event_Handler *handler;
@ -311,6 +322,8 @@ edi_create_efl_project(const char *skelpath, const char *parentdir,
snprintf(tmp, sizeof(tmp), "%s/edi_%s", eina_environment_tmp_get(), name); snprintf(tmp, sizeof(tmp), "%s/edi_%s", eina_environment_tmp_get(), name);
snprintf(dest, sizeof(dest), "%s/%s", parentdir, name); snprintf(dest, sizeof(dest), "%s/%s", parentdir, name);
snprintf(skelpath, sizeof(skelpath), PACKAGE_DATA_DIR "/templates/%s.tar.gz", template_name);
INF("Creating project \"%s\" at path %s for %s<%s>\n", name, dest, user, email); INF("Creating project \"%s\" at path %s for %s<%s>\n", name, dest, user, email);
DBG("Extracting project files from %s\n", skelpath); DBG("Extracting project files from %s\n", skelpath);
@ -343,3 +356,61 @@ edi_create_efl_project(const char *skelpath, const char *parentdir,
free(cmd); free(cmd);
} }
static void
_edi_create_example_done_cb(void *data, Eio_File *file EINA_UNUSED)
{
Edi_Create_Example *create = data;
if (create->callback)
create->callback(create->path, EINA_TRUE);
}
static void
_edi_create_example_extract_dir(char *examples_path, Edi_Create_Example *create)
{
char path[PATH_MAX];
eina_file_path_join(path, sizeof(path), examples_path, create->name);
eio_dir_copy(path, create->path, NULL, NULL, _edi_create_example_done_cb,
_edi_create_error_cb, create);
free(examples_path);
}
EAPI void
edi_create_example(const char *example_name, const char *parentdir,
const char *name, Edi_Create_Cb func)
{
char dest[PATH_MAX], examplepath[PATH_MAX];
int status = 0;
Edi_Create_Example *data;
snprintf(dest, sizeof(dest), "%s/%s", parentdir, name);
snprintf(examplepath, sizeof(examplepath), "%s/%s/examples.git",
efreet_cache_home_get(), PACKAGE_NAME);
data = calloc(1, sizeof(Edi_Create_Example));
data->path = strdup(dest);
data->name = strdup(example_name);
data->callback = func;
INF("Extracting example project \"%s\" at path %s\n", example_name, dest);
if (ecore_file_exists(examplepath))
ERR("TODO: UPDATE NOT IMPLEMENTED");
// status = edi_scm_git_update(examplepath);
else
status = edi_scm_git_clone(EXAMPLES_GIT_URL, examplepath);
if (status)
{
ERR("git error: [%d]\n", status);
if (func)
func(dest, EINA_FALSE);
}
else
_edi_create_example_extract_dir(strdup(examplepath), data);
}

View File

@ -23,14 +23,23 @@ typedef void (*Edi_Create_Cb)(const char *path, Eina_Bool success);
*/ */
/** /**
* Create a new standard EFL project. * Create a new project from an Edi template.
* *
* @ingroup Creation * @ingroup Creation
*/ */
EAPI void EAPI void
edi_create_efl_project(const char *skelpath, const char *parentdir, edi_create_project(const char *template_name, const char *parentdir,
const char *name, const char *url, const char *user, const char *name, const char *url, const char *user,
const char *email, Edi_Create_Cb func); const char *email, Edi_Create_Cb func);
/**
* Create a new project from an example.
*
* @ingroup Creation
*/
EAPI void
edi_create_example(const char *example_name, const char *parentdir,
const char *name, Edi_Create_Cb func);
/** /**
* @} * @}

View File

@ -1,6 +1,9 @@
#ifndef EDI_PRIVATE_H #ifndef EDI_PRIVATE_H
# define EDI_PRIVATE_H # define EDI_PRIVATE_H
#include <Eina.h>
#include <Efreet.h>
extern int _edi_lib_log_dom; extern int _edi_lib_log_dom;
char *edi_create_escape_quotes(const char *in); char *edi_create_escape_quotes(const char *in);