[gnome-documents/wip/ui-changes] preview: make buttons insensitive when string doesn't match
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/ui-changes] preview: make buttons insensitive when string doesn't match
- Date: Tue, 4 Dec 2012 23:16:55 +0000 (UTC)
commit 318297b9bcee3b69efe447de747ef33d27bbb2ad
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Dec 4 18:12:44 2012 -0500
preview: make buttons insensitive when string doesn't match
Or when there's no string at all.
src/preview.js | 37 ++++++++++++++++++++++++-------------
1 files changed, 24 insertions(+), 13 deletions(-)
---
diff --git a/src/preview.js b/src/preview.js
index 5433b62..0aa85d9 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -30,6 +30,7 @@ const _ = imports.gettext.gettext;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
+const Signals = imports.signals;
const Global = imports.global;
const Tweener = imports.util.tweener;
@@ -267,6 +268,7 @@ const PreviewView = new Lang.Class({
// FIXME: ev_job_find_get_results() returns a GList **
// and thus is not introspectable
GdPrivate.ev_view_find_changed(this.view, job, page);
+ this.emit('search-changed', job.has_results());
},
setModel: function(model) {
@@ -293,6 +295,7 @@ const PreviewView = new Lang.Class({
return this._model;
}
});
+Signals.addSignalMethods(PreviewView.prototype);
const PreviewThumbnails = new Lang.Class({
Name: 'PreviewThumbnails',
@@ -413,6 +416,7 @@ const PreviewSearchbar = new Lang.Class({
this.parent();
this._previewView = previewView;
+ this._previewView.connect('search-changed', Lang.bind(this, this._onSearchChanged));
},
createSearchWidgets: function() {
@@ -432,19 +436,26 @@ const PreviewSearchbar = new Lang.Class({
controlsBox.get_style_context().add_class('raised');
this._searchContainer.add(controlsBox);
- let prev = new Gtk.Button({ action_name: 'app.find-prev' });
- prev.set_image(new Gtk.Image({ icon_name: 'go-up-symbolic',
- icon_size: Gtk.IconSize.MENU,
- margin: 2 }));
- prev.set_tooltip_text(_("Find Previous"));
- controlsBox.add(prev);
-
- let next = new Gtk.Button({ action_name: 'app.find-next' });
- next.set_image(new Gtk.Image({ icon_name: 'go-down-symbolic',
- icon_size: Gtk.IconSize.MENU,
- margin: 2 }));
- next.set_tooltip_text(_("Find Next"));
- controlsBox.add(next);
+ this._prev = new Gtk.Button({ action_name: 'app.find-prev' });
+ this._prev.set_image(new Gtk.Image({ icon_name: 'go-up-symbolic',
+ icon_size: Gtk.IconSize.MENU,
+ margin: 2 }));
+ this._prev.set_tooltip_text(_("Find Previous"));
+ controlsBox.add(this._prev);
+
+ this._next = new Gtk.Button({ action_name: 'app.find-next' });
+ this._next.set_image(new Gtk.Image({ icon_name: 'go-down-symbolic',
+ icon_size: Gtk.IconSize.MENU,
+ margin: 2 }));
+ this._next.set_tooltip_text(_("Find Next"));
+ controlsBox.add(this._next);
+
+ this._onSearchChanged(this._previewView, false);
+ },
+
+ _onSearchChanged: function(view, hasResults) {
+ this._prev.sensitive = hasResults;
+ this._next.sensitive = hasResults;
},
entryChanged: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]