2017-03-02 14:37:32 +00:00
|
|
|
using Gtk;
|
|
|
|
|
|
|
|
using Dino.Entities;
|
|
|
|
|
|
|
|
namespace Dino.Ui.ManageAccounts {
|
|
|
|
|
2017-12-03 18:42:15 +00:00
|
|
|
[GtkTemplate (ui = "/im/dino/Dino/manage_accounts/account_row.ui")]
|
2017-03-02 14:37:32 +00:00
|
|
|
public class AccountRow : Gtk.ListBoxRow {
|
|
|
|
|
2018-01-16 15:17:42 +00:00
|
|
|
[GtkChild] public AvatarImage image;
|
2017-03-10 17:07:28 +00:00
|
|
|
[GtkChild] public Label jid_label;
|
2017-04-08 09:53:10 +00:00
|
|
|
[GtkChild] public Image icon;
|
2017-03-02 14:37:32 +00:00
|
|
|
|
|
|
|
public Account account;
|
2017-04-08 09:53:10 +00:00
|
|
|
private StreamInteractor stream_interactor;
|
2017-03-02 14:37:32 +00:00
|
|
|
|
|
|
|
public AccountRow(StreamInteractor stream_interactor, Account account) {
|
2017-04-08 09:53:10 +00:00
|
|
|
this.stream_interactor = stream_interactor;
|
2017-03-02 14:37:32 +00:00
|
|
|
this.account = account;
|
2019-10-18 14:52:29 +00:00
|
|
|
image.set_conversation(stream_interactor, new Conversation(account.bare_jid, account, Conversation.Type.CHAT));
|
2017-03-02 14:37:32 +00:00
|
|
|
jid_label.set_label(account.bare_jid.to_string());
|
2017-04-08 09:53:10 +00:00
|
|
|
|
|
|
|
stream_interactor.connection_manager.connection_error.connect((account, error) => {
|
2017-11-11 20:29:13 +00:00
|
|
|
if (account.equals(this.account)) {
|
|
|
|
update_warning_icon();
|
|
|
|
}
|
2017-04-08 09:53:10 +00:00
|
|
|
});
|
|
|
|
stream_interactor.connection_manager.connection_state_changed.connect((account, state) => {
|
2017-11-11 20:29:13 +00:00
|
|
|
if (account.equals(this.account)) {
|
|
|
|
update_warning_icon();
|
|
|
|
}
|
2017-04-08 09:53:10 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private void update_warning_icon() {
|
|
|
|
ConnectionManager.ConnectionError? error = stream_interactor.connection_manager.get_error(account);
|
|
|
|
icon.visible = (error != null);
|
2017-03-02 14:37:32 +00:00
|
|
|
}
|
|
|
|
}
|
2017-03-10 17:07:28 +00:00
|
|
|
|
2017-08-17 19:24:01 +00:00
|
|
|
}
|