Skip to content
Commits on Source (15)
# History of versions #
* Version 47.0.2
* Added support for dark themes (Sundeep Mediratta)
* Reformatted all the code using Eslint (Sergio Costas)
* Fixed thumbnails generation when using the external program (Sergio Costas)
* Fixed some extra little bugs (Sergio Costas)
* Version 47.0.1
* New version scheme
* Cleaned the code (Sergio Costas and Sundeep Mediratta)
* Now DING is kept running in the lock screen (Sergio Costas)
* DBus proxy creation is now asynchronous, speeding up the start (Sergio Costas, based on code from Sundeep Mediratta)
* Now it can show the thumbnails for XCF (Gimp) files (Sergio Costas)
* Fixed rubber band initiation (Sundeep Mediratta)
......
......@@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* exported AskRenamePopup */
'use strict';
const Gtk = imports.gi.Gtk;
const Gio = imports.gi.Gio;
......@@ -26,27 +27,31 @@ const Gettext = imports.gettext.domain('ding');
const _ = Gettext.gettext;
var AskRenamePopup = class {
constructor(fileItem, allowReturnOnSameName, closeCB) {
this._closeCB = closeCB;
this._allowReturnOnSameName = allowReturnOnSameName;
this._desktopPath = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP);
this._fileItem = fileItem;
this._popover = new Gtk.Popover({relative_to: fileItem._iconContainer,
modal: true});
let contentBox = new Gtk.Grid({row_spacing: 6,
column_spacing: 6,
margin: 10});
this._popover = new Gtk.Popover({
relative_to: fileItem._iconContainer,
modal: true,
});
let contentBox = new Gtk.Grid({
row_spacing: 6,
column_spacing: 6,
margin: 10,
});
this._popover.add(contentBox);
let label = new Gtk.Label({label: fileItem.isDirectory ? _("Folder name") : _("File name"),
justify: Gtk.Justification.LEFT,
halign: Gtk.Align.START});
let label = new Gtk.Label({
label: fileItem.isDirectory ? _('Folder name') : _('File name'),
justify: Gtk.Justification.LEFT,
halign: Gtk.Align.START,
});
contentBox.attach(label, 0, 0, 2, 1);
this._textArea = new Gtk.Entry();
this._textArea.text = fileItem.fileName;
contentBox.attach(this._textArea, 0, 1, 1, 1);
this._button = new Gtk.Button({label: allowReturnOnSameName ? _("OK") : _("Rename")});
this._button = new Gtk.Button({label: allowReturnOnSameName ? _('OK') : _('Rename')});
contentBox.attach(this._button, 1, 1, 1, 1);
this._buttonId = this._button.connect('clicked', this._do_rename.bind(this));
this._textAreaChangedId = this._textArea.connect('changed', this._validate.bind(this));
......@@ -54,12 +59,12 @@ var AskRenamePopup = class {
this._popoverId = this._popover.connect('closed', this._cleanAll.bind(this));
this._textArea.set_can_default(true);
this._popover.set_default_widget(this._textArea);
this._button.get_style_context().add_class("suggested-action");
this._button.get_style_context().add_class('suggested-action');
contentBox.show_all();
this._popover.popup();
this._validate();
this._textArea.grab_focus_without_selecting();
this._textArea.select_region(0, DesktopIconsUtil.getFileExtensionOffset(fileItem.fileName, {'isDirectory':fileItem.isDirectory}).offset);
this._textArea.select_region(0, DesktopIconsUtil.getFileExtensionOffset(fileItem.fileName, {'isDirectory': fileItem.isDirectory}).offset);
}
_cleanAll() {
......@@ -85,11 +90,11 @@ var AskRenamePopup = class {
_validate() {
let text = this._textArea.text;
let final_path = this._desktopPath + '/' + text;
let final_file = Gio.File.new_for_commandline_arg(final_path);
if ((text == '') || (-1 != text.indexOf('/')) ||
((text == this._fileItem.fileName) && (!this._allowReturnOnSameName)) ||
(final_file.query_exists(null) && (text != this._fileItem.fileName))) {
let finalPath = `${this._desktopPath}/${text}`;
let finalFile = Gio.File.new_for_commandline_arg(finalPath);
if ((text == '') || (text.indexOf('/') !== -1) ||
((text == this._fileItem.fileName) && !this._allowReturnOnSameName) ||
(finalFile.query_exists(null) && (text !== this._fileItem.fileName))) {
this._button.sensitive = false;
} else {
this._button.sensitive = true;
......@@ -105,7 +110,7 @@ var AskRenamePopup = class {
return;
}
DBusUtils.RemoteFileOperations.RenameURIRemote(
this._fileItem.file.get_uri(), this._textArea.text,
this._fileItem.file.get_uri(), this._textArea.text
);
}
......
This diff is collapsed.
......@@ -22,6 +22,9 @@ imports.gi.versions.GnomeDesktop = '3.0';
const GnomeDesktop = imports.gi.GnomeDesktop;
const Gio = imports.gi.Gio;
/**
*
*/
function CreateThumbnail() {
let thumbnailFactoryNormal = GnomeDesktop.DesktopThumbnailFactory.new(GnomeDesktop.DesktopThumbnailSize.NORMAL);
let thumbnailFactoryLarge = GnomeDesktop.DesktopThumbnailFactory.new(GnomeDesktop.DesktopThumbnailSize.LARGE);
......@@ -44,7 +47,7 @@ function CreateThumbnail() {
if (thumbnailNormal != null) {
return 3;
}
if (thumbnailFactory.has_valid_failed_thumbnail(fileUri, modifiedTime)) {
if (thumbnailFactoryNormal.has_valid_failed_thumbnail(fileUri, modifiedTime)) {
return 4;
}
......
......@@ -14,10 +14,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* exported DBusInterfaces */
'use strict';
var DBusInterfaces = {
// net.haddes.SwitcherooControl
'net.hadess.SwitcherooControl': `<node>
// net.haddes.SwitcherooControl
'net.hadess.SwitcherooControl': `<node>
<interface name="net.hadess.SwitcherooControl">
<property name="HasDualGpu" type="b" access="read"/>
<property name="NumGPUs" type="u" access="read"/>
......@@ -25,8 +26,8 @@ var DBusInterfaces = {
</interface>
</node>`,
// org.freedesktop.FileManager1
'org.freedesktop.FileManager1': `<node>
// org.freedesktop.FileManager1
'org.freedesktop.FileManager1': `<node>
<interface name='org.freedesktop.FileManager1'>
<method name='ShowItems'>
<arg name='URIs' type='as' direction='in'/>
......@@ -39,8 +40,8 @@ var DBusInterfaces = {
</interface>
</node>`,
// org.gnome.ArchiveManager1
'org.gnome.ArchiveManager1': `<node>
// org.gnome.ArchiveManager1
'org.gnome.ArchiveManager1': `<node>
<interface name="org.gnome.ArchiveManager1">
<method name="GetSupportedTypes">
<arg name="action" type="s" direction="in"/>
......@@ -72,8 +73,8 @@ var DBusInterfaces = {
</interface>
</node>`,
// org.gnome.Nautilus.FileOperations2
'org.gnome.Nautilus.FileOperations2': `<node>
// org.gnome.Nautilus.FileOperations2
'org.gnome.Nautilus.FileOperations2': `<node>
<interface name='org.gnome.Nautilus.FileOperations2'>
<method name='CopyURIs'>
<arg type='as' name='sources' direction='in'/>
......@@ -117,8 +118,8 @@ var DBusInterfaces = {
</interface>
</node>`,
// org.gnome.NautilusPreviewer
'org.gnome.NautilusPreviewer': `<node>
// org.gnome.NautilusPreviewer
'org.gnome.NautilusPreviewer': `<node>
<interface name='org.gnome.NautilusPreviewer'>
<method name='ShowFile'>
<arg name='FileUri' type='s' direction='in'/>
......@@ -128,8 +129,8 @@ var DBusInterfaces = {
</interface>
</node>`,
// org.gtk.vfs.Metadata
'org.gtk.vfs.Metadata': `<node>
// org.gtk.vfs.Metadata
'org.gtk.vfs.Metadata': `<node>
<interface name='org.gtk.vfs.Metadata'>
<method name="Set">
<arg type='ay' name='treefile' direction='in'/>
......@@ -157,8 +158,8 @@ var DBusInterfaces = {
</interface>
</node>`,
// org.freedesktop.DBus.Introspectable
'org.freedesktop.DBus.Introspectable': `<node>
// org.freedesktop.DBus.Introspectable
'org.freedesktop.DBus.Introspectable': `<node>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg direction="out" type="s"/>
......@@ -166,8 +167,8 @@ var DBusInterfaces = {
</interface>
</node>`,
// org.freedesktop.Notifications
'org.freedesktop.Notifications': `<node>
// org.freedesktop.Notifications
'org.freedesktop.Notifications': `<node>
<interface name="org.freedesktop.Notifications">
<method name="Notify">
<arg type="s" name="arg_0" direction="in">
......@@ -220,5 +221,5 @@ var DBusInterfaces = {
</arg>
</signal>
</interface>
</node>`
</node>`,
};
This diff is collapsed.
......@@ -15,16 +15,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* exported DesktopGrid */
'use strict';
const Gtk = imports.gi.Gtk;
const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Prefs = imports.preferences;
const Enums = imports.enums;
const DesktopIconsUtil = imports.desktopIconsUtil;
const Signals = imports.signals;
const Gettext = imports.gettext.domain('ding');
......@@ -34,7 +32,6 @@ const _ = Gettext.gettext;
var elementSpacing = 2;
var DesktopGrid = class {
_connectSignal(object, signal, callback) {
this._signalIds.push([object, object.connect(signal, callback)]);
}
......@@ -52,13 +49,13 @@ var DesktopGrid = class {
this.updateUnscaledHeightWidthMargins();
this.createGrids();
this._window = new Gtk.ApplicationWindow({application: desktopManager.mainApp, "title": desktopName});
this._window = new Gtk.ApplicationWindow({application: desktopManager.mainApp, 'title': desktopName});
this._windowContext = this._window.get_style_context();
if (this._asDesktop) {
this._window.set_decorated(false);
this._window.set_deletable(false);
// For Wayland Transparent background, but only if this instance is working as desktop
this._windowContext.add_class("desktopwindow");
this._windowContext.add_class('desktopwindow');
// If we are under X11, Transparent background and everything else from here as well
if (this._desktopManager.using_X11) {
let screen = this._window.get_screen();
......@@ -76,7 +73,7 @@ var DesktopGrid = class {
}
} else {
// Opaque black test window
this._windowContext.add_class("testwindow");
this._windowContext.add_class('testwindow');
}
this._window.set_resizable(false);
this._connectSignal(this._window, 'delete-event', () => {
......@@ -92,7 +89,7 @@ var DesktopGrid = class {
}
});
this._eventBox = new Gtk.EventBox({ visible: true });
this._eventBox = new Gtk.EventBox({visible: true});
this.sizeEventBox();
this._window.add(this._eventBox);
this._container = new Gtk.Fixed();
......@@ -150,10 +147,8 @@ var DesktopGrid = class {
if (this._asDesktop) {
if (this._desktopManager.using_X11) {
this._size_divisor = Math.ceil(this._zoom);
} else {
if (this._premultiplied) {
this._size_divisor = 1;
}
} else if (this._premultiplied) {
this._size_divisor = 1;
}
}
this._windowWidth = Math.floor(this._desktopDescription.width / this._size_divisor);
......@@ -163,7 +158,7 @@ var DesktopGrid = class {
resizeWindow() {
this.updateWindowGeometry();
this._desktopName = `@!${this._x},${this._y};BDHF`;
if (this._desktopManager.using_X11){
if (this._desktopManager.using_X11) {
this._window.move(this._x / this._size_divisor, this._y / this._size_divisor);
}
this._window.set_title(this._desktopName);
......@@ -181,7 +176,7 @@ var DesktopGrid = class {
}
createGrids() {
this._width = Math.floor( this._width / this._size_divisor);
this._width = Math.floor(this._width / this._size_divisor);
this._height = Math.floor(this._height / this._size_divisor);
this._marginTop = Math.floor(this._marginTop / this._size_divisor);
this._marginBottom = Math.floor(this._marginBottom / this._size_divisor);
......@@ -210,8 +205,8 @@ var DesktopGrid = class {
setGridStatus() {
this._fileItems = {};
this._gridStatus = {};
for (let y=0; y<this._maxRows; y++) {
for (let x=0; x<this._maxColumns; x++) {
for (let y = 0; y < this._maxRows; y++) {
for (let x = 0; x < this._maxColumns; x++) {
this._setGridUse(x, y, false);
}
}
......@@ -228,7 +223,7 @@ var DesktopGrid = class {
destroy() {
this._destroying = true;
/* Disconnect signals */
for(let [object, signalId] of this._signalIds) {
for (let [object, signalId] of this._signalIds) {
object.disconnect(signalId);
}
this._signalIds = [];
......@@ -236,7 +231,7 @@ var DesktopGrid = class {
}
setDropDestination(dropDestination) {
dropDestination.drag_dest_set(Gtk.DestDefaults.MOTION | Gtk.DestDefaults.DROP, null, Gdk.DragAction.MOVE|Gdk.DragAction.COPY|Gdk.DragAction.DEFAULT);
dropDestination.drag_dest_set(Gtk.DestDefaults.MOTION | Gtk.DestDefaults.DROP, null, Gdk.DragAction.MOVE | Gdk.DragAction.COPY | Gdk.DragAction.DEFAULT);
let targets = new Gtk.TargetList(null);
targets.add(Gdk.atom_intern('x-special/ding-icon-list', false), Gtk.TargetFlags.SAME_APP,
Enums.DndTargetInfo.DING_ICON_LIST);
......@@ -251,10 +246,11 @@ var DesktopGrid = class {
this._connectSignal(dropDestination, 'drag-motion', (widget, context, x, y, time) => {
this.receiveMotion(x, y);
if (DesktopIconsUtil.getModifiersInDnD(context, Gdk.ModifierType.CONTROL_MASK))
if (DesktopIconsUtil.getModifiersInDnD(context, Gdk.ModifierType.CONTROL_MASK)) {
Gdk.drag_status(context, Gdk.DragAction.COPY, time);
else
} else {
Gdk.drag_status(context, Gdk.DragAction.MOVE, time);
}
});
this._connectSignal(this._eventBox, 'drag-leave', (widget, context, time) => {
this.receiveLeave();
......@@ -270,7 +266,7 @@ var DesktopGrid = class {
}
receiveMotion(x, y, global) {
if (! global) {
if (!global) {
x = this._elementWidth * Math.floor(x / this._elementWidth);
y = this._elementHeight * Math.floor(y / this._elementHeight);
[x, y] = this.coordinatesLocalToGlobal(x, y);
......@@ -279,7 +275,7 @@ var DesktopGrid = class {
}
receiveDrop(context, x, y, selection, info, forceLocal, forceCopy) {
if (! forceLocal) {
if (!forceLocal) {
x = this._elementWidth * Math.floor(x / this._elementWidth);
y = this._elementHeight * Math.floor(y / this._elementHeight);
[x, y] = this.coordinatesLocalToGlobal(x, y);
......@@ -288,7 +284,7 @@ var DesktopGrid = class {
this._window.queue_draw();
}
highLightGridAt(x,y) {
highLightGridAt(x, y) {
let selected = this.getGridAt(x, y, false);
this._selectedList = [selected];
this._window.queue_draw();
......@@ -299,7 +295,7 @@ var DesktopGrid = class {
this._window.queue_draw();
}
_getGridCoordinates(x, y, clamp) {
_getGridCoordinates(x, y) {
let placeX = Math.floor(x / this._elementWidth);
let placeY = Math.floor(y / this._elementHeight);
placeX = DesktopIconsUtil.clamp(placeX, 0, this._maxColumns - 1);
......@@ -319,7 +315,7 @@ var DesktopGrid = class {
return [localX, localY];
}
_fileAt(x,y) {
_fileAt(x, y) {
let [placeX, placeY] = this._getGridCoordinates(x, y);
return this._gridStatus[placeY * this._maxColumns + placeX];
}
......@@ -332,8 +328,8 @@ var DesktopGrid = class {
}
let newSelectedList = [];
for (let [x, y] of selectedList) {
x = x + this._elementWidth/2;
y = y + this._elementHeight/2;
x += this._elementWidth / 2;
y += this._elementHeight / 2;
x += ox;
y += oy;
let r = this.getGridAt(x, y);
......@@ -363,43 +359,51 @@ var DesktopGrid = class {
_doDrawRubberBand(cr) {
if (this._desktopManager.rubberBand && this._desktopManager.selectionRectangle) {
if (! this.gridGlobalRectangle.intersect(this._desktopManager.selectionRectangle)[0]) {
if (!this.gridGlobalRectangle.intersect(this._desktopManager.selectionRectangle)[0]) {
return;
}
let [xInit, yInit] = this.coordinatesGlobalToLocal(this._desktopManager.x1, this._desktopManager.y1);
let [xFin, yFin] = this.coordinatesGlobalToLocal(this._desktopManager.x2, this._desktopManager.y2);
cr.rectangle(xInit + 0.5, yInit + 0.5, xFin - xInit, yFin - yInit);
Gdk.cairo_set_source_rgba(cr, new Gdk.RGBA({red: this._desktopManager.selectColor.red,
green: this._desktopManager.selectColor.green,
blue: this._desktopManager.selectColor.blue,
alpha: 0.6})
Gdk.cairo_set_source_rgba(cr, new Gdk.RGBA({
red: this._desktopManager.selectColor.red,
green: this._desktopManager.selectColor.green,
blue: this._desktopManager.selectColor.blue,
alpha: 0.6,
})
);
cr.fill();
cr.setLineWidth(1);
cr.rectangle(xInit + 0.5, yInit + 0.5, xFin - xInit, yFin - yInit);
Gdk.cairo_set_source_rgba(cr, new Gdk.RGBA({red: this._desktopManager.selectColor.red,
green: this._desktopManager.selectColor.green,
blue: this._desktopManager.selectColor.blue,
alpha: 1.0})
Gdk.cairo_set_source_rgba(cr, new Gdk.RGBA({
red: this._desktopManager.selectColor.red,
green: this._desktopManager.selectColor.green,
blue: this._desktopManager.selectColor.blue,
alpha: 1.0,
})
);
cr.stroke();
}
if (this._desktopManager.showDropPlace && (this._selectedList !== null)) {
for(let [x, y] of this._selectedList) {
for (let [x, y] of this._selectedList) {
cr.rectangle(x + 0.5, y + 0.5, this._elementWidth, this._elementHeight);
Gdk.cairo_set_source_rgba(cr, new Gdk.RGBA({red: 1.0 - this._desktopManager.selectColor.red,
green: 1.0 - this._desktopManager.selectColor.green,
blue: 1.0 - this._desktopManager.selectColor.blue,
alpha: 0.4})
Gdk.cairo_set_source_rgba(cr, new Gdk.RGBA({
red: 1.0 - this._desktopManager.selectColor.red,
green: 1.0 - this._desktopManager.selectColor.green,
blue: 1.0 - this._desktopManager.selectColor.blue,
alpha: 0.4,
})
);
cr.fill();
cr.setLineWidth(0.5);
cr.rectangle(x + 0.5, y + 0.5, this._elementWidth, this._elementHeight);
Gdk.cairo_set_source_rgba(cr, new Gdk.RGBA({red: 1.0 - this._desktopManager.selectColor.red,
green: 1.0 - this._desktopManager.selectColor.green,
blue: 1.0 - this._desktopManager.selectColor.blue,
alpha: 1.0})
Gdk.cairo_set_source_rgba(cr, new Gdk.RGBA({
red: 1.0 - this._desktopManager.selectColor.red,
green: 1.0 - this._desktopManager.selectColor.green,
blue: 1.0 - this._desktopManager.selectColor.blue,
alpha: 1.0,
})
);
cr.stroke();
}
......@@ -410,39 +414,39 @@ var DesktopGrid = class {
/**
* Checks if these coordinates belong to this grid.
*
* @Returns: -1 if there is no free space for new icons;
* 0 if the coordinates are inside this grid;
* or the distance to the middle point, if none of the previous
* @returns -1 if there is no free space for new icons;
* 0 if the coordinates are inside this grid;
* or the distance to the middle point, if none of the previous
*/
let isFree = false;
for (let element in this._gridStatus) {
if (!this._gridStatus[element]) {
isFree = true;
break;
}
}
if (!isFree) {
return -1;
}
if (this._coordinatesBelongToThisGrid(x, y)) {
return 0;
}
return Math.pow(x - (this._x + this._windowWidth * this._zoom / 2), 2) + Math.pow(x - (this._y + this._windowHeight * this._zoom / 2), 2);
}
coordinatesGlobalToLocal(X, Y, widget=null) {
let isFree = false;
for (let element in this._gridStatus) {
if (!this._gridStatus[element]) {
isFree = true;
break;
}
}
if (!isFree) {
return -1;
}
if (this._coordinatesBelongToThisGrid(x, y)) {
return 0;
}
return Math.pow(x - (this._x + this._windowWidth * this._zoom / 2), 2) + Math.pow(x - (this._y + this._windowHeight * this._zoom / 2), 2);
}
coordinatesGlobalToLocal(X, Y, widget = null) {
X -= this._x;
Y -= this._y;
if (! widget) {
if (!widget) {
widget = this._eventBox;
}
let [belong, x, y] = this._window.translate_coordinates(widget, X, Y);
return [x, y];
}
coordinatesLocalToGlobal(x, y, widget=null) {
if (! widget) {
coordinatesLocalToGlobal(x, y, widget = null) {
if (!widget) {
widget = this._eventBox;
}
let [belongs, X, Y] = widget.translate_coordinates(this._window, x, y);
......@@ -450,7 +454,6 @@ var DesktopGrid = class {
}
_addFileItemTo(fileItem, column, row, coordinatesAction) {
if (this._destroying) {
return;
}
......@@ -461,11 +464,11 @@ var DesktopGrid = class {
this._fileItems[fileItem.uri] = [column, row, fileItem];
let [x, y] = this.coordinatesLocalToGlobal(localX + elementSpacing, localY + elementSpacing);
fileItem.setCoordinates(x,
y,
this._elementWidth - 2 * elementSpacing,
this._elementHeight - 2 * elementSpacing,
elementSpacing,
this);
y,
this._elementWidth - 2 * elementSpacing,
this._elementHeight - 2 * elementSpacing,
elementSpacing,
this);
/* If this file is new in the Desktop and hasn't yet
* fixed coordinates, store the new possition to ensure
* that the next time it will be shown in the same possition.
......@@ -487,23 +490,23 @@ var DesktopGrid = class {
}
addFileItemCloseTo(fileItem, x, y, coordinatesAction) {
let add_volumes_opposite = Prefs.desktopSettings.get_boolean('add-volumes-opposite');
let addVolumesOpposite = Prefs.desktopSettings.get_boolean('add-volumes-opposite');
let [column, row] = this._getEmptyPlaceClosestTo(x,
y,
coordinatesAction,
fileItem.isDrive && add_volumes_opposite);
y,
coordinatesAction,
fileItem.isDrive && addVolumesOpposite);
this._addFileItemTo(fileItem, column, row, coordinatesAction);
}
_isEmptyAt(x,y) {
return (this._gridStatus[y * this._maxColumns + x] === false);
_isEmptyAt(x, y) {
return this._gridStatus[y * this._maxColumns + x] === false;
}
_setGridUse(x, y, inUse) {
this._gridStatus[y * this._maxColumns + x] = inUse;
}
getGridAt(x, y, globalCoordinates=false) {
getGridAt(x, y, globalCoordinates = false) {
if (this._coordinatesBelongToThisGrid(x, y)) {
[x, y] = this.coordinatesGlobalToLocal(x, y);
if (globalCoordinates) {
......@@ -520,12 +523,11 @@ var DesktopGrid = class {
}
_coordinatesBelongToThisGrid(X, Y) {
let checkRectangle = new Gdk.Rectangle({ x: X, y: Y, width: 1, height: 1 });
return this.gridGlobalRectangle.intersect(checkRectangle)[0];
let checkRectangle = new Gdk.Rectangle({x: X, y: Y, width: 1, height: 1});
return this.gridGlobalRectangle.intersect(checkRectangle)[0];
}
_getEmptyPlaceClosestTo(x, y, coordinatesAction, reverseHorizontal) {
[x, y] = this.coordinatesGlobalToLocal(x, y);
let placeX = Math.floor(x / this._elementWidth);
let placeY = Math.floor(y / this._elementHeight);
......@@ -545,17 +547,17 @@ var DesktopGrid = class {
let resRow = null;
let minDistance = Infinity;
let column, row;
for (let tmp_column = 0; tmp_column < this._maxColumns; tmp_column++) {
for (let tmpColumn = 0; tmpColumn < this._maxColumns; tmpColumn++) {
if (cornerInversion[0]) {
column = this._maxColumns - tmp_column - 1;
column = this._maxColumns - tmpColumn - 1;
} else {
column = tmp_column;
column = tmpColumn;
}
for (let tmp_row = 0; tmp_row < this._maxRows; tmp_row++) {
for (let tmpRow = 0; tmpRow < this._maxRows; tmpRow++) {
if (cornerInversion[1]) {
row = this._maxRows - tmp_row - 1;
row = this._maxRows - tmpRow - 1;
} else {
row = tmp_row;
row = tmpRow;
}
if (!this._isEmptyAt(column, row)) {
continue;
......@@ -563,8 +565,9 @@ var DesktopGrid = class {
let proposedX = column * this._elementWidth;
let proposedY = row * this._elementHeight;
if (coordinatesAction == Enums.StoredCoordinates.ASSIGN)
if (coordinatesAction == Enums.StoredCoordinates.ASSIGN) {
return [column, row];
}
let distance = DesktopIconsUtil.distanceBetweenPoints(proposedX, proposedY, x, y);
if (distance < minDistance) {
found = true;
......@@ -576,7 +579,7 @@ var DesktopGrid = class {
}
if (!found) {
throw new Error(`Not enough place at monitor`);
throw new Error('Not enough place at monitor');
}
return [resColumn, resRow];
......
This diff is collapsed.
......@@ -153,7 +153,7 @@ var DesktopIconsUsableAreaClass = class {
return;
const usableArea = extension?.stateObj?.DesktopIconsUsableArea;
if (usableArea?.uuid === IDENTIFIER_UUID)
if (usableArea?.uuid === IDENTIFIER_UUID)
usableArea.setMarginsForExtension(Me.uuid, this._margins);
}
}
......@@ -15,8 +15,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* exported getModifiersInDnD, getDesktopDir, getScriptsDir, getTemplatesDir, clamp,
spawnCommandLine, launchTerminal, getFilteredEnviron, distanceBetweenPoints, getExtraFolders,
getMounts, getFileExtensionOffset, getFilesFromNautilusDnD, writeTextFileToDesktop,
windowHidePagerTaskbarModal, waitDelayMs */
'use strict';
const Gtk = imports.gi.Gtk;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Gdk = imports.gi.Gdk;
......@@ -26,47 +29,77 @@ const Gettext = imports.gettext.domain('ding');
const _ = Gettext.gettext;
/**
*
* @param context
* @param modifiersToCheck
*/
function getModifiersInDnD(context, modifiersToCheck) {
let device = context.get_device();
let display = device.get_display();
let keymap = Gdk.Keymap.get_for_display(display);
let modifiers = keymap.get_modifier_state();
return ((modifiers & modifiersToCheck) != 0);
return (modifiers & modifiersToCheck) != 0;
}
/**
*
*/
function getDesktopDir() {
let desktopPath = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP);
return Gio.File.new_for_commandline_arg(desktopPath);
}
/**
*
*/
function getScriptsDir() {
let scriptsDir = GLib.build_filenamev([GLib.get_home_dir(), Enums.NAUTILUS_SCRIPTS_DIR]);
return Gio.File.new_for_commandline_arg(scriptsDir);
}
/**
*
*/
function getTemplatesDir() {
let templatesDir = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_TEMPLATES);
if ((templatesDir == GLib.get_home_dir()) || (templatesDir == null)) {
return null;
}
return Gio.File.new_for_commandline_arg(templatesDir)
return Gio.File.new_for_commandline_arg(templatesDir);
}
/**
*
* @param value
* @param min
* @param max
*/
function clamp(value, min, max) {
return Math.max(Math.min(value, max), min);
};
}
function spawnCommandLine(command_line, environ=null) {
/**
*
* @param commandLine
* @param environ
*/
function spawnCommandLine(commandLine, environ = null) {
try {
let [success, argv] = GLib.shell_parse_argv(command_line);
let [success, argv] = GLib.shell_parse_argv(commandLine);
trySpawn(null, argv, environ);
} catch (err) {
print(`${command_line} failed with ${err}`);
print(`${commandLine} failed with ${err}`);
}
}
/**
*
* @param workdir
* @param command
*/
function launchTerminal(workdir, command) {
let terminalSettings = new Gio.Settings({ schema_id: Enums.TERMINAL_SCHEMA });
let terminalSettings = new Gio.Settings({schema_id: Enums.TERMINAL_SCHEMA});
let exec = terminalSettings.get_string(Enums.EXEC_KEY);
let argv = [exec, `--working-directory=${workdir}`];
if (command) {
......@@ -76,7 +109,13 @@ function launchTerminal(workdir, command) {
trySpawn(workdir, argv, null);
}
function trySpawn(workdir, argv, environ=null) {
/**
*
* @param workdir
* @param argv
* @param environ
*/
function trySpawn(workdir, argv, environ = null) {
/* The following code has been extracted from GNOME Shell's
* source code in Misc.Util.trySpawn function and modified to
* set the working directory.
......@@ -87,13 +126,15 @@ function trySpawn(workdir, argv, environ=null) {
var success, pid;
try {
[success, pid] = GLib.spawn_async(workdir, argv, environ,
GLib.SpawnFlags.SEARCH_PATH | GLib.SpawnFlags.DO_NOT_REAP_CHILD,
null);
GLib.SpawnFlags.SEARCH_PATH | GLib.SpawnFlags.DO_NOT_REAP_CHILD,
null);
} catch (err) {
/* Rewrite the error in case of ENOENT */
if (err.matches(GLib.SpawnError, GLib.SpawnError.NOENT)) {
throw new GLib.SpawnError({ code: GLib.SpawnError.NOENT,
message: _("Command not found") });
throw new GLib.SpawnError({
code: GLib.SpawnError.NOENT,
message: _('Command not found'),
});
} else if (err instanceof GLib.Error) {
// The exception from gjs contains an error string like:
// Error invoking GLib.spawn_command_line_async: Failed to
......@@ -101,8 +142,10 @@ function trySpawn(workdir, argv, environ=null) {
// We are only interested in the part in the parentheses. (And
// we can't pattern match the text, since it gets localized.)
let message = err.message.replace(/.*\((.+)\)/, '$1');
throw new (err.constructor)({ code: err.code,
message: message });
throw new err.constructor({
code: err.code,
message,
});
} else {
throw err;
}
......@@ -113,6 +156,9 @@ function trySpawn(workdir, argv, environ=null) {
GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, () => {});
}
/**
*
*/
function getFilteredEnviron() {
let environ = [];
for (let env of GLib.get_environ()) {
......@@ -128,12 +174,22 @@ function getFilteredEnviron() {
return environ;
}
/**
*
* @param x
* @param y
* @param x2
* @param y2
*/
function distanceBetweenPoints(x, y, x2, y2) {
return (Math.pow(x - x2, 2) + Math.pow(y - y2, 2));
return Math.pow(x - x2, 2) + Math.pow(y - y2, 2);
}
/**
*
*/
function getExtraFolders() {
let extraFolders = new Array();
let extraFolders = [];
if (Prefs.desktopSettings.get_boolean('show-home')) {
extraFolders.push([Gio.File.new_for_commandline_arg(GLib.get_home_dir()), Enums.FileType.USER_DIRECTORY_HOME]);
}
......@@ -143,13 +199,17 @@ function getExtraFolders() {
return extraFolders;
}
/**
*
* @param volumeMonitor
*/
function getMounts(volumeMonitor) {
let show_volumes = Prefs.desktopSettings.get_boolean('show-volumes');
let show_network = Prefs.desktopSettings.get_boolean('show-network-volumes');
let showVolumes = Prefs.desktopSettings.get_boolean('show-volumes');
let showNetwork = Prefs.desktopSettings.get_boolean('show-network-volumes');
try {
var mounts = volumeMonitor.get_mounts();
} catch(e) {
} catch (e) {
print(`Failed to get the list of mounts with ${e}`);
return [];
}
......@@ -158,23 +218,28 @@ function getMounts(volumeMonitor) {
let uris = [];
for (let mount of mounts) {
try {
let is_drive = (mount.get_drive() != null) || (mount.get_volume() != null);
let isDrive = (mount.get_drive() != null) || (mount.get_volume() != null);
let uri = mount.get_default_location().get_uri();
if (((is_drive && show_volumes) || (!is_drive && show_network)) && (!(uris.includes(uri)))) {
if (((isDrive && showVolumes) || (!isDrive && showNetwork)) && !uris.includes(uri)) {
result.push([mount.get_default_location(), Enums.FileType.EXTERNAL_DRIVE, mount]);
uris.push(uri);
}
} catch(e) {
} catch (e) {
print(`Failed with ${e} while getting volume`);
}
}
return result;
}
function getFileExtensionOffset(filename, opts={'isDirectory':false}) {
/**
*
* @param filename
* @param opts
*/
function getFileExtensionOffset(filename, opts = {'isDirectory': false}) {
let offset = filename.length;
let extension = '';
if (! opts.isDirectory) {
if (!opts.isDirectory) {
const doubleExtensions = ['.gz', '.bz2', '.sit', '.Z', '.bz', '.xz'];
for (const item of doubleExtensions) {
if (filename.endsWith(item)) {
......@@ -191,14 +256,19 @@ function getFileExtensionOffset(filename, opts={'isDirectory':false}) {
filename = filename.substring(0, offset);
}
}
return {'offset': offset, 'basename': filename, 'extension': extension};
return {offset, 'basename': filename, extension};
}
/**
*
* @param selection
* @param type
*/
function getFilesFromNautilusDnD(selection, type) {
let data = String.fromCharCode.apply(null, selection.get_data());
let retval = [];
let elements = data.split('\r\n');
for(let item of elements) {
for (let item of elements) {
if (item.length == 0) {
continue;
}
......@@ -217,37 +287,48 @@ function getFilesFromNautilusDnD(selection, type) {
return retval;
}
/**
*
* @param text
* @param filename
* @param dropCoordinates
*/
function writeTextFileToDesktop(text, filename, dropCoordinates) {
let path = GLib.build_filenamev([GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP), filename]);
let file = Gio.File.new_for_path(path);
const PERMISSIONS_MODE = 0o744;
if (GLib.mkdir_with_parents(file.get_parent().get_path(), PERMISSIONS_MODE) === 0) {
let [success, tag] = file.replace_contents(text, null, false, Gio.FileCreateFlags.REPLACE_DESTINATION, null);
let [success, tag] = file.replace_contents(text, null, false, Gio.FileCreateFlags.REPLACE_DESTINATION, null);
}
if (dropCoordinates != null) {
let info = new Gio.FileInfo();
info.set_attribute_string('metadata::nautilus-drop-position', `${dropCoordinates[0]},${dropCoordinates[1]}`);
try {
file.set_attributes_from_info(info, Gio.FileQueryInfoFlags.NONE, null);
} catch(e) {}
} catch (e) {}
}
}
/**
*
* @param window
* @param modal
*/
function windowHidePagerTaskbarModal(window, modal) {
let using_X11 = Gdk.Display.get_default().constructor.$gtype.name === 'GdkX11Display';
if (using_X11) {
let usingX11 = Gdk.Display.get_default().constructor.$gtype.name === 'GdkX11Display';
if (usingX11) {
window.set_type_hint(Gdk.WindowTypeHint.NORMAL);
window.set_skip_taskbar_hint(true);
window.set_skip_pager_hint(true);
} else {
let title = window.get_title();
if (title == null) {
title = "";
title = '';
}
if (modal) {
title = title + ' ';
title += ' ';
} else {
title = title + ' ';
title += ' ';
}
window.set_title(title);
}
......@@ -261,8 +342,12 @@ function windowHidePagerTaskbarModal(window, modal) {
}
}
/**
*
* @param ms
*/
function waitDelayMs(ms) {
return new Promise( (resolve, reject) => {
return new Promise((resolve, reject) => {
GLib.timeout_add(GLib.PRIORITY_DEFAULT, ms, () => {
resolve();
return false;
......
This diff is collapsed.
......@@ -30,34 +30,42 @@ let errorFound = false;
let asDesktop = false;
let primaryIndex = 0;
function print_usage() {
print("Desktop Icons NG");
print("Usage:");
print(" -h : show this help");
print(" -E : run as desktop (with transparent window, reading data from the extension...)");
print(" -P code path : set the path where the code is stored");
print(" -M index : index of the primary monitor");
print(" -D x:y:w:h:z:t:b:l:r:i : monitor data");
print(" x: X coordinate");
print(" y: Y coordinate");
print(" w: width in pixels");
print(" h: height in pixels");
print(" z: zoom value (must be greater than or equal to one)");
print(" t: top margin in pixels");
print(" b: bottom margin in pixels");
print(" l: left margin in pixels");
print(" r: right margin in pixels");
print(" i: monitor index (0, 1...)");
/**
*
*/
function printUsage() {
print('Desktop Icons NG');
print('Usage:');
print(' -h : show this help');
print(' -E : run as desktop (with transparent window, reading data from the extension...)');
print(' -P code path : set the path where the code is stored');
print(' -M index : index of the primary monitor');
print(' -D x:y:w:h:z:t:b:l:r:i : monitor data');
print(' x: X coordinate');
print(' y: Y coordinate');
print(' w: width in pixels');
print(' h: height in pixels');
print(' z: zoom value (must be greater than or equal to one)');
print(' t: top margin in pixels');
print(' b: bottom margin in pixels');
print(' l: left margin in pixels');
print(' r: right margin in pixels');
print(' i: monitor index (0, 1...)');
}
/**
*
* @param argv
*/
function parseCommandLine(argv) {
desktops = [];
for(let arg of argv) {
let data;
for (let arg of argv) {
if (lastCommand == null) {
switch(arg) {
switch (arg) {
case '-h':
case '-H':
print_usage();
printUsage();
errorFound = true;
break;
case '-E':
......@@ -79,35 +87,35 @@ function parseCommandLine(argv) {
if (errorFound) {
break;
}
switch(lastCommand) {
switch (lastCommand) {
case '-P':
codePath = arg;
break;
case '-D':
let data = arg.split(":");
data = arg.split(':');
if (data.length != 10) {
print("Incorrect number of parameters for -D\n");
print_usage();
print('Incorrect number of parameters for -D\n');
printUsage();
errorFound = true;
break;
}
if (parseFloat(data[4]) < 1.0) {
print("Error: ZOOM value can't be less than one\n");
print_usage();
printUsage();
errorFound = true;
break;
}
desktops.push({
x:parseInt(data[0]),
y:parseInt(data[1]),
width:parseInt(data[2]),
height:parseInt(data[3]),
zoom:parseFloat(data[4]),
marginTop:parseInt(data[5]),
marginBottom:parseInt(data[6]),
marginLeft:parseInt(data[7]),
marginRight:parseInt(data[8]),
monitorIndex:parseInt(data[9])
x: parseInt(data[0]),
y: parseInt(data[1]),
width: parseInt(data[2]),
height: parseInt(data[3]),
zoom: parseFloat(data[4]),
marginTop: parseInt(data[5]),
marginBottom: parseInt(data[6]),
marginLeft: parseInt(data[7]),
marginRight: parseInt(data[8]),
monitorIndex: parseInt(data[9]),
});
break;
case '-M':
......@@ -120,9 +128,9 @@ function parseCommandLine(argv) {
/* if no desktop list is provided, like when launching the program in stand-alone mode,
* configure a 1280x720 desktop
*/
desktops.push({x:0, y:0, width: 1280, height: 720, zoom: 1, marginTop: 0, marginBottom: 0, marginLeft: 0, marginRight: 0, monitorIndex: 0});
desktops.push({x: 0, y: 0, width: 1280, height: 720, zoom: 1, marginTop: 0, marginBottom: 0, marginLeft: 0, marginRight: 0, monitorIndex: 0});
}
for(let desktop of desktops) {
for (let desktop of desktops) {
desktop.primaryMonitor = primaryIndex;
}
}
......@@ -138,17 +146,17 @@ const Prefs = imports.preferences;
const Gettext = imports.gettext;
const PromiseUtils = imports.promiseUtils;
PromiseUtils._promisify({ keepOriginal: true }, Gio.FileEnumerator.prototype, 'close_async');
PromiseUtils._promisify({ keepOriginal: true }, Gio.FileEnumerator.prototype, 'next_files_async');
PromiseUtils._promisify({ keepOriginal: true }, Gio._LocalFilePrototype, 'delete_async');
PromiseUtils._promisify({ keepOriginal: true }, Gio._LocalFilePrototype, 'enumerate_children_async');
PromiseUtils._promisify({ keepOriginal: true }, Gio._LocalFilePrototype, 'make_directory_async');
PromiseUtils._promisify({ keepOriginal: true }, Gio._LocalFilePrototype, 'query_info_async');
PromiseUtils._promisify({ keepOriginal: true }, Gio._LocalFilePrototype, 'set_attributes_async');
PromiseUtils._promisify({keepOriginal: true}, Gio.FileEnumerator.prototype, 'close_async');
PromiseUtils._promisify({keepOriginal: true}, Gio.FileEnumerator.prototype, 'next_files_async');
PromiseUtils._promisify({keepOriginal: true}, Gio._LocalFilePrototype, 'delete_async');
PromiseUtils._promisify({keepOriginal: true}, Gio._LocalFilePrototype, 'enumerate_children_async');
PromiseUtils._promisify({keepOriginal: true}, Gio._LocalFilePrototype, 'make_directory_async');
PromiseUtils._promisify({keepOriginal: true}, Gio._LocalFilePrototype, 'query_info_async');
PromiseUtils._promisify({keepOriginal: true}, Gio._LocalFilePrototype, 'set_attributes_async');
let localePath = GLib.build_filenamev([codePath, "locale"]);
let localePath = GLib.build_filenamev([codePath, 'locale']);
if (Gio.File.new_for_path(localePath).query_exists(null)) {
Gettext.bindtextdomain("ding", localePath);
Gettext.bindtextdomain('ding', localePath);
}
const DesktopManager = imports.desktopManager;
......@@ -157,8 +165,10 @@ var desktopManager = null;
var dbusManager = null;
// Use different AppIDs to allow to test it from a command line while the main desktop is also running from the extension
const dingApp = new Gtk.Application({application_id: asDesktop ? 'com.rastersoft.ding' : 'com.rastersoft.dingtest',
flags: Gio.ApplicationFlags.HANDLES_COMMAND_LINE | Gio.ApplicationFlags.REPLACE});
const dingApp = new Gtk.Application({
application_id: asDesktop ? 'com.rastersoft.ding' : 'com.rastersoft.dingtest',
flags: Gio.ApplicationFlags.HANDLES_COMMAND_LINE | Gio.ApplicationFlags.REPLACE,
});
dingApp.connect('startup', () => {
Prefs.init(codePath);
......@@ -168,19 +178,19 @@ dingApp.connect('startup', () => {
dingApp.connect('activate', () => {
if (!desktopManager) {
desktopManager = new DesktopManager.DesktopManager(dingApp,
dbusManager,
desktops,
codePath,
asDesktop,
primaryIndex);
dbusManager,
desktops,
codePath,
asDesktop,
primaryIndex);
}
});
dingApp.connect('command-line', (app, commandLine) => {
let argv =[];
let argv = [];
argv = commandLine.get_arguments();
parseCommandLine(argv);
if (! errorFound) {
if (!errorFound) {
if (commandLine.get_is_remote()) {
desktopManager.updateGridWindows(desktops);
} else {
......
......@@ -14,9 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* exported EmulateX11WindowType */
'use strict';
const GLib = imports.gi.GLib;
const Shell = imports.gi.Shell;
const Meta = imports.gi.Meta;
const Main = imports.ui.main;
......@@ -41,8 +41,8 @@ class ManageWindow {
even to decorated windows.
*/
constructor(window, wayland_client, changedStatusCB) {
this._wayland_client = wayland_client;
constructor(window, waylandClient, changedStatusCB) {
this._waylandClient = waylandClient;
this._window = window;
this._signalIDs = [];
this._changedStatusCB = changedStatusCB;
......@@ -56,24 +56,24 @@ class ManageWindow {
this._window.move_frame(true, this._x, this._y);
}
}));
this._signalIDs.push(window.connect("notify::title", () => {
this._signalIDs.push(window.connect('notify::title', () => {
this._parseTitle();
}));
this._signalIDs.push(window.connect("notify::above", () => {
this._signalIDs.push(window.connect('notify::above', () => {
if (this._keepAtBottom && this._window.above) {
this._window.unmake_above();
}
}));
this._signalIDs.push(window.connect("notify::minimized", () => {
this._signalIDs.push(window.connect('notify::minimized', () => {
this._window.unminimize();
}));
this._signalIDs.push(window.connect("notify::maximized-vertically", ()=> {
this._signalIDs.push(window.connect('notify::maximized-vertically', () => {
if (!window.maximized_vertically) {
window.maximize(Meta.MaximizeFlags.VERTICAL);
}
this._moveIntoPlace();
}));
this._signalIDs.push(window.connect("notify::maximized-horizontally", ()=> {
this._signalIDs.push(window.connect('notify::maximized-horizontally', () => {
if (!window.maximized_horizontally) {
window.maximize(Meta.MaximizeFlags.HORIZONTAL);
}
......@@ -96,7 +96,7 @@ class ManageWindow {
}
disconnect() {
for(let signalID of this._signalIDs) {
for (let signalID of this._signalIDs) {
this._window.disconnect(signalID);
}
if (this._moveIntoPlaceID) {
......@@ -106,11 +106,11 @@ class ManageWindow {
this._window.unmake_above();
}
this._window = null;
this._wayland_client = null;
this._waylandClient = null;
}
set_wayland_client(client) {
this._wayland_client = client;
setWaylandClient(client) {
this._waylandClient = client;
}
_parseTitle() {
......@@ -124,31 +124,31 @@ class ManageWindow {
this._fixed = false;
let title = this._window.get_title();
if (title != null) {
if ((title.length > 0) && (title[title.length-1] == ' ')) {
if ((title.length > 1) && (title[title.length-2] == ' ')) {
title = "@!HTD";
if ((title.length > 0) && (title[title.length - 1] == ' ')) {
if ((title.length > 1) && (title[title.length - 2] == ' ')) {
title = '@!HTD';
} else {
title = "@!H";
title = '@!H';
}
}
let pos = title.search("@!");
let pos = title.search('@!');
if (pos != -1) {
let pos2 = title.search(";", pos)
let pos2 = title.search(';', pos);
let coords;
if (pos2 != -1) {
coords = title.substring(pos+2, pos2).trim().split(",");
coords = title.substring(pos + 2, pos2).trim().split(',');
} else {
coords = title.substring(pos+2).trim().split(",");
coords = title.substring(pos + 2).trim().split(',');
}
try {
this._x = parseInt(coords[0]);
this._y = parseInt(coords[1]);
} catch(e) {
} catch (e) {
global.log(`Exception ${e.message}.\n${e.stack}`);
}
try {
let extra_chars = title.substring(pos+2).trim().toUpperCase();
for (let char of extra_chars) {
let extraChars = title.substring(pos + 2).trim().toUpperCase();
for (let char of extraChars) {
switch (char) {
case 'B':
this._keepAtBottom = true;
......@@ -169,15 +169,15 @@ class ManageWindow {
break;
}
}
} catch(e) {
} catch (e) {
global.log(`Exception ${e.message}.\n${e.stack}`);
}
}
if (this._wayland_client) {
if (this._waylandClient) {
if (this._hideFromWindowList) {
this._wayland_client.hide_from_window_list(this._window);
this._waylandClient.hide_from_window_list(this._window);
} else {
this._wayland_client.show_in_window_list(this._window);
this._waylandClient.show_in_window_list(this._window);
}
}
if (this._keepAtTop != keepAtTop) {
......@@ -225,18 +225,18 @@ var EmulateX11WindowType = class {
that you want to give "superpowers" is mapped, add it with the
"addWindow" method. That's all.
*/
constructor () {
constructor() {
this._isX11 = !Meta.is_wayland_compositor();
this._windowList = [];
this._enableRefresh = true;
this._wayland_client = null;
this._waylandClient = null;
}
set_wayland_client(client) {
this._wayland_client = client;
for(let window of this._windowList) {
setWaylandClient(client) {
this._waylandClient = client;
for (let window of this._windowList) {
if (window.customJS_ding) {
window.customJS_ding.set_wayland_client(this._wayland_client);
window.customJS_ding.setWaylandClient(this._waylandClient);
}
}
}
......@@ -247,12 +247,12 @@ var EmulateX11WindowType = class {
}
this._idMap = global.window_manager.connect_after('map', (obj, windowActor) => {
let window = windowActor.get_meta_window();
if (this._wayland_client && this._wayland_client.query_window_belongs_to(window)) {
if (this._waylandClient && this._waylandClient.query_window_belongs_to(window)) {
this.addWindow(window);
}
this._refreshWindows(false);
});
this._idDestroy = global.window_manager.connect_after("destroy", (wm, windowActor) => {
this._idDestroy = global.window_manager.connect_after('destroy', (wm, windowActor) => {
// if a window is closed, ensure that the desktop doesn't receive the focus
let window = windowActor.get_meta_window();
if (window && (window.get_window_type() >= Meta.WindowType.DROPDOWN_MENU)) {
......@@ -288,7 +288,7 @@ var EmulateX11WindowType = class {
GLib.source_remove(this._activate_window_ID);
this._activate_window_ID = null;
}
for(let window of this._windowList) {
for (let window of this._windowList) {
this._clearWindow(window);
}
this._windowList = [];
......@@ -323,11 +323,11 @@ var EmulateX11WindowType = class {
if (window.get_meta_window) { // it is a MetaWindowActor
window = window.get_meta_window();
}
window.customJS_ding = new ManageWindow(window, this._wayland_client, () => {
window.customJS_ding = new ManageWindow(window, this._waylandClient, () => {
this._refreshWindows(true);
});
this._windowList.push(window);
window.customJS_ding.unmanagedID = window.connect("unmanaged", (window) => {
window.customJS_ding.unmanagedID = window.connect('unmanaged', window => {
this._clearWindow(window);
this._windowList = this._windowList.filter(item => item !== window);
});
......@@ -372,4 +372,4 @@ var EmulateX11WindowType = class {
});
}
}
}
};
......@@ -16,27 +16,29 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
'use strict';
var ICON_SIZE = { 'tiny': 36, 'small': 48, 'standard': 64, 'large': 96 };
var ICON_WIDTH = { 'tiny': 70, 'small': 90, 'standard': 120, 'large': 130 };
var ICON_HEIGHT = { 'tiny': 80, 'small': 90, 'standard': 106, 'large': 138 };
var ICON_SIZE = {'tiny': 36, 'small': 48, 'standard': 64, 'large': 96};
var ICON_WIDTH = {'tiny': 70, 'small': 90, 'standard': 120, 'large': 130};
var ICON_HEIGHT = {'tiny': 80, 'small': 90, 'standard': 106, 'large': 138};
var START_CORNER = { 'top-left': [false, false],
'top-right': [true, false],
'bottom-left': [false, true],
'bottom-right': [true, true]};
var START_CORNER = {
'top-left': [false, false],
'top-right': [true, false],
'bottom-left': [false, true],
'bottom-right': [true, true],
};
var FileType = {
NONE: null,
USER_DIRECTORY_HOME: 'show-home',
USER_DIRECTORY_TRASH: 'show-trash',
EXTERNAL_DRIVE: 'external-drive',
STACK_TOP: 'stack-top'
}
STACK_TOP: 'stack-top',
};
var StoredCoordinates = {
PRESERVE: 0,
OVERWRITE:1,
ASSIGN:2,
OVERWRITE: 1,
ASSIGN: 2,
};
var Selection = {
......@@ -45,7 +47,7 @@ var Selection = {
RIGHT_BUTTON: 2,
ENTER: 3,
LEAVE: 4,
RELEASE: 5
RELEASE: 5,
};
/* From NautilusFileUndoManagerState */
......@@ -59,14 +61,14 @@ var FileExistOperation = {
ASK: 0,
OVERWRITE: 1,
RENAME: 2,
SKIP: 3
SKIP: 3,
};
var WhatToDoWithExecutable = {
EXECUTE: 0,
EXECUTE_IN_TERMINAL: 1,
DISPLAY: 2,
CANCEL: 3
CANCEL: 3,
};
var SortOrder = {
......@@ -75,14 +77,14 @@ var SortOrder = {
DESCENDINGNAME: 'descendingname',
MODIFIEDTIME: 'modifiedtime',
KIND: 'kind',
SIZE: 'size'
SIZE: 'size',
};
var CompressionType = {
ZIP: 0,
TAR_XZ: 1,
SEVEN_ZIP: 2,
ENCRYPTED_ZIP: 3
ENCRYPTED_ZIP: 3,
};
var DndTargetInfo = {
......@@ -101,6 +103,7 @@ var SCHEMA = 'org.gnome.shell.extensions.ding';
var SCHEMA_MUTTER = 'org.gnome.mutter';
var EXEC_KEY = 'exec';
var NAUTILUS_SCRIPTS_DIR = '.local/share/nautilus/scripts';
var SCHEMA_DARK_SETTINGS = 'org.gnome.desktop.interface';
var S_IXUSR = 0o00100;
var S_IWOTH = 0o00002;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
'use strict';
const { GLib, Gio } = imports.gi;
const {GLib, Gio} = imports.gi;
const DEFAULT_ENUMERATE_BATCH_SIZE = 100;
const DEFAULT_QUERY_ATTRIBUTES = [
......@@ -23,6 +23,13 @@ const DEFAULT_QUERY_ATTRIBUTES = [
Gio.FILE_ATTRIBUTE_STANDARD_TYPE,
].join(',');
/**
*
* @param dir
* @param cancellable
* @param priority
* @param queryAttributes
*/
async function enumerateDir(dir, cancellable = null, priority = GLib.PRIORITY_DEFAULT,
queryAttributes = DEFAULT_QUERY_ATTRIBUTES) {
const childrenEnumerator = await dir.enumerate_children_async_promise(queryAttributes,
......@@ -31,7 +38,6 @@ async function enumerateDir(dir, cancellable = null, priority = GLib.PRIORITY_DE
try {
const children = [];
while (true) {
// The enumerator doesn't support multiple async calls, nor
// we can predict how many they will be, so using Promise.all
// isn't an option here, thus we just need to await each batch
......@@ -39,28 +45,46 @@ async function enumerateDir(dir, cancellable = null, priority = GLib.PRIORITY_DE
const batch = await childrenEnumerator.next_files_async_promise(
DEFAULT_ENUMERATE_BATCH_SIZE, priority, cancellable);
if (!batch.length)
if (!batch.length) {
return children;
}
children.push(...batch);
}
} finally {
if (!childrenEnumerator.is_closed())
if (!childrenEnumerator.is_closed()) {
await childrenEnumerator.close_async_promise(priority, null);
}
}
}
/**
*
* @param dir
* @param deleteParent
* @param cancellable
* @param priority
*/
async function recursivelyDeleteDir(dir, deleteParent, cancellable = null,
priority = GLib.PRIORITY_DEFAULT) {
const children = await enumerateDir(dir, cancellable, priority);
/* eslint-disable no-await-in-loop */
for (let info of children) {
await deleteFile(dir.get_child(info.get_name()), info, cancellable, priority);
}
if (deleteParent)
if (deleteParent) {
await dir.delete_async_promise(priority, cancellable);
}
}
/**
*
* @param file
* @param info
* @param cancellable
* @param priority
*/
async function deleteFile(file, info = null, cancellable = null,
priority = GLib.PRIORITY_DEFAULT) {
if (!info) {
......
This diff is collapsed.
......@@ -3,6 +3,5 @@
"name": "Desktop Icons NG (DING)",
"shell-version": ["3.38", "40", "41", "42", "43"],
"uuid": "ding@rastersoft.com",
"url": "https://gitlab.com/rastersoft/desktop-icons-ng",
"session-modes": ["user", "unlock-dialog"]
}
"url": "https://gitlab.com/rastersoft/desktop-icons-ng"
}