Nautilus – The GNOME file manager

Alexander Larsson, Red Hat Inc.

FOSDEM 2005

Nautilus – What is it

File manager for the GNOME desktop

Original vision – Universal Viewer

Shell that displays a location

Navigation

Views

Modified vision

Focus on managing files

Not an application, part of the desktop

Be the filesystem

Easy to use

History – the Eazel days

August 1999 – Eazel founded

December 1999 – Initial import into GNOME cvs

March 2001 – Nautilus 1.0 released

April 2001 – Gnome 1.4 (with Nautilus) released

April 2001 – My first patch to Nautilus commited

May 2001 – Nautilus 1.0.3 released

May 2001 – Eazel shuts down

History – Post Eazel

September 2001 – Red Hat Linux 7.2 (with Nautilus) work

February 2002 – I join Darin as maintainer

April 2002 – Last commit from Darin

June 2002 – Nautilus 2.0 released

June 2002 – Dave Camp joins the maintainer team

September 2003 – spatial branch lands

November 2004 – bonobo-slay branch lands

January 2005 – Martin Wehner joins the maintainer team

The Nautilus I/O Model – An overview

Single threaded UI

No blocking I/O calls on main thread

All I/O asynchronous

I/O done using Gnome VFS

Nautilus Application

NautilusFile abstraction

Gnome VFS async operations

Gnome VFS methods (file/ftp/smb)

Gnome VFS

File sytem abstraction

Uses URIs instead of filenames

file:///tmp/file.txt

smb://server/share/file.txt

sftp://server/tmp/file.txt

shared library modules implements a URI method

Methods implement a posix-like set of operations:

open, read, write, close, seek

get_file_info, set_file_info

open_directory, read_directory, close_directory

etc

Method interface

GnomeVFSResult open (GnomeVFSMethod *method,

GnomeVFSMethodHandle **method_handle_return,

GnomeVFSURI *uri,

GnomeVFSOpenMode mode,

GnomeVFSContext *context);

GnomeVFSResult read (GnomeVFSMethod *method,

GnomeVFSMethodHandle *method_handle,

gpointer buffer,

GnomeVFSFileSize num_bytes,

GnomeVFSFileSize *bytes_read_return,

GnomeVFSContext *context);

GnomeVFSResult close (GnomeVFSMethod *method,

GnomeVFSMethodHandle *method_handle,

GnomeVFSContext *context);

async Gnome VFS operations

Built on top of the normal Gnome VFS operations

Returns immediately, calls a callback when the I/O is finished

typedef void (* GnomeVFSAsyncOpenCallback) (GnomeVFSAsyncHandle *handle,

GnomeVFSResult result,

gpointer callback_data);

void gnome_vfs_async_open (GnomeVFSAsyncHandle **handle_return,

const gchar *text_uri,

GnomeVFSOpenMode open_mode,

int priority,

GnomeVFSAsyncOpenCallback callback,

gpointer callback_data);

async Gnome VFS operations - cont

Operations queue job object in a priority queue

Pool of worker thread executes the jobs

Uses glib mainloop to report result to main thread

Supports cancellation of jobs

NautilusFile

Easy way to do async I/O

Get NautilusFile for a URI, ask it for information

Initially you get “I don't know” results

Register monitor to get told when the file changes

Or call_when_ready for one-off uses

NautilusFile as cache

Reuses the results from I/O operations

This is a form of cache

Invalidation of attributes when you change a file

NautilusDirectory for cache of directories

Extending Nautilus

Anyone can send patches

External 3rd party extensions

Why external extensions?

Let people experiment with cool stuff

Features that not everyone needs/wants

Avoid dependencies in the core

Extending Nautilus

The original approach

File manager as a universal viewer

view components

Why views are a bad model for extension

Replaces the normal views

Looks and works differently

Can't extend the existing views

Bonobo

Heavy

Complicated

New Approach

fine grained extension points

shared library plugins

public interface exposing Nautilus internals

libnautilus-extension plugins

extensions are GTypeModules with some functions

nautilus_module_initialize, nautilus_module_shutdown, and nautilus_module_list_types.

links to libnautilus-extension

contains GTypes that implement provider interfaces

Property objects

Runs in the same process as Nautilus

May not call blocking I/O functions

NautilusFileInfo

The way modules do I/O

Represents a file Nautilus is interested in

the public interface to NautilusFile

Lives as long as Nautilus is interested in the file

Extensible (using NautilusInfoProvider)

NautilusMenuProvider

Adds menu items to file and background context menus

Adds toolbar items

Returns NautilusMenuItem objects

Properties: name, label, tip, icon, sensitive, priority

Signal: activate

NautilusPropertyPageProvider

Adds pages to the file property dialog

Returns NautilusPropertyPage objects

Properties: name, label (widget), page (widget)

NautilusColumnProvider

Adds “columns” to Nautilus.

Columns are available as icon view details and List View columns

Returns a list of NautilusColumn objects

Properties: name, attribute, label, description, xalign

Information comes from NautilusInfoProvider

NautilusInfoProvider

Lets extension add information about files

string attributes - displayed in columns

emblems

Works with the nautilus async I/O system

gets called when the information it provides is not up-to-date

NautilusInfoProvider details

Called when Nautilus needs information about a file:

NautilusOperationResult

(*update_file_info) (NautilusInfoProvider *provider,

NautilusFileInfo *file,

GClosure *update_complete,

NautilusOperationHandle **handle);

Add information using nautilus_file_info_add_emblem or nautilus_file_info_add_string_attribute

If information can be added without blocking, return NAUTILUS_OPERATION_COMPLETE

Otherwise, schedule I/O and return NAUTILUS_OPERATION_IN_PROGRESS and a NautilusOperationHandle

When done, call the update_complete closure

NautilusInfoProvider details

If Nautilus decides it doesn't need the results anymore it calls

void (*cancel_update) (NautilusInfoProvider *provider,

NautilusOperationHandle *handle);

Cancel outstanding operations

Don't call update_complete

NautilusInfoProvider details

Invalidate info if file changes

nautilus_file_info_invalidate_extension_info

Expensive to compute information

Nautilus throws away information on changes

Cache on NautilusFileInfo object

use weak references

Future Ideas on Extensions

Sidebars

File previews

mp3

animations

Better column handling

New directory views

Tree view

Search view

Need feedback

References

docs directory in Nautilus sources

http://primates.ximian.com/~dave/extending-nautilus/NautilusExtensions.html

Example code

nautilus-vcs

file-roller

nautilus-cd-burner

nautilus-list@gnome.org

#nautilus on GIMPnet

Questions?

2005-02-21T16:20:42