summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlliver Schinagl <o.schinagl@ultimaker.com>2015-04-01 06:21:44 (GMT)
committerOlliver Schinagl <o.schinagl@ultimaker.com>2015-04-28 05:07:13 (GMT)
commit047563d8e38634f3005e390957cb201ca497cfd3 (patch)
treed1865af76ec6d8dc1fc941a9c465704519845155
parentabc5fb57f0ba86effe610c284d21092ea28fdbaa (diff)
downloadeulogium-047563d8e38634f3005e390957cb201ca497cfd3.zip
eulogium-047563d8e38634f3005e390957cb201ca497cfd3.tar.gz
eulogium-047563d8e38634f3005e390957cb201ca497cfd3.tar.bz2
Add very basic file filter
Signed-off-by: Olliver Schinagl <o.schinagl@ultimaker.com>
-rw-r--r--src/eulogium.c58
-rw-r--r--src/eulogium.h3
2 files changed, 53 insertions, 8 deletions
diff --git a/src/eulogium.c b/src/eulogium.c
index 18e3549..4ad8947 100644
--- a/src/eulogium.c
+++ b/src/eulogium.c
@@ -39,6 +39,7 @@ void eulogium_print_file_set(struct eulogium_data *eulogium, char *filepath)
{
if (filepath && eulogium)
eulogium->print.file = filepath;
+ eulogium->print.name = ecore_file_strip_ext(ecore_file_file_get(filepath));
}
/* test function to map try to mouse button to emit a click event */
@@ -106,14 +107,17 @@ Evas_Object *eulogium_print_progress(struct eulogium_data *eulogium)
elm_table_pack(table, object, 0, 0, 3, 1);
object = elm_label_add(table);
- elm_object_text_set(object, "Random info.");
+ elm_object_text_set(object, "Preparing to print:");
evas_object_size_hint_weight_set(object, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(object, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(object);
elm_table_pack(table, object, 0, 1, 3, 1);
object = elm_label_add(table);
- elm_object_text_set(object, "File: \%s.");
+ elm_object_text_set(object, eulogium->print.name);
+ elm_label_slide_mode_set(object, ELM_LABEL_SLIDE_MODE_AUTO);
+ elm_label_slide_duration_set(object, 8);
+ elm_object_style_set(object, "slide_bounce");
evas_object_size_hint_weight_set(object, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(object, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(object);
@@ -174,6 +178,14 @@ elm_progressbar_value_set(eulogium->print.progress, 0.5);
evas_object_show(object);
elm_table_pack(table, object, 2, 5, 1, 1);
+ object = elm_label_add(table);
+ elm_object_text_set(object, "Mat: %%d meter");
+ evas_object_size_hint_weight_set(object, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(object, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(object);
+ elm_table_pack(table, object, 0, 6, 3, 1);
+
+
return table;
}
@@ -219,6 +231,28 @@ static int _cb_dirfile_sort(const void *data1, const void *data2)
return strcoll(filepath1, filepath2);
}
+char *ecore_file_ext_get(const char *path)
+{
+ char *p, *file = NULL;
+
+ p = strrchr(path, '.');
+ if ((!path) || (!p))
+ return NULL;
+ else if (p != path) {
+ int l = strlen(p);
+
+
+ if (l < 2)
+ return NULL;
+ file = malloc(strlen(p) * sizeof(char));
+ if (file) {
+ memcpy(file, &p[1], l);
+ }
+ }
+
+ return file;
+}
+
static void _cb_populate_filelist(const char *name, const char *path, void *data)
{
struct eulogium_data *eulogium = data;
@@ -226,21 +260,30 @@ static void _cb_populate_filelist(const char *name, const char *path, void *data
Evas_Object *icon;
Elm_Object_Item *list_item;
char *filepath;
+ char *ext;
uint_fast32_t dir_len;
uint_fast8_t hidden_visible = 1;
struct _filelist_sort *filelist_sort;
if (hidden_visible && (name[0] == '.'))
return;
- if (0//show_only_known //&&
- /* supported extensions */
- )
- return;
+
dir_len = strlen(name) + strlen(path) + sizeof('/') + 1;
filepath = malloc(dir_len);
snprintf(filepath, dir_len, "%s/%s", path, name);
+ if (!ecore_file_is_dir(filepath)) {
+ int len;
+
+ ext = ecore_file_ext_get(name);
+ if (!ext)
+ return;
+ len = strlen(ext);
+ if (strncmp(ext, "gcode", len) != 0) /* TODO: compare to array of filetypes/filterlist/mimetype */
+ return;
+ }
+
icon = elm_icon_add(list);
if (ecore_file_is_dir(filepath))
elm_icon_standard_set(icon, "folder");
@@ -300,7 +343,7 @@ Evas_Object *eulogium_print_menu(struct eulogium_data *eulogium, char *filepath)
icon = elm_icon_add(list);
elm_icon_standard_set(icon, "home");
- elm_list_item_prepend(list, "RETURN", icon, NULL, _cb_content_prev_set, eulogium); /* XXX TODO: when we pop the filelist from the stack, who calls elm_list_free();? */
+ elm_list_item_prepend(list, "< RETURN", icon, NULL, _cb_content_prev_set, eulogium); /* XXX TODO: when we pop the filelist from the stack, who calls elm_list_free();? */
elm_list_go(list);
// evas_object_smart_callback_add(list, "edge,bottom", _cb_filelist_bottom, list);
@@ -435,6 +478,7 @@ Evas_Object *eulogium_main_menu(Evas_Object *window, struct eulogium_data *eulog
static void eulogium_setup(struct eulogium_data *eulogium)
{
+ eulogium->print.name = NULL;
eulogium_button_cb_data_set(&but_main_print, eulogium);
eulogium_button_cb_data_set(&but_main_material, eulogium);
eulogium_button_cb_data_set(&but_main_maintanance, eulogium);
diff --git a/src/eulogium.h b/src/eulogium.h
index 47a3778..abd4bd0 100644
--- a/src/eulogium.h
+++ b/src/eulogium.h
@@ -6,7 +6,8 @@
struct print_data {
Evas_Object *progress;
char *status; /* TODO probably an enum for this */
- char *file;
+ const char *file;
+ const char *name;
};
struct eulogium_data {