anotherim-desktop/main/src/ui/add_conversation/list_row.vala

42 lines
1.2 KiB
Vala
Raw Normal View History

2017-03-02 14:37:32 +00:00
using Gee;
using Gtk;
using Dino.Entities;
using Xmpp;
2017-03-02 14:37:32 +00:00
namespace Dino.Ui {
2017-03-02 14:37:32 +00:00
[GtkTemplate (ui = "/im/dino/Dino/add_conversation/list_row.ui")]
2017-03-02 14:37:32 +00:00
public class ListRow : ListBoxRow {
2018-01-16 15:17:42 +00:00
[GtkChild] public AvatarImage image;
2017-03-10 17:07:28 +00:00
[GtkChild] public Label name_label;
[GtkChild] public Label via_label;
2017-03-02 14:37:32 +00:00
public Jid? jid;
public Account? account;
public ListRow() {}
2017-06-11 11:59:24 +00:00
public ListRow.from_jid(StreamInteractor stream_interactor, Jid jid, Account account, bool show_account) {
2017-03-02 14:37:32 +00:00
this.jid = jid;
this.account = account;
Conversation conv = new Conversation(jid, account, Conversation.Type.CHAT);
string display_name = Util.get_conversation_display_name(stream_interactor, conv);
2017-06-11 11:59:24 +00:00
if (show_account && stream_interactor.get_accounts().size > 1) {
2017-03-02 14:37:32 +00:00
via_label.label = @"via $(account.bare_jid)";
this.has_tooltip = true;
set_tooltip_text(jid.to_string());
} else if (display_name != jid.bare_jid.to_string()){
via_label.label = jid.bare_jid.to_string();
} else {
via_label.visible = false;
}
name_label.label = display_name;
image.set_conversation(stream_interactor, conv);
2017-03-02 14:37:32 +00:00
}
}
2017-03-10 17:07:28 +00:00
2017-08-17 19:24:01 +00:00
}