aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/add_conversation/list_row.vala
blob: 958445b7b768e3f8abde0648471e8aa436f870a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Gee;
using Gtk;

using Dino.Entities;

namespace Dino.Ui {

[GtkTemplate (ui = "/im/dino/Dino/add_conversation/list_row.ui")]
public class ListRow : ListBoxRow {

    [GtkChild] public Image image;
    [GtkChild] public Label name_label;
    [GtkChild] public Label via_label;

    public Jid? jid;
    public Account? account;

    public ListRow() {}

    public ListRow.from_jid(StreamInteractor stream_interactor, Jid jid, Account account, bool show_account) {
        this.jid = jid;
        this.account = account;

        string display_name = Util.get_display_name(stream_interactor, jid, account);
        if (show_account && stream_interactor.get_accounts().size > 1) {
            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;
        Util.image_set_from_scaled_pixbuf(image, (new AvatarGenerator(35, 35, image.scale_factor)).draw_jid(stream_interactor, jid, account));
    }
}

}