[gnome-documents] searchbar: Use inheritance instead of composition
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] searchbar: Use inheritance instead of composition
- Date: Mon, 3 Aug 2015 16:56:19 +0000 (UTC)
commit f3c2cfac50b9d14d44f9e6c203ddf2784d61d482
Author: Alessandro Bono <shadow openaliasbox org>
Date: Tue Jul 28 14:04:32 2015 +0200
searchbar: Use inheritance instead of composition
https://bugzilla.gnome.org/show_bug.cgi?id=752792
src/embed.js | 4 ++--
src/mainToolbar.js | 2 +-
src/preview.js | 4 ++--
src/searchbar.js | 45 +++++++++++++++++++++------------------------
4 files changed, 26 insertions(+), 29 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index 32b54ba..939102b 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -306,8 +306,8 @@ const Embed = new Lang.Class({
}
if (this._toolbar.searchbar) {
- this._toolbar.searchbar.connect('activate-result',
- Lang.bind(this, this._onActivateResult));
+ this._toolbar.searchbar.connectJS('activate-result',
+ Lang.bind(this, this._onActivateResult));
}
},
diff --git a/src/mainToolbar.js b/src/mainToolbar.js
index 85e3247..5b5b5de 100644
--- a/src/mainToolbar.js
+++ b/src/mainToolbar.js
@@ -52,7 +52,7 @@ const MainToolbar = new Lang.Class({
this.searchbar = this.createSearchbar();
if (this.searchbar)
- this.add(this.searchbar.widget);
+ this.add(this.searchbar);
let loadStartedId = Application.documentManager.connect('load-started', Lang.bind(this,
function() {
diff --git a/src/preview.js b/src/preview.js
index 06aa4b2..1631be1 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -985,7 +985,7 @@ const PreviewSearchbar = new Lang.Class({
this._previewView.startSearch(this._searchEntry.get_text());
},
- show: function() {
+ reveal: function() {
this.parent();
if (!this._searchEntry.get_text()) {
@@ -997,7 +997,7 @@ const PreviewSearchbar = new Lang.Class({
this._previewView.startSearch(this._searchEntry.get_text());
},
- hide: function() {
+ conceal: function() {
this._previewView.view.find_set_highlight_search(false);
this.searchChangeBlocked = true;
diff --git a/src/searchbar.js b/src/searchbar.js
index ebd61d6..adca056 100644
--- a/src/searchbar.js
+++ b/src/searchbar.js
@@ -37,18 +37,19 @@ const Utils = imports.utils;
const Searchbar = new Lang.Class({
Name: 'Searchbar',
+ Extends: Gtk.SearchBar,
_init: function() {
this.searchChangeBlocked = false;
- this.widget = new Gtk.SearchBar();
+ this.parent();
// subclasses will create this._searchEntry and this._searchContainer
// GtkWidgets
this.createSearchWidgets();
- this.widget.add(this._searchContainer);
- this.widget.connect_entry(this._searchEntry);
+ this.add(this._searchContainer);
+ this.connect_entry(this._searchEntry);
this._searchEntry.connect('search-changed', Lang.bind(this,
function() {
@@ -57,9 +58,9 @@ const Searchbar = new Lang.Class({
this.entryChanged();
}));
- this.widget.connect('notify::search-mode-enabled', Lang.bind(this,
+ this.connect('notify::search-mode-enabled', Lang.bind(this,
function() {
- let searchEnabled = this.widget.search_mode_enabled;
+ let searchEnabled = this.search_mode_enabled;
Application.application.change_action_state('search', GLib.Variant.new('b', searchEnabled));
}));
@@ -68,20 +69,20 @@ const Searchbar = new Lang.Class({
Lang.bind(this, this._onActionStateChanged));
this._onActionStateChanged(Application.application, 'search',
Application.application.get_action_state('search'));
- this.widget.connect('destroy', Lang.bind(this,
+ this.connect('destroy', Lang.bind(this,
function() {
Application.application.disconnect(searchStateId);
Application.application.change_action_state('search', GLib.Variant.new('b', false));
}));
- this.widget.show_all();
+ this.show_all();
},
_onActionStateChanged: function(source, actionName, state) {
if (state.get_boolean())
- this.show();
+ this.reveal();
else
- this.hide();
+ this.conceal();
},
createSearchWidgets: function() {
@@ -92,36 +93,32 @@ const Searchbar = new Lang.Class({
log('Error: Searchbar implementations must override entryChanged');
},
- destroy: function() {
- this.widget.destroy();
- },
-
handleEvent: function(event) {
// Skip if the search bar is shown and the focus is elsewhere
- if (this.widget.search_mode_enabled && !this._searchEntry.is_focus)
+ if (this.search_mode_enabled && !this._searchEntry.is_focus)
return false;
let keyval = event.get_keyval()[1];
- if (this.widget.search_mode_enabled && keyval == Gdk.KEY_Return) {
- this.emit('activate-result');
+ if (this.search_mode_enabled && keyval == Gdk.KEY_Return) {
+ this.emitJS('activate-result');
return true;
}
- return this.widget.handle_event(event);
+ return this.handle_event(event);
},
- show: function() {
- this.widget.search_mode_enabled = true;
+ reveal: function() {
+ this.search_mode_enabled = true;
},
- hide: function() {
- this.widget.search_mode_enabled = false;
+ conceal: function() {
+ this.search_mode_enabled = false;
// clear all the search properties when hiding the entry
this._searchEntry.set_text('');
}
});
-Signals.addSignalMethods(Searchbar.prototype);
+Utils.addJSSignalMethods(Searchbar.prototype);
const Dropdown = new Lang.Class({
Name: 'Dropdown',
@@ -321,12 +318,12 @@ const OverviewSearchbar = new Lang.Class({
this.parent();
},
- show: function() {
+ reveal: function() {
this._selectAll.enabled = false;
this.parent();
},
- hide: function() {
+ conceal: function() {
this._dropdownButton.set_active(false);
this._selectAll.enabled = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]