Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

gchem3d-viewer.c

Go to the documentation of this file.
00001 /* 
00002  * Gnome Chemisty Utils
00003  * gchem3d-viewer.c
00004  *
00005  * Copyright (C) 2005
00006  *
00007  * Developed by Jean Bréfort <jean.brefort@normalesup.org>
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Lesser General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00022  * USA
00023  */
00024 
00025 #include "config.h"
00026 #include <gcu/gtkchem3dviewer.h>
00027 #include <glib.h>
00028 #include <gtk/gtk.h>
00029 #include <stdio.h>
00030 #include <libgnomevfs/gnome-vfs.h>
00031 
00035 int main(int argc, char *argv[])
00036 {
00037         GtkWidget *window;
00038         GtkWidget *viewer;
00039         GnomeVFSURI *uri, *auri;
00040         char *path, *dir;
00041 
00042         gtk_init (&argc, &argv);
00043         if (!gnome_vfs_init ()) {
00044                 printf ("Could not initialize GnomeVFS\n");
00045                 return 1;
00046         }
00047 
00048         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
00049         gtk_window_set_title(GTK_WINDOW(window), "GtkChem3dViewer");
00050         g_signal_connect(GTK_OBJECT(window), "destroy",
00051                  GTK_SIGNAL_FUNC(gtk_main_quit),
00052                  NULL);
00053 
00054         if (argc >= 2) {
00055                 path = g_get_current_dir ();
00056                 dir = g_strconcat (path, "/", NULL);
00057                 g_free (path);
00058                 uri = gnome_vfs_uri_new (dir);
00059                 auri = gnome_vfs_uri_resolve_relative (uri, argv[1]);
00060                 path = gnome_vfs_uri_to_string (auri, GNOME_VFS_URI_HIDE_NONE);
00061                 viewer = gtk_chem3d_viewer_new(path);
00062                 g_free (path);
00063                 gnome_vfs_uri_unref (auri);
00064                 gnome_vfs_uri_unref (uri);
00065                 g_free (dir);
00066                 gtk_container_add(GTK_CONTAINER(window), viewer);
00067                 gtk_widget_show_all(window);
00068         
00069                 gtk_main();
00070         }
00071         
00072         return(0);
00073 }

Generated on Sat Aug 13 13:43:47 2005 for The Gnome Chemistry Utils by  doxygen 1.4.3