[gnome-documents] window: pack the views directly in a scrolled window
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] window: pack the views directly in a scrolled window
- Date: Fri, 26 Aug 2011 21:59:07 +0000 (UTC)
commit 83fccf472f93e9d2268f6762f6829e3bae3b174d
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Fri Aug 26 17:55:06 2011 -0400
window: pack the views directly in a scrolled window
Adding a viewport with a box inside here just doesn't work. This way
of handling has its downsizes, but it handles better maximization and
scrolling.
data/gtk-style.css | 5 +++++
src/loadMore.js | 21 +++++++++++++++------
src/mainWindow.js | 46 +++++++++++++++++++++++++++++++++++-----------
3 files changed, 55 insertions(+), 17 deletions(-)
---
diff --git a/data/gtk-style.css b/data/gtk-style.css
index 62ca2eb..07fa92d 100644
--- a/data/gtk-style.css
+++ b/data/gtk-style.css
@@ -2,4 +2,9 @@
.shadowed {
icon-shadow: 2 2 shade(@theme_bg_color, 0.80);
+}
+
+#ViewLoadMore {
+ border-image-width: 0 2 2 2;
+ border-width: 0 1 1 1;
}
\ No newline at end of file
diff --git a/src/loadMore.js b/src/loadMore.js
index f9d5b93..41b83a6 100644
--- a/src/loadMore.js
+++ b/src/loadMore.js
@@ -32,15 +32,19 @@ function LoadMoreButton() {
LoadMoreButton.prototype = {
_init: function() {
+ this._block = false;
+
this._controller = Global.offsetController;
this._controllerId =
this._controller.connect('item-count-changed',
Lang.bind(this, this._onItemCountChanged));
- this.widget = new Gtk.Button();
- this.widget.connect('clicked', Lang.bind(this, function() {
- this._controller.increaseOffset();
- }));
+ this.widget = new Gtk.Button({ no_show_all: true,
+ name: 'ViewLoadMore' });
+ this.widget.connect('clicked', Lang.bind(this,
+ function() {
+ this._controller.increaseOffset();
+ }));
this.widget.connect('destroy', Lang.bind(this,
function() {
@@ -50,11 +54,11 @@ LoadMoreButton.prototype = {
this._onItemCountChanged();
},
- _onItemCountChanged: function(itemCount) {
+ _onItemCountChanged: function() {
let remainingDocs = this._controller.getRemainingDocs();
let offsetStep = this._controller.getOffsetStep();
- if (remainingDocs <= 0) {
+ if (remainingDocs <= 0 || this._block) {
this.widget.hide();
return;
}
@@ -64,5 +68,10 @@ LoadMoreButton.prototype = {
this.widget.label = _("Load %d more documents").format(remainingDocs);
this.widget.show();
+ },
+
+ setBlock: function(block) {
+ this._block = block;
+ this._onItemCountChanged();
}
};
\ No newline at end of file
diff --git a/src/mainWindow.js b/src/mainWindow.js
index cd9d98c..66ab631 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -52,6 +52,7 @@ function MainWindow() {
MainWindow.prototype = {
_init: function() {
+ this._adjChangedId = 0;
this._pdfLoader = null;
this._loaderCancellable = null;
this._loaderTimeout = 0;
@@ -86,12 +87,45 @@ MainWindow.prototype = {
this._scrolledWin = new Gtk.ScrolledWindow({ hexpand: true,
vexpand: true,
shadow_type: Gtk.ShadowType.IN });
+ this._scrolledWin.get_style_context().set_junction_sides(Gtk.JunctionSides.BOTTOM);
this._viewContainer.add(this._scrolledWin);
+ this._loadMore = new LoadMore.LoadMoreButton();
+ this._viewContainer.add(this._loadMore.widget);
+
+ this._scrolledWin.vadjustment.connect('value-changed', Lang.bind(this, this._onAdjustmentChange));
+ this._onAdjustmentChange(this._scrolledWin.vadjustment);
+
this._grid.show_all();
this._prepareForOverview();
},
+ _onAdjustmentChange: function(adjustment) {
+ let end = (adjustment.value == (adjustment.upper - adjustment.get_page_size()));
+
+ if (adjustment.value == 0 &&
+ adjustment.upper == 0 &&
+ adjustment.get_page_size() == 0)
+ end = false;
+
+ if (end) {
+ if (!this._adjChangedId) {
+ this._loadMore.setBlock(false);
+
+ //wait for a changed event
+ this._adjChangedId = adjustment.connect('changed', Lang.bind(this,
+ function(adjustment) {
+ adjustment.disconnect(this._adjChangedId);
+ this._adjChangedId = 0;
+
+ this._loadMore.setBlock(true);
+ }));
+ }
+ } else {
+ this._loadMore.setBlock(true);
+ }
+ },
+
_destroyView: function() {
let child = this._scrolledWin.get_child();
if (child)
@@ -103,23 +137,13 @@ MainWindow.prototype = {
this._destroyView();
- this._loadMore = new LoadMore.LoadMoreButton();
- this._viewBox = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL });
- this._viewBox.add(this._loadMore.widget);
-
if (isList)
this.view = new ListView.ListView(this);
else
this.view = new IconView.IconView(this);
this.view.connect('item-activated', Lang.bind(this, this._onViewItemActivated));
-
- this._viewBox.attach_next_to(this.view.widget, this._loadMore.widget,
- Gtk.PositionType.TOP, 1, 1);
-
- this._scrolledWin.add_with_viewport(this._viewBox);
-
- this._viewBox.show();
+ this._scrolledWin.add(this.view.widget);
},
_refreshViewSettings: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]