Only use UI data for active converations cycling, clean up ConversationSelector
This commit is contained in:
parent
27fe07c3b4
commit
d9e45071d0
|
@ -34,7 +34,6 @@ set(RESOURCE_LIST
|
|||
conversation_list_titlebar.ui
|
||||
conversation_list_titlebar_csd.ui
|
||||
global_search.ui
|
||||
conversation_selector/view.ui
|
||||
conversation_selector/chat_row_tooltip.ui
|
||||
conversation_selector/conversation_row.ui
|
||||
conversation_summary/image_toolbar.ui
|
||||
|
@ -105,7 +104,6 @@ SOURCES
|
|||
src/ui/global_search.vala
|
||||
src/ui/conversation_selector/conversation_row.vala
|
||||
src/ui/conversation_selector/list.vala
|
||||
src/ui/conversation_selector/view.vala
|
||||
src/ui/conversation_summary/chat_state_populator.vala
|
||||
src/ui/conversation_summary/content_item_widget_factory.vala
|
||||
src/ui/conversation_summary/content_populator.vala
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="DinoUiConversationSelectorView">
|
||||
<property name="can_focus">True</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolled">
|
||||
<property name="expand">True</property>
|
||||
<property name="hscrollbar_policy">never</property>
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
|
@ -5,8 +5,15 @@
|
|||
<property name="orientation">horizontal</property>
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="DinoUiConversationSelectorView" id="conversation_list">
|
||||
<object class="GtkScrolledWindow" id="scrolled">
|
||||
<property name="expand">True</property>
|
||||
<property name="hscrollbar_policy">never</property>
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="DinoUiConversationSelectorList" id="conversation_list">
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="resize">False</property>
|
||||
|
|
|
@ -134,12 +134,12 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
|
|||
set_accels_for_action("app.add_conference", new string[]{"<Ctrl>G"});
|
||||
|
||||
SimpleAction loop_conversations_action = new SimpleAction("loop_conversations", null);
|
||||
loop_conversations_action.activate.connect(() => {controller.loop_conversations(false);});
|
||||
loop_conversations_action.activate.connect(() => { window.loop_conversations(false); });
|
||||
add_action(loop_conversations_action);
|
||||
set_accels_for_action("app.loop_conversations", new string[]{"<Ctrl>Tab"});
|
||||
|
||||
SimpleAction loop_conversations_bw_action = new SimpleAction("loop_conversations_bw", null);
|
||||
loop_conversations_bw_action.activate.connect(() => {controller.loop_conversations(true);});
|
||||
loop_conversations_bw_action.activate.connect(() => { window.loop_conversations(true); });
|
||||
add_action(loop_conversations_bw_action);
|
||||
set_accels_for_action("app.loop_conversations_bw", new string[]{"<Ctrl><Shift>Tab"});
|
||||
}
|
||||
|
|
|
@ -14,14 +14,9 @@ public class List : ListBox {
|
|||
private string[]? filter_values;
|
||||
private HashMap<Conversation, ConversationRow> rows = new HashMap<Conversation, ConversationRow>(Conversation.hash_func, Conversation.equals_func);
|
||||
|
||||
public List(StreamInteractor stream_interactor) {
|
||||
public List init(StreamInteractor stream_interactor) {
|
||||
this.stream_interactor = stream_interactor;
|
||||
|
||||
get_style_context().add_class("sidebar");
|
||||
set_filter_func(filter);
|
||||
set_header_func(header);
|
||||
set_sort_func(sort);
|
||||
|
||||
stream_interactor.get_module(ConversationManager.IDENTITY).conversation_activated.connect(add_conversation);
|
||||
stream_interactor.get_module(ConversationManager.IDENTITY).conversation_deactivated.connect(remove_conversation);
|
||||
stream_interactor.get_module(MessageProcessor.IDENTITY).message_received.connect(on_message_received);
|
||||
|
@ -34,6 +29,17 @@ public class List : ListBox {
|
|||
foreach (Conversation conversation in stream_interactor.get_module(ConversationManager.IDENTITY).get_active_conversations()) {
|
||||
add_conversation(conversation);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
construct {
|
||||
this.stream_interactor = stream_interactor;
|
||||
|
||||
get_style_context().add_class("sidebar");
|
||||
set_filter_func(filter);
|
||||
set_header_func(header);
|
||||
set_sort_func(sort);
|
||||
|
||||
realize.connect(() => {
|
||||
ListBoxRow? first_row = get_row_at_index(0);
|
||||
if (first_row != null) {
|
||||
|
@ -77,37 +83,44 @@ public class List : ListBox {
|
|||
row = new ConversationRow(stream_interactor, conversation);
|
||||
rows[conversation] = row;
|
||||
add(row);
|
||||
row.closed.connect(() => { select_next_conversation(conversation); });
|
||||
row.closed.connect(() => { select_fallback_conversation(conversation); });
|
||||
row.main_revealer.set_reveal_child(true);
|
||||
}
|
||||
invalidate_sort();
|
||||
}
|
||||
|
||||
private void select_next_conversation(Conversation conversation) {
|
||||
private void select_fallback_conversation(Conversation conversation) {
|
||||
if (get_selected_row() == rows[conversation]) {
|
||||
int index = rows[conversation].get_index();
|
||||
ListBoxRow? index_p1 = get_row_at_index(index + 1);
|
||||
if (index_p1 != null) {
|
||||
select_row(index_p1);
|
||||
row_activated(index_p1);
|
||||
} else if (index > 0) {
|
||||
ListBoxRow? index_m1 = get_row_at_index(index - 1);
|
||||
if (index_m1 != null) {
|
||||
select_row(index_m1);
|
||||
row_activated(index_m1);
|
||||
}
|
||||
ListBoxRow? next_select_row = get_row_at_index(index + 1);
|
||||
if (next_select_row == null) {
|
||||
next_select_row = get_row_at_index(index - 1);
|
||||
}
|
||||
if (next_select_row != null) {
|
||||
select_row(next_select_row);
|
||||
row_activated(next_select_row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void remove_conversation(Conversation conversation) {
|
||||
select_next_conversation(conversation);
|
||||
select_fallback_conversation(conversation);
|
||||
if (rows.has_key(conversation) && !conversation.active) {
|
||||
remove(rows[conversation]);
|
||||
rows.unset(conversation);
|
||||
}
|
||||
}
|
||||
|
||||
public void loop_conversations(bool backwards) {
|
||||
int index = get_selected_row().get_index();
|
||||
int new_index = ((index + (backwards ? -1 : 1)) + rows.size) % rows.size;
|
||||
ListBoxRow? next_select_row = get_row_at_index(new_index);
|
||||
if (next_select_row != null) {
|
||||
select_row(next_select_row);
|
||||
row_activated(next_select_row);
|
||||
}
|
||||
}
|
||||
|
||||
private void header(ListBoxRow row, ListBoxRow? before_row) {
|
||||
if (row.get_header() == null && before_row != null) {
|
||||
row.set_header(new Separator(Orientation.HORIZONTAL));
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
using Gee;
|
||||
using Gtk;
|
||||
using Gdk;
|
||||
|
||||
using Dino.Entities;
|
||||
|
||||
namespace Dino.Ui.ConversationSelector {
|
||||
|
||||
[GtkTemplate (ui = "/im/dino/Dino/conversation_selector/view.ui")]
|
||||
public class View : Box {
|
||||
public List conversation_list;
|
||||
|
||||
[GtkChild] private ScrolledWindow scrolled;
|
||||
|
||||
public View init(StreamInteractor stream_interactor) {
|
||||
conversation_list = new List(stream_interactor) { visible=true };
|
||||
scrolled.add(conversation_list);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -43,7 +43,7 @@ public class UnifiedWindow : Gtk.Window {
|
|||
public ChatInput.View chat_input;
|
||||
public ConversationListTitlebar conversation_list_titlebar;
|
||||
public ConversationListTitlebarCsd conversation_list_titlebar_csd;
|
||||
public ConversationSelector.View filterable_conversation_list;
|
||||
public ConversationSelector.List filterable_conversation_list;
|
||||
public ConversationSummary.ConversationView conversation_frame;
|
||||
public ConversationTitlebar conversation_titlebar;
|
||||
public ConversationTitlebarCsd conversation_titlebar_csd;
|
||||
|
@ -88,8 +88,6 @@ public class UnifiedWindow : Gtk.Window {
|
|||
if (this.conversation == null || !this.conversation.equals(conversation)) {
|
||||
this.conversation = conversation;
|
||||
conversation_selected(conversation);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +97,7 @@ public class UnifiedWindow : Gtk.Window {
|
|||
box.add(paned);
|
||||
chat_input = ((ChatInput.View) builder.get_object("chat_input")).init(stream_interactor);
|
||||
conversation_frame = ((ConversationSummary.ConversationView) builder.get_object("conversation_frame")).init(stream_interactor);
|
||||
filterable_conversation_list = ((ConversationSelector.View) builder.get_object("conversation_list")).init(stream_interactor);
|
||||
filterable_conversation_list = ((ConversationSelector.List) builder.get_object("conversation_list")).init(stream_interactor);
|
||||
goto_end_revealer = (Revealer) builder.get_object("goto_end_revealer");
|
||||
goto_end_button = (Button) builder.get_object("goto_end_button");
|
||||
search_box = ((GlobalSearch) builder.get_object("search_box")).init(stream_interactor);
|
||||
|
@ -167,6 +165,10 @@ public class UnifiedWindow : Gtk.Window {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loop_conversations(bool backwards) {
|
||||
filterable_conversation_list.loop_conversations(backwards);
|
||||
}
|
||||
}
|
||||
|
||||
public class WelcomePlceholder : UnifiedWindowPlaceholder {
|
||||
|
|
|
@ -79,7 +79,7 @@ public class UnifiedWindowController : Object {
|
|||
window.accounts_placeholder.primary_button.clicked.connect(() => { app.activate_action("accounts", null); });
|
||||
window.conversations_placeholder.primary_button.clicked.connect(() => { app.activate_action("add_chat", null); });
|
||||
window.conversations_placeholder.secondary_button.clicked.connect(() => { app.activate_action("add_conference", null); });
|
||||
window.filterable_conversation_list.conversation_list.conversation_selected.connect((conversation) => select_conversation(conversation));
|
||||
window.filterable_conversation_list.conversation_selected.connect((conversation) => select_conversation(conversation));
|
||||
|
||||
var vadjustment = window.conversation_frame.scrolled.vadjustment;
|
||||
vadjustment.notify["value"].connect(() => {
|
||||
|
@ -131,7 +131,7 @@ public class UnifiedWindowController : Object {
|
|||
|
||||
stream_interactor.get_module(ChatInteraction.IDENTITY).on_conversation_selected(conversation);
|
||||
conversation.active = true; // only for conversation_selected
|
||||
window.filterable_conversation_list.conversation_list.on_conversation_selected(conversation); // only for conversation_opened
|
||||
window.filterable_conversation_list.on_conversation_selected(conversation); // only for conversation_opened
|
||||
|
||||
if (do_reset_search) {
|
||||
reset_search_entry();
|
||||
|
@ -142,15 +142,6 @@ public class UnifiedWindowController : Object {
|
|||
}
|
||||
}
|
||||
|
||||
public void loop_conversations(bool backwards = false) {
|
||||
Gee.List<Conversation> conversations = stream_interactor.get_module(ConversationManager.IDENTITY).get_active_conversations();
|
||||
conversations.sort((a, b) => { return b.last_active.compare(a.last_active); });
|
||||
int index = conversations.index_of(this.conversation);
|
||||
index += backwards ? -1 : 1;
|
||||
select_conversation(conversations.get(index % conversations.size));
|
||||
}
|
||||
|
||||
|
||||
private void update_conversation_display_name() {
|
||||
conversation_display_name = Util.get_conversation_display_name(stream_interactor, conversation);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue