[gnome-documents] preview: create and destroy the fullscreen toolbar on fullscreen-changed
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] preview: create and destroy the fullscreen toolbar on fullscreen-changed
- Date: Tue, 15 Jan 2013 18:55:01 +0000 (UTC)
commit 2854bddb2f8565ab6ffdfcf741251c026a2ca0a2
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Jan 15 10:21:53 2013 -0500
preview: create and destroy the fullscreen toolbar on fullscreen-changed
Instead of creating it once; otherwise we'll have to deal with updating
its state whenever the document changes.
src/preview.js | 35 ++++++++++++++++++++++++-----------
1 files changed, 24 insertions(+), 11 deletions(-)
---
diff --git a/src/preview.js b/src/preview.js
index a801ad1..34d7eaa 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -52,9 +52,11 @@ const PreviewView = new Lang.Class({
this._controlsVisible = false;
this._pageChanged = false;
this._viewSelectionChanged = false;
+ this._fsToolbar = null;
+ this._overlayLayout = overlayLayout;
Application.modeController.connect('fullscreen-changed',
- Lang.bind(this, this._syncControlsVisible));
+ Lang.bind(this, this._onFullscreenChanged));
this.widget = new Gtk.ScrolledWindow({ hexpand: true,
vexpand: true,
@@ -69,15 +71,9 @@ const PreviewView = new Lang.Class({
// create page nav bar
this._navBar = new PreviewNav(this._model);
- overlayLayout.add(this._navBar.actor,
+ this._overlayLayout.add(this._navBar.actor,
Clutter.BinAlignment.FILL, Clutter.BinAlignment.END);
- // create fullscreen toolbar (hidden by default)
- this._fsToolbar = new PreviewFullscreenToolbar(this);
- this._fsToolbar.setModel(this._model);
- overlayLayout.add(this._fsToolbar.actor,
- Clutter.BinAlignment.FILL, Clutter.BinAlignment.START);
-
this.widget.show_all();
this._zoomIn = Application.application.lookup_action('zoom-in');
@@ -162,15 +158,33 @@ const PreviewView = new Lang.Class({
_syncControlsVisible: function() {
if (this._controlsVisible) {
- if (Application.modeController.getFullscreen())
+ if (this._fsToolbar)
this._fsToolbar.show();
this._navBar.show();
} else {
- this._fsToolbar.hide();
+ if (this._fsToolbar)
+ this._fsToolbar.hide();
this._navBar.hide();
}
},
+ _onFullscreenChanged: function() {
+ let fullscreen = Application.modeController.getFullscreen();
+
+ if (fullscreen) {
+ // create fullscreen toolbar (hidden by default)
+ this._fsToolbar = new PreviewFullscreenToolbar(this);
+ this._fsToolbar.setModel(this._model);
+ this._overlayLayout.add(this._fsToolbar.actor,
+ Clutter.BinAlignment.FILL, Clutter.BinAlignment.START);
+ } else {
+ this._fsToolbar.actor.destroy();
+ this._fsToolbar = null;
+ }
+
+ this._syncControlsVisible();
+ },
+
_onKeyPressEvent: function(widget, event) {
let keyval = event.get_keyval()[1];
let state = event.get_state()[1];
@@ -325,7 +339,6 @@ const PreviewView = new Lang.Class({
this._createView();
this.view.set_model(this._model);
this._navBar.widget.document_model = model;
- this._fsToolbar.setModel(model);
this._model.connect('page-changed', Lang.bind(this,
function() {
this._pageChanged = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]