forked from enlightenment/edi
examples: refactor template code to work for examples too
This commit is contained in:
parent
3497aee535
commit
305c7c4b43
|
@ -5,7 +5,7 @@ collections {
|
||||||
|
|
||||||
data {
|
data {
|
||||||
item: "title" "C EFL Beta Hello World";
|
item: "title" "C EFL Beta Hello World";
|
||||||
item: "directory" "tutorials/c/hellogui/";
|
item: "path" "tutorials/c/hellogui/";
|
||||||
item: "description"
|
item: "description"
|
||||||
"Hello World using the EFL Beta APIs";
|
"Hello World using the EFL Beta APIs";
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ collections {
|
||||||
|
|
||||||
data {
|
data {
|
||||||
item: "title" "C EFL Beta Game of Life";
|
item: "title" "C EFL Beta Game of Life";
|
||||||
item: "directory" "apps/c/life/";
|
item: "path" "apps/c/life/";
|
||||||
item: "description"
|
item: "description"
|
||||||
"Game of Life using the EFL Beta APIs";
|
"Game of Life using the EFL Beta APIs";
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ collections {
|
||||||
|
|
||||||
data {
|
data {
|
||||||
item: "title" "C EFL Beta Basic Text Editor";
|
item: "title" "C EFL Beta Basic Text Editor";
|
||||||
item: "directory" "apps/c/texteditor/";
|
item: "path" "apps/c/texteditor/";
|
||||||
item: "description"
|
item: "description"
|
||||||
"A basic text editor app using the EFL Beta APIs";
|
"A basic text editor app using the EFL Beta APIs";
|
||||||
}
|
}
|
||||||
|
|
|
@ -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";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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, meta + '.edj')
|
out = join_paths(get_option('prefix'), template_dir, 'templates.edj')
|
||||||
meson.add_install_script('../../../scripts/world_read.sh', out)
|
meson.add_install_script('../../../scripts/world_read.sh', out)
|
||||||
endforeach
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
collections {
|
||||||
|
group {
|
||||||
|
name: "eflproject";
|
||||||
|
max: 128 128;
|
||||||
|
|
||||||
|
data {
|
||||||
|
item: "title" "C EFL Project";
|
||||||
|
item: "path" "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!";
|
||||||
|
}
|
||||||
|
|
||||||
|
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" "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.";
|
||||||
|
}
|
||||||
|
|
||||||
|
parts {
|
||||||
|
part { name: "icon";
|
||||||
|
description { state: "default" 0.0;
|
||||||
|
max: 128 128;
|
||||||
|
images.image: "python.png" COMP;
|
||||||
|
image.normal: "python.png";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,21 +15,15 @@
|
||||||
#define _EDI_WELCOME_PROJECT_NEW_TABLE_WIDTH 4
|
#define _EDI_WELCOME_PROJECT_NEW_TABLE_WIDTH 4
|
||||||
|
|
||||||
typedef struct _Edi_Template
|
typedef struct _Edi_Template
|
||||||
{
|
|
||||||
char *edje_path;
|
|
||||||
char *skeleton_path;
|
|
||||||
char *title;
|
|
||||||
char *desc;
|
|
||||||
} Edi_Template;
|
|
||||||
|
|
||||||
typedef struct _Edi_Example
|
|
||||||
{
|
{
|
||||||
char *edje_id;
|
char *edje_id;
|
||||||
char *edje_path;
|
char *edje_path; // TODO fix
|
||||||
char *example_path;
|
char *path; // file path for skeleton, directory for example
|
||||||
char *title;
|
char *title;
|
||||||
char *desc;
|
char *desc;
|
||||||
} Edi_Example;
|
|
||||||
|
Eina_Bool is_template;
|
||||||
|
} Edi_Template;
|
||||||
|
|
||||||
typedef struct _Edi_Welcome_Data {
|
typedef struct _Edi_Welcome_Data {
|
||||||
Evas_Object *pb;
|
Evas_Object *pb;
|
||||||
|
@ -196,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;
|
||||||
|
|
||||||
|
@ -225,19 +219,22 @@ _edi_welcome_project_new_input_row_add(const char *text, const char *placeholder
|
||||||
}
|
}
|
||||||
|
|
||||||
Edi_Template *
|
Edi_Template *
|
||||||
_edi_template_add(const char *directory, const char *file)
|
_edi_template_add(const char *templates, const char *groupname)
|
||||||
{
|
{
|
||||||
Edi_Template *t;
|
Edi_Template *t;
|
||||||
char *path = edi_path_append(directory, file);
|
Evas_Object *group;
|
||||||
|
Ecore_Evas *evas; // TODO find a way to not need this!
|
||||||
if (!ecore_file_exists(path))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
t = malloc(sizeof(Edi_Template));
|
t = malloc(sizeof(Edi_Template));
|
||||||
t->title = edje_file_data_get(path, "title");
|
evas = ecore_evas_buffer_new(0, 0);
|
||||||
t->desc = edje_file_data_get(path, "description");
|
group = edje_object_add(ecore_evas_get(evas));
|
||||||
t->skeleton_path = edi_path_append(directory, edje_file_data_get(path, "file"));
|
edje_object_file_set(group, templates, groupname);
|
||||||
t->edje_path = path;
|
|
||||||
|
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;
|
return t;
|
||||||
}
|
}
|
||||||
|
@ -251,67 +248,34 @@ _edi_template_free(Edi_Template *t)
|
||||||
free(t->title);
|
free(t->title);
|
||||||
free(t->desc);
|
free(t->desc);
|
||||||
free(t->edje_path);
|
free(t->edje_path);
|
||||||
free(t->skeleton_path);
|
free(t->edje_id);
|
||||||
|
free(t->path);
|
||||||
free(t);
|
free(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_edi_templates_discover(const char *directory)
|
_edi_templates_discover(const char *directory)
|
||||||
{
|
{
|
||||||
Eina_List *files;
|
Eina_List *collection, *list;
|
||||||
char *file;
|
char path[PATH_MAX];
|
||||||
|
const char *groupname;
|
||||||
|
|
||||||
files = ecore_file_ls(directory);
|
eina_file_path_join(path, sizeof(path), directory, "templates.edj");
|
||||||
EINA_LIST_FREE(files, file)
|
if (!ecore_file_exists(path))
|
||||||
|
return;
|
||||||
|
|
||||||
|
collection = edje_file_collection_list(path);
|
||||||
|
EINA_LIST_FOREACH(collection, list, groupname)
|
||||||
{
|
{
|
||||||
if (eina_str_has_extension(file, ".edj"))
|
Edi_Template *template = _edi_template_add(path, groupname);
|
||||||
{
|
if (!template)
|
||||||
Edi_Template *template = _edi_template_add(directory, file);
|
continue;
|
||||||
if (template)
|
|
||||||
|
template->is_template = EINA_TRUE;
|
||||||
_available_templates = eina_list_append(_available_templates, template);
|
_available_templates = eina_list_append(_available_templates, template);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(file);
|
edje_mmap_collection_list_free(collection);
|
||||||
}
|
|
||||||
|
|
||||||
if (files)
|
|
||||||
eina_list_free(files);
|
|
||||||
}
|
|
||||||
|
|
||||||
Edi_Example *
|
|
||||||
_edi_example_add(const char *examples, const char *groupname)
|
|
||||||
{
|
|
||||||
Edi_Example *e;
|
|
||||||
Evas_Object *group;
|
|
||||||
Ecore_Evas *evas; // TODO find a way to not need this!
|
|
||||||
|
|
||||||
e = malloc(sizeof(Edi_Example));
|
|
||||||
evas = ecore_evas_buffer_new(0, 0);
|
|
||||||
group = edje_object_add(ecore_evas_get(evas));
|
|
||||||
edje_object_file_set(group, examples, groupname);
|
|
||||||
|
|
||||||
e->title = strdup(edje_object_data_get(group, "title"));
|
|
||||||
e->desc = strdup(edje_object_data_get(group, "description"));
|
|
||||||
e->example_path = strdup(edje_object_data_get(group, "directory"));
|
|
||||||
e->edje_path = strdup(examples);
|
|
||||||
e->edje_id = strdup(groupname);
|
|
||||||
|
|
||||||
ecore_evas_free(evas);
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_edi_example_free(Edi_Example *e)
|
|
||||||
{
|
|
||||||
if (!e)
|
|
||||||
return;
|
|
||||||
|
|
||||||
free(e->title);
|
|
||||||
free(e->desc);
|
|
||||||
free(e->edje_path);
|
|
||||||
free(e->edje_id);
|
|
||||||
free(e->example_path);
|
|
||||||
free(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -328,8 +292,11 @@ _edi_examples_discover(const char *directory)
|
||||||
collection = edje_file_collection_list(path);
|
collection = edje_file_collection_list(path);
|
||||||
EINA_LIST_FOREACH(collection, list, groupname)
|
EINA_LIST_FOREACH(collection, list, groupname)
|
||||||
{
|
{
|
||||||
Edi_Example *example = _edi_example_add(path, groupname);
|
Edi_Template *example = _edi_template_add(path, groupname);
|
||||||
if (example)
|
if (!example)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
example->is_template = EINA_FALSE;
|
||||||
_available_examples = eina_list_append(_available_examples, example);
|
_available_examples = eina_list_append(_available_examples, example);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,8 +306,7 @@ _edi_examples_discover(const char *directory)
|
||||||
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;
|
||||||
Edi_Example *example;
|
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
|
@ -352,7 +318,7 @@ _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)
|
EINA_LIST_FREE(_available_examples, example)
|
||||||
_edi_example_free(example);
|
_edi_template_free(example);
|
||||||
|
|
||||||
_edi_welcome_project_open(path, EINA_TRUE);
|
_edi_welcome_project_open(path, EINA_TRUE);
|
||||||
}
|
}
|
||||||
|
@ -500,7 +466,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);
|
||||||
|
|
||||||
|
@ -526,54 +492,6 @@ _header_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *source EI
|
||||||
return strdup((char *)data);
|
return strdup((char *)data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
|
||||||
_example_content_get(void *data, Evas_Object *obj, const char *source)
|
|
||||||
{
|
|
||||||
Evas_Object *frame, *table, *image, *entry;
|
|
||||||
Edi_Example *example = (Edi_Example *) data;
|
|
||||||
Eina_Slstr *content;
|
|
||||||
|
|
||||||
if (strcmp(source, "elm.swallow.content"))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
frame = elm_frame_add(obj);
|
|
||||||
elm_object_style_set(frame, "pad_medium");
|
|
||||||
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
||||||
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
||||||
evas_object_show(frame);
|
|
||||||
|
|
||||||
table = elm_table_add(obj);
|
|
||||||
evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
||||||
evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
||||||
elm_table_padding_set(table, 5, 5);
|
|
||||||
elm_table_homogeneous_set(table, EINA_TRUE);
|
|
||||||
evas_object_show(table);
|
|
||||||
elm_object_content_set(frame, table);
|
|
||||||
|
|
||||||
image = elm_image_add(table);
|
|
||||||
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_min_set(image, 96 * elm_config_scale_get(), 96 * elm_config_scale_get());
|
|
||||||
elm_image_file_set(image, example->edje_path, example->edje_id);
|
|
||||||
evas_object_show(image);
|
|
||||||
elm_table_pack(table, image, 0, 0, 1, 1);
|
|
||||||
|
|
||||||
entry = elm_entry_add(table);
|
|
||||||
evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
||||||
evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
||||||
elm_entry_editable_set(entry, EINA_FALSE);
|
|
||||||
elm_entry_scrollable_set(entry, EINA_FALSE);
|
|
||||||
elm_entry_single_line_set(entry, EINA_FALSE);
|
|
||||||
elm_entry_line_wrap_set(entry, ELM_WRAP_WORD);
|
|
||||||
elm_table_pack(table, entry, 1, 0, 3, 1);
|
|
||||||
evas_object_show(entry);
|
|
||||||
|
|
||||||
content = eina_slstr_printf("<b>%s</b><br><br>%s", example->title, example->desc);
|
|
||||||
elm_object_text_set(entry, content);
|
|
||||||
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -581,10 +499,9 @@ _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_Example *example;
|
|
||||||
Elm_Genlist_Item_Class *ith, *itc, *itc2;
|
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
|
Edi_Template *template, *example;
|
||||||
|
Elm_Genlist_Item_Class *ith, *itc;
|
||||||
|
|
||||||
naviframe = (Evas_Object *) data;
|
naviframe = (Evas_Object *) data;
|
||||||
|
|
||||||
|
@ -650,19 +567,8 @@ _edi_welcome_project_new_cb(void *data, Evas_Object *obj EINA_UNUSED, void *even
|
||||||
|
|
||||||
elm_genlist_item_append(list, ith, _("Examples"), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
elm_genlist_item_append(list, ith, _("Examples"), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
||||||
|
|
||||||
itc2 = elm_genlist_item_class_new();
|
|
||||||
itc2->item_style = "full";
|
|
||||||
itc2->func.text_get = NULL;
|
|
||||||
itc2->func.content_get = _example_content_get;
|
|
||||||
itc2->func.state_get = NULL;
|
|
||||||
itc2->func.del = NULL;
|
|
||||||
EINA_LIST_FOREACH(_available_examples, l, example)
|
EINA_LIST_FOREACH(_available_examples, l, example)
|
||||||
{
|
elm_genlist_item_append(list, itc, example, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
||||||
Elm_Widget_Item *item;
|
|
||||||
|
|
||||||
item = elm_genlist_item_append(list, itc2, example, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
|
||||||
elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_NONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
elm_genlist_realized_items_update(list);
|
elm_genlist_realized_items_update(list);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue