The Gnome Chemistry Utils  0.14.0
testgcrcrystalviewer.c
Go to the documentation of this file.
1 /*
2  * Gnome Chemisty Utils
3  * tests/testgcucrystalviewer.c
4  *
5  * Copyright (C) 2008-2010 Jean Bréfort <jean.brefort@normalesup.org>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
20  * USA
21  */
22 
23 #include <gcr/gcrcrystalviewer.h>
24 #include <gcu/chemistry.h>
25 #include <glib.h>
26 #include <gtk/gtk.h>
27 #include <stdio.h>
28 #include <libxml/parser.h>
29 
43 int main (int argc, char *argv[])
44 {
45  GtkWidget *window;
46  GtkWidget *viewer;
47  const char* filename;
48  xmlDocPtr xml;
49  gtk_init (&argc, &argv);
50 
51  gcu_element_load_databases ("radii", NULL);
52 
53  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
54  gtk_window_set_title (GTK_WINDOW (window), "GcuCrystalViewer test");
55  g_signal_connect (G_OBJECT (window), "destroy",
56  G_CALLBACK (gtk_main_quit),
57  NULL);
58 
59  if (argc >= 2)
60  filename = argv[1];
61  else
62  filename = SRCDIR"/nickel.gcrystal";
63  xml = xmlParseFile (filename);
64 
65  viewer = gcr_crystal_viewer_new (xml->children);
66  gtk_container_add (GTK_CONTAINER (window), viewer);
67  gtk_widget_show_all (window);
68 
69  gtk_main ();
70 
71  return 0;
72 }