GVFS AND SHORTCUTS IN THUNAR The "thunar-master.zip" was downloaded 2020-02-15 23:34:03 UTC from "https://github.com/xfce-mirror/thunar": STEP 1: How and where the privileges are checked in Thunar source: cd ./thunar-master && grep -r --include='*.c' -n '.' -e 'harm your system' Decide whether to show a warning about running as root using "geteuid": ./thunar/thunar-window.c:878: label = gtk_label_new (_("Warning, you are using the root account, you may harm your system.")); STEP 2: Where the privileges are checked using the "geteuid" function in Thunar source: grep -r --include='*.c' -n '.' -e 'geteuid' Determine the effective user ID of the Thunar process and store it in "effective_user_id": ./thunar/thunar-file.c:355: effective_user_id = geteuid (); Determine which groups to show in permissions chooser: ./thunar/thunar-permissions-chooser.c:934: if (G_UNLIKELY (geteuid () == 0)) ./thunar/thunar-permissions-chooser.c:947: user = thunar_user_manager_get_user_by_id (user_manager, geteuid ()); Determine the effective user ID of the Thunar process and store it in "thunar_user_effective_uid": ./thunar/thunar-user.c:222: thunar_user_effective_uid = geteuid (); Decide whether to show a warning about running as root using "geteuid": ./thunar/thunar-window.c:868: if (G_UNLIKELY (geteuid () == 0)) STEP 3: Where the privileges are checked using the "effective_user_id" or "thunar_user_effective_uid" variables in Thunar source: grep -r --include='*.c' -n '.' -e 'effective_user_id\|thunar_user_effective_uid' Use "effective_user_id" to allow/deny various file actions: ./thunar/thunar-file.c:130:static guint32 effective_user_id; ./thunar/thunar-file.c:355: effective_user_id = geteuid (); ./thunar/thunar-file.c:621: if (G_UNLIKELY (effective_user_id == 0)) ./thunar/thunar-file.c:641: user = thunar_user_manager_get_user_by_id (user_manager, effective_user_id); ./thunar/thunar-file.c:2120: G_FILE_ATTRIBUTE_UNIX_UID) != effective_user_id)) ./thunar/thunar-file.c:3307: return (effective_user_id == 0 && !thunar_file_is_trashed (file)); ./thunar/thunar-file.c:3311: return ((effective_user_id == 0 ./thunar/thunar-file.c:3312: || effective_user_id == g_file_info_get_attribute_uint32 (file->info, ./thunar/thunar-file.c:3416: else if (G_UNLIKELY (uid == effective_user_id && !thunar_file_is_writable (file))) Use "thunar_user_effective_uid" to check if the given user is the owner of the Thunar prosess: ./thunar/thunar-user.c:205:static guint32 thunar_user_effective_uid; ./thunar/thunar-user.c:222: thunar_user_effective_uid = geteuid (); ./thunar/thunar-user.c:464: return (user->id == thunar_user_effective_uid); STEP 4: Where gvfs is used in Thunar source: grep -r --include='*.c' -n '.' -e 'vfs' Check if the given gvfs scheme is supported using "g_vfs_get_default" and "g_vfs_get_supported_uri_schemes": ./thunar/thunar-gio-extensions.c:355:thunar_g_vfs_is_uri_scheme_supported (const gchar *scheme) ./thunar/thunar-gio-extensions.c:360: GVfs *gvfs; ./thunar/thunar-gio-extensions.c:364: gvfs = g_vfs_get_default (); ./thunar/thunar-gio-extensions.c:365: supported_schemes = g_vfs_get_supported_uri_schemes (gvfs); Decide whether to show the preference "Show action to permanently delete files and folders" in preferences dialog: ./thunar/thunar-preferences-dialog.c:668: if (thunar_g_vfs_is_uri_scheme_supported ("trash")) Decide whether to show a warning in preferences dialog that gvfs is not available: ./thunar/thunar-preferences-dialog.c:775: /* check the most important gvfs-backends, and inform if they are missing */ ./thunar/thunar-preferences-dialog.c:776: if (!thunar_g_vfs_is_uri_scheme_supported ("trash") || ./thunar/thunar-preferences-dialog.c:777: !thunar_g_vfs_is_uri_scheme_supported ("computer") || /* support for removable media */ ./thunar/thunar-preferences-dialog.c:778: !thunar_g_vfs_is_uri_scheme_supported ("sftp") ) ./thunar/thunar-preferences-dialog.c:792: gtk_label_set_markup (GTK_LABEL (label), _("It looks like gvfs is not available.\n" Decide a default value for the preference "Show action to permanently delete files and folders": ./thunar/thunar-preferences.c:659: !thunar_g_vfs_is_uri_scheme_supported ("trash"), Decide whether to append trash shortcut to PLACES in shortcuts model: ./thunar/thunar-shortcuts-model.c:1037: if (thunar_g_vfs_is_uri_scheme_supported ("trash")) Decide whether to perform "Move to Trash" or "Delete" action when removing selected files in standard view: ./thunar/thunar-standard-view.c:1911: if (thunar_g_vfs_is_uri_scheme_supported ("trash")) ./thunar/thunar-standard-view.c:4555: hide_trash_action = writable && (trashed || !trashable || !thunar_g_vfs_is_uri_scheme_supported ("trash")); Decide whether to append trash and network paths to system paths in tree model: ./thunar/thunar-tree-model.c:328: if (thunar_g_vfs_is_uri_scheme_supported ("trash")) ./thunar/thunar-tree-model.c:332: if (thunar_g_vfs_is_uri_scheme_supported ("network")) Decide whether to perform "Move to Trash" or "Delete" action when removing selected files in tree view: ./thunar/thunar-tree-view.c:1247: /* check if we should permanently delete the files (user holds shift or no gvfs available) */ ./thunar/thunar-tree-view.c:1249: (gtk_get_current_event_state (&state) && !thunar_g_vfs_is_uri_scheme_supported ("trash"))) Decide whether to show "Move to Trash" or "Delete" action in context menu: ./thunar/thunar-tree-view.c:1479: if (thunar_g_vfs_is_uri_scheme_supported ("trash")) ./thunar/thunar-tree-view.c:1497: if (!thunar_g_vfs_is_uri_scheme_supported ("trash") Decide whether to enable "Open" trash and network actions (Although "Browse Network" with its "Open*" actions is still shown in root Thunar without gvfs - is that wrong?): ./thunar/thunar-window.c:2334: if (thunar_g_vfs_is_uri_scheme_supported ("trash")) ./thunar/thunar-window.c:2360: gtk_action_set_visible (action, thunar_g_vfs_is_uri_scheme_supported ("network")); STEP 5: Where DEVICES shortcuts are handled in Thunar source: grep -r --include='*.c' -n '.' -e 'DEVICES' Use the list of hidden devices: ./thunar/thunar-device-monitor.c:50: PROP_HIDDEN_DEVICES ./thunar/thunar-device-monitor.c:145: PROP_HIDDEN_DEVICES, ./thunar/thunar-device-monitor.c:272: case PROP_HIDDEN_DEVICES: ./thunar/thunar-device-monitor.c:294: case PROP_HIDDEN_DEVICES: The list of hidden devices: ./thunar/thunar-preferences.c:54: PROP_HIDDEN_DEVICES, ./thunar/thunar-preferences.c:199: preferences_props[PROP_HIDDEN_DEVICES] = Determine tooltip for the shortcut: ./thunar/thunar-shortcuts-model.c:609: if ((shortcut->group & THUNAR_SHORTCUT_GROUP_DEVICES) != 0) Add the shortcuts group name "DEVICES": ./thunar/thunar-shortcuts-model.c:929: shortcut->group = THUNAR_SHORTCUT_GROUP_DEVICES_HEADER; ./thunar/thunar-shortcuts-model.c:930: shortcut->name = g_strdup (_("DEVICES")); Add the "File System" shortcut: ./thunar/thunar-shortcuts-model.c:935: shortcut->group = THUNAR_SHORTCUT_GROUP_DEVICES_FILESYSTEM; Set the specific kind of group for each kind of the device shortcut: ./thunar/thunar-shortcuts-model.c:1554: shortcut->group = THUNAR_SHORTCUT_GROUP_DEVICES_VOLUMES; ./thunar/thunar-shortcuts-model.c:1558: shortcut->group = THUNAR_SHORTCUT_GROUP_DEVICES_MOUNTS; Set the mask for the shortcuts group: ./thunar/thunar-shortcuts-view.c:1019: if ((group & THUNAR_SHORTCUT_GROUP_DEVICES) != 0) ./thunar/thunar-shortcuts-view.c:1020: mask = THUNAR_SHORTCUT_GROUP_DEVICES; Append the appropriate context menu items according to the shortcut's group (i.e. type): ./thunar/thunar-shortcuts-view.c:1142: case THUNAR_SHORTCUT_GROUP_DEVICES_VOLUMES: ./thunar/thunar-shortcuts-view.c:1209: case THUNAR_SHORTCUT_GROUP_DEVICES_MOUNTS: STEP 6: Where devices are loaded and hidden in Thunar source: (Found using a text editor search only in relevant *.c files manually filtered from the output of: grep -r --include='*.c' -n '.' -e 'hidden'): Get a list of all devices available using "thunar_device_monitor_get_devices": ./thunar/thunar-shortcuts-model.c:945 Load all volumes and mounts from gio volume monitor in "thunar_device_monitor_init": ./thunar/thunar-device-monitor.c:208+217 Determine the device "hidden" property value using "thunar_device_monitor_id_is_hidden" based on whether the device ID is in "hidden_devices" which is a loaded Thunar "hidden-devices" preference: ./thunar/thunar-device-monitor.c:313 Determine if the device is visible using "thunar_device_monitor_volume_is_visible" based on "can_eject || can_unmount || is_removable || can_mount". The "thunar_device_monitor_volume_is_visible" is used in "thunar_device_monitor_volume_changed". New devices are added to "hidden_volumes" and their visibility is set by manually calling "thunar_device_monitor_volume_changed": ./thunar/thunar-device-monitor.c:356 Hide device according to its "hidden" property in "thunar_device_monitor_set_hidden": ./thunar/thunar-device-monitor.c:791 Get the device "hidden" property value using "thunar_device_get_hidden" (related functions are "thunar_device_get_property" and "thunar_device_set_property"): ./thunar/thunar-device.c:397