[polari/wip/kunaljain/polari-search-result-view] mainWindow: Adjust mode switch conditions
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/kunaljain/polari-search-result-view] mainWindow: Adjust mode switch conditions
- Date: Fri, 22 Jul 2016 12:53:45 +0000 (UTC)
commit fd94c2d2bd09d4872127077087ed4697c8a67907
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Jul 21 13:26:38 2016 +0200
mainWindow: Adjust mode switch conditions
data/resources/main-window.ui | 4 ++--
src/mainWindow.js | 30 ++++++++++++++++++++++--------
2 files changed, 24 insertions(+), 10 deletions(-)
---
diff --git a/data/resources/main-window.ui b/data/resources/main-window.ui
index 2327a40..8ec43ed 100644
--- a/data/resources/main-window.ui
+++ b/data/resources/main-window.ui
@@ -228,7 +228,7 @@
<child>
<object class="GtkStack" id="leftStack">
<property name="visible">True</property>
- <property name="transition-type">slide-left-right</property>
+ <property name="transition-type">crossfade</property>
<property name="hexpand">true</property>
<!-- <property name="resize-mode">queue</property> -->
<property name="visible-child-name"
bind-source="Gjs_MainWindow"
@@ -289,7 +289,7 @@
<child>
<object class="GtkStack" id="rightStack">
<property name="visible">True</property>
- <property name="transition-type">slide-left-right</property>
+ <property name="transition-type">crossfade</property>
<property name="hexpand">true</property>
<property name="visible-child-name" bind-source="Gjs_MainWindow"
bind-property="mode" bind-flags="sync-create"/>
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 8943e95..eba254d 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -235,6 +235,8 @@ const MainWindow = new Lang.Class({
GObject.BindingFlags.BIDIRECTIONAL);
this._searchBar.connect_entry(this._searchEntry);
+ this._searchBar.connect('notify::search-mode-enabled',
+ Lang.bind(this, this._updateMode));
this._searchEntry.connect('search-changed',
Lang.bind(this, this._handleSearchChanged));
@@ -263,19 +265,31 @@ const MainWindow = new Lang.Class({
return this._mode;
},
- _handleSearchChanged: function(entry) {
- let text = entry.get_text().replace(/^\s+|\s+$/g, '');
- let app = this.application;
- let action = app.lookup_action('search-terms');
- action.change_state(GLib.Variant.new('s', text));
- if(text!='') {
- this._mode='search';
+ _updateMode: function() {
+ let mode;
+ if (this._mode == 'search') {
+ mode = this._searchBar.search_mode_enabled ? 'search' : 'chat';
} else {
- this._mode='chat';
+ let state = this.application.get_action_state('search-terms');
+ let [terms, ] = state.get_string();
+ mode = terms.length > 0 ? 'search' : 'chat';
}
+
+ if (mode == this._mode)
+ return;
+
+ this._mode = mode;
this.notify('mode');
},
+ _handleSearchChanged: function(entry) {
+ let text = entry.get_text().replace(/^\s+|\s+$/g, '');
+ let terms = new GLib.Variant('s',
+ text.length < MIN_SEARCH_WIDTH ? '' : text);
+ this.application.change_action_state('search-terms', terms);
+ this._updateMode();
+ },
+
_onWindowStateEvent: function(widget, event) {
let state = event.get_window().get_state();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]