Skip to content

Gtk4-DING: Completed port to Gtk4

Complete working port of Desktop Icons NG to gtk4.

Works!

Requires: Gtk4, Gnome 40, 41, or 42.

Other than using the Gtk4 toolkit, it in addition it has several new features, fixes and enhancemnts.

This branch has now diverged significantly from master and is becoming progressively difficult to rebase. Please see 'main' branch here for the latest version. The main branch has other new features, you can set the preferred desktop on double monitor setups for new icons.

NEW FEATURES

  • Can Make Links on the Desktop on Drag and Drop from Nautilus. Pressing the Alt button on drag modifies the drop to ask the user to Copy, Move or Make Links at the destination.

  • Links are checked just before launching them, in case they got broken in the background with no recent desktop refresh. If they are broken the icon is updated to the broken link icon, and the error dialog is popped up correctly. The reverse is also true, if a broken link resolves correctly as the target re-appeared, the link is opened and the icon updated to the correct icon.

  • Copied files retain the dropped position.

  • Merged all changes from branch more-asyncness, by Marco Trevisan, that was submitted upstream, to this Gtk4 branch to use async functions for everything.

  • Prevent Flashing Icons - Use async await promises to update the entire fileList icon widgets prior to placing on desktop. Do the same for stack Top Marker Folders.

  • Use Promises to detect when icons have been placed on the desktop, so that in draw desktop, it is clear that all the icons are placed on the desktop and desktop drawing is complete. This allows queuing code that can only be executed when icon placing is complete and the desktop draw is done.

  • Optimize refreshMenus after Icons are placed on Grid to point to the correct fileItem with the above promise. Also remake the menu as the old menu does not scroll and malfunctions. Same for do rename popup. No longer uses callback from fileItem to call these functions. Directly use Promises made above to update the menus and rename popups after icons are placed on grid. Stack top marker menus are also repositioned.

  • When Dock in in intelligent hide or auto hide mode, all menus and rename popups can be popped up under the dock, the dock does not detect them as it ignores DING completely. Updated the code to detect dock or any other object is likely in auto hide mode by detecting usableArea margins are set. Then popups the menu in the correct position so that they do not go under the dock or other auto hide object on the desktop.

  • Add eslintrc.json file and lint folder containing eslint rules for GJS/Gnome files eslintrc-gjs.yml and eslintrc-shell.yml for linting.

  • The entire project and all .js files are now scanned and corrected with eslint. All formatting is fixed and errors from eslint resolved, should follow GJS/Gnome guidelines.

  • Other than the UUID of the extension, changed the application ID, the Dbus object paths and GSetting schemas for the application. This is to differentiate it from the gtk-3 desktop icons NG extension. Both can be installed simultaneously on the same system. However both should not be run at the same time, only one extension should be active. This lets users test the extension, report problems that need fixing, and revert to the original gtk3 DING if does not work for them.

  • For Gnome 42, allow use of 'unlock-dialog' in session mode for the extension, so that it is not relaunched every time.

  • Can set preferred desktop for new icons on double monitor displays.

EXPERIMENTAL FEATURES

There is optional integration with Gsconnect extension available. If Gsconnect extension is installed, right click menus allow sending files directly from the desktop using Gsconnect. To use this feature, look for the "Gtk4-gsconnect-integration" branch in this repository, and install from that branch. Feedback, fixes appreciated, this branch has not been well tested at all.

FIXES

  • Fix Gtk4 Icon Rendering Code to at least render generic correct icons at the correct size.

  • Fix Drag and Drop. Need to add drag and drop controllers to DesktipIconItem.js.

  • Fix Rectangle Selection in Gtk4. Fixed by using Gtk.Overlay.

  • Fix clipboard. Fixed. Use new Gdk4 clipboard object, remove old dbus code and St. library clipboard code from extension.js

  • Fix DbusUtils Nautilus Wayland window handle. Can successfully get Wayland window handle via asynchronous call, using a promise with Gtk4. This is passed to Nautilus. Reset on callback from the Dbus call.

  • Cosmetic Fixes to Boxes as Padding and spacing is gone in Gtk4 and need to use other methods.

  • Composite Emblem Icons using Gtk4

  • Set custom icons using Gtk4 methods and calls.

  • Make Gtk4 Icons skinny, not tiles so that there is space around them to initiate selection rectangles.

  • Use Gtk Application keyboard accelerators for functions, Shortcuts are shown in Gio.Menus.

  • All menus are Gio.Menus.

  • Thumbnail.js GnomeDesktop.DesktopThumbnailFactory is Gtk3, will not work with current code. Till that is ported, thumbnail.js is launched as a separate Gtk Application, ding and thumbnail.js exchange thumbnail information over dbus. This is the last thing to complete this port. This is done for Gnome 40, Gnome 41.

  • GnomeDesktop4 is now available in some distros on Gnome 41. Others have it in Gnome 42 (eg Ubuntu Jammy). This branch now checks to see which version is available. If GnomeDesktop4 is available, it uses it directly to render thumbnails. If not available, it launches a helper app that uses Gtk3 and GnomeDesktop3, communicates with it over Dbus to render thumbnails.

  • Fix - the desktop is not highlighted with a green rectangle on Drag and Drop.

  • Fix - Rename popups and fileItem right click menus work correctly even if the desktop is refreshed while they are open. Rename popups and the right click menus are re positioned to point to the correct fileItem and both menus always operate on the correct file/fileItem. This also applies to stacktopItems, if they move the right click menu updates and moves with them.

  • Fix - Selection is kept even if the desktop is refreshed.

  • Fix - Keyboard accelerators work even after Gtk.PopoverMenu sub-menus are shown and dismissed. This seems to be a bug in Gtk4, accelerators don't work after a submenu is shown and dismissed, the fix is a little bit of a kludge, but gets the job done till this is fixed upstream.

  • Fix - Window Transparency under X11.

  • Gtk4 does not allow window move even on X11. X11 windows are now managed by the extension in the same way as Wayland windows.

  • Leverages Gtk4 calls to translate coordinates. Fix Rubber band initiation by correcting the grid Global Rectangle, local to global and global to local coordinates. Leverages Gtk calls for _coordinatesBelongToThisGrid() and new _coordinatesBelongToThisWindow(); Fixes initiation of this.globalRectangle using the above calls. Fixes iconContainer and labelContainer global rectangles with the above calls as well so that they work with fractional scaling. Thanks to Sergio Costas for Pointing out that eventbox gives negative coordinates in margins. Fix for correcting getDistance(x, y) from Sergio Costas !348 (merged). Removed scale from desktopgrid.js. Removed zoom from desktopIconItem.js

  • Refactoring to avoid boolean parameters, make code more readable. Added eslint.json and GJS/Gnome eslintrc-gjs.yml and eslintrc-shell.yml for linting.

KNOWN ISSUES

  • On X11, in latest Ubuntu and Fedora, Gtk.GestureClick.get_current_event_state() button click returns wrong state, crashing the Program. Works perfectly on Wayland on all distributions tried, works even on X11 on Manjaro and by extension on likely Arch Linux as well. Problem in GJS, reported upstream here. Reported upstream here in Gnome Discourse and here on Ubuntu Launchpad.

  • Gdk.Display.get_default().get_app_launch_context() when used in launch() to launch a desktop file freezes GJS ONLY on Ubuntu 22.04. Pops up a dialog asking to Force Quit or Wait, no debug info from DING. Works perfectly in Manjaro. Likely problem in GJS on Ubuntu. Current workaround is not to use the context, set to null, till fixed upstream. But is reported here on Ubuntu Launchpad. This is now fixed upstream.

  • Dragged Icon sets the wrong offset for the cursor and defaults to 0,0 with Gtk.DragSource.set_icon in Wayland. This works perfectly in X11 and the correct offset is set. Again likely problem in GJS/Gtk4, however drag and drop otherwise works perfectly till fixed upstream.

  • Application keyboard shortcut accelerators stop working after a submenu of a menu is closed, work perfectly if only the menu is closed. Bug reported here in Gnome Discourse, no clear solution. Current workaround is to destroy the menu once closed. Keyboard accelerators then work again normally.

  • Nesting submenus do not work, crash GJS, currently use sliding submenus with Gio.Menu. Bug reported here in Gnome Discourse, and fix was committed upstream. Wait till widely available in distributions prior to using option for nesting submenus, currently use sliding submenus.

  • Gtk.DropTargetAsync(), in X11, does not set Gtk.StateFlags.NORMAL on the widget once the drag is finished. Current workaround is to set it manually with Widget.set_state_flags(Gtk.StateFlags.NORMAL, true) explicitly on drag end. It works perfectly on Wayland without a workaround.

If this extension does not work for you, just deactivate it in extensions manager, and you can use the classic DING Gtk3 extension.

Edited by Sundeep Mediratta

Merge request reports

Loading