static GtkTreePath *
get_drop_path (NautilusTreeViewDragDest *dest,
               GtkTreePath *path)
{
    NautilusFile *file;
    GtkTreePath *ret;

    if (!path || !dest->details->have_drag_data) {
        return NULL;
    }

    ret = gtk_tree_path_copy (path);
    file = file_for_path (dest, ret);

    /* Go up the tree until we find a file that can accept a drop */
    while (file == NULL /* dummy row */ ||
            !nautilus_drag_can_accept_info (file,
                                            dest->details->drag_type,
                                            dest->details->drag_list)) {
        if (gtk_tree_path_get_depth (ret) == 1) {
            gtk_tree_path_free (ret);
            ret = NULL;
            break;
        } else {
            gtk_tree_path_up (ret);

            nautilus_file_unref (file);
            file = file_for_path (dest, ret);
        }
    }
    nautilus_file_unref (file);

    return ret;
}
static void
do_finalize (GObject *self)
{
    NautilusFileConflictDialogDetails *details =
        NAUTILUS_FILE_CONFLICT_DIALOG (self)->details;

    g_free (details->conflict_name);

    if (details->handle != NULL) {
        nautilus_file_list_cancel_call_when_ready (details->handle);
    }

    if (details->src_handler_id) {
        g_signal_handler_disconnect (details->source, details->src_handler_id);
        nautilus_file_monitor_remove (details->source, self);
    }

    if (details->dest_handler_id) {
        g_signal_handler_disconnect (details->destination, details->dest_handler_id);
        nautilus_file_monitor_remove (details->destination, self);
    }

    nautilus_file_unref (details->source);
    nautilus_file_unref (details->destination);
    nautilus_file_unref (details->dest_dir);

    G_OBJECT_CLASS (nautilus_file_conflict_dialog_parent_class)->finalize (self);
}
GHashTable *
nautilus_trashed_files_get_original_directories (GList *files,
        GList **unhandled_files)
{
    GHashTable *directories;
    NautilusFile *file, *original_file, *original_dir;
    GList *l, *m;

    directories = NULL;

    if (unhandled_files != NULL) {
        *unhandled_files = NULL;
    }

    for (l = files; l != NULL; l = l->next) {
        file = NAUTILUS_FILE (l->data);
        original_file = nautilus_file_get_trash_original_file (file);

        original_dir = NULL;
        if (original_file != NULL) {
            original_dir = nautilus_file_get_parent (original_file);
        }

        if (original_dir != NULL) {
            if (directories == NULL) {
                directories = g_hash_table_new_full (g_direct_hash, g_direct_equal,
                                                     (GDestroyNotify) nautilus_file_unref,
                                                     (GDestroyNotify) nautilus_file_list_unref);
            }
            nautilus_file_ref (original_dir);
            m = g_hash_table_lookup (directories, original_dir);
            if (m != NULL) {
                g_hash_table_steal (directories, original_dir);
                nautilus_file_unref (original_dir);
            }
            m = g_list_append (m, nautilus_file_ref (file));
            g_hash_table_insert (directories, original_dir, m);
        } else if (unhandled_files != NULL) {
            *unhandled_files = g_list_append (*unhandled_files, nautilus_file_ref (file));
        }

        if (original_file != NULL) {
            nautilus_file_unref (original_file);
        }

        if (original_dir != NULL) {
            nautilus_file_unref (original_dir);
        }
    }

    return directories;
}
Beispiel #4
0
static void
set_metadata_get_info_callback (GObject      *source_object,
                                GAsyncResult *res,
                                gpointer      callback_data)
{
    NautilusFile *file;
    GFileInfo *new_info;
    GError *error;

    file = callback_data;

    error = NULL;
    new_info = g_file_query_info_finish (G_FILE (source_object), res, &error);
    if (new_info != NULL)
    {
        if (nautilus_file_update_info (file, new_info))
        {
            nautilus_file_changed (file);
        }
        g_object_unref (new_info);
    }
    nautilus_file_unref (file);
    if (error)
    {
        g_error_free (error);
    }
}
Beispiel #5
0
static void
set_metadata_callback (GObject      *source_object,
                       GAsyncResult *result,
                       gpointer      callback_data)
{
    NautilusFile *file;
    GError *error;
    gboolean res;

    file = callback_data;

    error = NULL;
    res = g_file_set_attributes_finish (G_FILE (source_object),
                                        result,
                                        NULL,
                                        &error);

    if (res)
    {
        g_file_query_info_async (G_FILE (source_object),
                                 NAUTILUS_FILE_DEFAULT_ATTRIBUTES,
                                 0,
                                 G_PRIORITY_DEFAULT,
                                 NULL,
                                 set_metadata_get_info_callback, file);
    }
    else
    {
        nautilus_file_unref (file);
        g_error_free (error);
    }
}
void
nautilus_directory_remove_file (NautilusDirectory *directory, NautilusFile *file)
{
	GList *node;

	g_assert (NAUTILUS_IS_DIRECTORY (directory));
	g_assert (NAUTILUS_IS_FILE (file));
	g_assert (file->details->name != NULL);

	/* Find the list node in the hash table. */
	node = extract_from_hash_table (directory, file);
	g_assert (node != NULL);
	g_assert (node->data == file);

	/* Remove the item from the list. */
	directory->details->file_list = g_list_remove_link
		(directory->details->file_list, node);
	g_list_free_1 (node);

	nautilus_directory_remove_file_from_work_queue (directory, file);

	if (!file->details->unconfirmed) {
		directory->details->confirmed_file_count--;
	}

	/* Unref if we are monitoring. */
	if (nautilus_directory_is_file_list_monitored (directory)) {
		nautilus_file_unref (file);
	}
}
static gboolean
settings_search_is_recursive (NautilusQueryEditor *editor)
{
    NautilusQueryEditorPrivate *priv;
    NautilusFile *file;
    gboolean recursive;

    priv = nautilus_query_editor_get_instance_private (editor);

    if (!priv->location)
    {
        return TRUE;
    }

    file = nautilus_file_get (priv->location);

    if (nautilus_file_is_remote (file))
    {
        recursive = g_settings_get_enum (nautilus_preferences, "recursive-search") == NAUTILUS_SPEED_TRADEOFF_ALWAYS;
    }
    else
    {
        recursive = g_settings_get_enum (nautilus_preferences, "recursive-search") == NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY ||
                    g_settings_get_enum (nautilus_preferences, "recursive-search") == NAUTILUS_SPEED_TRADEOFF_ALWAYS;
    }

    nautilus_file_unref (file);

    return recursive;
}
static void
desktop_finalize (GObject *object)
{
	NautilusDesktopDirectoryFile *desktop_file;
	NautilusDesktopDirectory *desktop_directory;

	desktop_file = NAUTILUS_DESKTOP_DIRECTORY_FILE (object);
	desktop_directory = desktop_file->details->desktop_directory;

	/* Todo: ghash now safe? */
	eel_g_hash_table_safe_for_each
		(desktop_file->details->callbacks,
		 desktop_callback_remove_file_cover,
		 desktop_file->details->real_dir_file);
	
	if (g_hash_table_size (desktop_file->details->callbacks) != 0) {
		g_warning ("call_when_ready still pending when desktop virtual file is destroyed");
	}

	g_hash_table_destroy (desktop_file->details->callbacks);
	g_hash_table_destroy (desktop_file->details->monitors);

	nautilus_file_unref (desktop_file->details->real_dir_file);
	nautilus_directory_unref (NAUTILUS_DIRECTORY (desktop_directory));

	G_OBJECT_CLASS (nautilus_desktop_directory_file_parent_class)->finalize (object);
}
char *
nautilus_compute_title_for_location (GFile *location)
{
    NautilusFile *file;
    char *title;

    /* TODO-gio: This doesn't really work all that great if the
       info about the file isn't known atm... */

    if (nautilus_is_home_directory (location)) {
        return g_strdup (_("Home"));
    }

    title = NULL;
    if (location) {
        file = nautilus_file_get (location);
        title = nautilus_file_get_description (file);
        if (title == NULL) {
            title = nautilus_file_get_display_name (file);
        }
        nautilus_file_unref (file);
    }

    if (title == NULL) {
        title = g_file_get_basename (location);
    }

    return title;
}
/* This is a one-shot idle callback called from the main loop to call
   notify_file_changed() for a thumbnail. It frees the uri afterwards.
   We do this in an idle callback as I don't think nautilus_file_changed() is
   thread-safe. */
static gboolean
thumbnail_thread_notify_file_changed (gpointer image_uri)
{
	NautilusFile *file;

	gdk_threads_enter ();

	file = nautilus_file_get_by_uri ((char *) image_uri);
#ifdef DEBUG_THUMBNAILS
	g_message ("(Thumbnail Thread) Notifying file changed file:%p uri: %s\n", file, (char*) image_uri);
#endif

	if (file != NULL) {
		nautilus_file_set_is_thumbnailing (file, FALSE);
		nautilus_file_invalidate_attributes (file,
						     NAUTILUS_FILE_ATTRIBUTE_THUMBNAIL |
						     NAUTILUS_FILE_ATTRIBUTE_INFO);
		nautilus_file_unref (file);
	}
	g_free (image_uri);

	gdk_threads_leave ();

	return FALSE;
}
static void
desktop_callback_destroy (DesktopCallback *desktop_callback)
{
	g_assert (desktop_callback != NULL);
	g_assert (NAUTILUS_IS_DESKTOP_DIRECTORY_FILE (desktop_callback->desktop_file));

	nautilus_file_unref (NAUTILUS_FILE (desktop_callback->desktop_file));
	g_list_free (desktop_callback->non_ready_files);
	g_free (desktop_callback);
}
Beispiel #12
0
void
nautilus_directory_schedule_position_set (GList *position_setting_list)
{
	GList *p;
	const NautilusFileChangesQueuePosition *item;
	NautilusFile *file;
	char str[64];
	time_t now;

	time (&now);

	for (p = position_setting_list; p != NULL; p = p->next) {
		item = (NautilusFileChangesQueuePosition *) p->data;

		file = nautilus_file_get (item->location);
		
		if (item->set) {
			g_snprintf (str, sizeof (str), "%d,%d", item->point.x, item->point.y);
		} else {
			str[0] = 0;
		}
		nautilus_file_set_metadata
			(file,
			 NAUTILUS_METADATA_KEY_ICON_POSITION,
			 NULL,
			 str);

		if (item->set) {
			nautilus_file_set_time_metadata
				(file,
				 NAUTILUS_METADATA_KEY_ICON_POSITION_TIMESTAMP,
				 now);
		} else {
			nautilus_file_set_time_metadata
				(file,
				 NAUTILUS_METADATA_KEY_ICON_POSITION_TIMESTAMP,
				 UNDEFINED_TIME);
		}

		if (item->set) {
			g_snprintf (str, sizeof (str), "%d", item->screen);
		} else {
			str[0] = 0;
		}
		nautilus_file_set_metadata
			(file,
			 NAUTILUS_METADATA_KEY_SCREEN,
			 NULL,
			 str);
		
		nautilus_file_unref (file);
	}
}
static void
update_information_label (NautilusQueryEditor *editor)
{
    NautilusQueryEditorPrivate *priv;
    gboolean fts_sensitive = TRUE;

    priv = nautilus_query_editor_get_instance_private (editor);

    if (priv->location)
    {
        NautilusFile *file;
        gchar *label;
        gchar *uri;

        file = nautilus_file_get (priv->location);
        label = NULL;
        uri = g_file_get_uri (priv->location);

        if (nautilus_file_is_other_locations (file))
        {
            label = _("Searching locations only");
            fts_sensitive = FALSE;
        }
        else if (g_str_has_prefix (uri, "computer://"))
        {
            label = _("Searching devices only");
        }
        else if (g_str_has_prefix (uri, "network://"))
        {
            label = _("Searching network locations only");
            fts_sensitive = FALSE;
        }
        else if (nautilus_file_is_remote (file) &&
                 !settings_search_is_recursive (editor))
        {
            label = _("Remote location — only searching the current folder");
            fts_sensitive = FALSE;
        }
        else if (!settings_search_is_recursive (editor))
        {
            label = _("Only searching the current folder");
        }

        nautilus_search_popover_set_fts_sensitive (NAUTILUS_SEARCH_POPOVER (priv->popover),
                                                   fts_sensitive);

        gtk_widget_set_visible (priv->label, label != NULL);
        gtk_label_set_label (GTK_LABEL (priv->label), label);

        g_free (uri);
        nautilus_file_unref (file);
    }
}
Beispiel #14
0
static void
fm_ditem_page_exec_drag_data_received (GtkWidget *widget, GdkDragContext *context,
				       int x, int y,
				       GtkSelectionData *selection_data,
				       guint info, guint time,
				       GtkEntry *entry)
{
	char **uris;
	gboolean exactly_one;
	NautilusFile *file;
	GnomeDesktopItem *item;
	char *uri;
	const char *exec;
	
	uris = g_strsplit (selection_data->data, "\r\n", 0);
        exactly_one = uris[0] != NULL && (uris[1] == NULL || uris[1][0] == '\0');

	if (!exactly_one) {
		g_strfreev (uris);
		return;
	}

	file = nautilus_file_get_by_uri (uris[0]);

	g_return_if_fail (file != NULL);
	
	uri = nautilus_file_get_uri (file);
	if (nautilus_file_is_mime_type (file, "application/x-desktop")) {
		item = gnome_desktop_item_new_from_uri (uri,
							GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS,
							NULL);
		if (item != NULL &&
		    gnome_desktop_item_get_entry_type (item) == GNOME_DESKTOP_ITEM_TYPE_APPLICATION) {
			
			exec = gnome_desktop_item_get_string (item, GNOME_DESKTOP_ITEM_EXEC);
			gtk_entry_set_text (entry,
					    exec?exec:"");
			gnome_desktop_item_unref (item);
			
			gtk_widget_grab_focus (GTK_WIDGET (entry));
		}
	} else {
		gtk_entry_set_text (entry,
				    uri?uri:"");
	}
	
	g_free (uri);
	
	nautilus_file_unref (file);
	
	g_strfreev (uris);
}
static NautilusBookmark *
new_bookmark_from_uri (const char *uri, const char *label)
{
	NautilusBookmark *new_bookmark;
	NautilusFile *file;
	char *name;
	GIcon *icon;
	gboolean has_label;
	GFile *location;
	gboolean native;

	location = NULL;
	if (uri) {
		location = g_file_new_for_uri (uri);
	}
	
	has_label = FALSE;
	if (!label) { 
		name = nautilus_compute_title_for_location (location);
	} else {
		name = g_strdup (label);
		has_label = TRUE;
	}

	new_bookmark = NULL;
	
	if (uri) {
		native = g_file_is_native (location);
		file = nautilus_file_get (location);

		icon = NULL;
		if (nautilus_file_check_if_ready (file,
						  NAUTILUS_FILE_ATTRIBUTES_FOR_ICON)) {
			icon = nautilus_file_get_gicon (file, 0);
		}
		nautilus_file_unref (file);
		
		if (icon == NULL) {
			icon = native ? g_themed_icon_new (NAUTILUS_ICON_FOLDER) :
				g_themed_icon_new (NAUTILUS_ICON_FOLDER_REMOTE);
		}

		new_bookmark = nautilus_bookmark_new (location, name, has_label, icon);

		g_object_unref (icon);

	}
	g_free (name);
	g_object_unref (location);
	return new_bookmark;
}
static void
fm_ditem_page_exec_drag_data_received (GtkWidget *widget, GdkDragContext *context,
				       int x, int y,
				       GtkSelectionData *selection_data,
				       guint info, guint time,
				       GtkEntry *entry)
{
	char **uris;
	gboolean exactly_one;
	NautilusFile *file;
	GKeyFile *key_file;
	char *uri, *type, *exec;
	
	uris = g_strsplit (selection_data->data, "\r\n", 0);
        exactly_one = uris[0] != NULL && (uris[1] == NULL || uris[1][0] == '\0');

	if (!exactly_one) {
		g_strfreev (uris);
		return;
	}

	file = nautilus_file_get_by_uri (uris[0]);

	g_return_if_fail (file != NULL);
	
	uri = nautilus_file_get_uri (file);
	if (nautilus_file_is_mime_type (file, "application/x-desktop")) {
		key_file = _g_key_file_new_from_uri (uri, G_KEY_FILE_NONE, NULL);
		if (key_file != NULL) {
			type = g_key_file_get_string (key_file, MAIN_GROUP, "Type", NULL);
			if (type != NULL && strcmp (type, "Application") == 0) {
				exec = g_key_file_get_string (key_file, MAIN_GROUP, "Exec", NULL);
				if (exec != NULL) {
					g_free (uri);
					uri = exec;
				}
			}
			g_free (type);
			g_key_file_free (key_file);
		}
	} 
	gtk_entry_set_text (entry,
			    uri?uri:"");
	gtk_widget_grab_focus (GTK_WIDGET (entry));
	
	g_free (uri);
	
	nautilus_file_unref (file);
	
	g_strfreev (uris);
}
Beispiel #17
0
gboolean
nautilus_directory_is_remote (NautilusDirectory *directory)
{
        NautilusFile *file;
        gboolean is_remote;

        g_assert (NAUTILUS_IS_DIRECTORY (directory));

        file = nautilus_directory_get_corresponding_file (directory);
        is_remote = nautilus_file_is_remote (file);
        nautilus_file_unref (file);

        return is_remote;
}
static void
search_engine_hits_added (NautilusSearchEngine *engine, GList *hits, 
			  NautilusSearchDirectory *search)
{
	GList *hit_list;
	GList *file_list;
	NautilusFile *file;
	SearchMonitor *monitor;
	GList *monitor_list;

	file_list = NULL;

	for (hit_list = hits; hit_list != NULL; hit_list = hit_list->next) {
		NautilusSearchHit *hit = hit_list->data;
		const char *uri;

		uri = nautilus_search_hit_get_uri (hit);
		if (g_str_has_suffix (uri, NAUTILUS_SAVED_SEARCH_EXTENSION)) {
			/* Never return saved searches themselves as hits */
			continue;
		}

		nautilus_search_hit_compute_scores (hit, search->details->query);

		file = nautilus_file_get_by_uri (uri);
		nautilus_file_set_search_relevance (file, nautilus_search_hit_get_relevance (hit));

		for (monitor_list = search->details->monitor_list; monitor_list; monitor_list = monitor_list->next) {
			monitor = monitor_list->data;

			/* Add monitors */
			nautilus_file_monitor_add (file, monitor, monitor->monitor_attributes);
		}

		g_signal_connect (file, "changed", G_CALLBACK (file_changed), search),

		file_list = g_list_prepend (file_list, file);
		g_hash_table_add (search->details->files_hash, file);
	}
	
	search->details->files = g_list_concat (search->details->files, file_list);

	nautilus_directory_emit_files_added (NAUTILUS_DIRECTORY (search), file_list);

	file = nautilus_directory_get_corresponding_file (NAUTILUS_DIRECTORY (search));
	nautilus_file_emit_changed (file);
	nautilus_file_unref (file);

        search_directory_add_pending_files_callbacks (search);
}
static void
each_path_get_data_binder (NautilusDragEachSelectedItemDataGet data_get,
			   gpointer context,
			   gpointer data)
{
	DragDataGetInfo *info;
	GList *l;
	NautilusFile *file;
	GtkTreeRowReference *row;
	GtkTreePath *path;
	char *uri;
	GdkRectangle cell_area;
	GtkTreeViewColumn *column;

	info = context;

	g_return_if_fail (info->model->details->drag_view);

	column = gtk_tree_view_get_column (info->model->details->drag_view, 0);

	for (l = info->path_list; l != NULL; l = l->next) {
		row = l->data;

		path = gtk_tree_row_reference_get_path (row);
		file = nautilus_list_model_file_for_path (info->model, path);
		if (file) {
			gtk_tree_view_get_cell_area
				(info->model->details->drag_view,
				 path, 
				 column,
				 &cell_area);
				
			uri = nautilus_file_get_uri (file);
				
			(*data_get) (uri, 
				     0,
				     cell_area.y - info->model->details->drag_begin_y,
				     cell_area.width, cell_area.height, 
				     data);
				
			g_free (uri);
			
			nautilus_file_unref (file);
		}
		
		gtk_tree_path_free (path);
	}
}
Beispiel #20
0
static void
file_entry_free (FileEntry *file_entry)
{
	nautilus_file_unref (file_entry->file);
	if (file_entry->reverse_map) {
		g_hash_table_destroy (file_entry->reverse_map);
		file_entry->reverse_map = NULL;
	}
	if (file_entry->subdirectory != NULL) {
		nautilus_directory_unref (file_entry->subdirectory);
	}
	if (file_entry->files != NULL) {
		g_sequence_free (file_entry->files);
	}
	g_free (file_entry);
}
Beispiel #21
0
void
nautilus_directory_notify_files_removed (GList *files)
{
	GHashTable *changed_lists;
	GList *p;
	NautilusDirectory *directory;
	GHashTable *parent_directories;
	NautilusFile *file;
	GFile *location;

	/* Make a list of changed files in each directory. */
	changed_lists = g_hash_table_new (NULL, NULL);

	/* Make a list of parent directories that will need their counts updated. */
	parent_directories = g_hash_table_new (NULL, NULL);

	/* Go through all the notifications. */
	for (p = files; p != NULL; p = p->next) {
		location = p->data;

		/* Update file count for parent directory if anyone might care. */
		directory = get_parent_directory_if_exists (location);
		if (directory != NULL) {
			collect_parent_directories (parent_directories, directory);
			nautilus_directory_unref (directory);
		}

		/* Find the file. */
		file = nautilus_file_get_existing (location);
		if (file != NULL && !nautilus_file_rename_in_progress (file)) {
			/* Mark it gone and prepare to send the changed signal. */
			nautilus_file_mark_gone (file);
			hash_table_list_prepend (changed_lists,
						 file->details->directory,
						 nautilus_file_ref (file));
		}
		nautilus_file_unref (file);
	}

	/* Now send out the changed signals. */
	g_hash_table_foreach (changed_lists, call_files_changed_unref_free_list, NULL);
	g_hash_table_destroy (changed_lists);

	/* Invalidate count for each parent directory. */
	g_hash_table_foreach (parent_directories, invalidate_count_and_unref, NULL);
	g_hash_table_destroy (parent_directories);
}
Beispiel #22
0
/* "." for the directory-as-file, otherwise the filename */
NautilusFile *
nautilus_directory_find_file_by_internal_filename (NautilusDirectory *directory,
						   const char *internal_filename)
{
	NautilusFile *result;

	if (eel_strcmp (internal_filename, ".") == 0) {
		result = nautilus_directory_get_existing_corresponding_file (directory);
		if (result != NULL) {
			nautilus_file_unref (result);
		}
	} else {
		result = nautilus_directory_find_file_by_name (directory, internal_filename);
	}

	return result;
}
/* This is used to open compressed files that are not supported by gnome-autoar
 * in another application
 */
void
handle_unsupported_compressed_file (GtkWindow *parent_window,
                                    GFile     *compressed_file)
{
    HandleUnsupportedFileData *data;

    data = g_slice_new0 (HandleUnsupportedFileData);
    data->parent_window = parent_window;
    data->file = nautilus_file_get (compressed_file);

    invoke_main_context_sync (NULL, open_file_in_application, data);

    nautilus_file_unref (data->file);
    g_slice_free (HandleUnsupportedFileData, data);

    return;
}
Beispiel #24
0
static gboolean
source_is_deletable (GFile *file)
{
	NautilusFile *naut_file;
	gboolean ret;

	/* if there's no a cached NautilusFile, it returns NULL */
	naut_file = nautilus_file_get_existing (file);
	if (naut_file == NULL) {
		return FALSE;
	}
	
	ret = nautilus_file_can_delete (naut_file);
	nautilus_file_unref (naut_file);

	return ret;
}
static void
free_xdg_dir_cache (void)
{
    int i;

    if (cached_xdg_dirs != NULL) {
        for (i = 0; cached_xdg_dirs[i].type != NULL; i++) {
            if (cached_xdg_dirs[i].file != NULL) {
                nautilus_file_monitor_remove (cached_xdg_dirs[i].file,
                                              &cached_xdg_dirs[i]);
                g_signal_handlers_disconnect_by_func (cached_xdg_dirs[i].file,
                                                      G_CALLBACK (xdg_dir_changed),
                                                      &cached_xdg_dirs[i]);
                nautilus_file_unref (cached_xdg_dirs[i].file);
            }
            g_free (cached_xdg_dirs[i].type);
            g_free (cached_xdg_dirs[i].path);
        }
        g_free (cached_xdg_dirs);
    }
}
static char *
get_drop_target_uri_for_path (NautilusTreeViewDragDest *dest,
                              GtkTreePath *path)
{
    NautilusFile *file;
    char *target = NULL;
    gboolean can;

    file = file_for_path (dest, path);
    if (file == NULL) {
        return NULL;
    }
    can = nautilus_drag_can_accept_info (file,
                                         dest->details->drag_type,
                                         dest->details->drag_list);
    if (can) {
        target = nautilus_file_get_drop_target_uri (file);
    }
    nautilus_file_unref (file);

    return target;
}
char *
nautilus_compute_title_for_location (GFile *location)
{
	NautilusFile *file;
	char *title;

	/* TODO-gio: This doesn't really work all that great if the
	   info about the file isn't known atm... */
	
	title = NULL;
	if (location) {
		file = nautilus_file_get (location);
		title = nautilus_file_get_display_name (file);
		nautilus_file_unref (file);
	}

	if (title == NULL) {
		title = g_strdup ("");
	}
	
	return title;
}
static void
search_force_reload (NautilusDirectory *directory)
{
	NautilusSearchDirectory *search;
        NautilusFile *file;

	search = NAUTILUS_SEARCH_DIRECTORY (directory);

	if (!search->details->query) {
		return;
	}
	
	search->details->search_ready_and_valid = FALSE;

	/* Remove file monitors */
	reset_file_list (search);
	stop_search (search);

	file = nautilus_directory_get_corresponding_file (directory);
	nautilus_file_invalidate_all_attributes (file);
	nautilus_file_unref (file);
}
Beispiel #29
0
static char *
vfs_file_get_where_string (NautilusFile *file)
{
    GFile *activation_location;
    NautilusFile *location;
    char *where_string;

    if (!nautilus_file_is_in_recent (file))
    {
        location = nautilus_file_ref (file);
    }
    else
    {
        activation_location = nautilus_file_get_activation_location (file);
        location = nautilus_file_get (activation_location);
        g_object_unref (activation_location);
    }

    where_string = nautilus_file_get_parent_uri_for_display (location);

    nautilus_file_unref (location);
    return where_string;
}
void
nautilus_file_queue_remove (NautilusFileQueue *queue,
			    NautilusFile *file)
{
	GList *link;

	link = g_hash_table_lookup (queue->item_to_link_map, file);

	if (link == NULL) {
		/* It's not on the queue */
		return;
	}

	if (link == queue->tail) {
		/* Need to special-case removing the tail. */
		queue->tail = queue->tail->prev;
	}

	queue->head =  g_list_remove_link (queue->head, link);
	g_list_free (link);
	g_hash_table_remove (queue->item_to_link_map, file);

	nautilus_file_unref (file);
}