[gnome-documents] preview: make the thumbbar show on click
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] preview: make the thumbbar show on click
- Date: Thu, 13 Dec 2012 14:03:22 +0000 (UTC)
commit c793eb87db64349227ebe04ff088cca42fe217c0
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Nov 28 18:22:32 2012 -0500
preview: make the thumbbar show on click
And disappear when you click either on the document or on a scrollbar
itself.
src/preview.js | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 43 insertions(+), 1 deletions(-)
---
diff --git a/src/preview.js b/src/preview.js
index 66a5c01..85b6ff2 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -46,11 +46,17 @@ const PreviewView = new Lang.Class({
_init: function(overlayLayout) {
this._model = null;
this._jobFind = null;
+ this._controlsVisible = false;
+ this._selectionChanged = false;
this.widget = new Gtk.ScrolledWindow({ hexpand: true,
vexpand: true,
shadow_type: Gtk.ShadowType.IN });
this.widget.get_style_context().add_class('documents-scrolledwin');
+ this.widget.get_hscrollbar().connect('button-press-event', Lang.bind(this, this._onScrollbarClick));
+ this.widget.get_vscrollbar().connect('button-press-event', Lang.bind(this, this._onScrollbarClick));
+ this.widget.get_hadjustment().connect('value-changed', Lang.bind(this, this._onAdjustmentChanged));
+ this.widget.get_vadjustment().connect('value-changed', Lang.bind(this, this._onAdjustmentChanged));
this._createView();
@@ -58,6 +64,10 @@ const PreviewView = new Lang.Class({
this._thumbBar = new PreviewThumbnails(this._model);
overlayLayout.add(this._thumbBar.actor,
Clutter.BinAlignment.FILL, Clutter.BinAlignment.END);
+ this._thumbBar.view.connect('selection-changed', Lang.bind(this,
+ function() {
+ this._selectionChanged = true;
+ }));
this.widget.show_all();
@@ -105,10 +115,20 @@ const PreviewView = new Lang.Class({
this.view.connect('button-press-event',
Lang.bind(this, this._onButtonPressEvent));
+ this.view.connect('button-release-event',
+ Lang.bind(this, this._onButtonReleaseEvent));
this.view.connect('key-press-event',
Lang.bind(this, this._onKeyPressEvent));
},
+ _flipControlsState: function() {
+ this._controlsVisible = !this._controlsVisible;
+ if (this._controlsVisible)
+ this._thumbBar.show();
+ else
+ this._thumbBar.hide();
+ },
+
_onKeyPressEvent: function(widget, event) {
let keyval = event.get_keyval()[1];
let state = event.get_state()[1];
@@ -151,6 +171,29 @@ const PreviewView = new Lang.Class({
return false;
},
+ _onButtonReleaseEvent: function(widget, event) {
+ let button = event.get_button()[1];
+ let clickCount = event.get_click_count()[1];
+
+ if (button == 1 && clickCount == 1)
+ this._flipControlsState();
+
+ return false;
+ },
+
+ _onScrollbarClick: function() {
+ if (this._controlsVisible)
+ this._flipControlsState();
+
+ return false;
+ },
+
+ _onAdjustmentChanged: function() {
+ if (this._controlsVisible && !this._selectionChanged)
+ this._flipControlsState();
+ this._selectionChanged = false;
+ },
+
_changeRotation: function(offset) {
let rotation = this._model.get_rotation();
this._model.set_rotation(rotation + offset);
@@ -200,7 +243,6 @@ const PreviewView = new Lang.Class({
this._createView();
this.view.set_model(this._model);
this._thumbBar.view.model = model;
- this._thumbBar.show();
}
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]