#include <sys/types.h>
#include <dirent.h>
#include <error.h>
+#include <algorithm>
using namespace std;
int index;
};
-Eina_List *jsonFiles;
+
+std::vector<std::string> jsonFiles;
bool renderMode = true;
static void
}
Evas_Object *
-create_layout(Evas_Object *parent, char *file)
+create_layout(Evas_Object *parent, const char *file)
{
Evas_Object *layout, *slider, *image, *button;
Evas *e;
Elm_Object_Item *it = (Elm_Object_Item *)event_info;
elm_genlist_item_selected_set(it, EINA_FALSE);
- Evas_Object *layout = create_layout(nf, (char *)eina_list_nth(jsonFiles, (elm_genlist_item_index_get(it) - 1)));
+ Evas_Object *layout = create_layout(nf, jsonFiles[elm_genlist_item_index_get(it) - 1].c_str());
elm_naviframe_item_push(nf, NULL, NULL, NULL, layout, NULL);
}
_gl_text_get(void *data, Evas_Object *obj, const char *part)
{
ItemData *id = (ItemData *) data;
- char *str = (char *)eina_list_nth(jsonFiles, id->index);
- return strdup(str);
+ return strdup(jsonFiles[id->index].c_str());
}
static void
ItemData *itemData;
DIR *dir;
struct dirent *ent;
- int i, fileCount = 0;
if (argc > 1) {
if (!strcmp(argv[1], "--disable-render"))
dir = opendir(rscPath.c_str());
while ((ent = readdir(dir)) != NULL) {
if (!strncmp(ent->d_name + (strlen(ent->d_name) - 4), "json", 4)) {
- jsonFiles = eina_list_append(jsonFiles, strdup(ent->d_name));
- fileCount++;
+ jsonFiles.push_back(ent->d_name);
}
}
closedir(dir);
- for (i = 0; i < fileCount; i++) {
+ std::sort(jsonFiles.begin(), jsonFiles.end(), [](auto & a, auto &b){return a < b;});
+
+ for (uint i = 0; i < jsonFiles.size(); i++) {
itemData = (ItemData *)calloc(sizeof(ItemData), 1);
itemData->index = i;
elm_genlist_item_append(genlist, itc, (void *)itemData, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);