[gnome-documents] sidebar: bind F9 to sidebar visibility
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] sidebar: bind F9 to sidebar visibility
- Date: Fri, 28 Oct 2011 19:21:00 +0000 (UTC)
commit c7a37f41baca7a38c3a08ab1e86f192370693db3
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu Oct 27 18:40:18 2011 -0400
sidebar: bind F9 to sidebar visibility
As most of the other GNOME applications do already.
src/mainWindow.js | 7 +++++++
src/sidebar.js | 31 +++++++++++++++++++++++++------
2 files changed, 32 insertions(+), 6 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 8d645fc..0c2660c 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -242,6 +242,13 @@ MainWindow.prototype = {
},
_handleKeyOverview: function(event) {
+ let keyval = event.get_keyval()[1];
+
+ if (keyval == Gdk.KEY_F9) {
+ this._sidebar.toggleVisibility();
+ return true;
+ }
+
if (Utils.isSearchEvent(event)) {
Global.focusController.toggleSearch();
return true;
diff --git a/src/sidebar.js b/src/sidebar.js
index 103346d..05e6f97 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -404,6 +404,8 @@ function Sidebar() {
Sidebar.prototype = {
_init: function() {
+ this._sidebarVisible = true;
+
this.widget = new Gtk.Notebook({ show_tabs: false });
this.widget.get_style_context().add_class(Gtk.STYLE_CLASS_SIDEBAR);
@@ -433,15 +435,32 @@ Sidebar.prototype = {
this.widget.set_current_page(_SIDEBAR_SOURCES_PAGE);
},
+ _moveOut: function() {
+ Tweener.addTween(this.actor, { width: 0,
+ time: 0.15,
+ transition: 'easeInQuad' });
+ },
+
+ _moveIn: function() {
+ Tweener.addTween(this.actor, { width: this.widget.get_preferred_width()[1],
+ time: 0.15,
+ transition: 'easeOutQuad' });
+ },
+
_onWindowModeChanged: function(controller, mode) {
if (mode == WindowMode.WindowMode.PREVIEW) {
- Tweener.addTween(this.actor, { width: 0,
- time: 0.15,
- transition: 'easeInQuad' });
+ this._moveOut();
} else if (mode == WindowMode.WindowMode.OVERVIEW) {
- Tweener.addTween(this.actor, { width: this.widget.get_preferred_width()[1],
- time: 0.15,
- transition: 'easeOutQuad' });
+ if (this._sidebarVisible)
+ this._moveIn();
}
+ },
+
+ toggleVisibility: function() {
+ this._sidebarVisible = !this._sidebarVisible;
+ if (this._sidebarVisible)
+ this._moveIn();
+ else
+ this._moveOut();
}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]