e2164e05ec166037ad5b534e48fabaab47532b37
[fw/altos] / aoview / aoview_main.c
1 /*
2  * Copyright © 2009 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 #include "aoview.h"
19
20 static void usage(void) {
21         printf("aoview [--device|-d device_file]");
22         exit(1);
23 }
24
25 static void destroy_event(GtkWidget *widget, gpointer data)
26 {
27         gtk_main_quit();
28 }
29
30 int main(int argc, char **argv)
31 {
32         GladeXML *xml = NULL;
33         GtkWidget *mainwindow;
34         char *device = NULL;
35         GtkAboutDialog *about_dialog;
36
37         static struct option long_options[] = {
38                 { "device", 1, 0, 'd'},
39                 { 0, 0, 0, 0 }
40         };
41         for (;;) {
42                 int c, temp;
43
44                 c = getopt_long_only(argc, argv, "d:", long_options, &temp);
45                 if (c == -1)
46                         break;
47
48                 switch (c) {
49                 case 'd':
50                         device = optarg;
51                         break;
52                 default:
53                         usage();
54                 }
55         }
56
57         gtk_init(&argc, &argv);
58         glade_init();
59
60         xml = glade_xml_new("aoview.glade", NULL, NULL);
61         /* connect the signals in the interface */
62         glade_xml_signal_autoconnect(xml);
63
64         /* Hook up the close button. */
65         mainwindow = glade_xml_get_widget(xml, "aoview");
66         assert(mainwindow);
67
68         g_signal_connect (G_OBJECT(mainwindow), "destroy",
69             G_CALLBACK(destroy_event), NULL);
70
71         about_dialog = GTK_ABOUT_DIALOG(glade_xml_get_widget(xml, "about_dialog"));
72         assert(about_dialog);
73         gtk_about_dialog_set_version(about_dialog, AOVIEW_VERSION);
74
75         aoview_dev_dialog_init(xml);
76
77         aoview_state_init(xml);
78
79         aoview_log_init(xml);
80
81         aoview_table_init(xml);
82
83         gtk_main();
84
85         return 0;
86 }