Commit e80cbf60 authored by Paolo Bacchilega's avatar Paolo Bacchilega

show the rating as a sequence of stars

parent 13f17708
......@@ -534,7 +534,18 @@ gth_file_data_get_attribute_as_string (GthFileData *file_data,
if (GTH_IS_METADATA (obj)) {
switch (gth_metadata_get_data_type (GTH_METADATA (obj))) {
case GTH_METADATA_TYPE_STRING:
value = g_strdup (gth_metadata_get_formatted (GTH_METADATA (obj)));
if (strcmp (id, "general::rating") == 0) {
int n = atoi (gth_metadata_get_formatted (GTH_METADATA (obj)));
if ((n >= 0) && (n <= 5)) {
GString *str = g_string_new ("");
int i;
for (i = 1; i <= n; i++)
g_string_append (str, "⭐");
value = g_string_free (str, FALSE);
}
}
if (value == NULL)
value = g_strdup (gth_metadata_get_formatted (GTH_METADATA (obj)));
break;
case GTH_METADATA_TYPE_STRING_LIST:
value = gth_string_list_join (GTH_STRING_LIST (gth_metadata_get_string_list (GTH_METADATA (obj))), " ");
......
......@@ -298,6 +298,7 @@ gth_grid_view_item_update_caption (GthGridViewItem *item,
value = gth_file_data_get_attribute_as_string (item->file_data, attributes_v[i]);
if ((value != NULL) && ! g_str_equal (value, "")) {
char *escaped;
char *style;
if (metadata->len > 0)
g_string_append (metadata, "\n");
......@@ -313,7 +314,11 @@ gth_grid_view_item_update_caption (GthGridViewItem *item,
}
escaped = g_markup_escape_text (value, -1);
g_string_append_printf (metadata, "<span%s>%s</span>", (odd ? ODD_ROW_ATTR_STYLE : EVEN_ROW_ATTR_STYLE), escaped);
if (strcmp (attributes_v[i], "general::rating") == 0)
style = "";
else
style = (odd ? ODD_ROW_ATTR_STYLE : EVEN_ROW_ATTR_STYLE);
g_string_append_printf (metadata, "<span%s>%s</span>", style, escaped);
g_free (escaped);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment