[gnome-shell] popup-menu: Allow updating combobox items with scroll wheel
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] popup-menu: Allow updating combobox items with scroll wheel
- Date: Fri, 2 Sep 2011 16:11:39 +0000 (UTC)
commit 86aa4fe0a95f98d8eff03985bedf20f25d9cdfe1
Author: Florian MÃllner <fmuellner gnome org>
Date: Thu Sep 1 19:33:31 2011 +0200
popup-menu: Allow updating combobox items with scroll wheel
Rather than opening the combobox menu, allow using the scroll wheel
to cycle through the visible items.
https://bugzilla.gnome.org/show_bug.cgi?id=657973
js/ui/popupMenu.js | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index c272de7..2551d68 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -1507,6 +1507,10 @@ PopupComboMenu.prototype = {
}
this._getMenuItems()[position].actor.visible = visible;
+ },
+
+ getItemVisible: function(position) {
+ return this._getMenuItems()[position].actor.visible;
}
};
@@ -1533,6 +1537,8 @@ PopupComboBoxMenuItem.prototype = {
if (params.style_class)
this._menu.actor.add_style_class_name(params.style_class);
+ this.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
+
this._activeItemPos = -1;
this._items = [];
},
@@ -1551,6 +1557,33 @@ PopupComboBoxMenuItem.prototype = {
return null;
},
+ _onScrollEvent: function(actor, event) {
+ if (this._activeItemPos == -1)
+ return;
+
+ let position = this._activeItemPos;
+ let direction = event.get_scroll_direction();
+ if (direction == Clutter.ScrollDirection.DOWN) {
+ while (position < this._items.length - 1) {
+ position++;
+ if (this._menu.getItemVisible(position))
+ break;
+ }
+ } else if (direction == Clutter.ScrollDirection.UP) {
+ while (position > 0) {
+ position--;
+ if (this._menu.getItemVisible(position))
+ break;
+ }
+ }
+
+ if (position == this._activeItemPos)
+ return;
+
+ this.setActiveItem(position);
+ this.emit('active-item-changed', position);
+ },
+
activate: function(event) {
let topMenu = this._getTopMenu();
if (!topMenu)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]