diff options
author | fiaxh <git@mx.ax.lt> | 2017-08-23 20:30:44 +0200 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-08-25 22:29:40 +0200 |
commit | 5fcf8e73efeea60413a383e6e6a096a3981be1a2 (patch) | |
tree | 8f7aa88a0b167d46a90c2966b3ea15959a8a4014 /main/src/ui/avatar_generator.vala | |
parent | 7b395263c1ec0e6b057f7c3bb1d0525f6f38964d (diff) | |
download | dino-5fcf8e73efeea60413a383e6e6a096a3981be1a2.tar.gz dino-5fcf8e73efeea60413a383e6e6a096a3981be1a2.zip |
Show nicks in MUCs, real jid in individual occupant menu
Diffstat (limited to 'main/src/ui/avatar_generator.vala')
-rw-r--r-- | main/src/ui/avatar_generator.vala | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/main/src/ui/avatar_generator.vala b/main/src/ui/avatar_generator.vala index eb87a3e2..10406699 100644 --- a/main/src/ui/avatar_generator.vala +++ b/main/src/ui/avatar_generator.vala @@ -25,14 +25,21 @@ public class AvatarGenerator { this.scale_factor = scale_factor; } - public Pixbuf draw_jid(StreamInteractor stream_interactor, Jid jid, Account account) { + public Pixbuf draw_jid(StreamInteractor stream_interactor, Jid jid_, Account account) { + Jid? jid = jid_; this.stream_interactor = stream_interactor; + Jid? real_jid = stream_interactor.get_module(MucManager.IDENTITY).get_real_jid(jid, account); + if (real_jid != null && stream_interactor.get_module(AvatarManager.IDENTITY).get_avatar(account, real_jid) != null) { + jid = real_jid; + } return crop_corners(draw_tile(jid, account, width * scale_factor, height * scale_factor)); } public Pixbuf draw_message(StreamInteractor stream_interactor, Message message) { - Jid? real_jid = stream_interactor.get_module(MucManager.IDENTITY).get_message_real_jid(message); - return draw_jid(stream_interactor, real_jid != null ? real_jid : message.from, message.account); + if (message.real_jid != null && stream_interactor.get_module(AvatarManager.IDENTITY).get_avatar(message.account, message.real_jid) != null) { + return draw_jid(stream_interactor, message.real_jid, message.account); + } + return draw_jid(stream_interactor, message.from, message.account); } public Pixbuf draw_conversation(StreamInteractor stream_interactor, Conversation conversation) { @@ -44,8 +51,7 @@ public class AvatarGenerator { } public Pixbuf draw_text(string text) { - string color = greyscale ? COLOR_GREY : Util.get_avatar_hex_color(text); - Pixbuf pixbuf = draw_colored_rectangle_text(color, text, width, height); + Pixbuf pixbuf = draw_colored_rectangle_text(COLOR_GREY, text, width, height); return crop_corners(pixbuf); } @@ -81,12 +87,6 @@ public class AvatarGenerator { } private Pixbuf draw_chat_tile(Jid jid, Account account, int width, int height) { - if (stream_interactor.get_module(MucManager.IDENTITY).is_groupchat_occupant(jid, account)) { - Jid? real_jid = stream_interactor.get_module(MucManager.IDENTITY).get_real_jid(jid, account); - if (real_jid != null) { - return draw_tile(real_jid, account, width, height); - } - } Pixbuf? avatar = stream_interactor.get_module(AvatarManager.IDENTITY).get_avatar(account, jid); if (avatar != null) { double desired_ratio = (double) width / height; @@ -103,7 +103,7 @@ public class AvatarGenerator { return avatar; } else { string display_name = Util.get_display_name(stream_interactor, jid, account); - string color = greyscale ? COLOR_GREY : Util.get_avatar_hex_color(display_name); + string color = greyscale ? COLOR_GREY : Util.get_avatar_hex_color(stream_interactor, account, jid); return draw_colored_rectangle_text(color, display_name.get_char(0).toupper().to_string(), width, height); } } @@ -113,6 +113,13 @@ public class AvatarGenerator { if (stateless || occupants == null || occupants.size == 0) { return draw_chat_tile(jid, account, width, height); } + + for (int i = 0; i < occupants.size && i < 4; i++) { + Jid? real_jid = stream_interactor.get_module(MucManager.IDENTITY).get_real_jid(occupants[i], account); + if (real_jid != null && stream_interactor.get_module(AvatarManager.IDENTITY).get_avatar(account, real_jid) != null) { + occupants[i] = real_jid; + } + } Pixbuf pixbuf = initialize_pixbuf(width, height); if (occupants.size == 1 || occupants.size == 2 || occupants.size == 3) { add_tile_to_pixbuf(pixbuf, occupants[0], account, width / 2 - get_right_border(), height, 0, 0); |