8.2 Initializing and Shutting Down GnomeVFS


8.2 Initializing and Shutting Down GnomeVFS

To use GnomeVFS, include libgnomevfs/gnome-vfs.h in your source code. Compile and link with the flags you get with pkg-config (package name gnome-vfs-2.0 ).

The gnome_program_init() function initializes GnomeVFS for you, so if you're writing a GNOME application, you need only worry about shutting down the system. However, if you don't have a GNOME program, call

 gnome_vfs_init() 

to set up GnomeVFS. This call returns FALSE when it cannot get GnomeVFS working.

At the end of your program, you should shut down the GnomeVFS subsystem to force all pending cache operations and free the resources:

 gnome_vfs_shutdown() 

For example, a GTK+ (non-GNOME) application that uses GnomeVFS might have this structure:

 #include <libgnomevfs/gnome-vfs.h> #include <gtk/gtk.h> int main(int argc, char **argv) {   << miscellaneous initialization >>   if (!gnome_vfs_init())   {      g_error("could not initialize GnomeVFS");      << ... >>   }   << build application >>   gtk_main();   << miscellaneous shutdown >>   gnome_vfs_shutdown();   return(0); } 

If some other library is supposed to initialize GnomeVFS, you can check the status of GnomeVFS with

 if (!gnome_vfs_initialized()) {   if (!gnome_vfs_init())   {      g_error("could not initialize GnomeVFS");      << ... >>   } } 



The Official GNOME 2 Developers Guide
The Official GNOME 2 Developers Guide
ISBN: 1593270305
EAN: 2147483647
Year: 2004
Pages: 108

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net