From 693ab5b941d549098558012f5b9f4bf79a19edd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 19 Apr 2023 20:12:39 +0200 Subject: [PATCH] dash: Add option to show the show-apps button bound to icons in panel mode See: #1746 --- Settings.ui | 21 ++++++++++ dash.js | 38 ++++++++++++------- docking.js | 6 +++ prefs.js | 8 ++++ ....shell.extensions.dash-to-dock.gschema.xml | 4 ++ 5 files changed, 64 insertions(+), 13 deletions(-) diff --git a/Settings.ui b/Settings.ui index f6a387583..d6bd65a4f 100644 --- a/Settings.ui +++ b/Settings.ui @@ -1158,6 +1158,27 @@ + + + + 3 + + + 0 + start + Put <i>Show Applications</i> in a dock edge when using Panel mode + 1 + + + + 0 + 4 + 2 + + + diff --git a/dash.js b/dash.js index 0cbc44554..035c573ff 100644 --- a/dash.js +++ b/dash.js @@ -179,12 +179,7 @@ var DockDash = GObject.registerClass({ this._showAppsIcon.connect('menu-state-changed', (_icon, opened) => { this._itemMenuStateChanged(this._showAppsIcon, opened); }); - - if (Docking.DockManager.settings.showAppsAtTop) - this._dashContainer.insert_child_below(this._showAppsIcon, null); - else - this._dashContainer.insert_child_above(this._showAppsIcon, null); - + this.updateShowAppsButton(); this._background = new St.Widget({ style_class: 'dash-background', @@ -952,6 +947,8 @@ var DockDash = GObject.registerClass({ // This will update the size, and the corresponding number for each icon this._updateNumberOverlay(); + + this.updateShowAppsButton(); } _updateNumberOverlay() { @@ -1028,6 +1025,7 @@ var DockDash = GObject.registerClass({ showShowAppsButton() { this._showAppsIcon.visible = true; this._showAppsIcon.show(true); + this.updateShowAppsButton(); } hideShowAppsButton() { @@ -1045,16 +1043,30 @@ var DockDash = GObject.registerClass({ } updateShowAppsButton() { + if (this._showAppsIcon.get_parent() && !this._showAppsIcon.visible) + return; + + const { settings } = Docking.DockManager; const notifiedProperties = []; + const showAppsContainer = settings.dockExtended && + settings.showAppsAlwaysInTheEdge ? this._dashContainer : this._box; + this._signalsHandler.addWithLabel(Labels.FIRST_LAST_CHILD_WORKAROUND, - this._dashContainer, 'notify', + showAppsContainer, 'notify', (_obj, pspec) => notifiedProperties.push(pspec.name)); - if (Docking.DockManager.settings.showAppsAtTop) - this._dashContainer.set_child_below_sibling(this._showAppsIcon, null); - else - this._dashContainer.set_child_above_sibling(this._showAppsIcon, null); + if (this._showAppsIcon.get_parent() !== showAppsContainer) { + this._showAppsIcon.get_parent()?.remove_child(this._showAppsIcon); + if (Docking.DockManager.settings.showAppsAtTop) + showAppsContainer.insert_child_below(this._showAppsIcon, null); + else + showAppsContainer.insert_child_above(this._showAppsIcon, null); + } else if (settings.showAppsAtTop) { + showAppsContainer.set_child_below_sibling(this._showAppsIcon, null); + } else { + showAppsContainer.set_child_above_sibling(this._showAppsIcon, null); + } this._signalsHandler.removeWithLabel(Labels.FIRST_LAST_CHILD_WORKAROUND); @@ -1063,9 +1075,9 @@ var DockDash = GObject.registerClass({ // mutter issue that is being fixed: // https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2047 if (!notifiedProperties.includes('first-child')) - this._dashContainer.notify('first-child'); + showAppsContainer.notify('first-child'); if (!notifiedProperties.includes('last-child')) - this._dashContainer.notify('last-child'); + showAppsContainer.notify('last-child'); } }); diff --git a/docking.js b/docking.js index 26f4518ba..fabd07e34 100644 --- a/docking.js +++ b/docking.js @@ -581,6 +581,12 @@ const DockedDash = GObject.registerClass({ () => { this.dash.resetAppIcons(); }, + ], [ + settings, + 'changed::show-apps-always-in-the-edge', + () => { + this.dash.updateShowAppsButton(); + }, ], [ settings, 'changed::show-apps-at-top', diff --git a/prefs.js b/prefs.js index e57e33fd1..c7d8ee0bb 100644 --- a/prefs.js +++ b/prefs.js @@ -797,6 +797,14 @@ var Settings = GObject.registerClass({ this._builder.get_object('application_button_animation_button'), 'sensitive', Gio.SettingsBindFlags.DEFAULT); + this._settings.bind('show-apps-always-in-the-edge', + this._builder.get_object('show_apps_always_in_the_edge'), + 'active', + Gio.SettingsBindFlags.DEFAULT); + this._settings.bind('show-show-apps-button', + this._builder.get_object('show_apps_always_in_the_edge'), + 'sensitive', + Gio.SettingsBindFlags.DEFAULT); this._settings.bind('scroll-to-focused-application', this._builder.get_object('scroll_to_icon_switch'), 'active', diff --git a/schemas/org.gnome.shell.extensions.dash-to-dock.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-dock.gschema.xml index 09fe13075..800105b59 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-dock.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-dock.gschema.xml @@ -295,6 +295,10 @@ Show application button on the left Show application button on the left of the dash + + true + Show application button on the edge when using centered panel mode + true Animate Show Applications from the desktop