anotherim-desktop/main/src/ui/conversation_selector/groupchat_row.vala

46 lines
1.7 KiB
Vala
Raw Normal View History

2017-03-02 14:37:32 +00:00
using Dino.Entities;
namespace Dino.Ui.ConversationSelector {
2017-03-10 17:07:28 +00:00
2017-03-02 14:37:32 +00:00
public class GroupchatRow : ConversationRow {
public GroupchatRow(StreamInteractor stream_interactor, Conversation conversation) {
base(stream_interactor, conversation);
has_tooltip = true;
set_tooltip_text(conversation.counterpart.bare_jid.to_string());
2017-04-11 16:06:01 +00:00
update_avatar();
2017-03-02 14:37:32 +00:00
x_button.clicked.connect(on_x_button_clicked);
2017-04-11 16:06:01 +00:00
stream_interactor.get_module(MucManager.IDENTITY).left.connect(() => {
Idle.add(() => {
update_avatar();
return false;
});
});
2017-03-02 14:37:32 +00:00
}
public override void on_show_received(Show show) {
set_avatar((new AvatarGenerator(AVATAR_SIZE, AVATAR_SIZE, image.scale_factor))
.draw_conversation(stream_interactor, conversation), image.scale_factor);
}
public override void network_connection(bool connected) {
2017-04-11 16:06:01 +00:00
update_avatar();
2017-03-02 14:37:32 +00:00
}
private void on_x_button_clicked() {
stream_interactor.get_module(MucManager.IDENTITY).part(conversation.account, conversation.counterpart);
2017-03-02 14:37:32 +00:00
}
2017-04-11 16:06:01 +00:00
private void update_avatar() {
ConnectionManager.ConnectionState connection_state = stream_interactor.connection_manager.get_state(conversation.account);
bool is_joined = stream_interactor.get_module(MucManager.IDENTITY).is_joined(conversation.counterpart, conversation.account);
set_avatar((new AvatarGenerator(AVATAR_SIZE, AVATAR_SIZE, image.scale_factor))
.set_greyscale(connection_state != ConnectionManager.ConnectionState.CONNECTED || !is_joined)
.draw_conversation(stream_interactor, conversation), image.scale_factor);
}
2017-03-02 14:37:32 +00:00
}
2017-03-10 17:07:28 +00:00
2017-03-02 14:37:32 +00:00
}