Skip to content

Commit

Permalink
dash: Add option to show the show-apps button bound to icons in panel…
Browse files Browse the repository at this point in the history
… mode

See: #1746
  • Loading branch information
3v1n0 committed May 15, 2023
1 parent 4816e08 commit 693ab5b
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 13 deletions.
21 changes: 21 additions & 0 deletions Settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,27 @@
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="show_apps_always_in_the_edge">
<style>
<class name="text-button"/>
</style>
<property name="margin_top">3</property>
<child>
<object class="GtkLabel">
<property name="can_focus">0</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Put &lt;i&gt;Show Applications&lt;/i&gt; in a dock edge when using Panel mode</property>
<property name="use_markup">1</property>
</object>
</child>
<layout>
<property name="column">0</property>
<property name="row">4</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
</object>
</property>
</object>
Expand Down
38 changes: 25 additions & 13 deletions dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -1028,6 +1025,7 @@ var DockDash = GObject.registerClass({
showShowAppsButton() {
this._showAppsIcon.visible = true;
this._showAppsIcon.show(true);
this.updateShowAppsButton();
}

hideShowAppsButton() {
Expand All @@ -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);

Expand All @@ -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');
}
});

Expand Down
6 changes: 6 additions & 0 deletions docking.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
8 changes: 8 additions & 0 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 4 additions & 0 deletions schemas/org.gnome.shell.extensions.dash-to-dock.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@
<summary>Show application button on the left</summary>
<description>Show application button on the left of the dash</description>
</key>
<key type="b" name="show-apps-always-in-the-edge">
<default>true</default>
<summary>Show application button on the edge when using centered panel mode</summary>
</key>
<key type="b" name="animate-show-apps">
<default>true</default>
<summary>Animate Show Applications from the desktop</summary>
Expand Down

0 comments on commit 693ab5b

Please sign in to comment.