Blame docs/reference/gio/html/ch33.html

Packit ae235b
Packit ae235b
<html>
Packit ae235b
<head>
Packit ae235b
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Packit ae235b
<title>Migrating from GnomeVFS to GIO: GIO Reference Manual</title>
Packit ae235b
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
Packit ae235b
<link rel="home" href="index.html" title="GIO Reference Manual">
Packit ae235b
<link rel="up" href="migrating.html" title="Part III. Migrating to GIO">
Packit ae235b
<link rel="prev" href="ch32.html" title="Migrating from POSIX to GIO">
Packit ae235b
<link rel="next" href="ch33s02.html" title="Operations on multiple files">
Packit ae235b
<meta name="generator" content="GTK-Doc V1.27 (XML mode)">
Packit ae235b
<link rel="stylesheet" href="style.css" type="text/css">
Packit ae235b
</head>
Packit ae235b
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
Packit ae235b
Packit ae235b
Packit ae235b
Home
Packit ae235b
Up
Packit ae235b
Prev
Packit ae235b
Next
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Migrating from GnomeVFS to GIO
Packit ae235b
Packit ae235b
Trash handling
Packit ae235b
Operations on multiple files
Packit ae235b
Mime monitoring
Packit ae235b
Packit ae235b
Packit ae235b

Table 2. Comparison of GnomeVFS and GIO concepts

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GnomeVFS
Packit ae235b
GIO
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GnomeVFSURI
Packit ae235b
GFile
Packit ae235b
Packit ae235b
Packit ae235b
GnomeVFSFileInfo
Packit ae235b
GFileInfo
Packit ae235b
Packit ae235b
Packit ae235b
GnomeVFSResult
Packit ae235b
GError, with G_IO_ERROR values
Packit ae235b
Packit ae235b
Packit ae235b
GnomeVFSHandle & GnomeVFSAsyncHandle
Packit ae235b
GInputStream or GOutputStream
Packit ae235b
Packit ae235b
Packit ae235b
GnomeVFSDirectoryHandle
Packit ae235b
GFileEnumerator
Packit ae235b
Packit ae235b
Packit ae235b
mime type
Packit ae235b
content type
Packit ae235b
Packit ae235b
Packit ae235b
GnomeVFSMonitor
Packit ae235b
GFileMonitor
Packit ae235b
Packit ae235b
Packit ae235b
GnomeVFSVolumeMonitor
Packit ae235b
GVolumeMonitor
Packit ae235b
Packit ae235b
Packit ae235b
GnomeVFSVolume
Packit ae235b
GMount
Packit ae235b
Packit ae235b
Packit ae235b
GnomeVFSDrive
Packit ae235b
GVolume
Packit ae235b
Packit ae235b
Packit ae235b
-
Packit ae235b
GDrive
Packit ae235b
Packit ae235b
Packit ae235b
GnomeVFSContext
Packit ae235b
GCancellable
Packit ae235b
Packit ae235b
Packit ae235b
gnome_vfs_async_cancel
Packit ae235b
g_cancellable_cancel
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b

Packit ae235b
Trash handling
Packit ae235b

Packit ae235b
        The handling of trashed files has been changed in GIO, compared
Packit ae235b
        to gnome-vfs. gnome-vfs has a home-grown trash implementation that 
Packit ae235b
        predates the freedesktop.org Desktop Trash Can specification
Packit ae235b
        that is implemented in GIO. The location for storing trashed files 
Packit ae235b
        has changed from $HOME/.Trash to 
Packit ae235b
        $HOME/.local/share/Trash (or more correctly
Packit ae235b
        $XDG_DATA_HOME/Trash), which means that 
Packit ae235b
        there is a need for migrating files that have been trashed by 
Packit ae235b
        gnome-vfs to the new location.
Packit ae235b
      

Packit ae235b

Packit ae235b
        In gnome-vfs, the trash:// scheme offering a 
Packit ae235b
        merged view of all trash directories was implemented in nautilus,
Packit ae235b
        and trash-handling applications had to find and monitor all trash 
Packit ae235b
        directories themselves. With GIO, the trash://
Packit ae235b
        implementation has been moved to gvfs and applications can simply
Packit ae235b
        monitor that location:
Packit ae235b
      

Packit ae235b
Packit ae235b
  
Packit ae235b
    
Packit ae235b
      
Packit ae235b
        
1
Packit ae235b
2
Packit ae235b
3
Packit ae235b
4
Packit ae235b
5
Packit ae235b
6
Packit ae235b
7
Packit ae235b
8
Packit ae235b
9
Packit ae235b
10
Packit ae235b
11
Packit ae235b
12
Packit ae235b
13
Packit ae235b
14
Packit ae235b
15
Packit ae235b
16
Packit ae235b
17
Packit ae235b
18
Packit ae235b
19
Packit ae235b
20
Packit ae235b
21
Packit ae235b
22
Packit ae235b
23
Packit ae235b
24
Packit ae235b
25
Packit ae235b
26
Packit ae235b
27
Packit ae235b
28
Packit ae235b
29
Packit ae235b
30
Packit ae235b
31
Packit ae235b
32
Packit ae235b
33
Packit ae235b
34
Packit ae235b
        
static void
Packit ae235b
file_changed (GFileMonitor      *file_monitor,
Packit ae235b
              GFile             *child,
Packit ae235b
              GFile             *other_file,
Packit ae235b
              GFileMonitorEvent  event_type,
Packit ae235b
              gpointer           user_data)
Packit ae235b
{
Packit ae235b
  switch (event_type)
Packit ae235b
  {
Packit ae235b
  case G_FILE_MONITOR_EVENT_DELETED:
Packit ae235b
    g_print ("'%s' removed from trash\n", g_file_get_basename (child));
Packit ae235b
    break;
Packit ae235b
  case G_FILE_MONITOR_EVENT_CREATED:
Packit ae235b
    g_print ("'%s' added to trash\n", g_file_get_basename (child));
Packit ae235b
    break;
Packit ae235b
  default: ;
Packit ae235b
  }
Packit ae235b
}
Packit ae235b
Packit ae235b
static void
Packit ae235b
start_monitoring_trash (void)
Packit ae235b
{
Packit ae235b
  GFile *file;
Packit ae235b
  GFileMonitor *monitor;
Packit ae235b
Packit ae235b
  file = g_file_new_for_uri ("trash://");
Packit ae235b
  monitor = g_file_monitor_directory (file, 0, NULL, NULL);
Packit ae235b
  g_object_unref (file);
Packit ae235b
Packit ae235b
  g_signal_connect (monitor, "changed", G_CALLBACK (file_changed), NULL);
Packit ae235b
Packit ae235b
  /* ... */
Packit ae235b
Packit ae235b
}
Packit ae235b
      
Packit ae235b
    
Packit ae235b
  
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
        GIO exposes some useful metadata about trashed files. There are
Packit ae235b
        trash::orig-path and trash::deletion-date attributes. The 
Packit ae235b
        standard::icon attribute of the trash:// 
Packit ae235b
        itself provides a suitable icon for displaying the trash can on 
Packit ae235b
        the desktop. If you are using this icon, make sure to monitor
Packit ae235b
        this attribute for changes, since the icon may be updated to
Packit ae235b
        reflect that state of the trash can.
Packit ae235b
      

Packit ae235b

Packit ae235b
        Moving a file to the trash is much simpler with GIO. Instead of
Packit ae235b
        using gnome_vfs_find_directory() with GNOME_VFS_DIRECTORY_KIND_TRASH 
Packit ae235b
        to find out where to move the trashed file, just use the g_file_trash()
Packit ae235b
        function.
Packit ae235b
      

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Generated by GTK-Doc V1.27
Packit ae235b
</body>
Packit ae235b
</html>