<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<title>Migrating from GConf to GSettings</title>
+<title>Migrating from GnomeVFS to GIO</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GIO Reference Manual">
<link rel="up" href="migrating.html" title="Part III. Migrating to GIO">
-<link rel="prev" href="ch28s03.html" title="Mime monitoring">
-<link rel="next" href="ch29s02.html" title="Conceptual differences">
+<link rel="prev" href="ch28.html" title="Migrating from POSIX to GIO">
+<link rel="next" href="ch29s02.html" title="Operations on multiple files">
<meta name="generator" content="GTK-Doc V1.18 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
-<td><a accesskey="p" href="ch28s03.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
+<td><a accesskey="p" href="ch28.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="migrating.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GIO Reference Manual</th>
</tr></table>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
-<a name="id693097"></a>Migrating from GConf to GSettings</h2></div></div></div>
+<a name="idp46022064"></a>Migrating from GnomeVFS to GIO</h2></div></div></div>
<div class="toc"><dl>
-<dt><span class="section"><a href="ch29.html#id570376">Before you start</a></span></dt>
-<dt><span class="section"><a href="ch29s02.html">Conceptual differences</a></span></dt>
-<dt><span class="section"><a href="ch29s03.html">GConfClient (and GConfBridge) API conversion</a></span></dt>
-<dt><span class="section"><a href="ch29s04.html">Change notification</a></span></dt>
-<dt><span class="section"><a href="ch29s05.html">Change sets</a></span></dt>
-<dt><span class="section"><a href="ch29s06.html">Schema conversion</a></span></dt>
-<dt><span class="section"><a href="ch29s07.html">Data conversion</a></span></dt>
+<dt><span class="section"><a href="ch29.html#idp13054160">Trash handling</a></span></dt>
+<dt><span class="section"><a href="ch29s02.html">Operations on multiple files</a></span></dt>
+<dt><span class="section"><a href="ch29s03.html">Mime monitoring</a></span></dt>
</dl></div>
-<div class="section">
+<div class="table">
+<a name="gnome-vfs-vs-gio"></a><p class="title"><b>Table 6. Comparison of GnomeVFS and GIO concepts</b></p>
+<div class="table-contents"><table summary="Comparison of GnomeVFS and GIO concepts" border="1">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>GnomeVFS</th>
+<th>GIO</th>
+</tr></thead>
+<tbody>
+<tr>
+<td>GnomeVFSURI</td>
+<td>GFile</td>
+</tr>
+<tr>
+<td>GnomeVFSFileInfo</td>
+<td>GFileInfo</td>
+</tr>
+<tr>
+<td>GnomeVFSResult</td>
+<td>GError, with G_IO_ERROR values</td>
+</tr>
+<tr>
+<td>GnomeVFSHandle & GnomeVFSAsyncHandle</td>
+<td>GInputStream or GOutputStream</td>
+</tr>
+<tr>
+<td>GnomeVFSDirectoryHandle</td>
+<td>GFileEnumerator</td>
+</tr>
+<tr>
+<td>mime type</td>
+<td>content type</td>
+</tr>
+<tr>
+<td>GnomeVFSMonitor</td>
+<td>GFileMonitor</td>
+</tr>
+<tr>
+<td>GnomeVFSVolumeMonitor</td>
+<td>GVolumeMonitor</td>
+</tr>
+<tr>
+<td>GnomeVFSVolume</td>
+<td>GMount</td>
+</tr>
+<tr>
+<td>GnomeVFSDrive</td>
+<td>GVolume</td>
+</tr>
+<tr>
+<td>-</td>
+<td>GDrive</td>
+</tr>
+<tr>
+<td>GnomeVFSContext</td>
+<td>GCancellable</td>
+</tr>
+<tr>
+<td>gnome_vfs_async_cancel</td>
+<td>g_cancellable_cancel</td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<br class="table-break"><div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="id570376"></a>Before you start</h2></div></div></div>
+<a name="idp13054160"></a>Trash handling</h2></div></div></div>
+<p>
+ The handling of trashed files has been changed in GIO, compared
+ to gnome-vfs. gnome-vfs has a home-grown trash implementation that
+ predates the freedesktop.org <a class="ulink" href="http://www.freedesktop.org/wiki/Specifications/trash-spec" target="_top">Desktop Trash Can</a> specification
+ that is implemented in GIO. The location for storing trashed files
+ has changed from <code class="filename">$HOME/.Trash</code> to
+ <code class="filename">$HOME/.local/share/Trash</code> (or more correctly
+ <code class="filename">$XDG_DATA_HOME/Trash</code>), which means that
+ there is a need for migrating files that have been trashed by
+ gnome-vfs to the new location.
+ </p>
+<p>
+ In gnome-vfs, the <code class="filename">trash://</code> scheme offering a
+ merged view of all trash directories was implemented in nautilus,
+ and trash-handling applications had to find and monitor all trash
+ directories themselves. With GIO, the <code class="filename">trash://</code>
+ implementation has been moved to gvfs and applications can simply
+ monitor that location:
+ </p>
+<div class="informalexample"><pre class="programlisting">
+static void
+file_changed (GFileMonitor *file_monitor,
+ GFile *child,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ gpointer user_data)
+{
+ switch (event_type)
+ {
+ case G_FILE_MONITOR_EVENT_DELETED:
+ g_print ("'%s' removed from trash\n", g_file_get_basename (child));
+ break;
+ case G_FILE_MONITOR_EVENT_CREATED:
+ g_print ("'%s' added to trash\n", g_file_get_basename (child));
+ break;
+ default: ;
+ }
+}
+
+static void
+start_monitoring_trash (void)
+{
+ GFile *file;
+ GFileMonitor *monitor;
+
+ file = g_file_new_for_uri ("trash://");
+ monitor = g_file_monitor_directory (file, 0, NULL, NULL);
+ g_object_unref (file);
+
+ g_signal_connect (monitor, "changed", G_CALLBACK (file_changed), NULL);
+
+ /* ... */
+
+}
+</pre></div>
<p>
- Converting individual applications and their settings from GConf to
- GSettings can be done at will. But desktop-wide settings like font or
- theme settings often have consumers in multiple modules. Therefore,
- some consideration has to go into making sure that all users of a setting
- are converted to GSettings at the same time or that the program
- responsible for configuring that setting continues to update the value in
- both places.
+ GIO exposes some useful metadata about trashed files. There are
+ trash::orig-path and trash::deletion-date attributes. The
+ standard::icon attribute of the <code class="filename">trash://</code>
+ itself provides a suitable icon for displaying the trash can on
+ the desktop. If you are using this icon, make sure to monitor
+ this attribute for changes, since the icon may be updated to
+ reflect that state of the trash can.
</p>
<p>
- It is always a good idea to have a look at how others have handled
- similar problems before. An examplaric conversion can be found e.g.
- in the <a class="ulink" href="http://git.gnome.org/browse/gnome-utils/log/?h=gsettings-tutorial" target="_top">gsettings-tutorial</a> branch of gnome-utils.
+ Moving a file to the trash is much simpler with GIO. Instead of
+ using <code class="function">gnome_vfs_find_directory()</code> with <code class="literal">GNOME_VFS_DIRECTORY_KIND_TRASH</code>
+ to find out where to move the trashed file, just use the <a class="link" href="GFile.html#g-file-trash" title="g_file_trash ()"><code class="function">g_file_trash()</code></a>
+ function.
</p>
</div>
</div>