parent
4a8d628924
commit
6613f3f05a
|
@ -107,12 +107,18 @@ public class FileItemWidgetGenerator : WidgetGenerator, Object {
|
||||||
public Object get_widget(ContentItem item) {
|
public Object get_widget(ContentItem item) {
|
||||||
FileItem file_item = item as FileItem;
|
FileItem file_item = item as FileItem;
|
||||||
FileTransfer transfer = file_item.file_transfer;
|
FileTransfer transfer = file_item.file_transfer;
|
||||||
if (transfer.mime_type != null && transfer.mime_type.has_prefix("image")) {
|
|
||||||
|
if (transfer.mime_type != null) {
|
||||||
|
foreach (PixbufFormat pixbuf_format in Pixbuf.get_formats()) {
|
||||||
|
foreach (string mime_type in pixbuf_format.get_mime_types()) {
|
||||||
|
if (mime_type == transfer.mime_type)
|
||||||
return getImageWidget(transfer);
|
return getImageWidget(transfer);
|
||||||
} else {
|
|
||||||
return getDefaultWidget(transfer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return getDefaultWidget(transfer);
|
||||||
|
}
|
||||||
|
|
||||||
private Widget getImageWidget(FileTransfer file_transfer) {
|
private Widget getImageWidget(FileTransfer file_transfer) {
|
||||||
Image image = new Image() { halign=Align.START, visible = true };
|
Image image = new Image() { halign=Align.START, visible = true };
|
||||||
|
@ -123,6 +129,8 @@ public class FileItemWidgetGenerator : WidgetGenerator, Object {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pixbuf = pixbuf.apply_embedded_orientation();
|
||||||
|
|
||||||
int max_scaled_height = MAX_HEIGHT * image.scale_factor;
|
int max_scaled_height = MAX_HEIGHT * image.scale_factor;
|
||||||
if (pixbuf.height > max_scaled_height) {
|
if (pixbuf.height > max_scaled_height) {
|
||||||
pixbuf = pixbuf.scale_simple((int) ((double) max_scaled_height / pixbuf.height * pixbuf.width), max_scaled_height, Gdk.InterpType.BILINEAR);
|
pixbuf = pixbuf.scale_simple((int) ((double) max_scaled_height / pixbuf.height * pixbuf.width), max_scaled_height, Gdk.InterpType.BILINEAR);
|
||||||
|
|
Loading…
Reference in a new issue