Allow to cycle active conversations with Ctrl+(Shift)+Tab

Closes #400, Closes #142, related to #145
This commit is contained in:
Roberto Santalla 2019-03-21 17:20:35 +01:00 committed by fiaxh
parent c14459a2bd
commit 27fe07c3b4
2 changed files with 19 additions and 0 deletions

View file

@ -132,6 +132,16 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
});
add_action(conference_action);
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);});
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);});
add_action(loop_conversations_bw_action);
set_accels_for_action("app.loop_conversations_bw", new string[]{"<Ctrl><Shift>Tab"});
}
public bool use_csd() {

View file

@ -142,6 +142,15 @@ 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);
}