add custom detail view progress type

This commit is contained in:
Carsten Haitzler 2023-10-17 20:34:59 +01:00
parent 20682de4ba
commit 6b9cc3fa07
2 changed files with 52 additions and 16 deletions

View File

@ -111,19 +111,30 @@ function handle_cmd_dir_set() {
# begin initial listing of files
e_cmd "list-begin"
# define some params we're going to use
D="detail-format=text,text,text,checkview,timestamp,size detail1=one detail2=two detail3=three"
# an icon image to use
e_val_escape M ${DIR}"ic.jpg"
M="type=file icon="${M}
# add one new file (4 of them) with params
D="detail-format=text,text,progress,checkview,timestamp,size"
e_val_escape F ${DIR}"abba"
e_cmd "file-add path="${F}" "${M}" "${D}" detail4=1 detail5=0 detail6=576/65536"
e_cmd "file-add path="${F}" "${M}" "${D}\
" detail1=one detail2=two detail3=33/100 detail4=1 detail5=0 detail6=576/65536"
D="detail-format=text,text,progress,checkview,timestamp,size"
e_val_escape F ${DIR}"boopy__==!@#$%^&*();"
e_cmd "file-add path="${F}" "${M}" "${D}" detail4=0 detail5=1696332215 detail6=16384/65536"
e_cmd "file-add path="${F}" "${M}" "${D}\
" detail1=one detail2=two detail3=noval,55/100 detail4=0 detail5=1696332215 detail6=16384/65536"
D="detail-format=text,text,text,checkview,timestamp,size"
e_val_escape F ${DIR}"g h i"
e_cmd "file-add path="${F}" "${M}" "${D}" detail4=true detail5=1696322215 detail6=65535/65536"
e_cmd "file-add path="${F}" "${M}" "${D}\
" detail1=one detail2=two detail3=three detail4=true detail5=1696322215 detail6=65535/65536"
D="detail-format=text,text,text,checkview,timestamp,size"
e_val_escape F ${DIR}"z~"
e_cmd "file-add path="${F}" "${M}" "${D}" detail4=false detail5=1296332215 detail6=7823/65536"
e_cmd "file-add path="${F}" "${M}" "${D}\
" detail1=one detail2=two detail3=three detail4=false detail5=1296332215 detail6=7823/65536"
# end initial listing of files
e_cmd "list-end"
}

View File

@ -1243,10 +1243,16 @@ _icon_detail_edje_text_set_free(Evas_Object *o, const char *part, char *str)
free(str);
}
static char *
_cb_progress_noval(double v EINA_UNUSED)
{
return "";
}
static void
_icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
const char *theme_edj_file, int col,
const char *detail, const char *format)
const char *theme_edj_file, int col, const char *detail,
const char *format)
{
Evas_Object *o;
char buf[128];
@ -1307,17 +1313,36 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
o = _icon_detail_grid_add(icon, sd, col);
o = _icon_detail_grid_sub_edje_add(icon, e, theme_edj_file, col,
"e/fileman/default/check");
if ((!strcasecmp(detail, "1")) ||
(!strcasecmp(detail, "on")) ||
(!strcasecmp(detail, "true")) ||
(!strcasecmp(detail, "yes")))
if ((!strcasecmp(detail, "1")) || (!strcasecmp(detail, "on"))
|| (!strcasecmp(detail, "true")) || (!strcasecmp(detail, "yes")))
edje_object_signal_emit(o, "e,state,on", "e");
else
edje_object_signal_emit(o, "e,state,off", "e");
else edje_object_signal_emit(o, "e,state,off", "e");
}
else
fprintf(stderr, "Uknown format for file '%s' column %i format '%s'\n",
icon->info.file, col, format);
else if (!strcmp(format, "progress"))
{ // format: 33/100 or noval,41/50 - value / maxvalue optional noval
int val = 0, max = 100;
o = _icon_detail_grid_add(icon, sd, col);
o = elm_progressbar_add(o);
elm_progressbar_horizontal_set(o, EINA_TRUE);
elm_progressbar_span_size_set(o, 1);
elm_grid_pack(icon->o_list_detail_swallow[col], o, 0, 0, 1, 1);
if (sscanf(detail, "%i/%i", &val, &max) == 2)
{
if (max < 1) max = 0;
}
else if (sscanf(detail, "noval,%i/%i", &val, &max) == 2)
{
elm_progressbar_unit_format_function_set(o, _cb_progress_noval,
NULL);
if (max < 1) max = 0;
}
elm_progressbar_value_set(o, (double)val / (double)max);
evas_object_show(o);
}
else fprintf(stderr,
"Uknown format for file '%s' column %i format '%s'\n",
icon->info.file, col, format);
}
static void