Preselect next conversation when closed and crossfade
This commit is contained in:
parent
582cc78edd
commit
be2234835a
|
@ -6,27 +6,44 @@
|
||||||
<property name="homogeneous">False</property>
|
<property name="homogeneous">False</property>
|
||||||
<property name="spacing">0</property>
|
<property name="spacing">0</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkScrolledWindow" id="scrolled">
|
<object class="GtkStack" id="stack">
|
||||||
|
<property name="transition_type">crossfade</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkScrolledWindow" id="scrolled">
|
||||||
<property name="margin">15</property>
|
<property name="visible">True</property>
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="main">
|
<object class="GtkBox">
|
||||||
<property name="expand">False</property>
|
<property name="margin">15</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">15</property>
|
<child>
|
||||||
<property name="visible">True</property>
|
<object class="GtkBox" id="main">
|
||||||
</object>
|
<property name="expand">False</property>
|
||||||
</child>
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<property name="spacing">15</property>
|
||||||
<object class="GtkBox" id="filler">
|
<property name="visible">True</property>
|
||||||
<property name="expand">True</property>
|
</object>
|
||||||
<property name="visible">True</property>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="filler">
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="name">main</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="name">void</property>
|
||||||
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class ChatInput : Box {
|
||||||
check_convert_smiley();
|
check_convert_smiley();
|
||||||
}
|
}
|
||||||
if (event.keyval == Key.Return) {
|
if (event.keyval == Key.Return) {
|
||||||
if (event.state == ModifierType.SHIFT_MASK) {
|
if ((event.state & ModifierType.SHIFT_MASK) > 0) {
|
||||||
text_input.buffer.insert_at_cursor("\n", 1);
|
text_input.buffer.insert_at_cursor("\n", 1);
|
||||||
} else if (text_input.buffer.text != ""){
|
} else if (text_input.buffer.text != ""){
|
||||||
send_text();
|
send_text();
|
||||||
|
|
|
@ -11,6 +11,9 @@ namespace Dino.Ui.ConversationSelector {
|
||||||
[GtkTemplate (ui = "/org/dino-im/conversation_selector/conversation_row.ui")]
|
[GtkTemplate (ui = "/org/dino-im/conversation_selector/conversation_row.ui")]
|
||||||
public abstract class ConversationRow : ListBoxRow {
|
public abstract class ConversationRow : ListBoxRow {
|
||||||
|
|
||||||
|
public signal void closed();
|
||||||
|
public signal void disappeared();
|
||||||
|
|
||||||
[GtkChild] protected Image image;
|
[GtkChild] protected Image image;
|
||||||
[GtkChild] private Label name_label;
|
[GtkChild] private Label name_label;
|
||||||
[GtkChild] private Label time_label;
|
[GtkChild] private Label time_label;
|
||||||
|
@ -120,8 +123,10 @@ public abstract class ConversationRow : ListBoxRow {
|
||||||
private void on_x_button_clicked() {
|
private void on_x_button_clicked() {
|
||||||
main_revealer.set_transition_type(RevealerTransitionType.SLIDE_UP);
|
main_revealer.set_transition_type(RevealerTransitionType.SLIDE_UP);
|
||||||
main_revealer.set_reveal_child(false);
|
main_revealer.set_reveal_child(false);
|
||||||
|
closed();
|
||||||
main_revealer.notify["child-revealed"].connect(() => {
|
main_revealer.notify["child-revealed"].connect(() => {
|
||||||
conversation.active = false;
|
conversation.active = false;
|
||||||
|
disappeared();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,10 @@ public class List : ListBox {
|
||||||
Idle.add(() => {add_conversation(conversation); return false;});
|
Idle.add(() => {add_conversation(conversation); return false;});
|
||||||
});
|
});
|
||||||
MessageManager.get_instance(stream_interactor).message_received.connect((message, conversation) => {
|
MessageManager.get_instance(stream_interactor).message_received.connect((message, conversation) => {
|
||||||
Idle.add(() => {message_received(message, conversation); return false;});
|
Idle.add(() => {on_message_received(message, conversation); return false;});
|
||||||
});
|
});
|
||||||
MessageManager.get_instance(stream_interactor).message_sent.connect((message, conversation) => {
|
MessageManager.get_instance(stream_interactor).message_sent.connect((message, conversation) => {
|
||||||
Idle.add(() => {message_received(message, conversation); return false;});
|
Idle.add(() => {on_message_received(message, conversation); return false;});
|
||||||
});
|
});
|
||||||
PresenceManager.get_instance(stream_interactor).show_received.connect((show, jid, account) => {
|
PresenceManager.get_instance(stream_interactor).show_received.connect((show, jid, account) => {
|
||||||
Idle.add(() => {
|
Idle.add(() => {
|
||||||
|
@ -93,7 +93,21 @@ public class List : ListBox {
|
||||||
invalidate_filter();
|
invalidate_filter();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add_conversation(Conversation conversation) {
|
public void on_conversation_selected(Conversation conversation) {
|
||||||
|
if (!rows.has_key(conversation)) {
|
||||||
|
add_conversation(conversation);
|
||||||
|
}
|
||||||
|
this.select_row(rows[conversation]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void on_message_received(Entities.Message message, Conversation conversation) {
|
||||||
|
if (rows.has_key(conversation)) {
|
||||||
|
rows[conversation].message_received(message);
|
||||||
|
invalidate_sort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void add_conversation(Conversation conversation) {
|
||||||
ConversationRow row;
|
ConversationRow row;
|
||||||
if (!rows.has_key(conversation)) {
|
if (!rows.has_key(conversation)) {
|
||||||
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
|
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
|
||||||
|
@ -103,33 +117,35 @@ public class List : ListBox {
|
||||||
}
|
}
|
||||||
rows[conversation] = row;
|
rows[conversation] = row;
|
||||||
add(row);
|
add(row);
|
||||||
|
row.closed.connect(() => { on_conversation_closed(conversation); });
|
||||||
|
row.disappeared.connect(() => { on_conversation_disappeared(conversation); });
|
||||||
row.main_revealer.set_reveal_child(true);
|
row.main_revealer.set_reveal_child(true);
|
||||||
conversation.notify["active"].connect((s, p) => {
|
|
||||||
if (rows.has_key(conversation) && !conversation.active) {
|
|
||||||
remove_conversation(conversation);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
invalidate_sort();
|
invalidate_sort();
|
||||||
queue_draw();
|
queue_draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove_conversation(Conversation conversation) {
|
private void on_conversation_closed(Conversation conversation) {
|
||||||
remove(rows[conversation]);
|
if (get_selected_row() == rows[conversation]) {
|
||||||
rows.unset(conversation);
|
int index = rows[conversation].get_index();
|
||||||
}
|
ListBoxRow? index_p1 = get_row_at_index(index + 1);
|
||||||
|
if (index_p1 != null) {
|
||||||
public void on_conversation_selected(Conversation conversation) {
|
select_row(index_p1);
|
||||||
if (!rows.has_key(conversation)) {
|
row_activated(index_p1);
|
||||||
add_conversation(conversation);
|
} else if (index > 0) {
|
||||||
|
ListBoxRow? index_m1 = get_row_at_index(index - 1);
|
||||||
|
if (index_m1 != null) {
|
||||||
|
select_row(index_m1);
|
||||||
|
row_activated(index_p1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.select_row(rows[conversation]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void message_received(Entities.Message message, Conversation conversation) {
|
private void on_conversation_disappeared(Conversation conversation) {
|
||||||
if (rows.has_key(conversation)) {
|
if (rows.has_key(conversation) && !conversation.active) {
|
||||||
rows[conversation].message_received(message);
|
remove(rows[conversation]);
|
||||||
invalidate_sort();
|
rows.unset(conversation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,8 @@ public interface ConversationItem : Gtk.Widget {
|
||||||
switch (get_message_kind(message)) {
|
switch (get_message_kind(message)) {
|
||||||
case MessageKind.TEXT:
|
case MessageKind.TEXT:
|
||||||
return new MergedMessageItem(stream_interactor, conversation, message);
|
return new MergedMessageItem(stream_interactor, conversation, message);
|
||||||
break;
|
|
||||||
case MessageKind.ME_COMMAND:
|
case MessageKind.ME_COMMAND:
|
||||||
return new SlashMeItem(stream_interactor, conversation, message);
|
return new SlashMeItem(stream_interactor, conversation, message);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ public class View : Box {
|
||||||
|
|
||||||
[GtkChild] private ScrolledWindow scrolled;
|
[GtkChild] private ScrolledWindow scrolled;
|
||||||
[GtkChild] private Box main;
|
[GtkChild] private Box main;
|
||||||
|
[GtkChild] private Stack stack;
|
||||||
|
|
||||||
private StreamInteractor stream_interactor;
|
private StreamInteractor stream_interactor;
|
||||||
private ConversationItem? last_conversation_item;
|
private ConversationItem? last_conversation_item;
|
||||||
|
@ -56,6 +57,7 @@ public class View : Box {
|
||||||
|
|
||||||
public void initialize_for_conversation(Conversation? conversation) {
|
public void initialize_for_conversation(Conversation? conversation) {
|
||||||
this.conversation = conversation;
|
this.conversation = conversation;
|
||||||
|
stack.set_visible_child_name("void");
|
||||||
clear();
|
clear();
|
||||||
conversation_items.clear();
|
conversation_items.clear();
|
||||||
was_upper = null;
|
was_upper = null;
|
||||||
|
@ -95,6 +97,7 @@ public class View : Box {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update_chat_state();
|
update_chat_state();
|
||||||
|
stack.set_visible_child_name("main");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_received_state(Account account, Jid jid, string state) {
|
private void on_received_state(Account account, Jid jid, string state) {
|
||||||
|
|
Loading…
Reference in a new issue