linuxmint/cjs

GLib.get_user_special_dir always returns ~/Desktop

Closed this issue · 2 comments

According to GLib documentation, GLib.get_user_special_dir is to be used to get Documents, Video or Picture home folder. However it seems that it always returns /home/<Username>/Desktop

Step to reproduce :

  • Open cinnamon looking glass
  • Type GLib.get_user_special_dir(GLib.UserDirectory.G_USER_DIRECTORY_DOCUMENTS)
  • Expected output : ~/Documents
  • Actual output : ~/Desktop
    (also test inside applets, same result)

Image proof https://i.imgur.com/b9xgcqb.png (nb: bureau is french for Desktop)

The enum value you're using is invalid:

The correct one works for me:
image
image

GObject introspection 'interpretation' can be a bit confusing at times, but you'll never have G_ as part of the value (think of it as being handled by the GLib. portion).

In the case of GUserDirectory, personally I think its wrong - it should be GLib.UserDirectory.DESKTOP. When in doubt, I suppose work backwards from the right. (At least that's how I do it, or I leave a python interpreter open - it'll generally be identical).

The fact it's even accepting the full enum name is odd, but I have no explanation. It's not that surprising - introspection can exhibit weird behavior sometimes.

https://gjs-docs.gnome.org/glib20~2.66.1/glib.userdirectory

Right sorry for the mistake, and thanks for the tip !
Apparently any invalid value will default to desktop (here, "For compatibility with existing practise, GLib.UserDirectory falls back to $HOME/Desktop when XDG special user directories have not been set up.")