aboutsummaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-03-31 01:17:01 +0200
committerfiaxh <git@mx.ax.lt>2017-03-31 16:39:28 +0200
commit22adbd38dca0868f0e10754314a3859bba0a7d87 (patch)
tree44ecf9cf8af6aef78030dade95aecb1de2b99873 /main/src
parent7d2f995a097086be01426cc79c9c801dabaf9e3b (diff)
downloaddino-22adbd38dca0868f0e10754314a3859bba0a7d87.tar.gz
dino-22adbd38dca0868f0e10754314a3859bba0a7d87.zip
Handle MUC private messages
Diffstat (limited to 'main/src')
-rw-r--r--main/src/ui/conversation_selector/chat_row.vala22
-rw-r--r--main/src/ui/conversation_selector/conversation_row.vala23
-rw-r--r--main/src/ui/conversation_selector/groupchat_pm_row.vala54
-rw-r--r--main/src/ui/conversation_selector/list.vala9
-rw-r--r--main/src/ui/conversation_summary/view.vala2
-rw-r--r--main/src/ui/util.vala3
6 files changed, 90 insertions, 23 deletions
diff --git a/main/src/ui/conversation_selector/chat_row.vala b/main/src/ui/conversation_selector/chat_row.vala
index 5e3270aa..83ad3a11 100644
--- a/main/src/ui/conversation_selector/chat_row.vala
+++ b/main/src/ui/conversation_selector/chat_row.vala
@@ -57,27 +57,7 @@ public class ChatRow : ConversationRow {
ArrayList<Jid>? full_jids = stream_interactor.get_module(PresenceManager.IDENTITY).get_full_jids(conversation.counterpart, conversation.account);
if (full_jids != null) {
for (int i = 0; i < full_jids.size; i++) {
- Box box = new Box(Orientation.HORIZONTAL, 5);
-
- Show show = stream_interactor.get_module(PresenceManager.IDENTITY).get_last_show(full_jids[i], conversation.account);
- Image image = new Image();
- if (show.as == Show.AWAY) {
- image.set_from_icon_name("dino-status-away", IconSize.SMALL_TOOLBAR);
- } else if (show.as == Show.XA || show.as == Show.DND) {
- image.set_from_icon_name("dino-status-dnd", IconSize.SMALL_TOOLBAR);
- } else if (show.as == Show.CHAT) {
- image.set_from_icon_name("dino-status-chat", IconSize.SMALL_TOOLBAR);
- } else {
- image.set_from_icon_name("dino-status-online", IconSize.SMALL_TOOLBAR);
- }
- box.add(image);
-
- Label resource = new Label(full_jids[i].resourcepart);
- resource.xalign = 0;
- box.add(resource);
- box.show_all();
-
- inner_box.add(box);
+ inner_box.add(get_fulljid_box(full_jids[i]));
}
}
return main_box;
diff --git a/main/src/ui/conversation_selector/conversation_row.vala b/main/src/ui/conversation_selector/conversation_row.vala
index 6930db67..ce8845f2 100644
--- a/main/src/ui/conversation_selector/conversation_row.vala
+++ b/main/src/ui/conversation_selector/conversation_row.vala
@@ -120,6 +120,29 @@ public abstract class ConversationRow : ListBoxRow {
message_label.label = message_label.label;
}
+ protected Box get_fulljid_box(Jid full_jid) {
+ Box box = new Box(Orientation.HORIZONTAL, 5) { visible=true };
+
+ Show show = stream_interactor.get_module(PresenceManager.IDENTITY).get_last_show(full_jid, conversation.account);
+ Image image = new Image() { visible=true };
+ if (show.as == Show.AWAY) {
+ image.set_from_icon_name("dino-status-away", IconSize.SMALL_TOOLBAR);
+ } else if (show.as == Show.XA || show.as == Show.DND) {
+ image.set_from_icon_name("dino-status-dnd", IconSize.SMALL_TOOLBAR);
+ } else if (show.as == Show.CHAT) {
+ image.set_from_icon_name("dino-status-chat", IconSize.SMALL_TOOLBAR);
+ } else {
+ image.set_from_icon_name("dino-status-online", IconSize.SMALL_TOOLBAR);
+ }
+ box.add(image);
+
+ Label resource = new Label(full_jid.resourcepart) { visible=true };
+ resource.xalign = 0;
+ box.add(resource);
+ box.show_all();
+ return box;
+ }
+
private void on_x_button_clicked() {
main_revealer.set_transition_type(RevealerTransitionType.SLIDE_UP);
main_revealer.set_reveal_child(false);
diff --git a/main/src/ui/conversation_selector/groupchat_pm_row.vala b/main/src/ui/conversation_selector/groupchat_pm_row.vala
new file mode 100644
index 00000000..f556b45d
--- /dev/null
+++ b/main/src/ui/conversation_selector/groupchat_pm_row.vala
@@ -0,0 +1,54 @@
+using Gdk;
+using Gee;
+using Gtk;
+
+using Xmpp;
+using Dino.Entities;
+
+namespace Dino.Ui.ConversationSelector {
+
+public class GroupchatPmRow : ConversationRow {
+
+ public GroupchatPmRow(StreamInteractor stream_interactor, Conversation conversation) {
+ base(stream_interactor, conversation);
+ has_tooltip = true;
+ query_tooltip.connect ((x, y, keyboard_tooltip, tooltip) => {
+ tooltip.set_custom(generate_tooltip());
+ return true;
+ });
+ update_avatar();
+ }
+
+ public override void on_show_received(Show show) {
+ update_avatar();
+ }
+
+ public override void network_connection(bool connected) {
+ if (!connected) {
+ set_avatar((new AvatarGenerator(AVATAR_SIZE, AVATAR_SIZE, image.scale_factor)).set_greyscale(true).draw_conversation(stream_interactor, conversation), image.scale_factor);
+ } else {
+ update_avatar();
+ }
+ }
+
+ public void update_avatar() {
+ ArrayList<Jid> full_jids = stream_interactor.get_module(PresenceManager.IDENTITY).get_full_jids(conversation.counterpart, conversation.account);
+ set_avatar((new AvatarGenerator(AVATAR_SIZE, AVATAR_SIZE, image.scale_factor))
+ .set_greyscale(full_jids == null)
+ .draw_conversation(stream_interactor, conversation), image.scale_factor);
+ }
+
+ private Widget generate_tooltip() {
+ Builder builder = new Builder.from_resource("/org/dino-im/conversation_selector/chat_row_tooltip.ui");
+ Box main_box = builder.get_object("main_box") as Box;
+ Box inner_box = builder.get_object("inner_box") as Box;
+ Label jid_label = builder.get_object("jid_label") as Label;
+ jid_label.label = conversation.counterpart.to_string();
+ if (stream_interactor.get_module(MucManager.IDENTITY).get_nick(conversation.counterpart, conversation.account) != null) {
+ inner_box.add(get_fulljid_box(conversation.counterpart));
+ }
+ return main_box;
+ }
+}
+
+} \ No newline at end of file
diff --git a/main/src/ui/conversation_selector/list.vala b/main/src/ui/conversation_selector/list.vala
index dee70e4b..f580c4c5 100644
--- a/main/src/ui/conversation_selector/list.vala
+++ b/main/src/ui/conversation_selector/list.vala
@@ -39,8 +39,9 @@ public class List : ListBox {
});
stream_interactor.get_module(PresenceManager.IDENTITY).show_received.connect((show, jid, account) => {
Idle.add(() => {
- Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(jid, account);
- if (conversation != null && rows.has_key(conversation)) rows[conversation].on_show_received(show);
+ foreach (Conversation conversation in stream_interactor.get_module(ConversationManager.IDENTITY).get_conversations_for_presence(show, account)) {
+ if (rows.has_key(conversation)) rows[conversation].on_show_received(show);
+ }
return false;
});
});
@@ -123,6 +124,8 @@ public class List : ListBox {
if (!rows.has_key(conversation)) {
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
row = new GroupchatRow(stream_interactor, conversation);
+ } else if (conversation.type_ == Conversation.Type.GROUPCHAT_PM){
+ row = new GroupchatPmRow(stream_interactor, conversation);
} else {
row = new ChatRow(stream_interactor, conversation);
}
@@ -186,6 +189,8 @@ public class List : ListBox {
if (cr1 != null && cr2 != null) {
Conversation c1 = cr1.conversation;
Conversation c2 = cr2.conversation;
+ if (c1.last_active == null) return -1;
+ if (c2.last_active == null) return 1;
int comp = c2.last_active.compare(c1.last_active);
if (comp == 0) {
return Util.get_conversation_display_name(stream_interactor, c1)
diff --git a/main/src/ui/conversation_summary/view.vala b/main/src/ui/conversation_summary/view.vala
index 0e06a80a..d264de32 100644
--- a/main/src/ui/conversation_summary/view.vala
+++ b/main/src/ui/conversation_summary/view.vala
@@ -151,6 +151,8 @@ public class View : Box {
}
private void load_earlier_messages() {
+ if (earliest_message == null) return;
+
was_value = scrolled.vadjustment.value;
lock(reloading_lock) {
if(reloading) return;
diff --git a/main/src/ui/util.vala b/main/src/ui/util.vala
index 810ab13d..993a996f 100644
--- a/main/src/ui/util.vala
+++ b/main/src/ui/util.vala
@@ -40,6 +40,9 @@ public class Util : Object {
}
public static string get_conversation_display_name(StreamInteractor stream_interactor, Conversation conversation) {
+ if (conversation.type_ == Conversation.Type.GROUPCHAT_PM) {
+ return conversation.counterpart.resourcepart + " from " + get_display_name(stream_interactor, conversation.counterpart.bare_jid, conversation.account);
+ }
return get_display_name(stream_interactor, conversation.counterpart, conversation.account);
}