[Thunar-dev] Patching xfdesktop to add Thunar Trash icon

Benedikt Meurer benedikt.meurer at unix-ag.uni-siegen.de
Fri Aug 4 22:40:17 CEST 2006


Gregoire Gentil wrote:
> Hello,
> 
> I'm trying to patch xfdesktop to add a Trash icon on the desktop. This
> trash icon is supposed to be linked to the new Thunar trash feature.
> 
> As shown in the attached file, I have written a function called
> xfdesktop_file_icon_manager_load_Trash that is doing the following:
> 
> path = thunar_vfs_path_get_for_trash();
> info = thunar_vfs_info_new_for_path(path, NULL);
> info->custom_icon = "emblem-trash";
> icon = xfdesktop_file_icon_new(info, fmanager->priv->gscreen);
> xfdesktop_icon_view_add_item(fmanager->priv->icon_view,
> XFDESKTOP_ICON(icon));

You should not touch the custom_icon in your code, because that is like
to crash when the info is released.

> Unfortunately, the resulting icon launches the root (/) instead of the
> trash (trash:///). I have developped the same feature for the Home so I
> know that the flow is working fine. Any idea what is wrong with my
> implementation or what should I patch?

I'd suggest to use the org.xfce.Trash D-Bus interface, which is also
used by the trash panel applet to communicate with the trash. You can
check the code in plugins/thunar-tpa/, it's really straight forward and
all the complicated stuff is handled in Thunar, so you don't need to
duplicate all the necessary code in xfdesktop.

> PS: Note that thunar_vfs_path_dup_uri(thunar_vfs_path_get_for_trash())
> returns trash:/// and
> thunar_vfs_path_get_name(thunar_vfs_path_get_for_trash()) returns /
> which perhaps explains the problem.

Sure, because the name of every root node is "/".

Benedikt



More information about the Xfce4-dev mailing list