~ubuntu-branches/ubuntu/precise/glib2.0/precise-updates

« back to all changes in this revision

Viewing changes to docs/reference/gio/html/ch27.html

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2012-01-17 11:16:09 UTC
  • mfrom: (1.59.36)
  • Revision ID: package-import@ubuntu.com-20120117111609-l6hqg8snni7gh1a4
Tags: 2.31.10-0ubuntu1
* New upstream version:
  GResource:
  - A new facility to allow linking data files into binaries and make 
    them available as resources
  - Resources are compiled using glib-compile-resources
  - GIO supports resource:/// uris to access resources
* debian/libglib2.0-0.install.in: install glib-compile-resources there
* debian/libglib2.0-0.symbols: new version update

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
<html>
3
3
<head>
4
4
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
 
<title>Migrating from GnomeVFS to GIO</title>
 
5
<title>Migrating from POSIX to GIO</title>
6
6
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7
7
<link rel="home" href="index.html" title="GIO Reference Manual">
8
 
<link rel="up" href="migrating.html" title="Part III. Migrating to GIO">
9
 
<link rel="prev" href="ch26.html" title="Migrating from POSIX to GIO">
10
 
<link rel="next" href="ch27s02.html" title="Operations on multiple files">
 
8
<link rel="up" href="migrating.html" title="Part I. Migrating to GIO">
 
9
<link rel="prev" href="migrating.html" title="Part I. Migrating to GIO">
 
10
<link rel="next" href="ch28.html" title="Migrating from GnomeVFS to GIO">
11
11
<meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12
12
<link rel="stylesheet" href="style.css" type="text/css">
13
13
</head>
14
14
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15
15
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
16
 
<td><a accesskey="p" href="ch26.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
 
16
<td><a accesskey="p" href="migrating.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
17
17
<td><a accesskey="u" href="migrating.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
18
18
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
19
19
<th width="100%" align="center">GIO Reference Manual</th>
20
 
<td><a accesskey="n" href="ch27s02.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
 
20
<td><a accesskey="n" href="ch28.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
21
21
</tr></table>
22
22
<div class="chapter">
23
23
<div class="titlepage"><div><div><h2 class="title">
24
 
<a name="id735094"></a>Migrating from GnomeVFS to GIO</h2></div></div></div>
25
 
<div class="toc"><dl>
26
 
<dt><span class="section"><a href="ch27.html#id770962">Trash handling</a></span></dt>
27
 
<dt><span class="section"><a href="ch27s02.html">Operations on multiple files</a></span></dt>
28
 
<dt><span class="section"><a href="ch27s03.html">Mime monitoring</a></span></dt>
29
 
</dl></div>
 
24
<a name="id426477"></a>Migrating from POSIX to GIO</h2></div></div></div>
30
25
<div class="table">
31
 
<a name="gnome-vfs-vs-gio"></a><p class="title"><b>Table 6. Comparison of GnomeVFS and GIO concepts</b></p>
32
 
<div class="table-contents"><table summary="Comparison of GnomeVFS and GIO concepts" border="1">
 
26
<a name="posix-vs-gio"></a><p class="title"><b>Table 5. Comparison of POSIX and GIO concepts</b></p>
 
27
<div class="table-contents"><table summary="Comparison of POSIX and GIO concepts" border="1">
33
28
<colgroup>
34
29
<col>
35
30
<col>
36
31
</colgroup>
37
32
<thead><tr>
38
 
<th>GnomeVFS</th>
 
33
<th>POSIX</th>
39
34
<th>GIO</th>
40
35
</tr></thead>
41
36
<tbody>
42
37
<tr>
43
 
<td>GnomeVFSURI</td>
44
 
<td>GFile</td>
45
 
</tr>
46
 
<tr>
47
 
<td>GnomeVFSFileInfo</td>
48
 
<td>GFileInfo</td>
49
 
</tr>
50
 
<tr>
51
 
<td>GnomeVFSResult</td>
52
 
<td>GError, with G_IO_ERROR values</td>
53
 
</tr>
54
 
<tr>
55
 
<td>GnomeVFSHandle &amp; GnomeVFSAsyncHandle</td>
56
 
<td>GInputStream or GOutputStream</td>
57
 
</tr>
58
 
<tr>
59
 
<td>GnomeVFSDirectoryHandle</td>
60
 
<td>GFileEnumerator</td>
61
 
</tr>
62
 
<tr>
63
 
<td>mime type</td>
64
 
<td>content type</td>
65
 
</tr>
66
 
<tr>
67
 
<td>GnomeVFSMonitor</td>
68
 
<td>GFileMonitor</td>
69
 
</tr>
70
 
<tr>
71
 
<td>GnomeVFSVolumeMonitor</td>
72
 
<td>GVolumeMonitor</td>
73
 
</tr>
74
 
<tr>
75
 
<td>GnomeVFSVolume</td>
76
 
<td>GMount</td>
77
 
</tr>
78
 
<tr>
79
 
<td>GnomeVFSDrive</td>
80
 
<td>GVolume</td>
81
 
</tr>
82
 
<tr>
83
 
<td>-</td>
84
 
<td>GDrive</td>
85
 
</tr>
86
 
<tr>
87
 
<td>GnomeVFSContext</td>
88
 
<td>GCancellable</td>
89
 
</tr>
90
 
<tr>
91
 
<td>gnome_vfs_async_cancel</td>
92
 
<td>g_cancellable_cancel</td>
 
38
<td>char *path</td>
 
39
<td>GFile *file</td>
 
40
</tr>
 
41
<tr>
 
42
<td>struct stat *buf</td>
 
43
<td>GFileInfo *info</td>
 
44
</tr>
 
45
<tr>
 
46
<td>struct statvfs *buf</td>
 
47
<td>GFileInfo *info</td>
 
48
</tr>
 
49
<tr>
 
50
<td rowspan="2">int fd</td>
 
51
<td>GInputStream *in</td>
 
52
</tr>
 
53
<tr><td>GOutputStream *out</td></tr>
 
54
<tr>
 
55
<td>DIR *</td>
 
56
<td>GFileEnumerator *enum</td>
 
57
</tr>
 
58
<tr>
 
59
<td>fstab entry</td>
 
60
<td>GUnixMountPoint *mount_point</td>
 
61
</tr>
 
62
<tr>
 
63
<td>mtab entry</td>
 
64
<td>GUnixMountEntry *mount_entry</td>
93
65
</tr>
94
66
</tbody>
95
67
</table></div>
96
68
</div>
97
 
<br class="table-break"><div class="section">
98
 
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
99
 
<a name="id770962"></a>Trash handling</h2></div></div></div>
100
 
<p>
101
 
        The handling of trashed files has been changed in GIO, compared
102
 
        to gnome-vfs. gnome-vfs has a home-grown trash implementation that 
103
 
        predates the freedesktop.org <a class="ulink" href="http://www.freedesktop.org/wiki/Specifications/trash-spec" target="_top">Desktop Trash Can</a> specification
104
 
        that is implemented in GIO. The location for storing trashed files 
105
 
        has changed from <code class="filename">$HOME/.Trash</code> to 
106
 
        <code class="filename">$HOME/.local/share/Trash</code> (or more correctly
107
 
        <code class="filename">$XDG_DATA_HOME/Trash</code>), which means that 
108
 
        there is a need for migrating files that have been trashed by 
109
 
        gnome-vfs to the new location.
110
 
      </p>
111
 
<p>
112
 
        In gnome-vfs, the <code class="filename">trash://</code> scheme offering a 
113
 
        merged view of all trash directories was implemented in nautilus,
114
 
        and trash-handling applications had to find and monitor all trash 
115
 
        directories themselves. With GIO, the <code class="filename">trash://</code>
116
 
        implementation has been moved to gvfs and applications can simply
117
 
        monitor that location:
118
 
      </p>
119
 
<div class="informalexample">
120
 
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
121
 
    <tbody>
122
 
      <tr>
123
 
        <td class="listing_lines" align="right"><pre>1
124
 
2
125
 
3
126
 
4
127
 
5
128
 
6
129
 
7
130
 
8
131
 
9
132
 
10
133
 
11
134
 
12
135
 
13
136
 
14
137
 
15
138
 
16
139
 
17
140
 
18
141
 
19
142
 
20
143
 
21
144
 
22
145
 
23
146
 
24
147
 
25
148
 
26
149
 
27
150
 
28
151
 
29
152
 
30
153
 
31
154
 
32
155
 
33
156
 
34</pre></td>
157
 
        <td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
158
 
<span class="function">file_changed</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">GFileMonitor</span><span class="normal">      </span><span class="symbol">*</span><span class="normal">file_monitor</span><span class="symbol">,</span>
159
 
<span class="normal">              </span><span class="usertype">GFile</span><span class="normal">             </span><span class="symbol">*</span><span class="normal">child</span><span class="symbol">,</span>
160
 
<span class="normal">              </span><span class="usertype">GFile</span><span class="normal">             </span><span class="symbol">*</span><span class="normal">other_file</span><span class="symbol">,</span>
161
 
<span class="normal">              </span><span class="usertype">GFileMonitorEvent</span><span class="normal">  event_type</span><span class="symbol">,</span>
162
 
<span class="normal">              </span><span class="usertype">gpointer</span><span class="normal">           user_data</span><span class="symbol">)</span>
163
 
<span class="cbracket">{</span>
164
 
<span class="normal">  </span><span class="keyword">switch</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">event_type</span><span class="symbol">)</span>
165
 
<span class="normal">  </span><span class="cbracket">{</span>
166
 
<span class="normal">  </span><span class="keyword">case</span><span class="normal"> <a href="GFileMonitor.html#G-FILE-MONITOR-EVENT-DELETED:CAPS">G_FILE_MONITOR_EVENT_DELETED</a></span><span class="symbol">:</span>
167
 
<span class="normal">    </span><span class="function"><a href="./../glib/glib/glib-Warnings-and-Assertions.html#g-print">g_print</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"'%s' removed from trash</span><span class="specialchar">\n</span><span class="string">"</span><span class="symbol">,</span><span class="normal"> </span><span class="function"><a href="GFile.html#g-file-get-basename">g_file_get_basename</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">child</span><span class="symbol">));</span>
168
 
<span class="normal">    </span><span class="keyword">break</span><span class="symbol">;</span>
169
 
<span class="normal">  </span><span class="keyword">case</span><span class="normal"> <a href="GFileMonitor.html#G-FILE-MONITOR-EVENT-CREATED:CAPS">G_FILE_MONITOR_EVENT_CREATED</a></span><span class="symbol">:</span>
170
 
<span class="normal">    </span><span class="function"><a href="./../glib/glib/glib-Warnings-and-Assertions.html#g-print">g_print</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"'%s' added to trash</span><span class="specialchar">\n</span><span class="string">"</span><span class="symbol">,</span><span class="normal"> </span><span class="function"><a href="GFile.html#g-file-get-basename">g_file_get_basename</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">child</span><span class="symbol">));</span>
171
 
<span class="normal">    </span><span class="keyword">break</span><span class="symbol">;</span>
172
 
<span class="normal">  </span><span class="keyword">default</span><span class="symbol">:</span><span class="normal"> </span><span class="symbol">;</span>
173
 
<span class="normal">  </span><span class="cbracket">}</span>
174
 
<span class="cbracket">}</span>
175
 
 
176
 
<span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
177
 
<span class="function">start_monitoring_trash</span><span class="normal"> </span><span class="symbol">(</span><span class="type">void</span><span class="symbol">)</span>
178
 
<span class="cbracket">{</span>
179
 
<span class="normal">  </span><span class="usertype">GFile</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">file</span><span class="symbol">;</span>
180
 
<span class="normal">  </span><span class="usertype">GFileMonitor</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">monitor</span><span class="symbol">;</span>
181
 
 
182
 
<span class="normal">  file </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="GFile.html#g-file-new-for-uri">g_file_new_for_uri</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"trash://"</span><span class="symbol">);</span>
183
 
<span class="normal">  monitor </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="GFile.html#g-file-monitor-directory">g_file_monitor_directory</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">file</span><span class="symbol">,</span><span class="normal"> </span><span class="number">0</span><span class="symbol">,</span><span class="normal"> <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">,</span><span class="normal"> <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span>
184
 
<span class="normal">  </span><span class="function"><a href="./../gobject/gobject/gobject-The-Base-Object-Type.html#g-object-unref">g_object_unref</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">file</span><span class="symbol">);</span>
185
 
 
186
 
<span class="normal">  </span><span class="function"><a href="./../gobject/gobject/gobject-Signals.html#g-signal-connect">g_signal_connect</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">monitor</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"changed"</span><span class="symbol">,</span><span class="normal"> </span><span class="function"><a href="./../gobject/gobject/gobject-Closures.html#G-CALLBACK:CAPS">G_CALLBACK</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">file_changed</span><span class="symbol">),</span><span class="normal"> <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span>
187
 
 
188
 
<span class="normal">  </span><span class="comment">/* ... */</span>
189
 
 
190
 
<span class="cbracket">}</span></pre></td>
191
 
      </tr>
192
 
    </tbody>
193
 
  </table>
194
 
</div>
195
 
 
196
 
<p>
197
 
        GIO exposes some useful metadata about trashed files. There are
198
 
        trash::orig-path and trash::deletion-date attributes. The 
199
 
        standard::icon attribute of the <code class="filename">trash://</code> 
200
 
        itself provides a suitable icon for displaying the trash can on 
201
 
        the desktop. If you are using this icon, make sure to monitor
202
 
        this attribute for changes, since the icon may be updated to
203
 
        reflect that state of the trash can.
204
 
      </p>
205
 
<p>
206
 
        Moving a file to the trash is much simpler with GIO. Instead of
207
 
        using <code class="function">gnome_vfs_find_directory()</code> with <code class="literal">GNOME_VFS_DIRECTORY_KIND_TRASH</code> 
208
 
        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>
209
 
        function.
210
 
      </p>
211
 
</div>
 
69
<br class="table-break">
212
70
</div>
213
71
<div class="footer">
214
72
<hr>