From d0e86d0a8ebb6bbb254a0fb7474d09c58d8379e3 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Thu, 31 Aug 2017 22:22:44 +0200 Subject: [PATCH] small fixes --- libdino/src/plugin/interfaces.vala | 1 + main/src/ui/add_conversation/list_row.vala | 2 +- .../ui/conversation_selector/conversation_row.vala | 4 ++-- main/src/ui/conversation_selector/list.vala | 2 +- .../ui/conversation_summary/conversation_view.vala | 11 ++++++++++- .../conversation_summary/default_message_display.vala | 1 + main/src/ui/conversation_summary/file_populator.vala | 1 + .../conversation_summary/slashme_message_display.vala | 1 + 8 files changed, 18 insertions(+), 5 deletions(-) diff --git a/libdino/src/plugin/interfaces.vala b/libdino/src/plugin/interfaces.vala index 0e0ad27c..09877560 100644 --- a/libdino/src/plugin/interfaces.vala +++ b/libdino/src/plugin/interfaces.vala @@ -85,6 +85,7 @@ public abstract class MetaConversationItem : Object { public virtual string display_name { get; set; default=null; } public virtual bool dim { get; set; default=false; } public virtual DateTime? sort_time { get; set; default=null; } + public virtual double seccondary_sort_indicator { get; set; } public virtual DateTime? display_time { get; set; default=null; } public virtual Encryption? encryption { get; set; default=null; } public virtual Entities.Message.Marked? mark { get; set; default=null; } diff --git a/main/src/ui/add_conversation/list_row.vala b/main/src/ui/add_conversation/list_row.vala index 1f69074d..5c33095f 100644 --- a/main/src/ui/add_conversation/list_row.vala +++ b/main/src/ui/add_conversation/list_row.vala @@ -32,7 +32,7 @@ public class ListRow : ListBoxRow { via_label.visible = false; } name_label.label = display_name; - image.set_from_pixbuf((new AvatarGenerator(35, 35, image.scale_factor)).draw_jid(stream_interactor, jid, account)); + Util.image_set_from_scaled_pixbuf(image, (new AvatarGenerator(35, 35, image.scale_factor)).draw_jid(stream_interactor, jid, account)); } } diff --git a/main/src/ui/conversation_selector/conversation_row.vala b/main/src/ui/conversation_selector/conversation_row.vala index d9432583..ec00349b 100644 --- a/main/src/ui/conversation_selector/conversation_row.vala +++ b/main/src/ui/conversation_selector/conversation_row.vala @@ -56,7 +56,7 @@ public abstract class ConversationRow : ListBoxRow { Entities.Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_last_message(conversation); if (message != null) { update_message(message.body.replace("\n", " ")); - update_time(message.time.to_utc()); + update_time(message.time); } } @@ -89,7 +89,7 @@ public abstract class ConversationRow : ListBoxRow { time = new_time; } if (time != null) { - time_label.label = get_relative_time(time); + time_label.label = get_relative_time(time.to_local()); } } diff --git a/main/src/ui/conversation_selector/list.vala b/main/src/ui/conversation_selector/list.vala index 0e0ce554..c46376ed 100644 --- a/main/src/ui/conversation_selector/list.vala +++ b/main/src/ui/conversation_selector/list.vala @@ -206,4 +206,4 @@ public class List : ListBox { } } -} \ No newline at end of file +} diff --git a/main/src/ui/conversation_summary/conversation_view.vala b/main/src/ui/conversation_summary/conversation_view.vala index 9379e8ba..3f5a85b6 100644 --- a/main/src/ui/conversation_summary/conversation_view.vala +++ b/main/src/ui/conversation_summary/conversation_view.vala @@ -16,7 +16,7 @@ public class ConversationView : Box, Plugins.ConversationItemCollection { [GtkChild] private Stack stack; private StreamInteractor stream_interactor; - private Gee.TreeSet meta_items = new TreeSet((a, b) => { return a.sort_time.compare(b.sort_time); }); + private Gee.TreeSet meta_items = new TreeSet(sort_meta_items); private Gee.Map> meta_after_items = new Gee.HashMap>(); private Gee.HashMap item_item_skeletons = new Gee.HashMap(); private Gee.HashMap widgets = new Gee.HashMap(); @@ -169,6 +169,15 @@ public class ConversationView : Box, Plugins.ConversationItemCollection { if (meta_items.size > 0) message_item_populator.populate_number(conversation, meta_items.first().sort_time, 20); } + private static int sort_meta_items(Plugins.MetaConversationItem a, Plugins.MetaConversationItem b) { + int res = a.sort_time.compare(b.sort_time); + if (res == 0) { + if (a.seccondary_sort_indicator < b.seccondary_sort_indicator) res = -1; + else if (a.seccondary_sort_indicator > b.seccondary_sort_indicator) res = 1; + } + return res; + } + // Workaround GTK TextView issues private void force_alloc_width(Widget widget, int width) { Allocation alloc = Allocation(); diff --git a/main/src/ui/conversation_summary/default_message_display.vala b/main/src/ui/conversation_summary/default_message_display.vala index 6082253d..44040a3b 100644 --- a/main/src/ui/conversation_summary/default_message_display.vala +++ b/main/src/ui/conversation_summary/default_message_display.vala @@ -35,6 +35,7 @@ public class MetaMessageItem : Plugins.MetaConversationItem { this.message = message; this.jid = message.from; this.sort_time = message.local_time; + this.seccondary_sort_indicator = message.id + 0.2085; this.display_time = message.time; this.encryption = message.encryption; } diff --git a/main/src/ui/conversation_summary/file_populator.vala b/main/src/ui/conversation_summary/file_populator.vala index 9046155a..d1a26d12 100644 --- a/main/src/ui/conversation_summary/file_populator.vala +++ b/main/src/ui/conversation_summary/file_populator.vala @@ -70,6 +70,7 @@ public class ImageItem : Plugins.MetaConversationItem { this.jid = file_transfer.direction == FileTransfer.DIRECTION_SENT ? new Jid.with_resource(file_transfer.account.bare_jid.to_string(), file_transfer.account.resourcepart) : file_transfer.counterpart; this.sort_time = file_transfer.time; + this.seccondary_sort_indicator = file_transfer.id + 0.2903; this.display_time = file_transfer.time; this.encryption = file_transfer.encryption; this.mark = file_to_message_state(file_transfer.state); diff --git a/main/src/ui/conversation_summary/slashme_message_display.vala b/main/src/ui/conversation_summary/slashme_message_display.vala index 58d93142..cb3d5cd2 100644 --- a/main/src/ui/conversation_summary/slashme_message_display.vala +++ b/main/src/ui/conversation_summary/slashme_message_display.vala @@ -41,6 +41,7 @@ public class MetaSlashmeItem : Plugins.MetaConversationItem { this.message = message; this.jid = message.from; this.sort_time = message.local_time; + this.seccondary_sort_indicator = message.id + 0.0845; this.display_time = message.time; this.encryption = message.encryption; }