2008-07-01 22:57:50 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
2008-06-10 00:39:35 +00:00
|
|
|
* gtkfilesystem.c: Filesystem abstraction functions.
|
2003-03-21 20:34:02 +00:00
|
|
|
* Copyright (C) 2003, Red Hat, Inc.
|
2008-06-10 00:39:35 +00:00
|
|
|
* Copyright (C) 2007-2008 Carlos Garnacho
|
2003-03-21 20:34:02 +00:00
|
|
|
*
|
2012-02-27 13:01:10 +00:00
|
|
|
* This library is free software; you can redistribute it and/or modify
|
2008-06-10 00:39:35 +00:00
|
|
|
* it under the terms of the GNU Lesser General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
2003-03-21 20:34:02 +00:00
|
|
|
*
|
2012-02-27 13:01:10 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2003-03-21 20:34:02 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2008-06-10 00:39:35 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2012-02-27 13:01:10 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2003-03-21 20:34:02 +00:00
|
|
|
*
|
2012-02-27 13:01:10 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2008-06-10 00:39:35 +00:00
|
|
|
*
|
|
|
|
* Authors: Carlos Garnacho <carlos@imendio.com>
|
2003-03-21 20:34:02 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-26 10:19:23 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2008-09-22 08:55:58 +00:00
|
|
|
#include <glib/gi18n-lib.h>
|
2008-06-10 00:39:35 +00:00
|
|
|
|
2008-07-07 09:05:02 +00:00
|
|
|
#include "gtkfilechooser.h"
|
2003-03-21 20:34:02 +00:00
|
|
|
#include "gtkfilesystem.h"
|
2008-07-07 09:05:02 +00:00
|
|
|
#include "gtkicontheme.h"
|
2008-06-10 00:39:35 +00:00
|
|
|
#include "gtkprivate.h"
|
2003-03-21 20:34:02 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
/* #define DEBUG_MODE */
|
|
|
|
#ifdef DEBUG_MODE
|
2008-06-13 08:36:26 +00:00
|
|
|
#define DEBUG(x) g_debug (x);
|
2008-06-10 00:39:35 +00:00
|
|
|
#else
|
2008-06-13 08:36:26 +00:00
|
|
|
#define DEBUG(x)
|
2008-06-10 00:39:35 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define FILES_PER_QUERY 100
|
|
|
|
|
|
|
|
/* The pointers we return for a GtkFileSystemVolume are opaque tokens; they are
|
|
|
|
* really pointers to GDrive, GVolume or GMount objects. We need an extra
|
|
|
|
* token for the fake "File System" volume. So, we'll return a pointer to
|
|
|
|
* this particular string.
|
|
|
|
*/
|
|
|
|
static const gchar *root_volume_token = N_("File System");
|
|
|
|
#define IS_ROOT_VOLUME(volume) ((gpointer) (volume) == (gpointer) root_volume_token)
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
PROP_FILE,
|
|
|
|
PROP_ENUMERATOR,
|
|
|
|
PROP_ATTRIBUTES
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
VOLUMES_CHANGED,
|
|
|
|
FS_LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
FILES_ADDED,
|
|
|
|
FILES_REMOVED,
|
|
|
|
FILES_CHANGED,
|
|
|
|
FINISHED_LOADING,
|
|
|
|
DELETED,
|
|
|
|
FOLDER_LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint fs_signals [FS_LAST_SIGNAL] = { 0, };
|
|
|
|
|
|
|
|
typedef struct AsyncFuncData AsyncFuncData;
|
|
|
|
|
2010-08-26 17:15:37 +00:00
|
|
|
struct GtkFileSystemPrivate
|
2008-06-10 00:39:35 +00:00
|
|
|
{
|
|
|
|
GVolumeMonitor *volume_monitor;
|
|
|
|
|
|
|
|
/* This list contains elements that can be
|
|
|
|
* of type GDrive, GVolume and GMount
|
|
|
|
*/
|
|
|
|
GSList *volumes;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AsyncFuncData
|
|
|
|
{
|
|
|
|
GtkFileSystem *file_system;
|
|
|
|
GFile *file;
|
|
|
|
GCancellable *cancellable;
|
|
|
|
gchar *attributes;
|
|
|
|
|
|
|
|
gpointer callback;
|
|
|
|
gpointer data;
|
|
|
|
};
|
2003-04-04 22:43:12 +00:00
|
|
|
|
2008-06-13 16:47:41 +00:00
|
|
|
G_DEFINE_TYPE (GtkFileSystem, _gtk_file_system, G_TYPE_OBJECT)
|
2008-06-10 00:39:35 +00:00
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
/* GtkFileSystem methods */
|
|
|
|
static void
|
|
|
|
volumes_changed (GVolumeMonitor *volume_monitor,
|
|
|
|
gpointer volume,
|
|
|
|
gpointer user_data)
|
2003-03-21 20:34:02 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
GtkFileSystem *file_system;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
gdk_threads_enter ();
|
2003-03-21 20:34:02 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
file_system = GTK_FILE_SYSTEM (user_data);
|
|
|
|
g_signal_emit (file_system, fs_signals[VOLUMES_CHANGED], 0, volume);
|
|
|
|
gdk_threads_leave ();
|
2003-03-21 20:34:02 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
static void
|
|
|
|
gtk_file_system_dispose (GObject *object)
|
2003-03-21 20:34:02 +00:00
|
|
|
{
|
2010-08-26 13:57:05 +00:00
|
|
|
GtkFileSystem *file_system = GTK_FILE_SYSTEM (object);
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkFileSystemPrivate *priv = file_system->priv;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
DEBUG ("dispose");
|
2003-03-21 20:34:02 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (priv->volumes)
|
|
|
|
{
|
|
|
|
g_slist_foreach (priv->volumes, (GFunc) g_object_unref, NULL);
|
|
|
|
g_slist_free (priv->volumes);
|
|
|
|
priv->volumes = NULL;
|
|
|
|
}
|
2003-03-26 16:24:35 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (priv->volume_monitor)
|
2003-03-26 16:24:35 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (priv->volume_monitor, volumes_changed, object);
|
|
|
|
g_object_unref (priv->volume_monitor);
|
|
|
|
priv->volume_monitor = NULL;
|
2003-03-26 16:24:35 +00:00
|
|
|
}
|
2008-06-10 00:39:35 +00:00
|
|
|
|
2008-06-13 16:47:41 +00:00
|
|
|
G_OBJECT_CLASS (_gtk_file_system_parent_class)->dispose (object);
|
2003-03-26 16:24:35 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
static void
|
2008-06-13 16:47:41 +00:00
|
|
|
_gtk_file_system_class_init (GtkFileSystemClass *class)
|
2003-03-21 20:34:02 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
object_class->dispose = gtk_file_system_dispose;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
fs_signals[VOLUMES_CHANGED] =
|
|
|
|
g_signal_new ("volumes-changed",
|
|
|
|
G_TYPE_FROM_CLASS (object_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GtkFileSystemClass, volumes_changed),
|
|
|
|
NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2010-08-26 17:15:37 +00:00
|
|
|
g_type_class_add_private (object_class, sizeof (GtkFileSystemPrivate));
|
2003-03-21 20:34:02 +00:00
|
|
|
}
|
|
|
|
|
2008-12-01 05:42:28 +00:00
|
|
|
static gboolean
|
|
|
|
mount_referenced_by_volume_activation_root (GList *volumes, GMount *mount)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
GFile *mount_root;
|
|
|
|
gboolean ret;
|
|
|
|
|
|
|
|
ret = FALSE;
|
|
|
|
|
|
|
|
mount_root = g_mount_get_root (mount);
|
|
|
|
|
|
|
|
for (l = volumes; l != NULL; l = l->next)
|
|
|
|
{
|
|
|
|
GVolume *volume = G_VOLUME (l->data);
|
|
|
|
GFile *volume_activation_root;
|
|
|
|
|
|
|
|
volume_activation_root = g_volume_get_activation_root (volume);
|
|
|
|
if (volume_activation_root != NULL)
|
|
|
|
{
|
|
|
|
if (g_file_has_prefix (volume_activation_root, mount_root))
|
|
|
|
{
|
|
|
|
ret = TRUE;
|
|
|
|
g_object_unref (volume_activation_root);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
g_object_unref (volume_activation_root);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (mount_root);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
static void
|
|
|
|
get_volumes_list (GtkFileSystem *file_system)
|
2006-05-01 21:41:12 +00:00
|
|
|
{
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkFileSystemPrivate *priv = file_system->priv;
|
2008-06-10 00:39:35 +00:00
|
|
|
GList *l, *ll;
|
|
|
|
GList *drives;
|
|
|
|
GList *volumes;
|
|
|
|
GList *mounts;
|
|
|
|
GDrive *drive;
|
|
|
|
GVolume *volume;
|
|
|
|
GMount *mount;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (priv->volumes)
|
2006-05-01 21:41:12 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
g_slist_foreach (priv->volumes, (GFunc) g_object_unref, NULL);
|
|
|
|
g_slist_free (priv->volumes);
|
|
|
|
priv->volumes = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* first go through all connected drives */
|
|
|
|
drives = g_volume_monitor_get_connected_drives (priv->volume_monitor);
|
|
|
|
|
|
|
|
for (l = drives; l != NULL; l = l->next)
|
|
|
|
{
|
|
|
|
drive = l->data;
|
|
|
|
volumes = g_drive_get_volumes (drive);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (volumes)
|
|
|
|
{
|
|
|
|
for (ll = volumes; ll != NULL; ll = ll->next)
|
|
|
|
{
|
|
|
|
volume = ll->data;
|
|
|
|
mount = g_volume_get_mount (volume);
|
|
|
|
|
|
|
|
if (mount)
|
|
|
|
{
|
|
|
|
/* Show mounted volume */
|
|
|
|
priv->volumes = g_slist_prepend (priv->volumes, g_object_ref (mount));
|
|
|
|
g_object_unref (mount);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Do show the unmounted volumes in the sidebar;
|
|
|
|
* this is so the user can mount it (in case automounting
|
|
|
|
* is off).
|
|
|
|
*
|
|
|
|
* Also, even if automounting is enabled, this gives a visual
|
|
|
|
* cue that the user should remember to yank out the media if
|
|
|
|
* he just unmounted it.
|
|
|
|
*/
|
|
|
|
priv->volumes = g_slist_prepend (priv->volumes, g_object_ref (volume));
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (volume);
|
|
|
|
}
|
2008-07-03 22:46:00 +00:00
|
|
|
|
|
|
|
g_list_free (volumes);
|
2008-06-10 00:39:35 +00:00
|
|
|
}
|
|
|
|
else if (g_drive_is_media_removable (drive) && !g_drive_is_media_check_automatic (drive))
|
|
|
|
{
|
|
|
|
/* If the drive has no mountable volumes and we cannot detect media change.. we
|
|
|
|
* display the drive in the sidebar so the user can manually poll the drive by
|
|
|
|
* right clicking and selecting "Rescan..."
|
|
|
|
*
|
|
|
|
* This is mainly for drives like floppies where media detection doesn't
|
|
|
|
* work.. but it's also for human beings who like to turn off media detection
|
|
|
|
* in the OS to save battery juice.
|
|
|
|
*/
|
|
|
|
|
|
|
|
priv->volumes = g_slist_prepend (priv->volumes, g_object_ref (drive));
|
2006-05-01 21:41:12 +00:00
|
|
|
}
|
2010-03-09 04:56:43 +00:00
|
|
|
|
|
|
|
g_object_unref (drive);
|
2006-05-01 21:41:12 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
g_list_free (drives);
|
|
|
|
|
|
|
|
/* add all volumes that is not associated with a drive */
|
|
|
|
volumes = g_volume_monitor_get_volumes (priv->volume_monitor);
|
|
|
|
|
|
|
|
for (l = volumes; l != NULL; l = l->next)
|
2006-05-01 21:41:12 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
volume = l->data;
|
|
|
|
drive = g_volume_get_drive (volume);
|
|
|
|
|
|
|
|
if (drive)
|
|
|
|
{
|
|
|
|
g_object_unref (drive);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
mount = g_volume_get_mount (volume);
|
|
|
|
|
|
|
|
if (mount)
|
|
|
|
{
|
|
|
|
/* show this mount */
|
|
|
|
priv->volumes = g_slist_prepend (priv->volumes, g_object_ref (mount));
|
|
|
|
g_object_unref (mount);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* see comment above in why we add an icon for a volume */
|
|
|
|
priv->volumes = g_slist_prepend (priv->volumes, g_object_ref (volume));
|
|
|
|
}
|
2010-03-09 04:56:43 +00:00
|
|
|
|
|
|
|
g_object_unref (volume);
|
2006-05-01 21:41:12 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
/* add mounts that has no volume (/etc/mtab mounts, ftp, sftp,...) */
|
|
|
|
mounts = g_volume_monitor_get_mounts (priv->volume_monitor);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
for (l = mounts; l != NULL; l = l->next)
|
|
|
|
{
|
|
|
|
mount = l->data;
|
|
|
|
volume = g_mount_get_volume (mount);
|
|
|
|
|
|
|
|
if (volume)
|
|
|
|
{
|
|
|
|
g_object_unref (volume);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-12-01 05:42:28 +00:00
|
|
|
/* if there's exists one or more volumes with an activation root inside the mount,
|
|
|
|
* don't display the mount
|
|
|
|
*/
|
|
|
|
if (mount_referenced_by_volume_activation_root (volumes, mount))
|
|
|
|
{
|
2010-03-09 04:56:43 +00:00
|
|
|
g_object_unref (mount);
|
2008-12-01 05:42:28 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
/* show this mount */
|
|
|
|
priv->volumes = g_slist_prepend (priv->volumes, g_object_ref (mount));
|
2010-03-09 04:56:43 +00:00
|
|
|
g_object_unref (mount);
|
2008-06-10 00:39:35 +00:00
|
|
|
}
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-12-01 05:42:28 +00:00
|
|
|
g_list_free (volumes);
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
g_list_free (mounts);
|
|
|
|
}
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
static void
|
2008-06-13 16:47:41 +00:00
|
|
|
_gtk_file_system_init (GtkFileSystem *file_system)
|
2008-06-10 00:39:35 +00:00
|
|
|
{
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkFileSystemPrivate *priv;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
|
|
DEBUG ("init");
|
|
|
|
|
2010-08-26 13:57:05 +00:00
|
|
|
file_system->priv = G_TYPE_INSTANCE_GET_PRIVATE (file_system,
|
|
|
|
GTK_TYPE_FILE_SYSTEM,
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkFileSystemPrivate);
|
2010-08-26 13:57:05 +00:00
|
|
|
priv = file_system->priv;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
|
|
/* Volumes */
|
|
|
|
priv->volume_monitor = g_volume_monitor_get ();
|
|
|
|
|
|
|
|
g_signal_connect (priv->volume_monitor, "mount-added",
|
|
|
|
G_CALLBACK (volumes_changed), file_system);
|
|
|
|
g_signal_connect (priv->volume_monitor, "mount-removed",
|
|
|
|
G_CALLBACK (volumes_changed), file_system);
|
|
|
|
g_signal_connect (priv->volume_monitor, "mount-changed",
|
|
|
|
G_CALLBACK (volumes_changed), file_system);
|
|
|
|
g_signal_connect (priv->volume_monitor, "volume-added",
|
|
|
|
G_CALLBACK (volumes_changed), file_system);
|
|
|
|
g_signal_connect (priv->volume_monitor, "volume-removed",
|
|
|
|
G_CALLBACK (volumes_changed), file_system);
|
|
|
|
g_signal_connect (priv->volume_monitor, "volume-changed",
|
|
|
|
G_CALLBACK (volumes_changed), file_system);
|
|
|
|
g_signal_connect (priv->volume_monitor, "drive-connected",
|
|
|
|
G_CALLBACK (volumes_changed), file_system);
|
|
|
|
g_signal_connect (priv->volume_monitor, "drive-disconnected",
|
|
|
|
G_CALLBACK (volumes_changed), file_system);
|
|
|
|
g_signal_connect (priv->volume_monitor, "drive-changed",
|
|
|
|
G_CALLBACK (volumes_changed), file_system);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* GtkFileSystem public methods */
|
|
|
|
GtkFileSystem *
|
2008-06-13 16:47:41 +00:00
|
|
|
_gtk_file_system_new (void)
|
2006-05-01 21:41:12 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
return g_object_new (GTK_TYPE_FILE_SYSTEM, NULL);
|
2006-05-01 21:41:12 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
GSList *
|
2008-06-13 16:47:41 +00:00
|
|
|
_gtk_file_system_list_volumes (GtkFileSystem *file_system)
|
2006-05-01 21:41:12 +00:00
|
|
|
{
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkFileSystemPrivate *priv = file_system->priv;
|
2008-06-10 00:39:35 +00:00
|
|
|
GSList *list;
|
|
|
|
|
|
|
|
DEBUG ("list_volumes");
|
|
|
|
|
2010-08-26 13:57:05 +00:00
|
|
|
get_volumes_list (file_system);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
|
|
list = g_slist_copy (priv->volumes);
|
|
|
|
|
2008-06-20 20:39:22 +00:00
|
|
|
#ifndef G_OS_WIN32
|
2008-06-10 00:39:35 +00:00
|
|
|
/* Prepend root volume */
|
|
|
|
list = g_slist_prepend (list, (gpointer) root_volume_token);
|
2008-06-20 20:39:22 +00:00
|
|
|
#endif
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
|
|
return list;
|
2006-05-01 21:41:12 +00:00
|
|
|
}
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
free_async_data (AsyncFuncData *async_data)
|
2003-03-21 20:34:02 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
g_object_unref (async_data->file_system);
|
|
|
|
g_object_unref (async_data->file);
|
|
|
|
g_object_unref (async_data->cancellable);
|
|
|
|
|
|
|
|
g_free (async_data->attributes);
|
|
|
|
g_free (async_data);
|
2003-03-21 20:34:02 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
static void
|
|
|
|
query_info_callback (GObject *source_object,
|
|
|
|
GAsyncResult *result,
|
|
|
|
gpointer user_data)
|
2006-05-01 21:41:12 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
AsyncFuncData *async_data;
|
|
|
|
GError *error = NULL;
|
|
|
|
GFileInfo *file_info;
|
|
|
|
GFile *file;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
DEBUG ("query_info_callback");
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
file = G_FILE (source_object);
|
|
|
|
async_data = (AsyncFuncData *) user_data;
|
|
|
|
file_info = g_file_query_info_finish (file, result, &error);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (async_data->callback)
|
|
|
|
{
|
|
|
|
gdk_threads_enter ();
|
|
|
|
((GtkFileSystemGetInfoCallback) async_data->callback) (async_data->cancellable,
|
|
|
|
file_info, error, async_data->data);
|
|
|
|
gdk_threads_leave ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (file_info)
|
|
|
|
g_object_unref (file_info);
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
g_error_free (error);
|
|
|
|
|
|
|
|
free_async_data (async_data);
|
2003-03-21 20:34:02 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
GCancellable *
|
2008-06-13 16:47:41 +00:00
|
|
|
_gtk_file_system_get_info (GtkFileSystem *file_system,
|
|
|
|
GFile *file,
|
|
|
|
const gchar *attributes,
|
|
|
|
GtkFileSystemGetInfoCallback callback,
|
|
|
|
gpointer data)
|
2004-01-16 03:35:33 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
GCancellable *cancellable;
|
|
|
|
AsyncFuncData *async_data;
|
|
|
|
|
2004-01-16 03:35:33 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
|
2008-06-10 00:39:35 +00:00
|
|
|
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
2004-01-16 03:35:33 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
cancellable = g_cancellable_new ();
|
2004-01-16 03:35:33 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
async_data = g_new0 (AsyncFuncData, 1);
|
|
|
|
async_data->file_system = g_object_ref (file_system);
|
|
|
|
async_data->file = g_object_ref (file);
|
|
|
|
async_data->cancellable = g_object_ref (cancellable);
|
|
|
|
|
|
|
|
async_data->callback = callback;
|
|
|
|
async_data->data = data;
|
2003-12-17 05:55:16 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
g_file_query_info_async (file,
|
|
|
|
attributes,
|
|
|
|
G_FILE_QUERY_INFO_NONE,
|
|
|
|
G_PRIORITY_DEFAULT,
|
|
|
|
cancellable,
|
|
|
|
query_info_callback,
|
|
|
|
async_data);
|
|
|
|
|
|
|
|
return cancellable;
|
2003-12-17 05:55:16 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
static void
|
|
|
|
drive_poll_for_media_cb (GObject *source_object,
|
|
|
|
GAsyncResult *result,
|
|
|
|
gpointer user_data)
|
2003-12-17 05:55:16 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
AsyncFuncData *async_data;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
g_drive_poll_for_media_finish (G_DRIVE (source_object), result, &error);
|
|
|
|
async_data = (AsyncFuncData *) user_data;
|
2003-12-17 05:55:16 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
gdk_threads_enter ();
|
|
|
|
((GtkFileSystemVolumeMountCallback) async_data->callback) (async_data->cancellable,
|
|
|
|
(GtkFileSystemVolume *) source_object,
|
|
|
|
error, async_data->data);
|
|
|
|
gdk_threads_leave ();
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
g_error_free (error);
|
2003-12-17 05:55:16 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
static void
|
|
|
|
volume_mount_cb (GObject *source_object,
|
|
|
|
GAsyncResult *result,
|
|
|
|
gpointer user_data)
|
2003-12-17 05:55:16 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
AsyncFuncData *async_data;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
g_volume_mount_finish (G_VOLUME (source_object), result, &error);
|
|
|
|
async_data = (AsyncFuncData *) user_data;
|
2003-12-17 05:55:16 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
gdk_threads_enter ();
|
|
|
|
((GtkFileSystemVolumeMountCallback) async_data->callback) (async_data->cancellable,
|
|
|
|
(GtkFileSystemVolume *) source_object,
|
|
|
|
error, async_data->data);
|
|
|
|
gdk_threads_leave ();
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
g_error_free (error);
|
2003-12-17 05:55:16 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
GCancellable *
|
2008-06-13 16:47:41 +00:00
|
|
|
_gtk_file_system_mount_volume (GtkFileSystem *file_system,
|
|
|
|
GtkFileSystemVolume *volume,
|
|
|
|
GMountOperation *mount_operation,
|
|
|
|
GtkFileSystemVolumeMountCallback callback,
|
|
|
|
gpointer data)
|
2003-12-17 05:55:16 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
GCancellable *cancellable;
|
|
|
|
AsyncFuncData *async_data;
|
|
|
|
gboolean handled = FALSE;
|
|
|
|
|
|
|
|
DEBUG ("volume_mount");
|
|
|
|
|
|
|
|
cancellable = g_cancellable_new ();
|
|
|
|
|
|
|
|
async_data = g_new0 (AsyncFuncData, 1);
|
|
|
|
async_data->file_system = g_object_ref (file_system);
|
|
|
|
async_data->cancellable = g_object_ref (cancellable);
|
|
|
|
|
|
|
|
async_data->callback = callback;
|
|
|
|
async_data->data = data;
|
2003-12-17 05:55:16 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (G_IS_DRIVE (volume))
|
|
|
|
{
|
|
|
|
/* this path happens for drives that are not polled by the OS and where the last media
|
|
|
|
* check indicated that no media was available. So the thing to do here is to
|
|
|
|
* invoke poll_for_media() on the drive
|
|
|
|
*/
|
|
|
|
g_drive_poll_for_media (G_DRIVE (volume), cancellable, drive_poll_for_media_cb, async_data);
|
|
|
|
handled = TRUE;
|
|
|
|
}
|
|
|
|
else if (G_IS_VOLUME (volume))
|
|
|
|
{
|
|
|
|
g_volume_mount (G_VOLUME (volume), G_MOUNT_MOUNT_NONE, mount_operation, cancellable, volume_mount_cb, async_data);
|
|
|
|
handled = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!handled)
|
|
|
|
free_async_data (async_data);
|
|
|
|
|
|
|
|
return cancellable;
|
2003-12-17 05:55:16 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
static void
|
|
|
|
enclosing_volume_mount_cb (GObject *source_object,
|
|
|
|
GAsyncResult *result,
|
|
|
|
gpointer user_data)
|
2003-12-17 05:55:16 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
GtkFileSystemVolume *volume;
|
|
|
|
AsyncFuncData *async_data;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
async_data = (AsyncFuncData *) user_data;
|
|
|
|
g_file_mount_enclosing_volume_finish (G_FILE (source_object), result, &error);
|
2008-06-13 16:47:41 +00:00
|
|
|
volume = _gtk_file_system_get_volume_for_file (async_data->file_system, G_FILE (source_object));
|
2003-12-17 05:55:16 +00:00
|
|
|
|
2008-12-14 02:14:19 +00:00
|
|
|
/* Silently drop G_IO_ERROR_ALREADY_MOUNTED error for gvfs backends without visible mounts. */
|
|
|
|
/* Better than doing query_info with additional I/O every time. */
|
|
|
|
if (error && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_ALREADY_MOUNTED))
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
gdk_threads_enter ();
|
|
|
|
((GtkFileSystemVolumeMountCallback) async_data->callback) (async_data->cancellable, volume,
|
|
|
|
error, async_data->data);
|
|
|
|
gdk_threads_leave ();
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
g_error_free (error);
|
2010-03-09 04:56:43 +00:00
|
|
|
|
|
|
|
_gtk_file_system_volume_unref (volume);
|
2003-12-17 05:55:16 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
GCancellable *
|
2008-06-13 16:47:41 +00:00
|
|
|
_gtk_file_system_mount_enclosing_volume (GtkFileSystem *file_system,
|
|
|
|
GFile *file,
|
|
|
|
GMountOperation *mount_operation,
|
|
|
|
GtkFileSystemVolumeMountCallback callback,
|
|
|
|
gpointer data)
|
2003-12-17 05:55:16 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
GCancellable *cancellable;
|
|
|
|
AsyncFuncData *async_data;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
|
2008-06-10 00:39:35 +00:00
|
|
|
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
2006-08-15 17:28:34 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
DEBUG ("mount_enclosing_volume");
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
cancellable = g_cancellable_new ();
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
async_data = g_new0 (AsyncFuncData, 1);
|
|
|
|
async_data->file_system = g_object_ref (file_system);
|
|
|
|
async_data->file = g_object_ref (file);
|
|
|
|
async_data->cancellable = g_object_ref (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
async_data->callback = callback;
|
|
|
|
async_data->data = data;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
g_file_mount_enclosing_volume (file,
|
|
|
|
G_MOUNT_MOUNT_NONE,
|
|
|
|
mount_operation,
|
|
|
|
cancellable,
|
|
|
|
enclosing_volume_mount_cb,
|
|
|
|
async_data);
|
|
|
|
return cancellable;
|
2003-12-17 05:55:16 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
GtkFileSystemVolume *
|
2008-06-13 16:47:41 +00:00
|
|
|
_gtk_file_system_get_volume_for_file (GtkFileSystem *file_system,
|
|
|
|
GFile *file)
|
2003-10-08 04:14:55 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
GMount *mount;
|
|
|
|
|
|
|
|
DEBUG ("get_volume_for_file");
|
2003-10-08 04:14:55 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
mount = g_file_find_enclosing_mount (file, NULL, NULL);
|
|
|
|
|
|
|
|
if (!mount && g_file_is_native (file))
|
|
|
|
return (GtkFileSystemVolume *) root_volume_token;
|
|
|
|
|
|
|
|
return (GtkFileSystemVolume *) mount;
|
2003-10-08 04:14:55 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
/* GtkFileSystemVolume public methods */
|
|
|
|
gchar *
|
2008-06-13 16:47:41 +00:00
|
|
|
_gtk_file_system_volume_get_display_name (GtkFileSystemVolume *volume)
|
2004-02-19 07:43:39 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
DEBUG ("volume_get_display_name");
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (IS_ROOT_VOLUME (volume))
|
|
|
|
return g_strdup (_(root_volume_token));
|
|
|
|
if (G_IS_DRIVE (volume))
|
|
|
|
return g_drive_get_name (G_DRIVE (volume));
|
|
|
|
else if (G_IS_MOUNT (volume))
|
|
|
|
return g_mount_get_name (G_MOUNT (volume));
|
|
|
|
else if (G_IS_VOLUME (volume))
|
|
|
|
return g_volume_get_name (G_VOLUME (volume));
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
gboolean
|
2008-06-13 16:47:41 +00:00
|
|
|
_gtk_file_system_volume_is_mounted (GtkFileSystemVolume *volume)
|
2004-02-19 07:43:39 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
gboolean mounted;
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
DEBUG ("volume_is_mounted");
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (IS_ROOT_VOLUME (volume))
|
|
|
|
return TRUE;
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
mounted = FALSE;
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (G_IS_MOUNT (volume))
|
|
|
|
mounted = TRUE;
|
|
|
|
else if (G_IS_VOLUME (volume))
|
2004-02-19 07:43:39 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
GMount *mount;
|
|
|
|
|
|
|
|
mount = g_volume_get_mount (G_VOLUME (volume));
|
|
|
|
|
|
|
|
if (mount)
|
|
|
|
{
|
|
|
|
mounted = TRUE;
|
|
|
|
g_object_unref (mount);
|
|
|
|
}
|
2004-02-19 07:43:39 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
return mounted;
|
2004-02-19 07:43:39 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
GFile *
|
2008-06-13 16:47:41 +00:00
|
|
|
_gtk_file_system_volume_get_root (GtkFileSystemVolume *volume)
|
2004-02-19 07:43:39 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
GFile *file = NULL;
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
DEBUG ("volume_get_base");
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (IS_ROOT_VOLUME (volume))
|
|
|
|
return g_file_new_for_uri ("file:///");
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (G_IS_MOUNT (volume))
|
|
|
|
file = g_mount_get_root (G_MOUNT (volume));
|
|
|
|
else if (G_IS_VOLUME (volume))
|
|
|
|
{
|
|
|
|
GMount *mount;
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
mount = g_volume_get_mount (G_VOLUME (volume));
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (mount)
|
|
|
|
{
|
|
|
|
file = g_mount_get_root (mount);
|
|
|
|
g_object_unref (mount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return file;
|
2004-02-19 07:43:39 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
static GdkPixbuf *
|
|
|
|
get_pixbuf_from_gicon (GIcon *icon,
|
|
|
|
GtkWidget *widget,
|
|
|
|
gint icon_size,
|
|
|
|
GError **error)
|
2004-02-19 07:43:39 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
GdkScreen *screen;
|
|
|
|
GtkIconTheme *icon_theme;
|
|
|
|
GtkIconInfo *icon_info;
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
|
|
|
|
screen = gtk_widget_get_screen (GTK_WIDGET (widget));
|
|
|
|
icon_theme = gtk_icon_theme_get_for_screen (screen);
|
|
|
|
|
|
|
|
icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme,
|
|
|
|
icon,
|
|
|
|
icon_size,
|
2008-06-11 03:17:55 +00:00
|
|
|
GTK_ICON_LOOKUP_USE_BUILTIN);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
|
|
if (!icon_info)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
pixbuf = gtk_icon_info_load_icon (icon_info, error);
|
|
|
|
gtk_icon_info_free (icon_info);
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
return pixbuf;
|
2004-02-19 07:43:39 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
GdkPixbuf *
|
2008-06-13 16:47:41 +00:00
|
|
|
_gtk_file_system_volume_render_icon (GtkFileSystemVolume *volume,
|
|
|
|
GtkWidget *widget,
|
|
|
|
gint icon_size,
|
|
|
|
GError **error)
|
2004-02-19 07:43:39 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
GIcon *icon = NULL;
|
2008-06-10 11:50:43 +00:00
|
|
|
GdkPixbuf *pixbuf;
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
DEBUG ("volume_get_icon_name");
|
|
|
|
|
|
|
|
if (IS_ROOT_VOLUME (volume))
|
2008-06-18 16:22:42 +00:00
|
|
|
icon = g_themed_icon_new ("drive-harddisk");
|
2008-06-10 00:39:35 +00:00
|
|
|
else if (G_IS_DRIVE (volume))
|
|
|
|
icon = g_drive_get_icon (G_DRIVE (volume));
|
|
|
|
else if (G_IS_VOLUME (volume))
|
|
|
|
icon = g_volume_get_icon (G_VOLUME (volume));
|
|
|
|
else if (G_IS_MOUNT (volume))
|
2008-06-15 23:32:11 +00:00
|
|
|
icon = g_mount_get_icon (G_MOUNT (volume));
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (!icon)
|
|
|
|
return NULL;
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 11:50:43 +00:00
|
|
|
pixbuf = get_pixbuf_from_gicon (icon, widget, icon_size, error);
|
|
|
|
|
|
|
|
g_object_unref (icon);
|
|
|
|
|
|
|
|
return pixbuf;
|
2008-06-10 00:39:35 +00:00
|
|
|
}
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2010-03-09 04:56:43 +00:00
|
|
|
GtkFileSystemVolume *
|
|
|
|
_gtk_file_system_volume_ref (GtkFileSystemVolume *volume)
|
|
|
|
{
|
|
|
|
if (IS_ROOT_VOLUME (volume))
|
|
|
|
return volume;
|
|
|
|
|
|
|
|
if (G_IS_MOUNT (volume) ||
|
|
|
|
G_IS_VOLUME (volume) ||
|
|
|
|
G_IS_DRIVE (volume))
|
|
|
|
g_object_ref (volume);
|
|
|
|
|
|
|
|
return volume;
|
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
void
|
2010-03-09 04:56:43 +00:00
|
|
|
_gtk_file_system_volume_unref (GtkFileSystemVolume *volume)
|
2008-06-10 00:39:35 +00:00
|
|
|
{
|
|
|
|
/* Root volume doesn't need to be freed */
|
|
|
|
if (IS_ROOT_VOLUME (volume))
|
|
|
|
return;
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (G_IS_MOUNT (volume) ||
|
|
|
|
G_IS_VOLUME (volume) ||
|
|
|
|
G_IS_DRIVE (volume))
|
|
|
|
g_object_unref (volume);
|
|
|
|
}
|
2004-02-19 07:43:39 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
/* GFileInfo helper functions */
|
|
|
|
GdkPixbuf *
|
2008-06-13 16:47:41 +00:00
|
|
|
_gtk_file_info_render_icon (GFileInfo *info,
|
2008-06-10 00:39:35 +00:00
|
|
|
GtkWidget *widget,
|
|
|
|
gint icon_size)
|
|
|
|
{
|
|
|
|
GIcon *icon;
|
|
|
|
GdkPixbuf *pixbuf = NULL;
|
2008-06-13 16:47:41 +00:00
|
|
|
const gchar *thumbnail_path;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
|
|
thumbnail_path = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
|
|
|
|
|
|
|
|
if (thumbnail_path)
|
|
|
|
pixbuf = gdk_pixbuf_new_from_file_at_size (thumbnail_path,
|
|
|
|
icon_size, icon_size,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (!pixbuf)
|
|
|
|
{
|
|
|
|
icon = g_file_info_get_icon (info);
|
|
|
|
|
|
|
|
if (icon)
|
|
|
|
pixbuf = get_pixbuf_from_gicon (icon, widget, icon_size, NULL);
|
2008-10-23 09:59:46 +00:00
|
|
|
|
|
|
|
if (!pixbuf)
|
|
|
|
{
|
|
|
|
/* Use general fallback for all files without icon */
|
|
|
|
icon = g_themed_icon_new ("text-x-generic");
|
|
|
|
pixbuf = get_pixbuf_from_gicon (icon, widget, icon_size, NULL);
|
|
|
|
g_object_unref (icon);
|
|
|
|
}
|
2004-02-19 07:43:39 +00:00
|
|
|
}
|
2004-02-23 20:24:01 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
return pixbuf;
|
|
|
|
}
|
2008-12-14 02:14:19 +00:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
_gtk_file_info_consider_as_directory (GFileInfo *info)
|
|
|
|
{
|
|
|
|
GFileType type = g_file_info_get_file_type (info);
|
|
|
|
|
|
|
|
return (type == G_FILE_TYPE_DIRECTORY ||
|
2008-12-15 16:12:09 +00:00
|
|
|
type == G_FILE_TYPE_MOUNTABLE ||
|
|
|
|
type == G_FILE_TYPE_SHORTCUT);
|
2008-12-14 02:14:19 +00:00
|
|
|
}
|
|
|
|
|