static void _browser_browse_root(Enna_Browser *browser) { Eina_List *l; Enna_Class_Activity *act; Enna_Buffer *buf; Enna_File *f; EINA_LIST_FOREACH(enna_activities_get(), l, act) { f = calloc(1, sizeof(Enna_File)); buf = enna_buffer_new(); enna_buffer_appendf(buf, "/%s", act->name); f->name = eina_stringshare_add(act->name); f->uri = eina_stringshare_add(buf->buf); enna_buffer_free(buf); f->label = eina_stringshare_add(act->label); f->icon = eina_stringshare_add(act->icon); f->icon_file = eina_stringshare_add(act->bg); f->type = ENNA_FILE_MENU; browser->files = eina_list_append(browser->files, f); if (browser->add) browser->add(browser->add_data, f); }
const char * enna_util_duration_to_string(const char *length) { const char *str; Enna_Buffer *buf; int hh = 0; int mm = 0; int ss = 0; hh = (int) (atoi(length) / 3600 / 1000); mm = (int) ((atoi(length) / 60 / 1000) - (60 * hh)); ss = (int) ((atoi(length) / 1000) - (60 * mm) - (3600 * hh)); buf = enna_buffer_new(); if (hh) enna_buffer_appendf(buf, "%.2dh", hh); if (mm) enna_buffer_appendf(buf, "%.2d:", mm); enna_buffer_appendf(buf, "%.2d", ss); str = eina_stringshare_add(buf->buf); enna_buffer_free(buf); return str; }
/* ecore timer callback */ static Eina_Bool _update_infos_cb(void *data) { Enna_Buffer *b; Evas_Object *obj; obj = data; b = enna_buffer_new(); set_enna_information(b); set_system_information(b); edje_object_part_text_set(obj, "sysinfo.text", b->buf); edje_object_signal_emit(obj, "sysinfo,show", "enna"); enna_buffer_free(b); return ECORE_CALLBACK_RENEW; }
char * enna_util_tuple_set (Eina_List *tuple, const char *delimiter) { char *buf; Enna_Buffer *b; char *c; Eina_List *l; if (!tuple || !delimiter) return NULL; b = enna_buffer_new(); EINA_LIST_FOREACH(tuple, l, c) { if (b->len > 0) enna_buffer_append(b, delimiter); enna_buffer_append(b, c); } buf = strdup(b->buf); enna_buffer_free(b); return buf; }
void enna_panel_infos_set_text(Evas_Object *obj, Enna_Metadata *m) { Enna_Buffer *buf; const char *codec, *value; const char *alternative_title, *title, *categories, *year; const char *length, *director, *actors, *overview; Smart_Data *sd = evas_object_data_get(obj, "sd"); int len; if (!sd) return; if (!m) { edje_object_part_text_set(sd->o_edje, "panel.textblock", _("No such information ...")); return; } buf = enna_buffer_new(); enna_buffer_append(buf, "<h4><hl><sd><b>"); alternative_title = enna_metadata_meta_get(m, "alternative_title", 1); title = enna_metadata_meta_get(m, "title", 1); enna_buffer_append(buf, alternative_title ? alternative_title : title); enna_buffer_append(buf, "</b></sd></hl></h4><br>"); len = buf->len; categories = enna_metadata_meta_get(m, "category", 5); if (categories) enna_buffer_appendf(buf, "<h2>%s</h2><br>", categories); year = enna_metadata_meta_get(m, "year", 1); if (year) enna_buffer_append(buf, year); length = enna_metadata_meta_duration_get(m); if (length) { if (year) enna_buffer_append(buf, " - "); enna_buffer_appendf(buf, "%s", length); } enna_buffer_append(buf, "<br><br>"); len += 8; director = enna_metadata_meta_get(m, "director", 1); if (director) { enna_buffer_append(buf, "<ul>"); enna_buffer_append(buf, _("Director:")); enna_buffer_appendf(buf, " </ul> %s<br>", director); } actors = enna_metadata_meta_get(m, "actor", 5); if (actors) { enna_buffer_append(buf, "<ul>"); enna_buffer_append(buf, _("Cast:")); enna_buffer_appendf(buf, " </ul> %s<br>", actors); } if (director || actors) enna_buffer_append(buf, "<br>"); overview = enna_metadata_meta_get(m, "synopsis", 1); if (overview) enna_buffer_appendf(buf, "%s", overview); enna_buffer_append(buf, "<br><br>"); len += 8; codec = enna_metadata_meta_get(m, "video_codec", 1); if (codec) { const char *width, *height, *aspect; width = enna_metadata_meta_get(m, "width", 1); height = enna_metadata_meta_get(m, "height", 1); aspect = enna_metadata_meta_get(m, "video_aspect", 1); enna_buffer_append(buf, "<hl>"); enna_buffer_append(buf, _("Video:")); enna_buffer_appendf(buf, " </hl> %s", codec); if (width && height) enna_buffer_appendf(buf, ", %sx%s", width, height); if (aspect) { float ratio = enna_util_atof(aspect) / 10000; if (ratio) enna_buffer_appendf(buf, ", %.2f", ratio); } enna_buffer_appendf(buf, "<br>"); eina_stringshare_del(width); eina_stringshare_del(height); eina_stringshare_del(aspect); eina_stringshare_del(codec); } codec = enna_metadata_meta_get(m, "audio_codec", 1); if (codec) { const char *channels, *bitrate; channels = enna_metadata_meta_get(m, "audio_channels", 1); bitrate = enna_metadata_meta_get(m, "audio_bitrate", 1); enna_buffer_append(buf, "<hl>"); enna_buffer_append(buf, _("Audio:")); enna_buffer_appendf(buf, " </hl> %s", codec); if (channels) enna_buffer_appendf(buf, ", %s ch.", channels); if (bitrate) enna_buffer_appendf(buf, ", %i kbps", atoi(bitrate) / 1000); enna_buffer_appendf(buf, "<br>"); eina_stringshare_del(channels); eina_stringshare_del(bitrate); eina_stringshare_del(codec); } value = enna_metadata_meta_get(m, "filesize", 1); if (value) { enna_buffer_append(buf, "<hl>"); enna_buffer_append(buf, _("Size:")); enna_buffer_appendf(buf, " </hl> %.2f MB<br>", atol(value) / 1024.0 / 1024.0); } eina_stringshare_del(value); /* tell if no more infos are available */ if (buf->len == len) enna_buffer_append(buf, _("No further information can be retrieved")); edje_object_part_text_set(sd->o_edje, "panel.textblock", buf->buf); enna_buffer_free(buf); eina_stringshare_del(alternative_title); eina_stringshare_del(title); eina_stringshare_del(categories); eina_stringshare_del(year); eina_stringshare_del(length); eina_stringshare_del(director); eina_stringshare_del(actors); eina_stringshare_del(overview); }