diff --git a/src/API/Attachment.vala b/src/API/Attachment.vala index 268e4432..1c787b38 100644 --- a/src/API/Attachment.vala +++ b/src/API/Attachment.vala @@ -9,6 +9,7 @@ public class Tuba.API.Attachment : Entity, Widgetizable { set { this.t_preview_url = value; } get { return (this.t_preview_url == null || this.t_preview_url == "") ? url : t_preview_url; } } + public API.AttachmentMeta? meta { get; set; default=null; } public File? source_file { get; set; } diff --git a/src/API/Attachment/Meta.vala b/src/API/Attachment/Meta.vala new file mode 100644 index 00000000..96475d4d --- /dev/null +++ b/src/API/Attachment/Meta.vala @@ -0,0 +1,4 @@ +public class Tuba.API.AttachmentMeta : Entity { + public API.AttachmentMetaInfo? small { get; set; default=null; } + public API.AttachmentMetaInfo? original { get; set; default=null; } +} \ No newline at end of file diff --git a/src/API/Attachment/Meta/Info.vala b/src/API/Attachment/Meta/Info.vala new file mode 100644 index 00000000..11e430e5 --- /dev/null +++ b/src/API/Attachment/Meta/Info.vala @@ -0,0 +1,5 @@ +public class Tuba.API.AttachmentMetaInfo : Entity { + public int64 width { get; set; default=0; } + public int64 height { get; set; default=0; } + public float aspect { get; set; default=0.0f; } +} \ No newline at end of file diff --git a/src/API/Attachment/Meta/meson.build b/src/API/Attachment/Meta/meson.build new file mode 100644 index 00000000..b0691e09 --- /dev/null +++ b/src/API/Attachment/Meta/meson.build @@ -0,0 +1,3 @@ +sources += files( + 'Info.vala', +) diff --git a/src/API/Attachment/meson.build b/src/API/Attachment/meson.build new file mode 100644 index 00000000..20857408 --- /dev/null +++ b/src/API/Attachment/meson.build @@ -0,0 +1,5 @@ +sources += files( + 'Meta.vala', +) + +subdir('Meta') diff --git a/src/API/meson.build b/src/API/meson.build index bba7c180..c073ef09 100644 --- a/src/API/meson.build +++ b/src/API/meson.build @@ -22,6 +22,7 @@ sources += files( ) subdir('Account') +subdir('Attachment') subdir('Instance') subdir('PeerTube') subdir('Status') diff --git a/src/Widgets/Attachment/Box.vala b/src/Widgets/Attachment/Box.vala index 951329b7..bb6860aa 100644 --- a/src/Widgets/Attachment/Box.vala +++ b/src/Widgets/Attachment/Box.vala @@ -41,6 +41,8 @@ public class Tuba.Widgets.Attachment.Box : Adw.Bin { return; } + var single_attachment = list.size == 1; + list.@foreach (item => { try { var widget = item.to_widget (); @@ -51,6 +53,14 @@ public class Tuba.Widgets.Attachment.Box : Adw.Bin { box.insert (flowboxchild, -1); attachment_widgets += ((Widgets.Attachment.Image) widget); + if (single_attachment) { + if (item != null && item.meta != null && item.meta.small != null && item.meta.small.width != 0 && item.meta.small.height != 0 && item.meta.small.aspect != 0.0f) { + // var is_landscape = item.meta.small.width > item.meta.small.height; + // widget.height_request = + } else { + widget.height_request = 384; + } + } ((Widgets.Attachment.Image) widget).on_any_attachment_click.connect (() => open_all_attachments(item.url)); } catch (Oopsie e) { warning(@"Error updating attachments: $(e.message)"); @@ -58,8 +68,13 @@ public class Tuba.Widgets.Attachment.Box : Adw.Bin { return true; }); - box.max_children_per_line = 2; - box.min_children_per_line = 2; + if (single_attachment) { + box.max_children_per_line = 1; + box.min_children_per_line = 1; + } else { + box.max_children_per_line = 2; + box.min_children_per_line = 2; + } // if (list.size > 1) { // box.max_children_per_line = 2; // }