2 <title>Migrating from GnomeVFS to GIO</title>
4 <table id="gnome-vfs-vs-gio">
5 <title>Comparison of GnomeVFS and GIO concepts</title>
8 <row><entry>GnomeVFS</entry><entry>GIO</entry></row>
11 <row><entry>GnomeVFSURI</entry><entry>GFile</entry></row>
12 <row><entry>GnomeVFSFileInfo</entry><entry>GFileInfo</entry></row>
13 <row><entry>GnomeVFSResult</entry><entry>GError, with G_IO_ERROR values</entry></row>
14 <row><entry>GnomeVFSHandle & GnomeVFSAsyncHandle</entry><entry>GInputStream or GOutputStream</entry></row>
15 <row><entry>GnomeVFSDirectoryHandle</entry><entry>GFileEnumerator</entry></row>
16 <row><entry>mime type</entry><entry>content type</entry></row>
17 <row><entry>GnomeVFSMonitor</entry><entry>GFileMonitor</entry></row>
18 <row><entry>GnomeVFSVolumeMonitor</entry><entry>GVolumeMonitor</entry></row>
19 <row><entry>GnomeVFSVolume</entry><entry>GMount</entry></row>
20 <row><entry>GnomeVFSDrive</entry><entry>GVolume</entry></row>
21 <row><entry>-</entry><entry>GDrive</entry></row>
22 <row><entry>GnomeVFSContext</entry><entry>GCancellable</entry></row>
23 <row><entry>gnome_vfs_async_cancel</entry><entry>g_cancellable_cancel</entry></row>
29 <title>Trash handling</title>
32 The handling of trashed files has been changed in GIO, compared
33 to gnome-vfs. gnome-vfs has a home-grown trash implementation that
34 predates the freedesktop.org <ulink url="http://www.freedesktop.org/wiki/Specifications/trash-spec">Desktop Trash Can</ulink> specification
35 that is implemented in GIO. The location for storing trashed files
36 has changed from <filename>$HOME/.Trash</filename> to
37 <filename>$HOME/.local/share/Trash</filename> (or more correctly
38 <filename>$XDG_DATA_HOME/Trash</filename>), which means that
39 there is a need for migrating files that have been trashed by
40 gnome-vfs to the new location.
43 In gnome-vfs, the <filename>trash://</filename> scheme offering a
44 merged view of all trash directories was implemented in nautilus,
45 and trash-handling applications had to find and monitor all trash
46 directories themselves. With GIO, the <filename>trash://</filename>
47 implementation has been moved to gvfs and applications can simply
48 monitor that location:
50 <informalexample><programlisting>
52 file_changed (GFileMonitor *file_monitor,
55 GFileMonitorEvent event_type,
60 case G_FILE_MONITOR_EVENT_DELETED:
61 g_print ("'%s' removed from trash\n", g_file_get_basename (child));
63 case G_FILE_MONITOR_EVENT_CREATED:
64 g_print ("'%s' added to trash\n", g_file_get_basename (child));
71 start_monitoring_trash (void)
74 GFileMonitor *monitor;
76 file = g_file_new_for_uri ("trash://");
77 monitor = g_file_monitor_directory (file, 0, NULL, NULL);
78 g_object_unref (file);
80 g_signal_connect (monitor, "changed", G_CALLBACK (file_changed), NULL);
85 </programlisting></informalexample>
87 GIO exposes some useful metadata about trashed files. There are
88 trash::orig-path and trash::deletion-date attributes. The
89 standard::icon attribute of the <filename>trash://</filename>
90 itself provides a suitable icon for displaying the trash can on
91 the desktop. If you are using this icon, make sure to monitor
92 this attribute for changes, since the icon may be updated to
93 reflect that state of the trash can.
96 Moving a file to the trash is much simpler with GIO. Instead of
97 using gnome_vfs_find_directory() with %GNOME_VFS_DIRECTORY_KIND_TRASH
98 to find out where to move the trashed file, just use the g_file_trash()
104 <title>Operations on multiple files</title>
107 gnome-vfs has the dreaded gnome_vfs_xfer_uri_list() function which
108 has tons of options and offers the equivalent of cp, mv, ln, mkdir
109 and rm at the same time.
112 GIO offers a much simpler I/O scheduler functionality instead, that
113 lets you schedule a function to be called in a separate thread, or
114 if threads are not available, as an idle in the mainloop.
115 See g_io_scheduler_push_job().
121 <title>Mime monitoring</title>
124 gnome-vfs offered a way to monitor the association between mime types
125 and default handlers for changes, with the #GnomeVFSMIMEMonitor object.
126 GIO does not offer a replacement for this functionality at this time,
127 since we have not found a compelling use case where
128 #GnomeVFSMIMEMonitor was used. If you think you have such a use
129 case, please report it at
130 <ulink url="http://bugzilla.gnome.org">bugzilla.gnome.org</ulink>.