Commit d2628308 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Add nautilus_file_get_activation_location.

2008-01-18  Alexander Larsson  <alexl@redhat.com>

        * libnautilus-private/nautilus-file.[ch]:
        Add nautilus_file_get_activation_location.
	
        * libnautilus-private/nautilus-directory-async.c:
	Get mounts from mountable files too.
	


svn path=/trunk/; revision=13619
parent 4edc08f2
2008-01-18 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-file.[ch]:
Add nautilus_file_get_activation_location.
* libnautilus-private/nautilus-directory-async.c:
Get mounts from mountable files too.
2008-01-18 Alexander Larsson <alexl@redhat.com>
* src/nautilus-x-content-bar.c:
......
......@@ -1730,9 +1730,21 @@ wants_thumbnail (const Request *request)
static gboolean
lacks_mount (NautilusFile *file)
{
return (file->details->is_mountpoint ||
file->details->type == G_FILE_TYPE_MOUNTABLE) &&
!file->details->mount_is_up_to_date;
return (!file->details->mount_is_up_to_date &&
(
/* Unix mountpoint, could be a GMount */
file->details->is_mountpoint ||
/* The toplevel directory of something */
(file->details->type == G_FILE_TYPE_DIRECTORY &&
nautilus_file_is_self_owned (file)) ||
/* Mountable with a target_uri, could be a mountpoint */
(file->details->type == G_FILE_TYPE_MOUNTABLE &&
file->details->activation_location != NULL)
)
);
}
static gboolean
......@@ -3883,38 +3895,27 @@ mount_state_free (MountState *state)
}
static void
find_enclosing_mount_callback (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
got_mount (MountState *state, GMount *mount)
{
GMount *mount;
NautilusDirectory *directory;
MountState *state;
NautilusFile *file;
state = user_data;
if (state->directory == NULL) {
/* Operation was cancelled. Bail out */
mount_state_free (state);
return;
}
directory = nautilus_directory_ref (state->directory);
mount = g_file_find_enclosing_mount_finish (G_FILE (source_object),
res, NULL);
directory = nautilus_directory_ref (state->directory);
state->directory->details->mount_state = NULL;
async_job_end (state->directory, "mount");
file = nautilus_file_ref (state->file);
file->details->mount_is_up_to_date = TRUE;
if (file->details->mount) {
g_object_unref (file->details->mount);
file->details->mount = NULL;
}
file->details->mount_is_up_to_date = TRUE;
if (mount) {
file->details->mount = g_object_ref (mount);
}
file->details->mount = mount;
nautilus_directory_async_state_changed (directory);
nautilus_file_changed (file);
......@@ -3927,6 +3928,73 @@ find_enclosing_mount_callback (GObject *source_object,
}
static void
find_enclosing_mount_callback (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GMount *mount;
MountState *state;
GFile *location, *root;
state = user_data;
if (state->directory == NULL) {
/* Operation was cancelled. Bail out */
mount_state_free (state);
return;
}
mount = g_file_find_enclosing_mount_finish (G_FILE (source_object),
res, NULL);
if (mount) {
root = g_mount_get_root (mount);
location = nautilus_file_get_location (state->file);
if (!g_file_equal (location, root)) {
g_object_unref (mount);
mount = NULL;
}
g_object_unref (root);
g_object_unref (location);
}
got_mount (state, mount);
if (mount) {
g_object_unref (mount);
}
}
static GMount *
get_mount_at (GFile *target)
{
GVolumeMonitor *monitor;
GFile *root;
GList *mounts, *l;
GMount *found;
monitor = g_volume_monitor_get ();
mounts = g_volume_monitor_get_mounts (monitor);
found = NULL;
for (l = mounts; l != NULL; l = l->next) {
root = g_mount_get_root (l->data);
if (g_file_equal (target, root)) {
found = g_object_ref (l->data);
break;
}
g_object_unref (root);
}
eel_g_object_list_free (mounts);
g_object_unref (monitor);
return found;
}
static void
mount_start (NautilusDirectory *directory,
NautilusFile *file,
......@@ -3959,12 +4027,30 @@ mount_start (NautilusDirectory *directory,
location = nautilus_file_get_location (file);
directory->details->mount_state = state;
g_file_find_enclosing_mount_async (location,
G_PRIORITY_DEFAULT,
state->cancellable,
find_enclosing_mount_callback,
state);
if (file->details->type == G_FILE_TYPE_MOUNTABLE) {
GFile *target;
GMount *mount;
mount = NULL;
target = nautilus_file_get_activation_location (file);
if (target != NULL) {
mount = get_mount_at (target);
g_object_unref (target);
}
got_mount (state, mount);
if (mount) {
g_object_unref (mount);
}
} else {
g_file_find_enclosing_mount_async (location,
G_PRIORITY_DEFAULT,
state->cancellable,
find_enclosing_mount_callback,
state);
}
g_object_unref (location);
}
......
......@@ -2996,6 +2996,18 @@ nautilus_file_get_activation_uri (NautilusFile *file)
return nautilus_file_get_uri (file);
}
GFile *
nautilus_file_get_activation_location (NautilusFile *file)
{
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
if (file->details->activation_location != NULL) {
return g_object_ref (file->details->activation_location);
}
return nautilus_file_get_location (file);
}
char *
nautilus_file_get_drop_target_uri (NautilusFile *file)
......
......@@ -369,6 +369,7 @@ GList *nautilus_file_list_filter_hidden_and_backup (GList
*/
gboolean nautilus_file_has_activation_uri (NautilusFile *file);
char * nautilus_file_get_activation_uri (NautilusFile *file);
GFile * nautilus_file_get_activation_location (NautilusFile *file);
char * nautilus_file_get_drop_target_uri (NautilusFile *file);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment