small fixes

This commit is contained in:
fiaxh 2017-08-31 22:22:44 +02:00
parent d2a5287eff
commit d0e86d0a8e
8 changed files with 18 additions and 5 deletions

View file

@ -85,6 +85,7 @@ public abstract class MetaConversationItem : Object {
public virtual string display_name { get; set; default=null; } public virtual string display_name { get; set; default=null; }
public virtual bool dim { get; set; default=false; } public virtual bool dim { get; set; default=false; }
public virtual DateTime? sort_time { get; set; default=null; } 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 DateTime? display_time { get; set; default=null; }
public virtual Encryption? encryption { get; set; default=null; } public virtual Encryption? encryption { get; set; default=null; }
public virtual Entities.Message.Marked? mark { get; set; default=null; } public virtual Entities.Message.Marked? mark { get; set; default=null; }

View file

@ -32,7 +32,7 @@ public class ListRow : ListBoxRow {
via_label.visible = false; via_label.visible = false;
} }
name_label.label = display_name; 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));
} }
} }

View file

@ -56,7 +56,7 @@ public abstract class ConversationRow : ListBoxRow {
Entities.Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_last_message(conversation); Entities.Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_last_message(conversation);
if (message != null) { if (message != null) {
update_message(message.body.replace("\n", " ")); 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; time = new_time;
} }
if (time != null) { if (time != null) {
time_label.label = get_relative_time(time); time_label.label = get_relative_time(time.to_local());
} }
} }

View file

@ -16,7 +16,7 @@ public class ConversationView : Box, Plugins.ConversationItemCollection {
[GtkChild] private Stack stack; [GtkChild] private Stack stack;
private StreamInteractor stream_interactor; private StreamInteractor stream_interactor;
private Gee.TreeSet<Plugins.MetaConversationItem> meta_items = new TreeSet<Plugins.MetaConversationItem>((a, b) => { return a.sort_time.compare(b.sort_time); }); private Gee.TreeSet<Plugins.MetaConversationItem> meta_items = new TreeSet<Plugins.MetaConversationItem>(sort_meta_items);
private Gee.Map<Plugins.MetaConversationItem, Gee.List<Plugins.MetaConversationItem>> meta_after_items = new Gee.HashMap<Plugins.MetaConversationItem, Gee.List<Plugins.MetaConversationItem>>(); private Gee.Map<Plugins.MetaConversationItem, Gee.List<Plugins.MetaConversationItem>> meta_after_items = new Gee.HashMap<Plugins.MetaConversationItem, Gee.List<Plugins.MetaConversationItem>>();
private Gee.HashMap<Plugins.MetaConversationItem, ConversationItemSkeleton> item_item_skeletons = new Gee.HashMap<Plugins.MetaConversationItem, ConversationItemSkeleton>(); private Gee.HashMap<Plugins.MetaConversationItem, ConversationItemSkeleton> item_item_skeletons = new Gee.HashMap<Plugins.MetaConversationItem, ConversationItemSkeleton>();
private Gee.HashMap<Plugins.MetaConversationItem, Widget> widgets = new Gee.HashMap<Plugins.MetaConversationItem, Widget>(); private Gee.HashMap<Plugins.MetaConversationItem, Widget> widgets = new Gee.HashMap<Plugins.MetaConversationItem, Widget>();
@ -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); 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 // Workaround GTK TextView issues
private void force_alloc_width(Widget widget, int width) { private void force_alloc_width(Widget widget, int width) {
Allocation alloc = Allocation(); Allocation alloc = Allocation();

View file

@ -35,6 +35,7 @@ public class MetaMessageItem : Plugins.MetaConversationItem {
this.message = message; this.message = message;
this.jid = message.from; this.jid = message.from;
this.sort_time = message.local_time; this.sort_time = message.local_time;
this.seccondary_sort_indicator = message.id + 0.2085;
this.display_time = message.time; this.display_time = message.time;
this.encryption = message.encryption; this.encryption = message.encryption;
} }

View file

@ -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.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.sort_time = file_transfer.time;
this.seccondary_sort_indicator = file_transfer.id + 0.2903;
this.display_time = file_transfer.time; this.display_time = file_transfer.time;
this.encryption = file_transfer.encryption; this.encryption = file_transfer.encryption;
this.mark = file_to_message_state(file_transfer.state); this.mark = file_to_message_state(file_transfer.state);

View file

@ -41,6 +41,7 @@ public class MetaSlashmeItem : Plugins.MetaConversationItem {
this.message = message; this.message = message;
this.jid = message.from; this.jid = message.from;
this.sort_time = message.local_time; this.sort_time = message.local_time;
this.seccondary_sort_indicator = message.id + 0.0845;
this.display_time = message.time; this.display_time = message.time;
this.encryption = message.encryption; this.encryption = message.encryption;
} }