[gnome-shell/T27795: 90/138] Remove the search entry from upstream GNOME Shell



commit 72959fc34f541e61f951893c26ce7f816e787765
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Wed Feb 14 10:42:19 2018 +0000

    Remove the search entry from upstream GNOME Shell
    
    We will be reciclying our own OverviewEntry class for the desktop
    search in Endless, so we need to remove the one from upstream before
    we get our own search entry widget landed, to keep commits cleaner.

 js/ui/overview.js         |  15 +--
 js/ui/overviewControls.js |   4 +-
 js/ui/viewSelector.js     | 242 ++--------------------------------------------
 3 files changed, 11 insertions(+), 250 deletions(-)
---
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 8271361971..f61caabd87 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -277,20 +277,8 @@ var Overview = class {
 
         this._shellInfo = new ShellInfo();
 
-        this._searchEntry = new St.Entry({ style_class: 'search-entry',
-                                           /* Translators: this is the text displayed
-                                              in the search entry when no search is
-                                              active; it should not exceed ~30
-                                              characters. */
-                                           hint_text: _("Type to search…"),
-                                           track_hover: true,
-                                           can_focus: true });
-        this._searchEntryBin = new St.Bin({ child: this._searchEntry,
-                                            x_align: St.Align.MIDDLE });
-        this._overview.add_actor(this._searchEntryBin);
-
         // Create controls
-        this._controls = new OverviewControls.ControlsManager(this._searchEntry);
+        this._controls = new OverviewControls.ControlsManager();
         this.viewSelector = this._controls.viewSelector;
 
         // Add our same-line elements after the search entry
@@ -500,7 +488,6 @@ var Overview = class {
 
     focusSearch() {
         this.show();
-        this._searchEntry.grab_key_focus();
     }
 
     _showOrSwitchPage(page) {
diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js
index c168c8cf58..a9d67f7d22 100644
--- a/js/ui/overviewControls.js
+++ b/js/ui/overviewControls.js
@@ -416,11 +416,11 @@ var ControlsLayout = GObject.registerClass({
 });
 
 var ControlsManager = class {
-    constructor(searchEntry) {
+    constructor() {
         this._thumbnailsBox = new WorkspaceThumbnail.ThumbnailsBox();
         this._thumbnailsSlider = new ThumbnailsSlider(this._thumbnailsBox);
 
-        this.viewSelector = new ViewSelector.ViewSelector(searchEntry);
+        this.viewSelector = new ViewSelector.ViewSelector();
         this.viewSelector.connect('page-changed', this._setVisibility.bind(this));
         this.viewSelector.connect('page-empty', this._onPageEmpty.bind(this));
 
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index e99fc8ecf3..c2783d2532 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -21,8 +21,7 @@ var PINCH_GESTURE_THRESHOLD = 0.7;
 
 var ViewPage = {
     WINDOWS: 1,
-    APPS: 2,
-    SEARCH: 3
+    APPS: 2
 };
 
 const ViewsDisplayPage = {
@@ -229,43 +228,11 @@ class ViewsDisplayConstraint extends Monitor.MonitorConstraint {
 });
 
 var ViewSelector = class {
-    constructor(searchEntry) {
+    constructor() {
         this.actor = new Shell.Stack({ name: 'viewSelector' });
 
         this._activePage = null;
 
-        this._searchActive = false;
-
-        this._entry = searchEntry;
-        ShellEntry.addContextMenu(this._entry);
-
-        this._text = this._entry.clutter_text;
-        this._text.connect('text-changed', this._onTextChanged.bind(this));
-        this._text.connect('key-press-event', this._onKeyPress.bind(this));
-        this._text.connect('key-focus-in', () => {
-            this._searchResults.highlightDefault(true);
-        });
-        this._text.connect('key-focus-out', () => {
-            this._searchResults.highlightDefault(false);
-        });
-        this._entry.connect('popup-menu', () => {
-            if (!this._searchActive)
-                return;
-
-            this._entry.menu.close();
-            this._searchResults.popupMenuDefault();
-        });
-        this._entry.connect('notify::mapped', this._onMapped.bind(this));
-        global.stage.connect('notify::key-focus', this._onStageKeyFocusChanged.bind(this));
-
-        this._entry.set_primary_icon(new St.Icon({ style_class: 'search-entry-icon',
-                                                   icon_name: 'edit-find-symbolic' }));
-        this._clearIcon = new St.Icon({ style_class: 'search-entry-icon',
-                                        icon_name: 'edit-clear-symbolic' });
-
-        this._iconClickedId = 0;
-        this._capturedEventId = 0;
-
         this._workspacesDisplay = new WorkspacesView.WorkspacesDisplay();
         this._workspacesDisplay.connect('empty-space-clicked', this._onEmptySpaceClicked.bind(this));
         this._workspacesPage = this._addPage(this._workspacesDisplay.actor,
@@ -279,22 +246,6 @@ var ViewSelector = class {
 
         this.appDisplay = this._viewsDisplay.appDisplay;
 
-        this._searchResults = new Search.SearchResults();
-        this._searchPage = this._addPage(this._searchResults.actor,
-                                         _("Search"), 'edit-find-symbolic',
-                                         { a11yFocus: this._entry });
-
-        // Since the entry isn't inside the results container we install this
-        // dummy widget as the last results container child so that we can
-        // include the entry in the keynav tab path
-        this._focusTrap = new FocusTrap({ can_focus: true });
-        this._focusTrap.connect('key-focus-in', () => {
-            this._entry.grab_key_focus();
-        });
-        this._searchResults.actor.add_actor(this._focusTrap);
-
-        global.focus_manager.add_group(this._searchResults.actor);
-
         this._stageKeyPressId = 0;
         Main.overview.connect('showing', () => {
             this._stageKeyPressId = global.stage.connect('key-press-event',
@@ -374,8 +325,6 @@ var ViewSelector = class {
     }
 
     show(viewPage) {
-        this.reset();
-
         // We're always starting up to the APPS page, so avoid making the workspacesDisplay
         // (used for the Windows picker) visible to prevent situations where that actor
         // would intercept clicks meant for the desktop's icons grid.
@@ -398,7 +347,6 @@ var ViewSelector = class {
     }
 
     hide() {
-        this.reset();
         this._workspacesDisplay.hide();
     }
 
@@ -499,18 +447,12 @@ var ViewSelector = class {
 
         let symbol = event.get_key_symbol();
 
-        if (symbol == Clutter.Escape) {
-            if (this._activePage == this._workspacesPage)
-                Main.overview.toggleWindows();
-            else if (this._searchActive)
-                this.reset();
-            else
-                Main.overview.hide();
-
+        if (symbol == Clutter.Escape && this._activePage == this._workspacesPage) {
+            Main.overview.toggleWindows();
             return Clutter.EVENT_STOP;
-        } else if (this._shouldTriggerSearch(symbol)) {
-            this.startSearch(event);
-        } else if (!this._searchActive && !global.stage.key_focus) {
+        }
+
+        if (!global.stage.key_focus) {
             if (symbol == Clutter.Tab || symbol == Clutter.Down) {
                 this._activePage.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
                 return Clutter.EVENT_STOP;
@@ -522,172 +464,6 @@ var ViewSelector = class {
         return Clutter.EVENT_PROPAGATE;
     }
 
-    _searchCancelled() {
-        this._showPage(this._appsPage);
-
-        // Leave the entry focused when it doesn't have any text;
-        // when replacing a selected search term, Clutter emits
-        // two 'text-changed' signals, one for deleting the previous
-        // text and one for the new one - the second one is handled
-        // incorrectly when we remove focus
-        // (https://bugzilla.gnome.org/show_bug.cgi?id=636341) */
-        if (this._text.text != '')
-            this.reset();
-    }
-
-    reset() {
-        // Don't drop the key focus on Clutter's side if anything but the
-        // overview has pushed a modal (e.g. system modals when activated using
-        // the overview).
-        if (Main.modalCount <= 1)
-            global.stage.set_key_focus(null);
-
-        this._entry.text = '';
-
-        this._text.set_cursor_visible(true);
-        this._text.set_selection(0, 0);
-    }
-
-    _onStageKeyFocusChanged() {
-        let focus = global.stage.get_key_focus();
-        let appearFocused = (this._entry.contains(focus) ||
-                             this._searchResults.actor.contains(focus));
-
-        this._text.set_cursor_visible(appearFocused);
-
-        if (appearFocused)
-            this._entry.add_style_pseudo_class('focus');
-        else
-            this._entry.remove_style_pseudo_class('focus');
-    }
-
-    _onMapped() {
-        if (this._entry.mapped) {
-            // Enable 'find-as-you-type'
-            this._capturedEventId = global.stage.connect('captured-event',
-                                                         this._onCapturedEvent.bind(this));
-            this._text.set_cursor_visible(true);
-            this._text.set_selection(0, 0);
-        } else {
-            // Disable 'find-as-you-type'
-            if (this._capturedEventId > 0)
-                global.stage.disconnect(this._capturedEventId);
-            this._capturedEventId = 0;
-        }
-    }
-
-    _shouldTriggerSearch(symbol) {
-        if (symbol == Clutter.Multi_key)
-            return true;
-
-        if (symbol == Clutter.BackSpace && this._searchActive)
-            return true;
-
-        let unicode = Clutter.keysym_to_unicode(symbol);
-        if (unicode == 0)
-            return false;
-
-        if (getTermsForSearchString(String.fromCharCode(unicode)).length > 0)
-            return true;
-
-        return false;
-    }
-
-    startSearch(event) {
-        global.stage.set_key_focus(this._text);
-
-        let synthEvent = event.copy();
-        synthEvent.set_source(this._text);
-        this._text.event(synthEvent, false);
-    }
-
-    // the entry does not show the hint
-    _isActivated() {
-        return this._text.text == this._entry.get_text();
-    }
-
-    _onTextChanged() {
-        let terms = getTermsForSearchString(this._entry.get_text());
-
-        this._searchActive = (terms.length > 0);
-        this._searchResults.setTerms(terms);
-
-        if (this._searchActive) {
-            this._showPage(this._searchPage);
-
-            this._entry.set_secondary_icon(this._clearIcon);
-
-            if (this._iconClickedId == 0)
-                this._iconClickedId = this._entry.connect('secondary-icon-clicked',
-                                                          this.reset.bind(this));
-        } else {
-            if (this._iconClickedId > 0) {
-                this._entry.disconnect(this._iconClickedId);
-                this._iconClickedId = 0;
-            }
-
-            this._entry.set_secondary_icon(null);
-            this._searchCancelled();
-        }
-    }
-
-    _onKeyPress(entry, event) {
-        let symbol = event.get_key_symbol();
-        if (symbol == Clutter.Escape) {
-            if (this._isActivated()) {
-                this.reset();
-                return Clutter.EVENT_STOP;
-            }
-        } else if (this._searchActive) {
-            let arrowNext, nextDirection;
-            if (entry.get_text_direction() == Clutter.TextDirection.RTL) {
-                arrowNext = Clutter.Left;
-                nextDirection = St.DirectionType.LEFT;
-            } else {
-                arrowNext = Clutter.Right;
-                nextDirection = St.DirectionType.RIGHT;
-            }
-
-            if (symbol == Clutter.Tab) {
-                this._searchResults.navigateFocus(St.DirectionType.TAB_FORWARD);
-                return Clutter.EVENT_STOP;
-            } else if (symbol == Clutter.ISO_Left_Tab) {
-                this._focusTrap.can_focus = false;
-                this._searchResults.navigateFocus(St.DirectionType.TAB_BACKWARD);
-                this._focusTrap.can_focus = true;
-                return Clutter.EVENT_STOP;
-            } else if (symbol == Clutter.Down) {
-                this._searchResults.navigateFocus(St.DirectionType.DOWN);
-                return Clutter.EVENT_STOP;
-            } else if (symbol == arrowNext && this._text.position == -1) {
-                this._searchResults.navigateFocus(nextDirection);
-                return Clutter.EVENT_STOP;
-            } else if (symbol == Clutter.Return || symbol == Clutter.KP_Enter) {
-                this._searchResults.activateDefault();
-                return Clutter.EVENT_STOP;
-            }
-        }
-        return Clutter.EVENT_PROPAGATE;
-    }
-
-    _onCapturedEvent(actor, event) {
-        if (event.type() == Clutter.EventType.BUTTON_PRESS) {
-            let source = event.get_source();
-            if (source != this._text &&
-                this._text.has_key_focus() &&
-                this._text.text == '' &&
-                !this._text.has_preedit () &&
-                !Main.layoutManager.keyboardBox.contains(source)) {
-                // the user clicked outside after activating the entry, but
-                // with no search term entered and no keyboard button pressed
-                // - cancel the search
-                this.reset();
-            }
-        }
-
-        return Clutter.EVENT_PROPAGATE;
-    }
-
     _pageFromViewPage(viewPage) {
         let page;
 
@@ -702,10 +478,8 @@ var ViewSelector = class {
     getActivePage() {
         if (this._activePage == this._workspacesPage)
             return ViewPage.WINDOWS;
-        else if (this._activePage == this._appsPage)
-            return ViewPage.APPS;
         else
-            return ViewPage.SEARCH;
+            return ViewPage.APPS;
     }
 
     setActivePage(viewPage) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]