Skip to content

Locations refactory to use native Gio.AppIcon's (for GNOME 42 support) #1656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 51 commits into from
May 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
dae5719
locations: Use native GIcon as location Apps-icons
3v1n0 Nov 10, 2021
7545a79
locations: Use native Gio.FileMonitor rate limit instead of a custom …
3v1n0 Nov 10, 2021
cd0a1eb
locations: Fix typo on FileManager app (un)wrapping functions
3v1n0 Dec 8, 2021
52888a7
locations: Fix handling of location apps on isolated workspaces mode
3v1n0 Dec 9, 2021
2961690
locations: Also destroy all removable devices on Removables manager d…
3v1n0 Dec 13, 2021
a716c1a
locations: Only emit changed signal if a monitored device has been re…
3v1n0 Dec 13, 2021
9a45528
locations: Only update Trash icon on changes
3v1n0 Nov 10, 2021
4b45ffe
locations: Remove unmounted locations by value
3v1n0 Nov 10, 2021
4dd3146
locations: Use native AppInfo's and Shell mount operations
3v1n0 Dec 7, 2021
252ef24
docking: Ignore left/right corner changes if not available
3v1n0 Feb 22, 2022
f774430
prefs: Add support to show in GNOME 42 libadwaita-based dialog
3v1n0 Feb 23, 2022
fbd85bc
utils: Support vfunc injections on newer GObject classes as per gjs 1.71
3v1n0 Feb 23, 2022
5ad140c
metadata: Add support for gnome-shell 42
3v1n0 Jan 24, 2022
609143d
fileManager1API: Cleanup the code to get windows from location path
3v1n0 Dec 8, 2021
c991dcd
fileManager1API: Keep windows paths cached so we can monitor changes
3v1n0 Dec 8, 2021
e3febfc
utils: Add support for (un)blocking signals handlers
3v1n0 Dec 8, 2021
d6f9bb9
locations: Smart managing wrapped windows backed applications signal …
3v1n0 Dec 9, 2021
88afaab
locations: Use proxy properties to expose private items to public object
3v1n0 Dec 9, 2021
021666e
locations: Chain up to parent destroy() function if any
3v1n0 Dec 9, 2021
c1d4a1c
locations: Manage sources as part of DtdData
3v1n0 Jan 23, 2022
e496666
locations: Manage windows changes in base class
3v1n0 Dec 9, 2021
ec7f47c
cleanup: Move shellAppCompare under Utils as it's a generic tool
3v1n0 Dec 9, 2021
23dd498
locations: Keep locations windows ordered following the shell algorithm
3v1n0 Dec 9, 2021
631259b
locations: Use windows array directly where there's no need for metho…
3v1n0 Dec 9, 2021
bb7501c
locations: Resort and notify windows changes on user-time changes
3v1n0 Dec 9, 2021
aea4902
locations: Sort location windows apps only demand
3v1n0 Dec 9, 2021
ee2e5fc
fileManager1API: Only emit windows-changed signal if windows / locati…
3v1n0 Dec 9, 2021
baca53d
fileManager1API: Manage unmanaged windows early
3v1n0 Dec 9, 2021
ea8a330
locations: Include actual app ID in the string representation
3v1n0 Dec 9, 2021
80f1660
utils: Add CancellableChild, a GCancellable that monitors a parent in…
3v1n0 Dec 15, 2021
58d68a3
locations: Get Trash icon from the folder attributes
3v1n0 Dec 9, 2021
f0f3efc
locations: Add support for showing custom icon files on mounts
3v1n0 Dec 9, 2021
6765ac6
fileManager1API: Include transient windows as part of the location wi…
3v1n0 Dec 13, 2021
4173bb9
locations: Monitor windows-changed from apps and not from fm1Client
3v1n0 Dec 13, 2021
d56bef7
locations: Ignore native file manager windows-changed signal emissions
3v1n0 Dec 13, 2021
7074fc7
locations: Try to get trash status from metadata info before iterating
3v1n0 Dec 13, 2021
1b5b9a6
locations: Move handling of trash logic into TrashAppInfo
3v1n0 Dec 13, 2021
97b69df
locations: Manage all mountable volumes, whether they're mounted or not
3v1n0 Dec 13, 2021
f1e45bc
locations: Do not try to add null volumes from valid mounts
3v1n0 Feb 22, 2022
07cd49e
locations: Add support for optionally showing all mountable devices
3v1n0 Dec 13, 2021
9321e24
locations: Add support for showing network volumes
3v1n0 Dec 13, 2021
1b7039f
locations: Use ChildCancellable to avoid queuing multiple trash updates
3v1n0 Dec 15, 2021
666a55d
locations: Do not try to perform (un)mount actions concurrently
3v1n0 Dec 15, 2021
adb8f28
appIcons: Show menu item as insensitive if the app is busy
3v1n0 Dec 15, 2021
66f6be8
locations: Wait for location apps to own windows before updating file…
3v1n0 Jan 24, 2022
2bd0112
locations: Add support for starting app state
3v1n0 Jan 24, 2022
85ea33d
locations: Support opening new location windows when using nautilus
3v1n0 Jan 24, 2022
0f97f60
locations: Reintroduce manual rate limiting for trash monitoring
vanvugt Mar 2, 2022
ae11cb7
locations: Always ignore OR windows in windows-backed app implementation
3v1n0 Apr 11, 2022
d378382
appIcons/prefs: Follow upstream terminology for Favorite or Pinned apps
3v1n0 Apr 28, 2022
a6447f2
docking: Use snake-case name for implicit defined properties
3v1n0 Apr 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions Settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@
<property name="can_focus">0</property>
<property name="hexpand">1</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Show favorite applications</property>
<property name="label" translatable="yes">Show pinned applications</property>

<layout>
<property name="column">0</property>
Expand Down Expand Up @@ -1208,14 +1208,40 @@
<property name="can_focus">0</property>
<property name="hexpand">1</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Show mounted volumes and devices</property>
<property name="label" translatable="yes">Show volumes and devices</property>

<layout>
<property name="column">0</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="show_only_mounted_devices_check">
<property name="label" translatable="yes">Only if mounted</property>
<property name="halign">start</property>
<property name="margin_top">12</property>

<layout>
<property name="column">0</property>
<property name="row">1</property>
<property name="column-span">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="show_network_volumes_check">
<property name="label" translatable="yes">Include network volumes</property>
<property name="halign">start</property>
<property name="margin_top">12</property>

<layout>
<property name="column">0</property>
<property name="row">2</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
</object>
</property>
</object>
Expand Down
22 changes: 16 additions & 6 deletions appIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const Gettext = imports.gettext.domain('dashtodock');
const __ = Gettext.gettext;
const N__ = function(e) { return e };

const Config = imports.misc.config;

const AppDisplay = imports.ui.appDisplay;
const AppFavorites = imports.ui.appFavorites;
const BoxPointer = imports.ui.boxpointer;
Expand All @@ -31,6 +33,7 @@ const Workspace = imports.ui.workspace;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Docking = Me.imports.docking;
const Locations = Me.imports.locations;
const Utils = Me.imports.utils;
const WindowPreview = Me.imports.windowPreview;
const AppIconIndicators = Me.imports.appIconIndicators;
Expand Down Expand Up @@ -853,8 +856,8 @@ var DockAppIcon = GObject.registerClass({
var DockLocationAppIcon = GObject.registerClass({
}, class DockLocationAppIcon extends DockAbstractAppIcon {
_init(app, monitorIndex, iconAnimator) {
if (!app.location)
throw new Error('Provided application %s has no location'.format(app));
if (!(app.appInfo instanceof Locations.LocationAppInfo))
throw new Error('Provided application %s is not a Location'.format(app));

super._init(app, monitorIndex, iconAnimator);

Expand All @@ -864,6 +867,8 @@ var DockLocationAppIcon = GObject.registerClass({
this._signalsHandler.add(global.display, 'notify::focus-window',
() => this._updateFocusState());
}

this._signalsHandler.add(this.app, 'notify::icon', () => this.icon.update());
}

get location() {
Expand All @@ -879,10 +884,9 @@ var DockLocationAppIcon = GObject.registerClass({
});

function makeAppIcon(app, monitorIndex, iconAnimator) {
if (app.location)
if (app.appInfo instanceof Locations.LocationAppInfo)
return new DockLocationAppIcon(app, monitorIndex, iconAnimator);


return new DockAppIcon(app, monitorIndex, iconAnimator);
}

Expand Down Expand Up @@ -1024,6 +1028,7 @@ const DockAppIconMenu = class DockAppIconMenu extends PopupMenu.PopupMenu {
for (let i = 0; i < actions.length; i++) {
let action = actions[i];
let item = this._appendMenuItem(appInfo.get_action_name(action));
item.sensitive = !appInfo.busy;
item.connect('activate', (emitter, event) => {
this._source.app.launch_action(action, event.get_time(), -1);
this.emit('activate-window', null);
Expand All @@ -1038,15 +1043,20 @@ const DockAppIconMenu = class DockAppIconMenu extends PopupMenu.PopupMenu {
this._appendSeparator();

let isFavorite = AppFavorites.getAppFavorites().isFavorite(this._source.app.get_id());
const [majorVersion] = Config.PACKAGE_VERSION.split('.');

if (isFavorite) {
let item = this._appendMenuItem(_('Remove from Favorites'));
const label = majorVersion >= 42 ? _('Unpin') :
_('Remove from Favorites');
let item = this._appendMenuItem(label);
item.connect('activate', () => {
let favs = AppFavorites.getAppFavorites();
favs.removeFavorite(this._source.app.get_id());
});
} else {
let item = this._appendMenuItem(_('Add to Favorites'));
const label = majorVersion >= 42 ? _('Pin to Dash') :
_('Add to Favorites');
let item = this._appendMenuItem(label);
item.connect('activate', () => {
let favs = AppFavorites.getAppFavorites();
favs.addFavorite(this._source.app.get_id());
Expand Down
3 changes: 0 additions & 3 deletions dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,10 +781,7 @@ var DockDash = GObject.registerClass({
oldApps = oldApps.filter(app => !app.location || app.isTrash)
}

this._signalsHandler.removeWithLabel('show-trash');
if (dockManager.trash) {
this._signalsHandler.addWithLabel('show-trash',
dockManager.trash, 'changed', this._queueRedisplay.bind(this));
const trashApp = dockManager.trash.getApp();
if (!newApps.includes(trashApp))
newApps.push(trashApp);
Expand Down
29 changes: 18 additions & 11 deletions docking.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ var DockedDash = GObject.registerClass({
reactive: false,
style_class: positionStyleClass[this._position],
});

if (this.monitorIndex === undefined) {
// Hello turkish locale, gjs has instead defined this.monitorİndex
// See: https://gitlab.gnome.org/GNOME/gjs/-/merge_requests/742
this.monitorIndex = this.monitor_index;
}

this._rtl = (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL);

// Load settings
Expand Down Expand Up @@ -1685,16 +1692,13 @@ var DockManager = class DashToDock_DockManager {
this._trash = null;
}

Locations.unWrapWindowsManagerApp();
[this._methodInjections, this._vfuncInjections, this._propertyInjections].forEach(
Locations.unWrapFileManagerApp();
[this._methodInjections, this._propertyInjections].forEach(
injections => injections.removeWithLabel('locations'));

if (showMounts || showTrash) {
this._vfuncInjections.addWithLabel('locations', Gio.DesktopAppInfo.prototype,
'get_id', function () { return this.customId ?? this.vfunc_get_id() });

if (this.settings.isolateLocations) {
const fileManagerApp = Locations.wrapWindowsManagerApp();
const fileManagerApp = Locations.wrapFileManagerApp();

this._methodInjections.addWithLabel('locations', [
Shell.AppSystem.prototype, 'get_running',
Expand All @@ -1708,7 +1712,7 @@ var DockManager = class DashToDock_DockManager {
if (fileManagerIdx > -1 && fileManagerApp?.state !== Shell.AppState.RUNNING)
runningApps.splice(fileManagerIdx, 1);

return [...runningApps, ...locationApps].sort(Locations.shellAppCompare);
return [...runningApps, ...locationApps].sort(Utils.shellAppCompare);
}
],
[
Expand Down Expand Up @@ -2366,7 +2370,7 @@ var DockManager = class DashToDock_DockManager {
}
this._trash?.destroy();
this._trash = null;
Locations.unWrapWindowsManagerApp();
Locations.unWrapFileManagerApp();
this._removables?.destroy();
this._removables = null;
this._iconTheme.destroy();
Expand All @@ -2382,9 +2386,12 @@ var DockManager = class DashToDock_DockManager {
}

/**
* Adjust Panel corners
* Adjust Panel corners, remove this when 41 won't be supported anymore
*/
_adjustPanelCorners() {
if (!Main.panel._rightCorner || !Main.panel._leftCorner)
return;

let position = Utils.getPosition();
let isHorizontal = ((position == St.Side.TOP) || (position == St.Side.BOTTOM));
let dockOnPrimary = this._settings.multiMonitor ||
Expand All @@ -2399,8 +2406,8 @@ var DockManager = class DashToDock_DockManager {
}

_revertPanelCorners() {
Main.panel._leftCorner.show();
Main.panel._rightCorner.show();
Main.panel._leftCorner?.show();
Main.panel._rightCorner?.show();
}
};
Signals.addSignalMethods(DockManager.prototype);
Expand Down
Loading