[polari] roomList: Switch to channels with unread/pending messages
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] roomList: Switch to channels with unread/pending messages
- Date: Wed, 17 Feb 2016 21:47:42 +0000 (UTC)
commit 63db11456afea97e5d6cafcbb3f4b7274724848f
Author: raresv <rares visalom gmail com>
Date: Mon Feb 15 14:12:13 2016 +0200
roomList: Switch to channels with unread/pending messages
Add functionality to switch to channels that have
pending/unread messages.
The Alt+Shift+Down and Ctrl+Shift+PageDown combinations
can be used to switch to the next room with pending/unread
messages, while the Alt+Shift+Up and Ctrl+Shift+PageUp
combinations can be used to switch to the previous room
with pending/unread messages.
Also, the keyboard shortcuts have been updated.
https://bugzilla.gnome.org/show_bug.cgi?id=761290
data/resources/help-overlay.ui | 15 +++++++++++++++
src/application.js | 6 +++++-
src/roomList.js | 30 +++++++++++++++++++++++++++++-
3 files changed, 49 insertions(+), 2 deletions(-)
---
diff --git a/data/resources/help-overlay.ui b/data/resources/help-overlay.ui
index 6a871bd..019f418 100644
--- a/data/resources/help-overlay.ui
+++ b/data/resources/help-overlay.ui
@@ -5,6 +5,7 @@
<child>
<object class="GtkShortcutsSection">
<property name="visible">True</property>
+ <property name="max-height">14</property>
<!--property name="section-name">shortcuts</property-->
<child>
<object class="GtkShortcutsGroup">
@@ -75,6 +76,20 @@
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">True</property>
+ <property name="title" translatable="yes" context="shortcut window">Next Room with Unread
Messages</property>
+ <property name="accelerator"><Primary><Shift>Page_Down</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes" context="shortcut window">Previous Room with
Unread Messages</property>
+ <property name="accelerator"><Primary><Shift>Page_Up</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
<property name="title" translatable="yes" context="shortcut window">First Room</property>
<property name="accelerator"><Primary>Home</property>
</object>
diff --git a/src/application.js b/src/application.js
index a1e50d6..225e6ac 100644
--- a/src/application.js
+++ b/src/application.js
@@ -108,7 +108,11 @@ const Application = new Lang.Class({
{ name: 'last-room',
accels: ['<Primary>End'] },
{ name: 'nth-room',
- parameter_type: GLib.VariantType.new('i') }
+ parameter_type: GLib.VariantType.new('i') },
+ { name: 'next-pending-room',
+ accels: ['<Alt><Shift>Down', '<Primary><Shift>Page_Down']},
+ { name: 'previous-pending-room',
+ accels: ['<Alt><Shift>Up', '<Primary><Shift>Page_Up']}
];
actionEntries.forEach(Lang.bind(this,
function(actionEntry) {
diff --git a/src/roomList.js b/src/roomList.js
index 3bad1e2..f2cc3b5 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -61,6 +61,10 @@ const RoomRow = new Lang.Class({
return this._room.account;
},
+ get hasPending() {
+ return !this.get_style_context().has_class('inactive');
+ },
+
selected: function() {
if (!this._room.channel)
this._updatePending();
@@ -395,6 +399,18 @@ const RoomList = new Lang.Class({
return;
this.select_row(this._getRoomRowAtIndex(n - 1));
}));
+ action = app.lookup_action('next-pending-room');
+ action.connect('activate', Lang.bind(this,
+ function() {
+ this._moveSelectionFull(Gtk.DirectionType.DOWN,
+ (row) => { return row.hasPending; });
+ }));
+ action = app.lookup_action('previous-pending-room');
+ action.connect('activate', Lang.bind(this,
+ function() {
+ this._moveSelectionFull(Gtk.DirectionType.UP,
+ (row) => { return row.hasPending; });
+ }));
},
_onLeaveActivated: function(action, param) {
@@ -426,12 +442,24 @@ const RoomList = new Lang.Class({
},
_moveSelection: function(direction) {
+ this._moveSelectionFull(direction, () => { return true; });
+ },
+
+ _moveSelectionFull: function(direction, testFunction){
let current = this.get_selected_row();
if (!current)
return;
+
let inc = direction == Gtk.DirectionType.UP ? -1 : 1;
let index = this._rowToRoomIndex(current.get_index());
- let row = this._getRoomRowAtIndex(index + inc);
+
+ let row = current;
+
+ do {
+ index += inc;
+ row = this._getRoomRowAtIndex(index);
+ } while (row && !testFunction(row));
+
if (row)
this.select_row(row);
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]