[gnome-shell/gbsneto/folders-as-dialogs: 2/3] appDisplay: Remove rename popup



commit 4c06fa349f33ca3b41c82b1e451b0746bcc53b13
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Dec 17 16:47:01 2019 -0300

    appDisplay: Remove rename popup
    
    This functionality always suffered from discoveribility
    problems, and now that the folder dialog can rename the
    app folders, there's just no reason to keep it.
    
    Remove the rename popup.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/896

 data/theme/gnome-shell-sass/_common.scss |   6 +-
 js/ui/appDisplay.js                      | 189 ++-----------------------------
 2 files changed, 12 insertions(+), 183 deletions(-)
---
diff --git a/data/theme/gnome-shell-sass/_common.scss b/data/theme/gnome-shell-sass/_common.scss
index 5afac88b9b..00a428c2b2 100644
--- a/data/theme/gnome-shell-sass/_common.scss
+++ b/data/theme/gnome-shell-sass/_common.scss
@@ -1535,9 +1535,9 @@ StScrollBar {
         @extend %button;
 
         padding: 0;
-        width: 32px;
-        height: 32px;
-        border-radius: 16px;
+        width: 36px;
+        height: 36px;
+        border-radius: 18px;
 
         & > StIcon { icon-size: 16px }
       }
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 9a9f8feb10..0177808bb6 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -1219,10 +1219,6 @@ var FolderIcon = GObject.registerClass({
         this._itemDragEndId = Main.overview.connect(
             'item-drag-end', this._onDragEnd.bind(this));
 
-        this._popupTimeoutId = 0;
-
-        this.connect('popup-menu', this._popupRenamePopup.bind(this));
-
         this.connect('destroy', this._onDestroy.bind(this));
 
         this._folder.connect('changed', this._redisplay.bind(this));
@@ -1242,8 +1238,6 @@ var FolderIcon = GObject.registerClass({
 
         if (this._dialog)
             this._dialog.destroy();
-
-        this._removeMenuTimeout();
     }
 
     vfunc_clicked() {
@@ -1258,7 +1252,6 @@ var FolderIcon = GObject.registerClass({
     }
 
     open() {
-        this._removeMenuTimeout();
         this._ensurePopup();
         this.view._scrollView.vscroll.adjustment.value = 0;
         this._dialog.popup();
@@ -1367,181 +1360,8 @@ var FolderIcon = GObject.registerClass({
             });
         }
     }
-
-    _removeMenuTimeout() {
-        if (this._popupTimeoutId > 0) {
-            GLib.source_remove(this._popupTimeoutId);
-            this._popupTimeoutId = 0;
-        }
-    }
-
-    _setPopupTimeout() {
-        this._removeMenuTimeout();
-        this._popupTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, MENU_POPUP_TIMEOUT, () => {
-            this._popupTimeoutId = 0;
-            this._popupRenamePopup();
-            return GLib.SOURCE_REMOVE;
-        });
-        GLib.Source.set_name_by_id(this._popupTimeoutId,
-                                   '[gnome-shell] this._popupRenamePopup');
-    }
-
-    vfunc_leave_event(crossingEvent) {
-        let ret = super.vfunc_leave_event(crossingEvent);
-        this.fake_release();
-        this._removeMenuTimeout();
-        return ret;
-    }
-
-    vfunc_button_press_event(buttonEvent) {
-        super.vfunc_button_press_event(buttonEvent);
-
-        if (buttonEvent.button == 1) {
-            this._setPopupTimeout();
-        } else if (buttonEvent.button == 3) {
-            this._popupRenamePopup();
-            return Clutter.EVENT_STOP;
-        }
-        return Clutter.EVENT_PROPAGATE;
-    }
-
-    vfunc_touch_event(touchEvent) {
-        super.vfunc_touch_event(touchEvent);
-
-        if (touchEvent.type == Clutter.EventType.TOUCH_BEGIN)
-            this._setPopupTimeout();
-
-        return Clutter.EVENT_PROPAGATE;
-    }
-
-    _popupRenamePopup() {
-        this._removeMenuTimeout();
-        this.fake_release();
-
-        if (!this._menu) {
-            this._menuManager = new PopupMenu.PopupMenuManager(this);
-
-            this._menu = new RenameFolderMenu(this, this._folder);
-            this._menuManager.addMenu(this._menu);
-
-            this._menu.connect('open-state-changed', (menu, isPoppedUp) => {
-                if (!isPoppedUp)
-                    this.sync_hover();
-            });
-            let id = Main.overview.connect('hiding', () => {
-                this._menu.close();
-            });
-            this.connect('destroy', () => {
-                Main.overview.disconnect(id);
-            });
-        }
-
-        this.set_hover(true);
-        this._menu.open();
-        this._menuManager.ignoreRelease();
-    }
 });
 
-var RenameFolderMenuItem = GObject.registerClass(
-class RenameFolderMenuItem extends PopupMenu.PopupBaseMenuItem {
-    _init(folder) {
-        super._init({
-            style_class: 'rename-folder-popup-item',
-            reactive: false,
-        });
-        this.setOrnament(PopupMenu.Ornament.HIDDEN);
-
-        this._folder = folder;
-
-        // Entry
-        this._entry = new St.Entry({
-            x_expand: true,
-            width: 200,
-        });
-        this.add_child(this._entry);
-
-        this._entry.clutter_text.connect(
-            'notify::text', this._validate.bind(this));
-        this._entry.clutter_text.connect(
-            'activate', this._updateFolderName.bind(this));
-
-        // Rename button
-        this._button = new St.Button({
-            style_class: 'button',
-            reactive: true,
-            button_mask: St.ButtonMask.ONE | St.ButtonMask.TWO,
-            can_focus: true,
-            label: _('Rename'),
-        });
-        this.add_child(this._button);
-
-        this._button.connect('clicked', this._updateFolderName.bind(this));
-    }
-
-    vfunc_map() {
-        this._entry.text = _getFolderName(this._folder);
-        this._entry.clutter_text.set_selection(0, -1);
-        super.vfunc_map();
-    }
-
-    vfunc_key_focus_in() {
-        super.vfunc_key_focus_in();
-        this._entry.clutter_text.grab_key_focus();
-    }
-
-    _isValidFolderName() {
-        let folderName = _getFolderName(this._folder);
-        let newFolderName = this._entry.text.trim();
-
-        return newFolderName.length > 0 && newFolderName != folderName;
-    }
-
-    _validate() {
-        let isValid = this._isValidFolderName();
-
-        this._button.reactive = isValid;
-    }
-
-    _updateFolderName() {
-        if (!this._isValidFolderName())
-            return;
-
-        let newFolderName = this._entry.text.trim();
-        this._folder.set_string('name', newFolderName);
-        this._folder.set_boolean('translate', false);
-        this.activate(Clutter.get_current_event());
-    }
-});
-
-var RenameFolderMenu = class RenameFolderMenu extends PopupMenu.PopupMenu {
-    constructor(source, folder) {
-        super(source, 0.5, St.Side.BOTTOM);
-        this.actor.add_style_class_name('rename-folder-popup');
-
-        // We want to keep the item hovered while the menu is up
-        this.blockSourceEvents = true;
-
-        let menuItem = new RenameFolderMenuItem(folder);
-        this.addMenuItem(menuItem);
-
-        // Focus the text entry on menu pop-up
-        this.focusActor = menuItem;
-
-        // Chain our visibility and lifecycle to that of the source
-        this._sourceMappedId = source.connect('notify::mapped', () => {
-            if (!source.mapped)
-                this.close();
-        });
-        source.connect('destroy', () => {
-            source.disconnect(this._sourceMappedId);
-            this.destroy();
-        });
-
-        Main.uiGroup.add_actor(this.actor);
-    }
-};
-Signals.addSignalMethods(RenameFolderMenu.prototype);
-
 var AppFolderDialog = GObject.registerClass({
     Signals: {
         'open-state-changed': { param_types: [GObject.TYPE_BOOLEAN] },
@@ -1603,6 +1423,10 @@ var AppFolderDialog = GObject.registerClass({
         });
         this._viewBox.add_child(this._entryBox);
 
+        // Empty actor to center the title
+        let ghostButton = new Clutter.Actor();
+        this._entryBox.add_child(ghostButton);
+
         let stack = new Shell.Stack({
             x_expand: true,
             x_align: Clutter.ActorAlign.CENTER,
@@ -1656,6 +1480,11 @@ var AppFolderDialog = GObject.registerClass({
 
         this._entryBox.add_child(button);
 
+        ghostButton.add_constraint(new Clutter.BindConstraint({
+            source: button,
+            coordinate: Clutter.BindCoordinate.SIZE,
+        }));
+
         this._folder.connect('changed::name', () => this._syncFolderName());
         this._syncFolderName();
     }


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