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

40 lines
1.2 KiB
Vala
Raw Normal View History

2017-03-02 14:37:32 +00:00
using Gee;
using Gtk;
using Dino.Entities;
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 {
2017-03-10 17:07:28 +00:00
[GtkChild] public Image image;
[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;
string display_name = Util.get_display_name(stream_interactor, jid, account);
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;
2017-08-31 20:22:44 +00:00
Util.image_set_from_scaled_pixbuf(image, (new AvatarGenerator(35, 35, image.scale_factor)).draw_jid(stream_interactor, jid, account));
2017-03-02 14:37:32 +00:00
}
}
2017-03-10 17:07:28 +00:00
2017-08-17 19:24:01 +00:00
}